优化指令,防止骚扰。只发给自己

This commit is contained in:
liuwei
2025-03-11 17:38:41 +08:00
parent df0d74ceda
commit e7edd55b67
2 changed files with 9 additions and 7 deletions

View File

@@ -299,8 +299,10 @@ class Robot(Job):
if msg.from_self():
self.revoke_receive_message(msg)
rsp = self.gbm.handle_command(msg.roomid, msg.content)
self.send_text_msg(rsp, msg.roomid, msg.sender)
return
# 不在群里发送,防止被骚扰
if rsp is not None:
self.send_text_msg(rsp, msg.sender)
return
except Exception as e:
self.LOG.error(f"revoke_receive_message error: {e}")

View File

@@ -138,18 +138,18 @@ class GroupBotManager:
# 如果是MENU指令返回功能列表
if command_str.strip().upper() == "MENU":
return GroupBotManager.display_menu()
return f"群ID{group_id} \n {GroupBotManager.display_menu_status(group_id)}"
# 如果是MENU-STATUS指令返回功能列表及其状态
if command_str.strip().upper() == "MENU_STATUS":
return GroupBotManager.display_menu_status(group_id)
return f"群ID{group_id} \n {GroupBotManager.display_menu_status(group_id)}"
# 如果是GROUP_LIST指令返回 group:list 清单
if command_str.strip().upper() == "GROUP_LIST":
return GroupBotManager.get_group_list()
if len(command_parts) < 2:
return "无效命令,格式应为:功能-操作 或 序号-操作"
return None
feature_str = command_parts[0]
action = command_parts[1]
@@ -194,10 +194,10 @@ class GroupBotManager:
# 根据不同的操作启用或禁用功能
if action == "启用":
GroupBotManager.set_group_permission(group_id, feature, PermissionStatus.ENABLED)
return f"{feature.description} 已启用"
return f"群ID{group_id} \n {feature.description} 已启用"
elif action == "关闭":
GroupBotManager.set_group_permission(group_id, feature, PermissionStatus.DISABLED)
return f"{feature.description} 已关闭"
return f"群ID{group_id} \n {feature.description} 已关闭"
else:
return "无效操作,仅支持启用或关闭"