bugfixes due to threading
This commit is contained in:
		| @@ -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 | ||||
| @@ -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() | ||||
|   | ||||
| @@ -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 | ||||
|   | ||||
| @@ -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 | ||||
|   | ||||
| @@ -4,6 +4,14 @@ import numpy as np | ||||
| from threading import Thread | ||||
|  | ||||
|  | ||||
| import logging | ||||
| log = logging.getLogger('werkzeug') | ||||
| log.setLevel(logging.ERROR) | ||||
| # hide the info-messages of each GET-request | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| class BroadcastUpdates: | ||||
|     """Broadcasts (out) updates for the hw-handler to be fetched periodically""" | ||||
|      | ||||
|   | ||||
| @@ -12,7 +12,7 @@ class Launcher: | ||||
|     def __init__(self, **modules): | ||||
|         """""" | ||||
|         self.persistence = p_io.PersistentDict("persistence/prst.json") | ||||
|         self.db = p_out.DBLogging() | ||||
|         self.db = p_out.DBLogging | ||||
|  | ||||
|         logger.info(self.__class__.__name__ + " initialized") | ||||
|  | ||||
| @@ -31,7 +31,7 @@ class Launcher: | ||||
|             logger.info("Starting module "+ module.__class__.__name__) | ||||
|             module.modules = self.modules | ||||
|             module.persistence = self.persistence | ||||
|             module.db = self.db | ||||
|             module.db = self.db() # newly initialized for every module | ||||
|             module.start() | ||||
|  | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Remy Moll
					Remy Moll