exuxmafuapi
v1.121.0
Published
API wrapper for ExuXmafu services
Downloads
139
Readme
exuxmarfoAPI
Node.js ESM port of pyTelegramBotAPI (telebot).
Version
4.33.0
Features
- ESM-native - Pure ES module architecture for Node.js 18+
- Architectural fidelity - Mirrors pyTelegramBotAPI's module separation
TeleBot- Core bot class (event registry, polling engine)apihelper- Raw HTTP request compilation and endpoint executiontypes- Telegram object schemas withstyleattribute for colored buttonsutil- Worker pool, token validation, async helpers
- Async event registry - Translated from Python's message_handler router array
- InlineKeyboardButton style - Native support for
"primary","success","danger"colored buttons - Worker pool - Async task execution with configurable thread count
- Handler system - Decorator and direct registration for all update types
Installation
npm install exuxmarfoAPIQuick Start
import { TeleBot } from 'exuxmarfoAPI';
import { InlineKeyboardButton, InlineKeyboardMarkup } from 'exuxmarfoAPI';
const bot = new TeleBot('YOUR_BOT_TOKEN', {
parse_mode: 'HTML'
});
// Handler registration via decorator-style pattern
bot.message_handler({ commands: ['start'] })(async (msg) => {
await bot.sendMessage(msg.chat.id, 'Welcome!');
});
// Colored buttons (style attribute)
bot.message_handler({ commands: ['menu'] })(async (msg) => {
const markup = new InlineKeyboardMarkup([
[
new InlineKeyboardButton('Confirm', { callback_data: 'confirm', style: 'success' }),
new InlineKeyboardButton('Delete', { callback_data: 'delete', style: 'danger' }),
new InlineKeyboardButton('Info', { callback_data: 'info', style: 'primary' }),
]
]);
await bot.sendMessage(msg.chat.id, 'Choose an action:', { reply_markup: markup });
});
// Callback query handler
bot.callback_query_handler({ func: (cq) => true })(async (cq) => {
await bot.answerCallbackQuery(cq.id, { text: `You clicked: ${cq.data}` });
});
// Start polling
await bot.polling({ non_stop: true });Directory Structure
exuxmarfoAPI/
├── package.json # ESM config, dependencies
├── index.js # Root export module
├── README.md # This file
└── src/
├── TeleBot.js # Core bot class
├── apihelper.js # HTTP request engine
├── types.js # Telegram type schemas
├── util.js # Async helpers & worker pool
└── ext/
└── RE_REROUTE.md # Extension placeholderButton Styles
The InlineKeyboardButton class natively accepts and serializes a style
attribute for colored buttons in Telegram Mini Apps and clients that support it:
import { InlineKeyboardButton, InlineKeyboardMarkup } from 'exuxmarfoAPI';
// Available styles: "primary" (blue), "success" (green), "danger" (red)
const button = new InlineKeyboardButton('Submit', {
callback_data: 'submit',
style: 'success' // serialized as `"style": "success"` in JSON payload
});
// Using the InlineKeyboardBuilder utility
import { InlineKeyboardBuilder } from 'exuxmarfoAPI';
const markup = new InlineKeyboardBuilder()
.addStyledButton('Save', 'save_data', 'success')
.addStyledButton('Cancel', 'cancel_op', 'danger')
.nextRow()
.addCallbackButton('Help', 'show_help')
.build();
await bot.sendMessage(chatId, 'Actions:', { reply_markup: markup });API Methods
All major Telegram Bot API methods are available on the TeleBot instance:
sendMessage,sendPhoto,sendAudio,sendDocument,sendVideo,sendVoiceforwardMessage,copyMessage,editMessageText,editMessageCaptiondeleteMessage,pinChatMessage,unpinChatMessagegetChat,getChatMember,banChatMember,promoteChatMembersetWebhook,deleteWebhook,getWebhookInfoanswerCallbackQuery,answerInlineQuerysendInvoice,createInvoiceLinksendSticker,getStickerSet,createNewStickerSetsetMyCommands,getMyCommandsgetAvailableGifts,sendGiftverifyUser,verifyChat- And many more...
Handler Types
| Handler | Registration Method | Trigger |
|---------|-------------------|---------|
| Message | message_handler() | Any incoming message |
| Edited Message | edited_message_handler() | Edited messages |
| Channel Post | channel_post_handler() | Channel posts |
| Callback Query | callback_query_handler() | Inline button clicks |
| Inline Query | inline_handler() | @bot queries |
| Chosen Inline | chosen_inline_handler() | Selected inline result |
| Shipping Query | shipping_query_handler() | Shipping inquiries |
| Pre-checkout | pre_checkout_query_handler() | Payment checkouts |
| Poll | poll_handler() | Poll state changes |
| Chat Member | chat_member_handler() | Membership changes |
| Join Request | chat_join_request_handler() | Chat join requests |
License
GPL-2.0
