mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-12 09:11:12 +00:00
fix(telegram): add sendChatAction 401 backoff guard (land #27415, thanks @widingmarcus-cyber)
Co-authored-by: Marcus Widing <widing.marcus@gmail.com>
This commit is contained in:
@@ -116,6 +116,8 @@ export type BuildTelegramMessageContextParams = {
|
||||
resolveGroupActivation: ResolveGroupActivation;
|
||||
resolveGroupRequireMention: ResolveGroupRequireMention;
|
||||
resolveTelegramGroupConfig: ResolveTelegramGroupConfig;
|
||||
/** Global (per-account) handler for sendChatAction 401 backoff (#27092). */
|
||||
sendChatActionHandler: import("./sendchataction-401-backoff.js").TelegramSendChatActionHandler;
|
||||
};
|
||||
|
||||
async function resolveStickerVisionSupport(params: {
|
||||
@@ -156,6 +158,7 @@ export const buildTelegramMessageContext = async ({
|
||||
resolveGroupActivation,
|
||||
resolveGroupRequireMention,
|
||||
resolveTelegramGroupConfig,
|
||||
sendChatActionHandler,
|
||||
}: BuildTelegramMessageContextParams) => {
|
||||
const msg = primaryCtx.message;
|
||||
const chatId = msg.chat.id;
|
||||
@@ -243,7 +246,12 @@ export const buildTelegramMessageContext = async ({
|
||||
const sendTyping = async () => {
|
||||
await withTelegramApiErrorLogging({
|
||||
operation: "sendChatAction",
|
||||
fn: () => bot.api.sendChatAction(chatId, "typing", buildTypingThreadParams(replyThreadId)),
|
||||
fn: () =>
|
||||
sendChatActionHandler.sendChatAction(
|
||||
chatId,
|
||||
"typing",
|
||||
buildTypingThreadParams(replyThreadId),
|
||||
),
|
||||
});
|
||||
};
|
||||
|
||||
@@ -252,7 +260,11 @@ export const buildTelegramMessageContext = async ({
|
||||
await withTelegramApiErrorLogging({
|
||||
operation: "sendChatAction",
|
||||
fn: () =>
|
||||
bot.api.sendChatAction(chatId, "record_voice", buildTypingThreadParams(replyThreadId)),
|
||||
sendChatActionHandler.sendChatAction(
|
||||
chatId,
|
||||
"record_voice",
|
||||
buildTypingThreadParams(replyThreadId),
|
||||
),
|
||||
});
|
||||
} catch (err) {
|
||||
logVerbose(`telegram record_voice cue failed for chat ${chatId}: ${String(err)}`);
|
||||
|
||||
Reference in New Issue
Block a user