Skip to content

Commit

Permalink
fix: tgpy error when editing MessageService, e.g. when deleting all m…
Browse files Browse the repository at this point in the history
…essages in pm or beating your high score in games
  • Loading branch information
vanutp committed Mar 9, 2024
1 parent eec91a9 commit 5d6fb5e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions tgpy/api/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -87,8 +89,11 @@ 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:
Expand Down

0 comments on commit 5d6fb5e

Please sign in to comment.