
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
@libtelegram/helpers
Advanced tools
LibTelegram AntiFlood middleware
Learn about the hitting limits in Telegram Bots API.
You can install this package by the following command.
npm install @libtelegram/anti-flood
const antiFlood = require('@libtelegram/anti-flood');
The antiFlood
object exposes various factories to create middlewares
The omission
function skips the message if the time elapsed since the previous message is less than a delay
function callback(usr, msg) {
usr.reply('Too many messages');
}
bot.use(antiFlood.omission({ delay: 1 / 2 }, callback));
The omission
function takes an options
object that may contain any of the following keys:
The minimum time interval between messages in seconds
Defaults to 0.5
.
Callback to be called after too many messages are detected
callback
has a signature of (usr, msg)
.
function callback(usr, msg) {
usr.reply('You won\'t be able to use the bot for 2 minutes');
}
bot.use(antiFlood.penalty({
maxAttempts: 3,
timeLimit: 2,
timeBlocked: 2 * 60,
}, callback));
The penalty
function takes an options
object that may contain any of the following keys:
The maximum number of requests from a user for a given time limit. After exceeding the number of attempts, the bot will not respond to user messages
Defaults to 5
.
The time in seconds during which the counter of attempts is added.
Defaults to 2
.
The time in seconds for which the user will be blocked
Defaults to 60
.
Callback to be called after user is blocked
callback
has a signature of (usr, msg)
.
FAQs
AntiFlood middleware for LibTelegram
We found that @libtelegram/helpers demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.