8000 fix(channel): normalize bot-addressed commands by qqqqqf-q · Pull Request #803 · felinics/Memoh · GitHub
[go: up one dir, main page]

Skip to content

fix(channel): normalize bot-addressed commands - #803

Merged
qqqqqf-q merged 10 commits into
mainfrom
fix/channel-command-entry
Jul 15, 2026
Merged

qqqqqf-q merged 10 commits into
mainfrom
fix/channel-command-entry

Conversation

@qqqqqf-q
Copy link
Copy Markdown
Member

Summary

  • introduce a canonical command invocation parser shared by channel routing, slash classification, access checks, and command execution
  • normalize bot-addressing forms such as @bot /command, /command@bot, and /command @bot while rejecting commands addressed to another bot
  • publish adapter bot aliases and tighten Telegram mention matching to exact username boundaries

Behavior

  • supports leading and trailing bot mentions, multiple leading mentions, Discord mention syntax, and quoted arguments
  • applies command-specific operand handling so /new ignores addressing mentions and callback flags without stripping mentions from unrelated commands
  • parses each inbound command once and carries the same invocation through the routing path

Test plan

  • GOCACHE=/tmp/memoh-go-cache go test ./internal/... -count=1
  • GOCACHE=/tmp/memoh-go-cache go test ./cmd/... -count=1

@qqqqqf-q
qqqqqf-q marked this pull request as ready for review July 15, 2026 03:59
@qqqqqf-q
Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4fb24c7ba4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +85 to +86
if commandIndex > 0 && !addressed {
return Invocation{}, ErrCommandForOtherBot
Copy 8000 link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve Slack app-mention commands

When a Slack app mention sends text like <@U123> /help, the Slack adapter leaves that mention in Message.Text and only marks is_mentioned without publishing the Slack bot user ID as a bot alias (internal/channel/adapters/slack/slack.go:538-567). This new rejection therefore treats the already-directed Slack command as ErrCommandForOtherBot and DecisionRejectNoop, so the later ExtractCommandText fallback that used to execute /help, /new, etc. is never reached. Please either pass Slack's self user ID as an alias or allow input.Directed messages to extract the command after an unmatched leading mention.

Useful? React with 👍 / 👎.

@qqqqqf-q
Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bab437a333

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +74 to +77
if token.Quoted || !isMentionToken(token.Value) {
return Invocation{}, ErrNotCommand
}
if aliasMatchesInvocation(token.Value, input.BotAliases) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve commands after punctuated bot mentions

When a group command is addressed with common punctuation after the mention, such as Telegram @MemohBot, /new or Slack <@UBOT>: /status, the adapters still mark the message as directed, and the previous ExtractCommandText path would execute the slash command after the whitespace. This parser now requires the pre-command token to be an exact alias match; the comma/colon makes the token fail matching, so the command is ignored or forwarded as normal chat instead of running.

Useful? React with 👍 / 👎.

"attachments": len(attachments),
"is_mentioned": isMentioned,
"is_reply_to_bot": isReplyToBot,
"bot_alias": strings.TrimSpace(parsed.UserID),
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Include Matrix localpart in bot aliases

Matrix mention detection accepts both the full MXID and its localpart (isMatrixBotMentioned checks @memoh:example.com and @memoh), but the new slash alias metadata only exposes the full MXID. In rooms where users type the localpart form that the adapter already treats as a mention, e.g. @memoh /new, ParseInvocation cannot match the leading token and treats the command as addressed to another bot, so the channel command is dropped.

Useful? React with 👍 / 👎.

@qqqqqf-q
qqqqqf-q merged commit d9b2fb1 into main Jul 15, 2026
10 checks passed
@chen-ran
chen-ran deleted the fix/channel-command-entry branch September 11, 2026 12:35
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

0