This repository has been archived by the owner on May 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
56 lines (49 loc) · 1.82 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
48
49
50
51
52
53
54
55
56
# 此项目遵循 Mirai 使用的 AGPL-3.0 协议仍然保持开源并继续使用 AGPL-3.0
# 如果您需要在此项目的基础上改动那么我强烈建议:
# - 保持开源
# - 使用 AGPL-3.0 协议
# - 注明使用了 Mirai 并其源代码来自此仓库
import os
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 lib_not_dr.logger.logger import Logger
import botfunc
import databases
logger = Logger.get_logger_by_name("intro")
# 创建数据库
databases.database_create()
saya = create(Saya)
app = Ariadne(
connection=config(
botfunc.get_config('qq'),
botfunc.get_config('verifyKey'),
HttpClientConfig(host=botfunc.get_config('mirai_api_http')),
WebsocketClientConfig(host=botfunc.get_config('mirai_api_http')),
),
)
with saya.module_context():
for root, dirs, files in os.walk("./modules", topdown=False):
for name in files:
module = os.path.join(root, name).replace('\\', '.').replace('./', '').replace('/', '.').split('.')
if '__pycache__' in module:
continue
if module[1] == 'NO_USE':
continue
if module[1] == 'Beta_Channel':
continue
module = '.'.join(module)[:-3]
logger.info(f'{module} 将被载入')
saya.require(module)
for module, channel in saya.channels.items():
logger.info(f"module: {module}")
logger.info(f"name: {channel.meta['name']}")
logger.info(f"author: {' '.join(channel.meta['author'])}")
logger.info(f"description: {channel.meta['description']}")
logger.success('恭喜!启动成功,0Error,至少目前如此,也祝你以后如此')
app.launch_blocking()