← Back to PRs

#17748: fix: transcribe voice messages in Telegram DMs (v2)

by Limitless2023 open 2026-02-16 04:40 View on GitHub →
channel: telegram stale size: XS
## Summary Fixed critical TDZ bug and improved DM voice transcription support. ## Changes - Move preflightTranscript declaration before first use (fixes TDZ error) - Add transcription for all voice messages in DMs ## Testing - pnpm build - pnpm check ## AI-assisted Yes - AI-assisted with human review Fixes #17101 <!-- greptile_comment --> <h3>Greptile Summary</h3> This PR extends Telegram preflight audio transcription to cover DM voice messages, not just group messages with mention requirements. The single condition `needsPreflightTranscription` is split into two clearly named flags: `needsGroupMentionTranscription` (unchanged group logic) and `needsDmTranscription` (`!isGroup && hasAudio`). - Splits the transcription condition into `needsGroupMentionTranscription` and `needsDmTranscription` for clarity - Group transcription behavior is unchanged (`isGroup && requireMention && hasAudio && !hasUserText && mentionRegexes.length > 0`) - DM voice messages without captions will now be transcribed and the `<media:audio>` placeholder replaced with transcript text - The existing `bodyText === "<media:audio>"` guard at line 434 ensures transcripts only replace the placeholder, not user-supplied captions <h3>Confidence Score: 4/5</h3> - This PR is safe to merge — the change is minimal, clearly scoped, and preserves existing group transcription behavior. - Score of 4 reflects a small, focused change with clear intent. The group transcription condition is unchanged (no regression risk). The new DM transcription path correctly integrates with the existing bodyText replacement logic for caption-less voice messages. One minor inefficiency exists (transcribing captioned DM audio unnecessarily) but it was already flagged in a prior review thread and is non-critical. - No files require special attention. The single changed file (`src/telegram/bot-message-context.ts`) has a clean, well-bounded modification. <sub>Last reviewed commit: 77ba49c</sub> <!-- greptile_other_comments_section --> <!-- /greptile_comment -->

Most Similar PRs