Skip to content

Commit

Permalink
fix: on_all() decorator don't recive all updates
Browse files Browse the repository at this point in the history
  • Loading branch information
z44d committed Jul 14, 2024
1 parent 1fdb9d9 commit 0fe7454
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
8 changes: 5 additions & 3 deletions tgram/tgbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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",
Expand Down
3 changes: 2 additions & 1 deletion tgram/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
]
Expand Down

0 comments on commit 0fe7454

Please sign in to comment.