From 54ab8419d68e2ee3b927a059ae6ffe6fe960b8a7 Mon Sep 17 00:00:00 2001 From: angerstoner Date: Thu, 4 Oct 2018 23:39:05 +0200 Subject: [PATCH] sudo kill --- schneiderbot.py | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/schneiderbot.py b/schneiderbot.py index f1ce2db..4606403 100644 --- a/schneiderbot.py +++ b/schneiderbot.py @@ -74,7 +74,6 @@ MODES = { "full" : HIDE_CATEGORIES_FULL } - # Enable logging logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO) @@ -127,13 +126,35 @@ def sendDog(bot, update): dog = pydog.PyDog() bot.send_photo(chat_id=update.message.chat_id, photo=dog.get_random_image()) -def kill(bot, update): +def kill(bot, update, sudocall = False): """kill me pls""" - update.message.reply_text(update.message.from_user.first_name + " died") + message = update.message.from_user.first_name + " died" + if sudocall: + message += " for real" + update.message.reply_text(message) -def revive(bot, update): +def revive(bot, update, sudocall = False): """unkill me pls""" - update.message.reply_text(update.message.from_user.first_name + " is no longer dead!") + message = update.message.from_user.first_name + " is living again" + if sudocall: + message += " for real" + update.message.reply_text(message) + +SUDOCMDS = { + "kill" : kill, + "revive" : revive + } + +def sudo(bot, update, args): + """for real""" + if not args : + update.message.reply_text("Unknown command") + return + for arg in args: + if arg in SUDOCMDS: + SUDOCMDS[arg](bot, update, True) + else: + update.message.reply_text("Unknown command") def sendCatDog(bot, update): """Best of both worlds!""" @@ -238,6 +259,7 @@ def main(): dp.add_handler(CommandHandler("manta", manta)) dp.add_handler(CommandHandler("goodlife", goodlife)) dp.add_handler(CommandHandler("mensa", mensa, pass_args=True)) + dp.add_handler(CommandHandler("sudo", sudo, pass_args=True)) dp.add_handler(CommandHandler("cat", sendCat)) dp.add_handler(CommandHandler("dog", sendDog)) dp.add_handler(CommandHandler("catdog", sendCatDog))