mirror of
https://github.com/paul-nameless/tg
synced 2024-11-22 03:43:19 +00:00
Fix bug in update handler decorator
This commit is contained in:
parent
4e68561a95
commit
718bf5a7a7
2 changed files with 7 additions and 5 deletions
|
@ -336,7 +336,10 @@ class MsgModel:
|
|||
]
|
||||
msg_set = self.msg_ids[chat_id]
|
||||
for msg_id in msg_ids:
|
||||
msg_set.remove(msg_id)
|
||||
try:
|
||||
msg_set.remove(msg_id)
|
||||
except KeyError:
|
||||
continue
|
||||
|
||||
def update_msg_content_opened(self, chat_id: int, msg_id: int) -> None:
|
||||
for message in self.msgs[chat_id]:
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue