Trigger Matrix bot on lines prefixed with botName - #64
Open
strk-ai-agent wants to merge 1 commit into
Open
Conversation
Resolves messages like "opencode: hello" or "@OpenCode hello" using the existing config.botName value. The check is inserted between the !oc trigger prefix and the @user:server mention, and is case-insensitive with an optional leading "@". Also drops the hardcoded "bot:" fallback which is now redundant when botName matches. Assisted-By: MiniMax-M3 via opencode 1.18.9
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a new trigger pattern for the Matrix connector: messages like
opencode: helloor@opencode hellonow activate the bot, using the existingconfig.botNamevalue (defaultoc).Changes
escapeRegexhelper + two precompiled regexes (BOT_NAME_TRIGGER_RE,BOT_NAME_TRIGGER_STRIP_RE) inconnectors/matrix.ts, built once at startup so per-message handling stays cheap.botNameis properly escaped to support names containing regex metacharacters.handleRoomMessageright after the!octrigger prefix and before the@user:servermention check. It accepts an optional leading@, is case-insensitive, and allows either a colon or whitespace as the separator.^@?bot[:\s]fallback, which is now redundant wheneverbotNamematches (and was never reachable when it didn't).Trigger order after this change
!oc(orMATRIX_TRIGGER/config.triggeroverride)botname:(new, configurable)@user:servermention of the bot's full Matrix IDExample
With
"botName": "opencode":opencode: do something-> triggers, query = "do something"@Opencode do something-> triggers, query = "do something"!oc do something-> still triggers as before@myassistant:matrix.org do something-> triggers via mention checkVerified with
tsc --noEmit,bun run check:connectors, and the existing Matrix unit + integration tests (24 pass).Assisted-By: MiniMax-M3 via opencode 1.18.9