#πŸ”’ Telegram Userbot on Pyrogram

13 messages Β· Page 1 of 1 (latest)

burnt pawn
#

I have this errors:

"ERROR:asyncio:Task exception was never retrieved"
and
"ValueError: Peer id invalid:"

The second error show id that I didn't wrote in my project, although I wrote this:

"logging.warning(f"Message from channel {message.chat.title} (ID: {message.chat.id}) not in ALLOWED_CHANNELS.")"

thick locustBOT
#

@burnt pawn

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

fickle blade
#

send the full error

#

!traceback

thick locustBOT
#
Traceback

Please provide the full traceback for your exception in order to help us identify your issue.
While the last line of the error message tells us what kind of error you got,
the full traceback will tell us which line, and other critical information to solve your problem.
Please avoid screenshots so we can copy and paste parts of the message.

A full traceback could look like:

Traceback (most recent call last):
  File "my_file.py", line 5, in <module>
    add_three("6")
  File "my_file.py", line 2, in add_three
    a = num + 3
        ~~~~^~~
TypeError: can only concatenate str (not "int") to str

If the traceback is long, use our pastebin.

burnt pawn
#

one sec

#

ERROR:pyrogram.dispatcher:Peer id invalid: -1002232476061
Traceback (most recent call last):
File "D:\ΠŸΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠΈΡ€ΠΎΠ²Π°Π½ΠΈΠ΅\ΠŸΡ€ΠΎΠ΅ΠΊΡ‚Ρ‹\tgbot.venv\Lib\site-packages\pyrogram\methods\advanced\resolve_peer.py", line 62, in resolve_peer
return await self.storage.get_peer_by_id(peer_id)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\ΠŸΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠΈΡ€ΠΎΠ²Π°Π½ΠΈΠ΅\ΠŸΡ€ΠΎΠ΅ΠΊΡ‚Ρ‹\tgbot.venv\Lib\site-packages\pyrogram\storage\sqlite_storage.py", line 142, in get_peer_by_id
raise KeyError(f"ID not found: {peer_id}")
KeyError: 'ID not found: -1002232476061'

During handling of the above exception, another exception occurred:

#

Traceback (most recent call last):
File "D:\ΠŸΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠΈΡ€ΠΎΠ²Π°Π½ΠΈΠ΅\ΠŸΡ€ΠΎΠ΅ΠΊΡ‚Ρ‹\tgbot.venv\Lib\site-packages\pyrogram\dispatcher.py", line 214, in handler_worker
await parser(update, users, chats)
File "D:\ΠŸΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠΈΡ€ΠΎΠ²Π°Π½ΠΈΠ΅\ΠŸΡ€ΠΎΠ΅ΠΊΡ‚Ρ‹\tgbot.venv\Lib\site-packages\pyrogram\dispatcher.py", line 75, in edited_message_parser
parsed, _ = await message_parser(update, users, chats)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\ΠŸΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠΈΡ€ΠΎΠ²Π°Π½ΠΈΠ΅\ΠŸΡ€ΠΎΠ΅ΠΊΡ‚Ρ‹\tgbot.venv\Lib\site-packages\pyrogram\dispatcher.py", line 68, in message_parser
await pyrogram.types.Message._parse(self.client, update.message, users, chats,
File "D:\ΠŸΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠΈΡ€ΠΎΠ²Π°Π½ΠΈΠ΅\ΠŸΡ€ΠΎΠ΅ΠΊΡ‚Ρ‹\tgbot.venv\Lib\site-packages\pyrogram\types\messages_and_media\message.py", line 836, in _parse
reply_to_message = await client.get_messages(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\ΠŸΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠΈΡ€ΠΎΠ²Π°Π½ΠΈΠ΅\ΠŸΡ€ΠΎΠ΅ΠΊΡ‚Ρ‹\tgbot.venv\Lib\site-packages\pyrogram\methods\messages\get_messages.py", line 101, in get_messages
peer = await self.resolve_peer(chat_id)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\ΠŸΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠΈΡ€ΠΎΠ²Π°Π½ΠΈΠ΅\ΠŸΡ€ΠΎΠ΅ΠΊΡ‚Ρ‹\tgbot.venv\Lib\site-packages\pyrogram\methods\advanced\resolve_peer.py", line 89, in resolve_peer
peer_type = utils.get_peer_type(peer_id)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\ΠŸΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠΈΡ€ΠΎΠ²Π°Π½ΠΈΠ΅\ΠŸΡ€ΠΎΠ΅ΠΊΡ‚Ρ‹\tgbot.venv\Lib\site-packages\pyrogram\utils.py", line 246, in get_peer_type
raise ValueError(f"Peer id invalid: {peer_id}")
ValueError: Peer id invalid: -1002232476061

compact charm
#

sorry cat on keyboard

#

okay, I checked. the lib hasn't been updated in over a year
and what you encountered is a known error but won't be fixed because lib is not maintained https://github.com/pyrogram/pyrogram/pull/1430

monkey-patching fix:

import pyrogram.utils
pyrogram.utils.MIN_CHAT_ID = -999999999999
pyrogram.utils.MIN_CHANNEL_ID = -1007852516352

min channel id is different than this pr had it, I used current value from https://core.telegram.org/api/bots/ids

this code can be added on top of your main code file. I prefer patching like this rather than editing file inside a lib (edited file won't survive if you reinstall the lib)

GitHub

Contribution Request: Update MIN_CHANNEL_ID and MIN_CHAT_ID in Pyrogram
Title: Update MIN_CHANNEL_ID and MIN_CHAT_ID to Fix "Peer id invalid" Error
Description
This contribution r...

burnt pawn
#

Its working! Thank you so much!!! ❀️

thick locustBOT
#
Python help channel closed for inactivity

This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.