-
-
Notifications
You must be signed in to change notification settings - Fork 51
Description
Describe the bug
When sending a single image with a caption to the Telegram bot, it works perfectly and syncs to Memos. However, when sending multiple images (an album/media group) along with text, Memos only receives the images, and the text (caption) is completely lost.
To Reproduce
Steps to reproduce the behavior:
Open the Telegram bot connected to Memogram.
Select 2 or more images to send as an album (Media Group).
Add some text in the caption field before sending.
Send the message.
Go to the Memos web interface.
See error: The images are successfully uploaded as resources, but the text is missing.
Expected behavior
Memogram should group the multiple images together and extract the caption, creating a single Memo containing the text and all the attached images.
Technical Root Cause & Suggested Fix
Based on the Telegram Bot API design, when a user sends a media group, Telegram splits it into multiple independent Message objects with the same media_group_id. Crucially, only the first message in the group contains the caption, while the subsequent messages have an empty caption.
Currently, the Go code seems to process these incoming messages sequentially/concurrently without a buffer. It appears that the messages with the empty caption might be overwriting the initial text, or the bot is failing to merge them into a single Memos creation request.
Suggested approach: Implement a short-lived memory buffer (or Redis cache) mapped by media_group_id. When a message with a media_group_id arrives, wait for a short duration (e.g., 2-3 seconds) to collect all related media files. Then, extract the single caption and the array of photo resources, and send them as a single combined API request to Memos.
Environment details:
Memogram Version: [latest]
Memos Version: [latest]