-
Notifications
You must be signed in to change notification settings - Fork 18
/
BanFilter.py
69 lines (48 loc) · 1.85 KB
/
BanFilter.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
from telethon.sync import TelegramClient
from telethon import utils
from telethon.errors.rpcerrorlist import PhoneNumberBannedError
import csv
import configparser
config = configparser.ConfigParser()
config.read("config.ini")
export_phone = config['Telegram']['export_phone']
export_api_id = config['Telegram']['export_api_id']
export_api_hash = config['Telegram']['export_api_hash']
from_group = config['Telegram']['from_channel']
api_id = int(export_api_id)
api_hash = str(export_api_hash)
MadeByDeltaXd = []
done = False
with open('phone.csv', 'r') as f:
str_list = [row[0] for row in csv.reader(f)]
po = 0
for unparsed_phone in str_list:
po += 1
phone = utils.parse_phone(unparsed_phone)
print(f"Login {phone}")
client = TelegramClient(f"sessions/{phone}", api_id, api_hash)
#client.start(phone)
client.connect()
if not client.is_user_authorized():
try:
print('This Phone Has Been Revoked')
delta_xd = str(po)
delta_op = str(unparsed_phone)
MadeByDeltaXd.append(delta_xd+' - '+delta_op)
continue
except PhoneNumberBannedError:
print('Ban')
delta_xd = str(po)
delta_op = str(unparsed_phone)
MadeByDeltaXd.append(delta_xd+' - '+delta_op)
continue
#client.disconnect()
print()
done = True
print('List Of Banned Numbers')
print(*MadeByDeltaXd,sep='\n')
print('Saved In BanNumers.csv')
with open('BanNumbers.csv', 'w', encoding='UTF-8') as writeFile:
writer = csv.writer(writeFile, delimiter=",", lineterminator="\n")
writer.writerows(MadeByDeltaXd)
input("Done!" if done else "Error!")