I have to join chats via links, which are in a file.Only 30 links were correct but if i try to join myself it will be succeed.
Last time i tried to use a link in join_chat method:
async def main():
await app.start()
me = await app.get_me()
spic = [el.strip() for el in open('links.txt')]
for el in spic:
try:
chat = await app.get_chat(el)
if me.id not in chat.members:
await app.join_chat(el.rstrip())
await app.archive_chats(chat.id)
else:
print("Already in the group:", chat.title)
except:
print('Chat is not found')
await asyncio.sleep(1,5)
I also tried to indicate an username received from the link:
async def main():
await app.start()
spic = [el for el in open('links.txt')]
for el in spic:
try:
username = el.split("/")[-1]
await app.join_chat(str(username))
chat = await app.get_chat(username)
edit_text_file(str(chat.id))
await app.archive_chats(chat.id)
except:
print('Chat is not found')
await asyncio.sleep(1.5)
If i remove except handler i will get this error: "pyrogram.errors.exceptions.bad_request_400.UsernameInvalid: Telegram says: [400 USERNAME_INVALID] - The username is invalid (caused by "contacts.ResolveUsername")" Can you help me? Thank you