PEP-131: voiceText takes the user after rebase onto feedback voice (PEP-143)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Асель 2026-11-16 20:11:07 +05:00 committed by peppa-bot
parent 4a30be42c4
commit c49866d356

View File

@ -626,7 +626,7 @@ export function createBot(o: BotOptions) {
} }
/** Text of a voice note; null — it could not be heard, and the user has been told. */ /** Text of a voice note; null — it could not be heard, and the user has been told. */
async function voiceText(m: TgMessage): Promise<string | null> { async function voiceText(user: User, m: TgMessage): Promise<string | null> {
const f = m.voice ?? m.audio!; const f = m.voice ?? m.audio!;
const cfg = transcribeConfig(); const cfg = transcribeConfig();
if (!cfg) return reply(m.chat.id, tr("Голосовые сообщения пока не работают. Напишите задачу текстом."), m.message_id).then(() => null); if (!cfg) return reply(m.chat.id, tr("Голосовые сообщения пока не работают. Напишите задачу текстом."), m.message_id).then(() => null);
@ -649,7 +649,7 @@ export function createBot(o: BotOptions) {
} }
async function onVoice(user: User, m: TgMessage) { async function onVoice(user: User, m: TgMessage) {
const text = await voiceText(m); const text = await voiceText(user, m);
if (text) await onPlainText(user, m.chat.id, text, true); if (text) await onPlainText(user, m.chat.id, text, true);
} }
@ -685,7 +685,7 @@ export function createBot(o: BotOptions) {
if (text.startsWith("/")) return closeFeedbackMode(db, user.id).then(() => "pass" as const); if (text.startsWith("/")) return closeFeedbackMode(db, user.id).then(() => "pass" as const);
let said = text || m.caption?.trim() || ""; let said = text || m.caption?.trim() || "";
if (!said && (m.voice || m.audio)) { if (!said && (m.voice || m.audio)) {
const heard = await voiceText(m); const heard = await voiceText(user, m);
if (!heard) return "done"; if (!heard) return "done";
said = heard; said = heard;
} }