mirror of
https://github.com/paul-nameless/tg
synced 2025-02-16 18:48:24 +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]
|
msg_set = self.msg_ids[chat_id]
|
||||||
for msg_id in msg_ids:
|
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:
|
def update_msg_content_opened(self, chat_id: int, msg_id: int) -> None:
|
||||||
for message in self.msgs[chat_id]:
|
for message in self.msgs[chat_id]:
|
||||||
|
|
|
@ -24,15 +24,14 @@ def update_handler(
|
||||||
update_type not in handlers
|
update_type not in handlers
|
||||||
), f"Update type <{update_type}> already has handler: {handlers[update_type]}"
|
), f"Update type <{update_type}> already has handler: {handlers[update_type]}"
|
||||||
|
|
||||||
handlers[update_type] = fun
|
|
||||||
|
|
||||||
@wraps(fun)
|
@wraps(fun)
|
||||||
def wrapper(controller: Controller, update: Dict[str, Any]) -> None:
|
def wrapper(controller: Controller, update: Dict[str, Any]) -> None:
|
||||||
try:
|
try:
|
||||||
return fun(controller, update)
|
fun(controller, update)
|
||||||
except Exception:
|
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 wrapper
|
||||||
|
|
||||||
return decorator
|
return decorator
|
||||||
|
|
Loading…
Add table
Reference in a new issue