Skip to content

feat(telegram): describe locations, contacts, polls and dice - #836

Open
grootbro wants to merge 4 commits into
vercel:mainfrom
grootbro:feat/telegram-non-file-content
Open

feat(telegram): describe locations, contacts, polls and dice#836
grootbro wants to merge 4 commits into
vercel:mainfrom
grootbro:feat/telegram-non-file-content

Conversation

@grootbro

Copy link
Copy Markdown

Based on #835.

Telegram sends several message kinds with neither text nor a file. They reached the handler as empty messages: the content was in the payload, but anything reading text saw nothing and could not tell an empty delivery from a shared location.

A location, venue, contact, poll, dice, game, invoice and story now each produce a short literal description, in the same place a sticker produces its emoji:

📍 55.75, 37.61
📍 Central Library, 12 Main St
👤 Ada Lovelace +15551234567
📊 Lunch or dinner?
🎲 4
🎮 Corsairs
🧾 Yearly plan — 49.99 USD
📖 Story

The wording stays minimal and the structured payload is untouched on the raw message, so a handler that wants the coordinates or the poll options still has them.

Thread.reply() threw NotImplementedError on Telegram because the adapter
had no reply method, even though the Bot API threads an answer to its
question with reply_parameters.

postMessage takes an optional reply target and passes it to every send
path — text, rich messages, documents, attachments and both media group
variants — and reply() delegates to it, matching how the WhatsApp adapter
implements the same contract. The target is decoded through the existing
decodeCompositeMessageId, so a target from another chat is rejected the
same way an edit would be.

allow_sending_without_reply is set so a deleted target degrades to an
unthreaded message instead of failing the send.

Signed-off-by: grootbro <vadim@ravefox.dev>
In a group a Telegram bot only sees messages that address it, and users
address a bot by replying to it as often as by typing its handle. The
adapter reported isMention for the handle but not for the reply, so a bot
went quiet the moment the conversation moved to replies.

mentionOnReply turns that on. It is off by default: the flag changes which
messages report isMention, and a bot that deliberately answers only
explicit mentions should keep the stricter behaviour. It also reads from
TELEGRAM_MENTION_ON_REPLY so a deployment can set it without code.

The check runs before the empty-text guard, so a reply carrying only a
photo or a document counts too.

Signed-off-by: grootbro <vadim@ravefox.dev>
A sticker carries no text, so it reached the handler as an empty message
and looked like a delivery that had lost its body. An animation — the MP4
Telegram sends for a GIF — was not declared on the message type and was
dropped on the floor.

A sticker now reports the emoji it stands for as the message text, plus an
image attachment typed by its real format: WebP for a still one, WebM for
a video sticker, TGS for a Lottie one. An animation arrives as a video
attachment alongside the other media types.

Signed-off-by: grootbro <vadim@ravefox.dev>
Telegram sends several message kinds with neither text nor a file. They
reached the handler as empty messages: the content was in the payload, but
anything reading text saw nothing and could not tell an empty delivery
from a shared location.

A location, venue, contact, poll and dice now each produce a short literal
description, in the same place a sticker produces its emoji. The wording
stays minimal and the structured payload is untouched on the raw message,
so a handler that wants coordinates still has them.

Signed-off-by: grootbro <vadim@ravefox.dev>
@grootbro
grootbro requested a review from a team as a code owner August 17, 2026 21:46
@vercel

vercel Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

@grootbro is attempting to deploy a commit to the Vercel Team on Vercel.

A member of the Team first needs to authorize it.

}

// An animation is Telegram's GIF: an MP4 without sound.
if (raw.animation) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Animation/GIF Telegram messages yield two attachments because both raw.document and raw.animation branches fire for the same file.

Fix on Vercel

Comment on lines +2569 to +2575
const urlReplyParameters = this.buildReplyParameters(
replyToMessageId,
thread.chatId
);
if (urlReplyParameters) {
payload.reply_parameters = urlReplyParameters;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
const urlReplyParameters = this.buildReplyParameters(
replyToMessageId,
thread.chatId
);
if (urlReplyParameters) {
payload.reply_parameters = urlReplyParameters;
}
}
const urlReplyParameters = this.buildReplyParameters(
replyToMessageId,
thread.chatId
);
if (urlReplyParameters) {
payload.reply_parameters = urlReplyParameters;

URL-based attachment replies drop reply threading when no inline keyboard is present because reply_parameters is set only inside the if (replyMarkup) block

Fix on Vercel

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