Fix reply message not found

This commit is contained in:
2022-03-05 22:48:24 +03:00
parent 4045eb3bc4
commit d948fc1f36
2 changed files with 17 additions and 5 deletions

View File

@@ -6,3 +6,9 @@ export function isNotModifiedMessage(e: any): boolean {
return e.description === 'Bad Request: message is not modified: specified new message content and reply markup are exactly the same as a current content and reply markup of the message';
}
export function isReplyMessageNotFound(e: any): boolean {
if (!(e instanceof TelegramError)) return false;
return e.description === 'Bad Request: replied message not found';
}

View File

@@ -20,7 +20,7 @@ import { getRandomKeyboard, getTextPaginationData, getUpdateLogKeyboard, getUser
import { sendFile } from './hooks/downloading';
import { setCommands } from './hooks/setCommands';
import { downloadImage } from './services/downloader';
import { isNotModifiedMessage } from './errors_utils';
import { isNotModifiedMessage, isReplyMessageNotFound } from './errors_utils';
Sentry.init({
@@ -378,10 +378,16 @@ export async function createApprovedBot(token: string, state: BotState): Promise
]
]);
await ctx.telegram.sendMessage(ctx.message.chat.id, Messages.SEARCH_MESSAGE, {
reply_to_message_id: ctx.message.message_id,
reply_markup: keyboard.reply_markup,
});
try {
await ctx.telegram.sendMessage(ctx.message.chat.id, Messages.SEARCH_MESSAGE, {
reply_to_message_id: ctx.message.message_id,
reply_markup: keyboard.reply_markup,
});
} catch (e) {
if (!isReplyMessageNotFound(e)) {
Sentry.captureException(e);
}
}
});
bot.catch((err) => {