forked from noob-coder123/Genisys
-
Notifications
You must be signed in to change notification settings - Fork 0
/
usradder.py
116 lines (112 loc) · 3.73 KB
/
usradder.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
from telethon.sync import TelegramClient
from telethon.tl.types import InputPeerChannel
from telethon.errors.rpcerrorlist import PeerFloodError, UserPrivacyRestrictedError
from telethon.tl.functions.channels import InviteToChannelRequest
import sys
import csv
import time
import random
import pyfiglet
#import traceback
from colorama import init, Fore
import os
init()
r = Fore.RED
g = Fore.GREEN
rs = Fore.RESET
w = Fore.WHITE
cy = Fore.CYAN
ye = Fore.YELLOW
colors = [r, g, w, ye, cy]
info = g + '[' + w + 'i' + g + ']' + rs
attempt = g + '[' + w + '+' + g + ']' + rs
sleep = g + '[' + w + '*' + g + ']' + rs
error = g + '[' + r + '!' + g + ']' + rs
def banner():
f = pyfiglet.Figlet(font='slant')
logo = f.renderText('Genisys')
print(random.choice(colors) + logo + rs)
print(f'{info}{g} Genisys Adder[USERNAME] V2.5{rs}')
print(f'{info}{g} Author: github.com/Cryptonian007{rs}\n')
def clscreen():
os.system('cls')
clscreen()
banner()
api_id = int(sys.argv[1])
api_hash = str(sys.argv[2])
phone = str(sys.argv[3])
file = str(sys.argv[4])
group = str(sys.argv[5])
class Relog:
def __init__(self, lst, filename):
self.lst = lst
self.filename = filename
def start(self):
with open(self.filename, 'w', encoding='UTF-8') as f:
writer = csv.writer(f, delimiter=",", lineterminator="\n")
writer.writerow(['username', 'user id', 'access hash', 'group', 'group id'])
for user in self.lst:
writer.writerow([user['username'], user['id'], user['access_hash'], user['group'], user['group_id']])
f.close()
def update_list(lst, temp_lst):
count = 0
while count != len(temp_lst):
del lst[0]
count += 1
return lst
users = []
with open(file, encoding='UTF-8') as f:
rows = csv.reader(f, delimiter=',', lineterminator='\n')
next(rows, None)
for row in rows:
user = {}
user['username'] = row[0]
user['user_id'] = row[1]
user['access_hash'] = row[2]
user['group'] = row[3]
user['group_id'] = row[4]
users.append(user)
client = TelegramClient(f'sessions\\{phone}', api_id, api_hash)
client.connect()
time.sleep(1.5)
target_group = client.get_entity(group)
entity = InputPeerChannel(target_group.id, target_group.access_hash)
group_name = target_group.title
print(f'{info}{g} Adding members to {group_name}{rs}\n')
n = 0
added_users = []
for user in users:
n += 1
added_users.append(user)
if n % 50 == 0:
print(f'{sleep}{g} Sleep 2 min to prevent possible account ban{rs}')
time.sleep(120)
try:
if user['username'] == "":
continue
user_to_add = client.get_input_entity(user['username'])
client(InviteToChannelRequest(entity, [user_to_add]))
usr_id = user['user_id']
print(f'{attempt}{g} Adding {usr_id}{rs}')
print(f'{sleep}{g} Sleep 20s{rs}')
time.sleep(20)
except PeerFloodError:
#time.sleep()
os.system(f'del {file}')
sys.exit(f'\n{error}{r} Aborted. Peer Flood Error{rs}')
except UserPrivacyRestrictedError:
print(f'{error}{r} User Privacy Restriction{rs}')
continue
except KeyboardInterrupt:
print(f'{error}{r} Aborted. Keyboard Interrupt{rs}')
update_list(users, added_users)
if not len(users) == 0:
print(f'{info}{g} Remaining users logged to {file}')
logger = Relog(users, file)
logger.start()
except:
print(f'{error}{r} Some Other error in adding{rs}')
continue
#os.system(f'del {file}')
input(f'{info}{g}Adding complete...Press enter to exit...')
sys.exit()