Repository navigation
Give Telegram cards a button to type your own answer - #20
Conversation
A Telegram card offered only its option buttons, so a free-text answer had no visible route. Every question card and view card sent to Telegram now carries a last button, added once in sendCard so no caller can leave it out. A tap sends a force_reply prompt (an inline keyboard and a reply prompt cannot share a message), and the next text in that chat answers that card: a question gets it as its custom answer, a view gets it as the user's reply. The arm is per chat and spent on use, a second tap replaces the first, and text for a card that has since closed goes on as an ordinary message. Plain numbers still answer the newest card.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 987ecab169
ℹ️ 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".
| const armedCard = armed.get(armKey(conn, msg.chat.key)) | ||
| if (armedCard !== undefined && body !== '') { | ||
| armed.delete(armKey(conn, msg.chat.key)) | ||
| if (await answerTyped(conn, msg.chat, armedCard, body)) return |
There was a problem hiding this comment.
Bind the armed answer to the user who pressed the button
In a Telegram group with multiple paired users, one user can press “Type my own answer” and another user's next message mentioning or replying to the bot will consume that arm. Because the key contains only the connection and chat, unrelated text is submitted as the first user's card answer, closing the question before their actual answer arrives. Store the initiating sender ID and require it to match before consuming the armed card; other users' messages should retain their ordinary routing.
Useful? React with 👍 / 👎.
| const armedCard = armed.get(armKey(conn, msg.chat.key)) | ||
| if (armedCard !== undefined && body !== '') { | ||
| armed.delete(armKey(conn, msg.chat.key)) | ||
| if (await answerTyped(conn, msg.chat, armedCard, body)) return |
There was a problem hiding this comment.
Preserve attachments when consuming a typed reply
If the user answers an armed card with a captioned photo or document, Telegram supplies both nonempty text and images/files. This early return passes only the caption to answerTyped, bypassing the attachment processing below. For a view, the resulting sendUser call likewise contains only text, so an answer such as “use the attached specification” reaches the Bot without its specification and the card is settled anyway. Preserve or separately deliver the attachments when handling the typed answer rather than silently discarding them.
Useful? React with 👍 / 👎.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Job DSB-CARD-TYPE-20261112 (Igor). Steve's rule: every Telegram menu gets a fourth option where he can type his own answer.
What changed:
sendCardinsrc/host/im/index.jsappends a "Type my own answer" button (t:<cardKey>) to every question card (q:) and view card (v:) sent on Telegram. It is the one funnel every card goes through, so no caller can forget it. Approvals and secret requests are left as they are: neither takes a typed answer.reply_markup: {force_reply: true}.telegram.jsgains theforceReplysend option; a message never carries both an inline keyboard and a reply prompt.rt.answerQuestionwith{custom}, a view as the user's own message (a view has no free-text answer; DS Bot already closes it as replied). The card is settled and edited shut.Tests: 7 new in
im.test.jsplus 1 inim-telegram.test.js, and the options-view button list updated. 6 of them fail on the unpatched source; the other 3 guard unchanged behaviour (ordinary text, a closed card, a plain number).Not done: no smoke bench, no live Telegram run, profile untouched.