perf: 更改库的加载顺序

This commit is contained in:
Soulter
2024-05-21 08:41:46 +08:00
parent f67b171385
commit 7babb87934
2 changed files with 16 additions and 19 deletions
+10 -8
View File
@@ -4,7 +4,6 @@ import sys
import warnings
import traceback
import threading
from SparkleLogging.utils.core import LogManager
from logging import Formatter, Logger
warnings.filterwarnings("ignore")
@@ -78,19 +77,12 @@ def check_env():
exit()
if __name__ == "__main__":
logger = LogManager.GetLogger(
log_name='astrbot-core',
out_to_console=True,
custom_formatter=Formatter('[%(asctime)s| %(name)s - %(levelname)s|%(filename)s:%(lineno)d]: %(message)s', datefmt="%H:%M:%S")
)
logger.info(logo_tmpl)
# 设置代理
from util.cmd_config import CmdConfig
cc = CmdConfig()
http_proxy = cc.get("http_proxy")
https_proxy = cc.get("https_proxy")
logger.info(f"使用代理: {http_proxy}, {https_proxy}")
if http_proxy:
os.environ['HTTP_PROXY'] = http_proxy
if https_proxy:
@@ -98,6 +90,16 @@ if __name__ == "__main__":
os.environ['NO_PROXY'] = 'https://api.sgroup.qq.com'
update_dept()
from SparkleLogging.utils.core import LogManager
logger = LogManager.GetLogger(
log_name='astrbot-core',
out_to_console=True,
custom_formatter=Formatter('[%(asctime)s| %(name)s - %(levelname)s|%(filename)s:%(lineno)d]: %(message)s', datefmt="%H:%M:%S")
)
logger.info(logo_tmpl)
logger.info(f"使用代理: {http_proxy}, {https_proxy}")
check_env()
t = threading.Thread(target=main, daemon=True)
t.start()
+6 -11
View File
@@ -11,6 +11,7 @@ from nakuru import (
Notify
)
from typing import Union
from type.types import GlobalObject
import time
from ._platfrom import Platform
@@ -29,7 +30,7 @@ class FakeSource:
class QQGOCQ(Platform):
def __init__(self, cfg: dict, message_handler: callable, global_object) -> None:
def __init__(self, cfg: dict, message_handler: callable, global_object: GlobalObject) -> None:
super().__init__(message_handler)
self.loop = asyncio.new_event_loop()
@@ -38,14 +39,8 @@ class QQGOCQ(Platform):
self.waiting = {}
self.cc = CmdConfig()
self.cfg = cfg
try:
self.nick_qq = cfg['nick_qq']
except:
self.nick_qq = ["ai", "!", ""]
nick_qq = self.nick_qq
if isinstance(nick_qq, str):
nick_qq = [nick_qq]
self.context = global_object
self.unique_session = cfg['uniqueSessionMode']
self.pic_mode = cfg['qq_pic_mode']
@@ -132,8 +127,8 @@ class QQGOCQ(Platform):
if message.type.value == "GroupMessage":
if str(i.qq) == str(message.self_id):
resp = True
elif isinstance(i, Plain):
for nick in self.nick_qq:
elif isinstance(i, Plain) and self.context.nick:
for nick in self.context.nick:
if nick != '' and i.text.strip().startswith(nick):
resp = True
break