加入菜单功能,去除@使用AI功能
This commit is contained in:
BIN
admin/dashboard/static/favicon_logosc.zip
Normal file
BIN
admin/dashboard/static/favicon_logosc.zip
Normal file
Binary file not shown.
BIN
admin/dashboard/static/logo.png
Normal file
BIN
admin/dashboard/static/logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1001 KiB |
10
robot.py
10
robot.py
@@ -202,10 +202,12 @@ class Robot(Job):
|
||||
Feature.AI_CAPABILITY) == PermissionStatus.DISABLED:
|
||||
return True
|
||||
else:
|
||||
if msg.type == 1: # 只处理类型为1的消息提供的问题,引用@不予以对话
|
||||
rsp = self.chat.get_answer(q, (msg.roomid if msg.from_group() else msg.sender))
|
||||
else:
|
||||
return True
|
||||
msg = self.gbm.get_enabled_features(msg.roomid)
|
||||
self.message_util.send_text_msg(msg, (msg.roomid if msg.from_group() else msg.sender), msg.sender)
|
||||
# if msg.type == 1: # 只处理类型为1的消息提供的问题,引用@不予以对话
|
||||
# rsp = self.chat.get_answer(q, (msg.roomid if msg.from_group() else msg.sender))
|
||||
# else:
|
||||
return True
|
||||
if rsp:
|
||||
if msg.from_group():
|
||||
self.send_text_msg(rsp, msg.roomid, msg.sender)
|
||||
|
||||
@@ -27,7 +27,7 @@ class Feature(Enum):
|
||||
ROBOT = 1, "群机器人"
|
||||
DAILY_NEWS = 2, "每日新闻自动播报"
|
||||
DAILY_SUMMARY = 3, "每日群发言总结"
|
||||
AI_CAPABILITY = 4, "群AI能力"
|
||||
AI_CAPABILITY = 4, "群AI能力 [ai, dify, 聊天, AI] "
|
||||
SUMMARY_CAPABILITY = 5, "群总结能力 [#总结]"
|
||||
PDF_CAPABILITY = 6, "sehuatang PDF能力"
|
||||
EPIC = 7, "EPIC自动播报" # 新增的功能
|
||||
@@ -226,6 +226,45 @@ class GroupBotManager:
|
||||
menu.append(f"{feature.value}. {feature.description}")
|
||||
return "\n".join(menu)
|
||||
|
||||
@staticmethod
|
||||
def get_enabled_features(group_id):
|
||||
"""获取某个群已启用的功能列表及其描述,并返回格式化的字符串
|
||||
只返回描述中包含指令(方括号[])的功能
|
||||
|
||||
Args:
|
||||
group_id: 群ID
|
||||
|
||||
Returns:
|
||||
str: 格式化的已启用功能列表字符串
|
||||
"""
|
||||
enabled_features = []
|
||||
|
||||
# 检查群是否在列表中
|
||||
if group_id not in GroupBotManager.local_cache["group_list"]:
|
||||
return "该群未启用机器人功能"
|
||||
|
||||
# 遍历所有功能,检查哪些已启用且包含指令
|
||||
for feature in Feature:
|
||||
status = GroupBotManager.get_group_permission(group_id, feature)
|
||||
# 只添加已启用且描述中包含方括号的功能
|
||||
if status == PermissionStatus.ENABLED and "[" in feature.description and "]" in feature.description:
|
||||
enabled_features.append({
|
||||
"id": feature.value,
|
||||
"name": feature.name,
|
||||
"description": feature.description
|
||||
})
|
||||
|
||||
# 如果没有启用任何带指令的功能
|
||||
if not enabled_features:
|
||||
return "该群未启用任何带指令的功能"
|
||||
|
||||
# 构建格式化的字符串
|
||||
result = f"群功能菜单:\n"
|
||||
for feature in enabled_features:
|
||||
result += f"{feature['id']}.{feature['name']}:{feature['description']}\n"
|
||||
|
||||
return result
|
||||
|
||||
@staticmethod
|
||||
def get_group_list():
|
||||
"""返回所有启用了群机器人的群组清单,格式为集合"""
|
||||
|
||||
Reference in New Issue
Block a user