-
Notifications
You must be signed in to change notification settings - Fork 0
/
SchoolHelper.py
58 lines (41 loc) · 1.79 KB
/
SchoolHelper.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
# -*- coding: utf-8 -*-
from datetime import datetime
from threading import Thread
from config import Main
from commands import Command
from keyboard import Keyboard
from tasks.rules import Rule
from all_json_data import *
@Main.BOT.message_handler(content_types=["text"])
def get_message(message):
print("%s : %s : %s" % (datetime.now(), message.chat.id, message.text))
Command.get_answer(message.chat.id, message.text)
@Main.BOT.callback_query_handler(func=lambda call: True)
def query_handler(call):
chat_id = call.message.chat.id
message_id = call.message.message_id
call_data = call.data.split("/")
print("%s : %s : %s" % (datetime.now(), chat_id, call_data))
if not chat_id in Main.USER_LIST:
Main.USER_LIST[chat_id] = {"dir": "menu"}
try:
if call_data[0] == "menu":
Keyboard.menu_keyboard(chat_id, None, message_id)
elif call_data[0] == "admin":
admin_commands[call_data[1]](chat_id)
elif call_data[0] == "rules":
if len(call_data) <= 2:
Keyboard.rules_keyboard(chat_id, call_data, message_id)
else:
send_rule = Rule()
Thread(target=send_rule.send_file, args=(chat_id, call_data)).start()
elif call_data[0] in all_lessons and len(call_data) == 1:
Keyboard.lesson_keyboard(chat_id, call_data[0], message_id)
elif call_data[1] in all_lessons[call_data[0]]["more"]:
Main.USER_LIST[chat_id]["dir"] = "/".join(call_data)
all_lessons[call_data[0]]["more"][call_data[1]]["func"](chat_id)
except Exception as error:
print(error)
if __name__ == "__main__":
Main.START_TIME = datetime.now()
Main.BOT.polling(none_stop=True)