-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
78 lines (61 loc) · 2.88 KB
/
main.py
File metadata and controls
78 lines (61 loc) · 2.88 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
72
73
74
75
76
77
78
from Source.TeleBotAdminPanel import Panel, Modules
from Source.Functions import SendStub
from dublib.Methods.System import CheckPythonMinimalVersion
from dublib.TelebotUtils.Cache import TeleCache
from dublib.Engine.Configurator import Config
from dublib.TelebotUtils import UsersManager
from dublib.TelebotUtils import TeleMaster
from dublib.Methods.Data import Zerotify
from dotenv import load_dotenv
from telebot import types
#==========================================================================================#
# >>>>> ИНИЦИАЛИЗАЦИЯ <<<<< #
#==========================================================================================#
CheckPythonMinimalVersion(3, 10)
load_dotenv()
Settings = Config("Settings.json")
Settings.load()
MasterBot = TeleMaster(Settings["bot_token"])
Bot = MasterBot.bot
Manager = UsersManager("Data/Users", threads = Settings["users_manager_threads"])
Cacher = TeleCache()
Cacher.set_bot(Bot)
Cacher.set_chat_id(Settings["cacher_chat_id"])
#==========================================================================================#
# >>>>> НАСТРОЙКА ПАНЕЛИ УПРАВЛЕНИЯ <<<<< #
#==========================================================================================#
AdminPanel = Panel(Bot, Manager, Settings["password"])
TBAP_TREE = {
"📊 Статистика": Modules.SM_Statistics,
"✉️ Рассылка": Modules.SM_Mailing,
"❌ Закрыть": Modules.SM_Close
}
AdminPanel.set_tree(TBAP_TREE)
#==========================================================================================#
# >>>>> ОБРАБОТКА СОБЫТИЙ <<<<< #
#==========================================================================================#
@Bot.message_handler(commands = ["admin"])
def Command(Message: types.Message):
User = Manager.auth(Message.from_user)
Password = Message.text.split(" ")[1:]
Password = " ".join(Password).strip()
Password = Zerotify(Password)
if not AdminPanel.login(User, Password): Bot.send_message(User.id, "Доступ запрещён.")
else: Bot.send_message(User.id, "Панель управления открыта.", reply_markup = AdminPanel.open(User))
@Bot.message_handler(content_types = ["text"])
def TextHandler(message: types.Message):
User = Manager.auth(message.from_user)
if AdminPanel.procedures.text(message): return
SendStub(Settings, Cacher, Bot, User)
AdminPanel.decorators.inline_keyboards()
@Bot.callback_query_handler()
def CallbackHandler(call: types.CallbackQuery):
User = Manager.auth(call.message.from_user)
Bot.answer_callback_query(call.id)
SendStub(Settings, Cacher, Bot, User)
@Bot.message_handler(content_types = ["animation", "audio", "document", "photo", "video"])
def AttachmentHandler(Message: types.Message):
User = Manager.auth(Message.from_user)
if AdminPanel.procedures.attachments(Message): return
SendStub(Settings, Cacher, Bot, User)
Bot.infinity_polling()