Add /hmmmm

This commit is contained in:
Ceda EI 2019-04-01 15:34:48 +05:30
parent 5873ffabe6
commit 5b0b4821dd
1 changed files with 8 additions and 3 deletions

11
bot.py
View File

@ -12,12 +12,12 @@ logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - \
%(message)s', level=logging.INFO) %(message)s', level=logging.INFO)
def cursed(bot, update, args): def cursed(bot, update, args, subreddit):
try: try:
lim = args[0] lim = args[0]
except(IndexError): except(IndexError):
lim = 1 lim = 1
url = f"https://www.reddit.com/r/cursedimages/top.json?limit={lim}" url = f"https://www.reddit.com/r/{subreddit}/top.json?limit={lim}"
headers = { headers = {
'user-agent': ('windows / chrome 67 [desktop]: mozilla/5.0 ' 'user-agent': ('windows / chrome 67 [desktop]: mozilla/5.0 '
'(windows nt 10.0; win64; x64)')} '(windows nt 10.0; win64; x64)')}
@ -32,5 +32,10 @@ def cursed(bot, update, args):
updater = Updater(token=config.api_key) updater = Updater(token=config.api_key)
dispatcher = updater.dispatcher dispatcher = updater.dispatcher
dispatcher.add_handler(CommandHandler('cursed', cursed, pass_args=True)) dispatcher.add_handler(CommandHandler('cursed', lambda x, y, z:
cursed(x, y, z, "CursedImages"),
pass_args=True))
dispatcher.add_handler(CommandHandler('hmmmm', lambda x, y, z:
cursed(x, y, z, "hmmm"),
pass_args=True))
updater.start_polling() updater.start_polling()