Skip to content

Commit

Permalink
Re-enable telegram
Browse files Browse the repository at this point in the history
  • Loading branch information
LunaUrsa committed Oct 14, 2023
1 parent 6fa54a3 commit a15f9cf
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 27 deletions.
5 changes: 3 additions & 2 deletions src/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ import discordConnect from './discord/discord';
import api from './discord/api/api'; // eslint-disable-line
// import startMatrix from './matrix/matrix';
// import ircConnect from './irc/irc';
// import telegramConnect from './telegram/telegram';
import telegramConnect from './telegram/telegram';

sourceMap.install();

global.bootTime = new Date();
Expand All @@ -37,7 +38,7 @@ async function start() {
if (env.DISCORD_CLIENT_TOKEN && validateEnv('DISCORD')) await discordConnect();
// if (env.MATRIX_ACCESS_TOKEN && validateEnv('MATRIX') && env.NODE_ENV !== 'production') await startMatrix();
// if (env.IRC_PASSWORD && validateEnv('IRC') && env.NODE_ENV !== 'production') ircConnect();
// if (env.TELEGRAM_TOKEN && validateEnv('TELEGRAM') && env.NODE_ENV !== 'production') await telegramConnect();
if (env.TELEGRAM_TOKEN && validateEnv('TELEGRAM') && env.NODE_ENV !== 'production') await telegramConnect();
}

start();
Expand Down
50 changes: 32 additions & 18 deletions src/telegram/commands/t.index.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,34 @@
/* eslint-disable global-require */
import { Composer } from 'telegraf';
import start from './t.start';
import drug from './t.drug';
import topic from './t.topic';
import combo from './t.combo';
import breathe from './t.breathe';
import combochart from './t.combochart';
import irc from './t.irc';
import ban from './t.ban';
import moderateChat from './t.moderateChat';
import gban from './t.gban';
import about from './t.about';
import recovery from './t.recovery';
import calcMushrooms from './t.calc-mushrooms';
import calcLsd from './t.calc-lsd';

export default Composer.compose([
require('./t.start'),
require('./t.drug'),
require('./t.topic'),
require('./t.combo'),
require('./t.breathe'),
require('./t.combochart'),
require('./t.irc'),
require('./t.ban'),
require('./t.moderateChat'),
require('./t.gban'),
// require('./t.eightball'),
require('./t.about'),
require('./t.recovery'),
require('./t.calc-mushrooms'),
require('./t.calc-lsd'),
]);

export default [
start,
drug,
topic,
combo,
breathe,
combochart,
irc,
ban,
moderateChat,
gban,
// eightball,
about,
recovery,
calcMushrooms,
calcLsd,
]
15 changes: 9 additions & 6 deletions src/telegram/telegram.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
import { Telegraf as TelegramClient } from 'telegraf';

const commands = require('./commands/t.index');
import { Telegraf } from 'telegraf';
import commands from './commands/t.index';

const F = f(__filename);

export default async function telegramConnect() {
log.debug(F, 'Connecting to Telegram...');

const bot = new TelegramClient(env.TELEGRAM_TOKEN);
const bot = new Telegraf(env.TELEGRAM_TOKEN);

// load bot commands
bot.use(commands);
bot.use(...commands);

bot.launch();

bot.catch((err: any) => {
log.error(F, `Error in Telegram bot: ${err}`);
});

global.telegramClient = bot;

process.once('SIGINT', () => bot.stop('SIGINT'));
process.once('SIGTERM', () => bot.stop('SIGTERM'));
}

declare global {
var telegramClient: TelegramClient; // eslint-disable-line
var telegramClient: Telegraf;
}
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"*/matrix/*",
"*/node_modules",
"node_modules",
"*/telegram/*",
// "*/telegram/*",
"**/__tests__editreply_/*",
"**/__tests__integration__/*",
"**/__tests__modals__/*",
Expand Down

0 comments on commit a15f9cf

Please sign in to comment.