From 310a8733c8e5ef7b9271adbf7b241cab32d38c98 Mon Sep 17 00:00:00 2001 From: AskaEth Date: Sun, 28 Jun 2026 12:06:09 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20IoT=E8=AE=BE=E5=A4=87=E6=8E=A7=E5=88=B6?= =?UTF-8?q?=E4=BB=85=E9=99=90=E7=AE=A1=E7=90=86=E5=91=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/ai-core/internal/tools/iot_control_tool.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/backend/ai-core/internal/tools/iot_control_tool.go b/backend/ai-core/internal/tools/iot_control_tool.go index 57d8875..709df49 100644 --- a/backend/ai-core/internal/tools/iot_control_tool.go +++ b/backend/ai-core/internal/tools/iot_control_tool.go @@ -5,6 +5,8 @@ import ( "encoding/json" "fmt" "strings" + + plgManager "git.yeij.top/AskaEth/Cyrene-Plugins/manager" ) // IoTControlTool IoT 设备控制工具 @@ -123,6 +125,15 @@ func normalizeAction(arguments map[string]interface{}) string { // Execute 执行设备控制 func (t *IoTControlTool) Execute(ctx context.Context, arguments map[string]interface{}) (*ToolResult, error) { + // 仅管理员可以控制设备 + isAdmin, _ := ctx.Value(plgManager.CtxKeyIsAdmin).(bool) + if !isAdmin { + return &ToolResult{ + ToolName: "iot_control", + Success: false, + Error: "只有管理员才能控制设备哦~", + }, nil + } if t.iotClient == nil { return &ToolResult{ ToolName: "iot_control",