diff --git a/tg/models.py b/tg/models.py index c7ea00d..2e8dee8 100644 --- a/tg/models.py +++ b/tg/models.py @@ -336,7 +336,7 @@ class MsgModel: ] msg_set = self.msg_ids[chat_id] for msg_id in msg_ids: - msg_set.remove(msg_id) + msg_set.discard(msg_id) def update_msg_content_opened(self, chat_id: int, msg_id: int) -> None: for message in self.msgs[chat_id]: diff --git a/tg/update_handlers.py b/tg/update_handlers.py index c9ffc85..c00b52c 100644 --- a/tg/update_handlers.py +++ b/tg/update_handlers.py @@ -24,15 +24,14 @@ def update_handler( update_type not in handlers ), f"Update type <{update_type}> already has handler: {handlers[update_type]}" - handlers[update_type] = fun - @wraps(fun) def wrapper(controller: Controller, update: Dict[str, Any]) -> None: try: - return fun(controller, update) + fun(controller, update) except Exception: - log.exception("Error happened in %s handler", fun.__name__) + log.exception("Error happened in handler: %s", update_type) + handlers[update_type] = wrapper return wrapper return decorator