Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.32 KB | None | 0 0
  1. from telethon.sync import TelegramClient
  2. from telethon.tl.functions.channels import InviteToChannelRequest, JoinChannelRequest
  3. from telethon.tl.functions.users import GetFullUserRequest
  4. from telethon.sync import TelegramClient
  5. import sys
  6. import time
  7.  
  8. def connect(api_id, api_hash, phone, users):
  9. client = TelegramClient(phone, api_id, api_hash)
  10. client.connect()
  11. if not client.is_user_authorized():
  12. client.send_code_request(phone)
  13. client.sign_in(phone, input('Enter the code: '))
  14. print(phone + ' has connected.')
  15.  
  16. target_group_entity = client.get_entity('https://t.me/TenGrassJoin')
  17. client(JoinChannelRequest(target_group_entity))
  18.  
  19. try:
  20. client(InviteToChannelRequest(target_group_entity,users))
  21. print(phone + " Has Invited : " + users[0])
  22. time.sleep(0.5)
  23. except Exception as e:
  24. code = False
  25. try:
  26. code = e.code
  27. except:
  28. pass
  29. if code != False:
  30. print("Error {}".format(code), e)
  31. if code == 400:
  32. print('---------------{} blocked. '.format(phone))
  33. return True
  34. else:
  35. print("Error", e)
  36.  
  37. client.disconnect()
  38.  
  39. def get_names():
  40. users = []
  41. file_name = input('Members to Add File name: ')
  42. with open(file_name,'r') as in_file:
  43. for name in in_file:
  44. name = name.rstrip()
  45. users.append(name)
  46. in_file.close()
  47. return users
  48.  
  49. def main():
  50. allowed_senders_amount = len(all_senders)
  51.  
  52. users = get_names()
  53.  
  54. all_senders = [
  55. ["123123",'154tr1dfx3904slkdm2734ahsdu12xcx','+123566877049'],
  56. ["456456",'3csscef3345556424433555512341234','+123511899048'],
  57. ["789789",'tyyfec355fbdee37a223465457512353','+123533825031'],
  58. ["333222",'23a12dd66f83451defc35d1455b3pos3','+123543825033'],
  59. ]
  60.  
  61. while allowed_senders_amount != 0:
  62. for api_id, api_hash, phone in all_senders:
  63. user_name = []
  64. user_name.append(users[0])
  65. response = connect(api_id, api_hash, phone, user_name)
  66.  
  67. ----------------- המטרה:
  68. אם הפונקציה מחזירה True :
  69. זאת אומרת שהמשמש נחסם ואז אני רוצה שהלולאה לא תשתמש יותר בפרטים של אותו השולח
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement