feat: send voice notes to Telegram as voice messages
This commit is contained in:
parent
3544ff7435
commit
1d209636b4
1 changed files with 9 additions and 1 deletions
|
|
@ -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}");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue