From 43a443e64badcc649091320992a461c45aed37aa Mon Sep 17 00:00:00 2001 From: Hoshina Date: Sun, 15 Feb 2026 22:50:31 +0800 Subject: [PATCH] feat(onebot): add user ID allowlist check for incoming messages - Currently, the agent does not respond to messages sent by users outside the allowlist. --- pkg/channels/onebot.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkg/channels/onebot.go b/pkg/channels/onebot.go index f3932d796..ef7b84c4a 100644 --- a/pkg/channels/onebot.go +++ b/pkg/channels/onebot.go @@ -776,6 +776,15 @@ func (c *OneBotChannel) parseMessageSegments(raw json.RawMessage, selfID int64) func (c *OneBotChannel) handleRawEvent(raw *oneBotRawEvent) { switch raw.PostType { case "message": + if userID, err := parseJSONInt64(raw.UserID); err == nil && userID > 0 { + if !c.IsAllowed(strconv.FormatInt(userID, 10)) { + logger.DebugCF("onebot", "Message rejected by allowlist", map[string]interface{}{ + "user_id": userID, + }) + return + } + } + evt, err := c.normalizeMessageEvent(raw) if err != nil { logger.WarnCF("onebot", "Failed to normalize message event", map[string]interface{}{