
Security News
AGENTS.md Gains Traction as an Open Format for AI Coding Agents
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
@bot-base/callback-data
Advanced tools
Lightweight and simple library that helps manage callback data when using inline buttons in messages
$ npm install @bot-base/callback-data
or using yarn
:
$ yarn add @bot-base/callback-data
import { Telegraf, Markup, Context } from 'telegraf';
import { CallbackData } from '@bot-base/callback-data';
const bot = new Telegraf(process.env.BOT_TOKEN);
const greetingData = new CallbackData<{ type: string; }>(
'greeting', // namespace identifier
['type'] // data properties
);
bot.start((ctx: Context) =>
ctx.reply('How to greet?', {
...Markup.inlineKeyboard([
Markup.button.callback(
'oldschool',
greetingData.create({
type: 'oldschool',
})
), // callback data is equal to `greeting:oldschool`
Markup.button.callback(
'modern',
greetingData.create({
type: 'modern',
})
), // callback data is equal to `greeting:modern`
]),
})
);
bot.action(
greetingData.filter({
type: 'modern',
}),
(ctx) => ctx.answerCbQuery('Yo')
);
bot.action(
greetingData.filter({
type: 'oldschool',
}),
(ctx) => ctx.answerCbQuery('Hello')
);
bot.launch();
There's some more complex examples: counter and menu.
exampleCallbackData = new CallbackData(
'namespace-prefix',
['id', 'action' /* many as you want */]
/* separator = ':' */
);
const callbackData = exampleCallbackData.create({
id: '1337',
action: 'show',
});
console.log(callbackData); // namespace-prefix:1337:show
const parsedCallbackData = exampleCallbackData.parse(callbackData);
console.log(parsedCallbackData); // { id: "1337", action: "show" }
const regexpCallbackDataFilter = exampleCallbackData.filter({
action: 'show',
});
console.log(regexpCallbackDataFilter); // /namespace-prefix:.*:show/
FAQs
Easy callback data management for Telegram
The npm package @bot-base/callback-data receives a total of 0 weekly downloads. As such, @bot-base/callback-data popularity was classified as not popular.
We found that @bot-base/callback-data 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
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.