群机器人管理能力补充。
This commit is contained in:
@@ -209,4 +209,62 @@ def api_group_message_trend(group_id):
|
|||||||
})
|
})
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"获取群组消息趋势数据出错: {e}")
|
logger.error(f"获取群组消息趋势数据出错: {e}")
|
||||||
return jsonify({'success': False, 'error': str(e)}), 500
|
return jsonify({'success': False, 'error': str(e)}), 500
|
||||||
|
|
||||||
|
# 添加缺失的群组状态更新接口
|
||||||
|
@robot_bp.route('/api/group/<group_id>/status', methods=['POST'])
|
||||||
|
@login_required
|
||||||
|
def api_update_group_status(group_id):
|
||||||
|
try:
|
||||||
|
server = current_app.dashboard_server
|
||||||
|
data = request.json
|
||||||
|
status = data.get('status')
|
||||||
|
|
||||||
|
if status == 'disabled':
|
||||||
|
# 禁用该群组的所有功能
|
||||||
|
logger.info(f"正在禁用群组 {group_id} 的所有功能")
|
||||||
|
|
||||||
|
# 获取所有功能并禁用
|
||||||
|
for feature in Feature:
|
||||||
|
GroupBotManager.set_group_permission(group_id, feature, PermissionStatus.DISABLED)
|
||||||
|
|
||||||
|
# 特殊处理ROBOT功能,从群组列表中移除
|
||||||
|
if group_id in GroupBotManager.local_cache["group_list"]:
|
||||||
|
GroupBotManager.local_cache["group_list"].remove(group_id)
|
||||||
|
|
||||||
|
# 从Redis中移除
|
||||||
|
r = server.db_manager.get_redis_connection()
|
||||||
|
r.srem("group:list", group_id)
|
||||||
|
|
||||||
|
return jsonify({
|
||||||
|
"success": True,
|
||||||
|
"message": f"群组 {group_id} 的所有功能已禁用"
|
||||||
|
})
|
||||||
|
elif status == 'enabled':
|
||||||
|
# 启用该群组的基本功能
|
||||||
|
logger.info(f"正在启用群组 {group_id} 的基本功能")
|
||||||
|
|
||||||
|
# 添加到群组列表
|
||||||
|
if group_id not in GroupBotManager.local_cache["group_list"]:
|
||||||
|
GroupBotManager.local_cache["group_list"].add(group_id)
|
||||||
|
|
||||||
|
# 添加到Redis
|
||||||
|
r = server.db_manager.get_redis_connection()
|
||||||
|
r.sadd("group:list", group_id)
|
||||||
|
|
||||||
|
# 启用ROBOT基本功能
|
||||||
|
GroupBotManager.set_group_permission(group_id, Feature.ROBOT, PermissionStatus.ENABLED)
|
||||||
|
|
||||||
|
return jsonify({
|
||||||
|
"success": True,
|
||||||
|
"message": f"群组 {group_id} 的基本功能已启用"
|
||||||
|
})
|
||||||
|
else:
|
||||||
|
return jsonify({
|
||||||
|
"success": False,
|
||||||
|
"error": "不支持的状态值,只接受 'enabled' 或 'disabled'"
|
||||||
|
}), 400
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"更新群组状态失败: {e}")
|
||||||
|
return jsonify({"success": False, "error": str(e)}), 500
|
||||||
@@ -315,7 +315,7 @@
|
|||||||
submitAddGroup() {
|
submitAddGroup() {
|
||||||
this.$refs.addGroupForm.validate(valid => {
|
this.$refs.addGroupForm.validate(valid => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
axios.post('/robot/api/group', {
|
axios.post('/robot/api/add_group', {
|
||||||
group_id: this.addGroupForm.groupId
|
group_id: this.addGroupForm.groupId
|
||||||
})
|
})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
|
|||||||
Reference in New Issue
Block a user