{"_id":"@astralibx/telegram-bot","_rev":"3-41261f57ae4b27a78e6d352f5bd69a98","name":"@astralibx/telegram-bot","dist-tags":{"latest":"0.2.0"},"versions":{"0.1.1":{"name":"@astralibx/telegram-bot","version":"0.1.1","keywords":["telegram","bot","node-telegram-bot-api","keyboard-builder","webhook","polling","user-tracking"],"license":"MIT","_id":"@astralibx/telegram-bot@0.1.1","maintainers":[{"name":"astralib","email":"1997hariprakash@gmail.com"}],"homepage":"https://github.com/Hariprakash1997/astralib#readme","bugs":{"url":"https://github.com/Hariprakash1997/astralib/issues"},"dist":{"shasum":"20ca9ee5ca30faf8969f10f1d9119e8ae003b22e","tarball":"https://registry.npmjs.org/@astralibx/telegram-bot/-/telegram-bot-0.1.1.tgz","fileCount":66,"integrity":"sha512-sHp2vQOzs3hpsbZESSGtmSmevyumXvpovd6rH+4IQCo8+kxDOTQqkZUjLtnbw+HMPD5nRVtX4OFWXi05hYavww==","signatures":[{"sig":"MEYCIQCvHjne25NEoIDJNPdkiNXsqXAuuQqOYwGqxiDGWL+DLAIhAInF+0nAHKM0OvSH3P+lAXzm7c9aN4BRZGeClG5184Gz","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":101710},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"df956e4b9f30b71fc0ee0eba6b811eee2092bf52","scripts":{"lint":"eslint src/","test":"vitest run","build":"tsc","clean":"rm -rf dist","test:watch":"vitest","test:coverage":"vitest run --coverage"},"_npmUser":{"name":"astralib","email":"1997hariprakash@gmail.com"},"repository":{"url":"git+https://github.com/Hariprakash1997/astralib.git","type":"git","directory":"packages/telegram/bot"},"_npmVersion":"10.9.4","description":"Customizable Telegram bot factory with command registration, keyboard builder, webhook/polling, and user tracking","directories":{},"_nodeVersion":"22.22.1","dependencies":{"zod":"^3.23.0","@astralibx/core":"*"},"_hasShrinkwrap":false,"devDependencies":{"vitest":"^3.0.0","express":"^5.0.0","mongoose":"^8.12.1","typescript":"^5.8.2","@types/express":"^5.0.0","@vitest/coverage-v8":"^3.0.0","mongodb-memory-server":"^10.0.0","node-telegram-bot-api":"^0.66.0","@types/node-telegram-bot-api":"^0.64.0"},"peerDependencies":{"express":"^4.18.0 || ^5.0.0","mongoose":"^7.0.0 || ^8.0.0","node-telegram-bot-api":"^0.60.0"},"_npmOperationalInternal":{"tmp":"tmp/telegram-bot_0.1.1_1773730924837_0.009774524960433961","host":"s3://npm-registry-packages-npm-production"}},"0.1.2":{"name":"@astralibx/telegram-bot","version":"0.1.2","keywords":["telegram","bot","node-telegram-bot-api","keyboard-builder","webhook","polling","user-tracking"],"license":"MIT","_id":"@astralibx/telegram-bot@0.1.2","maintainers":[{"name":"astralib","email":"1997hariprakash@gmail.com"}],"homepage":"https://github.com/Hariprakash1997/astralib#readme","bugs":{"url":"https://github.com/Hariprakash1997/astralib/issues"},"dist":{"shasum":"51628f74ad8e4601686f3661b1af1556769eb300","tarball":"https://registry.npmjs.org/@astralibx/telegram-bot/-/telegram-bot-0.1.2.tgz","fileCount":66,"integrity":"sha512-fKHxtMW3w+belGdHBYHCuknbeWomuvThW9hQoLd2rYFdplkYdovAqaZPnfoQuyAiIuSlqscVNQkxc0sz1keGMQ==","signatures":[{"sig":"MEUCIQCDV/5oH8LVJerOhxnjPqFneaF49jU41+l8hA+Hw+abzAIge5x6dI+khTVbEFknbxG0lBIvJ4/S5hj8CzgesC8irk8=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":101710},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"fd42f0db8c9fd08982aee61f94304819cd425d54","scripts":{"lint":"eslint src/","test":"vitest run","build":"tsc","clean":"rm -rf dist","test:watch":"vitest","test:coverage":"vitest run --coverage"},"_npmUser":{"name":"astralib","email":"1997hariprakash@gmail.com"},"repository":{"url":"git+https://github.com/Hariprakash1997/astralib.git","type":"git","directory":"packages/telegram/bot"},"_npmVersion":"10.9.4","description":"Customizable Telegram bot factory with command registration, keyboard builder, webhook/polling, and user tracking","directories":{},"_nodeVersion":"22.22.1","dependencies":{"zod":"^3.23.0","@astralibx/core":"*"},"_hasShrinkwrap":false,"devDependencies":{"vitest":"^3.0.0","express":"^5.0.0","mongoose":"^8.12.1","typescript":"^5.8.2","@types/express":"^5.0.0","@vitest/coverage-v8":"^3.0.0","mongodb-memory-server":"^10.0.0","node-telegram-bot-api":"^0.66.0","@types/node-telegram-bot-api":"^0.64.0"},"peerDependencies":{"express":"^4.18.0 || ^5.0.0","mongoose":"^7.0.0 || ^8.0.0","node-telegram-bot-api":"^0.60.0"},"_npmOperationalInternal":{"tmp":"tmp/telegram-bot_0.1.2_1773733708248_0.05699259345401719","host":"s3://npm-registry-packages-npm-production"}},"0.2.0":{"name":"@astralibx/telegram-bot","version":"0.2.0","description":"Customizable Telegram bot factory with command registration, keyboard builder, webhook/polling, and user tracking","repository":{"type":"git","url":"git+https://github.com/Hariprakash1997/astralib.git","directory":"packages/telegram/bot"},"main":"dist/index.js","types":"dist/index.d.ts","scripts":{"build":"tsc","test":"vitest run","test:watch":"vitest","test:coverage":"vitest run --coverage","lint":"eslint src/","clean":"rm -rf dist"},"keywords":["telegram","bot","node-telegram-bot-api","keyboard-builder","webhook","polling","user-tracking"],"license":"MIT","dependencies":{"@astralibx/core":"*","zod":"^3.23.0"},"peerDependencies":{"express":"^4.18.0 || ^5.0.0","mongoose":"^7.0.0 || ^8.0.0","node-telegram-bot-api":"^0.60.0"},"devDependencies":{"@types/express":"^5.0.0","@types/node-telegram-bot-api":"^0.64.0","@vitest/coverage-v8":"^3.0.0","express":"^5.0.0","mongodb-memory-server":"^10.0.0","mongoose":"^8.12.1","node-telegram-bot-api":"^0.66.0","typescript":"^5.8.2","vitest":"^3.0.0"},"_id":"@astralibx/telegram-bot@0.2.0","gitHead":"b96fb6e63feccf19591d627ddda0c3d04f165ad2","bugs":{"url":"https://github.com/Hariprakash1997/astralib/issues"},"homepage":"https://github.com/Hariprakash1997/astralib#readme","_nodeVersion":"22.22.1","_npmVersion":"10.9.4","dist":{"integrity":"sha512-bnKXo7cgrqTLztm9/Q+TuTZqZxukp7/+3UD0JU6IR0SsZzl5PTR+C1xvKuMQatnjnTHadEhu4FkqdWE2TzObkQ==","shasum":"15a7a36bfdd9c63f42c15f46886a3b92610ac68f","tarball":"https://registry.npmjs.org/@astralibx/telegram-bot/-/telegram-bot-0.2.0.tgz","fileCount":70,"unpackedSize":111341,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDBFnmO2zC3CzQNEmVO4Wl+gvVbuqWwUNTdq08HxmiGyQIhALAXRC/TNLcIfKNh51/EVQ9NB9UDtn4D3IqkpBos3Ido"}]},"_npmUser":{"name":"astralib","email":"1997hariprakash@gmail.com"},"directories":{},"maintainers":[{"name":"astralib","email":"1997hariprakash@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/telegram-bot_0.2.0_1773814061219_0.18743959298418167"},"_hasShrinkwrap":false}},"time":{"created":"2026-03-17T07:02:04.780Z","modified":"2026-03-18T06:07:41.497Z","0.1.1":"2026-03-17T07:02:04.979Z","0.1.2":"2026-03-17T07:48:28.420Z","0.2.0":"2026-03-18T06:07:41.370Z"},"bugs":{"url":"https://github.com/Hariprakash1997/astralib/issues"},"license":"MIT","homepage":"https://github.com/Hariprakash1997/astralib#readme","keywords":["telegram","bot","node-telegram-bot-api","keyboard-builder","webhook","polling","user-tracking"],"repository":{"type":"git","url":"git+https://github.com/Hariprakash1997/astralib.git","directory":"packages/telegram/bot"},"description":"Customizable Telegram bot factory with command registration, keyboard builder, webhook/polling, and user tracking","maintainers":[{"name":"astralib","email":"1997hariprakash@gmail.com"}],"readme":"# @astralibx/telegram-bot\n\nA customizable Telegram bot factory with command registration, keyboard builder, webhook/polling support, user tracking, and Express admin routes. Create a fully functional bot with a single factory call.\n\n> **Getting started?** See the [Quick Start Tutorial](https://github.com/Hariprakash1997/astralib/blob/main/packages/telegram/docs/quick-start-tutorial.md) for a step-by-step walkthrough, [Integration Guide](https://github.com/Hariprakash1997/astralib/blob/main/packages/telegram/docs/integration-guide.md) for multi-package setup, or the [Glossary](https://github.com/Hariprakash1997/astralib/blob/main/packages/telegram/docs/glossary.md) for ID terminology.\n\n## Install\n\n```bash\nnpm install @astralibx/telegram-bot\n```\n\n### Peer Dependencies\n\n| Package | Required |\n|---------|----------|\n| `express` | Yes |\n| `mongoose` | Yes |\n| `node-telegram-bot-api` | Yes |\n\n```bash\nnpm install express mongoose node-telegram-bot-api\n```\n\n## Quick Start\n\n```ts\nimport express from 'express';\nimport mongoose from 'mongoose';\nimport { createTelegramBot } from '@astralibx/telegram-bot';\n\nconst app = express();\napp.use(express.json());\n\nconst db = await mongoose.createConnection('mongodb://localhost:27017/myapp');\n\nconst bot = createTelegramBot({\n  token: process.env.TELEGRAM_BOT_TOKEN!,\n  mode: 'polling',\n  db: { connection: db },\n  commands: [\n    {\n      command: 'start',\n      description: 'Start the bot',\n      handler: async (msg, bot) => {\n        await bot.sendMessage(msg.chat.id, `Welcome, ${msg.from?.first_name}!`);\n      },\n    },\n    {\n      command: 'help',\n      description: 'Show help',\n      handler: async (msg, bot) => {\n        await bot.sendMessage(msg.chat.id, 'Available commands: /start, /help');\n      },\n    },\n  ],\n  callbacks: [\n    {\n      pattern: /btn_.*/,\n      handler: async (query, bot) => {\n        await bot.answerCallbackQuery(query.id, { text: 'Button clicked!' });\n      },\n    },\n  ],\n  hooks: {\n    onUserStart: ({ firstName }) => console.log(`New user: ${firstName}`),\n    onError: ({ error, context }) => console.error(`Error in ${context}:`, error.message),\n  },\n});\n\n// Admin routes (protect with your own auth middleware)\napp.use('/api/bot', bot.routes);\n\n// Start the bot\nawait bot.start();\n\n// Graceful shutdown\nprocess.on('SIGTERM', () => bot.stop());\n\napp.listen(3000);\n```\n\n## Runtime Command Registration\n\n```ts\nbot.registerCommand({\n  command: 'status',\n  description: 'Show bot status',\n  handler: async (msg, instance) => {\n    const info = bot.getBotInfo();\n    await instance.sendMessage(msg.chat.id, `Bot: ${info?.username}, Running: ${bot.isRunning()}`);\n  },\n});\n\nbot.removeCommand('status');\n```\n\n## Keyboard Builder\n\n```ts\nconst kb = bot.keyboards;\n\n// Inline keyboard\nconst inline = kb.inline([\n  [{ text: 'Yes', callback_data: 'confirm_yes' }, { text: 'No', callback_data: 'confirm_no' }],\n]);\nawait bot.sendMessage(chatId, 'Confirm?', { reply_markup: inline });\n\n// Reply keyboard\nconst reply = kb.reply([['Option A', 'Option B'], ['Option C']], { oneTimeKeyboard: true });\nawait bot.sendMessage(chatId, 'Choose:', { reply_markup: reply });\n\n// Remove keyboard\nconst remove = kb.remove();\nawait bot.sendMessage(chatId, 'Keyboard removed.', { reply_markup: remove });\n```\n\n## Features\n\n- **Polling and webhook modes** -- Choose between long-polling or webhook with automatic setup. [Details](https://github.com/Hariprakash1997/astralib/blob/main/packages/telegram/bot/docs/configuration.md)\n- **Command registration** -- Define commands at creation or register them at runtime. [Details](https://github.com/Hariprakash1997/astralib/blob/main/packages/telegram/bot/docs/configuration.md#commands)\n- **Callback and inline query handlers** -- Pattern-matched handlers for interactive elements. [Details](https://github.com/Hariprakash1997/astralib/blob/main/packages/telegram/bot/docs/configuration.md#callbacks)\n- **Keyboard builder** -- Fluent API for inline, reply, and remove keyboards. [Details](https://github.com/Hariprakash1997/astralib/blob/main/packages/telegram/bot/docs/types.md#keyboardbuilder)\n- **Middleware chain** -- Intercept messages before command handlers execute. [Details](https://github.com/Hariprakash1997/astralib/blob/main/packages/telegram/bot/docs/configuration.md#middleware)\n- **User tracking** -- Automatic contact tracking with interaction history per bot. [Details](https://github.com/Hariprakash1997/astralib/blob/main/packages/telegram/bot/docs/types.md#usertrackerservice)\n- **Admin API routes** -- 4 REST endpoints for bot status, stats, and user management. [Details](https://github.com/Hariprakash1997/astralib/blob/main/packages/telegram/bot/docs/api-routes.md)\n- **Lifecycle hooks** -- React to new users, blocked users, commands, and errors. [Details](https://github.com/Hariprakash1997/astralib/blob/main/packages/telegram/bot/docs/configuration.md#hooks)\n- **Account Manager Bridge** -- Optional integration with `@astralibx/telegram-account-manager` for sending messages via TDLib clients. [Details](#account-manager-bridge)\n\n## Getting Started Guide\n\n1. [Configuration](https://github.com/Hariprakash1997/astralib/blob/main/packages/telegram/bot/docs/configuration.md) -- Token, mode, database, commands, callbacks, middleware, hooks\n2. [API Routes](https://github.com/Hariprakash1997/astralib/blob/main/packages/telegram/bot/docs/api-routes.md) -- 4 admin REST endpoints for status, stats, and users\n3. [Types](https://github.com/Hariprakash1997/astralib/blob/main/packages/telegram/bot/docs/types.md) -- All importable types, constants, errors, and service classes\n\n## Account Manager Bridge\n\nOptional utility for integrating with `@astralibx/telegram-account-manager`. Allows bot commands to send messages via TDLib clients.\n\n```typescript\nimport { createAccountManagerBridge } from '@astralibx/telegram-bot';\nimport { createTelegramAccountManager } from '@astralibx/telegram-account-manager';\n\nconst tam = createTelegramAccountManager(config);\nconst bridge = createAccountManagerBridge(tam);\n\n// In a bot command handler:\ncommands: [{\n  command: 'send',\n  description: 'Send via TDLib',\n  handler: async (msg, bot) => {\n    await bridge.sendViaTDLib('account-id', msg.chat.id.toString(), 'Hello from TDLib!');\n  },\n}]\n```\n\nSee [Types](https://github.com/Hariprakash1997/astralib/blob/main/packages/telegram/bot/docs/types.md#account-manager-bridge) for the `AccountManagerBridge` and `AccountManagerLike` interfaces.\n\n## License\n\nMIT\n","readmeFilename":"README.md"}