Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from telethon.sync import TelegramClient
- from telethon.tl.functions.channels import InviteToChannelRequest, JoinChannelRequest
- from telethon.tl.functions.users import GetFullUserRequest
- from telethon.sync import TelegramClient
- import sys
- import time
- def connect(api_id, api_hash, phone, users):
- client = TelegramClient(phone, api_id, api_hash)
- client.connect()
- if not client.is_user_authorized():
- client.send_code_request(phone)
- client.sign_in(phone, input('Enter the code: '))
- print(phone + ' has connected.')
- target_group_entity = client.get_entity('https://t.me/TenGrassJoin')
- client(JoinChannelRequest(target_group_entity))
- try:
- client(InviteToChannelRequest(target_group_entity,users))
- print(phone + " Has Invited : " + users[0])
- time.sleep(0.5)
- except Exception as e:
- code = False
- try:
- code = e.code
- except:
- pass
- if code != False:
- print("Error {}".format(code), e)
- if code == 400:
- print('---------------{} blocked. '.format(phone))
- return True
- else:
- print("Error", e)
- client.disconnect()
- def get_names():
- users = []
- file_name = input('Members to Add File name: ')
- with open(file_name,'r') as in_file:
- for name in in_file:
- name = name.rstrip()
- users.append(name)
- in_file.close()
- return users
- def main():
- allowed_senders_amount = len(all_senders)
- users = get_names()
- all_senders = [
- ["123123",'154tr1dfx3904slkdm2734ahsdu12xcx','+123566877049'],
- ["456456",'3csscef3345556424433555512341234','+123511899048'],
- ["789789",'tyyfec355fbdee37a223465457512353','+123533825031'],
- ["333222",'23a12dd66f83451defc35d1455b3pos3','+123543825033'],
- ]
- while allowed_senders_amount != 0:
- for api_id, api_hash, phone in all_senders:
- user_name = []
- user_name.append(users[0])
- response = connect(api_id, api_hash, phone, user_name)
- ----------------- המטרה:
- אם הפונקציה מחזירה True :
- זאת אומרת שהמשמש נחסם ואז אני רוצה שהלולאה לא תשתמש יותר בפרטים של אותו השולח
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement