smtp_to_telegram
smtp_to_telegram copied to clipboard
Support sending multiple attachments as albums
Right now when smtp_to_telegram
receives a mail with multiple photo attachments, it sends each image separately via the sendPhoto API call. This makes each image appear as a separate standalone message as a reply to the original message. Telegram supports albums, which groups together multiple (2-10) images in a single message. Sending albums as a bot is possible via the sendMediaGroup API.
Also I'd like to add that the album doesn't have to be a reply to a text message, it can contain a text message as well. According to this StackOverflow post, Telegram uses the caption
property of the first element of the array as the text part of the message.
(I suspect a similar method exists for the sendPhoto
and sendDocuments
endpoints as well.)
These changes together would merge emails containing multiple photo attachments to a single message with a single notification (and a single Telegram API call).
I started poking around to implement this myself and I noticed that you're doing raw REST calls to call the Telegram API which makes the code a bit hard to work with for me. What was your reason to work with raw calls instead of a bot library like telegram-bot-api or telebot? Would you accept a PR which replaces Telegram API calls with a bot framework?
@janost i've checked your fork and it works perfectly for synology surveillance alerts. Do you mind publishing your fork to docker hub so it can be easily accessible by syno nas owners? thanks
@dmitryuv I haven't touched my fork in a long time and honestly I'm not too happy with its quality. I might clean it up a little and submit it once I have some time to work on it, but it probably won't happen anytime soon. Or maybe it will happen, I really don't know.