{"id":39432302,"url":"https://github.com/kazedevid/teh","last_synced_at":"2026-06-12T02:00:33.515Z","repository":{"id":330720875,"uuid":"1123715228","full_name":"KazeDevID/teh","owner":"KazeDevID","description":"Lightweight Telegram Bot API","archived":false,"fork":false,"pushed_at":"2026-06-11T14:04:24.000Z","size":119,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-11T14:04:31.573Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://github.com/KazeDevID/teh/wiki","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/KazeDevID.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-12-27T13:16:28.000Z","updated_at":"2026-04-26T11:01:31.000Z","dependencies_parsed_at":null,"dependency_job_id":"2a211b88-61ee-44e0-bbad-6f6091d1b164","html_url":"https://github.com/KazeDevID/teh","commit_stats":null,"previous_names":["kazedevid/teh"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/KazeDevID/teh","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KazeDevID%2Fteh","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KazeDevID%2Fteh/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KazeDevID%2Fteh/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KazeDevID%2Fteh/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KazeDevID","download_url":"https://codeload.github.com/KazeDevID/teh/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KazeDevID%2Fteh/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34225351,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-12T02:00:06.859Z","response_time":109,"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":[],"created_at":"2026-01-18T04:05:26.468Z","updated_at":"2026-06-12T02:00:33.497Z","avatar_url":"https://github.com/KazeDevID.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Telega\n\nA modern, production-ready Telegram Bot API library for Node.js with full TypeScript support.\n\n## Features\n\n- **Full TypeScript Support** - Complete type definitions for all Telegram Bot API types\n- **ESM \u0026 CommonJS** - Works with both module systems\n- **Modern Architecture** - Built with async/await, Promises, and modern JavaScript\n- **Tree-shakeable** - Optimized for minimal bundle size\n- **Zero Dependencies** - Uses native `fetch` for HTTP requests\n- **Both Polling \u0026 Webhook** - Flexible update receiving methods\n- **Middleware System** - Powerful middleware for request processing\n- **Command Handler** - Built-in command parsing and handling\n- **Plugin System** - Extensible via plugins\n- **Rate Limit Handling** - Automatic retry on rate limits\n- **Comprehensive API** - All Telegram Bot API methods implemented\n\n## Installation\n\n```bash\nnpm install @mkzstyleee/telega\n```\n\n## Quick Start\n\n```javascript\nimport { Telega } from '@mkzstyleee/telega';\n\nconst bot = new Telega({\n  token: 'YOUR_BOT_TOKEN',\n});\n\n// Handle /start command\nbot.command('start', async (ctx) =\u003e {\n  await ctx.reply('Hello! I am a bot powered by Telega.');\n});\n\n// Handle /ping command\nbot.command('ping', async (ctx) =\u003e {\n  await ctx.reply('Pong!');\n});\n\n// Echo messages\nbot.on('message', async (ctx) =\u003e {\n  const text = ctx.getText();\n  if (text \u0026\u0026 !ctx.message?.isCommand) {\n    await ctx.reply(`You said: ${text}`);\n  }\n});\n\n// Start polling\nbot.startPolling();\n```\n\n## Documentation\n\n### Table of Contents\n\n- [Getting Started](docs/getting-started.md)\n- [Installation](docs/installation.md)\n- [Sending Messages](docs/send-message.md)\n- [Webhook](docs/webhook.md)\n- [Polling](docs/polling.md)\n- [Middleware](docs/middleware.md)\n- [Commands](docs/commands.md)\n- [Plugins](docs/plugins.md)\n- [TypeScript](docs/typescript.md)\n- [API Reference](docs/api-reference.md)\n\n### Sending Messages\n\n```javascript\n// Simple text message\nawait bot.sendMessage(chatId, 'Hello World!');\n\n// With reply markup\nawait bot.sendMessage(chatId, 'Choose an option:', {\n  replyMarkup: {\n    inline_keyboard: [\n      [{ text: 'Option 1', callback_data: 'opt1' }],\n      [{ text: 'Option 2', callback_data: 'opt2' }],\n    ],\n  },\n});\n\n// With formatting (MarkdownV2)\nawait bot.sendMessage(chatId, '*Bold* and _italic_ text', {\n  parseMode: 'MarkdownV2',\n});\n```\n\n### Keyboard Builder\n\n```javascript\nimport { keyboard } from '@mkzstyleee/telega';\n\nconst inlineKeyboard = keyboard()\n  .text('Button 1', 'callback_1')\n  .text('Button 2', 'callback_2')\n  .row()\n  .url('Visit Website', 'https://example.com')\n  .build();\n\nawait bot.sendMessage(chatId, 'Choose:', {\n  replyMarkup: inlineKeyboard,\n});\n```\n\n### Middleware\n\n```javascript\n// Global middleware\nbot.use(async (ctx, next) =\u003e {\n  console.log(`Update ${ctx.update.update_id} received`);\n  await next();\n});\n\n// Logging middleware for errors\nbot.use(async (ctx, next) =\u003e {\n  try {\n    await next();\n  } catch (error) {\n    console.error('Error:', error);\n    await ctx.reply('An error occurred');\n  }\n});\n```\n\n### Commands\n\n```javascript\n// Simple command\nbot.command('hello', async (ctx) =\u003e {\n  await ctx.reply('Hello there!');\n});\n\n// Command with aliases\nbot.command('start', async (ctx) =\u003e {\n  await ctx.reply('Welcome!');\n}, { aliases: ['begin', 'init'] });\n\n// Command with description (for help)\nbot.command('help', showHelp, { description: 'Show help message' });\n```\n\n### Webhook\n\n```javascript\n// Start webhook server\nawait bot.startWebhook({\n  url: 'https://your-domain.com/webhook',\n  port: 3000,\n  path: '/webhook',\n  secretToken: 'your-secret-token',\n});\n\n// Express integration\nimport express from 'express';\nconst app = express();\n\napp.post('/webhook', bot.webhook.getExpressMiddleware());\n\napp.listen(3000);\n```\n\n### Context\n\nThe context object provides convenient methods and properties:\n\n```javascript\nbot.on('message', async (ctx) =\u003e {\n  // Access update data\n  const user = ctx.from;        // User who sent the message\n  const chat = ctx.chat;        // Chat where message was sent\n  const message = ctx.message;  // The message object\n\n  // Reply methods\n  await ctx.reply('Text');\n  await ctx.replyWithPhoto('https://example.com/photo.jpg');\n  await ctx.replyWithDocument(buffer);\n  await ctx.replyWithSticker('sticker_id');\n\n  // Edit message\n  await ctx.editMessageText('New text');\n\n  // Delete message\n  await ctx.deleteMessage();\n\n  // Get message text\n  const text = ctx.getText();\n\n  // Get command\n  const cmd = ctx.getCommand();\n\n  // Chat type checks\n  ctx.isPrivate();    // true if private chat\n  ctx.isGroup();      // true if group\n  ctx.isSupergroup(); // true if supergroup\n  ctx.isChannel();    // true if channel\n});\n```\n\n### Plugins\n\n```javascript\nimport { createSessionPlugin, createRateLimitPlugin } from '@mkzstyleee/telega';\n\n// Session plugin\nawait bot.plugin(createSessionPlugin({ ttl: 3600000 }));\n\n// Rate limiting\nawait bot.plugin(createRateLimitPlugin({\n  windowMs: 60000,\n  max: 5,\n  message: 'Too many messages!',\n}));\n```\n\n## API Reference\n\n### Constructor\n\n```javascript\nconst bot = new Telega({\n  token: 'BOT_TOKEN',           // Required\n  baseUrl: 'https://...',       // Optional: API URL\n  timeout: 30000,               // Optional: Request timeout\n  maxRetries: 3,                // Optional: Max retries\n  autoRetryOnRateLimit: true,   // Optional: Auto retry on 429\n  logger: { level: 'info' },    // Optional: Logger config\n});\n```\n\n### Methods\n\n| Method | Description |\n|--------|-------------|\n| `startPolling(options?)` | Start long polling |\n| `stopPolling()` | Stop polling |\n| `startWebhook(options)` | Start webhook server |\n| `stopWebhook()` | Stop webhook server |\n| `use(middleware)` | Add middleware |\n| `command(name, handler, options?)` | Register command |\n| `on(event, handler)` | Register event handler |\n| `plugin(plugin)` | Install plugin |\n| `sendMessage(chatId, text, options?)` | Send text message |\n| `sendPhoto(chatId, photo, options?)` | Send photo |\n| `sendDocument(chatId, document, options?)` | Send document |\n| `getMe()` | Get bot information |\n| `getFile(fileId)` | Get file info |\n| `downloadFile(path)` | Download file |\n\n## Examples\n\nCheck the `examples/` directory for more examples:\n\n- Basic bot\n- Commands\n- Middleware\n- Webhook\n- TypeScript\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkazedevid%2Fteh","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkazedevid%2Fteh","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkazedevid%2Fteh/lists"}