Skip to content

Give Telegram cards a button to type your own answer - #20

Merged
neotechnet merged 1 commit into
stack/installed-0.3.5from
feat/telegram-typed-answer
Nov 12, 2026
Merged

neotechnet merged 1 commit into
stack/installed-0.3.5from
feat/telegram-typed-answer

Conversation

@neotechnet

Copy link
Copy Markdown
Owner

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:

  • sendCard in src/host/im/index.js appends 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.
  • A tap arms that card for that chat and sends a prompt with reply_markup: {force_reply: true}. telegram.js gains the forceReply send option; a message never carries both an inline keyboard and a reply prompt.
  • The next text in that chat answers the armed card: a question through rt.answerQuestion with {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.
  • Text with nothing armed is untouched. A card that closed after it was armed is never answered; the text goes on as an ordinary message. The arm is spent on use, and a second tap replaces the first. The arm lives in memory only, so after a restart typed text is an ordinary message, which still closes the card.
  • Plain numbers still answer the newest card.

Tests: 7 new in im.test.js plus 1 in im-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.

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.

@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: 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".

Comment on lines +592 to +595
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

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 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

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 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 👍 / 👎.

@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-12T17:05:29.659694Z 987ecab PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@neotechnet
neotechnet merged commit 718d46a into stack/installed-0.3.5 Nov 12, 2026
14 checks passed
@neotechnet
neotechnet deleted the feat/telegram-typed-answer branch November 12, 2026 21:19
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