forked from SAGIRI-kawaii/saya_plugins_collection
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
47 lines (38 loc) · 1.07 KB
/
main.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
import asyncio
import os
from graia.saya import Saya
from graia.broadcast import Broadcast
from graia.saya.builtins.broadcast import BroadcastBehaviour
from graia.application import GraiaMiraiApplication, Session
from utils import load_config
loop = asyncio.get_event_loop()
bcc = Broadcast(loop=loop)
saya = Saya(bcc)
saya.install_behaviours(BroadcastBehaviour(bcc))
configs = load_config()
app = GraiaMiraiApplication(
broadcast=bcc,
connect_info=Session(
host=configs["miraiHost"],
authKey=configs["authKey"],
account=configs["BotQQ"],
websocket=True
)
)
ignore = ["__init__.py", "__pycache__"]
with saya.module_context():
for module in os.listdir("modules"):
if module in ignore:
continue
try:
if os.path.isdir(module):
saya.require(f"modules.{module}")
else:
saya.require(f"modules.{module.split('.')[0]}")
except ModuleNotFoundError:
pass
app.launch_blocking()
try:
loop.run_forever()
except KeyboardInterrupt:
exit()