perf: 更改库的加载顺序
This commit is contained in:
@@ -4,7 +4,6 @@ import sys
|
|||||||
import warnings
|
import warnings
|
||||||
import traceback
|
import traceback
|
||||||
import threading
|
import threading
|
||||||
from SparkleLogging.utils.core import LogManager
|
|
||||||
from logging import Formatter, Logger
|
from logging import Formatter, Logger
|
||||||
|
|
||||||
warnings.filterwarnings("ignore")
|
warnings.filterwarnings("ignore")
|
||||||
@@ -78,19 +77,12 @@ def check_env():
|
|||||||
exit()
|
exit()
|
||||||
|
|
||||||
if __name__ == "__main__":
|
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
|
from util.cmd_config import CmdConfig
|
||||||
cc = CmdConfig()
|
cc = CmdConfig()
|
||||||
http_proxy = cc.get("http_proxy")
|
http_proxy = cc.get("http_proxy")
|
||||||
https_proxy = cc.get("https_proxy")
|
https_proxy = cc.get("https_proxy")
|
||||||
logger.info(f"使用代理: {http_proxy}, {https_proxy}")
|
|
||||||
if http_proxy:
|
if http_proxy:
|
||||||
os.environ['HTTP_PROXY'] = http_proxy
|
os.environ['HTTP_PROXY'] = http_proxy
|
||||||
if https_proxy:
|
if https_proxy:
|
||||||
@@ -98,6 +90,16 @@ if __name__ == "__main__":
|
|||||||
os.environ['NO_PROXY'] = 'https://api.sgroup.qq.com'
|
os.environ['NO_PROXY'] = 'https://api.sgroup.qq.com'
|
||||||
|
|
||||||
update_dept()
|
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()
|
check_env()
|
||||||
t = threading.Thread(target=main, daemon=True)
|
t = threading.Thread(target=main, daemon=True)
|
||||||
t.start()
|
t.start()
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ from nakuru import (
|
|||||||
Notify
|
Notify
|
||||||
)
|
)
|
||||||
from typing import Union
|
from typing import Union
|
||||||
|
from type.types import GlobalObject
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from ._platfrom import Platform
|
from ._platfrom import Platform
|
||||||
@@ -29,7 +30,7 @@ class FakeSource:
|
|||||||
|
|
||||||
|
|
||||||
class QQGOCQ(Platform):
|
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)
|
super().__init__(message_handler)
|
||||||
|
|
||||||
self.loop = asyncio.new_event_loop()
|
self.loop = asyncio.new_event_loop()
|
||||||
@@ -38,14 +39,8 @@ class QQGOCQ(Platform):
|
|||||||
self.waiting = {}
|
self.waiting = {}
|
||||||
self.cc = CmdConfig()
|
self.cc = CmdConfig()
|
||||||
self.cfg = cfg
|
self.cfg = cfg
|
||||||
|
|
||||||
try:
|
self.context = global_object
|
||||||
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.unique_session = cfg['uniqueSessionMode']
|
self.unique_session = cfg['uniqueSessionMode']
|
||||||
self.pic_mode = cfg['qq_pic_mode']
|
self.pic_mode = cfg['qq_pic_mode']
|
||||||
@@ -132,8 +127,8 @@ class QQGOCQ(Platform):
|
|||||||
if message.type.value == "GroupMessage":
|
if message.type.value == "GroupMessage":
|
||||||
if str(i.qq) == str(message.self_id):
|
if str(i.qq) == str(message.self_id):
|
||||||
resp = True
|
resp = True
|
||||||
elif isinstance(i, Plain):
|
elif isinstance(i, Plain) and self.context.nick:
|
||||||
for nick in self.nick_qq:
|
for nick in self.context.nick:
|
||||||
if nick != '' and i.text.strip().startswith(nick):
|
if nick != '' and i.text.strip().startswith(nick):
|
||||||
resp = True
|
resp = True
|
||||||
break
|
break
|
||||||
|
|||||||
Reference in New Issue
Block a user