mirror of
https://github.com/flibusta-apps/book_bot.git
synced 2025-12-06 15:35:35 +01:00
Fix setMyCommands
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { Context, Telegraf, Markup } from 'telegraf';
|
import { Context, Telegraf, Markup, TelegramError } from 'telegraf';
|
||||||
|
|
||||||
import { BotState, Cache } from '@/bots/manager';
|
import { BotState, Cache } from '@/bots/manager';
|
||||||
|
|
||||||
@@ -25,12 +25,22 @@ export async function createApprovedBot(token: string, state: BotState): Promise
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
async function setMyCommands() {
|
||||||
await bot.telegram.setMyCommands([
|
await bot.telegram.setMyCommands([
|
||||||
{command: "random", description: "Попытать удачу"},
|
{command: "random", description: "Попытать удачу"},
|
||||||
{command: "update_log", description: "Информация об обновлении каталога"},
|
{command: "update_log", description: "Информация об обновлении каталога"},
|
||||||
{command: "settings", description: "Настройки"},
|
{command: "settings", description: "Настройки"},
|
||||||
{command: "help", description: "Помощь"},
|
{command: "help", description: "Помощь"},
|
||||||
]);
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
await setMyCommands();
|
||||||
|
} catch (e: unknown) {
|
||||||
|
if (e instanceof TelegramError && e.response.error_code === 429) {
|
||||||
|
setTimeout(() => setMyCommands(), 1000 * (e.response.parameters?.retry_after || 5));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bot.use(async (ctx: Context, next) => {
|
bot.use(async (ctx: Context, next) => {
|
||||||
if (ctx.from) {
|
if (ctx.from) {
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import BotsManager from './bots/manager';
|
import BotsManager from './bots/manager';
|
||||||
|
|
||||||
|
setTimeout(() => BotsManager.start(), 5000);
|
||||||
BotsManager.start();
|
|
||||||
|
|||||||
Reference in New Issue
Block a user