fix(telegram): fix regex precedence for 403 error detection
- Group alternatives correctly: /403.*(bot.*not.*member|bot was blocked)/i - Require 403 for both alternatives (previously bot.*blocked matched any error) - Update error message to cover both scenarios - Fixes Greptile review feedback
This commit is contained in:
parent
f0f8226fac
commit
e9c69ff1df
@ -493,12 +493,12 @@ function createTelegramRequestWithDiag(params: {
|
||||
function wrapTelegramChatNotFoundError(err: unknown, params: { chatId: string; input: string }) {
|
||||
const errorMsg = formatErrorMessage(err);
|
||||
|
||||
// Check for 403 "bot is not a member" error
|
||||
if (/403.*bot.*not.*member|bot.*blocked/i.test(errorMsg)) {
|
||||
// Check for 403 "bot is not a member" or "bot was blocked" errors
|
||||
if (/403.*(bot.*not.*member|bot was blocked)/i.test(errorMsg)) {
|
||||
return new Error(
|
||||
[
|
||||
`Telegram send failed: bot is not a member of the chat (chat_id=${params.chatId}).`,
|
||||
"Fix: Add the bot to the channel/group, or ensure it has not been removed/blocked.",
|
||||
`Telegram send failed: bot is not a member of the chat or was blocked (chat_id=${params.chatId}).`,
|
||||
"Fix: Add the bot to the channel/group, or ensure it has not been removed/blocked by the user.",
|
||||
`Input was: ${JSON.stringify(params.input)}.`,
|
||||
].join(" "),
|
||||
);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user