nonebot2/tests/bot.py

34 lines
753 B
Python
Raw Normal View History

2020-06-30 02:13:58 +00:00
import os
import sys
2020-07-04 14:51:10 +00:00
sys.path.insert(0, os.path.abspath(".."))
2020-06-30 02:13:58 +00:00
import nonebot
from nonebot.log import logger, default_format
# test custom log
logger.add("error.log",
rotation="00:00",
diagnose=False,
level="ERROR",
format=default_format)
2020-06-30 02:13:58 +00:00
2020-09-12 13:44:59 +00:00
nonebot.init(custom_config2="config on init")
2020-07-04 14:51:10 +00:00
app = nonebot.get_asgi()
# load builtin plugin
2020-09-10 10:31:53 +00:00
nonebot.load_builtin_plugins()
# load local plugins
2020-07-04 14:51:10 +00:00
nonebot.load_plugins("test_plugins")
2020-11-21 12:40:09 +00:00
print(nonebot.require("test_export"))
2020-09-12 13:44:59 +00:00
# modify some config / config depends on loaded configs
config = nonebot.get_driver().config
config.custom_config3 = config.custom_config1
2020-09-17 10:23:41 +00:00
config.custom_config4 = "New custom config"
2020-09-12 13:44:59 +00:00
2020-06-30 02:13:58 +00:00
if __name__ == "__main__":
2020-07-04 14:51:10 +00:00
nonebot.run(app="bot:app")