Skip to content

Feat/strip bot mention group commands#110

Merged
Qsnh merged 20 commits intomainfrom
feat/strip-bot-mention-group-commands
Apr 20, 2026
Merged

Feat/strip bot mention group commands#110
Qsnh merged 20 commits intomainfrom
feat/strip-bot-mention-group-commands

Conversation

@Qsnh
Copy link
Copy Markdown
Contributor

@Qsnh Qsnh commented Apr 20, 2026

No description provided.

Qsnh and others added 20 commits April 20, 2026 00:19
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…mands

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add BotName config to each platform (feishu/dingtalk/wecom/telegram/weixin).
Gateway strips exact @<BotName> tokens from message content before passing
to command handlers, so commands like /clear and /engine work when prefixed
or suffixed with @机器人. Stored message content is unchanged.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add platform bot_name input to all 5 platforms in the interactive
config wizard. Prompts appear after required fields, leave empty to
skip @mention stripping. Updates configValues, loadExistingConfig,
config template, and i18n strings (en + zh).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…pBotMentions

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…t-path

Add IsCommand(content string) bool to the CommandHandler interface so
Dispatch can detect and handle slash commands immediately, skipping the
debounce window entirely. Concrete handlers (EngineCommandHandler,
ClearCommandHandler, chainedHandler) implement the method with pure
token matching; no side effects.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Route slash commands through a serialized buffered channel instead of
calling HandleCommand synchronously in Dispatch, so the platform
receiver goroutine returns immediately. Also removes the now-unreachable
HandleCommand call in onDebounce that was dead code after the IsCommand
fast-path was added.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Apply stripBotMentions to both the debounce path and DB storage so that
@botName and surrounding whitespace are removed from IngestedMessage.Content
and BatchMsg.Content for all inbound messages. Replace the strings.Fields
word-split implementation with a regex that preserves multi-line formatting.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Pre-compile @mention patterns once in WithBotNames instead of recompiling
on every message dispatch. Also replace strings.Fields allocation in
IsCommand with allocation-free strings.HasPrefix checks.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…oup commands

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Extract compileBotNameREs helper to eliminate duplication between
  WithBotNames and strip_test.go; add empty-string guard to prevent
  compiling a bare @-only pattern
- Extract isExactOrPrefixed helper so ClearCommandHandler and
  EngineCommandHandler share a single IsCommand implementation
- Thread gateway lifecycle context into runCommandConsumer so in-flight
  commands respect graceful shutdown
- Remove what-comments on stripBotMentions, Run, and HandleCommand

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- promptBotName: remove survey.Required validator so users can leave
  bot name empty as the prompt message instructs ("leave empty to skip")
- gateway: store stripped content in Dispatch so onDebounce uses it
  directly, avoiding a second regex pass per message per bot name
- gateway: runCommandConsumer exits via ctx.Done() rather than draining
  the channel with a cancelled context; also removes the send-on-closed
  cmdCh panic risk since the channel is no longer closed in Run

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ip' from bot_name prompt

Bot name is mandatory; the prompt copy was wrong. Remove the misleading
hint from both en/zh locales and keep survey.Required.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ot_name optional

- Move stripBotMentions() call before g.mu.Lock() in Dispatch(); botNameREs is
  immutable after construction so no lock is needed, and this keeps regex work
  out of the critical section
- Drop survey.Required from promptBotName so users on DM-only platforms can
  leave bot_name empty

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Bot name must be provided when configuring a platform; the optional
stripping behaviour only activates when the name is non-empty, but
leaving it blank during setup is a misconfiguration.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Qsnh Qsnh merged commit 888da84 into main Apr 20, 2026
@Qsnh Qsnh deleted the feat/strip-bot-mention-group-commands branch April 20, 2026 10:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant