Fixes kopieerpasta and adds fallback
This commit is contained in:
+15
-7
@@ -80,19 +80,27 @@ class General(commands.Cog):
|
|||||||
@commands.command(pass_context=True)
|
@commands.command(pass_context=True)
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def kopieerpasta(self, ctx):
|
def kopieerpasta(self, ctx):
|
||||||
""" iets schattigs... """
|
"""Een willekeurige shitpost"""
|
||||||
print(type(ctx.message.channel))
|
|
||||||
rkopieerpasta = self.r.subreddit('kopieerpasta')
|
rkopieerpasta = self.r.subreddit('kopieerpasta')
|
||||||
post = rkopieerpasta.top('month', limit=250)
|
post = rkopieerpasta.random()
|
||||||
listing = list(post)
|
|
||||||
random.shuffle(listing)
|
|
||||||
post = listing[0]
|
|
||||||
|
|
||||||
|
# Subreddits kunnen de random functie uitzetten, dus dit is de fallback:
|
||||||
|
if post == None:
|
||||||
|
post = rkopieerpasta.top('month', limit=250)
|
||||||
|
listing = list(post)
|
||||||
|
random.shuffle(listing)
|
||||||
|
post = listing[0]
|
||||||
try:
|
try:
|
||||||
yield from ctx.message.delete()
|
yield from ctx.message.delete()
|
||||||
except:
|
except:
|
||||||
print("No permission to delete message")
|
print("No permission to delete message")
|
||||||
yield from ctx.channel.send('**'+post.title+'**```'+post.selftext+'```')
|
|
||||||
|
# Er is een 2000 karakter limiet wat met sommige pastas overschreden kan worden.
|
||||||
|
# eigenlijk willen we het dan opnieuw proberen maar dat is lastiger, dus maar gewoon berichtje.
|
||||||
|
if (len(post.selftext)+len(post.title)) >= 1990:
|
||||||
|
yield from ctx.channel.send('Sorry, kopieerpasta te lang. Probeer het maar opnieuw .')
|
||||||
|
else:
|
||||||
|
yield from ctx.channel.send('**'+post.title+'**```'+post.selftext+'```')
|
||||||
|
|
||||||
@commands.command(pass_context=True)
|
@commands.command(pass_context=True)
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
|
|||||||
Reference in New Issue
Block a user