fix(mx-space): pass unhandled text updates to next middleware - #126
Open
specialhua wants to merge 1 commit into
Open
specialhua wants to merge 1 commit into
specialhua wants to merge 1 commit into
Conversation
The owner comment-reply `text` handler returned without calling `next()` for every message it did not consume. It is registered before the commands in `bindCommands` (which awaits `setMyCommands` first), so every module command such as /mx_stat, /mx_get_detail and /hitokoto was swallowed and never answered. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LPQRktGEiEMKSFtRWjgh45
SafeDep Report SummaryNo dependency changes detected. Nothing to scan. This report is generated by SafeDep GitHub App |
This branch has not been deployed
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.



Problem
Module commands never get a reply. Sending
/mx_stat,/mx_get_detail,/mx_get_posts,/mx_get_notesor/hitokototo the bot does nothing, in private chats and in groups. No error is logged./startand/helpstill work.Cause
bindEventsinsrc/modules/mx-space/index.tsregisterstgBot.on("text", ...)for replying to comments and rejecting friend links. The handler returns early for any message it does not consume (not from the owner, or not a reply to a tracked message), and it never callsnext().Registration order makes this swallow every command:
bindEventsregisters thetexthandler synchronously.bindCommands→setTGBotCommandsfirst awaitsgetMyCommands/setMyCommands, and only then callstgBot.command(...).So the
texthandler always sits in front of the module commands. A command is also a text message, so it stops there and the command handler never runs./helpand/startare registered earlier ininitTgBot, which is why they still work.History, for context:
eaee94b(feat: comment reply) added a bot-leveltgBot.on('text', ctx => botEventBus.emit('text', ctx))forwarder insrc/bot/index.ts, also withoutnext(). It was registered beforecommand('help'), so at that point every command except/startwas swallowed.2d25ff7moved the handler into the mx-space module./helpstarted working again, but the module commands are still swallowed.Fix
The handler now takes
nextand callsreturn next()on each early-return path for messages it does not handle. A short comment explains why.Nothing changes for messages the handler does consume. When the owner replies to a tracked comment or link-audit message, the handler still handles it and stops there.
Verification
pnpm typecheck,pnpm build, andeslint/prettier --checkon the changed file all pass.Offline check against the real module, no network. I bundled a small script with the project's tsdown settings. It calls the real
registerfromsrc/modules/mx-space, stubsTelegram.prototype.callApi, and feeds/mx_get_detailfromownerIdin a private chat throughbot.handleUpdate:main[](command swallowed)[sendMessage](usage reply sent)On a real deployment (Docker, Node 22),
/mx_statgot no reply before this change and replies normally after it.🤖 Generated with Claude Code
https://claude.ai/code/session_01LPQRktGEiEMKSFtRWjgh45