Skip to content

s0ftik3/telegraf-userblock

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Telegraf User Block

Telegraf (Telegram bot framework) middleware that helps you to handle users who blocked your bot.

Installation

$ npm i telegraf-userblock

Example

const Telegraf = require('telegraf');
const userBlock = require('telegraf-userblock');

const bot = new Telegraf(process.env.TOKEN);

bot.use(
    userBlock({
        onUserBlock: (ctx, next, userId) => {
            console.log('This user %s has blocked the bot.', userId);
            return next();
        },
    })
);

bot.launch();

API

Options

  • onUserBlock: action after some user blocked your bot.
{
    onUserBlock: (ctx, next, userId) => {
        // ctx — current context
        // next — go ahead after work of middleware's done
        // userId — id of the user who blocked the bot, alternatively you could use ctx.update.my_chat_member.from.id
    },
};

About

Handling if user blocked the bot middleware for Telegraf.

Topics

Resources

License

Stars

Watchers

Forks