feat: send voice notes to Telegram as voice messages

This commit is contained in:
Lewis Wynne 2026-04-10 02:42:16 +01:00
parent 3544ff7435
commit 1d209636b4

View file

@ -19,7 +19,7 @@ async fn notify(bot: &Bot, chat_id: ChatId, entry: &Entry) {
/// Listen for new entries on the channel and send Telegram notifications. /// Listen for new entries on the channel and send Telegram notifications.
pub async fn notification_task(bot: Bot, chat_id: ChatId, mut rx: Receiver<(Entry, Option<Vec<u8>>, Option<Vec<u8>>)>) { pub async fn notification_task(bot: Bot, chat_id: ChatId, mut rx: Receiver<(Entry, Option<Vec<u8>>, Option<Vec<u8>>)>) {
while let Some((entry, drawing_bytes, _voice_bytes)) = rx.recv().await { while let Some((entry, drawing_bytes, voice_bytes)) = rx.recv().await {
notify(&bot, chat_id, &entry).await; notify(&bot, chat_id, &entry).await;
if let Some(bytes) = drawing_bytes { if let Some(bytes) = drawing_bytes {
if let Err(e) = bot.send_photo( if let Err(e) = bot.send_photo(
@ -29,6 +29,14 @@ pub async fn notification_task(bot: Bot, chat_id: ChatId, mut rx: Receiver<(Entr
tracing::error!("failed to send drawing photo: {e}"); tracing::error!("failed to send drawing photo: {e}");
} }
} }
if let Some(bytes) = voice_bytes {
if let Err(e) = bot.send_voice(
chat_id,
teloxide::types::InputFile::memory(bytes).file_name("voice_note.webm"),
).await {
tracing::error!("failed to send voice note: {e}");
}
}
} }
} }