forked from DenizShabani/telegramscraper
-
Notifications
You must be signed in to change notification settings - Fork 1
/
manager.py
168 lines (161 loc) · 5.62 KB
/
manager.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
import requests
from telethon.sync import TelegramClient
from telethon.errors.rpcerrorlist import PhoneNumberBannedError
import pickle, pyfiglet
from colorama import init, Fore
import os, random
from time import sleep
init()
lg = Fore.LIGHTGREEN_EX
w = Fore.WHITE
cy = Fore.CYAN
ye = Fore.YELLOW
r = Fore.RED
n = Fore.RESET
colors = [lg, r, w, cy, ye]
def banner():
f = pyfiglet.Figlet(font='slant')
banner = f.renderText('Telegram')
print(f'{random.choice(colors)}{banner}{n}')
print(r+' Version: 1.1 | Author: Shabani'+n+'\n')
def clr():
if os.name == 'nt':
os.system('cls')
else:
os.system('clear')
while True:
clr()
#print(r)
banner()
#print(n)
print(lg+'[1] Add new accounts'+n)
print(lg+'[2] Filter all banned accounts'+n)
print(lg+'[3] List out all the accounts'+n)
print(lg+'[4] Delete specific accounts'+n)
#print(lg+'[5] Update your Genisys'+n)
print(lg+'[5] Quit')
a = int(input(f'\nEnter your choice: {r}'))
if a == 1:
with open('vars.txt', 'ab') as g:
newly_added = []
while True:
a = int(input(f'\n{lg}Enter API ID: {r}'))
b = str(input(f'{lg}Enter API Hash: {r}'))
c = str(input(f'{lg}Enter Phone Number: {r}'))
p = ''.join(c.split())
pickle.dump([a, b, p], g)
newly_added.append([a, b, p])
ab = input(f'\nDo you want to add more accounts?[y/n]: ')
if 'y' in ab:
pass
else:
print('\n'+lg+'[i] Saved all accounts in vars.txt'+n)
g.close()
sleep(3)
clr()
print(lg + '[*] Logging in from new accounts...\n')
for added in newly_added:
c = TelegramClient(f'sessions/{added[2]}', added[0], added[1])
try:
c.start()
print(f'n\n{lg}[+] Logged in - {added[2]}')
c.disconnect()
except PhoneNumberBannedError:
print(f'{r}[!] {added[2]} is banned! Filter it using option 2')
continue
print('\n')
input(f'\n{lg}Press enter to goto main menu...')
break
g.close()
elif a == 2:
accounts = []
banned_accs = []
h = open('vars.txt', 'rb')
while True:
try:
accounts.append(pickle.load(h))
except EOFError:
break
h.close()
if len(accounts) == 0:
print(r+'[!] There are no accounts! Please add some and retry')
sleep(3)
else:
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()
if not client.is_user_authorized():
try:
client.send_code_request(phone)
client.sign_in(phone, input('[+] Enter the code: '))
except PhoneNumberBannedError:
print(r+str(phone) + ' is banned!'+n)
banned_accs.append(account)
if len(banned_accs) == 0:
print(lg+'Congrats! No banned accounts')
input('\nPress enter to goto main menu')
else:
for m in banned_accs:
accounts.remove(m)
with open('vars.txt', 'wb') as k:
for a in accounts:
Id = a[0]
Hash = a[1]
Phone = a[2]
pickle.dump([Id, Hash, Phone], k)
k.close()
print(lg+'[i] All banned accounts removed'+n)
input('\nPress enter to goto main menu')
elif a == 3:
display = []
j = open('vars.txt', 'rb')
while True:
try:
display.append(pickle.load(j))
except EOFError:
break
j.close()
print(f'\n{lg}')
print(f'API ID | API Hash | Phone')
print(f'==========================================================')
i = 0
for z in display:
print(f'{z[0]} | {z[1]} | {z[2]}')
i += 1
print(f'==========================================================')
input('\nPress enter to goto main menu')
elif a == 4:
accs = []
f = open('vars.txt', 'rb')
while True:
try:
accs.append(pickle.load(f))
except EOFError:
break
f.close()
i = 0
print(f'{lg}[i] Choose an account to delete\n')
for acc in accs:
print(f'{lg}[{i}] {acc[2]}{n}')
i += 1
index = int(input(f'\n{lg}[+] Enter a choice: {n}'))
phone = str(accs[index][2])
session_file = phone + '.session'
if os.name == 'nt':
os.system(f'del sessions\\{session_file}')
else:
os.system(f'rm sessions/{session_file}')
del accs[index]
f = open('vars.txt', 'wb')
for account in accs:
pickle.dump(account, f)
print(f'\n{lg}[+] Account Deleted{n}')
input(f'{lg}Press enter to goto main menu{n}')
f.close()
elif a == 5:
clr()
banner()
quit()