forked from kshubham506/vcplayerbot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Config.py
141 lines (113 loc) · 4.9 KB
/
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
from dotenv import dotenv_values
import argparse
import os
from utils.Singleton import Singleton
class Config(metaclass=Singleton):
def getCLIParser(self):
parser = argparse.ArgumentParser()
parser.add_argument(
"-env", "--Environment", help="[optional]Provide environment (local/prod)"
)
return parser
def __init__(self) -> None:
self.args = self.getCLIParser().parse_args()
if self.args.Environment == "prod":
self.config = {
**dotenv_values(".env"),
**os.environ,
}
self.config["env"] = "prod"
else:
self.config = {
**dotenv_values(".env.local"),
**os.environ,
}
self.config["env"] = "local"
self.config["source"] = "tgcalls"
self.config["server"] = "tgserver-beta"
self.config["ALLOWED_CHAT_TYPES"] = [
"channel",
"groups",
"group",
"supergroup",
"supergroups",
"megagroup",
]
## no need to modify these
if "BOT_URL" not in self.config or not self.config["BOT_URL"]:
self.config["BOT_URL"] = "https://t.me/vcplayerbot"
if "PARENT_URL" not in self.config or not self.config["PARENT_URL"]:
self.config["PARENT_URL"] = "https://t.me/sktechhub"
if "SUPPORT_GROUP" not in self.config or not self.config["SUPPORT_GROUP"]:
self.config["SUPPORT_GROUP"] = "https://t.me/voicechatsupport"
if "GITHUB_REPO" not in self.config or not self.config["GITHUB_REPO"]:
self.config["GITHUB_REPO"] = "https://github.com/kshubham506/vcplayerbot"
self.config["SUDO_USER"] = [563365858]
self.config["PROMOTIONAL_DATA"] = {}
"""
The below values you can specify as env variables or modify here directly
"""
# number which dentores how many simultaneous playbacks can run
if (
"SIMULTANEOUS_CALLS" not in self.config
or not self.config["SIMULTANEOUS_CALLS"]
):
self.config["SIMULTANEOUS_CALLS"] = 5
# text to add at footer of each play message (if any)
if "PLAYBACK_FOOTER" not in self.config:
self.config["PLAYBACK_FOOTER"] = ""
# number of songs that can be added to queue
if "PLAYLIST_SIZE" not in self.config or not self.config["PLAYLIST_SIZE"]:
self.config["PLAYLIST_SIZE"] = 10
# max duration for any song/video
if (
"ALLOWED_SONG_DURATION_IN_SEC" not in self.config
or not self.config["ALLOWED_SONG_DURATION_IN_SEC"]
):
self.config["ALLOWED_SONG_DURATION_IN_SEC"] = 13 * 60
# readme file/url listing steps to generate session string
if (
"SESSION_STRING_STEPS" not in self.config
or not self.config["SESSION_STRING_STEPS"]
):
self.config[
"SESSION_STRING_STEPS"
] = "https://github.com/kshubham506/vcplayerbot/blob/master/get_session_string.md"
# minimum number of members required to access the bot
if "MIN_MEMBERS_REQUIRED" not in self.config:
self.config["MIN_MEMBERS_REQUIRED"] = 0
# default value for new chat: ALLOW_VIDEO
if "ALLOW_VIDEO" not in self.config:
self.config["ALLOW_VIDEO"] = True
# default value for new chat: ALLOW_AUDIO
if "ALLOW_AUDIO" not in self.config:
self.config["ALLOW_AUDIO"] = True
# default value for new chat: ALLOW_OTHERS
if "ALLOW_YOUTUBE" not in self.config:
self.config["ALLOW_YOUTUBE"] = True
# default value for new chat: ALLOW_OTHERS
if "ALLOW_OTHERS" not in self.config:
self.config["ALLOW_OTHERS"] = True
# default value for new chat: MAX_VIDEO_RES
if "MAX_VIDEO_RES" not in self.config:
self.config["MAX_VIDEO_RES"] = 1920
# default value for new chat: MAX_AUDIO_RES
if "MAX_AUDIO_RES" not in self.config:
self.config["MAX_AUDIO_RES"] = 1920
# default value for new chat: ALLOW_REPEAT
if "ALLOW_REPEAT" not in self.config:
self.config["ALLOW_REPEAT"] = True
# should other group be able to add the bot and use it
# 0 - False , 1 - True
if "ALLOW_MULTIPLE_CHATS" not in self.config:
self.config["ALLOW_MULTIPLE_CHATS"] = 1
def get(self, key):
return self.config.get(key)
def getAll(self):
return self.config
def setExtraData(self, key, value):
self.config[key] = value
def setBotId(self, value):
self.config["BOT_ID"] = value
def setBotUsername(self, value):
self.config["BOT_USERNAME"] = value