加入dify 自动撤回
This commit is contained in:
@@ -12,6 +12,7 @@ from message_util import MessageUtil
|
||||
from plugin_common.message_plugin_interface import MessagePluginInterface
|
||||
from plugin_common.plugin_interface import PluginStatus
|
||||
from utils.decorator.plugin_decorators import plugin_stats_decorator
|
||||
from utils.revoke.message_auto_revoke import MessageAutoRevoke
|
||||
from utils.robot_cmd.robot_command import Feature, PermissionStatus, GroupBotManager
|
||||
from utils.decorator.points_decorator import plugin_points_cost
|
||||
from utils.media_downloader import MediaDownloader
|
||||
@@ -124,6 +125,8 @@ class DifyPlugin(MessagePluginInterface):
|
||||
gbm: GroupBotManager = message.get("gbm")
|
||||
|
||||
bot: WechatAPIClient = message.get("bot")
|
||||
revoke: MessageAutoRevoke = message.get("revoke")
|
||||
|
||||
# 处理被@的消息
|
||||
if message.get("is_at", False) and roomid:
|
||||
# 检查权限
|
||||
@@ -161,7 +164,11 @@ class DifyPlugin(MessagePluginInterface):
|
||||
|
||||
except Exception as e:
|
||||
self.LOG.error(f"处理Dify聊天请求出错: {e}")
|
||||
await bot.send_text_message((roomid if roomid else sender), "❌未能获取到回复,请稍后再试", sender)
|
||||
client_msg_id, create_time, new_msg_id = await bot.send_text_message((roomid if roomid else sender),
|
||||
"❌未能获取到回复,请稍后再试",
|
||||
sender)
|
||||
revoke.add_message_to_revoke(roomid, client_msg_id, create_time, new_msg_id, 5)
|
||||
|
||||
return False, f"处理出错: {e}"
|
||||
|
||||
# 原有的命令处理逻辑
|
||||
@@ -210,8 +217,11 @@ class DifyPlugin(MessagePluginInterface):
|
||||
|
||||
except Exception as e:
|
||||
self.LOG.error(f"处理Dify聊天请求出错: {e}")
|
||||
await bot.send_text_message((roomid if roomid else sender), f"❌请求出错:{str(e)}",
|
||||
sender if roomid else "")
|
||||
client_msg_id, create_time, new_msg_id = await bot.send_text_message((roomid if roomid else sender),
|
||||
f"❌请求出错:{str(e)}",
|
||||
sender if roomid else "")
|
||||
|
||||
revoke.add_message_to_revoke(roomid, client_msg_id, create_time, new_msg_id, 5)
|
||||
return False, f"处理出错: {e}"
|
||||
|
||||
def _chat_with_dify(self, session_id: str, user_id: str, query: str) -> Optional[str]:
|
||||
|
||||
Reference in New Issue
Block a user