-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
43 lines (34 loc) · 1.01 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
'''bot主文件'''
from pathlib import Path
import pkgutil
from creart import create
from graia.ariadne.app import Ariadne
from graia.ariadne.connection.config import (
HttpClientConfig,
WebsocketClientConfig,
config,
)
from graia.saya import Saya
from arclet.alconna.graia.saya import AlconnaBehaviour, AlconnaSchema
from arclet.alconna.graia import Match, AlconnaDispatcher
from arclet.alconna import Alconna
import json5
saya = create(Saya)
create(AlconnaBehaviour)
with open(Path(__file__).parent / 'account.json', 'r', encoding='utf-8') as f:
account = json5.load(f)
qq = account['qq']
verify_key = account['verify_key']
port = account['port']
bot = Ariadne(
connection=config(
int(qq),
verify_key,
HttpClientConfig(host=f"http://localhost:{port}"),
WebsocketClientConfig(host=f"http://localhost:{port}"),
)
)
with saya.module_context():
for module in pkgutil.iter_modules(['modules']):
saya.require(f'modules.{module.name}')
bot.launch_blocking()