-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain_controller.py
More file actions
executable file
·45 lines (36 loc) · 1.42 KB
/
Copy pathmain_controller.py
File metadata and controls
executable file
·45 lines (36 loc) · 1.42 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
### Main goals of the Minimal branch is to cut out all unnecessary code and make the bot as lightweight as possible.
### TODO: Remove all example mods and integrate critical mods and tools into the base TelegramHandler class
from initial import Initial
from config import *
from plugins.motd.motd_controller import motd_handler, motd_commands
import asyncio
from telegram_handler import Bot
base = Initial()
base.startup_time()
# this function is the message handler. every command is hardcoded for both private and group chats
async def webapi_handler(q, admin):
async for item in base.feed(q):
try:
# callbacks
if base.bot.is_callback(item):
pass
# messages
if admin:
if base.bot.get_chat_id(item) == ADMIN:
if base.get(item) in motd_commands:
await motd_handler(item)
else:
await command_cycle(item)
elif not admin:
await command_cycle(item)
except Exception as e:
print(e)
async def command_cycle(data):
if base.get(data) == '/debug':
await base.send(data, 'Ping')
elif base.get(data).startswith('/bal'):
pass
# await send(data, motd.balance)
loop2 = asyncio.get_event_loop()
loop2.create_task(base.bot.loop_void(queue=base.queue, data_resolver=webapi_handler))
loop2.run_forever()