{"id":36500675,"url":"https://github.com/vietxuandev/telegram-bot-module","last_synced_at":"2026-01-12T02:20:46.062Z","repository":{"id":271078369,"uuid":"912361898","full_name":"vietxuandev/telegram-bot-module","owner":"vietxuandev","description":"Telegram Bot Module for NestJS","archived":false,"fork":false,"pushed_at":"2025-03-02T16:41:45.000Z","size":35,"stargazers_count":1,"open_issues_count":11,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-11-01T08:18:55.312Z","etag":null,"topics":["module","nestjs","telegram","telegram-bot"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/telegram-bot-module","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vietxuandev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-05T11:13:43.000Z","updated_at":"2025-03-02T05:16:14.000Z","dependencies_parsed_at":"2025-01-05T11:16:45.012Z","dependency_job_id":"ff431a94-8cbd-42f6-bd2e-4bde81bef0e2","html_url":"https://github.com/vietxuandev/telegram-bot-module","commit_stats":null,"previous_names":["vietxuandev/telegram-bot-module"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/vietxuandev/telegram-bot-module","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vietxuandev%2Ftelegram-bot-module","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vietxuandev%2Ftelegram-bot-module/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vietxuandev%2Ftelegram-bot-module/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vietxuandev%2Ftelegram-bot-module/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vietxuandev","download_url":"https://codeload.github.com/vietxuandev/telegram-bot-module/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vietxuandev%2Ftelegram-bot-module/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28332006,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-12T00:36:25.062Z","status":"online","status_checked_at":"2026-01-12T02:00:08.677Z","response_time":98,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["module","nestjs","telegram","telegram-bot"],"created_at":"2026-01-12T02:20:42.488Z","updated_at":"2026-01-12T02:20:46.055Z","avatar_url":"https://github.com/vietxuandev.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Description\n\nTelegram Bot utilities module for [NestJS](https://nestjs.com/) based on the [node-telegram-bot-api](https://github.com/yagop/node-telegram-bot-api) package.\n\n## Installation\n\n```bash\n$ npm install --save telegram-bot-module\n```\n\n## Usage\n\n### Basic Setup\n\nImport `TelegramBotModule` into your application:\n\n```typescript\nimport { TelegramBotModule } from 'telegram-bot-module';\n\n@Module({\n  imports: [\n    TelegramBotModule.forRoot({\n      isGlobal: true,\n      token: process.env.TELEGRAM_BOT_TOKEN,\n      polling: true,\n      filepath: false,\n    }),\n  ],\n  providers: [...],\n})\nexport class AppModule {}\n```\n\n### Inject `TelegramBotService` to Send or Handle Messages\n\n```typescript\nimport { Injectable } from \"@nestjs/common\";\nimport { TelegramBotService } from \"telegram-bot-module\";\n\n@Injectable()\nexport class BotService {\n  constructor(private readonly telegramBotService: TelegramBotService) {}\n\n  async sendMessage(chatId: number, message: string): Promise\u003cvoid\u003e {\n    await this.telegramBotService.sendMessage(chatId, message);\n  }\n}\n```\n\n### Handle Updates\n\nSubscribe to Telegram updates in your application:\n\n```typescript\nimport { Injectable, OnModuleInit } from \"@nestjs/common\";\nimport { TelegramBotService } from \"telegram-bot-module\";\n\n@Injectable()\nexport class BotUpdateService implements OnModuleInit {\n  constructor(private readonly telegramBotService: TelegramBotService) {}\n\n  onModuleInit() {\n    this.telegramBotService.on(\"message\", (msg) =\u003e {\n      console.log(\"New message received:\", msg.text);\n    });\n  }\n}\n```\n\n## Dynamic Token Handling\n\nYou can dynamically manage the Telegram bot token by using the `forRootAsync` method:\n\n```typescript\nimport { ConfigModule, ConfigService } from \"@nestjs/config\";\n\n@Module({\n  imports: [\n    TelegramBotModule.forRootAsync({\n      imports: [ConfigModule],\n      useFactory: (configService: ConfigService) =\u003e ({\n        token: configService.get\u003cstring\u003e(\"TELEGRAM_BOT_TOKEN\"),\n      }),\n      inject: [ConfigService],\n    }),\n  ],\n})\nexport class AppModule {}\n```\n\n## API Methods\n\nThis package provides wrappers for the most commonly used methods from `node-telegram-bot-api`:\n\n#### `sendMessage(chatId: number | string, message: string, options?: TelegramBot.SendMessageOptions): Promise\u003cTelegramBot.Message\u003e`\n\nSend a message to a chat.\n\n#### `on(event: string, callback: (msg: TelegramBot.Message) =\u003e void): void`\n\nSubscribe to Telegram bot updates, such as `message`, `callback_query`, etc.\n\n#### `setWebhook(url: string): Promise\u003cvoid\u003e`\n\nSet a webhook URL for your bot.\n\n#### `getWebhookInfo(): Promise\u003cTelegramBot.WebhookInfo\u003e`\n\nRetrieve information about the currently set webhook.\n\n## Advanced Usage\n\nIf you want to use the full power of `node-telegram-bot-api`, you can access the underlying instance directly:\n\n```typescript\nimport { TelegramBotService } from \"telegram-bot-module\";\n\n@Injectable()\nexport class AdvancedBotService {\n  constructor(private readonly telegramBotService: TelegramBotService) {}\n\n  async customMethod() {\n    const botInstance = this.telegramBotService.getBotInstance();\n    // Call any method from node-telegram-bot-api\n    await botInstance.setChatTitle(123456789, \"New Chat Title\");\n  }\n}\n```\n\n## Support\n\nThis package is open source and licensed under the MIT license. Contributions are welcome!\n\n## Stay in touch\n\n- Author - [Jayden Nguyen](https://github.com/vietxuandev)\n- Repository - [GitHub](https://github.com/vietxuandev/telegram-bot-module)\n- NPM Package - [NPM](https://www.npmjs.com/package/telegram-bot-module)\n\n## License\n\nThis package is [MIT licensed](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvietxuandev%2Ftelegram-bot-module","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvietxuandev%2Ftelegram-bot-module","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvietxuandev%2Ftelegram-bot-module/lists"}