Advertisement
Guest User

Untitled

a guest
Apr 9th, 2021
18
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. from api import api_id,api_hash
  2. from telethon import TelegramClient , events
  3. from telethon.tl.functions.messages import ImportChatInviteRequest , CheckChatInviteRequest
  4. from telethon.tl.functions.channels import JoinChannelRequest
  5. import aiofiles
  6. import asyncio
  7. from telethon.errors.rpcerrorlist import InviteHashEmptyError , InviteHashExpiredError
  8.  
  9.  
  10. client = TelegramClient('my_account',api_id,api_hash,
  11. device_model="Xiaomi Redmi Note 8",
  12. system_version="SDK 25",
  13. app_version="0.22.8.1361",
  14. lang_code="RU",
  15. system_lang_code="RU",
  16. flood_sleep_threshold=3000
  17. )
  18.  
  19. client.start()
  20. print(client.is_connected())
  21.  
  22.  
  23. async def main():
  24. tasks = []
  25. async with aiofiles.open('spisok.txt', mode='r') as f:
  26. async for line in f:
  27. task = asyncio.create_task(joingroup(line))
  28.  
  29. tasks.append(task)
  30.  
  31.  
  32. await asyncio.gather(*tasks)
  33.  
  34.  
  35.  
  36. async def joingroup(line):
  37.  
  38. a = line.rstrip()
  39. a = a.split('/')
  40.  
  41.  
  42. try:
  43. result = await client(CheckChatInviteRequest(str(a[-1])))
  44. print(result)
  45. except InviteHashEmptyError:
  46. print('InviteHashEmptyError')
  47. except InviteHashExpiredError:
  48. print('InviteHashExpiredError')
  49. except InviteHashInvalidError:
  50. print('InviteHashInvalidError')
  51.  
  52.  
  53.  
  54. with client:
  55.  
  56. client.loop.run_until_complete(main())
  57.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement