telegram-user: align outbound reply + chunking
This commit is contained in:
parent
7f4e402c4d
commit
29d9d875a7
@ -58,6 +58,12 @@ type TelegramUserSetupInput = ChannelSetupInput & {
|
|||||||
apiHash?: string;
|
apiHash?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function parseReplyToId(replyToId?: string | null): number | undefined {
|
||||||
|
if (!replyToId) return undefined;
|
||||||
|
const parsed = Number.parseInt(replyToId, 10);
|
||||||
|
return Number.isFinite(parsed) ? parsed : undefined;
|
||||||
|
}
|
||||||
|
|
||||||
function normalizeTelegramUserGroupKey(raw?: string | null): string | undefined {
|
function normalizeTelegramUserGroupKey(raw?: string | null): string | undefined {
|
||||||
if (!raw) return undefined;
|
if (!raw) return undefined;
|
||||||
const trimmed = raw.trim();
|
const trimmed = raw.trim();
|
||||||
@ -238,16 +244,20 @@ export const telegramUserPlugin: ChannelPlugin<ResolvedTelegramUserAccount> = {
|
|||||||
deliveryMode: "direct",
|
deliveryMode: "direct",
|
||||||
chunker: (text, limit) =>
|
chunker: (text, limit) =>
|
||||||
getTelegramUserRuntime().channel.text.chunkMarkdownText(text, limit),
|
getTelegramUserRuntime().channel.text.chunkMarkdownText(text, limit),
|
||||||
|
chunkerMode: "markdown",
|
||||||
textChunkLimit: 4000,
|
textChunkLimit: 4000,
|
||||||
pollMaxOptions: 10,
|
pollMaxOptions: 10,
|
||||||
sendText: async ({ to, text, accountId, threadId }) => {
|
sendText: async ({ to, text, accountId, threadId, replyToId }) => {
|
||||||
|
const parsedReplyToId = parseReplyToId(replyToId);
|
||||||
const result = await sendMessageTelegramUser(to, text, {
|
const result = await sendMessageTelegramUser(to, text, {
|
||||||
accountId: accountId ?? undefined,
|
accountId: accountId ?? undefined,
|
||||||
threadId,
|
threadId,
|
||||||
|
...(parsedReplyToId ? { replyToId: parsedReplyToId } : {}),
|
||||||
});
|
});
|
||||||
return { channel: "telegram-user", ...result };
|
return { channel: "telegram-user", ...result };
|
||||||
},
|
},
|
||||||
sendMedia: async ({ cfg, to, text, mediaUrl, accountId, threadId }) => {
|
sendMedia: async ({ cfg, to, text, mediaUrl, accountId, threadId, replyToId }) => {
|
||||||
|
const parsedReplyToId = parseReplyToId(replyToId);
|
||||||
const maxBytes = resolveChannelMediaMaxBytes({
|
const maxBytes = resolveChannelMediaMaxBytes({
|
||||||
cfg,
|
cfg,
|
||||||
resolveChannelLimitMb: ({ cfg, accountId }) =>
|
resolveChannelLimitMb: ({ cfg, accountId }) =>
|
||||||
@ -261,14 +271,17 @@ export const telegramUserPlugin: ChannelPlugin<ResolvedTelegramUserAccount> = {
|
|||||||
accountId: accountId ?? undefined,
|
accountId: accountId ?? undefined,
|
||||||
mediaUrl,
|
mediaUrl,
|
||||||
threadId,
|
threadId,
|
||||||
|
...(parsedReplyToId ? { replyToId: parsedReplyToId } : {}),
|
||||||
...(maxBytes ? { maxBytes } : {}),
|
...(maxBytes ? { maxBytes } : {}),
|
||||||
});
|
});
|
||||||
return { channel: "telegram-user", ...result };
|
return { channel: "telegram-user", ...result };
|
||||||
},
|
},
|
||||||
sendPoll: async ({ to, poll, accountId, threadId }) => {
|
sendPoll: async ({ to, poll, accountId, threadId, replyToId }) => {
|
||||||
|
const parsedReplyToId = parseReplyToId(replyToId);
|
||||||
const result = await sendPollTelegramUser(to, poll, {
|
const result = await sendPollTelegramUser(to, poll, {
|
||||||
accountId: accountId ?? undefined,
|
accountId: accountId ?? undefined,
|
||||||
threadId,
|
threadId,
|
||||||
|
...(parsedReplyToId ? { replyToId: parsedReplyToId } : {}),
|
||||||
});
|
});
|
||||||
return { channel: "telegram-user", ...result };
|
return { channel: "telegram-user", ...result };
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user