-
-
Notifications
You must be signed in to change notification settings - Fork 46
/
make_config.py
167 lines (155 loc) · 5.99 KB
/
make_config.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
import csv
import json
import re
from pathlib import Path
from init import rs, w, r, banner, clr, lg
clr()
banner()
print(f" {r}Version: {w}3.1 {r}| Author: {w}SAIF ALI{rs}\n")
print(f" {r}Telegram {w}@DearSaif {r}| Instagram: {w}@_Prince.Babu_{rs}\n")
print(
f" {r}For Get Your Group ID Add {w}@MissCutieRobot {r}To Your Group And Send /id In Your Group After Get Your Group ID Remove -100 From Your Group ID Before Enter In Script\n"
)
def check_num(phone):
"""Parses the given phone, or returns None if it's invalid."""
if isinstance(phone, int):
return str(phone)
else:
phone = re.sub(r"[+()\s-]", "", str(phone))
if phone.isdigit():
return phone
DEFAULT_API_ID = 25194789
DEFAULT_API_HASH = "e59afe25c17585635ec031c889eb5b34"
DEFAULT = "UserStatus.RECENTLY"
OPTIONS = (
"UserStatus.LAST_MONTH",
"UserStatus.LAST_WEEK",
"UserStatus.OFFLINE",
"UserStatus.RECENTLY",
"UserStatus.ONLINE",
)
config_path = Path("config.json")
delay = int(input(f" {lg}Enter Delay Timing For Per Member Adding : {w}"))
group_source = input(
"Enter The Group ID Of The Group From Which The Members Have To Be Scraped : "
)
group_target = input(
"Enter The Group ID Of The Group In Which The Member Is To Be Added : "
)
group_source_username = input(
"Enter The Username Of The Group From Which The Members Have To Be Scraped : "
)
if "+" in group_source_username:
pass
else:
group_source_username = re.sub(
"(@)|(https://t.me/)|(http://t.me/)", "", group_source_username
)
group_target_username = input(
"Enter The Username Of The Group In Which The Member Is To Be Added : "
)
if "+" in group_target_username:
pass
else:
group_target_username = re.sub(
"(@)|(https://t.me/)|(http://t.me/)", "", group_target_username
)
choice = input(
f"\n\nType YES To Add API And HASH Manually\nType NO To Use Default One From Telegram Public API:> "
).lower()
def main():
# for _ in range(n):
if choice[0] == "n":
with open("phone.csv", "r") as f:
str_list = [row[0] for row in csv.reader(f)]
po = 0
if str_list:
config = {
"group_source": group_source,
"group_target": group_target,
"group_source_username": group_source_username,
"group_target_username": group_target_username,
"from_date_active": DEFAULT,
"auto_join": True,
"spam_check": True,
"wait_time": delay,
"accounts": [],
}
for phone in str_list:
phone = check_num(phone)
po += 1
print(
f"{phone} Added To Config Run python login.py To Login Your Accounts"
)
new_account = {
"phone": phone,
"api_id": DEFAULT_API_ID,
"api_hash": DEFAULT_API_HASH,
}
config["accounts"].append(new_account)
else:
if config_path.exists():
with open(config_path, "r", encoding="utf-8") as file:
config = json.load(file)
else:
config = {
"group_source": group_source,
"group_target": group_target,
"group_source_username": group_source_username,
"group_target_username": group_target_username,
"from_date_active": DEFAULT,
"auto_join": True,
"spam_check": True,
"wait_time": delay,
"accounts": [],
}
count = int(input("How Many Numbers You Want To Add : "))
while count > 0:
phon = input("Enter Your Number With Country Code : ")
phone = check_num(phon)
print(
f"{phone} Added To Config Path Now Run python login.py To Login Your Accounts"
)
new_account = {
"phone": phone,
"api_id": DEFAULT_API_ID,
"api_hash": DEFAULT_API_HASH,
}
config["accounts"].append(new_account)
count -= 1
with open(config_path, "w", encoding="utf-8") as file:
json.dump(config, file, indent=4)
elif choice[0] == "y":
count = int(input("How Many Numbers You Want To Add : "))
if config_path.exists():
with open(config_path, "r", encoding="utf-8") as file:
config = json.load(file)
else:
config = {
"group_source": group_source,
"group_target": group_target,
"group_source_username": group_source_username,
"group_target_username": group_target_username,
"from_date_active": DEFAULT,
"auto_join": True,
"spam_check": True,
"wait_time": delay,
"accounts": [],
}
count = int(input("How Many Numbers You Want To Add : "))
while count > 0:
phon = input("Enter Your Number With Country Code : ")
phone = check_num(phon)
apiid = int(input("Enter Your API_ID : "))
hashid = input("Enter Your API_HASH : ")
print(
f"{phone} Added To Config Path Run python login.py To Login Your Accounts"
)
new_account = {"phone": phone, "api_id": apiid, "api_hash": hashid}
config["accounts"].append(new_account)
count -= 1
with open(config_path, "w", encoding="utf-8") as file:
json.dump(config, file, indent=4)
else:
print("wrong option use YES / NO")
main()