forked from AmiyaBot/Amiya-Bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathamiya.py
48 lines (36 loc) · 1.03 KB
/
amiya.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
import asyncio
import functions
from core.network.httpServer import HttpServer
from core.control import StateControl
from core.util import read_yaml
from core.bot import BotHandlers
from core import log, init_core
BotHandlers.add_prefix(
read_yaml('config/private/talking.yaml').call.positive
)
class AmiyaBot:
def __init__(self):
log.info(
[
f'starting Amiya-Bot...',
f'%d function module(s) loaded.' % len([f for f in dir(functions) if f.startswith('__')])
] + BotHandlers.detail()
)
StateControl.start()
self.tasks = init_core()
async def run(self):
await asyncio.wait(self.tasks)
log.info('AmiyaBot shutdown.')
async def bot_run_forever():
while StateControl.keep_running:
await AmiyaBot().run()
if __name__ == '__main__':
console_server = HttpServer()
asyncio.run(
asyncio.wait(
[
bot_run_forever(),
console_server.serve()
]
)
)