Simplified command handling (no cancer

This commit is contained in:
Christian Rendina 2020-03-09 00:34:04 +01:00
parent 5e57a323d2
commit 109443427d

View File

@ -1,5 +1,5 @@
# File: MammottoInline.py # File: inline.py
# Description: MammotroBot inline wrapper # Description: Inline wrapper
# Author: Arvs100 # Author: Arvs100
# Date: 25-12-2019 ~ 28-12-2019 # Date: 25-12-2019 ~ 28-12-2019
from telegram.ext import Updater, InlineQueryHandler, CommandHandler from telegram.ext import Updater, InlineQueryHandler, CommandHandler
@ -16,6 +16,16 @@ class InlineBot:
self.errorText = "Sowwy mawster, an ewror occuwed. ;;w;;" 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): def callRequest(self, command, senderid, text):
r = requests.get(self.apiUrl, r = requests.get(self.apiUrl,
headers={ headers={
@ -80,13 +90,9 @@ class InlineBot:
query = update.inline_query.query query = update.inline_query.query
results = list() results = list()
if not query: if not query:
results.append(self.makeResult("Pony", "yay, ponies!", self.callRequest("pony", senderid, query))) for key in self.commands:
results.append(self.makeResult("Clop", "NSFW ponies", self.callRequest("clop", senderid, query))) desc = self.commands[key]
results.append(self.makeResult("Furry", "Furries", self.callRequest("furry", senderid, query))) results.append(self.makeResult(key, desc, self.callRequest(key.lower(), 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"))
else: else:
results.append(self.makeResult("Cancer", "Search cancer about " + query, self.callRequest("cancer", senderid, query))) 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) context.bot.answer_inline_query(update.inline_query.id, results, 1, False)