diff --git a/telebot/__init__.py b/telebot/__init__.py index 9b33dbc..a877b69 100644 --- a/telebot/__init__.py +++ b/telebot/__init__.py @@ -113,7 +113,7 @@ class TeleBot: self.worker_pool = util.ThreadPool(num_threads=num_threads) @staticmethod - def dump_handlers(handlers, filename="./handler-saves/step.save", file_mode="w"): + def dump_handlers(handlers, filename, file_mode="w"): dirs = filename.rsplit('/', maxsplit=1)[0] os.makedirs(dirs, exist_ok=True) with open(filename + ".tmp", file_mode) as file: @@ -165,6 +165,12 @@ class TeleBot: with open(filename, "r") as file: handlers = json.load(file) + for handler in handlers: + name = handler["callback"]["name"] + module = handler["callback"]["module"] + + handler = getattr(sys.modules[module], name) + return handlers def load_next_step_handlers(self, filename="./handler-saves/step.save"):