feat(telegram): implement intermittent status updates (edit/inline)
This commit is contained in:
parent
005b601b13
commit
e7486d1a55
@ -93,9 +93,7 @@ export async function deliverReplies(params: {
|
|||||||
|
|
||||||
if (shouldEditLast && reply.text) {
|
if (shouldEditLast && reply.text) {
|
||||||
const editId = String(lastSent!.messageId);
|
const editId = String(lastSent!.messageId);
|
||||||
console.error(
|
|
||||||
`[CRITICAL LOG] [telegram/bot/delivery.ts] Editing previous STATUS message ${editId} with: ${JSON.stringify(reply.text)}`,
|
|
||||||
);
|
|
||||||
try {
|
try {
|
||||||
await editMessageTelegram(chatId, editId, reply.text, {
|
await editMessageTelegram(chatId, editId, reply.text, {
|
||||||
token: params.token,
|
token: params.token,
|
||||||
@ -104,17 +102,12 @@ export async function deliverReplies(params: {
|
|||||||
});
|
});
|
||||||
sentMessageId = editId;
|
sentMessageId = editId;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(
|
logVerbose(`Telegram edit failed, falling back to new message: ${String(err)}`);
|
||||||
`[CRITICAL LOG] [telegram/bot/delivery.ts] Edit failed, falling back to new message: ${String(err)}`,
|
|
||||||
);
|
|
||||||
// Fall through to send new message
|
// Fall through to send new message
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!sentMessageId && reply.isStatusMessage && reply.text) {
|
if (!sentMessageId && reply.isStatusMessage && reply.text) {
|
||||||
console.error(
|
|
||||||
`[CRITICAL LOG] [telegram/bot/delivery.ts] Sending NEW status message: ${JSON.stringify(reply.text)}`,
|
|
||||||
);
|
|
||||||
const result = await sendMessageTelegram(chatId, reply.text, {
|
const result = await sendMessageTelegram(chatId, reply.text, {
|
||||||
token: params.token,
|
token: params.token,
|
||||||
accountId: params.accountId,
|
accountId: params.accountId,
|
||||||
@ -126,9 +119,6 @@ export async function deliverReplies(params: {
|
|||||||
} else if (!sentMessageId) {
|
} else if (!sentMessageId) {
|
||||||
const chunks = chunkText(reply.text || "");
|
const chunks = chunkText(reply.text || "");
|
||||||
for (const chunk of chunks) {
|
for (const chunk of chunks) {
|
||||||
console.error(
|
|
||||||
`[CRITICAL LOG] [telegram/bot/delivery.ts] Sending text chunk: ${JSON.stringify(chunk.text)}`,
|
|
||||||
);
|
|
||||||
const msgId = await sendTelegramText(bot, chatId, chunk.html, runtime, {
|
const msgId = await sendTelegramText(bot, chatId, chunk.html, runtime, {
|
||||||
replyToMessageId:
|
replyToMessageId:
|
||||||
replyToId && (replyToMode === "all" || !hasReplied) ? replyToId : undefined,
|
replyToId && (replyToMode === "all" || !hasReplied) ? replyToId : undefined,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user