Skip to content

Support two-way message replies and quotes for Telegram forum topics and webhooks - #78

Open
mysubcult wants to merge 1 commit into
LiveHelperChat:masterfrom
mysubcult:feature/telegram-topic-reply-sync
Open

Support two-way message replies and quotes for Telegram forum topics and webhooks#78
mysubcult wants to merge 1 commit into
LiveHelperChat:masterfrom
mysubcult:feature/telegram-topic-reply-sync

Conversation

@mysubcult

Copy link
Copy Markdown
Contributor

Summary

This PR implements native two-way message replies and quotes synchronization between Telegram forum topics (operator side) and visitor channels (Telegram visitor bot / Web widget / Incoming webhooks).

Clean changes included:

  1. classes/Commands/GenericmessageCommand.php:

    • Intercepts operator replies in forum topics ($message->getReplyToMessage()).
    • Looks up the original message via tg_topic_msg_id in meta_msg.
    • Appends standard [quote=ID] BBCode to the message and populates meta_msg_array['content']['quote'] and meta_msg_array['content']['reply_to'].
    • Saves operator's Telegram message_id into tg_topic_msg_id.
  2. bootstrap/bootstrap.php:

    • Added saveTopicMsgId($msg, $topicMsgId) to record topic message_id on send.
    • Added getTopicReplyId($msg, $chatId) to resolve target topic message IDs from content.reply_to.db_msg_id, content.reply_to.iwh_msg_id, content.quote.id, or [quote=ID].
    • Passes reply_to_message_id to Telegram Bot API when sending text messages, media files, and bot messages into the topic.
  3. Default configuration templates updated (doc/telegram/):

    • doc/telegram/incoming-webhook.json: Added "message_id_reply": "message.reply_to_message.message_id" so incoming replies from visitors in Telegram are mapped automatically.
    • doc/telegram/rest-api.json: Added {reply_to},"reply_parameters":{"message_id":raw_{{iwh_msg_id}}}{/reply_to} to body_raw and body_raw_file so operator topic replies are sent to the visitor with native Telegram reply_parameters.

@mysubcult
mysubcult force-pushed the feature/telegram-topic-reply-sync branch from 2c08ba5 to dd2f64e Compare August 21, 2026 12:46
@mysubcult

Copy link
Copy Markdown
Contributor Author

Hi @remdex,

Apologies for the previous branch state — some leftover static paths from an older dev commit accidentally slipped in earlier.

I have completely cleaned up the branch and rebased it directly onto clean master as a single commit:

  • Removed all static/hardcoded paths: uses standard LHC $file->file_path_server and Longman\TelegramBot\Request::encodeFile().
  • Cleaned quote formatting: uses standard LHC [quote=ID] BBCode without any extra emojis or decorators.
  • Thoroughly tested live: verified both operator-to-visitor and visitor-to-operator quotes/replies in real Telegram forum topics, web widget, and webhooks. Everything works seamlessly.
  • Updated default templates (doc/telegram/): added message_id_reply and reply_parameters so new imports work out of the box.

Please take a look when you have a moment. Thanks!

@mysubcult
mysubcult force-pushed the feature/telegram-topic-reply-sync branch 9 times, most recently from 0178ea3 to eee54a8 Compare August 22, 2026 10:09
@mysubcult
mysubcult force-pushed the feature/telegram-topic-reply-sync branch from eee54a8 to 5ff450d Compare August 22, 2026 10: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