调整xml内容
This commit is contained in:
@@ -8,12 +8,14 @@ from datetime import datetime
|
|||||||
robot_bp = Blueprint('robot', __name__, url_prefix='/robot')
|
robot_bp = Blueprint('robot', __name__, url_prefix='/robot')
|
||||||
LOG = logger
|
LOG = logger
|
||||||
|
|
||||||
|
|
||||||
# 机器人管理页面
|
# 机器人管理页面
|
||||||
@robot_bp.route('/')
|
@robot_bp.route('/')
|
||||||
@login_required
|
@login_required
|
||||||
def robot_management():
|
def robot_management():
|
||||||
return render_template('robot_management.html')
|
return render_template('robot_management.html')
|
||||||
|
|
||||||
|
|
||||||
# API路由
|
# API路由
|
||||||
@robot_bp.route('/api/groups')
|
@robot_bp.route('/api/groups')
|
||||||
@login_required
|
@login_required
|
||||||
@@ -45,7 +47,7 @@ def api_robot_groups():
|
|||||||
try:
|
try:
|
||||||
robot_status = GroupBotManager.get_group_permission(group_id, Feature.ROBOT)
|
robot_status = GroupBotManager.get_group_permission(group_id, Feature.ROBOT)
|
||||||
except:
|
except:
|
||||||
robot_status = PermissionStatus.UNKNOWN
|
robot_status = PermissionStatus.DISABLED
|
||||||
|
|
||||||
group_data.append({
|
group_data.append({
|
||||||
"group_id": group_id,
|
"group_id": group_id,
|
||||||
@@ -66,6 +68,7 @@ def api_robot_groups():
|
|||||||
LOG.error(f"获取群组列表失败: {e}")
|
LOG.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>/permissions')
|
@robot_bp.route('/api/group/<group_id>/permissions')
|
||||||
@login_required
|
@login_required
|
||||||
def api_robot_group_permissions(group_id):
|
def api_robot_group_permissions(group_id):
|
||||||
@@ -86,6 +89,7 @@ def api_robot_group_permissions(group_id):
|
|||||||
LOG.error(f"获取群组权限失败: {e}")
|
LOG.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>/permissions', methods=['POST'])
|
@robot_bp.route('/api/group/<group_id>/permissions', methods=['POST'])
|
||||||
@login_required
|
@login_required
|
||||||
def api_update_robot_permissions(group_id):
|
def api_update_robot_permissions(group_id):
|
||||||
@@ -115,6 +119,7 @@ def api_update_robot_permissions(group_id):
|
|||||||
LOG.error(f"更新群组权限失败: {e}")
|
LOG.error(f"更新群组权限失败: {e}")
|
||||||
return jsonify({"success": False, "error": str(e)}), 400
|
return jsonify({"success": False, "error": str(e)}), 400
|
||||||
|
|
||||||
|
|
||||||
@robot_bp.route('/api/batch_operation', methods=['POST'])
|
@robot_bp.route('/api/batch_operation', methods=['POST'])
|
||||||
@login_required
|
@login_required
|
||||||
def api_robot_batch_operation():
|
def api_robot_batch_operation():
|
||||||
@@ -138,6 +143,7 @@ def api_robot_batch_operation():
|
|||||||
LOG.error(f"批量操作失败: {e}")
|
LOG.error(f"批量操作失败: {e}")
|
||||||
return jsonify({"success": False, "error": str(e)}), 400
|
return jsonify({"success": False, "error": str(e)}), 400
|
||||||
|
|
||||||
|
|
||||||
@robot_bp.route('/api/add_group', methods=['POST'])
|
@robot_bp.route('/api/add_group', methods=['POST'])
|
||||||
@login_required
|
@login_required
|
||||||
def api_add_group():
|
def api_add_group():
|
||||||
@@ -150,7 +156,7 @@ def api_add_group():
|
|||||||
return jsonify({"success": False, "error": "群组ID不能为空"}), 400
|
return jsonify({"success": False, "error": "群组ID不能为空"}), 400
|
||||||
|
|
||||||
group_id = group_id.strip()
|
group_id = group_id.strip()
|
||||||
#如果group_id 不是@chatroom 结尾,这提示错误
|
# 如果group_id 不是@chatroom 结尾,这提示错误
|
||||||
if not group_id.endswith("@chatroom"):
|
if not group_id.endswith("@chatroom"):
|
||||||
return jsonify({"success": False, "error": "群组ID必须以 @chatroom 结尾"}), 400
|
return jsonify({"success": False, "error": "群组ID必须以 @chatroom 结尾"}), 400
|
||||||
|
|
||||||
@@ -182,6 +188,7 @@ def api_add_group():
|
|||||||
LOG.error(f"添加群组失败: {e}")
|
LOG.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>/message_trend')
|
@robot_bp.route('/api/group/<group_id>/message_trend')
|
||||||
@login_required
|
@login_required
|
||||||
def api_group_message_trend(group_id):
|
def api_group_message_trend(group_id):
|
||||||
@@ -214,6 +221,7 @@ def api_group_message_trend(group_id):
|
|||||||
LOG.error(f"获取群组消息趋势数据出错: {e}")
|
LOG.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'])
|
@robot_bp.route('/api/group/<group_id>/status', methods=['POST'])
|
||||||
@login_required
|
@login_required
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ from utils.robot_cmd.robot_command import Feature, PermissionStatus, GroupBotMan
|
|||||||
import mysql.connector.pooling
|
import mysql.connector.pooling
|
||||||
|
|
||||||
from wechat_ipad import WechatAPIClient
|
from wechat_ipad import WechatAPIClient
|
||||||
|
from wechat_ipad.models.message import WxMessage
|
||||||
|
|
||||||
|
|
||||||
class PointTradePlugin(MessagePluginInterface):
|
class PointTradePlugin(MessagePluginInterface):
|
||||||
@@ -161,8 +162,9 @@ class PointTradePlugin(MessagePluginInterface):
|
|||||||
command = content.split(" ")
|
command = content.split(" ")
|
||||||
sender = message.get("sender")
|
sender = message.get("sender")
|
||||||
roomid = message.get("roomid", "")
|
roomid = message.get("roomid", "")
|
||||||
xml = message.get("xml", "")
|
|
||||||
|
|
||||||
|
msg: WxMessage = message.get("full_wx_msg")
|
||||||
|
xml = msg.msg_source
|
||||||
# 检查命令格式
|
# 检查命令格式
|
||||||
if len(command) < 3:
|
if len(command) < 3:
|
||||||
client_msg_id, create_time, new_msg_id = await self.bot.send_at_message((roomid if roomid else sender),
|
client_msg_id, create_time, new_msg_id = await self.bot.send_at_message((roomid if roomid else sender),
|
||||||
|
|||||||
Reference in New Issue
Block a user