fix(telegram): voice-note tag defaults (#188, thanks @manmal)

This commit is contained in:
Peter Steinberger
2026-01-08 03:13:54 +00:00
parent 2972fce02c
commit 15379dedf0
6 changed files with 109 additions and 3 deletions

View File

@@ -23,6 +23,7 @@ import type { OriginatingChannelType, TemplateContext } from "../templating.js";
import { normalizeVerboseLevel, type VerboseLevel } from "../thinking.js";
import { SILENT_REPLY_TOKEN } from "../tokens.js";
import type { GetReplyOptions, ReplyPayload } from "../types.js";
import { extractAudioTag } from "./audio-tags.js";
import { createFollowupRunner } from "./followup-runner.js";
import {
enqueueFollowupRun,
@@ -30,14 +31,12 @@ import {
type QueueSettings,
scheduleFollowupDrain,
} from "./queue.js";
import { extractAudioTag } from "./audio-tags.js";
import {
applyReplyTagsToPayload,
applyReplyThreading,
filterMessagingToolDuplicates,
isRenderablePayload,
} from "./reply-payloads.js";
import { extractReplyToTag } from "./reply-tags.js";
import {
createReplyToModeFilter,
resolveReplyToMode,
@@ -341,6 +340,7 @@ export async function runReplyAgent(params: {
const hasMedia =
Boolean(taggedPayload.mediaUrl) ||
(taggedPayload.mediaUrls?.length ?? 0) > 0;
if (!cleaned && !hasMedia) return;
if (cleaned?.trim() === SILENT_REPLY_TOKEN && !hasMedia)
return;
const blockPayload: ReplyPayload = applyReplyToMode({

View File

@@ -0,0 +1,25 @@
import { describe, expect, it } from "vitest";
import { extractAudioTag } from "./audio-tags.js";
describe("extractAudioTag", () => {
it("detects audio_as_voice and strips the tag", () => {
const result = extractAudioTag("Hello [[audio_as_voice]] world");
expect(result.audioAsVoice).toBe(true);
expect(result.hasTag).toBe(true);
expect(result.cleaned).toBe("Hello world");
});
it("returns empty output for missing text", () => {
const result = extractAudioTag(undefined);
expect(result.audioAsVoice).toBe(false);
expect(result.hasTag).toBe(false);
expect(result.cleaned).toBe("");
});
it("removes tag-only messages", () => {
const result = extractAudioTag("[[audio_as_voice]]");
expect(result.audioAsVoice).toBe(true);
expect(result.cleaned).toBe("");
});
});