fix: unify telegram thread handling

This commit is contained in:
Ayaan Zaidi
2026-02-02 08:53:42 +05:30
committed by Ayaan Zaidi
parent 5020bfa2a9
commit 19b8416a81
10 changed files with 151 additions and 46 deletions

View File

@@ -1,5 +1,5 @@
import type { Bot } from "grammy";
import { buildTelegramThreadParams } from "./bot/helpers.js";
import { buildTelegramThreadParams, type TelegramThreadSpec } from "./bot/helpers.js";
const TELEGRAM_DRAFT_MAX_CHARS = 4096;
const DEFAULT_THROTTLE_MS = 300;
@@ -15,7 +15,7 @@ export function createTelegramDraftStream(params: {
chatId: number;
draftId: number;
maxChars?: number;
messageThreadId?: number;
thread?: TelegramThreadSpec | number | null;
throttleMs?: number;
log?: (message: string) => void;
warn?: (message: string) => void;
@@ -25,7 +25,7 @@ export function createTelegramDraftStream(params: {
const rawDraftId = Number.isFinite(params.draftId) ? Math.trunc(params.draftId) : 1;
const draftId = rawDraftId === 0 ? 1 : Math.abs(rawDraftId);
const chatId = params.chatId;
const threadParams = buildTelegramThreadParams(params.messageThreadId);
const threadParams = buildTelegramThreadParams(params.thread);
let lastSentText = "";
let lastSentAt = 0;