{"_id":"@alexalexlex/nestjs-telegram","name":"@alexalexlex/nestjs-telegram","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@alexalexlex/nestjs-telegram","version":"0.1.0","description":"A lightweight, RxJS-based NestJS client for the Telegram Bot API.","author":{"name":"Alexalexlex","url":"https://github.com/Alexalexlex"},"license":"MIT","publishConfig":{"access":"public"},"keywords":["nestjs","telegram","telegram-bot","telegram-bot-api","bot","rxjs","nest"],"homepage":"https://github.com/Alexalexlex/nestjs-telegram#readme","repository":{"type":"git","url":"git+https://github.com/Alexalexlex/nestjs-telegram.git"},"bugs":{"url":"https://github.com/Alexalexlex/nestjs-telegram/issues"},"main":"dist/index.js","types":"dist/index.d.ts","engines":{"node":">=16"},"peerDependencies":{"@nestjs/axios":"^3.0.0 || ^4.0.0","@nestjs/common":"^8.0.0 || ^9.0.0 || ^10.0.0 || ^11.0.0","@nestjs/core":"^8.0.0 || ^9.0.0 || ^10.0.0 || ^11.0.0","axios":"^1.0.0","reflect-metadata":"^0.1.13 || ^0.2.0","rxjs":"^7.0.0"},"devDependencies":{"@nestjs/axios":"^3.1.3","@nestjs/common":"^10.4.15","@nestjs/core":"^10.4.15","@types/node":"^20.17.0","@typescript-eslint/eslint-plugin":"^7.18.0","@typescript-eslint/parser":"^7.18.0","axios":"^1.7.9","eslint":"^8.57.1","eslint-config-prettier":"^9.1.0","eslint-plugin-prettier":"^5.2.1","prettier":"^3.4.2","reflect-metadata":"^0.2.2","rimraf":"^5.0.10","rxjs":"^7.8.1","typescript":"^5.7.3"},"scripts":{"clean":"rimraf dist","build":"rimraf dist && tsc -p tsconfig.build.json","format":"prettier --write \"src/**/*.ts\"","lint":"eslint \"src/**/*.ts\"","lint:fix":"eslint \"src/**/*.ts\" --fix"},"_id":"@alexalexlex/nestjs-telegram@0.1.0","_integrity":"sha512-IlUpDm5ZZFUGOz0qMYIFqfE+MsT5upJOM/4fhrUtPxso0uKZUQYwBEx/Tl8Pyb38L5ZAQZbqOqiUio7vyWd8zw==","_resolved":"/private/var/folders/xv/6sjtlnqx3qbbtpsp16j8h7l40000gn/T/3ac802a5633d2915bb2ffd9fb9f77b0b/alexalexlex-nestjs-telegram-0.1.0.tgz","_from":"file:alexalexlex-nestjs-telegram-0.1.0.tgz","_nodeVersion":"24.15.0","_npmVersion":"11.12.1","dist":{"integrity":"sha512-IlUpDm5ZZFUGOz0qMYIFqfE+MsT5upJOM/4fhrUtPxso0uKZUQYwBEx/Tl8Pyb38L5ZAQZbqOqiUio7vyWd8zw==","shasum":"b0b52fac9636f7eccbabf82f46b66a86b662070a","tarball":"https://registry.npmjs.org/@alexalexlex/nestjs-telegram/-/nestjs-telegram-0.1.0.tgz","fileCount":39,"unpackedSize":85819,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCM7lhCGUv6WMT5DAYypDcEeNlWUkPqn6Jtmi4T8ZNVjgIhAJ0akX8LimghI2w1NN8KdHPGJHe7GWTqV3DfxI0F0a7V"}]},"_npmUser":{"name":"alexalexlex","email":"flalex855@gmail.com"},"directories":{},"maintainers":[{"name":"alexalexlex","email":"flalex855@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/nestjs-telegram_0.1.0_1782381829189_0.8234451989267046"},"_hasShrinkwrap":false}},"time":{"created":"2026-06-25T10:03:49.080Z","0.1.0":"2026-06-25T10:03:49.319Z","modified":"2026-06-25T10:03:49.549Z"},"maintainers":[{"name":"alexalexlex","email":"flalex855@gmail.com"}],"description":"A lightweight, RxJS-based NestJS client for the Telegram Bot API.","homepage":"https://github.com/Alexalexlex/nestjs-telegram#readme","keywords":["nestjs","telegram","telegram-bot","telegram-bot-api","bot","rxjs","nest"],"repository":{"type":"git","url":"git+https://github.com/Alexalexlex/nestjs-telegram.git"},"author":{"name":"Alexalexlex","url":"https://github.com/Alexalexlex"},"bugs":{"url":"https://github.com/Alexalexlex/nestjs-telegram/issues"},"license":"MIT","readme":"# @alexalexlex/nestjs-telegram\n\nA lightweight, **RxJS-based [NestJS](https://nestjs.com/) client for the\n[Telegram Bot API](https://core.telegram.org/bots/api)**. Drop the module into\nyour app, inject `TelegramService`, and call the Bot API with fully-typed\npayloads — every method returns an `Observable`.\n\n> **Note**\n> Not published to npm yet. When you're ready, publish the scoped package as\n> public: `npm publish --access public` (already preconfigured via\n> `publishConfig` in `package.json`).\n\n## Features\n\n- 🧩 **Idiomatic NestJS** — a dynamic module with `forRoot` / `forRootAsync`.\n- 🔌 **No hard-coded config** — pass the bot token however you like; no forced\n  dependency on `@nestjs/config` or a specific env-var name.\n- 🦺 **Typed** — interfaces for updates, messages, chats, users, keyboards and\n  every method payload.\n- 🪶 **Tiny** — built on `@nestjs/axios` + `rxjs`, nothing else.\n- 🚪 **Escape hatch** — `callRequest()` lets you reach any Bot API method that\n  doesn't have a dedicated wrapper yet.\n\n## Installation\n\n```bash\nnpm install @alexalexlex/nestjs-telegram\n# peer dependencies (most NestJS apps already have these)\nnpm install @nestjs/common @nestjs/core @nestjs/axios axios rxjs reflect-metadata\n```\n\n## Quick start\n\nRegister the module once (usually in `AppModule`) and inject the service\nwherever you need it.\n\n```ts\nimport { Module } from '@nestjs/common';\nimport { TelegramModule } from '@alexalexlex/nestjs-telegram';\n\n@Module({\n  imports: [\n    TelegramModule.forRoot({\n      token: process.env.TELEGRAM_API_KEY!,\n      isGlobal: true, // optional: makes TelegramService available app-wide\n    }),\n  ],\n})\nexport class AppModule {}\n```\n\n```ts\nimport { Injectable } from '@nestjs/common';\nimport { firstValueFrom } from 'rxjs';\nimport { TelegramService } from '@alexalexlex/nestjs-telegram';\n\n@Injectable()\nexport class MyService {\n  constructor(private readonly telegram: TelegramService) {}\n\n  // RxJS style\n  ping(chatId: number) {\n    this.telegram\n      .sendMessage({ chat_id: chatId, text: 'pong 🏓' })\n      .subscribe();\n  }\n\n  // async/await style\n  async pingAsync(chatId: number) {\n    return firstValueFrom(\n      this.telegram.sendMessage({ chat_id: chatId, text: 'pong 🏓' }),\n    );\n  }\n}\n```\n\n## Async configuration\n\nUse `forRootAsync` to resolve the token from another provider — e.g.\n`ConfigService`. This is the direct replacement for reading\n`TELEGRAM_API_KEY` from the environment inside the service.\n\n```ts\nimport { Module } from '@nestjs/common';\nimport { ConfigModule, ConfigService } from '@nestjs/config';\nimport { TelegramModule } from '@alexalexlex/nestjs-telegram';\n\n@Module({\n  imports: [\n    ConfigModule.forRoot({ isGlobal: true }),\n    TelegramModule.forRootAsync({\n      imports: [ConfigModule],\n      inject: [ConfigService],\n      isGlobal: true,\n      useFactory: (config: ConfigService) => ({\n        token: config.getOrThrow<string>('TELEGRAM_API_KEY'),\n        // apiUrl: 'http://localhost:8081/bot', // optional, e.g. local Bot API server\n      }),\n    }),\n  ],\n})\nexport class AppModule {}\n```\n\n`useClass` / `useExisting` are also supported via a `TelegramOptionsFactory`:\n\n```ts\nimport { Injectable } from '@nestjs/common';\nimport { TelegramModuleOptions, TelegramOptionsFactory } from '@alexalexlex/nestjs-telegram';\n\n@Injectable()\nexport class TelegramConfig implements TelegramOptionsFactory {\n  createTelegramOptions(): TelegramModuleOptions {\n    return { token: process.env.TELEGRAM_API_KEY! };\n  }\n}\n\n// TelegramModule.forRootAsync({ useClass: TelegramConfig })\n```\n\n## Usage examples\n\n### Long polling\n\n```ts\nimport { firstValueFrom } from 'rxjs';\n\nconst updates = await firstValueFrom(this.telegram.getUpdates());\nfor (const update of updates) {\n  if (update.message?.text) {\n    await firstValueFrom(\n      this.telegram.sendMessage({\n        chat_id: update.message.chat.id,\n        text: `You said: ${update.message.text}`,\n      }),\n    );\n  }\n}\n```\n\n### Inline keyboard\n\n```ts\nthis.telegram\n  .sendMessage({\n    chat_id: chatId,\n    text: 'Pick one:',\n    reply_markup: {\n      inline_keyboard: [\n        [{ text: '👍 Yes', callback_data: 'yes' }],\n        [{ text: '👎 No', callback_data: 'no' }],\n      ],\n    },\n  } as any)\n  .subscribe();\n```\n\n### Message reaction\n\n```ts\nthis.telegram\n  .setMessageReaction({\n    chat_id: chatId,\n    message_id: messageId,\n    reaction: [{ type: 'emoji', emoji: '🔥' }],\n  })\n  .subscribe();\n```\n\n## Available methods\n\n`TelegramService` wraps these Bot API methods (all return an `Observable`):\n\n| Method | Bot API |\n| --- | --- |\n| `getMe()` | [getMe](https://core.telegram.org/bots/api#getme) |\n| `getUpdates()` | [getUpdates](https://core.telegram.org/bots/api#getupdates) |\n| `getChat(data)` | [getChat](https://core.telegram.org/bots/api#getchat) |\n| `leaveChat(data)` | [leaveChat](https://core.telegram.org/bots/api#leavechat) |\n| `getChatAdministrators(data)` | [getChatAdministrators](https://core.telegram.org/bots/api#getchatadministrators) |\n| `getMyCommands()` | [getMyCommands](https://core.telegram.org/bots/api#getmycommands) |\n| `sendMessage(data)` | [sendMessage](https://core.telegram.org/bots/api#sendmessage) |\n| `sendChatAction(data)` | [sendChatAction](https://core.telegram.org/bots/api#sendchataction) |\n| `sendVideo(data)` | [sendVideo](https://core.telegram.org/bots/api#sendvideo) |\n| `createChatInviteLink(data)` | [createChatInviteLink](https://core.telegram.org/bots/api#createchatinvitelink) |\n| `approveChatJoinRequest(data)` | [approveChatJoinRequest](https://core.telegram.org/bots/api#approvechatjoinrequest) |\n| `editMessageReplyMarkup(data)` | [editMessageReplyMarkup](https://core.telegram.org/bots/api#editmessagereplymarkup) |\n| `editMessageText(data)` | [editMessageText](https://core.telegram.org/bots/api#editmessagetext) |\n| `deleteMessage(data)` | [deleteMessage](https://core.telegram.org/bots/api#deletemessage) |\n| `setMessageReaction(data)` | [setMessageReaction](https://core.telegram.org/bots/api#setmessagereaction) |\n\n### Calling any other method\n\nAnything not listed above is one `callRequest` away:\n\n```ts\nimport { Method } from '@alexalexlex/nestjs-telegram';\n\nthis.telegram\n  .callRequest('sendPhoto', Method.POST, { chat_id: chatId, photo: url })\n  .subscribe();\n```\n\n## Error handling\n\nWhen Telegram responds with `ok: false`, the `Observable` throws an\n`IErrorData` (`{ description?, code }`). Handle it with RxJS `catchError` or a\n`try/catch` around `firstValueFrom`:\n\n```ts\nimport { catchError, of } from 'rxjs';\n\nthis.telegram\n  .sendMessage({ chat_id: chatId, text: 'hi' })\n  .pipe(catchError((err) => of({ failed: err })))\n  .subscribe();\n```\n\n## Development\n\n```bash\nnpm install\nnpm run build   # compiles to dist/ with type declarations\nnpm run lint\n```\n\n## License\n\n[MIT](./LICENSE) © Alexalexlex\n","readmeFilename":"README.md","_rev":"1-5a2ce2de715bc05167c9e139bdd787aa"}