-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
161 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"token": "{TELEGRAM_BOT_TOKEN}", | ||
"target": "{GROUP_OR_CHANNEL_ID}", | ||
"clean-tags": true, | ||
"parse-mode": null, | ||
"disable-web-page-preview": true, | ||
"blacklist": [], | ||
"attachments": { | ||
"doc": true, | ||
"photo": true, | ||
"video": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
from dublib.Methods import ReadJSON | ||
|
||
import os | ||
|
||
# Менеджер конфигураций. | ||
class Configurator: | ||
|
||
# Читает конфигурации. | ||
def __ReadConfigs(self) -> dict: | ||
# Список файлов в директории конфигурации. | ||
FilesList = os.listdir("Config") | ||
# Фильтрация только файлов формата JSON. | ||
FilesList = list(filter(lambda x: x.endswith(".json"), FilesList)) | ||
# Словарь конфигураций. | ||
Configurations = dict() | ||
|
||
# Удаление примера. | ||
if "Example.json" in FilesList: | ||
FilesList.remove("Example.json") | ||
|
||
# Для каждого файла конфигурации. | ||
for Filename in FilesList: | ||
# Прочитать конфигурацию в словарь. | ||
Configurations[Filename.replace(".json", "")] = ReadJSON("Config/" + Filename) | ||
|
||
return Configurations | ||
|
||
# Конструктор. | ||
def __init__(self): | ||
|
||
#---> Генерация динамических свойств. | ||
#==========================================================================================# | ||
# Словарь конфигураций. | ||
self.__Configurations = self.__ReadConfigs() | ||
|
||
# Возвращает настройки вложений. | ||
def getAttachments(self, ConfigName: str) -> dict: | ||
return self.__Configurations[ConfigName]["attachments"] | ||
|
||
# Возвращает настройки в конфигурации. | ||
def getConfig(self, ConfigName: str) -> dict: | ||
return self.__Configurations[ConfigName] | ||
|
||
# Возвращает список конфигураций. | ||
def getConfigsNames(self) -> list[str]: | ||
return list(self.__Configurations.keys()) | ||
|
||
# Возвращает токен для указанной конфигурации. | ||
def getToken(self, ConfigName: str) -> str: | ||
return self.__Configurations[ConfigName]["token"] | ||
|
||
# Возвращает список токенов ботов. | ||
def getTokens(self): | ||
# Список токенов. | ||
TokensList = list() | ||
|
||
# Для каждого элемента записать токен. | ||
for Config in self.__Configurations.values: | ||
TokensList.append(Config["token"]) | ||
|
||
return TokensList |
Oops, something went wrong.