mirror of
https://github.com/paul-nameless/tg
synced 2024-11-25 13:20:25 +00:00
Merge pull request #102 from paul-nameless/fix-decorator
Fix bug in update handler decorator
This commit is contained in:
commit
9604c302bc
2 changed files with 4 additions and 5 deletions
|
@ -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]:
|
||||
|
|
|
@ -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