0.0.4 • Published 4 years ago

@botol/tg-session v0.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

Botol TgBot Session

Example

import { BotolTg } from '@botol/tg-bot';
import { BotolSession } from '@botol/tg-session';

type session = { user: string };
let bot = new BotolTg('<token>');
let botSession = bot.middleware(
    BotolSession<session>({
        init: () => ({ user: 'undefined' }),
    }),
);
botSession.use(async (ctx) => {
    await ctx.reply(`hi ${ctx.session.user}`);
    if (ctx.text != null) {
        ctx.session.user = ctx.text;
    }
});
bot1.startPolling();