Merge pull request #102 from paul-nameless/fix-decorator

Fix bug in update handler decorator
This commit is contained in:
Nameless 2020-07-01 20:13:55 +08:00 committed by GitHub
commit 9604c302bc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 5 deletions

View file

@ -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]:

View file

@ -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