From 109443427da6981c1c4c6fc64d4dba160dd7c64f Mon Sep 17 00:00:00 2001 From: Arves100 Date: Mon, 9 Mar 2020 00:34:04 +0100 Subject: [PATCH] Simplified command handling (no cancer --- inline.py | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/inline.py b/inline.py index 58bcee5..5e37938 100644 --- a/inline.py +++ b/inline.py @@ -1,5 +1,5 @@ -# File: MammottoInline.py -# Description: MammotroBot inline wrapper +# File: inline.py +# Description: Inline wrapper # Author: Arvs100 # Date: 25-12-2019 ~ 28-12-2019 from telegram.ext import Updater, InlineQueryHandler, CommandHandler @@ -16,6 +16,16 @@ class InlineBot: self.errorText = "Sowwy mawster, an ewror occuwed. ;;w;;" + self.commands = { + "Pony" : "yay, ponies!", + "Clop" : "NSFW ponies", + "Furry" : "Furries" + "Loli" : "Cute lolis", + "Yiff" : "Yiff", + "Lewd" : "Say hi to the police", + "Rasoio" : "Dai facciamogli lo scherzo del rasoio!1!!" + } + def callRequest(self, command, senderid, text): r = requests.get(self.apiUrl, headers={ @@ -80,13 +90,9 @@ class InlineBot: query = update.inline_query.query results = list() if not query: - results.append(self.makeResult("Pony", "yay, ponies!", self.callRequest("pony", senderid, query))) - results.append(self.makeResult("Clop", "NSFW ponies", self.callRequest("clop", senderid, query))) - results.append(self.makeResult("Furry", "Furries", self.callRequest("furry", senderid, query))) - results.append(self.makeResult("Loli", "Cute lolis", self.callRequest("loli", senderid, query))) - results.append(self.makeResult("Yiff", "Yiff", self.callRequest("yiff", senderid, query))) - results.append(self.makeResult("Lewd", "Say hi to the police", self.callRequest("lewd", senderid, query))) - results.append(self.makeResult("Rasoio", "Dai facciamogli lo scherzo del rasoio!1!!", "https://www.youtube.com/watch?v=sj8kNDOpvWI")) + for key in self.commands: + desc = self.commands[key] + results.append(self.makeResult(key, desc, self.callRequest(key.lower(), senderid, query))) else: results.append(self.makeResult("Cancer", "Search cancer about " + query, self.callRequest("cancer", senderid, query))) context.bot.answer_inline_query(update.inline_query.id, results, 1, False)