blob: da8d02d5bb8a0095e9e91042e1fadc5fcc1be935 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
import { Telegraf } from "telegraf";
import config from "./config";
import { addActiveChat, removeActiveChat } from "./db";
import { tgMiddleware } from "./middleware";
console.log(`Setting up Telegram bot with token ${config.tgBotToken}`);
const bot = new Telegraf(config.tgBotToken);
bot.use(tgMiddleware.auth);
bot.command("/start", async (ctx) => {
await addActiveChat(ctx.chat.id);
await ctx.reply("HommaBot startattu. Uusia hommapäivityksiä viikon välein.");
});
bot.command("/stop", async (ctx) => {
await removeActiveChat(ctx.chat.id);
await ctx.reply("HommaBot pysäytetty!");
});
export { bot };
|