diff --git a/model/command/command.py b/model/command/command.py index 5fcab1ce9..3548d1d00 100644 --- a/model/command/command.py +++ b/model/command/command.py @@ -106,7 +106,7 @@ class Command: if self.command_start_with(message, "update"): return True, self.update(message, role) if message == "t2i": - return True, "t2i", self.t2i_toggle(message, role) + return True, self.t2i_toggle(message, role) if not self.provider and message == "help": return True, await self.help() @@ -220,6 +220,7 @@ class Command: "nick": "设置机器人唤醒词", "plugin": "插件安装、卸载和重载", "web on/off": "LLM 网页搜索能力", + "t2i": "启用/关闭文本转图片模式" } async def help_messager(self, commands: dict, platform: str, cached_plugins: List[RegisteredPlugin] = None): diff --git a/model/platform/qq_gocq.py b/model/platform/qq_gocq.py index c420dd5ce..593225ebc 100644 --- a/model/platform/qq_gocq.py +++ b/model/platform/qq_gocq.py @@ -44,7 +44,6 @@ class QQGOCQ(Platform): self.context = global_object self.unique_session = cfg['uniqueSessionMode'] - self.pic_mode = cfg['qq_pic_mode'] self.client = CQHTTP( host=self.cc.get("gocq_host", "127.0.0.1"), @@ -204,7 +203,7 @@ class QQGOCQ(Platform): res.append(Plain(text=res_str)) # if image mode, put all Plain texts into a new picture. - if self.pic_mode and isinstance(res, list): + if self.cc.get("qq_pic_mode", False) and isinstance(res, list): plains = [] news = [] for i in res: diff --git a/model/platform/qq_official.py b/model/platform/qq_official.py index bfcc693e1..aa3594efe 100644 --- a/model/platform/qq_official.py +++ b/model/platform/qq_official.py @@ -21,6 +21,7 @@ from type.message import * from typing import Union, List from nakuru.entities.components import * from util.image_render.helper import text_to_image_base +from util.cmd_config import CmdConfig from SparkleLogging.utils.core import LogManager from logging import Logger @@ -58,14 +59,14 @@ class QQOfficial(Platform): asyncio.set_event_loop(self.loop) self.waiting: dict = {} - + + self.cc = CmdConfig() self.cfg = cfg self.appid = cfg['qqbot']['appid'] self.token = cfg['qqbot']['token'] self.secret = cfg['qqbot_secret'] self.unique_session = cfg['uniqueSessionMode'] qq_group = cfg['qqofficial_enable_group_message'] - self.pic_mode = cfg['qq_pic_mode'] if qq_group: self.intents = botpy.Intents( @@ -198,7 +199,7 @@ class QQOfficial(Platform): # if response.status == 200: # image = PILImage.open(io.BytesIO(await response.read())) # image_path = gu.save_temp_img(image) - if self.pic_mode: + if self.cc.get("qq_pic_mode", False): plains = [] news = [] if isinstance(res, str): @@ -220,7 +221,7 @@ class QQOfficial(Platform): else: plain_text = res - if source is not None and image_path == '': # file_image与message_reference不能同时传入 + if source and not image_path: # file_image与message_reference不能同时传入 msg_ref = Reference(message_id=source.id, ignore_get_message_error=False)