LonamiWebs / Telethon

Pure Python 3 MTProto API Telegram client library, for bots too!
https://docs.telethon.dev
MIT License
9.93k stars 1.4k forks source link

PeerChat overflow #1312

Closed alexshavelev44 closed 5 years ago

alexshavelev44 commented 5 years ago

We have such event NewMessage.Event(original_update=UpdateShortChatMessage(id=238870, from_id=627005412, chat_id=334730735, message='d', pts=423470, pts_count=1, date=datetime.datetime(2019, 10, 31, 8, 9, 36, tzinfo=datetime.timezone.utc), out=True, mentioned=False, media_unread=False, silent=False, fwd_from=None, via_bot_id=None, reply_to_msg_id=None, entities=[]), pattern_match=None, message=Message(id=238870, to_id=PeerChat(chat_id=334730735), date=datetime.datetime(2019, 10, 31, 8, 9, 36, tzinfo=datetime.timezone.utc), message='d', out=True, mentioned=False, media_unread=False, silent=False, post=None, from_scheduled=None, legacy=None, edit_hide=None, from_id=627005412, fwd_from=None, via_bot_id=None, reply_to_msg_id=None, media=None, reply_markup=None, entities=[], views=None, edit_date=None, post_author=None, grouped_id=None, restriction_reason=[]))

PeerChat(chat_id=334730735)

but if call with this id await client.get_entity(PeerChat(dst_chat_id)) will receive

ERROR:telethon.client.updates:Unhandled exception on my_event_handler
Traceback (most recent call last):
  File "/Users/alex_shavelev/projects/bots/fb_anchors_forwarder/venv/lib/python3.7/site-packages/telethon/client/updates.py", line 422, in _dispatch_update
    await callback(event)
  File "userbot.py", line 17, in my_event_handler
    dst_chat = await client.get_entity(PeerChat(dst_chat_id))
  File "/Users/alex_shavelev/projects/bots/fb_anchors_forwarder/venv/lib/python3.7/site-packages/telethon/client/users.py", line 276, in get_entity
    functions.messages.GetChatsRequest(chats))).chats
  File "/Users/alex_shavelev/projects/bots/fb_anchors_forwarder/venv/lib/python3.7/site-packages/telethon/client/users.py", line 53, in __call__
    future = self._sender.send(request, ordered=ordered)
  File "/Users/alex_shavelev/projects/bots/fb_anchors_forwarder/venv/lib/python3.7/site-packages/telethon/network/mtprotosender.py", line 165, in send
    state = RequestState(request, self._loop)
  File "/Users/alex_shavelev/projects/bots/fb_anchors_forwarder/venv/lib/python3.7/site-packages/telethon/network/requeststate.py", line 17, in __init__
    self.data = bytes(request)
  File "/Users/alex_shavelev/projects/bots/fb_anchors_forwarder/venv/lib/python3.7/site-packages/telethon/tl/functions/messages.py", line 1141, in __bytes__
    b'\x15\xc4\xb5\x1c',struct.pack('<i', len(self.id)),b''.join(struct.pack('<i', x) for x in self.id),
  File "/Users/alex_shavelev/projects/bots/fb_anchors_forwarder/venv/lib/python3.7/site-packages/telethon/tl/functions/messages.py", line 1141, in <genexpr>
    b'\x15\xc4\xb5\x1c',struct.pack('<i', len(self.id)),b''.join(struct.pack('<i', x) for x in self.id),
struct.error: 'i' format requires -2147483648 <= number <= 2147483647
Lonami commented 5 years ago

What is the reason for closing?

alexshavelev44 commented 5 years ago

@Lonami passed wrong argument