]> git.giacomolli.uk - onechat/blob - telegram_voice.go
Require consent and review for autosquash
[onechat] / telegram_voice.go
1 package main
2
3 import "context"
4
5 // telegramVoiceText keeps a voice note or a fixed failure marker. Download and
6 // decode failures do not block later updates. Only owner messages reach it.
7 func telegramVoiceText(ctx context.Context, api *TelegramAPI, store *VoiceStore, transcriber *VoiceTranscriber, message *TelegramMessage) string {
8 text := "(voice not downloaded)"
9 if message.Voice.FileSize <= voiceMaxBytes {
10 data, err := api.GetFile(ctx, message.Voice.FileID, voiceMaxBytes, errVoiceSize)
11 if err == nil {
12 text = transcriber.Text(ctx, store, data)
13 }
14 }
15
16 if message.Caption != "" {
17 text += "\n" + message.Caption
18 }
19
20 return text
21 }