mirror of
https://github.com/flibusta-apps/book_bot.git
synced 2025-12-06 15:35:35 +01:00
Add bot debugger
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import { Context, Telegraf, Markup, TelegramError } from 'telegraf';
|
import { Context, Telegraf, Markup, TelegramError } from 'telegraf';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
|
import debug from 'debug';
|
||||||
|
|
||||||
import { BotState } from '@/bots/manager/types';
|
import { BotState } from '@/bots/manager/types';
|
||||||
|
|
||||||
@@ -24,6 +25,9 @@ import { getAnnotationHandler } from './annotations';
|
|||||||
import Sentry from '@/sentry';
|
import Sentry from '@/sentry';
|
||||||
|
|
||||||
|
|
||||||
|
const botDebugger = debug("approvedBot");
|
||||||
|
|
||||||
|
|
||||||
export async function createApprovedBot(token: string, state: BotState): Promise<Telegraf> {
|
export async function createApprovedBot(token: string, state: BotState): Promise<Telegraf> {
|
||||||
const bot = new Telegraf(token, {
|
const bot = new Telegraf(token, {
|
||||||
telegram: {
|
telegram: {
|
||||||
@@ -456,7 +460,7 @@ export async function createApprovedBot(token: string, state: BotState): Promise
|
|||||||
});
|
});
|
||||||
|
|
||||||
bot.catch((err, ctx: Context) => {
|
bot.catch((err, ctx: Context) => {
|
||||||
console.log({err, ctx});
|
botDebugger.log({err, ctx});
|
||||||
Sentry.captureException(err);
|
Sentry.captureException(err);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user