-1
import asyncio

from pyrogram import Client
from pyrogram.errors import PeerFlood
import time

api_id = 12905662
api_hash = "a7cfcd44cb95d26d7529d547c9a1d9ef"

vubor = input('Напишите "1" для парсинга, "2" для рассылки! ')
text = input('Текст для рассылки: ')

account = ['my_accont1', 'my_accont2', 'my_accont3', 'my_accont4', 'my_accont5', 'my_accont6', 'my_accont7',
           'my_accont8', 'my_accont9']


async def main():
    if vubor == '1':
        user = []
        with open('username.txt', 'r') as file:
            for users in file.readlines():
                y = users.strip()
                user.append(y)
            for acc in account:
                try:
                    async with Client(f"{acc}", api_id, api_hash) as app:
                        for all_user in user[0:500]:
                            time.sleep(5)
                            await app.send_message(all_user, text)
                            user.remove(all_user)
                except PeerFlood:
                    print('Аккаунт заблокировн')




asyncio.run(main())

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

  • check [This](https://docs.pyrogram.org/faq/peer-id-invalid-error#peer-id-invalid-error). Peer id must be int. – jak bin Nov 29 '22 at 18:45

1 Answers1

-5

Firstly, please learn how to ask a good question.

Secondly, your error message is already clear, you have to

Make sure you meet the peer before interacting with it

This means your session has to receive a message from them directly or via a shared chat, or have your session see any update to do with them in general.

ColinShark
  • 1,047
  • 2
  • 10
  • 18