This commit is contained in:
2022-08-06 13:09:59 +03:00
parent 553b87e1ba
commit 6d36d2c90e

View File

@@ -1,4 +1,4 @@
import { Context, Telegraf, Markup } from 'telegraf'; import { Context, Telegraf, Markup, TelegramError } from 'telegraf';
import moment from 'moment'; import moment from 'moment';
import { BotState } from '@/bots/manager/types'; import { BotState } from '@/bots/manager/types';
@@ -60,11 +60,18 @@ export async function createApprovedBot(token: string, state: BotState): Promise
} }
const name = ctx.message.from.first_name || ctx.message.from.username || 'пользователь'; const name = ctx.message.from.first_name || ctx.message.from.username || 'пользователь';
try {
await ctx.telegram.sendMessage(ctx.message.chat.id, await ctx.telegram.sendMessage(ctx.message.chat.id,
Messages.START_MESSAGE.replace('{name}', name), { Messages.START_MESSAGE.replace('{name}', name), {
reply_to_message_id: ctx.message.message_id, reply_to_message_id: ctx.message.message_id,
} }
); );
} catch (e) {
if (e instanceof TelegramError) {
if (e.code !== 403) throw e;
}
}
}); });
bot.command(["help", `help@${me.username}`], async (ctx: Context) => ctx.reply(Messages.HELP_MESSAGE)); bot.command(["help", `help@${me.username}`], async (ctx: Context) => ctx.reply(Messages.HELP_MESSAGE));