refactor: 不再向QQBotManager中传递config中可读的参数

This commit is contained in:
Rock Chin 2023-04-21 17:15:32 +08:00
parent 91746448a3
commit 016391c976
3 changed files with 8 additions and 9 deletions

View File

@ -193,9 +193,7 @@ def start(first_time_init=False):
pkg.openai.session.load_sessions()
# 初始化qq机器人
qqbot = pkg.qqbot.manager.QQBotManager(mirai_http_api_config=config.mirai_http_api_config,
timeout=config.process_message_timeout, retry=config.retry_times,
first_time_init=first_time_init)
qqbot = pkg.qqbot.manager.QQBotManager(first_time_init=first_time_init)
# 加载插件
import pkg.plugin.host

View File

@ -73,9 +73,12 @@ class QQBotManager:
ban_person = []
ban_group = []
def __init__(self, mirai_http_api_config: dict, timeout: int = 60, retry: int = 3, first_time_init=True):
self.timeout = timeout
self.retry = retry
def __init__(self, first_time_init=True):
import config
mirai_http_api_config = config.mirai_http_api_config
self.timeout = config.process_message_timeout
self.retry = config.retry_times
# 加载禁用列表
if os.path.exists("banlist.py"):
@ -195,9 +198,6 @@ class QQBotManager:
self.unsubscribe_all = unsubscribe_all
def go(self, func, *args, **kwargs):
self.pool.submit(func, *args, **kwargs)
def first_time_init(self, mirai_http_api_config: dict):
"""热重载后不再运行此函数"""
if 'adapter' not in mirai_http_api_config or mirai_http_api_config['adapter'] == "WebSocketAdapter":

View File

@ -5,6 +5,7 @@ import mirai.models.bus
import asyncio
import typing
class YiriMiraiAdapter(MessageSourceAdapter):
"""YiriMirai适配器"""
bot: mirai.Mirai