mirror of
https://github.com/flibusta-apps/book_bot.git
synced 2025-12-06 07:25:36 +01:00
Fix creating bots in manager
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
import * as Sentry from '@sentry/node';
|
||||||
|
|
||||||
import express, { Response, Request, NextFunction } from 'express';
|
import express, { Response, Request, NextFunction } from 'express';
|
||||||
import { Server } from 'http';
|
import { Server } from 'http';
|
||||||
|
|
||||||
@@ -10,12 +12,18 @@ import { Telegraf } from 'telegraf';
|
|||||||
import env from '@/config';
|
import env from '@/config';
|
||||||
import getBot, { BotStatuses } from './factory/index';
|
import getBot, { BotStatuses } from './factory/index';
|
||||||
|
|
||||||
|
Sentry.init({
|
||||||
|
dsn: env.SENTRY_DSN,
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
export enum Cache {
|
export enum Cache {
|
||||||
ORIGINAL = "original",
|
ORIGINAL = "original",
|
||||||
BUFFER = "buffer",
|
BUFFER = "buffer",
|
||||||
NO_CACHE = "no_cache"
|
NO_CACHE = "no_cache"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export interface BotState {
|
export interface BotState {
|
||||||
id: number;
|
id: number;
|
||||||
token: string;
|
token: string;
|
||||||
@@ -81,10 +89,17 @@ export default class BotsManager {
|
|||||||
await oldBot.telegram.deleteWebhook();
|
await oldBot.telegram.deleteWebhook();
|
||||||
await oldBot.telegram.logOut();
|
await oldBot.telegram.logOut();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e);
|
Sentry.captureException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
const bot = await getBot(state.token, state);
|
let bot: Telegraf;
|
||||||
|
|
||||||
|
try {
|
||||||
|
bot = await getBot(state.token, state);
|
||||||
|
} catch (e) {
|
||||||
|
Sentry.captureException(e);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const dockerIp = await dockerIpTools.getContainerIp();
|
const dockerIp = await dockerIpTools.getContainerIp();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user