-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathContactAdmins.py
56 lines (47 loc) · 1.76 KB
/
ContactAdmins.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
#! C:\Users\kosha\AppData\Local\Programs\Python\Python39\python.exe
from telethon.sessions import StringSession
from scrapers.clients import *
from scrapers.functions import *
import argparse
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument("--csvs", help="list of csv files", nargs="+", type=str)
parser.add_argument("--numbers", help="bot numbers", nargs="+", type=str)
args = parser.parse_args()
csvs = args.csvs
bots = args.numbers
bot = 0
with open('session_ids.csv') as f:
str_sessions_tuple = list()
lines = f.readlines()
for line in lines[1:]:
x = line.split(',')
str_sessions_tuple.append((x[-2].rstrip().replace(' ', ''), x[-1].rstrip()))
ph_dict = dict(str_sessions_tuple)
status = pd.read_csv('status.csv')
break_loop = False
for i, row in status.iterrows():
csv = row['file_name']
if csv not in csvs:
continue
file = 'splits/' + csv
start = 0
f = False
df = pd.read_csv(file)
while not f:
if bot == len(bots):
break_loop = True
break
number = bots[bot].replace(' ', '')
session_str = ph_dict[bots[bot].replace(' ', '')]
cl = TGClient(StringSession(session_str), api_id, api_hash)
df, f, start, _ = contact_admins(df, cl, start, session_str)
status['sender_no'].iloc[i] = ('' if pd.isna(row['sender_no']) else row['sender_no'] + ';') + bots[bot]
if not f:
bot += 1
df.to_csv('splits/' + csv, index=False)
bot += 1
if break_loop:
break
status['status'].iloc[i] = True
status.to_csv('status.csv', index=False)