https://github.com/s0ftik3/telegraf-userblock
Handling if user blocked the bot middleware for Telegraf.
https://github.com/s0ftik3/telegraf-userblock
bots telegraf telegram
Last synced: 5 months ago
JSON representation
Handling if user blocked the bot middleware for Telegraf.
- Host: GitHub
- URL: https://github.com/s0ftik3/telegraf-userblock
- Owner: s0ftik3
- License: mit
- Created: 2022-01-26T13:09:25.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-01-27T11:16:34.000Z (over 4 years ago)
- Last Synced: 2025-09-06T06:00:42.705Z (10 months ago)
- Topics: bots, telegraf, telegram
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/telegraf-userblock
- Size: 1.95 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Telegraf User Block
[Telegraf (Telegram bot framework)](https://github.com/telegraf/telegraf) middleware that helps you to handle users who blocked your bot.
## Installation
```js
$ npm i telegraf-userblock
```
## Example
```js
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.
```js
{
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
},
};
```