forked from noob-coder123/Genisys
-
Notifications
You must be signed in to change notification settings - Fork 1
/
tsadder.py
203 lines (197 loc) · 6.55 KB
/
tsadder.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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
from telethon.sync import TelegramClient
from telethon.tl.functions.messages import GetDialogsRequest
from telethon.tl.types import InputPeerEmpty, InputPeerChannel
from telethon.errors.rpcerrorlist import PeerFloodError, UserPrivacyRestrictedError, PhoneNumberBannedError
from telethon.tl.functions.channels import InviteToChannelRequest
import sys
from telethon.tl.functions.channels import JoinChannelRequest
import csv
import time
import keyboard
import random
import pyfiglet
from colorama import init, Fore
import os
import pickle
import traceback
'''
try:
import beepy
except ImportError:
if os.name == 'nt':
os.system('pip install beepy')
else:
pass
'''
init()
r = Fore.RED
lg = Fore.GREEN
rs = Fore.RESET
w = Fore.WHITE
cy = Fore.CYAN
ye = Fore.YELLOW
colors = [r, lg, w, ye, cy]
info = lg + '(' + w + 'i' + lg + ')' + rs
error = lg + '(' + r + '!' + lg + ')' + rs
success = w + '(' + lg + '*' + w + ')' + rs
INPUT = lg + '(' + cy + '~' + lg + ')' + rs
plus = lg + '(' + w + '+' + lg + ')' + rs
def banner():
f = pyfiglet.Figlet(font='slant')
logo = f.renderText('Genisys')
print(random.choice(colors) + logo + rs)
print(f'{r} Version: {w}2.5 {r}| Author: {w}Cryptonian{rs}')
def clr():
if os.name == 'nt':
os.system('cls')
else:
os.system('clear')
global scraped_grp
with open('target_grp.txt', 'r') as f:
scraped_grp = f.readline()
f.close()
clr()
banner()
users = []
input_file = 'members\\members.csv'
with open(input_file, 'r', encoding='UTF-8') as f:
reader = csv.reader(f, delimiter=',', lineterminator='\n')
next(reader, None)
for row in reader:
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)
accounts = []
f = open('vars.txt', 'rb')
while True:
try:
accounts.append(pickle.load(f))
except EOFError:
break
print('\n' + info + lg + ' Creating sessions for all accounts...' + rs)
for a in accounts:
iD = int(a[0])
Hash = str(a[1])
phn = str(a[2])
clnt = TelegramClient(f'sessions\\{phn}', iD, Hash)
clnt.connect()
banned = []
if not clnt.is_user_authorized():
try:
clnt.send_code_request(phn)
code = input(f'{INPUT}{lg} Enter code for {w}{phn}{cy}[s to skip]:{r}')
if 's' in code:
accounts.remove(a)
else:
clnt.sign_in(phn, code)
except PhoneNumberBannedError:
print(f'{error}{w}{phn} {r}is banned!{rs}')
banned.append(a)
for z in banned:
accounts.remove(z)
print('\n'+info+lg+'Banned account removed'+rs)
time.sleep(0.5)
clnt.disconnect()
print(info+' Sessions created!')
time.sleep(2)
print(f'{plus}{lg} Enter the exact username of the public group{w}[Without @]')
g = input(f'{INPUT}{lg} Username[Eg: Techmedies_Hub]: {r}')
group = 't.me/' + str(g)
#print('\n')
print(f'{info}{lg} Joining from all accounts...{rs}')
for account in accounts:
api_id = int(account[0])
api_hash = str(account[1])
phone = str(account[2])
client = TelegramClient(f'sessions\\{phone}', api_id, api_hash)
client.connect()
username = client.get_entity(group)
try:
client(JoinChannelRequest(username))
print(f'{success}{lg} Joined from {phone}')
except:
print(f'{error}{r} Error in joining from {phone}')
accounts.remove(account)
client.disconnect()
time.sleep(2)
clr()
number = len(accounts)
print(f'{info}{lg} Total accounts: {w}{number}')
print(f'{info}{lg} If you have more than 10 accounts then it is recommended to use 10 at a time')
a = int(input(f'{plus}{lg} Enter number of accounts to use: {r}'))
to_use = []
print(f'\n{info}{lg} Distributing CSV files...{rs}')
time.sleep(2)
for i in accounts[:a]:
done = []
to_use.append(i)
file = 'members\\members' + str(accounts.index(i)) + '.csv'
with open(file, '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 users[:60]:
writer.writerow([user['username'], user['user_id'], user['access_hash'], user['group'], user['group_id']])
done.append(user)
f.close()
del_count = 0
while del_count != len(done):
del users[0]
del_count += 1
if len(users) == 0:
break
if not len(users) == 0:
with open('members\\members.csv', '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 users:
writer.writerow([user['username'], user['user_id'], user['access_hash'], user['group'], user['group_id']])
f.close()
m = str(len(users))
print(f'{info}{lg} Remaining {m} users stored in {w}members.csv')
for acc in to_use:
accounts.remove(acc)
with open('vars.txt', 'wb') as f:
for acc in accounts:
pickle.dump(acc, f)
for k in to_use:
pickle.dump(k, f)
f.close()
'''
with open('resume.txt', 'w') as f:
f.write(scraped_grp)
f.close()
'''
print(f'{info}{lg} CSV file distribution complete{rs}')
time.sleep(2)
clr()
if not os.name == 'nt':
print(f'{error}{r} Automation supports only Windows systems')
sys.exit()
choice = int(input(f'{plus}{lg} Enter 1 to add by username or 2 to add by id: {r}'))
if choice == 1:
program = 'usradder.py'
else:
program = 'addbyid.py'
o = str(len(to_use))
print(f'\n{info}{r} This will be fully automated.')
print(f'{info}{r} Don\'t touch the keyboard until cmd window pop-up stops')
input(f'\n{plus}{lg} Press enter to continue...{rs}')
print(f'\n{info}{lg} Launching from {o} accounts...{rs}\n')
for i in range(5, 0, -1):
print(random.choice(colors) + str(i) + rs)
time.sleep(1)
for account in to_use:
api_id = str(account[0])
api_hash = str(account[1])
phone = str(account[2])
file = 'members\\members' + str(to_use.index(account)) + '.csv'
os.system('start cmd')
time.sleep(1.5)
keyboard.write('python' + ' ' + program + ' ' + api_id + ' ' + api_hash + ' ' + phone + ' ' + file + ' ' + group + ' ' + str(scraped_grp))
keyboard.press_and_release('Enter')
print(f'{plus}{lg} Launched from {phone}')
#beepy.beep(sound='ping')