summaryrefslogtreecommitdiff
path: root/ATRI/__init__.py
blob: 547e4bdd49fe3e17976b22751bc011fdbf780bec (plain)
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
from time import sleep
from pathlib import Path

import nonebot
from nonebot.adapters.onebot.v11 import Adapter

from .configs import Config

__version__ = "YHN-001-A07"
__conf_path = Path(".") / "config.yml"
__conf = Config(__conf_path)

conf = __conf.parse()


def asgi():
    return nonebot.get_asgi()


def driver():
    return nonebot.get_driver()


def init():
    nonebot.init(**__conf.get_runtime_conf())
    driver().register_adapter(Adapter)
    nonebot.load_plugins("ATRI/plugins")
    nonebot.load_plugins("ATRI/plugins/rss")
    if conf.WithGoCQHTTP.enabled:
        nonebot.load_plugin("nonebot_plugin_gocqhttp")
    sleep(3)


def run():
    log_level = "debug" if conf.BotConfig.debug else "warning"
    nonebot.run(log_level=log_level)