from pyrogram import Client
from pyrogram.errors import PeerFlood
import time
vubor = input('Нажмите Enter чтобы запустить рассылку! ')
api_id = 12905662
api_hash = "a7cfcd44cb95d26d7529d547c9a1d9ef"
app = Client('my_accont11', api_id, api_hash)
if vubor == '':
def rassulka(app):
try:
with open('username.txt', 'r') as file:
for users in file.readlines():
y = users.strip()
time.sleep(5)
app.send_message(y, 'q')
file.replace(y, '')
except PeerFlood:
print('Аккаунт заблокировн')
with app:
rassulka(app)
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
I do not know what to do
2
Answers
This error could mean several things (possible solution at the end):
About the last point: in order for you to meet a user and thus communicate with them, you should ask yourself how to contact people using official apps. The answer is the same for Pyrogram too and involves normal usages such as searching for usernames, meeting them in a common group, having their phone contacts saved, getting a message mentioning them or obtaining the dialogs list.
possible solution
it might happen because you have passed only numerical IDs, as a string. Pyrogram tries to resolve those as a username, if it can’t find those, it tries them as a phone number. If that still doesn’t match, you get an error.
Try to use the method with an integer, as the IDs you tried, are integers.
For write this code I used Pyrogram==1.3.6
For install Pyrogram 1.3.6: