bugfixes due to threading

This commit is contained in:
Remy Moll
2021-08-22 13:43:13 +02:00
parent b457999d3d
commit a86ac99f7d
6 changed files with 21 additions and 13 deletions

View File

@@ -59,7 +59,7 @@ class Help(BotFunc):
query.answer()
all_cmd = ""
for h in self.available_commands:
all_cmd += h + " - `" + self.available_commands[h] + "`\n"
all_cmd += "{} - `{}`\n".format(h, self.available_commands[h])
query.edit_message_text(text="List of all commands:\n" + all_cmd, parse_mode = ParseMode.MARKDOWN)
return ConversationHandler.END
@@ -120,7 +120,7 @@ class Help(BotFunc):
message = name + ": `" + self.available_commands[name] + "`"
query.edit_message_text(
text= "EHHHHH",
text= "Timed out...",
parse_mode = ParseMode.MARKDOWN_V2
)
return ConversationHandler.END

View File

@@ -5,8 +5,8 @@ CHOOSE_NUM = 1
class Joke(BotFunc):
"""Tells a joke from reddit."""
def __init__(self, api, prst):
super().__init__(prst)
def __init__(self, api, db):
super().__init__(db)
self.available_commands = {}
self.api = api
@@ -53,8 +53,8 @@ CHOOSE_TOPIC = 0
class Meme(BotFunc):
"""Gets the latest memes from reddit"""
def __init__(self, api, prst):
super().__init__(prst)
def __init__(self, api, db):
super().__init__(db)
self.available_commands = {}
self.api = api
@@ -87,7 +87,6 @@ class Meme(BotFunc):
def choose_topic(self, update: Update, context: CallbackContext) -> None:
super().entry_point()
query = update.callback_query
d = query.data
query.answer()

View File

@@ -38,9 +38,11 @@ class Search(BotFunc):
# formating
self.results = results
first = results[0]
message = first["text"] + "\n(" + first["url"] + ")\n\n"
if results:
first = results[0]
message = first["text"] + "\n(" + first["url"] + ")\n\n"
else:
message = "No results for search query."
update.message.reply_text(text = message, reply_markup=reply_markup)
super().log_activity(read = True, execute = True, send = True)
return MORE

View File

@@ -50,7 +50,6 @@ class ChatBot():
# "news" : self.commands.reddit.News(self.api_reddit, db),
"search" : self.commands.search.Search(self.api_search, db),
# ...
"plaintext" : self.commands.plaintext.Plain(db) # for handling non-command messages that should simply contribute to statistics
}
# must be a class that has a method create_handler