Guest User

Untitled

a guest
Jul 10th, 2018
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.63 KB | None | 0 0
  1. from telethon import TelegramClient, sync
  2.  
  3. from telethon.tl.functions.channels import GetParticipantsRequest
  4. from telethon.tl.functions.channels import GetFullChannelRequest
  5. from telethon.tl.functions.messages import GetHistoryRequest
  6. from telethon.tl.types import PeerUser, PeerChat, PeerChannel
  7. from telethon.tl.types import ChannelParticipantsSearch
  8. from telethon import utils
  9. from telethon.tl.types import ChannelParticipantsAdmins
  10. from telethon import errors
  11. from time import sleep
  12.  
  13.  
  14. api_id = 2222
  15. api_hash = 'asdasd'
  16. phone_number = '+phone'
  17.  
  18. ################################################
  19. # invite link for private channel
  20.  
  21. #channel_id = 1234
  22. chat_id = 1234
  23. #inveite_link='t.me/'
  24. ################################################
  25.  
  26. ################################################
  27.  
  28. client = TelegramClient(phone_number,api_id,api_hash)
  29.  
  30. assert client.start()
  31. if not client.is_user_authorized():
  32.     client.send_code_request(phone_number)
  33.     me = client.sign_in(phone_number, input('Enter code: '))
  34.  
  35. #for dialog in client.get_dialogs(limit=200):
  36. #   print (dialog.id,dialog.name)
  37.  
  38. client.get_dialogs()
  39. #channel = client.get_entity(inveite_link)
  40. #channel = client.get_entity(PeerChannel(channel_id))
  41. chat = client.get_entity(PeerChat(chat_id))
  42.  
  43. offset = 0
  44. limit = 200
  45.  
  46. while True:
  47.     participants = client(GetParticipantsRequest(
  48.         chat, chat, offset, limit,hash=0))
  49.     if not participants.users:
  50.         break
  51.     for _user in participants.users:
  52.         print( _user.id,',', _user.username,',',_user.first_name,',',_user.last_name)
  53.         # save User info to Database
  54.     offset += len(participants.users)
Advertisement
Add Comment
Please, Sign In to add comment