2020-06-30 10:13:58 +08:00
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
|
2020-07-04 22:51:10 +08:00
|
|
|
sys.path.insert(0, os.path.abspath(".."))
|
2020-06-30 10:13:58 +08:00
|
|
|
|
|
|
|
import nonebot
|
2021-09-28 20:56:05 +08:00
|
|
|
from nonebot.log import logger, default_format
|
2020-12-03 00:59:32 +08:00
|
|
|
from nonebot.adapters.ding import Bot as DingBot
|
2021-02-01 16:37:42 +08:00
|
|
|
from nonebot.adapters.mirai import Bot as MiraiBot
|
2021-07-03 13:53:01 +08:00
|
|
|
from nonebot.adapters.feishu import Bot as FeishuBot
|
2020-08-29 21:59:36 +08:00
|
|
|
|
|
|
|
# test custom log
|
2021-11-22 23:21:26 +08:00
|
|
|
logger.add(
|
|
|
|
"error.log", rotation="00:00", diagnose=False, level="ERROR", format=default_format
|
|
|
|
)
|
2020-06-30 10:13:58 +08:00
|
|
|
|
2020-09-12 21:44:59 +08:00
|
|
|
nonebot.init(custom_config2="config on init")
|
2021-09-28 20:56:05 +08:00
|
|
|
app = nonebot.get_asgi()
|
2020-12-02 13:17:27 +08:00
|
|
|
driver = nonebot.get_driver()
|
2020-12-03 00:59:32 +08:00
|
|
|
driver.register_adapter("ding", DingBot)
|
2021-02-01 16:37:42 +08:00
|
|
|
driver.register_adapter("mirai", MiraiBot)
|
2021-07-03 13:53:01 +08:00
|
|
|
driver.register_adapter("feishu", FeishuBot)
|
2020-07-04 22:51:10 +08:00
|
|
|
|
2020-08-29 21:59:36 +08:00
|
|
|
# load builtin plugin
|
2020-09-10 18:31:53 +08:00
|
|
|
nonebot.load_builtin_plugins()
|
2020-08-29 21:59:36 +08:00
|
|
|
|
2021-02-19 15:15:46 +08:00
|
|
|
# load all plugins
|
2021-02-24 17:48:08 +08:00
|
|
|
nonebot.load_from_toml("plugins.toml")
|
2020-07-04 22:51:10 +08:00
|
|
|
|
2020-09-12 21:44:59 +08:00
|
|
|
# modify some config / config depends on loaded configs
|
2020-12-02 13:17:27 +08:00
|
|
|
config = driver.config
|
2020-09-12 21:44:59 +08:00
|
|
|
config.custom_config3 = config.custom_config1
|
2020-09-17 18:23:41 +08:00
|
|
|
config.custom_config4 = "New custom config"
|
2020-09-12 21:44:59 +08:00
|
|
|
|
2020-06-30 10:13:58 +08:00
|
|
|
if __name__ == "__main__":
|
2021-09-28 20:56:05 +08:00
|
|
|
nonebot.run(app="__mp_main__:app")
|
|
|
|
# nonebot.run()
|