Compare commits
7 Commits
5388cba6e4
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 076987a4d5 | |||
| e7de69c0ac | |||
| 9cedd88405 | |||
| 3a7c2ba9d3 | |||
| 2d31804982 | |||
| 27bfa47b42 | |||
| a83081d482 |
@@ -4,12 +4,12 @@ from datetime import datetime
|
|||||||
|
|
||||||
|
|
||||||
def minify(content: str, maxlength: int, strip: Optional[str] = ' ', newlines: str = ' '):
|
def minify(content: str, maxlength: int, strip: Optional[str] = ' ', newlines: str = ' '):
|
||||||
content.replace('\n', newlines)
|
content = content.replace('\n', newlines)
|
||||||
if strip:
|
if strip:
|
||||||
content = content.strip(strip)
|
content = content.strip(strip)
|
||||||
|
|
||||||
if len(content) > maxlength:
|
if len(content) > maxlength:
|
||||||
new_content = content[maxlength-3] + '...'
|
new_content = content[:maxlength-3] + '...'
|
||||||
else:
|
else:
|
||||||
new_content = content
|
new_content = content
|
||||||
return new_content
|
return new_content
|
||||||
|
|||||||
@@ -129,19 +129,19 @@ class KoanComponent(cmds.Component):
|
|||||||
community = await self.bot.profiles.fetch_community(ctx.broadcaster)
|
community = await self.bot.profiles.fetch_community(ctx.broadcaster)
|
||||||
cid = community.communityid
|
cid = community.communityid
|
||||||
|
|
||||||
|
koan = None
|
||||||
if label is not None:
|
if label is not None:
|
||||||
koan = await self.koans.get_koan_label(cid, label)
|
koan = await self.koans.get_koan_label(cid, label)
|
||||||
if koan:
|
if not koan:
|
||||||
await ctx.reply(koan.message)
|
|
||||||
else:
|
|
||||||
await ctx.reply(f"Koan #{label} does not exist!")
|
await ctx.reply(f"Koan #{label} does not exist!")
|
||||||
else:
|
else:
|
||||||
koans = await self.koan.get_community_koans(communityid=cid)
|
koans = await self.koans.get_community_koans(communityid=cid)
|
||||||
if koans:
|
if koans:
|
||||||
koan = random.choice(koans)
|
koan = random.choice(koans)
|
||||||
formatted = f"Koan #{koan.koanlabel}: {koan.content}"
|
|
||||||
parts = [formatted[i: i:500] for i in range(0, len(formatted), 500)]
|
|
||||||
for part in parts:
|
|
||||||
await ctx.reply(part)
|
|
||||||
else:
|
else:
|
||||||
await ctx.reply("This channel doesn't have any koans!")
|
await ctx.reply("This channel doesn't have any koans!")
|
||||||
|
if koan:
|
||||||
|
formatted = f"Koan #{koan.koanlabel}: {koan.content}"
|
||||||
|
parts = [formatted[i : i+450] for i in range(0, len(formatted), 450)]
|
||||||
|
for part in parts:
|
||||||
|
await ctx.reply(part)
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
discord.py
|
||||||
|
twitchio
|
||||||
|
|||||||
Reference in New Issue
Block a user