You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am sure the error is coming from Pyrogram's code and not elsewhere
I have searched in the issue tracker for similar bug reports, including closed ones
I ran pip3 install -U https://github.com/pyrogram/pyrogram/archive/master.zip and reproduced the issue using the latest development version
Description
pyrogram.errors.exceptions.bad_request_400.PeerIdInvalid: Telegram says: [400 PEER_ID_INVALID] - The peer id being used is invalid or not known yet. Make sure you meet the peer before interacting with it
Steps to reproduce
I setup two telegram accounts. Neither are on each other's contact list
I added both telegram accounts into a group chat. They both typed in the group chat and both received the message. They should have satisfied the requirement of "meeting each other"
Despite this I keep getting a "pyrogram.errors.exceptions.bad_request_400.PeerIdInvalid: Telegram says: [400 PEER_ID_INVALID] - The peer id being used is invalid or not known yet. Make sure you meet the peer before interacting with it". when telegram account "Peter" tries to send a DM to "Sean" via API. Neither account has a username set but both are on a verified unique phone number.
Although they cannot message each other in DM using the API, I know that on the official client it's completely possible to DM someone you met in a group chat. Why can't I do it via the Telegram API? I should have met this peer in the group chat.
I am DMing them using the API through their chat ID.
Code example
frompyrogramimportClientfromdotenvimportload_dotenvimportosload_dotenv()
CONFIG= {
"telegram_api_id": int(os.getenv("TG_API_ID")),
"telegram_hash": os.getenv("TG_API_HASH"),
}
app=Client("my_account",CONFIG["telegram_api_id"],CONFIG["telegram_hash"])
withapp:
app.send_message(7141057061, "Hello there. I am using Pyrogram.")
Logs
Traceback (most recent call last):
File "C:\pytelegrambot\pytelegrambot\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 "C:\pytelegrambot\pytelegrambot\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: 7141057061'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\pytelegrambot\pytelegrambot\Lib\site-packages\pyrogram\methods\advanced\resolve_peer.py", line 123, in resolve_peer
return await self.storage.get_peer_by_id(peer_id)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\pytelegrambot\pytelegrambot\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: 7141057061'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\pytelegrambot\dm.py", line 16, in<module>
app.send_message(7141057061, "Hello there. I am using Pyrogram.")
File "C:\pytelegrambot\pytelegrambot\Lib\site-packages\pyrogram\sync.py", line 66, in async_to_sync_wrap
return loop.run_until_complete(coroutine)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python312\Lib\asyncio\base_events.py", line 684, in run_until_complete
returnfuture.result()
^^^^^^^^^^^^^^^
File "C:\pytelegrambot\pytelegrambot\Lib\site-packages\pyrogram\methods\messages\send_message.py", line 128, in send_message
peer=await self.resolve_peer(chat_id),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\pytelegrambot\pytelegrambot\Lib\site-packages\pyrogram\methods\advanced\resolve_peer.py", line 125, in resolve_peer
raise PeerIdInvalid
pyrogram.errors.exceptions.bad_request_400.PeerIdInvalid: Telegram says: [400 PEER_ID_INVALID] - The peer id being used is invalid or not known yet. Make sure you meet the peer before interacting with it
The text was updated successfully, but these errors were encountered:
Checklist
pip3 install -U https://github.com/pyrogram/pyrogram/archive/master.zip
and reproduced the issue using the latest development versionDescription
pyrogram.errors.exceptions.bad_request_400.PeerIdInvalid: Telegram says: [400 PEER_ID_INVALID] - The peer id being used is invalid or not known yet. Make sure you meet the peer before interacting with it
Steps to reproduce
Code example
Logs
The text was updated successfully, but these errors were encountered: