{"_id":"@anysk/telegramma","_rev":"4-6c06a0a572493e98f3f46c114344cc64","name":"@anysk/telegramma","dist-tags":{"latest":"4.20.0"},"versions":{"4.17.0":{"name":"@anysk/telegramma","version":"4.17.0","keywords":["telegraf","telegram","telegram bot api","bot","botapi","bot framework"],"author":{"name":"The Telegraf Contributors"},"license":"MIT","_id":"@anysk/telegramma@4.17.0","maintainers":[{"name":"anysk","email":"anysk81@gmail.com"}],"homepage":"https://github.com/AnySk/telegramma","bugs":{"url":"https://github.com/AnySk/telegramma/issues"},"ava":{"files":["test/*","!test/_*"]},"bin":{"telegraf":"lib/cli.mjs"},"dist":{"shasum":"5600586addbdf7d914bebe2d7f05a4d838292699","tarball":"https://registry.npmjs.org/@anysk/telegramma/-/telegramma-4.17.0.tgz","fileCount":168,"integrity":"sha512-8kvPjRbYZyRWFoes63MOdPHGqUp1IHVL3iM5SmC7g6RchKBHV9RjJB9BMHDK3uUUSW5YQgYKsppO3YaK27SpuA==","signatures":[{"sig":"MEQCIF8pOmW7YWw2k8HcHv/DYZ6Grtx1Wq+rl5jo8+5XIVdqAiA2Vs3yWHtkhmyAUUtWKxTunWfZEPsp4sAKZ8jLV1KOoQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":716428},"main":"lib/index.js","type":"commonjs","types":"./typings/index.d.ts","engines":{"node":"^12.20.0 || >=14.13.1"},"exports":{".":{"types":"./typings/index.d.ts","default":"./lib/index.js"},"./types":{"types":"./types.d.ts","default":"./types.js"},"./utils":{"types":"./utils.d.ts","default":"./utils.js"},"./format":{"types":"./format.d.ts","default":"./format.js"},"./future":{"types":"./future.d.ts","default":"./future.js"},"./markup":{"types":"./markup.d.ts","default":"./markup.js"},"./scenes":{"types":"./scenes.d.ts","default":"./scenes.js"},"./filters":{"types":"./filters.d.ts","default":"./filters.js"},"./session":{"types":"./session.d.ts","default":"./session.js"}},"gitHead":"0638cf4cc7ba8467ccb9222726024c99c54d119f","scripts":{"lint":"eslint .","test":"ava","build":"tsc && npm run expose","clean":"git clean -fX .eslintcache docs/build/ lib/ typings/","checks":"npm test && npm run lint","expose":"tsx build/expose.ts types scenes filters format future utils markup session","prepare":"npm run --silent build","pretest":"npm run build","refresh":"npm run clean && npm ci","lint:fix":"npm run lint -- --fix","build:docs":"typedoc src/index.ts"},"_npmUser":{"name":"anysk","email":"anysk81@gmail.com"},"repository":{"url":"git+ssh://git@github.com/AnySk/telegramma.git","type":"git"},"_npmVersion":"11.6.2","description":"Modern Telegram Bot Framework","directories":{},"_nodeVersion":"24.11.1","dependencies":{"mri":"^1.2.0","debug":"^4.3.5","p-timeout":"^4.1.0","node-fetch":"^2.7.0","safe-compare":"^1.1.4","sandwich-stream":"^2.0.2","abort-controller":"^3.0.0","@anysk/telegramma-types":"^10.1.1"},"_hasShrinkwrap":false,"devDependencies":{"ava":"^5.3.1","tsx":"^4.7.1","eslint":"^8.57.0","typedoc":"^0.25.0","prettier":"^3.0.3","fast-check":"^3.12.0","typescript":"^5.2.2","@types/node":"^20.4.2","@types/debug":"^4.1.8","@types/node-fetch":"^2.6.2","eslint-plugin-ava":"^14.0.0","eslint-plugin-node":"^11.1.0","@types/safe-compare":"^1.1.0","eslint-plugin-import":"^2.29.1","eslint-plugin-promise":"^6.1.1","eslint-config-prettier":"^9.1.0","eslint-plugin-prettier":"^5.1.3","@typescript-eslint/parser":"^6.21.0","@typescript-eslint/eslint-plugin":"^6.21.0"},"_npmOperationalInternal":{"tmp":"tmp/telegramma_4.17.0_1781786936458_0.8584224941889682","host":"s3://npm-registry-packages-npm-production"}},"4.18.0":{"name":"@anysk/telegramma","version":"4.18.0","keywords":["telegraf","telegram","telegram bot api","bot","botapi","bot framework"],"author":{"name":"AnySk"},"license":"MIT","_id":"@anysk/telegramma@4.18.0","maintainers":[{"name":"anysk","email":"anysk81@gmail.com"}],"homepage":"https://github.com/AnySk/telegramma","bugs":{"url":"https://github.com/AnySk/telegramma/issues"},"ava":{"files":["test/*","!test/_*"]},"bin":{"telegraf":"lib/cli.mjs"},"dist":{"shasum":"d669dfbdc3ca5e36ffeee03ba1fedcf7450895b8","tarball":"https://registry.npmjs.org/@anysk/telegramma/-/telegramma-4.18.0.tgz","fileCount":168,"integrity":"sha512-X55SzR5Psu+jH0q7GYKAhgDzc7EQ4xedaGO47mtF7XFKbBMXj5TvOp+j1W2EiLQ2ArqWXmjhAGQPX3ANS298wQ==","signatures":[{"sig":"MEYCIQCu2f57jmwVOlQOgRIj3XXDDf+MDAC7MUUp5GnXQK0r5gIhAMYldK+JnO8t2epoH4Xgp7UAZJeS7c6vbzaDuBRBz11x","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":804166},"main":"lib/index.js","type":"commonjs","types":"./typings/index.d.ts","engines":{"node":">=18.18.0"},"exports":{".":{"types":"./typings/index.d.ts","default":"./lib/index.js"},"./types":{"types":"./types.d.ts","default":"./types.js"},"./utils":{"types":"./utils.d.ts","default":"./utils.js"},"./format":{"types":"./format.d.ts","default":"./format.js"},"./future":{"types":"./future.d.ts","default":"./future.js"},"./markup":{"types":"./markup.d.ts","default":"./markup.js"},"./scenes":{"types":"./scenes.d.ts","default":"./scenes.js"},"./filters":{"types":"./filters.d.ts","default":"./filters.js"},"./session":{"types":"./session.d.ts","default":"./session.js"}},"gitHead":"d1836678a46eafa0e00a263a8556153058048120","scripts":{"lint":"eslint .","test":"ava","build":"tsc && npm run expose","clean":"git clean -fX .eslintcache docs/build/ lib/ typings/","checks":"npm test && npm run lint","expose":"tsx build/expose.ts types scenes filters format future utils markup session","prepare":"npm run --silent build","pretest":"npm run build","refresh":"npm run clean && npm ci","lint:fix":"npm run lint -- --fix","build:docs":"typedoc src/index.ts"},"_npmUser":{"name":"anysk","email":"anysk81@gmail.com"},"repository":{"url":"git+ssh://git@github.com/AnySk/telegramma.git","type":"git"},"_npmVersion":"11.6.2","description":"Modern Telegram Bot Framework","directories":{},"_nodeVersion":"24.11.1","dependencies":{"mri":"^1.2.0","debug":"^4.4.3","p-timeout":"^4.1.0","node-fetch":"^2.7.0","safe-compare":"^1.1.4","sandwich-stream":"^2.0.2","abort-controller":"^3.0.0","@anysk/telegramma-types":"^10.1.1"},"_hasShrinkwrap":false,"devDependencies":{"ava":"^5.3.1","tsx":"^4.22.4","eslint":"^8.57.1","typedoc":"^0.25.13","prettier":"^3.8.4","fast-check":"^3.23.2","typescript":"^5.2.2","@types/node":"^20.19.43","@types/debug":"^4.1.13","@types/node-fetch":"^2.6.13","eslint-plugin-ava":"^14.0.0","eslint-plugin-node":"^11.1.0","@types/safe-compare":"^1.1.2","eslint-plugin-import":"^2.32.0","eslint-plugin-promise":"^6.6.0","eslint-config-prettier":"^9.1.2","eslint-plugin-prettier":"^5.5.6","@typescript-eslint/parser":"^8.61.1","@typescript-eslint/eslint-plugin":"^8.61.1"},"_npmOperationalInternal":{"tmp":"tmp/telegramma_4.18.0_1781868883330_0.380663022905122","host":"s3://npm-registry-packages-npm-production"}},"4.19.0":{"name":"@anysk/telegramma","version":"4.19.0","keywords":["telegraf","telegram","telegram bot api","bot","botapi","bot framework"],"author":{"name":"AnySk"},"license":"MIT","_id":"@anysk/telegramma@4.19.0","maintainers":[{"name":"anysk","email":"anysk81@gmail.com"}],"homepage":"https://github.com/AnySk/telegramma","bugs":{"url":"https://github.com/AnySk/telegramma/issues"},"ava":{"files":["test/*","!test/_*"]},"bin":{"telegraf":"lib/cli.mjs"},"dist":{"shasum":"5664b1fd98f2d312956ace5a74fbba9d8c634cc2","tarball":"https://registry.npmjs.org/@anysk/telegramma/-/telegramma-4.19.0.tgz","fileCount":168,"integrity":"sha512-O4jQUc5wC5ZD6W6/LNVd7TNqjbJtVKVUQ1RAGKpqyfZD3rQPQ0BeKNFlzXxDq1ERfEuUJRdvbICsYMpBuv6Z2Q==","signatures":[{"sig":"MEUCIGakcQ6NfignYELxKD2kvuW5Jgtgp6pf1zq7A6RsIhYKAiEAqY56eRmlPXcNYMRYxhF3LCpKQEvVG9ypVqQpN/R1szg=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":829385},"main":"lib/index.js","type":"commonjs","types":"./typings/index.d.ts","engines":{"node":">=18.18.0"},"exports":{".":{"types":"./typings/index.d.ts","default":"./lib/index.js"},"./types":{"types":"./types.d.ts","default":"./types.js"},"./utils":{"types":"./utils.d.ts","default":"./utils.js"},"./format":{"types":"./format.d.ts","default":"./format.js"},"./future":{"types":"./future.d.ts","default":"./future.js"},"./markup":{"types":"./markup.d.ts","default":"./markup.js"},"./scenes":{"types":"./scenes.d.ts","default":"./scenes.js"},"./filters":{"types":"./filters.d.ts","default":"./filters.js"},"./session":{"types":"./session.d.ts","default":"./session.js"}},"gitHead":"daa69c1183f2fc8b71d5261a78efc96be2428f1b","scripts":{"lint":"eslint .","test":"ava","build":"tsc && npm run expose","clean":"git clean -fX .eslintcache docs/build/ lib/ typings/","checks":"npm test && npm run lint","expose":"tsx build/expose.ts types scenes filters format future utils markup session","prepare":"npm run --silent build","pretest":"npm run build","refresh":"npm run clean && npm ci","lint:fix":"npm run lint -- --fix","build:docs":"typedoc src/index.ts"},"_npmUser":{"name":"anysk","email":"anysk81@gmail.com"},"repository":{"url":"git+ssh://git@github.com/AnySk/telegramma.git","type":"git"},"_npmVersion":"11.13.0","description":"Modern Telegram Bot Framework","directories":{},"_nodeVersion":"24.16.0","dependencies":{"mri":"^1.2.0","debug":"^4.4.3","p-timeout":"^4.1.0","node-fetch":"^2.7.0","safe-compare":"^1.1.4","sandwich-stream":"^2.0.2","abort-controller":"^3.0.0","@anysk/telegramma-types":"^10.2.0"},"_hasShrinkwrap":false,"devDependencies":{"ava":"^5.3.1","tsx":"^4.22.4","eslint":"^8.57.1","typedoc":"^0.25.13","prettier":"^3.8.4","fast-check":"^3.23.2","typescript":"^5.2.2","@types/node":"^20.19.43","@types/debug":"^4.1.13","@types/node-fetch":"^2.6.13","eslint-plugin-ava":"^14.0.0","eslint-plugin-node":"^11.1.0","@types/safe-compare":"^1.1.2","eslint-plugin-import":"^2.32.0","eslint-plugin-promise":"^6.6.0","eslint-config-prettier":"^9.1.2","eslint-plugin-prettier":"^5.5.6","@typescript-eslint/parser":"^8.61.1","@typescript-eslint/eslint-plugin":"^8.61.1"},"_npmOperationalInternal":{"tmp":"tmp/telegramma_4.19.0_1784055025427_0.8905746014976259","host":"s3://npm-registry-packages-npm-production"}},"4.20.0":{"name":"@anysk/telegramma","version":"4.20.0","description":"Modern Telegram Bot Framework","license":"MIT","author":{"name":"AnySk"},"homepage":"https://github.com/AnySk/telegramma","repository":{"type":"git","url":"git+ssh://git@github.com/AnySk/telegramma.git"},"bugs":{"url":"https://github.com/AnySk/telegramma/issues"},"main":"lib/index.js","exports":{".":{"types":"./typings/index.d.ts","default":"./lib/index.js"},"./filters":{"types":"./filters.d.ts","default":"./filters.js"},"./future":{"types":"./future.d.ts","default":"./future.js"},"./scenes":{"types":"./scenes.d.ts","default":"./scenes.js"},"./types":{"types":"./types.d.ts","default":"./types.js"},"./format":{"types":"./format.d.ts","default":"./format.js"},"./utils":{"types":"./utils.d.ts","default":"./utils.js"},"./markup":{"types":"./markup.d.ts","default":"./markup.js"},"./session":{"types":"./session.d.ts","default":"./session.js"}},"bin":{"telegraf":"lib/cli.mjs"},"scripts":{"prepare":"npm run --silent build","build":"tsc && npm run expose","expose":"tsx build/expose.ts types scenes filters format future utils markup session","build:docs":"typedoc src/index.ts","pretest":"npm run build","test":"ava","lint":"eslint .","lint:fix":"npm run lint -- --fix","checks":"npm test && npm run lint","refresh":"npm run clean && npm ci","clean":"git clean -fX .eslintcache docs/build/ lib/ typings/"},"ava":{"files":["test/*","!test/_*"]},"type":"commonjs","engines":{"node":">=18.18.0"},"types":"./typings/index.d.ts","dependencies":{"@anysk/telegramma-types":"^10.3.0","abort-controller":"^3.0.0","debug":"^4.4.3","mri":"^1.2.0","node-fetch":"^2.7.0","p-timeout":"^4.1.0","safe-compare":"^1.1.4","sandwich-stream":"^2.0.2"},"devDependencies":{"@types/debug":"^4.1.13","@types/node":"^20.19.43","@types/node-fetch":"^2.6.13","@types/safe-compare":"^1.1.2","@typescript-eslint/eslint-plugin":"^8.61.1","@typescript-eslint/parser":"^8.61.1","ava":"^5.3.1","eslint":"^8.57.1","eslint-config-prettier":"^9.1.2","eslint-plugin-ava":"^14.0.0","eslint-plugin-import":"^2.32.0","eslint-plugin-node":"^11.1.0","eslint-plugin-prettier":"^5.5.6","eslint-plugin-promise":"^6.6.0","fast-check":"^3.23.2","prettier":"^3.8.4","tsx":"^4.22.4","typedoc":"^0.25.13","typescript":"^5.2.2"},"keywords":["telegraf","telegram","telegram bot api","bot","botapi","bot framework"],"gitHead":"7d6a4c60f2d43fbae68de221bd48faa171723b39","_id":"@anysk/telegramma@4.20.0","_nodeVersion":"24.16.0","_npmVersion":"11.13.0","dist":{"integrity":"sha512-qLjPNwck7meIhuqQhzuaaLrrg06Z9cT1yLCA1ycB8KNl4b9AfzKWC+zipmtwqYz3ser9cQze8fTAZLckvzD+EQ==","shasum":"bbf272f0333fe4def9e54a45dbfd6a48a3a25dd0","tarball":"https://registry.npmjs.org/@anysk/telegramma/-/telegramma-4.20.0.tgz","fileCount":168,"unpackedSize":831668,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCmILA0osdEflmNFeLxWmqQVUbN0wCaYCjepubKQgcFZgIgNKUEa5uf1N2f9AVNpWbyP/Eoqe4w6NvBCLrqtgFo8R0="}]},"_npmUser":{"name":"anysk","email":"anysk81@gmail.com"},"directories":{},"maintainers":[{"name":"anysk","email":"anysk81@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/telegramma_4.20.0_1787827115228_0.5597777664394652"},"_hasShrinkwrap":false}},"time":{"created":"2026-06-18T12:48:56.157Z","modified":"2026-08-27T10:38:35.570Z","4.17.0":"2026-06-18T12:48:56.618Z","4.18.0":"2026-06-19T11:34:43.513Z","4.19.0":"2026-07-14T18:50:25.588Z","4.20.0":"2026-08-27T10:38:35.411Z"},"bugs":{"url":"https://github.com/AnySk/telegramma/issues"},"author":{"name":"AnySk"},"license":"MIT","homepage":"https://github.com/AnySk/telegramma","keywords":["telegraf","telegram","telegram bot api","bot","botapi","bot framework"],"repository":{"type":"git","url":"git+ssh://git@github.com/AnySk/telegramma.git"},"description":"Modern Telegram Bot Framework","maintainers":[{"name":"anysk","email":"anysk81@gmail.com"}],"readme":"<header>\n\n<div align=\"center\">\n<h1 align=\"center\">telegramma</h1>\n\n<p>Modern Telegram Bot API framework for Node.js</p>\n\n<a href=\"https://core.telegram.org/bots/api\">\n\t<img src=\"https://img.shields.io/badge/Bot%20API-v10.3-f36caf.svg?style=flat-square\" alt=\"Bot API Version\" />\n</a>\n<a href=\"https://packagephobia.com/result?p=@anysk/telegramma\">\n\t<img src=\"https://flat.badgen.net/packagephobia/install/@anysk/telegramma\" alt=\"install size\" />\n</a>\n<a href=\"https://github.com/AnySk/telegramma\">\n\t<img src=\"https://img.shields.io/github/languages/top/AnySk/telegramma?style=flat-square&logo=github\" alt=\"GitHub top language\" />\n</a>\n</div>\n\n</header>\n\n> **Fork notice.** `telegramma` is a maintained fork of [Telegraf](https://github.com/telegraf/telegraf), published as **`@anysk/telegramma`**. It tracks the latest **Telegram Bot API (v10.3)** by depending on [`@anysk/telegramma-types`](https://github.com/AnySk/telegramma-types) and adding the corresponding API methods (ephemeral messages, rich messages, live photos, guest mode, poll media, join-request queries, etc.). The public API is otherwise unchanged from Telegraf v4.\n\n\n## Introduction\n\nBots are special [Telegram](https://telegram.org) accounts designed to handle messages automatically.\nUsers can interact with bots by sending them command messages in private or group chats.\nThese accounts serve as an interface for code running somewhere on your server.\n\nTelegraf is a library that makes it simple for you to develop your own Telegram bots using JavaScript or [TypeScript](https://www.typescriptlang.org/).\n\n### Features\n\n- Full [Telegram Bot API 10.3](https://core.telegram.org/bots/api) support\n- [Excellent TypeScript typings](https://github.com/AnySk/telegramma-types)\n- [Lightweight](https://packagephobia.com/result?p=@anysk/telegramma)\n- [AWS **λ**](https://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-handler.html)\n  / [Firebase](https://firebase.google.com/products/functions/)\n  / [Glitch](https://glitch.com/edit/#!/dashing-light)\n  / [Fly.io](https://fly.io/docs/languages-and-frameworks/node)\n  / Whatever ready\n- `http/https/fastify/Connect.js/express.js` compatible webhooks\n- Extensible\n\n### Example\n\n```js\nconst { Telegraf } = require('@anysk/telegramma')\nconst { message } = require('@anysk/telegramma/filters')\n\nconst bot = new Telegraf(process.env.BOT_TOKEN)\nbot.start((ctx) => ctx.reply('Welcome'))\nbot.help((ctx) => ctx.reply('Send me a sticker'))\nbot.on(message('sticker'), (ctx) => ctx.reply('👍'))\nbot.hears('hi', (ctx) => ctx.reply('Hey there'))\nbot.launch()\n\n// Enable graceful stop\nprocess.once('SIGINT', () => bot.stop('SIGINT'))\nprocess.once('SIGTERM', () => bot.stop('SIGTERM'))\n```\n\n```js\nconst { Telegraf } = require('@anysk/telegramma')\n\nconst bot = new Telegraf(process.env.BOT_TOKEN)\nbot.command('oldschool', (ctx) => ctx.reply('Hello'))\nbot.command('hipster', Telegraf.reply('λ'))\nbot.launch()\n\n// Enable graceful stop\nprocess.once('SIGINT', () => bot.stop('SIGINT'))\nprocess.once('SIGTERM', () => bot.stop('SIGTERM'))\n```\n\nFor additional bot examples see the new [`docs repo`](https://github.com/feathers-studio/telegraf-docs/).\n\n### Resources\n\n- [Getting started](#getting-started)\n- [API reference](https://telegraf.js.org/modules.html)\n- Telegram groups (sorted by number of members):\n  - [English](https://t.me/TelegrafJSChat)\n  - [Russian](https://t.me/telegrafjs_ru)\n  - [Uzbek](https://t.me/botjs_uz)\n  - [Ethiopian](https://t.me/telegraf_et)\n- [GitHub Discussions](https://github.com/telegraf/telegraf/discussions)\n- [Dependent repositories](https://libraries.io/npm/telegraf/dependent_repositories)\n\n## Getting started\n\n### Telegram token\n\nTo use the [Telegram Bot API](https://core.telegram.org/bots/api),\nyou first have to [get a bot account](https://core.telegram.org/bots)\nby [chatting with BotFather](https://core.telegram.org/bots#6-botfather).\n\nBotFather will give you a _token_, something like `123456789:AbCdefGhIJKlmNoPQRsTUVwxyZ`.\n\n### Installation\n\n```shellscript\n$ npm install @anysk/telegramma\n```\n\nor\n\n```shellscript\n$ yarn add @anysk/telegramma\n```\n\nor\n\n```shellscript\n$ pnpm add @anysk/telegramma\n```\n\n### `Telegraf` class\n\n[`Telegraf`] instance represents your bot. It's responsible for obtaining updates and passing them to your handlers.\n\nStart by [listening to commands](https://telegraf.js.org/classes/Telegraf-1.html#command) and [launching](https://telegraf.js.org/classes/Telegraf-1.html#launch) your bot.\n\n### `Context` class\n\n`ctx` you can see in every example is a [`Context`] instance.\n[`Telegraf`] creates one for each incoming update and passes it to your middleware.\nIt contains the `update`, `botInfo`, and `telegram` for making arbitrary Bot API requests,\nas well as shorthand methods and getters.\n\nThis is probably the class you'll be using the most.\n\n<!--\nTODO: Verify and update list\nHere is a list of\n\n#### Known middleware\n\n- [Internationalization](https://github.com/telegraf/telegraf-i18n)—simplifies selecting the right translation to use when responding to a user.\n- [Redis powered session](https://github.com/telegraf/telegraf-session-redis)—store session data using Redis.\n- [Local powered session (via lowdb)](https://github.com/RealSpeaker/telegraf-session-local)—store session data in a local file.\n- [Rate-limiting](https://github.com/telegraf/telegraf-ratelimit)—apply rate limitting to chats or users.\n- [Bottleneck powered throttling](https://github.com/KnightNiwrem/telegraf-throttler)—apply throttling to both incoming updates and outgoing API calls.\n- [Menus via inline keyboards](https://github.com/EdJoPaTo/telegraf-inline-menu)—simplify creating interfaces based on menus.\n- [Stateless Questions](https://github.com/EdJoPaTo/telegraf-stateless-question)—create stateless questions to Telegram users working in privacy mode.\n- [Natural language processing via wit.ai](https://github.com/telegraf/telegraf-wit)\n- [Natural language processing via recast.ai](https://github.com/telegraf/telegraf-recast)\n- [Multivariate and A/B testing](https://github.com/telegraf/telegraf-experiments)—add experiments to see how different versions of a feature are used.\n- [Powerfull bot stats via Mixpanel](https://github.com/telegraf/telegraf-mixpanel)\n- [statsd integration](https://github.com/telegraf/telegraf-statsd)\n- [and more...](https://www.npmjs.com/search?q=telegraf-)\n-->\n\n#### Shorthand methods\n\n```js\nimport { Telegraf } from '@anysk/telegramma'\nimport { message } from '@anysk/telegramma/filters'\n\nconst bot = new Telegraf(process.env.BOT_TOKEN)\n\nbot.command('quit', async (ctx) => {\n  // Explicit usage\n  await ctx.telegram.leaveChat(ctx.message.chat.id)\n\n  // Using context shortcut\n  await ctx.leaveChat()\n})\n\nbot.on(message('text'), async (ctx) => {\n  // Explicit usage\n  await ctx.telegram.sendMessage(ctx.message.chat.id, `Hello ${ctx.state.role}`)\n\n  // Using context shortcut\n  await ctx.reply(`Hello ${ctx.state.role}`)\n})\n\nbot.on('callback_query', async (ctx) => {\n  // Explicit usage\n  await ctx.telegram.answerCbQuery(ctx.callbackQuery.id)\n\n  // Using context shortcut\n  await ctx.answerCbQuery()\n})\n\nbot.on('inline_query', async (ctx) => {\n  const result = []\n  // Explicit usage\n  await ctx.telegram.answerInlineQuery(ctx.inlineQuery.id, result)\n\n  // Using context shortcut\n  await ctx.answerInlineQuery(result)\n})\n\nbot.launch()\n\n// Enable graceful stop\nprocess.once('SIGINT', () => bot.stop('SIGINT'))\nprocess.once('SIGTERM', () => bot.stop('SIGTERM'))\n```\n\n## Production\n\n### Webhooks\n\n```TS\nimport { Telegraf } from \"@anysk/telegramma\";\nimport { message } from '@anysk/telegramma/filters';\n\nconst bot = new Telegraf(token);\n\nbot.on(message(\"text\"), ctx => ctx.reply(\"Hello\"));\n\n// Start webhook via launch method (preferred)\nbot.launch({\n  webhook: {\n    // Public domain for webhook; e.g.: example.com\n    domain: webhookDomain,\n\n    // Port to listen on; e.g.: 8080\n    port: port,\n\n    // Optional path to listen for.\n    // `bot.secretPathComponent()` will be used by default\n    path: webhookPath,\n\n    // Optional secret to be sent back in a header for security.\n    // e.g.: `crypto.randomBytes(64).toString(\"hex\")`\n    secretToken: randomAlphaNumericString,\n  },\n});\n```\n\nUse `createWebhook()` if you want to attach Telegraf to an existing http server.\n\n<!-- global bot, tlsOptions -->\n\n```TS\nimport { createServer } from \"http\";\n\ncreateServer(await bot.createWebhook({ domain: \"example.com\" })).listen(3000);\n```\n\n```TS\nimport { createServer } from \"https\";\n\ncreateServer(tlsOptions, await bot.createWebhook({ domain: \"example.com\" })).listen(8443);\n```\n\n- [AWS Lambda example integration](https://github.com/feathers-studio/telegraf-docs/tree/master/examples/functions/aws-lambda)\n- [Google Cloud Functions example integration](https://github.com/feathers-studio/telegraf-docs/blob/master/examples/functions/google-cloud-function.ts)\n- [`express` example integration](https://github.com/feathers-studio/telegraf-docs/blob/master/examples/webhook/express.ts)\n- [`fastify` example integration](https://github.com/feathers-studio/telegraf-docs/blob/master/examples/webhook/fastify.ts)\n- [`koa` example integration](https://github.com/feathers-studio/telegraf-docs/blob/master/examples/webhook/koa.ts)\n- [NestJS framework integration module](https://github.com/bukhalo/nestjs-telegraf)\n- [Cloudflare Workers integration module](https://github.com/Tsuk1ko/cfworker-middware-telegraf)\n- Use [`bot.handleUpdate`](https://telegraf.js.org/classes/Telegraf-1.html#handleupdate) to write new integrations\n\n### Error handling\n\nIf middleware throws an error or times out, Telegraf calls `bot.handleError`. If it rethrows, update source closes, and then the error is printed to console and process terminates. If it does not rethrow, the error is swallowed.\n\nDefault `bot.handleError` always rethrows. You can overwrite it using `bot.catch` if you need to.\n\n⚠️ Swallowing unknown errors might leave the process in invalid state!\n\nℹ️ In production, `systemd` or [`pm2`](https://www.npmjs.com/package/pm2) can restart your bot if it exits for any reason.\n\n## Advanced topics\n\n### Working with files\n\nSupported file sources:\n\n- `Existing file_id`\n- `File path`\n- `Url`\n- `Buffer`\n- `ReadStream`\n\nAlso, you can provide an optional name of a file as `filename` when you send the file.\n\n<!-- global bot, fs -->\n\n```js\nbot.on('message', async (ctx) => {\n  // resend existing file by file_id\n  await ctx.replyWithSticker('123123jkbhj6b')\n\n  // send file\n  await ctx.replyWithVideo(Input.fromLocalFile('/path/to/video.mp4'))\n\n  // send stream\n  await ctx.replyWithVideo(\n    Input.fromReadableStream(fs.createReadStream('/path/to/video.mp4'))\n  )\n\n  // send buffer\n  await ctx.replyWithVoice(Input.fromBuffer(Buffer.alloc()))\n\n  // send url via Telegram server\n  await ctx.replyWithPhoto(Input.fromURL('https://picsum.photos/200/300/'))\n\n  // pipe url content\n  await ctx.replyWithPhoto(\n    Input.fromURLStream('https://picsum.photos/200/300/?random', 'kitten.jpg')\n  )\n})\n```\n\n### Middleware\n\nIn addition to `ctx: Context`, each middleware receives `next: () => Promise<void>`.\n\nAs in Koa and some other middleware-based libraries,\n`await next()` will call next middleware and wait for it to finish:\n\n```TS\nimport { Telegraf } from '@anysk/telegramma';\nimport { message } from '@anysk/telegramma/filters';\n\nconst bot = new Telegraf(process.env.BOT_TOKEN);\n\nbot.use(async (ctx, next) => {\n  console.time(`Processing update ${ctx.update.update_id}`);\n  await next() // runs next middleware\n  // runs after next middleware finishes\n  console.timeEnd(`Processing update ${ctx.update.update_id}`);\n})\n\nbot.on(message('text'), (ctx) => ctx.reply('Hello World'));\nbot.launch();\n\n// Enable graceful stop\nprocess.once('SIGINT', () => bot.stop('SIGINT'));\nprocess.once('SIGTERM', () => bot.stop('SIGTERM'));\n```\n\nWith this simple ability, you can:\n\n- extract information from updates and then `await next()` to avoid disrupting other middleware,\n- like [`Composer`] and [`Router`], `await next()` for updates you don't wish to handle,\n- like [`session`] and [`Scenes`], [extend the context](#extending-context) by mutating `ctx` before `await next()`,\n- [intercept API calls](https://github.com/telegraf/telegraf/discussions/1267#discussioncomment-254525),\n- reuse [other people's code](https://www.npmjs.com/search?q=telegraf-),\n- do whatever **you** come up with!\n\n[`Telegraf`]: https://telegraf.js.org/classes/Telegraf-1.html\n[`Composer`]: https://telegraf.js.org/classes/Composer.html\n[`Context`]: https://telegraf.js.org/classes/Context.html\n[`Router`]: https://telegraf.js.org/classes/Router.html\n[`session`]: https://telegraf.js.org/modules.html#session\n[`Scenes`]: https://telegraf.js.org/modules/Scenes.html\n\n### Usage with TypeScript\n\nTelegraf is written in TypeScript and therefore ships with declaration files for the entire library.\nMoreover, it includes types for the complete Telegram API via the [`typegram`](https://github.com/KnorpelSenf/typegram) package.\nWhile most types of Telegraf's API surface are self-explanatory, there's some notable things to keep in mind.\n\n#### Extending `Context`\n\nThe exact shape of `ctx` can vary based on the installed middleware.\nSome custom middleware might register properties on the context object that Telegraf is not aware of.\nConsequently, you can change the type of `ctx` to fit your needs in order for you to have proper TypeScript types for your data.\nThis is done through Generics:\n\n```ts\nimport { Context, Telegraf } from '@anysk/telegramma'\n\n// Define your own context type\ninterface MyContext extends Context {\n  myProp?: string\n  myOtherProp?: number\n}\n\n// Create your bot and tell it about your context type\nconst bot = new Telegraf<MyContext>('SECRET TOKEN')\n\n// Register middleware and launch your bot as usual\nbot.use((ctx, next) => {\n  // Yay, `myProp` is now available here as `string | undefined`!\n  ctx.myProp = ctx.chat?.first_name?.toUpperCase()\n  return next()\n})\n// ...\n```\n","readmeFilename":"README.md"}