diff --git a/tgram/tgbot.py b/tgram/tgbot.py index e09acab..f510d07 100644 --- a/tgram/tgbot.py +++ b/tgram/tgbot.py @@ -11,7 +11,7 @@ from .methods import TelegramBotMethods from .decorators import Decorators from .errors import APIException -from .utils import API_URL, get_file_name +from .utils import API_URL, get_file_name, ALL_UPDATES from .sync import wrap from concurrent.futures.thread import ThreadPoolExecutor @@ -148,8 +148,10 @@ def __init__( self._api_url = f"{api_url}bot{bot_token}/" def add_handler(self, handler: "tgram.handlers.Handler") -> None: - if (t := handler.type != "all") and t not in self.allowed_updates: - self.allowed_updates.append(t) + if handler.type == "all": + self.allowed_updates = ALL_UPDATES + elif handler.type not in self.allowed_updates: + self.allowed_updates.append(handler.type) logger.info( "(%s) added to %s handlers", diff --git a/tgram/utils.py b/tgram/utils.py index 21d3367..b8ed31b 100644 --- a/tgram/utils.py +++ b/tgram/utils.py @@ -3,9 +3,10 @@ import os from pathlib import Path +from typing import List API_URL = "https://api.telegram.org/" -ALL_UPDATES = [ +ALL_UPDATES: List[str] = [ getattr(Handlers, i) for i in filter(lambda x: not x.startswith("_"), Handlers.__dict__) ]