forked from FoxUserbot/FoxUserbot
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathconfigurator.py
More file actions
71 lines (54 loc) · 2.21 KB
/
configurator.py
File metadata and controls
71 lines (54 loc) · 2.21 KB
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
import os
import sys
import configparser
# default values (TDesktop)
config_id = "2040"
config_hash = "b18441a1ff607e10a989891a5462e627"
config_model = "FoxUserbot"
PATH_FILE = "userdata/config.ini"
config = configparser.ConfigParser()
config.read(PATH_FILE)
def api():
get_id = config.get("pyrogram", "api_id")
get_hash = config.get("pyrogram", "api_hash")
get_device_model = config.get("pyrogram", "device_model")
return get_id, get_hash, get_device_model
def update_api(api_id, api_hash):
# old variable (not work)
old_config_id = ["2860432", "29679445"]
old_config_hash = ["2fde6ca0f8ae7bb58844457a239c7214", "e656a7489649d542ceb3c326f54345ba"]
config_changed = False
if str(api_id) in old_config_id:
api_id_temp = api_id
api_id = config_id
config.set("pyrogram", "api_id", config_id)
config_changed = True
print(f"Updated API ID from {api_id_temp} to {config_id}")
if api_hash in old_config_hash:
api_hash_temp = api_hash
api_hash = config_hash
config.set("pyrogram", "api_hash", config_hash)
config_changed = True
print(f"Updated API Hash from {api_hash_temp} to {config_hash}")
if config_changed:
with open(PATH_FILE, "w") as config_file:
config.write(config_file)
print("Config file updated successfully!")
return api_id, api_hash
def my_api():
try:
api_id, api_hash, device_model = api()
api_id, api_hash = update_api(api_id, api_hash)
except (configparser.NoSectionError, configparser.NoOptionError):
if not config.has_section("pyrogram"):
config.add_section("pyrogram")
config.set("pyrogram", "api_id", config_id)
config.set("pyrogram", "api_hash", config_hash)
config.set("pyrogram", "device_model", config_model)
with open(PATH_FILE, "w") as config_file:
config.write(config_file)
api_id = config_id
api_hash = config_hash
device_model = config_model
print(f"Not found config.ini\nGenerating new...")
return api_id, api_hash, device_model