From 64b933d0546bdae6eb8092d17c56c90b8dd5035c Mon Sep 17 00:00:00 2001 From: Ivan Filipenkov Date: Sat, 9 Mar 2024 19:13:41 +0100 Subject: [PATCH] fix: tgpy error when editing MessageService, e.g. when deleting all messages in pm or beating your high score in games --- tgpy/api/utils.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tgpy/api/utils.py b/tgpy/api/utils.py index ed4c2c5..66c9cf7 100644 --- a/tgpy/api/utils.py +++ b/tgpy/api/utils.py @@ -7,7 +7,9 @@ import tokenize from io import BytesIO +from telethon import events from telethon.tl.custom import Message +from telethon.tl.types import MessageService import tgpy from tgpy.utils import REPO_ROOT, RunCmdException, execute_in_repo_root, run_cmd @@ -87,8 +89,9 @@ async def try_await(func, *args, **kwargs): return res -def outgoing_messages_filter(m: Message): - return m.out and not m.forward and not m.via_bot +def outgoing_messages_filter(e: events.NewMessage.Event | events.MessageEdited.Event): + m: Message = e.message + return m.out and not m.forward and not m.via_bot and not isinstance(m, MessageService) def tokenize_string(s: str) -> list[tokenize.TokenInfo] | None: