
Security News
Critical Security Vulnerability in React Server Components
React disclosed a CVSS 10.0 RCE in React Server Components and is advising users to upgrade affected packages and frameworks to patched versions now.
@xbibzlibrary/xbibz-team-telegram-bot
Advanced tools
A powerful and comprehensive Telegram bot library for TypeScript that exceeds Telegraf in functionality and ease of use
Built with โค๏ธ by Xbibz Official
๐ Features โข ๐ฆ Installation โข ๐ฏ Quick Start โข ๐ Documentation โข ๐ก Examples
๐ฏ Easy to UseSimple and intuitive API that makes bot development a breeze |
๐ High PerformanceOptimized for speed and efficiency with minimal overhead |
๐ช Full-FeaturedComplete Telegram Bot API support with advanced features |
๐ TypeScript FirstBuilt with TypeScript for excellent type safety and IntelliSense |
๐ง FlexibleHighly customizable with middleware and plugin support |
๐ Well DocumentedComprehensive documentation with plenty of examples |
# Using npm
npm install @xbibzlibrary/xbibz-team-telegram-bot
# Using yarn
yarn add @xbibzlibrary/xbibz-team-telegram-bot
# Using pnpm
pnpm add @xbibzlibrary/xbibz-team-telegram-bot
Create your first bot in just a few lines of code!
import { XbibzTelegramBot } from '@xbibzlibrary/xbibz-team-telegram-bot';
// Initialize the bot
const bot = new XbibzTelegramBot('YOUR_BOT_TOKEN', {
polling: true,
logLevel: 'info'
});
// Handle /start command
bot.command('start', async (ctx) => {
await ctx.reply('Hello! ๐ Welcome to Xbibz Bot!');
});
// Handle text messages
bot.onMessage(async (ctx) => {
if (ctx.text) {
await ctx.reply(`You said: ${ctx.text}`);
}
});
// Launch the bot
bot.launch();
console.log('๐ค Bot is running!');
Get your bot token from @BotFather and replace YOUR_BOT_TOKEN with it.
Commands are the backbone of Telegram bots. Xbibz makes it incredibly easy!
// Single command
bot.command('help', async (ctx) => {
await ctx.reply('Need help? Contact @XbibzOfficial');
});
// Multiple commands
bot.command(['hello', 'hi', 'hey'], async (ctx) => {
await ctx.reply('Hello there! ๐');
});
// Access command arguments
bot.command('echo', async (ctx) => {
const args = ctx.stateData.args; // Array of arguments
await ctx.reply(args.join(' '));
});
Handle different types of messages with ease!
// Text messages
bot.onMessage(async (ctx) => {
if (ctx.text) {
console.log('Received text:', ctx.text);
}
});
// Photo messages
bot.messageHandler.onPhoto(async (ctx) => {
await ctx.reply('Nice photo! ๐ธ');
});
// Video messages
bot.messageHandler.onVideo(async (ctx) => {
await ctx.reply('Cool video! ๐ฅ');
});
// Document messages
bot.messageHandler.onDocument(async (ctx) => {
await ctx.reply('Got your document! ๐');
});
// Location messages
bot.messageHandler.onLocation(async (ctx) => {
const { latitude, longitude } = ctx.message.location;
await ctx.reply(`Your location: ${latitude}, ${longitude} ๐`);
});
Create interactive buttons for your bot!
// Send message with inline keyboard
bot.command('menu', async (ctx) => {
const keyboard = {
inline_keyboard: [
[
{ text: '๐ Stats', callback_data: 'stats' },
{ text: 'โ๏ธ Settings', callback_data: 'settings' }
],
[
{ text: 'โ Help', callback_data: 'help' }
]
]
};
await ctx.reply('Choose an option:', { reply_markup: keyboard });
});
// Handle callback queries
bot.callbackQueryHandler.onData('stats', async (ctx) => {
await ctx.answerCallbackQuery({ text: 'Loading stats...' });
await ctx.editMessage('Here are your stats! ๐');
});
bot.callbackQueryHandler.onData('settings', async (ctx) => {
await ctx.answerCallbackQuery();
await ctx.editMessage('Settings menu โ๏ธ');
});
// Use regex for callback data
bot.callbackQueryHandler.onRegex(/^page_(\d+)$/, async (ctx) => {
const match = ctx.stateData.callbackMatch;
const page = match[1];
await ctx.editMessage(`Showing page ${page}`);
});
Keep track of user data across conversations!
const bot = new XbibzTelegramBot('YOUR_BOT_TOKEN', {
session: {
enabled: true,
storage: 'memory', // or 'file', 'redis', 'mongodb'
defaultSession: { count: 0 }
}
});
bot.command('count', async (ctx) => {
ctx.session.count = (ctx.session.count || 0) + 1;
await ctx.reply(`Button pressed ${ctx.session.count} times!`);
});
bot.command('reset', async (ctx) => {
ctx.session.count = 0;
await ctx.reply('Counter reset! ๐');
});
Create powerful middleware for your bot!
// Logging middleware
bot.use(async (ctx, next) => {
const start = Date.now();
await next();
const ms = Date.now() - start;
console.log(`Processing took ${ms}ms`);
});
// Admin-only middleware
async function adminOnly(ctx, next) {
const adminIds = [123456789, 987654321];
if (adminIds.includes(ctx.fromId)) {
return next();
}
await ctx.reply('โ Admin only command!');
}
bot.command('admin', adminOnly, async (ctx) => {
await ctx.reply('โ
Admin access granted!');
});
// Rate limiting middleware
const userLastMessage = new Map();
bot.use(async (ctx, next) => {
const userId = ctx.fromId;
const now = Date.now();
const lastMsg = userLastMessage.get(userId) || 0;
if (now - lastMsg < 1000) { // 1 second cooldown
await ctx.reply('โฐ Please wait before sending another message!');
return;
}
userLastMessage.set(userId, now);
await next();
});
Use filters to handle specific types of messages!
import { Filter } from '@xbibzlibrary/xbibz-team-telegram-bot';
// Private chat only
bot.use(async (ctx, next) => {
if (Filter.private(ctx)) {
return next();
}
await ctx.reply('This command works only in private chats!');
});
// Photo in private chat
bot.use(async (ctx, next) => {
if (Filter.and(Filter.private, Filter.photo)(ctx)) {
await ctx.reply('Private photo received! ๐ธ');
}
await next();
});
// Text containing "hello"
bot.use(async (ctx, next) => {
if (Filter.contains('hello')(ctx)) {
await ctx.reply('Hello! ๐');
}
await next();
});
// Regex pattern
bot.use(async (ctx, next) => {
if (Filter.regex(/\d{4}/)(ctx)) { // 4 digits
await ctx.reply('Found a 4-digit number!');
}
await next();
});
Multiple ways to send messages!
// Simple text
await ctx.reply('Hello World!');
// With formatting
await ctx.reply('*Bold* _italic_ `code`', {
parse_mode: 'Markdown'
});
// With HTML
await ctx.reply('<b>Bold</b> <i>italic</i>', {
parse_mode: 'HTML'
});
// Reply to message
await ctx.reply('This is a reply!', {
reply_to_message_id: ctx.messageId
});
// Send photo
await ctx.replyWithPhoto('https://example.com/photo.jpg', 'Photo caption');
// Send video
await ctx.replyWithVideo('https://example.com/video.mp4', 'Video caption');
// Send document
await ctx.replyWithDocument('https://example.com/doc.pdf', 'Document caption');
// Send location
await ctx.replyWithLocation(51.5074, -0.1278); // London coordinates
// Send poll
await ctx.replyWithPoll('What is your favorite color?', [
'Red', 'Blue', 'Green', 'Yellow'
]);
The context object gives you access to everything!
bot.onMessage(async (ctx) => {
// Message info
const text = ctx.text;
const messageId = ctx.messageId;
const chatId = ctx.chatId;
const userId = ctx.fromId;
// User info
const user = ctx.from;
console.log(user.first_name, user.username);
// Chat info
const chat = ctx.chat;
console.log(chat.type); // private, group, supergroup, channel
// Session
ctx.session.userData = 'some data';
// Typing action
await ctx.sendTyping();
// Edit message
await ctx.editMessage('New text');
// Delete message
await ctx.deleteMessage();
// Forward message
await ctx.forwardMessage(fromChatId, messageId);
// Chat actions
await ctx.banChatMember(userId);
await ctx.unbanChatMember(userId);
await ctx.pinChatMessage(messageId);
});
import { XbibzTelegramBot } from '@xbibzlibrary/xbibz-team-telegram-bot';
const bot = new XbibzTelegramBot('YOUR_BOT_TOKEN');
bot.command('start', async (ctx) => {
await ctx.reply('Echo bot started! Send me any message.');
});
bot.onMessage(async (ctx) => {
if (ctx.text && !ctx.text.startsWith('/')) {
await ctx.reply(ctx.text);
}
});
bot.launch();
const bot = new XbibzTelegramBot('YOUR_BOT_TOKEN', {
session: { enabled: true }
});
const questions = [
{ q: 'What is 2+2?', a: '4' },
{ q: 'Capital of France?', a: 'Paris' },
{ q: 'Largest planet?', a: 'Jupiter' }
];
bot.command('quiz', async (ctx) => {
ctx.session.score = 0;
ctx.session.questionIndex = 0;
const q = questions[0];
await ctx.reply(`Question 1: ${q.q}`);
});
bot.onMessage(async (ctx) => {
if (ctx.session.questionIndex !== undefined) {
const currentQ = questions[ctx.session.questionIndex];
if (ctx.text?.toLowerCase() === currentQ.a.toLowerCase()) {
ctx.session.score++;
await ctx.reply('โ
Correct!');
} else {
await ctx.reply(`โ Wrong! Answer: ${currentQ.a}`);
}
ctx.session.questionIndex++;
if (ctx.session.questionIndex < questions.length) {
const nextQ = questions[ctx.session.questionIndex];
await ctx.reply(`Question ${ctx.session.questionIndex + 1}: ${nextQ.q}`);
} else {
await ctx.reply(`๐ Quiz finished! Score: ${ctx.session.score}/${questions.length}`);
delete ctx.session.questionIndex;
}
}
});
bot.launch();
const bot = new XbibzTelegramBot('YOUR_BOT_TOKEN', {
session: { enabled: true, defaultSession: { cart: [] } }
});
const products = {
'apple': { name: 'Apple', price: 1.5 },
'banana': { name: 'Banana', price: 0.8 },
'orange': { name: 'Orange', price: 1.2 }
};
bot.command('shop', async (ctx) => {
const keyboard = {
inline_keyboard: Object.keys(products).map(key => ([
{ text: `${products[key].name} - $${products[key].price}`, callback_data: `buy_${key}` }
]))
};
await ctx.reply('๐ Welcome to our shop!', { reply_markup: keyboard });
});
bot.callbackQueryHandler.onRegex(/^buy_(.+)$/, async (ctx) => {
const productKey = ctx.stateData.callbackMatch[1];
const product = products[productKey];
ctx.session.cart.push(product);
await ctx.answerCallbackQuery({ text: `Added ${product.name} to cart!` });
});
bot.command('cart', async (ctx) => {
if (ctx.session.cart.length === 0) {
await ctx.reply('๐ Your cart is empty!');
return;
}
const total = ctx.session.cart.reduce((sum, item) => sum + item.price, 0);
const items = ctx.session.cart.map(item => `${item.name} - $${item.price}`).join('\n');
await ctx.reply(`๐ Your cart:\n${items}\n\nTotal: $${total.toFixed(2)}`);
});
bot.command('clear', async (ctx) => {
ctx.session.cart = [];
await ctx.reply('๐๏ธ Cart cleared!');
});
bot.launch();
xbibz-team-telegram-bot/
โโโ src/
โ โโโ core/
โ โ โโโ bot.ts # Main bot class
โ โ โโโ context.ts # Context class
โ โโโ api/
โ โ โโโ api-client.ts # Telegram API client
โ โโโ handlers/
โ โ โโโ command-handler.ts
โ โ โโโ message-handler.ts
โ โ โโโ callback-query-handler.ts
โ โ โโโ inline-query-handler.ts
โ โโโ middleware/
โ โ โโโ middleware.ts # Middleware system
โ โโโ session/
โ โ โโโ session-manager.ts
โ โโโ filters/
โ โ โโโ filter.ts # Message filters
โ โโโ utils/
โ โ โโโ logger.ts
โ โ โโโ error-handler.ts
โ โโโ types/
โ โ โโโ index.ts # TypeScript types
โ โโโ index.ts # Main export
โโโ examples/
โ โโโ basic/
โ โโโ advanced/
โ โโโ custom-middleware/
โโโ tests/
โโโ dist/ # Compiled output
โโโ package.json
# Install dependencies
npm install
# Build the project
npm run build
# Development mode (watch)
npm run dev
# Run tests
npm test
# Lint code
npm run lint
# Clean build
npm run clean
We welcome contributions! Here's how you can help:
git checkout -b feature/amazing-feature)git commit -m 'Add amazing feature')git push origin feature/amazing-feature)
๐ฑ Telegram@XbibzOfficial |
๐ต TikTok@xbibzofficiall |
โ DonateKo-fi |
Found this helpful? Consider supporting the project! โค๏ธ
This project is licensed under the MIT License - see the LICENSE file for details.

If you like this project, please give it a โญ on GitHub!
FAQs
A powerful and comprehensive Telegram bot library for TypeScript that exceeds Telegraf in functionality and ease of use
The npm package @xbibzlibrary/xbibz-team-telegram-bot receives a total of 0 weekly downloads. As such, @xbibzlibrary/xbibz-team-telegram-bot popularity was classified as not popular.
We found that @xbibzlibrary/xbibz-team-telegram-bot demonstrated a healthy version release cadence and project activity because the last version was released less than 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
React disclosed a CVSS 10.0 RCE in React Server Components and is advising users to upgrade affected packages and frameworks to patched versions now.

Research
/Security News
We spotted a wave of auto-generated โelf-*โ npm packages published every two minutes from new accounts, with simple malware variants and early takedowns underway.

Security News
TypeScript 6.0 will be the last JavaScript-based major release, as the project shifts to the TypeScript 7 native toolchain with major build speedups.