forked from LateNightKid/telegram-bot-for-outline-vpn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsettings.py
51 lines (34 loc) · 1.56 KB
/
settings.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
from helpers.classes import OutlineServer
import json
JSON_FILENAME = "settings.json"
with open(JSON_FILENAME, 'r') as file:
settings = json.load(file)
_tg_settings = settings['tg_bot_settings']
_outline_dl_links = settings['outline_dl_links']
BOT_API_TOKEN = _tg_settings['main_bot_api_token']
MONITOR_API_TOKEN = _tg_settings['monitor_bot_api_token']
ADMIN_CHAT_ID = _tg_settings['admin_chat_id']
DEFAULT_SERVER_ID = _tg_settings['default_server_id']
ENABLE_BLACKLIST = _tg_settings['enable_blacklist']
ENABLE_WHITELIST = _tg_settings['enable_whitelist']
BLACKLISTED_CHAT_IDS = _tg_settings['blacklisted_chat_ids']
WHITELISTED_CHAT_IDS = _tg_settings['whitelisted_chat_ids']
OUTLINE_WINDOWS_DOWNLOAD_LINK = _outline_dl_links['windows']
OUTLINE_MACOS_DOWNLOAD_LINK = _outline_dl_links['macos']
OUTLINE_LINUX_DOWNLOAD_LINK = _outline_dl_links['linux']
OUTLINE_CHOMEOS_DOWNLOAD_LINK = _outline_dl_links['chromeos']
OUTLINE_IOS_DOWNLOAD_LINK = _outline_dl_links['android']
OUTLINE_ANDROID_DOWNLOAD_LINK = _outline_dl_links['android']
OUTLINE_ANDROID_APK_DOWNLOAD_LINK = _outline_dl_links['apk']
def _read_outline_servers_from_settings() -> dict[str, OutlineServer]:
servers = {}
for server in settings['outline_servers']:
if server['is_enabled']:
id = server['id']
srv = OutlineServer(
api_url=server.get('api_url'),
location=server.get('location'),
is_enabled=True)
servers[id] = srv
return servers
servers = _read_outline_servers_from_settings()