-
Notifications
You must be signed in to change notification settings - Fork 23
/
bot.py
55 lines (49 loc) · 1.43 KB
/
bot.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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
from pathlib import Path
import nonebot
from nonebot.adapters.onebot.v11 import Adapter as ONEBOT_V11Adapter
from nonebot.log import default_format, logger
nonebot.init()
app = nonebot.get_asgi()
driver = nonebot.get_driver()
driver.register_adapter(ONEBOT_V11Adapter)
config = nonebot.get_driver().config
config.nb2_path = Path(__file__).parent
if __name__ == '__mp_main__' or ('run' in sys.argv and 'nb' in sys.argv[0]):
logger.add(
'logs/error.log',
rotation='00:00',
retention='1 week',
diagnose=False,
level='ERROR',
format=default_format,
encoding='utf-8',
)
logger.add(
'logs/info.log',
rotation='00:00',
retention='1 week',
diagnose=False,
level='INFO',
format=default_format,
encoding='utf-8',
)
logger.add(
'logs/warning.log',
rotation='00:00',
retention='1 week',
diagnose=False,
level='WARNING',
format=default_format,
encoding='utf-8',
)
if driver.config.use_plugin_go_cqhttp:
nonebot.load_plugin('nonebot_plugin_gocqhttp')
nonebot.load_from_toml('pyproject.toml')
# ...
if __name__ == '__main__':
# logger.warning("Always use `nb run` to start the bot instead of manually running!")
nonebot.load_plugin('nonebot_plugin_reboot')
nonebot.run(app='__mp_main__:app')