0

I am developing an unofficial Telegram program using the Pyrogram library in a shell environment. After a user connects their account to my program, they can provide a list of phone numbers and messages to the program, and the program will send those messages to the numbers.

The workflow is as follows: each phone number is added to the Telegram contacts list using the import_contacts method, and then the send_message method is used to send the message to the numbers.

I have encountered a strange issue where some accounts encounter a "400 PEER_ID_INVALID" error in the import_contacts method, even though the phone number is correct.

To investigate further, I tested the phone number using the Plus application with the same account connected to Pyrogram. I tried to save the number in the contacts section to see if there is any issue. Surprisingly, I received a similar error through the Plus application as well.

However, when I tested the same phone number with a different account in the Plus application, the contact was successfully created.

Any insights or suggestions on why I might be encountering this error only with certain accounts would be greatly appreciated.

first_name = self.__get_first_name()
            phone_number = str(self.phone_number).strip()

            async with PyrogramClientCM.get_instance(self.bot_id) as app:
                await app.import_contacts([
                    InputPhoneContact(phone_number, first_name)
                ])
B. Azizan
  • 93
  • 1
  • 4
  • 12

0 Answers0