From a30936f12047589889123beca3002af388fb08cb Mon Sep 17 00:00:00 2001 From: Alvis Date: Thu, 5 Mar 2026 11:22:34 +0000 Subject: [PATCH] wiki search people tested pipeline --- .gitignore | 1 + CLAUDE.md | 97 + adolf/ARCHITECTURE.md | 190 +- adolf/Dockerfile | 2 +- adolf/agent.py | 241 +- adolf/agent_factory.py | 39 +- adolf/channels.py | 75 + adolf/cli.py | 80 + adolf/docker-compose.yml | 13 + adolf/grammy/Dockerfile | 6 + adolf/grammy/bot.mjs | 56 + adolf/grammy/package.json | 7 + adolf/hello_world.py | 21 + adolf/langgraph.md | 247 + adolf/openmemory/Dockerfile | 6 + adolf/openmemory/requirements.txt | 6 + adolf/openmemory/server.py | 113 +- adolf/reasoning.md | 287 + adolf/router.py | 2 + adolf/test_pipeline.py | 305 +- adolf/wiki_research.py | 278 + haos/CLAUDE.md | 191 + ntfy/docker-compose.yml | 16 + openai/docker-compose.yml | 58 +- otter/docker-compose.yml | 9 + pihole/docker-compose.yaml | 55 + sandbox/tgbot/bot.mjs | 24 + sandbox/tgbot/node_modules/.package-lock.json | 115 + .../node_modules/@grammyjs/types/LICENSE | 21 + .../node_modules/@grammyjs/types/README.md | 107 + .../node_modules/@grammyjs/types/api.d.ts | 22 + .../@grammyjs/types/checklist.d.ts | 72 + .../node_modules/@grammyjs/types/inline.d.ts | 684 ++ .../node_modules/@grammyjs/types/langs.d.ts | 193 + .../node_modules/@grammyjs/types/manage.d.ts | 1058 +++ .../node_modules/@grammyjs/types/markup.d.ts | 250 + .../node_modules/@grammyjs/types/message.d.ts | 1362 ++++ .../node_modules/@grammyjs/types/methods.d.ts | 2429 +++++++ .../node_modules/@grammyjs/types/mod.d.ts | 13 + .../tgbot/node_modules/@grammyjs/types/mod.js | 2 + .../node_modules/@grammyjs/types/package.json | 34 + .../@grammyjs/types/passport.d.ts | 163 + .../node_modules/@grammyjs/types/payment.d.ts | 563 ++ .../@grammyjs/types/settings.d.ts | 120 + .../node_modules/@grammyjs/types/story.d.ts | 89 + .../node_modules/@grammyjs/types/update.d.ts | 78 + .../node_modules/abort-controller/LICENSE | 21 + .../node_modules/abort-controller/README.md | 98 + .../node_modules/abort-controller/browser.js | 13 + .../node_modules/abort-controller/browser.mjs | 11 + .../dist/abort-controller.d.ts | 43 + .../abort-controller/dist/abort-controller.js | 127 + .../dist/abort-controller.js.map | 1 + .../dist/abort-controller.mjs | 118 + .../dist/abort-controller.mjs.map | 1 + .../dist/abort-controller.umd.js | 5 + .../dist/abort-controller.umd.js.map | 1 + .../abort-controller/package.json | 97 + .../node_modules/abort-controller/polyfill.js | 21 + .../abort-controller/polyfill.mjs | 19 + sandbox/tgbot/node_modules/debug/LICENSE | 20 + sandbox/tgbot/node_modules/debug/README.md | 481 ++ sandbox/tgbot/node_modules/debug/package.json | 64 + .../tgbot/node_modules/debug/src/browser.js | 272 + .../tgbot/node_modules/debug/src/common.js | 292 + sandbox/tgbot/node_modules/debug/src/index.js | 10 + sandbox/tgbot/node_modules/debug/src/node.js | 263 + .../node_modules/event-target-shim/LICENSE | 22 + .../node_modules/event-target-shim/README.md | 293 + .../dist/event-target-shim.js | 871 +++ .../dist/event-target-shim.js.map | 1 + .../dist/event-target-shim.mjs | 862 +++ .../dist/event-target-shim.mjs.map | 1 + .../dist/event-target-shim.umd.js | 6 + .../dist/event-target-shim.umd.js.map | 1 + .../node_modules/event-target-shim/index.d.ts | 399 ++ .../event-target-shim/package.json | 82 + sandbox/tgbot/node_modules/grammy/LICENSE | 21 + sandbox/tgbot/node_modules/grammy/README.md | 347 + .../tgbot/node_modules/grammy/out/bot.d.ts | 314 + sandbox/tgbot/node_modules/grammy/out/bot.js | 590 ++ .../node_modules/grammy/out/composer.d.ts | 764 +++ .../tgbot/node_modules/grammy/out/composer.js | 704 ++ .../node_modules/grammy/out/context.d.ts | 1878 ++++++ .../tgbot/node_modules/grammy/out/context.js | 2481 +++++++ .../grammy/out/convenience/constants.d.ts | 98 + .../grammy/out/convenience/constants.js | 37 + .../grammy/out/convenience/frameworks.d.ts | 226 + .../grammy/out/convenience/frameworks.js | 393 ++ .../grammy/out/convenience/inline_query.d.ts | 401 ++ .../grammy/out/convenience/inline_query.js | 461 ++ .../grammy/out/convenience/input_media.d.ts | 72 + .../grammy/out/convenience/input_media.js | 82 + .../grammy/out/convenience/keyboard.d.ts | 879 +++ .../grammy/out/convenience/keyboard.js | 1155 ++++ .../grammy/out/convenience/session.d.ts | 345 + .../grammy/out/convenience/session.js | 455 ++ .../grammy/out/convenience/webhook.d.ts | 59 + .../grammy/out/convenience/webhook.js | 120 + .../node_modules/grammy/out/core/api.d.ts | 1952 ++++++ .../tgbot/node_modules/grammy/out/core/api.js | 2310 +++++++ .../node_modules/grammy/out/core/client.d.ts | 180 + .../node_modules/grammy/out/core/client.js | 228 + .../node_modules/grammy/out/core/error.d.ts | 53 + .../node_modules/grammy/out/core/error.js | 87 + .../node_modules/grammy/out/core/payload.d.ts | 39 + .../node_modules/grammy/out/core/payload.js | 202 + .../tgbot/node_modules/grammy/out/filter.d.ts | 1165 ++++ .../tgbot/node_modules/grammy/out/filter.js | 408 ++ .../tgbot/node_modules/grammy/out/mod.d.ts | 14 + sandbox/tgbot/node_modules/grammy/out/mod.js | 43 + .../grammy/out/platform.node.d.ts | 16 + .../node_modules/grammy/out/platform.node.js | 43 + .../node_modules/grammy/out/shim.node.d.ts | 2 + .../node_modules/grammy/out/shim.node.js | 7 + .../tgbot/node_modules/grammy/out/types.d.ts | 1 + .../tgbot/node_modules/grammy/out/types.js | 17 + .../node_modules/grammy/out/types.node.d.ts | 95 + .../node_modules/grammy/out/types.node.js | 110 + .../tgbot/node_modules/grammy/out/web.d.ts | 1 + sandbox/tgbot/node_modules/grammy/out/web.mjs | 5838 +++++++++++++++++ .../tgbot/node_modules/grammy/package.json | 71 + sandbox/tgbot/node_modules/ms/index.js | 162 + sandbox/tgbot/node_modules/ms/license.md | 21 + sandbox/tgbot/node_modules/ms/package.json | 38 + sandbox/tgbot/node_modules/ms/readme.md | 59 + .../tgbot/node_modules/node-fetch/LICENSE.md | 22 + .../tgbot/node_modules/node-fetch/README.md | 634 ++ .../tgbot/node_modules/node-fetch/browser.js | 25 + .../node_modules/node-fetch/lib/index.es.js | 1777 +++++ .../node_modules/node-fetch/lib/index.js | 1787 +++++ .../node_modules/node-fetch/lib/index.mjs | 1775 +++++ .../node_modules/node-fetch/package.json | 89 + sandbox/tgbot/node_modules/tr46/.npmignore | 4 + sandbox/tgbot/node_modules/tr46/index.js | 193 + sandbox/tgbot/node_modules/tr46/lib/.gitkeep | 0 .../node_modules/tr46/lib/mappingTable.json | 1 + sandbox/tgbot/node_modules/tr46/package.json | 31 + .../webidl-conversions/LICENSE.md | 12 + .../node_modules/webidl-conversions/README.md | 53 + .../webidl-conversions/lib/index.js | 189 + .../webidl-conversions/package.json | 23 + .../tgbot/node_modules/whatwg-url/LICENSE.txt | 21 + .../tgbot/node_modules/whatwg-url/README.md | 67 + .../node_modules/whatwg-url/lib/URL-impl.js | 200 + .../tgbot/node_modules/whatwg-url/lib/URL.js | 196 + .../node_modules/whatwg-url/lib/public-api.js | 11 + .../whatwg-url/lib/url-state-machine.js | 1297 ++++ .../node_modules/whatwg-url/lib/utils.js | 20 + .../node_modules/whatwg-url/package.json | 32 + sandbox/tgbot/package-lock.json | 123 + sandbox/tgbot/package.json | 15 + 152 files changed, 47694 insertions(+), 263 deletions(-) create mode 100644 .gitignore create mode 100644 adolf/channels.py create mode 100644 adolf/cli.py create mode 100644 adolf/grammy/Dockerfile create mode 100644 adolf/grammy/bot.mjs create mode 100644 adolf/grammy/package.json create mode 100644 adolf/hello_world.py create mode 100644 adolf/langgraph.md create mode 100644 adolf/openmemory/Dockerfile create mode 100644 adolf/openmemory/requirements.txt create mode 100644 adolf/reasoning.md create mode 100644 adolf/wiki_research.py create mode 100644 haos/CLAUDE.md create mode 100644 ntfy/docker-compose.yml create mode 100644 otter/docker-compose.yml create mode 100644 pihole/docker-compose.yaml create mode 100644 sandbox/tgbot/bot.mjs create mode 100644 sandbox/tgbot/node_modules/.package-lock.json create mode 100644 sandbox/tgbot/node_modules/@grammyjs/types/LICENSE create mode 100644 sandbox/tgbot/node_modules/@grammyjs/types/README.md create mode 100644 sandbox/tgbot/node_modules/@grammyjs/types/api.d.ts create mode 100644 sandbox/tgbot/node_modules/@grammyjs/types/checklist.d.ts create mode 100644 sandbox/tgbot/node_modules/@grammyjs/types/inline.d.ts create mode 100644 sandbox/tgbot/node_modules/@grammyjs/types/langs.d.ts create mode 100644 sandbox/tgbot/node_modules/@grammyjs/types/manage.d.ts create mode 100644 sandbox/tgbot/node_modules/@grammyjs/types/markup.d.ts create mode 100644 sandbox/tgbot/node_modules/@grammyjs/types/message.d.ts create mode 100644 sandbox/tgbot/node_modules/@grammyjs/types/methods.d.ts create mode 100644 sandbox/tgbot/node_modules/@grammyjs/types/mod.d.ts create mode 100644 sandbox/tgbot/node_modules/@grammyjs/types/mod.js create mode 100644 sandbox/tgbot/node_modules/@grammyjs/types/package.json create mode 100644 sandbox/tgbot/node_modules/@grammyjs/types/passport.d.ts create mode 100644 sandbox/tgbot/node_modules/@grammyjs/types/payment.d.ts create mode 100644 sandbox/tgbot/node_modules/@grammyjs/types/settings.d.ts create mode 100644 sandbox/tgbot/node_modules/@grammyjs/types/story.d.ts create mode 100644 sandbox/tgbot/node_modules/@grammyjs/types/update.d.ts create mode 100644 sandbox/tgbot/node_modules/abort-controller/LICENSE create mode 100644 sandbox/tgbot/node_modules/abort-controller/README.md create mode 100644 sandbox/tgbot/node_modules/abort-controller/browser.js create mode 100644 sandbox/tgbot/node_modules/abort-controller/browser.mjs create mode 100644 sandbox/tgbot/node_modules/abort-controller/dist/abort-controller.d.ts create mode 100644 sandbox/tgbot/node_modules/abort-controller/dist/abort-controller.js create mode 100644 sandbox/tgbot/node_modules/abort-controller/dist/abort-controller.js.map create mode 100644 sandbox/tgbot/node_modules/abort-controller/dist/abort-controller.mjs create mode 100644 sandbox/tgbot/node_modules/abort-controller/dist/abort-controller.mjs.map create mode 100644 sandbox/tgbot/node_modules/abort-controller/dist/abort-controller.umd.js create mode 100644 sandbox/tgbot/node_modules/abort-controller/dist/abort-controller.umd.js.map create mode 100644 sandbox/tgbot/node_modules/abort-controller/package.json create mode 100644 sandbox/tgbot/node_modules/abort-controller/polyfill.js create mode 100644 sandbox/tgbot/node_modules/abort-controller/polyfill.mjs create mode 100644 sandbox/tgbot/node_modules/debug/LICENSE create mode 100644 sandbox/tgbot/node_modules/debug/README.md create mode 100644 sandbox/tgbot/node_modules/debug/package.json create mode 100644 sandbox/tgbot/node_modules/debug/src/browser.js create mode 100644 sandbox/tgbot/node_modules/debug/src/common.js create mode 100644 sandbox/tgbot/node_modules/debug/src/index.js create mode 100644 sandbox/tgbot/node_modules/debug/src/node.js create mode 100644 sandbox/tgbot/node_modules/event-target-shim/LICENSE create mode 100644 sandbox/tgbot/node_modules/event-target-shim/README.md create mode 100644 sandbox/tgbot/node_modules/event-target-shim/dist/event-target-shim.js create mode 100644 sandbox/tgbot/node_modules/event-target-shim/dist/event-target-shim.js.map create mode 100644 sandbox/tgbot/node_modules/event-target-shim/dist/event-target-shim.mjs create mode 100644 sandbox/tgbot/node_modules/event-target-shim/dist/event-target-shim.mjs.map create mode 100644 sandbox/tgbot/node_modules/event-target-shim/dist/event-target-shim.umd.js create mode 100644 sandbox/tgbot/node_modules/event-target-shim/dist/event-target-shim.umd.js.map create mode 100644 sandbox/tgbot/node_modules/event-target-shim/index.d.ts create mode 100644 sandbox/tgbot/node_modules/event-target-shim/package.json create mode 100644 sandbox/tgbot/node_modules/grammy/LICENSE create mode 100644 sandbox/tgbot/node_modules/grammy/README.md create mode 100644 sandbox/tgbot/node_modules/grammy/out/bot.d.ts create mode 100644 sandbox/tgbot/node_modules/grammy/out/bot.js create mode 100644 sandbox/tgbot/node_modules/grammy/out/composer.d.ts create mode 100644 sandbox/tgbot/node_modules/grammy/out/composer.js create mode 100644 sandbox/tgbot/node_modules/grammy/out/context.d.ts create mode 100644 sandbox/tgbot/node_modules/grammy/out/context.js create mode 100644 sandbox/tgbot/node_modules/grammy/out/convenience/constants.d.ts create mode 100644 sandbox/tgbot/node_modules/grammy/out/convenience/constants.js create mode 100644 sandbox/tgbot/node_modules/grammy/out/convenience/frameworks.d.ts create mode 100644 sandbox/tgbot/node_modules/grammy/out/convenience/frameworks.js create mode 100644 sandbox/tgbot/node_modules/grammy/out/convenience/inline_query.d.ts create mode 100644 sandbox/tgbot/node_modules/grammy/out/convenience/inline_query.js create mode 100644 sandbox/tgbot/node_modules/grammy/out/convenience/input_media.d.ts create mode 100644 sandbox/tgbot/node_modules/grammy/out/convenience/input_media.js create mode 100644 sandbox/tgbot/node_modules/grammy/out/convenience/keyboard.d.ts create mode 100644 sandbox/tgbot/node_modules/grammy/out/convenience/keyboard.js create mode 100644 sandbox/tgbot/node_modules/grammy/out/convenience/session.d.ts create mode 100644 sandbox/tgbot/node_modules/grammy/out/convenience/session.js create mode 100644 sandbox/tgbot/node_modules/grammy/out/convenience/webhook.d.ts create mode 100644 sandbox/tgbot/node_modules/grammy/out/convenience/webhook.js create mode 100644 sandbox/tgbot/node_modules/grammy/out/core/api.d.ts create mode 100644 sandbox/tgbot/node_modules/grammy/out/core/api.js create mode 100644 sandbox/tgbot/node_modules/grammy/out/core/client.d.ts create mode 100644 sandbox/tgbot/node_modules/grammy/out/core/client.js create mode 100644 sandbox/tgbot/node_modules/grammy/out/core/error.d.ts create mode 100644 sandbox/tgbot/node_modules/grammy/out/core/error.js create mode 100644 sandbox/tgbot/node_modules/grammy/out/core/payload.d.ts create mode 100644 sandbox/tgbot/node_modules/grammy/out/core/payload.js create mode 100644 sandbox/tgbot/node_modules/grammy/out/filter.d.ts create mode 100644 sandbox/tgbot/node_modules/grammy/out/filter.js create mode 100644 sandbox/tgbot/node_modules/grammy/out/mod.d.ts create mode 100644 sandbox/tgbot/node_modules/grammy/out/mod.js create mode 100644 sandbox/tgbot/node_modules/grammy/out/platform.node.d.ts create mode 100644 sandbox/tgbot/node_modules/grammy/out/platform.node.js create mode 100644 sandbox/tgbot/node_modules/grammy/out/shim.node.d.ts create mode 100644 sandbox/tgbot/node_modules/grammy/out/shim.node.js create mode 100644 sandbox/tgbot/node_modules/grammy/out/types.d.ts create mode 100644 sandbox/tgbot/node_modules/grammy/out/types.js create mode 100644 sandbox/tgbot/node_modules/grammy/out/types.node.d.ts create mode 100644 sandbox/tgbot/node_modules/grammy/out/types.node.js create mode 100644 sandbox/tgbot/node_modules/grammy/out/web.d.ts create mode 100644 sandbox/tgbot/node_modules/grammy/out/web.mjs create mode 100644 sandbox/tgbot/node_modules/grammy/package.json create mode 100644 sandbox/tgbot/node_modules/ms/index.js create mode 100644 sandbox/tgbot/node_modules/ms/license.md create mode 100644 sandbox/tgbot/node_modules/ms/package.json create mode 100644 sandbox/tgbot/node_modules/ms/readme.md create mode 100644 sandbox/tgbot/node_modules/node-fetch/LICENSE.md create mode 100644 sandbox/tgbot/node_modules/node-fetch/README.md create mode 100644 sandbox/tgbot/node_modules/node-fetch/browser.js create mode 100644 sandbox/tgbot/node_modules/node-fetch/lib/index.es.js create mode 100644 sandbox/tgbot/node_modules/node-fetch/lib/index.js create mode 100644 sandbox/tgbot/node_modules/node-fetch/lib/index.mjs create mode 100644 sandbox/tgbot/node_modules/node-fetch/package.json create mode 100644 sandbox/tgbot/node_modules/tr46/.npmignore create mode 100644 sandbox/tgbot/node_modules/tr46/index.js create mode 100644 sandbox/tgbot/node_modules/tr46/lib/.gitkeep create mode 100644 sandbox/tgbot/node_modules/tr46/lib/mappingTable.json create mode 100644 sandbox/tgbot/node_modules/tr46/package.json create mode 100644 sandbox/tgbot/node_modules/webidl-conversions/LICENSE.md create mode 100644 sandbox/tgbot/node_modules/webidl-conversions/README.md create mode 100644 sandbox/tgbot/node_modules/webidl-conversions/lib/index.js create mode 100644 sandbox/tgbot/node_modules/webidl-conversions/package.json create mode 100644 sandbox/tgbot/node_modules/whatwg-url/LICENSE.txt create mode 100644 sandbox/tgbot/node_modules/whatwg-url/README.md create mode 100644 sandbox/tgbot/node_modules/whatwg-url/lib/URL-impl.js create mode 100644 sandbox/tgbot/node_modules/whatwg-url/lib/URL.js create mode 100644 sandbox/tgbot/node_modules/whatwg-url/lib/public-api.js create mode 100644 sandbox/tgbot/node_modules/whatwg-url/lib/url-state-machine.js create mode 100644 sandbox/tgbot/node_modules/whatwg-url/lib/utils.js create mode 100644 sandbox/tgbot/node_modules/whatwg-url/package.json create mode 100644 sandbox/tgbot/package-lock.json create mode 100644 sandbox/tgbot/package.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3573721 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +adolf/.env diff --git a/CLAUDE.md b/CLAUDE.md index efe08f8..a86f046 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -125,3 +125,100 @@ git push http://alvis:$GITEA_TOKEN@localhost:3000/alvis/AgapHost.wiki.git main - Remove outdated or redundant content when updating - Create a new page if a topic doesn't exist yet - Wiki files are Markdown, named `.md` + +## Home Assistant API + +**Instance**: `https://haos.alogins.net` +**Token**: Read from `$HA_TOKEN` environment variable — never hardcode it +**Base URL**: `https://haos.alogins.net/api/` +**Auth header**: `Authorization: Bearer ` + +### Common Endpoints +```bash +# Health check +curl -s -H "Authorization: Bearer $HA_TOKEN" \ + https://haos.alogins.net/api/ + +# Get all entity states +curl -s -H "Authorization: Bearer $HA_TOKEN" \ + https://haos.alogins.net/api/states + +# Get specific entity +curl -s -H "Authorization: Bearer $HA_TOKEN" \ + https://haos.alogins.net/api/states/ + +# Call service (e.g., turn on light) +curl -s -X POST \ + -H "Authorization: Bearer $HA_TOKEN" \ + -H "Content-Type: application/json" \ + -d '{"entity_id":"light.example"}' \ + https://haos.alogins.net/api/services// +``` + +**Note**: Status 401 = token invalid/expired + +## HA → Zabbix Alerting + +Home Assistant automations push alerts to Zabbix via `history.push` API (Zabbix 7.4 trapper items). No middleware needed. + +### Architecture + +``` +[HA sensor ON] → [HA automation] → [rest_command: HTTP POST] → [Zabbix history.push] → [trapper item] → [trigger] → [Telegram] +``` + +### Water Leak Sensors + +3x HOBEIAN ZG-222Z moisture sensors → Disaster-level Zabbix alert with room name. + +| HA Entity | Room | +|-----------|------| +| `binary_sensor.hobeian_zg_222z` | Kitchen | +| `binary_sensor.hobeian_zg_222z_2` | Bathroom | +| `binary_sensor.hobeian_zg_222z_3` | Laundry | + +**Zabbix side** (host "HA Agap", hostid 10780): +- Trapper item: `water.leak` (text type) — receives room name or "ok" +- Trigger: `last(/HA Agap/water.leak)<>"ok"` — Disaster (severity 5), manual close +- Trigger name uses `{ITEM.LASTVALUE}` to show room in notification + +**HA side** (`configuration.yaml`): +- `rest_command.zabbix_water_leak` — POST to Zabbix `history.push`, accepts `{{ room }}` template variable +- `rest_command.zabbix_water_leak_clear` — pushes "ok" to clear +- Automation "Water Leak Alert" — any sensor ON → sends room name to Zabbix +- Automation "Water Leak Clear" — all sensors OFF → sends "ok" + +### Adding a New HA → Zabbix Alert + +1. **Zabbix**: Create trapper item (type 2) on "HA Agap" via `item.create` API. Create trigger via `trigger.create`. +2. **HA config**: Add `rest_command` entry in `configuration.yaml` with `history.push` payload. Restart HA. +3. **HA automation**: Create via `POST /api/config/automation/config/` with trigger on sensor state and action calling the rest_command. +4. **Test**: Call `rest_command` via HA API, verify Zabbix problem appears. + +## Zabbix API + +**Instance**: `http://localhost:81` (local), `https://zb.alogins.net` (external) +**Endpoint**: `http://localhost:81/api_jsonrpc.php` +**Token**: Read from `$ZABBIX_TOKEN` environment variable — never hardcode it +**Auth header**: `Authorization: Bearer ` + +### Common Requests +```bash +# Check API version +curl -s -X POST http://localhost:81/api_jsonrpc.php \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $ZABBIX_TOKEN" \ + -d '{"jsonrpc":"2.0","method":"apiinfo.version","params":{},"id":1}' + +# Get all hosts +curl -s -X POST http://localhost:81/api_jsonrpc.php \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $ZABBIX_TOKEN" \ + -d '{"jsonrpc":"2.0","method":"host.get","params":{"output":"extend"},"id":1}' + +# Get problems/issues +curl -s -X POST http://localhost:81/api_jsonrpc.php \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $ZABBIX_TOKEN" \ + -d '{"jsonrpc":"2.0","method":"problem.get","params":{"output":"extend"},"id":1}' +``` diff --git a/adolf/ARCHITECTURE.md b/adolf/ARCHITECTURE.md index 5c98ec7..7c8871c 100644 --- a/adolf/ARCHITECTURE.md +++ b/adolf/ARCHITECTURE.md @@ -1,126 +1,89 @@ # Adolf -Persistent AI assistant reachable via Telegram. Three-tier model routing with GPU VRAM management. +Autonomous personal assistant with a multi-channel gateway. Three-tier model routing with GPU VRAM management. ## Architecture ``` -Telegram user - ↕ (long-polling) -[grammy] Node.js — port 3001 - - grammY bot polls Telegram - - on message: fire-and-forget POST /chat to deepagents - - exposes MCP SSE server: tool send_telegram_message(chat_id, text) - ↓ POST /chat → 202 Accepted immediately -[deepagents] Python FastAPI — port 8000 - ↓ -Pre-check: starts with /think? → force_complex=True, strip prefix - ↓ -Router (qwen2.5:0.5b, ~1-2s, always warm in VRAM) - Structured output: {tier: light|medium|complex, confidence: 0.0-1.0, reply?: str} - - light: simple conversational → router answers directly, ~1-2s - - medium: needs memory/web search → qwen3:4b + deepagents tools - - complex: multi-step research, planning, code → qwen3:8b + subagents - force_complex always overrides to complex - complex only if confidence >= 0.85 (else downgraded to medium) - ↓ - ├── light ─────────── router reply used directly (no extra LLM call) - ├── medium ────────── deepagents qwen3:4b + TodoList + tools - └── complex ───────── VRAM flush → deepagents qwen3:8b + TodoList + subagents - └→ background: exit_complex_mode (flush 8b, prewarm 4b+router) - ↓ -send_telegram_message via grammy MCP - ↓ -asyncio.create_task(store_memory_async) — spin-wait GPU idle → openmemory add_memory - ↕ MCP SSE ↕ HTTP -[openmemory] Python + mem0 — port 8765 [SearXNG — port 11437] - - add_memory, search_memory, get_all_memories - - extractor: qwen2.5:1.5b on GPU Ollama (11436) — 2–5s - - embedder: nomic-embed-text on CPU Ollama (11435) — 50–150ms - - vector store: Qdrant (port 6333), 768 dims +┌─────────────────────────────────────────────────────┐ +│ CHANNEL ADAPTERS │ +│ │ +│ [Telegram/Grammy] [CLI] [Voice — future] │ +│ ↕ ↕ ↕ │ +│ └────────────────┴────────────┘ │ +│ ↕ │ +│ ┌─────────────────────────┐ │ +│ │ GATEWAY (agent.py) │ │ +│ │ FastAPI :8000 │ │ +│ │ │ │ +│ │ POST /message │ ← all inbound │ +│ │ POST /chat (legacy) │ │ +│ │ GET /reply/{id} SSE │ ← CLI polling │ +│ │ GET /health │ │ +│ │ │ │ +│ │ channels.py registry │ │ +│ │ conversation buffers │ │ +│ └──────────┬──────────────┘ │ +│ ↓ │ +│ ┌──────────────────────┐ │ +│ │ AGENT CORE │ │ +│ │ three-tier routing │ │ +│ │ VRAM management │ │ +│ └──────────────────────┘ │ +│ ↓ │ +│ channels.deliver(session_id, channel, text)│ +│ ↓ ↓ │ +│ telegram → POST grammy/send cli → SSE queue │ +└─────────────────────────────────────────────────────┘ +``` + +## Channel Adapters + +| Channel | session_id | Inbound | Outbound | +|---------|-----------|---------|---------| +| Telegram | `tg-` | Grammy long-poll → POST /message | channels.py → POST grammy:3001/send | +| CLI | `cli-` | POST /message directly | GET /reply/{id} SSE stream | +| Voice | `voice-` | (future) | (future) | + +## Unified Message Flow + +``` +1. Channel adapter receives message +2. POST /message {text, session_id, channel, user_id} +3. 202 Accepted immediately +4. Background: run_agent_task(message, session_id, channel) +5. Route → run agent tier → get reply text +6. channels.deliver(session_id, channel, reply_text) + - always puts reply in pending_replies[session_id] queue (for SSE) + - calls channel-specific send callback +7. GET /reply/{session_id} SSE clients receive the reply ``` ## Three-Tier Model Routing | Tier | Model | VRAM | Trigger | Latency | |------|-------|------|---------|---------| -| Light | qwen2.5:1.5b (router answers) | ~1.2 GB (shared with extraction) | Router classifies as light | ~2–4s | -| Medium | qwen3:4b | ~2.5 GB | Default; router classifies medium | ~20–40s | -| Complex | qwen3:8b | ~5.5 GB | `/think` prefix | ~60–120s | +| Light | qwen2.5:1.5b (router answers) | ~1.2 GB | Router classifies as light | ~2–4s | +| Medium | qwen3:4b | ~2.5 GB | Default | ~20–40s | +| Complex | qwen3:8b | ~6.0 GB | `/think` prefix | ~60–120s | -**Normal VRAM** (light + medium): router/extraction(1.2, shared) + medium(2.5) = ~3.7 GB -**Complex VRAM**: 8b alone = ~5.5 GB — must flush others first - -### Router model: qwen2.5:1.5b (not 0.5b) - -qwen2.5:0.5b is too small for reliable classification — tends to output "medium" for everything -or produces nonsensical output. qwen2.5:1.5b is already loaded in VRAM for memory extraction, -so switching adds zero net VRAM overhead while dramatically improving accuracy. - -Router uses **raw text generation** (not structured output/JSON schema): -- Ask model to output one word: `light`, `medium`, or `complex` -- Parse with simple keyword matching (fallback: `medium`) -- For `light` tier: a second call generates the reply text +**`/think` prefix**: forces complex tier, stripped before sending to agent. ## VRAM Management -GTX 1070 has 8 GB VRAM. Ollama's auto-eviction can spill models to CPU RAM permanently -(all subsequent loads stay on CPU). To prevent this: +GTX 1070 — 8 GB. Ollama must be restarted if CUDA init fails (model loads on CPU). -1. **Always flush explicitly** before loading qwen3:8b (`keep_alive=0`) -2. **Verify eviction** via `/api/ps` poll (15s timeout) before proceeding -3. **Fallback**: timeout → log warning, run medium agent instead -4. **Post-complex**: flush 8b immediately, pre-warm 4b + router +1. Flush explicitly before loading qwen3:8b (`keep_alive=0`) +2. Verify eviction via `/api/ps` poll (15s timeout) before proceeding +3. Fallback: timeout → run medium agent instead +4. Post-complex: flush 8b, pre-warm 4b + router -```python -# Flush (force immediate unload): -POST /api/generate {"model": "qwen3:4b", "prompt": "", "keep_alive": 0} +## Session ID Convention -# Pre-warm (load into VRAM for 5 min): -POST /api/generate {"model": "qwen3:4b", "prompt": "", "keep_alive": 300} -``` +- Telegram: `tg-` (e.g. `tg-346967270`) +- CLI: `cli-` (e.g. `cli-alvis`) -## Agents - -**Medium agent** (`build_medium_agent`): -- `create_deep_agent` with TodoListMiddleware (auto-included) -- Tools: `search_memory`, `get_all_memories`, `web_search` -- No subagents - -**Complex agent** (`build_complex_agent`): -- `create_deep_agent` with TodoListMiddleware + SubAgentMiddleware -- Tools: all agent tools -- Subagents: - - `research`: web_search only, for thorough multi-query web research - - `memory`: search_memory + get_all_memories, for comprehensive context retrieval - -## Concurrency - -| Semaphore | Guards | Notes | -|-----------|--------|-------| -| `_reply_semaphore(1)` | GPU Ollama (all tiers) | One LLM reply inference at a time | -| `_memory_semaphore(1)` | GPU Ollama (qwen2.5:1.5b extraction) | One memory extraction at a time | - -Light path holds `_reply_semaphore` briefly (no GPU inference). -Memory extraction spin-waits until `_reply_semaphore` is free (60s timeout). - -## Pipeline - -1. User message → Grammy → `POST /chat` → 202 Accepted -2. Background: acquire `_reply_semaphore` → route → run agent tier → send reply -3. `asyncio.create_task(store_memory_async)` — spin-waits GPU free, then extracts memories -4. For complex: `asyncio.create_task(exit_complex_mode)` — flushes 8b, pre-warms 4b+router - -## External Services (from openai/ stack) - -| Service | Host Port | Role | -|---------|-----------|------| -| Ollama GPU | 11436 | All reply inference + extraction (qwen2.5:1.5b) | -| Ollama CPU | 11435 | Memory embedding (nomic-embed-text) | -| Qdrant | 6333 | Vector store for memories | -| SearXNG | 11437 | Web search | - -GPU Ollama config: `OLLAMA_MAX_LOADED_MODELS=2`, `OLLAMA_NUM_PARALLEL=1`. +Conversation history is keyed by session_id (5-turn buffer). ## Files @@ -128,17 +91,28 @@ GPU Ollama config: `OLLAMA_MAX_LOADED_MODELS=2`, `OLLAMA_NUM_PARALLEL=1`. adolf/ ├── docker-compose.yml Services: deepagents, openmemory, grammy ├── Dockerfile deepagents container (Python 3.12) -├── agent.py FastAPI + three-tier routing + run_agent_task -├── router.py Router class — qwen2.5:0.5b structured output routing +├── agent.py FastAPI gateway + three-tier routing +├── channels.py Channel registry + deliver() + pending_replies +├── router.py Router class — qwen2.5:1.5b routing ├── vram_manager.py VRAMManager — flush/prewarm/poll Ollama VRAM -├── agent_factory.py build_medium_agent / build_complex_agent (deepagents) +├── agent_factory.py build_medium_agent / build_complex_agent +├── cli.py Interactive CLI REPL client +├── wiki_research.py Batch wiki research pipeline (uses /message + SSE) ├── .env TELEGRAM_BOT_TOKEN (not committed) ├── openmemory/ │ ├── server.py FastMCP + mem0 MCP tools -│ ├── requirements.txt │ └── Dockerfile └── grammy/ - ├── bot.mjs grammY bot + MCP SSE server + ├── bot.mjs grammY Telegram bot + POST /send HTTP endpoint ├── package.json └── Dockerfile ``` + +## External Services (from openai/ stack) + +| Service | Host Port | Role | +|---------|-----------|------| +| Ollama GPU | 11436 | All reply inference | +| Ollama CPU | 11435 | Memory embedding (nomic-embed-text) | +| Qdrant | 6333 | Vector store for memories | +| SearXNG | 11437 | Web search | diff --git a/adolf/Dockerfile b/adolf/Dockerfile index d4cd94f..d81ee0c 100644 --- a/adolf/Dockerfile +++ b/adolf/Dockerfile @@ -5,6 +5,6 @@ WORKDIR /app RUN pip install --no-cache-dir deepagents langchain-ollama langgraph \ fastapi uvicorn langchain-mcp-adapters langchain-community httpx -COPY agent.py vram_manager.py router.py agent_factory.py hello_world.py . +COPY agent.py channels.py vram_manager.py router.py agent_factory.py hello_world.py . CMD ["uvicorn", "agent:app", "--host", "0.0.0.0", "--port", "8000"] diff --git a/adolf/agent.py b/adolf/agent.py index 2ab6351..8d415f9 100644 --- a/adolf/agent.py +++ b/adolf/agent.py @@ -3,10 +3,13 @@ import os import time from contextlib import asynccontextmanager -from fastapi import FastAPI, BackgroundTasks -from fastapi.responses import JSONResponse +from fastapi import FastAPI, BackgroundTasks, Request +from fastapi.responses import JSONResponse, StreamingResponse from pydantic import BaseModel +import re as _re +import httpx as _httpx + from langchain_ollama import ChatOllama from langchain_mcp_adapters.client import MultiServerMCPClient from langchain_community.utilities import SearxSearchWrapper @@ -15,6 +18,7 @@ from langchain_core.tools import Tool from vram_manager import VRAMManager from router import Router from agent_factory import build_medium_agent, build_complex_agent +import channels OLLAMA_BASE_URL = os.getenv("OLLAMA_BASE_URL", "http://localhost:11434") ROUTER_MODEL = os.getenv("DEEPAGENTS_ROUTER_MODEL", "qwen2.5:0.5b") @@ -22,36 +26,27 @@ MEDIUM_MODEL = os.getenv("DEEPAGENTS_MODEL", "qwen3:4b") COMPLEX_MODEL = os.getenv("DEEPAGENTS_COMPLEX_MODEL", "qwen3:8b") SEARXNG_URL = os.getenv("SEARXNG_URL", "http://host.docker.internal:11437") OPENMEMORY_URL = os.getenv("OPENMEMORY_URL", "http://openmemory:8765") -GRAMMY_URL = os.getenv("GRAMMY_URL", "http://grammy:3001") +CRAWL4AI_URL = os.getenv("CRAWL4AI_URL", "http://crawl4ai:11235") MAX_HISTORY_TURNS = 5 _conversation_buffers: dict[str, list] = {} MEDIUM_SYSTEM_PROMPT = ( - "You are a helpful AI assistant talking to a user via Telegram. " - "The user's ID is {user_id}. " - "IMPORTANT: When calling any memory tool (search_memory, get_all_memories), " - "always use user_id=\"{user_id}\". " - "Every conversation is automatically saved to memory after you reply — " - "you do NOT need to explicitly store anything. " - "NEVER tell the user you cannot remember or store information. " - "If the user asks you to remember something, acknowledge it and confirm it will be remembered. " - "Use search_memory when context from past conversations may be relevant. " + "You are a helpful AI assistant. " "Use web_search for questions about current events or facts you don't know. " "Reply concisely." ) COMPLEX_SYSTEM_PROMPT = ( - "You are a capable AI assistant tackling a complex, multi-step task for a Telegram user. " - "The user's ID is {user_id}. " - "IMPORTANT: When calling any memory tool (search_memory, get_all_memories), " - "always use user_id=\"{user_id}\". " - "Plan your work using write_todos before diving in. " - "Delegate: use the 'research' subagent for thorough web research across multiple queries, " - "and the 'memory' subagent to gather comprehensive context from past conversations. " - "Every conversation is automatically saved to memory — you do NOT need to store anything. " - "NEVER tell the user you cannot remember or store information. " - "Produce a thorough, well-structured reply." + "You are a deep research assistant. " + "web_search automatically fetches full page content from top results — use it 6+ times with different queries. " + "Also call fetch_url on any specific URL you want to read in full.\n\n" + "Run searches in English AND Russian/Latvian. " + "After getting results, run follow-up searches based on new facts found.\n\n" + "Write a structured markdown report with sections: " + "Overview, Education, Career, Publications, Online Presence, Interesting Findings.\n" + "Every fact must link to the real URL it came from: [fact](url). " + "NEVER invent URLs. End with: **Sources checked: N**" ) medium_agent = None @@ -59,24 +54,22 @@ complex_agent = None router: Router = None vram_manager: VRAMManager = None mcp_client = None -send_tool = None -add_memory_tool = None # GPU mutex: one LLM inference at a time _reply_semaphore = asyncio.Semaphore(1) -# Memory semaphore: one async extraction at a time -_memory_semaphore = asyncio.Semaphore(1) @asynccontextmanager async def lifespan(app: FastAPI): - global medium_agent, complex_agent, router, vram_manager - global mcp_client, send_tool, add_memory_tool + global medium_agent, complex_agent, router, vram_manager, mcp_client + + # Register channel adapters + channels.register_defaults() # Three model instances router_model = ChatOllama( model=ROUTER_MODEL, base_url=OLLAMA_BASE_URL, think=False, num_ctx=4096, - temperature=0, # deterministic classification + temperature=0, ) medium_model = ChatOllama( model=MEDIUM_MODEL, base_url=OLLAMA_BASE_URL, think=False, num_ctx=8192 @@ -90,7 +83,6 @@ async def lifespan(app: FastAPI): mcp_connections = { "openmemory": {"transport": "sse", "url": f"{OPENMEMORY_URL}/sse"}, - "grammy": {"transport": "sse", "url": f"{GRAMMY_URL}/sse"}, } mcp_client = MultiServerMCPClient(mcp_connections) for attempt in range(12): @@ -103,22 +95,90 @@ async def lifespan(app: FastAPI): print(f"[agent] MCP not ready (attempt {attempt + 1}/12): {e}. Retrying in 5s...") await asyncio.sleep(5) - send_tool = next((t for t in mcp_tools if t.name == "send_telegram_message"), None) - add_memory_tool = next((t for t in mcp_tools if t.name == "add_memory"), None) - agent_tools = [t for t in mcp_tools if t.name not in ("send_telegram_message", "add_memory")] + agent_tools = [t for t in mcp_tools if t.name not in ("add_memory", "search_memory", "get_all_memories")] searx = SearxSearchWrapper(searx_host=SEARXNG_URL) + + def _crawl4ai_fetch(url: str) -> str: + """Fetch a URL via Crawl4AI (JS-rendered, bot-bypass) and return clean markdown.""" + try: + r = _httpx.post(f"{CRAWL4AI_URL}/crawl", json={"urls": [url]}, timeout=60) + r.raise_for_status() + results = r.json().get("results", []) + if not results or not results[0].get("success"): + return "" + md_obj = results[0].get("markdown") or {} + md = md_obj.get("raw_markdown") if isinstance(md_obj, dict) else str(md_obj) + return (md or "")[:5000] + except Exception as e: + return f"[fetch error: {e}]" + + def _search_and_read(query: str) -> str: + """Search the web and automatically fetch full content of top results. + Returns snippets + full page content from the top URLs.""" + import json as _json + # Get structured results from SearXNG + try: + r = _httpx.get( + f"{SEARXNG_URL}/search", + params={"q": query, "format": "json"}, + timeout=15, + ) + data = r.json() + items = data.get("results", [])[:5] + except Exception as e: + return f"[search error: {e}]" + + if not items: + return "No results found." + + out = [f"Search: {query}\n"] + for i, item in enumerate(items, 1): + url = item.get("url", "") + title = item.get("title", "") + snippet = item.get("content", "")[:300] + out.append(f"\n[{i}] {title}\nURL: {url}\nSnippet: {snippet}") + + # Auto-fetch top 2 URLs for full content + out.append("\n\n--- Full page content ---") + for item in items[:2]: + url = item.get("url", "") + if not url: + continue + content = _crawl4ai_fetch(url) + if content and not content.startswith("[fetch error"): + out.append(f"\n### {url}\n{content[:3000]}") + + return "\n".join(out) + agent_tools.append(Tool( name="web_search", - func=searx.run, - description="Search the web for current information", + func=_search_and_read, + description=( + "Search the web and read full content of top results. " + "Returns search snippets AND full page text from the top URLs. " + "Use multiple different queries to research a topic thoroughly." + ), + )) + + def _fetch_url(url: str) -> str: + """Fetch and read the full text content of a URL.""" + content = _crawl4ai_fetch(url) + return content if content else "[fetch_url: empty or blocked]" + + agent_tools.append(Tool( + name="fetch_url", + func=_fetch_url, + description=( + "Fetch and read the full text content of a specific URL. " + "Use for URLs not covered by web_search. Input: a single URL string." + ), )) - # Build agents (system_prompt filled per-request with user_id) medium_agent = build_medium_agent( model=medium_model, agent_tools=agent_tools, - system_prompt=MEDIUM_SYSTEM_PROMPT.format(user_id="{user_id}"), + system_prompt=MEDIUM_SYSTEM_PROMPT, ) complex_agent = build_complex_agent( model=complex_model, @@ -139,42 +199,34 @@ async def lifespan(app: FastAPI): router = None vram_manager = None mcp_client = None - send_tool = None - add_memory_tool = None app = FastAPI(lifespan=lifespan) +# ── request models ───────────────────────────────────────────────────────────── + +class InboundMessage(BaseModel): + text: str + session_id: str # e.g. "tg-346967270", "cli-alvis" + channel: str # "telegram" | "cli" + user_id: str = "" # human identity; defaults to session_id if empty + metadata: dict = {} + + class ChatRequest(BaseModel): + """Legacy model — kept for test_pipeline.py compatibility.""" message: str chat_id: str -async def store_memory_async(conversation: str, user_id: str): - """Fire-and-forget: extract and store memories after GPU is free.""" - t_wait = time.monotonic() - while _reply_semaphore.locked(): - if time.monotonic() - t_wait > 60: - print(f"[memory] spin-wait timeout 60s, proceeding for user {user_id}", flush=True) - break - await asyncio.sleep(0.5) - async with _memory_semaphore: - t0 = time.monotonic() - try: - await add_memory_tool.ainvoke({"text": conversation, "user_id": user_id}) - print(f"[memory] stored in {time.monotonic() - t0:.1f}s for user {user_id}", flush=True) - except Exception as e: - print(f"[memory] error after {time.monotonic() - t0:.1f}s: {e}", flush=True) - +# ── helpers ──────────────────────────────────────────────────────────────────── def _extract_final_text(result) -> str | None: - """Extract last AIMessage content from agent result.""" msgs = result.get("messages", []) for m in reversed(msgs): if type(m).__name__ == "AIMessage" and getattr(m, "content", ""): return m.content - # deepagents may return output differently if isinstance(result, dict) and result.get("output"): return result["output"] return None @@ -192,10 +244,11 @@ def _log_messages(result): print(f"[agent] {role} → {tc['name']}({tc['args']})", flush=True) -async def run_agent_task(message: str, chat_id: str): - print(f"[agent] queued: {message[:80]!r} chat={chat_id}", flush=True) +# ── core task ────────────────────────────────────────────────────────────────── + +async def run_agent_task(message: str, session_id: str, channel: str = "telegram"): + print(f"[agent] queued: {message[:80]!r} chat={session_id}", flush=True) - # Pre-check: /think prefix forces complex tier force_complex = False clean_message = message if message.startswith("/think "): @@ -205,10 +258,9 @@ async def run_agent_task(message: str, chat_id: str): async with _reply_semaphore: t0 = time.monotonic() - history = _conversation_buffers.get(chat_id, []) + history = _conversation_buffers.get(session_id, []) print(f"[agent] running: {clean_message[:80]!r}", flush=True) - # Route the message tier, light_reply = await router.route(clean_message, history, force_complex) print(f"[agent] tier={tier} message={clean_message[:60]!r}", flush=True) @@ -220,7 +272,7 @@ async def run_agent_task(message: str, chat_id: str): print(f"[agent] light path: answered by router", flush=True) elif tier == "medium": - system_prompt = MEDIUM_SYSTEM_PROMPT.format(user_id=chat_id) + system_prompt = MEDIUM_SYSTEM_PROMPT result = await medium_agent.ainvoke({ "messages": [ {"role": "system", "content": system_prompt}, @@ -237,16 +289,15 @@ async def run_agent_task(message: str, chat_id: str): if not ok: print("[agent] complex→medium fallback (eviction timeout)", flush=True) tier = "medium" - system_prompt = MEDIUM_SYSTEM_PROMPT.format(user_id=chat_id) result = await medium_agent.ainvoke({ "messages": [ - {"role": "system", "content": system_prompt}, + {"role": "system", "content": MEDIUM_SYSTEM_PROMPT}, *history, {"role": "user", "content": clean_message}, ] }) else: - system_prompt = COMPLEX_SYSTEM_PROMPT.format(user_id=chat_id) + system_prompt = COMPLEX_SYSTEM_PROMPT.format(user_id=session_id) result = await complex_agent.ainvoke({ "messages": [ {"role": "system", "content": system_prompt}, @@ -263,47 +314,73 @@ async def run_agent_task(message: str, chat_id: str): except Exception as e: import traceback llm_elapsed = time.monotonic() - t0 - print(f"[agent] error after {llm_elapsed:.1f}s for chat {chat_id}: {e}", flush=True) + print(f"[agent] error after {llm_elapsed:.1f}s for chat {session_id}: {e}", flush=True) traceback.print_exc() - # Send reply via grammy MCP (split if > Telegram's 4096-char limit) - if final_text and send_tool: + # Deliver reply through the originating channel + if final_text: t1 = time.monotonic() - MAX_TG = 4000 # leave headroom below the 4096 hard limit - chunks = [final_text[i:i + MAX_TG] for i in range(0, len(final_text), MAX_TG)] - for chunk in chunks: - await send_tool.ainvoke({"chat_id": chat_id, "text": chunk}) + await channels.deliver(session_id, channel, final_text) send_elapsed = time.monotonic() - t1 - # Log in format compatible with test_pipeline.py parser print( f"[agent] replied in {time.monotonic() - t0:.1f}s " f"(llm={llm_elapsed:.1f}s, send={send_elapsed:.1f}s) tier={tier}", flush=True, ) - elif not final_text: + print(f"[agent] reply_text: {final_text}", flush=True) + else: print("[agent] warning: no text reply from agent", flush=True) # Update conversation buffer if final_text: - buf = _conversation_buffers.get(chat_id, []) + buf = _conversation_buffers.get(session_id, []) buf.append({"role": "user", "content": clean_message}) buf.append({"role": "assistant", "content": final_text}) - _conversation_buffers[chat_id] = buf[-(MAX_HISTORY_TURNS * 2):] + _conversation_buffers[session_id] = buf[-(MAX_HISTORY_TURNS * 2):] - # Async memory storage (fire-and-forget) - if add_memory_tool and final_text: - conversation = f"User: {clean_message}\nAssistant: {final_text}" - asyncio.create_task(store_memory_async(conversation, chat_id)) + +# ── endpoints ────────────────────────────────────────────────────────────────── + +@app.post("/message") +async def message(request: InboundMessage, background_tasks: BackgroundTasks): + """Unified inbound endpoint for all channels.""" + if medium_agent is None: + return JSONResponse(status_code=503, content={"error": "Agent not ready"}) + session_id = request.session_id + channel = request.channel + background_tasks.add_task(run_agent_task, request.text, session_id, channel) + return JSONResponse(status_code=202, content={"status": "accepted"}) @app.post("/chat") async def chat(request: ChatRequest, background_tasks: BackgroundTasks): + """Legacy endpoint — maps chat_id to tg- session for backward compatibility.""" if medium_agent is None: return JSONResponse(status_code=503, content={"error": "Agent not ready"}) - background_tasks.add_task(run_agent_task, request.message, request.chat_id) + session_id = f"tg-{request.chat_id}" + background_tasks.add_task(run_agent_task, request.message, session_id, "telegram") return JSONResponse(status_code=202, content={"status": "accepted"}) +@app.get("/reply/{session_id}") +async def reply_stream(session_id: str): + """ + SSE endpoint — streams the reply for a session once available, then closes. + Used by CLI client and wiki_research.py instead of log polling. + """ + q = channels.pending_replies.setdefault(session_id, asyncio.Queue()) + + async def event_generator(): + try: + text = await asyncio.wait_for(q.get(), timeout=900) + # Escape newlines so entire reply fits in one SSE data line + yield f"data: {text.replace(chr(10), '\\n').replace(chr(13), '')}\n\n" + except asyncio.TimeoutError: + yield "data: [timeout]\n\n" + + return StreamingResponse(event_generator(), media_type="text/event-stream") + + @app.get("/health") async def health(): return {"status": "ok", "agent_ready": medium_agent is not None} diff --git a/adolf/agent_factory.py b/adolf/agent_factory.py index 5926504..6182ff4 100644 --- a/adolf/agent_factory.py +++ b/adolf/agent_factory.py @@ -1,4 +1,4 @@ -from deepagents import create_deep_agent, SubAgent +from deepagents import create_deep_agent def build_medium_agent(model, agent_tools: list, system_prompt: str): @@ -11,44 +11,9 @@ def build_medium_agent(model, agent_tools: list, system_prompt: str): def build_complex_agent(model, agent_tools: list, system_prompt: str): - """Complex agent: create_deep_agent with TodoList planning + research/memory subagents.""" - web_tools = [t for t in agent_tools if getattr(t, "name", "") == "web_search"] - memory_tools = [ - t for t in agent_tools - if getattr(t, "name", "") in ("search_memory", "get_all_memories") - ] - - research_sub: SubAgent = { - "name": "research", - "description": ( - "Runs multiple web searches in parallel and synthesizes findings. " - "Use for thorough research tasks requiring several queries." - ), - "system_prompt": ( - "You are a research specialist. Search the web thoroughly using multiple queries. " - "Cite sources and synthesize information into a clear summary." - ), - "tools": web_tools, - "model": model, - } - - memory_sub: SubAgent = { - "name": "memory", - "description": ( - "Searches and retrieves all relevant memories about the user comprehensively. " - "Use to gather full context from past conversations." - ), - "system_prompt": ( - "You are a memory specialist. Search broadly using multiple queries. " - "Return all relevant facts and context you find." - ), - "tools": memory_tools, - "model": model, - } - + """Complex agent: direct agentic loop — calls web_search/fetch_url itself, no subagent indirection.""" return create_deep_agent( model=model, tools=agent_tools, system_prompt=system_prompt, - subagents=[research_sub, memory_sub], ) diff --git a/adolf/channels.py b/adolf/channels.py new file mode 100644 index 0000000..97c50c5 --- /dev/null +++ b/adolf/channels.py @@ -0,0 +1,75 @@ +""" +Channel registry and reply delivery for the Adolf multi-channel gateway. + +Each channel registers an async send callback: + channels.register("telegram", telegram_send) + channels.register("cli", cli_send) + +When the agent is done, it calls: + await channels.deliver(session_id, channel, text) + +Replies are also placed into per-session asyncio Queues so the +GET /reply/{session_id} SSE endpoint can stream them to polling clients. +""" + +import asyncio +import os +from typing import Awaitable, Callable + +import httpx + +# ── channel registry ────────────────────────────────────────────────────────── + +_callbacks: dict[str, Callable[[str, str], Awaitable[None]]] = {} +# session_id → Queue that receives the final reply text +pending_replies: dict[str, asyncio.Queue] = {} + + +def register(channel: str, callback: Callable[[str, str], Awaitable[None]]) -> None: + """Register an async send callback for a channel name.""" + _callbacks[channel] = callback + + +async def deliver(session_id: str, channel: str, text: str) -> None: + """ + Deliver a reply to the originating channel AND put it in the pending + queue so SSE /reply/{session_id} clients get it. + """ + # Always enqueue first so SSE listeners aren't missed + q = pending_replies.setdefault(session_id, asyncio.Queue()) + await q.put(text) + + cb = _callbacks.get(channel) + if cb: + await cb(session_id, text) + else: + print(f"[channels] no callback for channel={channel!r}, reply queued only", flush=True) + + +# ── built-in channel adapters ───────────────────────────────────────────────── + +GRAMMY_URL = os.getenv("GRAMMY_URL", "http://grammy:3001") + + +async def _telegram_send(session_id: str, text: str) -> None: + """Send reply to Telegram via Grammy's POST /send endpoint.""" + chat_id = session_id.removeprefix("tg-") + MAX_TG = 4000 + chunks = [text[i:i + MAX_TG] for i in range(0, len(text), MAX_TG)] + async with httpx.AsyncClient(timeout=15) as client: + for chunk in chunks: + await client.post( + f"{GRAMMY_URL}/send", + json={"chat_id": chat_id, "text": chunk}, + ) + + +async def _cli_send(session_id: str, text: str) -> None: + """CLI replies are handled entirely through the pending_replies queue — no-op here.""" + pass + + +def register_defaults() -> None: + """Register the built-in Telegram and CLI channel adapters.""" + register("telegram", _telegram_send) + register("cli", _cli_send) diff --git a/adolf/cli.py b/adolf/cli.py new file mode 100644 index 0000000..4cb909a --- /dev/null +++ b/adolf/cli.py @@ -0,0 +1,80 @@ +#!/usr/bin/env python3 +""" +Adolf CLI — interactive REPL for the multi-channel gateway. + +Usage: + python3 cli.py [--url http://localhost:8000] [--session cli-alvis] +""" + +import argparse +import json +import os +import sys +import urllib.request + +GATEWAY = "http://localhost:8000" + + +def post_message(gateway: str, text: str, session_id: str) -> None: + payload = json.dumps({ + "text": text, + "session_id": session_id, + "channel": "cli", + "user_id": os.getlogin(), + }).encode() + req = urllib.request.Request( + f"{gateway}/message", + data=payload, + headers={"Content-Type": "application/json"}, + method="POST", + ) + with urllib.request.urlopen(req, timeout=10) as r: + if r.status != 202: + print(f"[error] gateway returned {r.status}", file=sys.stderr) + sys.exit(1) + + +def wait_for_reply(gateway: str, session_id: str, timeout: int = 400) -> str: + """Open SSE stream and return first data event.""" + req = urllib.request.Request( + f"{gateway}/reply/{session_id}", + headers={"Accept": "text/event-stream"}, + ) + with urllib.request.urlopen(req, timeout=timeout + 5) as r: + for raw_line in r: + line = raw_line.decode("utf-8").rstrip("\n") + if line.startswith("data:"): + return line[5:].strip().replace("\\n", "\n") + return "" + + +def main(): + parser = argparse.ArgumentParser(description="Adolf CLI") + parser.add_argument("--url", default=GATEWAY, help="Gateway URL") + parser.add_argument("--session", default=f"cli-{os.getlogin()}", help="Session ID") + parser.add_argument("--timeout", type=int, default=400, help="Reply timeout (seconds)") + args = parser.parse_args() + + print(f"Adolf CLI (session={args.session}, gateway={args.url})") + print("Type your message and press Enter. Ctrl+C or Ctrl+D to exit.\n") + + try: + while True: + try: + text = input("> ").strip() + except EOFError: + break + if not text: + continue + + post_message(args.url, text, args.session) + print("...", end="", flush=True) + reply = wait_for_reply(args.url, args.session, timeout=args.timeout) + print(f"\r{reply}\n") + + except KeyboardInterrupt: + print("\nbye") + + +if __name__ == "__main__": + main() diff --git a/adolf/docker-compose.yml b/adolf/docker-compose.yml index 2469c37..6851e19 100644 --- a/adolf/docker-compose.yml +++ b/adolf/docker-compose.yml @@ -11,11 +11,14 @@ services: - DEEPAGENTS_COMPLEX_MODEL=qwen3:8b - DEEPAGENTS_ROUTER_MODEL=qwen2.5:1.5b - SEARXNG_URL=http://host.docker.internal:11437 + - GRAMMY_URL=http://grammy:3001 + - CRAWL4AI_URL=http://crawl4ai:11235 extra_hosts: - "host.docker.internal:host-gateway" depends_on: - openmemory - grammy + - crawl4ai restart: unless-stopped openmemory: @@ -41,3 +44,13 @@ services: - TELEGRAM_BOT_TOKEN=${TELEGRAM_BOT_TOKEN} - DEEPAGENTS_URL=http://deepagents:8000 restart: unless-stopped + + crawl4ai: + image: unclecode/crawl4ai:latest + container_name: crawl4ai + ports: + - "11235:11235" + environment: + - CRAWL4AI_LOG_LEVEL=WARNING + shm_size: "1g" + restart: unless-stopped diff --git a/adolf/grammy/Dockerfile b/adolf/grammy/Dockerfile new file mode 100644 index 0000000..c55d6a5 --- /dev/null +++ b/adolf/grammy/Dockerfile @@ -0,0 +1,6 @@ +FROM node:22-alpine +WORKDIR /app +COPY package.json . +RUN npm install +COPY bot.mjs . +CMD ["node", "bot.mjs"] diff --git a/adolf/grammy/bot.mjs b/adolf/grammy/bot.mjs new file mode 100644 index 0000000..51238fb --- /dev/null +++ b/adolf/grammy/bot.mjs @@ -0,0 +1,56 @@ +import { Bot } from "grammy"; +import express from "express"; + +const TELEGRAM_BOT_TOKEN = process.env.TELEGRAM_BOT_TOKEN; +const DEEPAGENTS_URL = process.env.DEEPAGENTS_URL || "http://deepagents:8000"; + +const bot = new Bot(TELEGRAM_BOT_TOKEN); + +// Forward all text messages to the unified gateway /message endpoint +bot.on("message:text", (ctx) => { + const text = ctx.message.text; + const chat_id = String(ctx.chat.id); + + console.log(`[grammy] message from ${chat_id}: ${text.slice(0, 80)}`); + + fetch(`${DEEPAGENTS_URL}/message`, { + method: "POST", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify({ + text, + session_id: `tg-${chat_id}`, + channel: "telegram", + user_id: chat_id, + }), + }).catch((err) => console.error("[grammy] error forwarding to deepagents:", err)); +}); + +// HTTP server — delivers replies from the gateway back to Telegram +const app = express(); +app.use(express.json()); + +app.post("/send", async (req, res) => { + const { chat_id, text } = req.body; + if (!chat_id || !text) { + res.status(400).json({ error: "chat_id and text required" }); + return; + } + try { + await bot.api.sendMessage(chat_id, text); + console.log(`[grammy] sent to ${chat_id}: ${text.slice(0, 60)}`); + res.json({ ok: true }); + } catch (err) { + console.error(`[grammy] send error to ${chat_id}:`, err.message); + res.status(500).json({ error: err.message }); + } +}); + +app.get("/health", (_req, res) => res.json({ ok: true })); + +app.listen(3001, () => { + console.log("[grammy] HTTP server listening on port 3001"); +}); + +bot.start({ + onStart: (info) => console.log(`[grammy] bot @${info.username} started`), +}); diff --git a/adolf/grammy/package.json b/adolf/grammy/package.json new file mode 100644 index 0000000..ca1ab35 --- /dev/null +++ b/adolf/grammy/package.json @@ -0,0 +1,7 @@ +{ + "type": "module", + "dependencies": { + "grammy": "^1.36.0", +"express": "^4.21.0" + } +} diff --git a/adolf/hello_world.py b/adolf/hello_world.py new file mode 100644 index 0000000..630136e --- /dev/null +++ b/adolf/hello_world.py @@ -0,0 +1,21 @@ +import os +from langchain_ollama import ChatOllama +from deepagents import create_deep_agent + +OLLAMA_BASE_URL = os.getenv("OLLAMA_BASE_URL", "http://localhost:11434") +MODEL = os.getenv("DEEPAGENTS_MODEL", "gemma3:4b") + +print(f"Connecting to Ollama at {OLLAMA_BASE_URL} with model {MODEL}") + +model = ChatOllama(model=MODEL, base_url=OLLAMA_BASE_URL) + +agent = create_deep_agent(model=model) + +result = agent.invoke({ + "messages": [{"role": "user", "content": "Say hello world in one sentence."}] +}) + +print("\n--- Agent Response ---") +for msg in result.get("messages", []): + if hasattr(msg, "content") and msg.content: + print(f"[{msg.__class__.__name__}]: {msg.content}") diff --git a/adolf/langgraph.md b/adolf/langgraph.md new file mode 100644 index 0000000..8a9d3b5 --- /dev/null +++ b/adolf/langgraph.md @@ -0,0 +1,247 @@ +# LangGraph: Multi-Model Routing Architecture + +## Problem + +`create_react_agent` uses one model for all steps in the ReAct loop: + +``` +qwen3:4b → decide to call tool ~37s +→ run tool ~1s +qwen3:4b → final answer ~37s +───────────────────────────────────── +Total ~75s +``` + +The routing step is classification + argument extraction — low entropy, constrained output. +It does not need the same model as answer generation. + +--- + +## Is the Pattern Established? (2025 Research) + +Yes. The 2025 consensus from multiple papers treats heterogeneous model architectures +(small for routing, large for generation) as **settled production engineering**, not research: + +- SLMs (1–12B) match or exceed LLMs on schema-constrained tasks (tool calls, JSON, function + calling) at 10×–100× lower compute cost (arXiv 2510.03847, arXiv 2506.02153) +- MasRouter (ACL 2025): routing in multi-agent graphs reduces costs 2× without quality loss +- Cascade routing (ICLR 2025): 4% accuracy improvement, 30–92% cost reduction vs naive routing +- NVIDIA research (2025): "Small Language Models are the Future of Agentic AI" + +**Limitations acknowledged in literature:** +- Bad router defeats the purpose — classifier quality is critical +- Cascade (try small, escalate if uncertain) adds latency on queries that escalate +- Pre-trained routers (RouteLLM, etc.) are calibrated for specific model pairs; local model + pairs need independent validation + +--- + +## Three-Tier Architecture (small → medium → large) + +### Concept + +``` +Incoming query + ↓ +[Router: tiny model or embedding classifier] ~1-2s + ├── simple/conversational → [Medium: qwen3:4b] ~20s + ├── needs tool call → [Medium: qwen3:4b + tools] ~20-40s + └── complex/multi-step → [Large: qwen3:8b + sub-agents] ~60s+ +``` + +### When to route to large + +Signals that justify loading a larger model: +- Multi-step reasoning required (math, code, planning) +- Sub-agent orchestration (the agent needs to call other agents) +- Explicit reasoning request ("think through", "analyze carefully") +- Low confidence from medium model (cascade pattern) + +### Trade-offs of three-tier vs two-tier + +| | Two-tier | Three-tier | +|--|---------|-----------| +| Simple queries | small router + medium answer | small router + medium answer (same) | +| Complex queries | medium (may struggle) | swap to large (better quality) | +| GPU constraint | manageable | hard — see below | +| Routing error cost | low | high (wrong tier = much slower) | + +--- + +## The 8GB GPU Constraint — Core Problem + +This is the central issue. Research numbers on model swapping (2025): + +**Cold swap from disk (no optimization)** +- TTFT exceeds 140s for 7B-class models on HDD; 5–15s on NVMe SSD +- Not viable for interactive use at any tier + +**vLLM Sleep Mode (offload to CPU RAM, not disk)** +- 18–200× faster than cold start; TTFT 2–3s per switch +- vLLM-specific — not available in Ollama + +**Ollama behavior on 8GB VRAM** +- Default `keep_alive`: 5 minutes — model stays warm after use +- Two models simultaneously: qwen3:4b (~2.5GB) + qwen2.5:1.5b (~1.2GB) = ~3.7GB — fits +- qwen3:4b + qwen3:8b = ~8GB — does not reliably fit; eviction required +- Sequential swap in Ollama: Ollama evicts old model, loads new one from SSD (~5–15s on NVMe) +- Known Ollama bug: model spills from VRAM to RAM → all subsequent loads stay on CPU until restart + +**Conclusion for three-tier on single 8GB GPU:** + +| Tier switch | Cost | Viable? | +|------------|------|---------| +| tiny router → medium (qwen3:4b) | model swap ~5-15s if router is separate | borderline | +| medium → large (qwen3:8b) | evict qwen3:4b, load qwen3:8b = ~5-15s additional | no, for interactive | +| Keep medium always warm, route to large on demand | 5-15s swap overhead per complex query | acceptable if complex queries are rare | + +**Honest verdict: three-tier with model swapping is not viable for interactive per-turn latency +on 8GB VRAM with Ollama.** vLLM with Sleep Mode would make it viable (2–3s switch) but +requires replacing Ollama. + +--- + +## Practical Architecture for 8GB GPU (Ollama) + +### Option 1: Two-tier, both models always in VRAM (recommended) + +Keep two small models loaded simultaneously: + +``` +qwen2.5:0.5b (~0.4GB) — router: tool call decision + arg extraction +qwen3:4b (~2.5GB) — answer: all generation +nomic-embed-text (CPU) — embedding: search and store +qwen2.5:1.5b (~1.2GB) — extraction: mem0 fact extraction (GPU) +───────────────────────────────────────────────────────── +Total VRAM: ~4.1GB — well within 8GB +``` + +No swapping needed. Router runs first (~1-2s), answer model runs after (~20s). + +``` +Router → tool call JSON or "no tool" ~1-2s +→ tool runs (if needed) ~1s +→ Answer model generates reply ~20s +───────────────────────────────────────────── +Total ~22-23s +``` + +vs current two-call approach: ~75s. + +### Option 2: Semantic routing (encoder-only, free) + +Use nomic-embed-text (already running on CPU) as the router: + +```python +query_vec = embed(query) +sims = { + "search_memory": cosine(query_vec, memory_topic_vec), + "web_search": cosine(query_vec, web_topic_vec), +} +# If max sim > threshold → call that tool directly +# Then pass result + original query to answer model +``` + +Zero VRAM overhead. ~50ms routing. Can't extract tool args from embedding alone — +needs hardcoded arg construction (e.g. query = original user message). + +### Option 3: Three-tier with rare large-model escalation + +Keep qwen3:4b warm. Route to qwen3:8b only for explicitly complex tasks. +Accept ~10s swap overhead for those queries. qwen3:8b gets unloaded after. + +``` +Router → simple → qwen3:4b ~20s (no swap) +Router → complex → evict 4b, load 8b → ~30s (10s swap + 20s inference) +``` + +Works if <20% of queries are "complex" and users accept occasional slow responses. +Best implemented with explicit user trigger ("think about this carefully") rather than +automatic classification, to avoid swap overhead on misclassified queries. + +--- + +## LangGraph Implementation + +`create_react_agent` locks to one model. Explicit graph supports per-node models: + +```python +from langgraph.graph import StateGraph, MessagesState +from langgraph.prebuilt import ToolNode +from langchain_ollama import ChatOllama + +router_model = ChatOllama(model="qwen2.5:0.5b", base_url=OLLAMA_GPU_URL) +answer_model = ChatOllama(model="qwen3:4b", base_url=OLLAMA_GPU_URL) +# For Option 3: large_model = ChatOllama(model="qwen3:8b", ...) + +def router_node(state): + # Small model only outputs tool call JSON or nothing + return {"messages": [router_model.bind_tools(tools).invoke(state["messages"])]} + +def answer_node(state): + # Large(r) model generates human reply — no tools bound + return {"messages": [answer_model.invoke(state["messages"])]} + +def route(state) -> str: + last = state["messages"][-1] + return "tools" if getattr(last, "tool_calls", []) else "answer" + +graph = StateGraph(MessagesState) +graph.add_node("router", router_node) +graph.add_node("tools", ToolNode(tools)) +graph.add_node("answer", answer_node) +graph.set_entry_point("router") +graph.add_conditional_edges("router", route) +graph.add_edge("tools", "answer") +graph.add_edge("answer", END) +agent = graph.compile() +``` + +For three-tier, add a complexity classifier node before the router that selects +`answer_model = medium_model or large_model` based on query signals. + +--- + +## Open Source Routing Tools + +| Tool | Ollama support | Status | Notes | +|------|---------------|--------|-------| +| LiteLLM | First-class | Active 2025 | Proxy with tiered routing, fallbacks, load balancing | +| RouteLLM (LMSYS) | Yes (documented) | Stale (last commit Aug 2024) | Calibrated for GPT-4 vs Mixtral pair | +| Router-R1 | No | Active (NeurIPS 2025) | RL-based, open-sourced on HuggingFace | +| LLMRouter (ulab) | No | Research 2025 | 16+ routing methods, fair comparison framework | +| FrugalGPT | No direct | Algorithm only | Portkey.ai has implementation guide | + +**Most practical for Ollama**: LiteLLM proxy with tiered model config. Handles routing, +fallbacks, and load balancing without changing agent code. + +--- + +## Summary: What to Do for Adolf + +| | Recommendation | +|--|---------------| +| Quick win (zero risk) | Remove "always call search_memory" from system prompt — history buffer covers conversational recall, saves ~37s | +| Best architecture for 8GB | Two-tier: qwen2.5:0.5b router + qwen3:4b answer, both in VRAM, ~22s total | +| Three-tier feasibility | Not viable for interactive use with Ollama model swapping; viable with vLLM Sleep Mode (~3s swap) if Ollama is replaced | +| Complex task routing | Use explicit user trigger or keyword detection rather than automatic classifier — avoids swap penalty on misclassification | + +--- + +## References + +- arXiv 2510.03847 — Small Language Models for Agentic Systems: A Survey +- arXiv 2506.02153 — Small Language Models are the Future of Agentic AI +- arXiv 2406.04692 — Mixture-of-Agents Enhances LLM Capabilities (original MoA paper) +- arXiv 2410.10347 — A Unified Approach to Routing and Cascading for LLMs (ICLR 2025) +- MasRouter — ACL 2025: https://aclanthology.org/2025.acl-long.757.pdf +- Router-R1 — NeurIPS 2025: https://github.com/ulab-uiuc/Router-R1 +- vLLM Sleep Mode: https://blog.vllm.ai/2025/10/26/sleep-mode.html +- NVIDIA GPU Memory Swap: https://developer.nvidia.com/blog/cut-model-deployment-costs-while-keeping-performance-with-gpu-memory-swap/ +- LangGraph multi-agent: https://langchain-ai.github.io/langgraph/tutorials/multi_agent/ +- LangGraph custom ReAct: https://langchain-ai.github.io/langgraph/how-tos/react-agent-from-scratch/ +- LiteLLM Ollama docs: https://docs.litellm.ai/docs/providers/ollama +- RouteLLM + Ollama example: https://github.com/lm-sys/RouteLLM/blob/main/examples/routing_to_local_models.md +- LLMRouter framework: https://ulab-uiuc.github.io/LLMRouter/ +- Functionary (tool-call fine-tuned): https://github.com/MeetKai/functionary +- Constrained generation (outlines): https://github.com/dottxt-ai/outlines diff --git a/adolf/openmemory/Dockerfile b/adolf/openmemory/Dockerfile new file mode 100644 index 0000000..038abf3 --- /dev/null +++ b/adolf/openmemory/Dockerfile @@ -0,0 +1,6 @@ +FROM python:3.12-slim +WORKDIR /app +COPY requirements.txt . +RUN pip install --no-cache-dir -r requirements.txt +COPY server.py . +CMD ["python", "server.py"] diff --git a/adolf/openmemory/requirements.txt b/adolf/openmemory/requirements.txt new file mode 100644 index 0000000..6ce37d4 --- /dev/null +++ b/adolf/openmemory/requirements.txt @@ -0,0 +1,6 @@ +mem0ai +ollama +fastapi +uvicorn +mcp[cli] +qdrant-client diff --git a/adolf/openmemory/server.py b/adolf/openmemory/server.py index fd85b37..73fd93c 100644 --- a/adolf/openmemory/server.py +++ b/adolf/openmemory/server.py @@ -1,24 +1,109 @@ +import json import os from mcp.server.fastmcp import FastMCP from mem0 import Memory +# Extraction LLM — GPU Ollama (qwen3:4b, same model as medium agent) +# Runs after reply when GPU is idle; spin-wait in agent.py prevents contention +OLLAMA_GPU_URL = os.getenv("OLLAMA_GPU_URL", "http://host.docker.internal:11436") + +# Embedding — CPU Ollama (nomic-embed-text, 137 MB RAM) +# Used for both search (50-150ms, acceptable) and store-time embedding OLLAMA_CPU_URL = os.getenv("OLLAMA_CPU_URL", "http://host.docker.internal:11435") + QDRANT_HOST = os.getenv("QDRANT_HOST", "host.docker.internal") QDRANT_PORT = int(os.getenv("QDRANT_PORT", "6333")) +# Change 2: Custom extraction prompt +# /no_think disables qwen3 thinking tokens so output is clean JSON +EXTRACTION_PROMPT = """/no_think +You are a memory extraction assistant. Extract factual statements from a conversation that are worth remembering long-term. + +Extract facts from BOTH user AND assistant messages, including: +- User details, preferences, and personal information +- User's plans, goals, and intentions +- The assistant's name or persona (if set by the user or stated by the assistant) +- Any commitments or agreements made +- Key facts stated as true + +Return ONLY valid JSON in this exact format: +{"facts": ["fact 1", "fact 2"]} + +If there are no facts worth storing, return: {"facts": []} + +IMPORTANT rules: +- Extract the EXACT concrete values mentioned. Never say "not known" or "unspecified". +- If the user states their name, job, pet, city, allergy, or preference — store the exact value. +- A single message may contain multiple facts — extract ALL of them. +- Do NOT extract vague summaries. Extract specific facts with real values. + +Examples: + +Input: "User: I live in Berlin\nAssistant: Got it, you're in Berlin!" +Output: {"facts": ["User lives in Berlin"]} + +Input: "User: My name is Alice and I live in Tokyo\nAssistant: Nice to meet you Alice!" +Output: {"facts": ["User's name is Alice", "User lives in Tokyo"]} + +Input: "User: I work as a software engineer at a startup\nAssistant: Cool!" +Output: {"facts": ["User works as a software engineer at a startup"]} + +Input: "User: I have a cat named Whiskers\nAssistant: Whiskers is a cute name!" +Output: {"facts": ["User has a cat named Whiskers"]} + +Input: "User: I'm allergic to nuts\nAssistant: I'll remember that." +Output: {"facts": ["User is allergic to nuts"]} + +Input: "User: remember that your name is Adolf\nAssistant: My name is Adolf!" +Output: {"facts": ["Assistant's name is Adolf"]} + +Input: "User: what time is it?\nAssistant: I don't have access to real-time data." +Output: {"facts": []} + +Input: "User: I prefer dark mode\nAssistant: Noted, I'll keep that in mind." +Output: {"facts": ["User prefers dark mode"]} + +Now extract facts from this conversation:""" + +# Update/dedup decision prompt — overrides mem0's default. +# qwen2.5:1.5b struggles with the default multi-step reasoning; this version is +# more explicit: list existing, list new, decide ADD/NONE per item. +UPDATE_PROMPT = """/no_think +You manage a memory store. Given EXISTING memories and NEW facts: +- For each EXISTING memory: output NONE (no change) or UPDATE (if a new fact replaces it) or DELETE. +- For each NEW fact: output ADD if it is not already covered by existing memories. Output NONE if it is already covered. +- IMPORTANT: You MUST include ALL new facts in your output — either as ADD or NONE. +- Output ONLY valid JSON, no explanation. + +Example A — new fact is genuinely new: +Existing: [{"id": "0", "text": "User lives in Berlin"}] +New facts: ["User is allergic to nuts"] +Output: {"memory": [{"id": "0", "text": "User lives in Berlin", "event": "NONE"}, {"id": "1", "text": "User is allergic to nuts", "event": "ADD"}]} + +Example B — new fact updates an existing one: +Existing: [{"id": "0", "text": "User lives in Berlin"}] +New facts: ["User lives in Paris"] +Output: {"memory": [{"id": "0", "text": "User lives in Paris", "event": "UPDATE", "old_memory": "User lives in Berlin"}]} + +Example C — new fact already covered: +Existing: [{"id": "0", "text": "User is allergic to nuts"}] +New facts: ["User has a nut allergy"] +Output: {"memory": [{"id": "0", "text": "User is allergic to nuts", "event": "NONE"}]}""" + config = { "llm": { "provider": "ollama", "config": { - "model": "qwen2.5:1.5b", - "ollama_base_url": OLLAMA_CPU_URL, + "model": "qwen3:4b", + "ollama_base_url": OLLAMA_GPU_URL, + "temperature": 0.1, # consistent JSON output }, }, "embedder": { "provider": "ollama", "config": { "model": "nomic-embed-text", - "ollama_base_url": OLLAMA_CPU_URL, + "ollama_base_url": OLLAMA_CPU_URL, # CPU: 50-150ms per query, no GPU needed }, }, "vector_store": { @@ -30,6 +115,8 @@ config = { "port": QDRANT_PORT, }, }, + "custom_fact_extraction_prompt": EXTRACTION_PROMPT, + "custom_update_memory_prompt": UPDATE_PROMPT, } memory = Memory.from_config(config) @@ -41,21 +128,27 @@ mcp = FastMCP("openmemory", host="0.0.0.0", port=8765) def add_memory(text: str, user_id: str = "default") -> str: """Store a memory for a user.""" result = memory.add(text, user_id=user_id) - return str(result) + # Change 3: return clean JSON instead of Python repr + return json.dumps(result, default=str) @mcp.tool() def search_memory(query: str, user_id: str = "default") -> str: """Search memories for a user using semantic similarity.""" - results = memory.search(query, user_id=user_id) - return str(results) + results = memory.search(query, user_id=user_id, limit=10, threshold=0.3) + # Filter to only return results with score >= 0.5 to avoid irrelevant noise + if isinstance(results, dict) and "results" in results: + results["results"] = [r for r in results["results"] if r.get("score", 0) >= 0.5] + return json.dumps(results, default=str) @mcp.tool() -def get_all_memories(user_id: str = "default") -> str: - """Get all stored memories for a user.""" - results = memory.get_all(user_id=user_id) - return str(results) +def get_all_memories(user_id: str = "default", limit: int = 50) -> str: + """Get stored memories for a user (up to limit).""" + # Change 5: cap results to avoid flooding context + results = memory.get_all(user_id=user_id, limit=limit) + # Change 3: return clean JSON instead of Python repr + return json.dumps(results, default=str) if __name__ == "__main__": diff --git a/adolf/reasoning.md b/adolf/reasoning.md new file mode 100644 index 0000000..414c26b --- /dev/null +++ b/adolf/reasoning.md @@ -0,0 +1,287 @@ +# Reasoning & Self-Reflection in Local LLM Agents + +Research-backed notes on implementing multi-stage reasoning for local 4-8B models (2025). + +--- + +## TL;DR + +For local 4-8B models, **programmatic self-critique loops rarely justify their cost**. +Native thinking tokens (Qwen3 `enable_thinking=True`) or external verifiers +give better results at lower complexity. See bottom of this file for recommendations. + +--- + +## Reasoning Patterns + +### Chain-of-Thought (CoT) + +Single forward pass, model thinks step-by-step before answering. +Zero implementation cost — just a prompt change. +Typical gain: +5-10pp on multi-step tasks vs no CoT. +No latency overhead beyond the extra output tokens. + +### Reflexion (Shinn et al., NeurIPS 2023) + +Multiple complete attempts. After each attempt, the model writes a textual critique +of what went wrong and stores it in episodic memory. Next attempt is conditioned on +that memory. + +``` +attempt 1 → fail → write critique → attempt 2 (reads critique) → ... +``` + +Key results (GPT-4): HumanEval 80% → 91% pass@1. +Cost: N complete task executions. At 30s/attempt, 5 trials = 2.5 minutes. +Implementation: https://github.com/noahshinn/reflexion + +### Reflection Loop (in-turn revision) + +Within a single turn: generate → critique → revise → [repeat]. +Simpler than Reflexion. More common in practice. + +``` +Generate → Critique → Revise → [stop condition] +``` + +Stop condition options: max iterations, score threshold, external verifier passes. + +### ReAct + Reflect + +Standard ReAct (Reason + Act) with an added Reflect step after failed tool calls. +Most common production pattern. Adds 1-3 extra LLM calls per failed action. + +### Tree of Thoughts (ToT) + +Explore N reasoning branches simultaneously, evaluate each node, BFS/DFS search. +Branching factor 3, depth 3 = 54 LLM calls per problem. Prohibitive for local models. +Works only if the model has strong self-evaluation capability (typically ≥32B). +ToTRL-trained Qwen3-8B achieved 0.633 on AIME 2025 — but required training-time RL, not +a prompt trick. + +### Graph of Thoughts (GoT) + +Generalizes ToT to arbitrary DAGs: thoughts can merge, split, or loop. +62% improvement in sorting vs ToT, 31% cost reduction. +Implementation: https://github.com/spcl/graph-of-thoughts +Higher complexity than ToT; graph structure is problem-specific. + +--- + +## Native Thinking Tokens (vs Programmatic Reflection) + +Open models with built-in reasoning scratchpads: + +| Model | Size | Ollama | Toggle | Notes | +|-------|------|--------|--------|-------| +| Qwen3 | 0.6B–235B | Yes | enable_thinking / think=True/False | Best option for local use | +| Qwen3-4B-Thinking-2507 | 4B | Yes | Always on | Dedicated thinking variant | +| QwQ-32B | 32B | Yes | Always on | Strong reasoning, needs VRAM | +| DeepSeek-R1 distills | 1.5B–70B | Yes | Always on | Llama/Qwen base | + +### Qwen3 thinking toggle in Ollama / LangChain + +```python +# LangChain +model = ChatOllama(model="qwen3:4b", think=True, num_ctx=8192) + +# Prompt-level (Ollama API) +# /think — enable per-request +# /no_think — disable per-request +``` + +Latency: thinking mode is 2-3x slower in wall-clock time (model generates internal +`...` tokens before answering). Qwen3-VL 8B Thinking: 262s vs 65s on a +complex visual reasoning task — but meaningfully better output. + +### Native thinking vs programmatic loop + +| | Native thinking | Programmatic multi-stage | +|--|----------------|------------------------| +| API calls | 1 | N (rounds × 2) | +| Implementation | Zero | Significant | +| Quality on 4-8B | Good (capability in weights) | Poor (weak model critiques itself) | +| Transparency | Opaque (one streamed block) | Inspectable per stage | +| Controllability | thinking_budget only | Full control | +| Latency | 2-3x tokens, 1 call | N × base latency | + +**For local 4-8B: native thinking almost always beats a hand-coded reflection loop.** + +--- + +## Does Programmatic Reflection Work on Small Models? + +Short answer: **mostly no without external verification**. + +From the research (2024-2025): + +- **"When Hindsight is Not 20/20" (arXiv 2404.09129)**: Self-reflection often makes + small models worse. A model that generated an error also lacks the capability to + identify it. It confidently accepts flawed reasoning on re-reading. + +- **THINKSLM (EMNLP 2025)**: Inference-time self-critique on Llama-3.1-8B is unreliable. + Training-time distilled reasoning traces help; prompt-based self-critique does not. + +- **Nature 2025 study**: Large gains (GPT-4: +18.5pp) diminish sharply for smaller models. + +- **Latency cost**: Each reflection round on a local 8B adds 5-30s. A 3-round loop + = 3x latency for 0-5% gain (or regression) on most tasks. + +### When it actually helps on small models + +1. **External verifier**: model doesn't self-evaluate — it reads objective pass/fail + feedback (unit tests, JSON schema checker, math verifier, search result grader). + Most reliable pattern. No self-evaluation capability required. + +2. **Stronger critic**: generate with 4B, critique with 32B or API model. Hybrid approach. + +3. **Native thinking weights**: reflection happens in a single forward pass with + trained weights. Far more reliable than prompt-based self-critique. + +4. **Structured error types**: code syntax, JSON validity, regex match — computable + error signal, not linguistic self-assessment. + +--- + +## LangGraph Reflection Loop Implementation + +LangGraph is suited for this because it supports cyclic graphs with state. + +### Minimal reflection graph + +```python +from langgraph.graph import StateGraph, START, END, MessagesState +from langchain_ollama import ChatOllama + +llm = ChatOllama(model="qwen3:4b", think=False) +critic_llm = ChatOllama(model="qwen3:4b", think=True) # or stronger model + +MAX_REFLECTIONS = 2 + +def generate(state): + response = llm.invoke(state["messages"]) + return {"messages": [response], "iterations": state.get("iterations", 0)} + +def reflect(state): + critique = critic_llm.invoke( + [{"role": "system", "content": "Critique this response. Be specific about errors."}] + + state["messages"] + ) + return { + "messages": [{"role": "user", "content": critique.content}], + "iterations": state["iterations"] + 1, + } + +def should_reflect(state) -> str: + if state.get("iterations", 0) >= MAX_REFLECTIONS: + return END + # Optionally: check external verifier here + return "reflect" + +graph = StateGraph(MessagesState) +graph.add_node("generate", generate) +graph.add_node("reflect", reflect) +graph.add_edge(START, "generate") +graph.add_conditional_edges("generate", should_reflect) +graph.add_edge("reflect", "generate") +agent = graph.compile() +``` + +### Self-Correcting RAG (CRAG pattern) + +``` +Retrieve → Grade documents → [rewrite query if bad] → Generate → Grade answer → [loop or END] +``` + +The document grader and answer grader are the "external verifiers" — they do +objective quality checks rather than linguistic self-critique. +LangChain tutorial: https://learnopencv.com/langgraph-self-correcting-agent-code-generation/ + +--- + +## Alternative Tooling + +### DSPy (recommended for pipeline optimization) + +DSPy treats prompts as learnable parameters. Define input/output signatures, run an +optimizer on examples, and DSPy auto-tunes prompts for your specific model. + +```python +import dspy +lm = dspy.LM('ollama_chat/qwen3:4b', api_base='http://localhost:11434', api_key='') +dspy.configure(lm=lm) + +class Reflect(dspy.Module): + def __init__(self): + self.gen = dspy.ChainOfThought("question -> answer") + self.critique = dspy.ChainOfThought("question, answer -> critique, improved_answer") + def forward(self, question): + first = self.gen(question=question) + return self.critique(question=question, answer=first.answer).improved_answer +``` + +Works with Ollama. Optimizer (BootstrapFewShot, MIPRO) tunes prompts automatically +but requires multiple LLM calls per training example — slow on local hardware. + +### Outlines (structured output) + +Constrained decoding — guarantees valid JSON/regex output from any model. +Use this inside a reflection loop to ensure the critic always returns structured feedback. +Works with Ollama via OpenAI-compatible API. +https://dottxt-ai.github.io/outlines/ + +### SGLang + +High-performance GPU serving runtime (replaces Ollama for GPU inference). +Natively understands `...` tokens, caches KV-prefix across reflection +rounds (RadixAttention). If you replace Ollama with SGLang: reflection loops become +significantly cheaper because repeated prompt prefixes are cache-hit. +https://github.com/sgl-project/sglang + +--- + +## Benchmarks Summary + +| Setup | Task | Quality Gain | Latency Cost | +|-------|------|-------------|-------------| +| GPT-4 + Reflexion | HumanEval | +11pp (80→91%) | ~5x | +| GPT-4 + reflection | Problem solving | +18.5pp | ~3x | +| Llama-7B + programmatic self-critique | Math | +7.1% | ~3x | +| Local 8B + same-model critique (typical) | General | 0-5% (often regression) | 2-3x | +| Qwen3-8B + native thinking | AIME 2025 | Matches models 10x larger | 2-3x tokens | +| Any model + external verifier (tests) | Code | +15-26pp | 1.5-2x | + +--- + +## Practical Recommendations for Adolf (local qwen3:4b / 8b) + +| Goal | Approach | Cost | +|------|----------|------| +| Better reasoning on hard questions | `think=True` in ChatOllama | 2-3x latency, zero code | +| Code/JSON correctness | External verifier (schema check, exec) + retry loop | +1 LLM call on failure | +| Complex multi-step tasks | Route to qwen3:8b with `think=True` | model swap + 2-3x tokens | +| Full reflection loop | Only if using stronger critic model or external verifier | significant complexity | +| Avoid | Programmatic self-critique using same 4-8B model as critic | adds latency, no gain | + +--- + +## References + +- Reflexion (Shinn et al., NeurIPS 2023): https://arxiv.org/abs/2303.11366 +- Tree of Thoughts: https://arxiv.org/abs/2305.10601 +- ToTRL (Qwen3 RL training): https://arxiv.org/html/2505.12717v1 +- Graph of Thoughts: https://arxiv.org/abs/2308.09687 +- Adaptive GoT (2025): https://arxiv.org/pdf/2502.05078 +- When Hindsight is Not 20/20: https://arxiv.org/html/2404.09129v1 +- THINKSLM (EMNLP 2025): https://aclanthology.org/2025.emnlp-main.1659.pdf +- MAR — Multi-Agent Reflexion: https://arxiv.org/html/2512.20845 +- Qwen3 technical report: https://arxiv.org/pdf/2505.09388 +- Qwen3 thinking cost measurement: https://medium.com/@frankmorales_91352/the-computational-cost-of-cognitive-depth-qwen3-vl-8b-instruct-vs-thinking-2517b677ba29 +- DeepSeek-R1: https://arxiv.org/abs/2501.12948 +- LangChain reflection blog: https://blog.langchain.com/reflection-agents/ +- LangGraph CRAG: https://learnopencv.com/langgraph-self-correcting-agent-code-generation/ +- DSPy: https://dspy.ai/ +- Outlines: https://dottxt-ai.github.io/outlines/ +- SGLang: https://github.com/sgl-project/sglang +- graph-of-thoughts: https://github.com/spcl/graph-of-thoughts +- reflexion (original code): https://github.com/noahshinn/reflexion diff --git a/adolf/router.py b/adolf/router.py index 31bce20..85b0012 100644 --- a/adolf/router.py +++ b/adolf/router.py @@ -32,6 +32,8 @@ LIGHT = answerable from general knowledge, no internet needed: MEDIUM = requires web search or the user's stored memories: current weather / today's news / Bitcoin price / what did we talk about + what is my name / where do I live / what is my job / do I have any pets + what do you know about me / what are my preferences / what did I tell you COMPLEX = /think prefix only: /think compare frameworks / /think plan a trip diff --git a/adolf/test_pipeline.py b/adolf/test_pipeline.py index c696a41..034720d 100644 --- a/adolf/test_pipeline.py +++ b/adolf/test_pipeline.py @@ -13,16 +13,19 @@ Tests: 8. Name recall — "what is your name?" → reply contains 9. Timing profile + bottleneck report 10. Easy benchmark — 10 easy questions → all must route to light - 11. Medium benchmark — 10 medium questions → must route to medium (or light, never complex) + 11. Medium benchmark — 11 medium questions → must route to medium (or light, never complex) 12. Hard benchmark — 10 /think questions → all must route to complex; VRAM flush verified + 13. Memory benchmark — store 5 facts, recall with 10 questions → verify keyword presence + 14. Dedup test — same fact sent twice → Qdrant must not grow by 2 Usage: python3 test_pipeline.py [--chat-id CHAT_ID] - [--bench-only] skip sections 1-9, run 10+11+12 - [--easy-only] skip 1-9 and 11+12, run only section 10 - [--medium-only] skip 1-9 and 10+12, run only section 11 - [--hard-only] skip 1-9 and 10+11, run only section 12 - [--no-bench] skip sections 10-12 + [--bench-only] skip sections 1-9, run 10+11+12+13 + [--easy-only] skip 1-9 and 11+12+13, run only section 10 + [--medium-only] skip 1-9 and 10+12+13, run only section 11 + [--hard-only] skip 1-9 and 10+11+13, run only section 12 + [--memory-only] skip 1-9 and 10+11+12, run only section 13 + [--no-bench] skip sections 10-13 Timing is extracted from deepagents container logs, not estimated from sleeps. """ @@ -79,6 +82,7 @@ BENCHMARK = { "do you remember what we talked about before?", "search for the best coffee shops in Tokyo", "what is happening in the tech industry this week?", + "what's the weather like today?", ], "hard": [ "/think compare the top 3 Python web frameworks (Django, FastAPI, Flask) and recommend one for a production REST API", @@ -187,18 +191,13 @@ def parse_run_block(lines, msg_prefix): reply_data = None for j, line in enumerate(block): - # Track last non-tool AIMessage (the final reply) + # Track last non-tool AIMessage (the final reply) — truncated at 150 chars in logs, + # used only as fallback if reply_text line is absent (older server versions) if "AIMessage:" in line and "→" not in line: txt = line.split("AIMessage:", 1)[-1].strip() if txt: last_ai_text = txt - # For light tier: router reply is stored in _conversation_buffers directly - # so there may be no AIMessage log — grab from tier=light line - if "[agent] tier=light" in line and "message=" in line: - # Extract preview text logged elsewhere if available - pass - m = re.search(r"replied in ([\d.]+)s \(llm=([\d.]+)s, send=([\d.]+)s\)", line) if m: # Extract optional tier tag at end of line @@ -209,13 +208,21 @@ def parse_run_block(lines, msg_prefix): "llm": float(m.group(2)), "send": float(m.group(3)), "tier": tier, - "reply_text": last_ai_text, + "reply_text": last_ai_text, # may be overwritten by reply_text line below "memory_s": None, "memory_error": False, "_j": j, } break + # Read full reply_text from dedicated log line (written immediately after replied-in line) + if reply_data is not None: + next_lines = block[reply_data["_j"] + 1: reply_data["_j"] + 3] + for line in next_lines: + if line.startswith("[agent] reply_text:"): + reply_data["reply_text"] = line[len("[agent] reply_text:"):].strip() + break + if reply_data is None: return None # reply not in logs yet @@ -281,16 +288,19 @@ parser.add_argument("--medium-only", action="store_true", help="Skip sections 1-9 and 10, run only section 11 (medium benchmark)") parser.add_argument("--hard-only", action="store_true", help="Skip sections 1-9 and 10+11, run only section 12 (hard benchmark)") +parser.add_argument("--memory-only", action="store_true", + help="Skip sections 1-9 and 10+11+12, run only section 13 (memory benchmark)") parser.add_argument("--no-bench", action="store_true", - help="Skip sections 10-12 (all benchmarks)") + help="Skip sections 10-13 (all benchmarks)") args = parser.parse_args() CHAT_ID = args.chat_id # Derived flags for readability -_skip_pipeline = args.bench_only or args.easy_only or args.medium_only or args.hard_only -_run_easy = not args.no_bench and not args.medium_only and not args.hard_only -_run_medium = not args.no_bench and not args.easy_only and not args.hard_only -_run_hard = not args.no_bench and not args.easy_only and not args.medium_only +_skip_pipeline = args.bench_only or args.easy_only or args.medium_only or args.hard_only or args.memory_only +_run_easy = not args.no_bench and not args.medium_only and not args.hard_only and not args.memory_only +_run_medium = not args.no_bench and not args.easy_only and not args.hard_only and not args.memory_only +_run_hard = not args.no_bench and not args.easy_only and not args.medium_only and not args.memory_only +_run_memory = not args.no_bench and not args.easy_only and not args.medium_only and not args.hard_only random_name = random.choice(NAMES) @@ -880,6 +890,263 @@ if _run_hard: ) +# ── 13. Memory benchmark — store facts, recall with keyword verification ─────── +if _run_memory: + _mem_name = random.choice([ + "Alice", "Bruno", "Camille", "Diego", "Elena", + "Farid", "Greta", "Hiroshi", "Irina", "Jonas", + ]) + _mem_city = random.choice([ + "Tokyo", "Berlin", "Cairo", "Sydney", "Oslo", + "Nairobi", "Lisbon", "Seoul", "Montreal", "Bangkok", + ]) + _mem_allergy = random.choice(["nuts", "gluten", "dairy", "shellfish", "eggs"]) + _mem_job = random.choice([ + ("software engineer", "startup"), + ("data scientist", "research lab"), + ("product manager", "tech company"), + ("DevOps engineer", "cloud provider"), + ]) + _mem_lang = random.choice(["Python", "Rust", "Go", "TypeScript", "Kotlin"]) + _mem_pet_name = random.choice([ + "Whiskers", "Biscuit", "Mango", "Pebble", "Shadow", + "Noodle", "Cheddar", "Cosmo", "Pippin", "Ziggy", + ]) + + print(f"\n[{INFO}] 13. Memory benchmark") + print(f" name={_mem_name} city={_mem_city} allergy={_mem_allergy} " + f"job={_mem_job[0]}@{_mem_job[1]} lang={_mem_lang} pet={_mem_pet_name}") + print(f" Storing 5 facts, then querying with 10 recall questions") + print(f" Chat ID: {CHAT_ID}") + print() + + # Wipe Qdrant collection and restart openmemory to eliminate stale data interference. + # Deleting the collection alone causes 404s — openmemory holds a live reference to it. + try: + import urllib.request as _ur + _req = _ur.Request(f"{QDRANT}/collections/adolf_memories", method="DELETE") + with _ur.urlopen(_req, timeout=5): + pass + print(f" [{INFO}] Wiped adolf_memories collection") + except Exception as e: + print(f" [{WARN}] Could not wipe collection: {e}") + + try: + subprocess.run( + ["docker", "compose", "-f", COMPOSE_FILE, "restart", "openmemory"], + capture_output=True, timeout=30, + ) + time.sleep(6) # wait for openmemory to reinitialize and recreate collection + print(f" [{INFO}] Restarted openmemory — fresh collection ready") + except Exception as e: + print(f" [{WARN}] Could not restart openmemory: {e}") + + MEMORY_FACTS = [ + f"My name is {_mem_name} and I live in {_mem_city}", + f"I prefer vegetarian food and I'm allergic to {_mem_allergy}", + f"I work as a {_mem_job[0]} at a {_mem_job[1]}", + f"My favorite programming language is {_mem_lang}", + f"I have a cat named {_mem_pet_name}", + ] + + MEMORY_RECALLS = [ + # (question, [keywords that must appear in reply]) + ("What is my name?", [_mem_name.lower()]), + ("Where do I live?", [_mem_city.lower()]), + ("Do I have any food allergies?", [_mem_allergy.lower()]), + ("What is my job?", [_mem_job[0].split()[0].lower()]), + ("What programming language do I prefer?", [_mem_lang.lower()]), + ("Do I have any pets?", [_mem_pet_name.lower()]), + ("Am I vegetarian or do I eat meat?", ["vegetarian"]), + ("What city am I in?", [_mem_city.lower()]), + ("Tell me what you know about me", [_mem_name.lower(), _mem_city.lower()]), + ("What's the name of my pet?", [_mem_pet_name.lower()]), + ] + + MEMORY_STORE_TIMEOUT = 180 # seconds per fact + MEMORY_RECALL_TIMEOUT = 180 # seconds per question + + # ── Store facts ────────────────────────────────────────────────────────── + print(f" Storing {len(MEMORY_FACTS)} facts...") + store_ok = 0 + for i, fact in enumerate(MEMORY_FACTS, 1): + print(f" [mem-store-{i:02d}] {fact!r}") + try: + status, _ = post_json(f"{DEEPAGENTS}/chat", + {"message": fact, "chat_id": CHAT_ID}, timeout=5) + if status != 202: + print(f" → [{FAIL}] POST returned {status}") + continue + except Exception as e: + print(f" → [{FAIL}] POST error: {e}") + continue + + found = wait_for(f"mem-store-{i:02d}", fact, timeout_s=MEMORY_STORE_TIMEOUT, need_memory=True) + if found: + store_ok += 1 + print(f" → [{PASS}] stored tier={found['tier']} mem={found['memory_s']}s") + else: + print(f" → [{FAIL}] timeout") + + report(f"All memory facts stored ({store_ok}/{len(MEMORY_FACTS)})", + store_ok == len(MEMORY_FACTS)) + + # Wait for async memory extraction to settle — poll Qdrant until point count stabilises + print(f"\n Waiting for memory extraction to settle (up to 60s)...") + _prev_count = -1 + _stable_ticks = 0 + for _ in range(30): + time.sleep(2) + try: + _, body = get(f"{QDRANT}/collections/adolf_memories") + _cur_count = json.loads(body).get("result", {}).get("points_count", 0) + except Exception: + _cur_count = _prev_count + if _cur_count == _prev_count: + _stable_ticks += 1 + if _stable_ticks >= 3: # stable for 6s + break + else: + _stable_ticks = 0 + _prev_count = _cur_count + print(f" Memory settled: {_cur_count} points in Qdrant") + + # ── Recall questions ───────────────────────────────────────────────────── + print(f"\n Querying with {len(MEMORY_RECALLS)} recall questions...") + recall_results = [] # (question, keywords, reply_text, passed) + + for i, (question, keywords) in enumerate(MEMORY_RECALLS, 1): + print(f" [mem-recall-{i:02d}] {question!r}") + + try: + status, _ = post_json(f"{DEEPAGENTS}/chat", + {"message": question, "chat_id": CHAT_ID}, timeout=5) + if status != 202: + print(f" → [{FAIL}] POST returned {status}") + recall_results.append((question, keywords, None, False)) + continue + except Exception as e: + print(f" → [{FAIL}] POST error: {e}") + recall_results.append((question, keywords, None, False)) + continue + + t_start = time.monotonic() + found = None + while time.monotonic() - t_start < MEMORY_RECALL_TIMEOUT: + since = int(time.monotonic() - t_start) + 30 + lines = fetch_logs(since_s=since) + found = parse_run_block(lines, question) + if found: + break + time.sleep(2) + + if not found: + print(f" → [{FAIL}] timeout") + recall_results.append((question, keywords, None, False)) + continue + + reply_text = (found.get("reply_text") or "").lower() + hit_keywords = [kw for kw in keywords if kw.lower() in reply_text] + passed = len(hit_keywords) == len(keywords) + tag_str = PASS if passed else WARN + missing = [kw for kw in keywords if kw.lower() not in reply_text] + detail = f"tier={found['tier']} lat={found['reply_total']:.1f}s" + if missing: + detail += f" missing keywords: {missing}" + print(f" → [{tag_str}] {detail}") + recall_results.append((question, keywords, found.get("reply_text"), passed)) + + time.sleep(1) + + # Summary + print(f"\n {'#':<4} {'Pass':<5} {'Question':<45} {'Keywords'}") + print(f" {'─'*4} {'─'*5} {'─'*45} {'─'*30}") + for idx, (q, kws, reply, ok) in enumerate(recall_results, 1): + ok_str = "✓" if ok else "✗" + print(f" {ok_str} {idx:<3} {'yes' if ok else 'no':<5} {q[:45]:<45} {kws}") + + recall_pass = sum(1 for _, _, _, ok in recall_results if ok) + total_recall = len(recall_results) + print(f"\n Memory recall score: {recall_pass}/{total_recall}") + + report(f"Memory recall ({recall_pass}/{total_recall} keywords found)", + recall_pass == total_recall, + f"{recall_pass}/{total_recall} questions had all expected keywords in reply") + + +# ── 14. Deduplication test — same fact stored twice must not grow Qdrant by 2 ─ +if _run_memory: + print(f"\n[{INFO}] 14. Memory deduplication test") + print(f" Sends the same fact twice — Qdrant point count must not increase by 2") + print(f" Chat ID: {CHAT_ID}") + print() + + DEDUP_TIMEOUT = 120 + + _dedup_fact = f"My lucky number is {random.randint(1000, 9999)}" + print(f" Fact: {_dedup_fact!r}") + + def _qdrant_count_dedup(): + try: + _, body = get(f"{QDRANT}/collections/adolf_memories") + return json.loads(body).get("result", {}).get("points_count", 0) + except Exception: + return 0 + + pts_before = _qdrant_count_dedup() + print(f" Qdrant points before: {pts_before}") + + # Send fact the first time + print(f" [dedup-1] sending fact (first time)") + try: + status, _ = post_json(f"{DEEPAGENTS}/chat", + {"message": _dedup_fact, "chat_id": CHAT_ID}, timeout=5) + if status != 202: + report("Dedup: first POST accepted", False, f"status={status}") + else: + found1 = wait_for("dedup-1", _dedup_fact, timeout_s=DEDUP_TIMEOUT, need_memory=True) + if found1: + print(f" [dedup-1] stored tier={found1['tier']} mem={found1['memory_s']}s") + else: + print(f" [dedup-1] timeout") + except Exception as e: + report("Dedup: first POST accepted", False, str(e)) + found1 = None + + pts_after_first = _qdrant_count_dedup() + new_first = pts_after_first - pts_before + print(f" Qdrant after first send: {pts_before} → {pts_after_first} (+{new_first})") + + # Send exact same fact again + print(f" [dedup-2] sending same fact (second time)") + try: + status, _ = post_json(f"{DEEPAGENTS}/chat", + {"message": _dedup_fact, "chat_id": CHAT_ID}, timeout=5) + if status != 202: + report("Dedup: second POST accepted", False, f"status={status}") + else: + found2 = wait_for("dedup-2", _dedup_fact, timeout_s=DEDUP_TIMEOUT, need_memory=True) + if found2: + print(f" [dedup-2] stored tier={found2['tier']} mem={found2['memory_s']}s") + else: + print(f" [dedup-2] timeout") + except Exception as e: + report("Dedup: second POST accepted", False, str(e)) + + pts_after_second = _qdrant_count_dedup() + new_second = pts_after_second - pts_after_first + print(f" Qdrant after second send: {pts_after_first} → {pts_after_second} (+{new_second})") + + # Pass: second store added no MORE points than the first (NOOP or UPDATE, not ADD) + # If first send stored 0 points (fact too trivial), dedup is vacuously satisfied. + dedup_ok = new_second <= new_first + report( + "Deduplication: second identical fact not added to Qdrant", + dedup_ok, + f"first send: +{new_first} pts, second send: +{new_second} pts (want second ≤ first)", + ) + + # ── summary ─────────────────────────────────────────────────────────────────── print(f"\n{'─'*55}") total = len(results) diff --git a/adolf/wiki_research.py b/adolf/wiki_research.py new file mode 100644 index 0000000..f2e2def --- /dev/null +++ b/adolf/wiki_research.py @@ -0,0 +1,278 @@ +#!/usr/bin/env python3 +""" +Wiki Research Pipeline — searches the web for each person/place in the family wiki. + +Uses Adolf's complex agent (/think prefix → qwen3:8b + web_search) to research +each subject and aggregates findings into research.md. + +Usage: + python3 wiki_research.py [--subject "Name"] [--dry-run] [--timeout 300] + [--output PATH] +""" + +import argparse +import json +import re +import sys +import time +import urllib.parse +import urllib.request +from datetime import datetime +from pathlib import Path + +# ── config ───────────────────────────────────────────────────────────────────── +GATEWAY = "http://localhost:8000" +WIKI_ROOT = Path("/mnt/ssd/dbs/otter/app-data/repository") +DEFAULT_OUTPUT = WIKI_ROOT / "research.md" + +PASS = "\033[32mPASS\033[0m" +FAIL = "\033[31mFAIL\033[0m" +INFO = "\033[36mINFO\033[0m" + + +# ── helpers ──────────────────────────────────────────────────────────────────── + +def post_message(text: str, session_id: str, timeout: int = 10) -> int: + payload = json.dumps({ + "text": text, + "session_id": session_id, + "channel": "cli", + "user_id": "wiki-pipeline", + }).encode() + req = urllib.request.Request( + f"{GATEWAY}/message", + data=payload, + headers={"Content-Type": "application/json"}, + method="POST", + ) + with urllib.request.urlopen(req, timeout=timeout) as r: + return r.status + + +def wait_for_reply(label: str, session_id: str, timeout_s: int = 300) -> str | None: + """Open SSE stream on /reply/{session_id} and return reply text, or None on timeout.""" + req = urllib.request.Request( + f"{GATEWAY}/reply/{urllib.parse.quote(session_id, safe='')}", + headers={"Accept": "text/event-stream"}, + ) + t0 = time.monotonic() + tick = 0 + deadline = t0 + timeout_s + + # Show progress while waiting (SSE blocks until reply is ready) + print(f"\r [{label}] waiting... ", end="", flush=True) + + try: + with urllib.request.urlopen(req, timeout=timeout_s + 30) as r: + for raw_line in r: + elapsed = time.monotonic() - t0 + line = raw_line.decode("utf-8").rstrip("\n") + if line.startswith("data:"): + text = line[5:].strip().replace("\\n", "\n") + print(f"\r [{label}] done after {elapsed:.0f}s{' ' * 30}") + if text == "[timeout]": + return None + return text + tick += 1 + rem = int(deadline - time.monotonic()) + print(f"\r [{label}] {elapsed:.0f}s elapsed, {rem}s left — waiting... ", + end="", flush=True) + except Exception as e: + print(f"\r [{label}] SSE error: {e}{' ' * 30}") + + print(f"\r [{label}] TIMEOUT after {timeout_s}s{' ' * 30}") + return None + + +# ── wiki parsing ─────────────────────────────────────────────────────────────── + +def slugify(name: str) -> str: + s = name.lower() + s = re.sub(r"[^\w\s-]", "", s) + s = re.sub(r"\s+", "-", s.strip()) + return s[:60] + + +def parse_wiki_file(path: Path): + try: + text = path.read_text(encoding="utf-8") + except Exception: + return None + + lines = text.splitlines() + name = None + context_parts = [] + + for line in lines[:50]: + stripped = line.strip() + if not name and stripped.startswith("# "): + name = stripped[2:].strip() + continue + if name: + if stripped.startswith("[![") or stripped.startswith("!["): + continue + if stripped: + context_parts.append(stripped) + if len(context_parts) >= 20: + break + + if not name: + return None + return name, "\n".join(context_parts) + + +def discover_subjects(wiki_root: Path): + subjects = [] + for subdir in ["люди", "места"]: + folder = wiki_root / subdir + if not folder.exists(): + continue + for md_file in sorted(folder.glob("*.md")): + result = parse_wiki_file(md_file) + if result: + name, context = result + subjects.append((name, context, subdir)) + return subjects + + +# ── output ───────────────────────────────────────────────────────────────────── + +def load_existing_names(output_path: Path) -> set: + if not output_path.exists(): + return set() + return set(re.findall(r"^## (.+)$", output_path.read_text(encoding="utf-8"), re.MULTILINE)) + + +def init_output(output_path: Path, total: int): + if not output_path.exists(): + output_path.write_text( + f"# Wiki Research Results\n\n" + f"Generated: {datetime.now().strftime('%Y-%m-%d %H:%M')}\n" + f"Subjects: {total}\n\n---\n\n", + encoding="utf-8", + ) + + +def append_result(output_path: Path, name: str, elapsed: float, reply_text: str): + date_str = datetime.now().strftime("%Y-%m-%d") + block = ( + f"## {name}\n\n" + f"**Searched**: {date_str} **Elapsed**: {elapsed:.0f}s\n\n" + f"{reply_text or '_No reply captured._'}\n\n---\n\n" + ) + with open(output_path, "a", encoding="utf-8") as f: + f.write(block) + + +# ── research prompt ──────────────────────────────────────────────────────────── + +def build_prompt(name: str, context: str, subdir: str) -> str: + kind = "person" if subdir == "люди" else "place" + return ( + f"/think You are researching a {kind} for a private family wiki. " + f"Find everything publicly available. Be thorough and specific.\n\n" + f"**Subject**: {name}\n" + f"**Known context** (from the family wiki — do NOT just repeat this):\n{context}\n\n" + f"**Research instructions** (MUST follow exactly):\n" + f"1. Call web_search, then IMMEDIATELY call fetch_url on every URL found in results.\n" + f"2. You MUST call fetch_url at least 5 times — do not write the report until you have.\n" + f"3. Priority URLs to fetch: Google Scholar profile, ResearchGate, IEEE Xplore, LinkedIn, employer page.\n" + f"4. Run searches in English AND Russian/Latvian.\n" + f"5. After fetching pages, derive follow-up searches from what you find.\n\n" + f"**Output format** (required):\n" + f"- Use markdown with sections: Overview, Education, Career, Publications, " + f"Online Presence, Interesting Findings, Not Found\n" + f"- Every fact must have a source link: [fact](url)\n" + f"- Include actual URLs to profiles, papers, articles found\n" + f"- 'Interesting Findings': non-trivial facts not in the wiki context above\n" + f"- Last line must be: **Sources checked: N** (count of URLs you fetched with fetch_url)\n\n" + f'If truly nothing is found publicly, say "No public information found." ' + f"but only after exhausting all search angles." + ) + + +# ── main ─────────────────────────────────────────────────────────────────────── + +def main(): + parser = argparse.ArgumentParser(description="Wiki research pipeline") + parser.add_argument("--subject", help="Single subject (substring match)") + parser.add_argument("--dry-run", action="store_true", help="Print prompts, don't send") + parser.add_argument("--timeout", type=int, default=300, help="Per-subject timeout (s)") + parser.add_argument("--output", type=Path, default=DEFAULT_OUTPUT, help="Output file") + args = parser.parse_args() + + subjects = discover_subjects(WIKI_ROOT) + if not subjects: + print(f"[{FAIL}] No subjects found in {WIKI_ROOT}") + sys.exit(1) + + print(f"[{INFO}] Discovered {len(subjects)} subjects") + + if args.subject: + needle = args.subject.lower() + subjects = [(n, c, s) for n, c, s in subjects if needle in n.lower()] + if not subjects: + print(f"[{FAIL}] No subject matching '{args.subject}'") + sys.exit(1) + print(f"[{INFO}] Filtered to {len(subjects)} subject(s)") + + if args.dry_run: + for name, context, subdir in subjects: + print(f"\n{'='*60}\nSUBJECT: {name} ({subdir})") + print(f"PROMPT:\n{build_prompt(name, context, subdir)}") + return + + init_output(args.output, len(subjects)) + existing = load_existing_names(args.output) + print(f"[{INFO}] Output: {args.output} ({len(existing)} already done)") + + total = len(subjects) + done = 0 + failed = [] + + for idx, (name, context, subdir) in enumerate(subjects, 1): + if name in existing: + print(f"[{idx}/{total}] SKIP {name} (already in output)") + done += 1 + continue + + prompt = build_prompt(name, context, subdir) + session_id = f"wiki-{slugify(name)}" + label = f"{idx}/{total}" + + print(f"\n[{label}] {name}") + + try: + status = post_message(prompt, session_id, timeout=10) + if status != 202: + print(f" [{FAIL}] Unexpected status {status}") + failed.append(name) + continue + except Exception as e: + print(f" [{FAIL}] POST failed: {e}") + failed.append(name) + continue + + t0 = time.monotonic() + reply_text = wait_for_reply(label, session_id, timeout_s=args.timeout) + elapsed = time.monotonic() - t0 + + if reply_text is None: + print(f" [{FAIL}] Timeout") + failed.append(name) + append_result(args.output, name, elapsed, "_Research timed out._") + continue + + print(f" [{PASS}] {elapsed:.0f}s — {len(reply_text)} chars") + append_result(args.output, name, elapsed, reply_text) + done += 1 + + print(f"\n{'='*60}") + print(f"Done: {done}/{total}") + if failed: + print(f"Failed ({len(failed)}): {', '.join(failed)}") + print(f"Output: {args.output}") + + +if __name__ == "__main__": + main() diff --git a/haos/CLAUDE.md b/haos/CLAUDE.md new file mode 100644 index 0000000..f7513eb --- /dev/null +++ b/haos/CLAUDE.md @@ -0,0 +1,191 @@ +# Home Assistant REST API + +## Connection + +- **Base URL**: `http://:8123/api/` +- **Auth header**: `Authorization: Bearer ` +- **Token**: Generate at `http://:8123/profile` → Long-Lived Access Tokens +- **Response format**: JSON (except `/api/error_log` which is plaintext) + +Store token in env var, never hardcode: +```bash +export HA_TOKEN="your_token_here" +export HA_URL="http://:8123" +``` + +## Status Codes + +| Code | Meaning | +|------|---------| +| 200 | Success (existing resource) | +| 201 | Created (new resource) | +| 400 | Bad request | +| 401 | Unauthorized | +| 404 | Not found | +| 405 | Method not allowed | + +## GET Endpoints + +```bash +# Health check +GET /api/ + +# Current HA configuration +GET /api/config + +# Loaded components +GET /api/components + +# All entity states +GET /api/states + +# Specific entity state +GET /api/states/ + +# Available services +GET /api/services + +# Available events +GET /api/events + +# Error log (plaintext) +GET /api/error_log + +# Camera image +GET /api/camera_proxy/ + +# All calendar entities +GET /api/calendars + +# Calendar events (start and end are required ISO timestamps) +GET /api/calendars/?start=&end= + +# Historical state changes +GET /api/history/period/?filter_entity_id= +# Optional params: end_time, minimal_response, no_attributes, significant_changes_only + +# Logbook entries +GET /api/logbook/ +# Optional params: entity=, end_time= +``` + +## POST Endpoints + +```bash +# Create or update entity state (virtual, not device) +POST /api/states/ +{"state": "on", "attributes": {"brightness": 255}} + +# Fire an event +POST /api/events/ +{"optional": "event_data"} + +# Call a service +POST /api/services// +{"entity_id": "light.living_room"} + +# Call service and get its response +POST /api/services//?return_response +{"entity_id": "..."} + +# Render a Jinja2 template +POST /api/template +{"template": "{{ states('sensor.temperature') }}"} + +# Validate configuration +POST /api/config/core/check_config + +# Handle an intent +POST /api/intent/handle +{"name": "HassTurnOn", "data": {"name": "lights"}} +``` + +## DELETE Endpoints + +```bash +# Remove an entity +DELETE /api/states/ +``` + +## Example curl Usage + +```bash +# Health check +curl -s -H "Authorization: Bearer $HA_TOKEN" $HA_URL/api/ + +# Get all states +curl -s -H "Authorization: Bearer $HA_TOKEN" $HA_URL/api/states | jq . + +# Get specific entity +curl -s -H "Authorization: Bearer $HA_TOKEN" $HA_URL/api/states/light.living_room + +# Turn on a light +curl -s -X POST \ + -H "Authorization: Bearer $HA_TOKEN" \ + -H "Content-Type: application/json" \ + -d '{"entity_id": "light.living_room"}' \ + $HA_URL/api/services/light/turn_on + +# Render template +curl -s -X POST \ + -H "Authorization: Bearer $HA_TOKEN" \ + -H "Content-Type: application/json" \ + -d '{"template": "{{ states(\"sensor.temperature\") }}"}' \ + $HA_URL/api/template +``` + +## Devices + +### Lights +4x Zigbee Tuya lights (TZ3210 TS0505B): +- `light.tz3210_r5afgmkl_ts0505b` (G2) +- `light.tz3210_r5afgmkl_ts0505b_g2` (G22) +- `light.tz3210_r5afgmkl_ts0505b_2` +- `light.tz3210_r5afgmkl_ts0505b_3` + +Support: color_temp (2000-6535K), xy color mode, brightness (0-254) + +### Vacuum Cleaner +**Entity**: `vacuum.xiaomi_ru_1173505785_ov71gl` (Петя Петя) +**Status**: Docked +**Type**: Xiaomi robot vacuum with mop + +**Rooms** (from `sensor.xiaomi_ru_1173505785_ov71gl_room_information_p_2_16`): +- ID 4: Спальня (Bedroom) +- ID 3: Гостиная (Living Room) +- ID 5: Кухня (Kitchen) +- ID 6: Прихожая (Hallway) +- ID 7: Ванная комната (Bathroom) + +**Services**: +- `vacuum.start` — Start cleaning +- `vacuum.pause` — Pause +- `vacuum.stop` — Stop +- `vacuum.return_to_base` — Dock +- `vacuum.clean_spot` — Clean spot +- `vacuum.set_fan_speed` — Set fan (param: `fan_speed`) +- `vacuum.send_command` — Raw command (params: `command`, `params`) +- Room-aware: `start_vacuum_room_sweep`, `start_zone_sweep`, `get_room_configs`, `set_room_clean_configs` + +**Key attributes**: +- `sensor.xiaomi_ru_1173505785_ov71gl_room_information_p_2_16` — Room data (JSON) +- `sensor.xiaomi_ru_1173505785_ov71gl_zone_ids_p_2_12` — Zone IDs +- `button.xiaomi_ru_1173505785_ov71gl_auto_room_partition_a_10_5` — Auto-detect room boundaries + +### Water Leak Sensors +3x HOBEIAN ZG-222Z Zigbee moisture sensors: +- `binary_sensor.hobeian_zg_222z` — Kitchen +- `binary_sensor.hobeian_zg_222z_2` — Bathroom +- `binary_sensor.hobeian_zg_222z_3` — Laundry + +Battery sensors: `sensor.hobeian_zg_222z_battery`, `_2`, `_3` + +**Automations** (push to Zabbix via `rest_command`): +- "Water Leak Alert" (`water_leak_alert`) — any sensor ON → `rest_command.zabbix_water_leak` with room name +- "Water Leak Clear" (`water_leak_clear`) — all sensors OFF → `rest_command.zabbix_water_leak_clear` + +## Notes + +- `POST /api/states/` creates a virtual state representation only — it does NOT control physical devices. Use `POST /api/services/...` for actual device control. +- Timestamp format: `YYYY-MM-DDThh:mm:ssTZD` (ISO 8601) +- Using `?return_response` on a service that doesn't support it returns a 400 error diff --git a/ntfy/docker-compose.yml b/ntfy/docker-compose.yml new file mode 100644 index 0000000..890e76d --- /dev/null +++ b/ntfy/docker-compose.yml @@ -0,0 +1,16 @@ +services: + ntfy: + image: binwiederhier/ntfy + container_name: ntfy + command: serve + environment: + - NTFY_BASE_URL=https://ntfy.alogins.net + - NTFY_CACHE_FILE=/var/lib/ntfy/cache.db + - NTFY_AUTH_FILE=/var/lib/ntfy/auth.db + - NTFY_AUTH_DEFAULT_ACCESS=deny-all + - NTFY_BEHIND_PROXY=true + volumes: + - /mnt/misc/ntfy:/var/lib/ntfy + ports: + - "8840:80" + restart: unless-stopped diff --git a/openai/docker-compose.yml b/openai/docker-compose.yml index a9d351d..9175e59 100644 --- a/openai/docker-compose.yml +++ b/openai/docker-compose.yml @@ -1,12 +1,42 @@ services: + ollama: + image: ollama/ollama + container_name: ollama + ports: + - "11436:11434" + volumes: + - /mnt/ssd/ai/ollama:/root/.ollama + - /mnt/ssd/ai/open-webui:/app/backend/data + restart: always + environment: + # Allow qwen3:8b + qwen2.5:1.5b to coexist in VRAM (~6.7-7.7 GB on 8 GB GPU) + - OLLAMA_MAX_LOADED_MODELS=2 + # One GPU inference at a time — prevents compute contention between models + - OLLAMA_NUM_PARALLEL=1 + deploy: + resources: + reservations: + devices: + - driver: nvidia + count: all + capabilities: [gpu] + + ollama-cpu: + image: ollama/ollama + container_name: ollama-cpu + ports: + - "11435:11434" + volumes: + - /mnt/ssd/ai/ollama-cpu:/root/.ollama + restart: always + open-webui: - image: ghcr.io/open-webui/open-webui:ollama + image: ghcr.io/open-webui/open-webui:main container_name: open-webui ports: - "3125:8080" volumes: - - ollama:/root/.ollama - - open-webui:/app/backend/data + - /mnt/ssd/ai/open-webui:/app/backend/data restart: always deploy: resources: @@ -18,6 +48,22 @@ services: environment: - ANTHROPIC_API_KEY=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 -volumes: - ollama: - open-webui: + searxng: + image: docker.io/searxng/searxng:latest + container_name: searxng + volumes: + - /mnt/ssd/ai/searxng/config/:/etc/searxng/ + - /mnt/ssd/ai/searxng/data/:/var/cache/searxng/ + restart: always + ports: + - "11437:8080" + + qdrant: + image: qdrant/qdrant + container_name: qdrant + ports: + - "6333:6333" + - "6334:6334" + restart: always + volumes: + - /mnt/ssd/dbs/qdrant:/qdrant/storage:z diff --git a/otter/docker-compose.yml b/otter/docker-compose.yml new file mode 100644 index 0000000..968580f --- /dev/null +++ b/otter/docker-compose.yml @@ -0,0 +1,9 @@ +services: + otterwiki: + image: redimp/otterwiki:2 + restart: unless-stopped + ports: + - 8083:80 + volumes: + - /mnt/ssd/dbs/otter/app-data:/app-data + diff --git a/pihole/docker-compose.yaml b/pihole/docker-compose.yaml new file mode 100644 index 0000000..3119c2d --- /dev/null +++ b/pihole/docker-compose.yaml @@ -0,0 +1,55 @@ + +networks: + macvlan-br0: + driver: macvlan + driver_opts: + parent: br0 + ipam: + config: + - subnet: 192.168.1.0/24 + gateway: 192.168.1.1 + # ip_range: 192.168.1.192/27 + +services: + pihole: + container_name: pihole + image: pihole/pihole:latest + #ports: + # DNS Ports + #- "53:53/tcp" + #- "53:53/udp" + # Default HTTP Port + #- "80:80/tcp" + # Default HTTPs Port. FTL will generate a self-signed certificate + #- "443:443/tcp" + # Uncomment the below if using Pi-hole as your DHCP Server + #- "67:67/udp" + # Uncomment the line below if you are using Pi-hole as your NTP server + #- "123:123/udp" + + networks: + macvlan-br0: + ipv4_address: 192.168.1.2 + environment: + # Set the appropriate timezone for your location from + # https://en.wikipedia.org/wiki/List_of_tz_database_time_zones, e.g: + TZ: 'Europe/Moscow' + # Set a password to access the web interface. Not setting one will result in a random password being assigned + FTLCONF_webserver_api_password: 'correct horse 123' + # If using Docker's default `bridge` network setting the dns listening mode should be set to 'ALL' + FTLCONF_dns_listeningMode: 'ALL' + # Volumes store your data between container upgrades + volumes: + # For persisting Pi-hole's databases and common configuration file + - '/mnt/ssd/dbs/pihole:/etc/pihole' + # Uncomment the below if you have custom dnsmasq config files that you want to persist. Not needed for most starting fresh with Pi-hole v6. If you're upgrading from v5 you and have used this directory before, you should keep it enabled for the first v6 container start to allow for a complete migration. It can be removed afterwards. Needs environment variable FTLCONF_misc_etc_dnsmasq_d: 'true' + #- './etc-dnsmasq.d:/etc/dnsmasq.d' + cap_add: + # See https://github.com/pi-hole/docker-pi-hole#note-on-capabilities + # Required if you are using Pi-hole as your DHCP server, else not needed + - NET_ADMIN + # Required if you are using Pi-hole as your NTP client to be able to set the host's system time + - SYS_TIME + # Optional, if Pi-hole should get some more processing time + - SYS_NICE + restart: unless-stopped diff --git a/sandbox/tgbot/bot.mjs b/sandbox/tgbot/bot.mjs new file mode 100644 index 0000000..373e729 --- /dev/null +++ b/sandbox/tgbot/bot.mjs @@ -0,0 +1,24 @@ +import { Bot } from "grammy"; + +const BOT_TOKEN = "8428861272:AAH9V_I-ZLk9CsS1-_KnNT77I28WTrzwl4A"; + +const bot = new Bot(BOT_TOKEN); + +bot.on("message", (ctx) => { + const chatId = ctx.chat.id; + const text = ctx.msg.text ?? "(no text)"; + const from = ctx.from?.username ?? ctx.from?.first_name ?? "unknown"; + console.log(`[MSG] chat_id=${chatId} from=${from} text="${text}"`); + ctx.reply(`Your chat_id is: ${chatId}`); +}); + +bot.command("start", (ctx) => { + const chatId = ctx.chat.id; + console.log(`[START] chat_id=${chatId}`); + ctx.reply(`Hello! Your chat_id is: ${chatId}\nUse this in Zabbix media settings.`); +}); + +console.log("Bot starting (polling)..."); +bot.start({ + onStart: (info) => console.log(`Bot @${info.username} is running. Send a message to get your chat_id.`), +}); diff --git a/sandbox/tgbot/node_modules/.package-lock.json b/sandbox/tgbot/node_modules/.package-lock.json new file mode 100644 index 0000000..c40c58c --- /dev/null +++ b/sandbox/tgbot/node_modules/.package-lock.json @@ -0,0 +1,115 @@ +{ + "name": "tgbot", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "node_modules/@grammyjs/types": { + "version": "3.24.0", + "resolved": "https://registry.npmjs.org/@grammyjs/types/-/types-3.24.0.tgz", + "integrity": "sha512-qQIEs4lN5WqUdr4aT8MeU6UFpMbGYAvcvYSW1A4OO1PABGJQHz/KLON6qvpf+5RxaNDQBxiY2k2otIhg/AG7RQ==", + "license": "MIT" + }, + "node_modules/abort-controller": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz", + "integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==", + "license": "MIT", + "dependencies": { + "event-target-shim": "^5.0.0" + }, + "engines": { + "node": ">=6.5" + } + }, + "node_modules/debug": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", + "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/event-target-shim": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", + "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/grammy": { + "version": "1.40.0", + "resolved": "https://registry.npmjs.org/grammy/-/grammy-1.40.0.tgz", + "integrity": "sha512-ssuE7fc1AwqlUxHr931OCVW3fU+oFDjHZGgvIedPKXfTdjXvzP19xifvVGCnPtYVUig1Kz+gwxe4A9M5WdkT4Q==", + "license": "MIT", + "dependencies": { + "@grammyjs/types": "3.24.0", + "abort-controller": "^3.0.0", + "debug": "^4.4.3", + "node-fetch": "^2.7.0" + }, + "engines": { + "node": "^12.20.0 || >=14.13.1" + } + }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "license": "MIT" + }, + "node_modules/node-fetch": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", + "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", + "license": "MIT", + "dependencies": { + "whatwg-url": "^5.0.0" + }, + "engines": { + "node": "4.x || >=6.0.0" + }, + "peerDependencies": { + "encoding": "^0.1.0" + }, + "peerDependenciesMeta": { + "encoding": { + "optional": true + } + } + }, + "node_modules/tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", + "license": "MIT" + }, + "node_modules/webidl-conversions": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==", + "license": "BSD-2-Clause" + }, + "node_modules/whatwg-url": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", + "license": "MIT", + "dependencies": { + "tr46": "~0.0.3", + "webidl-conversions": "^3.0.0" + } + } + } +} diff --git a/sandbox/tgbot/node_modules/@grammyjs/types/LICENSE b/sandbox/tgbot/node_modules/@grammyjs/types/LICENSE new file mode 100644 index 0000000..b9a5b7b --- /dev/null +++ b/sandbox/tgbot/node_modules/@grammyjs/types/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2021-2024 KnorpelSenf + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/sandbox/tgbot/node_modules/@grammyjs/types/README.md b/sandbox/tgbot/node_modules/@grammyjs/types/README.md new file mode 100644 index 0000000..4d39bba --- /dev/null +++ b/sandbox/tgbot/node_modules/@grammyjs/types/README.md @@ -0,0 +1,107 @@ +# Telegram Bot API types for grammY + +[grammY](https://github.com/grammyjs/grammY) makes writing Telegram bots easy. Check it out! + +This package just provides type annotations for the complete Telegram Bot API, and aims at making them usable for grammY. It contains no runnable code. + +Originally, this package is based on `typegram`, but since the update to Telegram Bot API 5.1, `typegram` is no longer directly updated. Instead, this package is maintained and its updates are backported to `typegram`. Hence, both packages are kept up to date with the Telegram Bot API for now. + +## Available Types + +Generally this package just exposes a huge load of `interface`s that correspond to the **types** used throughout the Telegram Bot API. + +Note that the API specification sometimes only has one name for multiple variants of a type, e.g. there is a number of different `Update`s you can receive, but they're all just called `Update`. +If you need to access the individual variants of an `Update`, refer to `Update.MessageUpdate` and its siblings. + +In fact, this pattern is used for various types, namely: + +- `CallbackQuery` +- `Chat` +- `ChatFullInfo` +- `InlineKeyboardButton` +- `KeyboardButton` +- `Message` +- `MessageEntity` +- `Location` +- `Update` + +Naturally, when the API specification is actually modelling types to be unions (e.g. `InlineQueryResult`), this is reflected here as a union type, too. +Those types are not closed. + +## Available Methods + +In addition to the types, this package provides you with another type `Telegram` which contains all available **methods** of the API. +There is no further structure applied to this, but if you can come up with something reasonable, please suggest it in an issue or directly open a PR. +In grammY, these types are what defines the `bot.api.raw` object. + +Each method takes just a single argument with a structure that corresponds to the object expected by Telegram. +The helper type `Opts` (where `M` is the method name) allows grammY to access that type directly. + +## Handling JSON-Serialized Objects + +Some methods of the Telegram Bot API are expected to be called with JSON-serialized objects contained in a property of the payload, rather than an actual JSON payload. +In other words, the objects are serialized twice—the first time in order to conform with the docs, and the second time when the payload is actually sent in the POST body to the API server. + +The most prominent example is the `reply_markup` property that appears in a number of different methods, but more than a dozen other properties like this can be found throughout the API. + +Strictly speaking, the `@grammyjs/types` types do not reflect this accurately. +Instead of using `string` (representing a serialized object) as the type, `@grammyjs/types` uses the type of the object itself, thus ignoring the serialization step. +For instance, instead of declaring `reply_markup: string`, it declares the property as `reply_markup: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply` because that is what is supposed to be serialized to `string` before calling the respective method. + +That makes sense for the reason that grammY uses the types in its wrapper code around the Telegram Bot API, exposed as `bot.raw.api`. +This wrapper code does the necessary JSON serialization automatically for the required properties. +Bots written with grammY then do not need to care about which properties to serialize and which not. +Given that `@grammyjs/types` refers to the objects themselves instead of their serialized strings, the wrapper code can now simply expose the `@grammyjs/types` types to its consumers without having to transform them before. + +Consequently, the descriptions of all methods are adjusted in order to reflect this, i.e. the JSDoc comments do not mention JSON serialization (in contrast to their official equivalents). + +## Customizing `InputFile` + +The Telegram Bot API lets bots send files in [three different ways](https://core.telegram.org/bots/api#sending-files). +Two of those ways are by specifying a `string`—either a `file_id` or a URL. +The third option, however, is by uploading files to the server using multipart/form-data. + +The first two means to send a file are already covered by the type annotations across the library. +In all places where a `file_id` or a URL is permitted, the corresponding property allows a `string`. + +We will now look at the type declarations that are relevant for uploading files directly. +grammY automatically translates calls to `sendDocument` and the like to multipart/form-data uploads when supplied with an `InputFile` object in the `document` property of the argument object. + +`@grammyjs/types` should not have to know what objects you want to support as `InputFile`s. +Consequently, the type `InputFile` is not defined in this library. + +Instead, grammY specifies its own version of what an `InputFile` is, hence automatically adjusting `@grammyjs/types` with a custom `InputFile` type used throughout all affected methods and interfaces. +This is possible by adding a type parameter to all affected types. +grammY then import types parametrises these types with its version of `InputFile`, and re-exports the adjusted types. +This is why you should always import Bot API as described here: . + +## Differences to the Bot API + +Some documentation strings are intentionally different from what is written on the website. +The actual type definitions themselves are never different. + +1. No formatting. + We do not leverage the markdown capabilities of JSDoc for the sake of easier copying and thus reduced maintenance efforts. +2. No mentions of `JSON-serialized`. + As underlying libraries handle serialization, these words are removed from the explanations. +3. No mentions of integer numbers that exceed 2^31 but not 2^51. + All numbers are 64-bit floats in JS, so this is irrelevant. + Note that JS bit operators cast numbers to 32-bit integers and back, but we deliberately ignore this because people who use bit operators on identifiers or file sizes should know what they're doing, and they should also know that it's a bad idea. +4. No `More info on Sending Files »`. + File handling is abstracted away by the underlying library. + Also, without the links, it's useless anyway. + The same is true for the links to more info about requesting chats and users. +5. No images. + Documentation strings containing an image are adjusted to make sense without the images, too. + +## Contributing + +This is a Deno project. +All the files are TypeScript files that are published on . +This project uses [deno2node](https://github.com/fromdeno/deno2node) to emit declaration files which are then published on npm. + +If you want to work on this, you do not need to have Node.js installed. +You also should not run `npm install`. +You only need [Deno](https://deno.land) and the VSCode extensions recommended in this repo. + +Run `deno task` to see available development scripts. diff --git a/sandbox/tgbot/node_modules/@grammyjs/types/api.d.ts b/sandbox/tgbot/node_modules/@grammyjs/types/api.d.ts new file mode 100644 index 0000000..ea7c9f7 --- /dev/null +++ b/sandbox/tgbot/node_modules/@grammyjs/types/api.d.ts @@ -0,0 +1,22 @@ +export interface ApiError { + ok: false; + error_code: number; + description: string; + parameters?: ResponseParameters; +} +export interface ApiSuccess { + ok: true; + result: T; +} +/** The response contains an object, which always has a Boolean field 'ok' and may have an optional String field 'description' with a human-readable description of the result. If 'ok' equals true, the request was successful and the result of the query can be found in the 'result' field. In case of an unsuccessful request, 'ok' equals false and the error is explained in the 'description'. An Integer 'error_code' field is also returned, but its contents are subject to change in the future. Some errors may also have an optional field 'parameters' of the type ResponseParameters, which can help to automatically handle the error. + +All methods in the Bot API are case-insensitive. +All queries must be made using UTF-8. */ +export type ApiResponse = ApiError | ApiSuccess; +/** Describes why a request was unsuccessful. */ +export interface ResponseParameters { + /** The group has been migrated to a supergroup with the specified identifier. */ + migrate_to_chat_id?: number; + /** In case of exceeding flood control, the number of seconds left to wait before the request can be repeated */ + retry_after?: number; +} diff --git a/sandbox/tgbot/node_modules/@grammyjs/types/checklist.d.ts b/sandbox/tgbot/node_modules/@grammyjs/types/checklist.d.ts new file mode 100644 index 0000000..a1618b2 --- /dev/null +++ b/sandbox/tgbot/node_modules/@grammyjs/types/checklist.d.ts @@ -0,0 +1,72 @@ +import type { Chat, User } from "./manage.js"; +import type { Message, MessageEntity, ParseMode } from "./message.js"; +/** Describes a task in a checklist. */ +export interface ChecklistTask { + /** Unique identifier of the task */ + id: number; + /** Text of the task */ + text: string; + /** Special entities that appear in the task text */ + text_entities?: MessageEntity[]; + /** User that completed the task; omitted if the task wasn't completed by a user */ + completed_by_user?: User; + /** Chat that completed the task; omitted if the task wasn't completed by a chat */ + completed_by_chat?: Chat; + /** Point in time (Unix timestamp) when the task was completed; 0 if the task wasn't completed */ + completion_date?: number; +} +/** Describes a checklist. */ +export interface Checklist { + /** Title of the checklist */ + title: string; + /** Special entities that appear in the checklist title */ + title_entities?: MessageEntity[]; + /** List of tasks in the checklist */ + tasks: ChecklistTask[]; + /** True, if users other than the creator of the list can add tasks to the list */ + others_can_add_tasks?: true; + /** True, if users other than the creator of the list can mark tasks as done or not done */ + others_can_mark_tasks_as_done?: true; +} +/** Describes a task to add to a checklist. */ +export interface InputChecklistTask { + /** Unique identifier of the task; must be positive and unique among all task identifiers currently present in the checklist */ + id: number; + /** Text of the task; 1-100 characters after entities parsing */ + text: string; + /** Mode for parsing entities in the text. See formatting options for more details. */ + parse_mode?: ParseMode; + /** List of special entities that appear in the text, which can be specified instead of parse_mode. Currently, only bold, italic, underline, strikethrough, spoiler, and custom_emoji entities are allowed. */ + text_entities?: MessageEntity[]; +} +/** Describes a checklist to create. */ +export interface InputChecklist { + /** Title of the checklist; 1-255 characters after entities parsing */ + title: string; + /** Mode for parsing entities in the title. See formatting options for more details. */ + parse_mode?: ParseMode; + /** List of special entities that appear in the title, which can be specified instead of parse_mode. Currently, only bold, italic, underline, strikethrough, spoiler, and custom_emoji entities are allowed. */ + title_entities?: MessageEntity[]; + /** List of 1-30 tasks in the checklist */ + tasks: InputChecklistTask[]; + /** Pass True if other users can add tasks to the checklist */ + others_can_add_tasks?: boolean; + /** Pass True if other users can mark tasks as done or not done in the checklist */ + others_can_mark_tasks_as_done?: true; +} +/** Describes a service message about checklist tasks marked as done or not done. */ +export interface ChecklistTasksDone { + /** Message containing the checklist whose tasks were marked as done or not done. Note that the Message object in this field will not contain the reply_to_message field even if it itself is a reply. */ + checklist_message?: Message; + /** Identifiers of the tasks that were marked as done */ + marked_as_done_task_ids?: number[]; + /** Identifiers of the tasks that were marked as not done */ + marked_as_not_done_task_ids?: number[]; +} +/** Describes a service message about tasks added to a checklist. */ +export interface ChecklistTasksAdded { + /** Message containing the checklist to which the tasks were added. Note that the Message object in this field will not contain the reply_to_message field even if it itself is a reply. */ + checklist_message?: Message; + /** List of tasks added to the checklist */ + tasks: ChecklistTask[]; +} diff --git a/sandbox/tgbot/node_modules/@grammyjs/types/inline.d.ts b/sandbox/tgbot/node_modules/@grammyjs/types/inline.d.ts new file mode 100644 index 0000000..cb51e73 --- /dev/null +++ b/sandbox/tgbot/node_modules/@grammyjs/types/inline.d.ts @@ -0,0 +1,684 @@ +import type { Chat, User } from "./manage.js"; +import type { InlineKeyboardMarkup, WebAppInfo } from "./markup.js"; +import type { LinkPreviewOptions, Location, MessageEntity, ParseMode } from "./message.js"; +import type { LabeledPrice } from "./payment.js"; +/** This object represents an incoming inline query. When the user sends an empty query, your bot could return some default or trending results. */ +export interface InlineQuery { + /** Unique identifier for this query */ + id: string; + /** Sender */ + from: User; + /** Text of the query (up to 256 characters) */ + query: string; + /** Offset of the results to be returned, can be controlled by the bot */ + offset: string; + /** Type of the chat from which the inline query was sent. Can be either “sender” for a private chat with the inline query sender, “private”, “group”, “supergroup”, or “channel”. The chat type should be always known for requests sent from official clients and most third-party clients, unless the request was sent from a secret chat */ + chat_type?: "sender" | Chat["type"]; + /** Sender location, only for bots that request user location */ + location?: Location; +} +/** This object represents one result of an inline query. Telegram clients currently support results of the following 20 types: +- InlineQueryResultCachedAudio +- InlineQueryResultCachedDocument +- InlineQueryResultCachedGif +- InlineQueryResultCachedMpeg4Gif +- InlineQueryResultCachedPhoto +- InlineQueryResultCachedSticker +- InlineQueryResultCachedVideo +- InlineQueryResultCachedVoice +- InlineQueryResultArticle +- InlineQueryResultAudio +- InlineQueryResultContact +- InlineQueryResultGame +- InlineQueryResultDocument +- InlineQueryResultGif +- InlineQueryResultLocation +- InlineQueryResultMpeg4Gif +- InlineQueryResultPhoto +- InlineQueryResultVenue +- InlineQueryResultVideo +- InlineQueryResultVoice + +Note: All URLs passed in inline query results will be available to end users and therefore must be assumed to be public. */ +export type InlineQueryResult = InlineQueryResultCachedAudio | InlineQueryResultCachedDocument | InlineQueryResultCachedGif | InlineQueryResultCachedMpeg4Gif | InlineQueryResultCachedPhoto | InlineQueryResultCachedSticker | InlineQueryResultCachedVideo | InlineQueryResultCachedVoice | InlineQueryResultArticle | InlineQueryResultAudio | InlineQueryResultContact | InlineQueryResultGame | InlineQueryResultDocument | InlineQueryResultGif | InlineQueryResultLocation | InlineQueryResultMpeg4Gif | InlineQueryResultPhoto | InlineQueryResultVenue | InlineQueryResultVideo | InlineQueryResultVoice; +/** Represents a link to an article or web page. */ +export interface InlineQueryResultArticle { + /** Type of the result, must be article */ + type: "article"; + /** Unique identifier for this result, 1-64 Bytes */ + id: string; + /** Title of the result */ + title: string; + /** Content of the message to be sent */ + input_message_content: InputMessageContent; + /** Inline keyboard attached to the message */ + reply_markup?: InlineKeyboardMarkup; + /** URL of the result */ + url?: string; + /** Short description of the result */ + description?: string; + /** Url of the thumbnail for the result */ + thumbnail_url?: string; + /** Thumbnail width */ + thumbnail_width?: number; + /** Thumbnail height */ + thumbnail_height?: number; +} +/** Represents a link to a photo. By default, this photo will be sent by the user with optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the photo. */ +export interface InlineQueryResultPhoto { + /** Type of the result, must be photo */ + type: "photo"; + /** Unique identifier for this result, 1-64 bytes */ + id: string; + /** A valid URL of the photo. Photo must be in JPEG format. Photo size must not exceed 5MB */ + photo_url: string; + /** URL of the thumbnail for the photo */ + thumbnail_url: string; + /** Width of the photo */ + photo_width?: number; + /** Height of the photo */ + photo_height?: number; + /** Title for the result */ + title?: string; + /** Short description of the result */ + description?: string; + /** Caption of the photo to be sent, 0-1024 characters after entities parsing */ + caption?: string; + /** Pass True, if the caption must be shown above the message media */ + show_caption_above_media?: boolean; + /** Mode for parsing entities in the photo caption. See formatting options for more details. */ + parse_mode?: ParseMode; + /** List of special entities that appear in the caption, which can be specified instead of parse_mode */ + caption_entities?: MessageEntity[]; + /** Inline keyboard attached to the message */ + reply_markup?: InlineKeyboardMarkup; + /** Content of the message to be sent instead of the photo */ + input_message_content?: InputMessageContent; +} +/** Represents a link to an animated GIF file. By default, this animated GIF file will be sent by the user with optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the animation. */ +export interface InlineQueryResultGif { + /** Type of the result, must be gif */ + type: "gif"; + /** Unique identifier for this result, 1-64 bytes */ + id: string; + /** A valid URL for the GIF file */ + gif_url: string; + /** Width of the GIF */ + gif_width?: number; + /** Height of the GIF */ + gif_height?: number; + /** Duration of the GIF in seconds */ + gif_duration?: number; + /** URL of the static (JPEG or GIF) or animated (MPEG4) thumbnail for the result */ + thumbnail_url: string; + /** MIME type of the thumbnail, must be one of “image/jpeg”, “image/gif”, or “video/mp4”. Defaults to “image/jpeg” */ + thumbnail_mime_type?: "image/jpeg" | "image/gif" | "video/mp4"; + /** Title for the result */ + title?: string; + /** Caption of the GIF file to be sent, 0-1024 characters after entities parsing */ + caption?: string; + /** Pass True, if the caption must be shown above the message media */ + show_caption_above_media?: boolean; + /** Mode for parsing entities in the caption. See formatting options for more details. */ + parse_mode?: ParseMode; + /** List of special entities that appear in the caption, which can be specified instead of parse_mode */ + caption_entities?: MessageEntity[]; + /** Inline keyboard attached to the message */ + reply_markup?: InlineKeyboardMarkup; + /** Content of the message to be sent instead of the GIF animation */ + input_message_content?: InputMessageContent; +} +/** Represents a link to a video animation (H.264/MPEG-4 AVC video without sound). By default, this animated MPEG-4 file will be sent by the user with optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the animation. */ +export interface InlineQueryResultMpeg4Gif { + /** Type of the result, must be mpeg4_gif */ + type: "mpeg4_gif"; + /** Unique identifier for this result, 1-64 bytes */ + id: string; + /** A valid URL for the MPEG4 file */ + mpeg4_url: string; + /** Video width */ + mpeg4_width?: number; + /** Video height */ + mpeg4_height?: number; + /** Video duration in seconds */ + mpeg4_duration?: number; + /** URL of the static (JPEG or GIF) or animated (MPEG4) thumbnail for the result */ + thumbnail_url: string; + /** MIME type of the thumbnail, must be one of “image/jpeg”, “image/gif”, or “video/mp4”. Defaults to “image/jpeg” */ + thumbnail_mime_type?: "image/jpeg" | "image/gif" | "video/mp4"; + /** Title for the result */ + title?: string; + /** Caption of the MPEG-4 file to be sent, 0-1024 characters after entities parsing */ + caption?: string; + /** Pass True, if the caption must be shown above the message media */ + show_caption_above_media?: boolean; + /** Mode for parsing entities in the caption. See formatting options for more details. */ + parse_mode?: ParseMode; + /** List of special entities that appear in the caption, which can be specified instead of parse_mode */ + caption_entities?: MessageEntity[]; + /** Inline keyboard attached to the message */ + reply_markup?: InlineKeyboardMarkup; + /** Content of the message to be sent instead of the video animation */ + input_message_content?: InputMessageContent; +} +/** Represents a link to a page containing an embedded video player or a video file. By default, this video file will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the video. + +> If an InlineQueryResultVideo message contains an embedded video (e.g., YouTube), you must replace its content using input_message_content. */ +export interface InlineQueryResultVideo { + /** Type of the result, must be video */ + type: "video"; + /** Unique identifier for this result, 1-64 bytes */ + id: string; + /** A valid URL for the embedded video player or video file */ + video_url: string; + /** MIME type of the content of the video URL, “text/html” or “video/mp4” */ + mime_type: "text/html" | "video/mp4"; + /** URL of the thumbnail (JPEG only) for the video */ + thumbnail_url: string; + /** Title for the result */ + title: string; + /** Caption of the video to be sent, 0-1024 characters after entities parsing */ + caption?: string; + /** Pass True, if the caption must be shown above the message media */ + show_caption_above_media?: boolean; + /** Mode for parsing entities in the video caption. See formatting options for more details. */ + parse_mode?: ParseMode; + /** List of special entities that appear in the caption, which can be specified instead of parse_mode */ + caption_entities?: MessageEntity[]; + /** Video width */ + video_width?: number; + /** Video height */ + video_height?: number; + /** Video duration in seconds */ + video_duration?: number; + /** Short description of the result */ + description?: string; + /** Inline keyboard attached to the message */ + reply_markup?: InlineKeyboardMarkup; + /** Content of the message to be sent instead of the video. This field is required if InlineQueryResultVideo is used to send an HTML-page as a result (e.g., a YouTube video). */ + input_message_content?: InputMessageContent; +} +/** Represents a link to an MP3 audio file. By default, this audio file will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the audio. */ +export interface InlineQueryResultAudio { + /** Type of the result, must be audio */ + type: "audio"; + /** Unique identifier for this result, 1-64 bytes */ + id: string; + /** A valid URL for the audio file */ + audio_url: string; + /** Title */ + title: string; + /** Caption, 0-1024 characters after entities parsing */ + caption?: string; + /** Mode for parsing entities in the audio caption. See formatting options for more details. */ + parse_mode?: ParseMode; + /** List of special entities that appear in the caption, which can be specified instead of parse_mode */ + caption_entities?: MessageEntity[]; + /** Performer */ + performer?: string; + /** Audio duration in seconds */ + audio_duration?: number; + /** Inline keyboard attached to the message */ + reply_markup?: InlineKeyboardMarkup; + /** Content of the message to be sent instead of the audio */ + input_message_content?: InputMessageContent; +} +/** Represents a link to a voice recording in an .OGG container encoded with OPUS. By default, this voice recording will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the the voice message. */ +export interface InlineQueryResultVoice { + /** Type of the result, must be voice */ + type: "voice"; + /** Unique identifier for this result, 1-64 bytes */ + id: string; + /** A valid URL for the voice recording */ + voice_url: string; + /** Recording title */ + title: string; + /** Caption, 0-1024 characters after entities parsing */ + caption?: string; + /** Mode for parsing entities in the voice message caption. See formatting options for more details. */ + parse_mode?: ParseMode; + /** List of special entities that appear in the caption, which can be specified instead of parse_mode */ + caption_entities?: MessageEntity[]; + /** Recording duration in seconds */ + voice_duration?: number; + /** Inline keyboard attached to the message */ + reply_markup?: InlineKeyboardMarkup; + /** Content of the message to be sent instead of the voice recording */ + input_message_content?: InputMessageContent; +} +/** Represents a link to a file. By default, this file will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the file. Currently, only .PDF and .ZIP files can be sent using this method. */ +export interface InlineQueryResultDocument { + /** Type of the result, must be document */ + type: "document"; + /** Unique identifier for this result, 1-64 bytes */ + id: string; + /** Title for the result */ + title: string; + /** Caption of the document to be sent, 0-1024 characters after entities parsing */ + caption?: string; + /** Mode for parsing entities in the document caption. See formatting options for more details. */ + parse_mode?: ParseMode; + /** List of special entities that appear in the caption, which can be specified instead of parse_mode */ + caption_entities?: MessageEntity[]; + /** A valid URL for the file */ + document_url: string; + /** MIME type of the content of the file, either “application/pdf” or “application/zip” */ + mime_type: "application/pdf" | "application/zip"; + /** Short description of the result */ + description?: string; + /** Inline keyboard attached to the message */ + reply_markup?: InlineKeyboardMarkup; + /** Content of the message to be sent instead of the file */ + input_message_content?: InputMessageContent; + /** URL of the thumbnail (JPEG only) for the file */ + thumbnail_url?: string; + /** Thumbnail width */ + thumbnail_width?: number; + /** Thumbnail height */ + thumbnail_height?: number; +} +/** Represents a location on a map. By default, the location will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the location. */ +export interface InlineQueryResultLocation { + /** Type of the result, must be location */ + type: "location"; + /** Unique identifier for this result, 1-64 Bytes */ + id: string; + /** Location latitude in degrees */ + latitude: number; + /** Location longitude in degrees */ + longitude: number; + /** Location title */ + title: string; + /** The radius of uncertainty for the location, measured in meters; 0-1500 */ + horizontal_accuracy?: number; + /** Period in seconds during which the location can be updated, should be between 60 and 86400, or 0x7FFFFFFF for live locations that can be edited indefinitely. */ + live_period?: number; + /** For live locations, a direction in which the user is moving, in degrees. Must be between 1 and 360 if specified. */ + heading?: number; + /** For live locations, a maximum distance for proximity alerts about approaching another chat member, in meters. Must be between 1 and 100000 if specified. */ + proximity_alert_radius?: number; + /** Inline keyboard attached to the message */ + reply_markup?: InlineKeyboardMarkup; + /** Content of the message to be sent instead of the location */ + input_message_content?: InputMessageContent; + /** Url of the thumbnail for the result */ + thumbnail_url?: string; + /** Thumbnail width */ + thumbnail_width?: number; + /** Thumbnail height */ + thumbnail_height?: number; +} +/** Represents a venue. By default, the venue will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the venue. */ +export interface InlineQueryResultVenue { + /** Type of the result, must be venue */ + type: "venue"; + /** Unique identifier for this result, 1-64 Bytes */ + id: string; + /** Latitude of the venue location in degrees */ + latitude: number; + /** Longitude of the venue location in degrees */ + longitude: number; + /** Title of the venue */ + title: string; + /** Address of the venue */ + address: string; + /** Foursquare identifier of the venue if known */ + foursquare_id?: string; + /** Foursquare type of the venue, if known. (For example, “arts_entertainment/default”, “arts_entertainment/aquarium” or “food/icecream”.) */ + foursquare_type?: string; + /** Google Places identifier of the venue */ + google_place_id?: string; + /** Google Places type of the venue. (See supported types.) */ + google_place_type?: string; + /** Inline keyboard attached to the message */ + reply_markup?: InlineKeyboardMarkup; + /** Content of the message to be sent instead of the venue */ + input_message_content?: InputMessageContent; + /** Url of the thumbnail for the result */ + thumbnail_url?: string; + /** Thumbnail width */ + thumbnail_width?: number; + /** Thumbnail height */ + thumbnail_height?: number; +} +/** Represents a contact with a phone number. By default, this contact will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the contact. */ +export interface InlineQueryResultContact { + /** Type of the result, must be contact */ + type: "contact"; + /** Unique identifier for this result, 1-64 Bytes */ + id: string; + /** Contact's phone number */ + phone_number: string; + /** Contact's first name */ + first_name: string; + /** Contact's last name */ + last_name?: string; + /** Additional data about the contact in the form of a vCard, 0-2048 bytes */ + vcard?: string; + /** Inline keyboard attached to the message */ + reply_markup?: InlineKeyboardMarkup; + /** Content of the message to be sent instead of the contact */ + input_message_content?: InputMessageContent; + /** Url of the thumbnail for the result */ + thumbnail_url?: string; + /** Thumbnail width */ + thumbnail_width?: number; + /** Thumbnail height */ + thumbnail_height?: number; +} +/** Represents a Game. */ +export interface InlineQueryResultGame { + /** Type of the result, must be game */ + type: "game"; + /** Unique identifier for this result, 1-64 bytes */ + id: string; + /** Short name of the game */ + game_short_name: string; + /** Inline keyboard attached to the message */ + reply_markup?: InlineKeyboardMarkup; +} +/** Represents a link to a photo stored on the Telegram servers. By default, this photo will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the photo. */ +export interface InlineQueryResultCachedPhoto { + /** Type of the result, must be photo */ + type: "photo"; + /** Unique identifier for this result, 1-64 bytes */ + id: string; + /** A valid file identifier of the photo */ + photo_file_id: string; + /** Title for the result */ + title?: string; + /** Short description of the result */ + description?: string; + /** Caption of the photo to be sent, 0-1024 characters after entities parsing */ + caption?: string; + /** Pass True, if the caption must be shown above the message media */ + show_caption_above_media?: boolean; + /** Mode for parsing entities in the photo caption. See formatting options for more details. */ + parse_mode?: ParseMode; + /** List of special entities that appear in the caption, which can be specified instead of parse_mode */ + caption_entities?: MessageEntity[]; + /** Inline keyboard attached to the message */ + reply_markup?: InlineKeyboardMarkup; + /** Content of the message to be sent instead of the photo */ + input_message_content?: InputMessageContent; +} +/** Represents a link to an animated GIF file stored on the Telegram servers. By default, this animated GIF file will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with specified content instead of the animation. */ +export interface InlineQueryResultCachedGif { + /** Type of the result, must be gif */ + type: "gif"; + /** Unique identifier for this result, 1-64 bytes */ + id: string; + /** A valid file identifier for the GIF file */ + gif_file_id: string; + /** Title for the result */ + title?: string; + /** Caption of the GIF file to be sent, 0-1024 characters after entities parsing */ + caption?: string; + /** Pass True, if the caption must be shown above the message media */ + show_caption_above_media?: boolean; + /** Mode for parsing entities in the caption. See formatting options for more details. */ + parse_mode?: ParseMode; + /** List of special entities that appear in the caption, which can be specified instead of parse_mode */ + caption_entities?: MessageEntity[]; + /** Inline keyboard attached to the message */ + reply_markup?: InlineKeyboardMarkup; + /** Content of the message to be sent instead of the GIF animation */ + input_message_content?: InputMessageContent; +} +/** Represents a link to a video animation (H.264/MPEG-4 AVC video without sound) stored on the Telegram servers. By default, this animated MPEG-4 file will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the animation. */ +export interface InlineQueryResultCachedMpeg4Gif { + /** Type of the result, must be mpeg4_gif */ + type: "mpeg4_gif"; + /** Unique identifier for this result, 1-64 bytes */ + id: string; + /** A valid file identifier for the MPEG4 file */ + mpeg4_file_id: string; + /** Title for the result */ + title?: string; + /** Caption of the MPEG-4 file to be sent, 0-1024 characters after entities parsing */ + caption?: string; + /** Pass True, if the caption must be shown above the message media */ + show_caption_above_media?: boolean; + /** Mode for parsing entities in the caption. See formatting options for more details. */ + parse_mode?: ParseMode; + /** List of special entities that appear in the caption, which can be specified instead of parse_mode */ + caption_entities?: MessageEntity[]; + /** Inline keyboard attached to the message */ + reply_markup?: InlineKeyboardMarkup; + /** Content of the message to be sent instead of the video animation */ + input_message_content?: InputMessageContent; +} +/** Represents a link to a sticker stored on the Telegram servers. By default, this sticker will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the sticker. */ +export interface InlineQueryResultCachedSticker { + /** Type of the result, must be sticker */ + type: "sticker"; + /** Unique identifier for this result, 1-64 bytes */ + id: string; + /** A valid file identifier of the sticker */ + sticker_file_id: string; + /** Inline keyboard attached to the message */ + reply_markup?: InlineKeyboardMarkup; + /** Content of the message to be sent instead of the sticker */ + input_message_content?: InputMessageContent; +} +/** Represents a link to a file stored on the Telegram servers. By default, this file will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the file. */ +export interface InlineQueryResultCachedDocument { + /** Type of the result, must be document */ + type: "document"; + /** Unique identifier for this result, 1-64 bytes */ + id: string; + /** Title for the result */ + title: string; + /** A valid file identifier for the file */ + document_file_id: string; + /** Short description of the result */ + description?: string; + /** Caption of the document to be sent, 0-1024 characters after entities parsing */ + caption?: string; + /** Mode for parsing entities in the document caption. See formatting options for more details. */ + parse_mode?: ParseMode; + /** List of special entities that appear in the caption, which can be specified instead of parse_mode */ + caption_entities?: MessageEntity[]; + /** Inline keyboard attached to the message */ + reply_markup?: InlineKeyboardMarkup; + /** Content of the message to be sent instead of the file */ + input_message_content?: InputMessageContent; +} +/** Represents a link to a video file stored on the Telegram servers. By default, this video file will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the video. */ +export interface InlineQueryResultCachedVideo { + /** Type of the result, must be video */ + type: "video"; + /** Unique identifier for this result, 1-64 bytes */ + id: string; + /** A valid file identifier for the video file */ + video_file_id: string; + /** Title for the result */ + title: string; + /** Short description of the result */ + description?: string; + /** Caption of the video to be sent, 0-1024 characters after entities parsing */ + caption?: string; + /** Pass True, if the caption must be shown above the message media */ + show_caption_above_media?: boolean; + /** Mode for parsing entities in the video caption. See formatting options for more details. */ + parse_mode?: ParseMode; + /** List of special entities that appear in the caption, which can be specified instead of parse_mode */ + caption_entities?: MessageEntity[]; + /** Inline keyboard attached to the message */ + reply_markup?: InlineKeyboardMarkup; + /** Content of the message to be sent instead of the video */ + input_message_content?: InputMessageContent; +} +/** Represents a link to a voice message stored on the Telegram servers. By default, this voice message will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the voice message. */ +export interface InlineQueryResultCachedVoice { + /** Type of the result, must be voice */ + type: "voice"; + /** Unique identifier for this result, 1-64 bytes */ + id: string; + /** A valid file identifier for the voice message */ + voice_file_id: string; + /** Voice message title */ + title: string; + /** Caption, 0-1024 characters after entities parsing */ + caption?: string; + /** Mode for parsing entities in the voice message caption. See formatting options for more details. */ + parse_mode?: ParseMode; + /** List of special entities that appear in the caption, which can be specified instead of parse_mode */ + caption_entities?: MessageEntity[]; + /** Inline keyboard attached to the message */ + reply_markup?: InlineKeyboardMarkup; + /** Content of the message to be sent instead of the voice message */ + input_message_content?: InputMessageContent; +} +/** Represents a link to an MP3 audio file stored on the Telegram servers. By default, this audio file will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the audio. */ +export interface InlineQueryResultCachedAudio { + /** Type of the result, must be audio */ + type: "audio"; + /** Unique identifier for this result, 1-64 bytes */ + id: string; + /** A valid file identifier for the audio file */ + audio_file_id: string; + /** Caption, 0-1024 characters after entities parsing */ + caption?: string; + /** Mode for parsing entities in the audio caption. See formatting options for more details. */ + parse_mode?: ParseMode; + /** List of special entities that appear in the caption, which can be specified instead of parse_mode */ + caption_entities?: MessageEntity[]; + /** Inline keyboard attached to the message */ + reply_markup?: InlineKeyboardMarkup; + /** Content of the message to be sent instead of the audio */ + input_message_content?: InputMessageContent; +} +/** This object represents the content of a message to be sent as a result of an inline query. Telegram clients currently support the following 5 types: + +- InputTextMessageContent +- InputLocationMessageContent +- InputVenueMessageContent +- InputContactMessageContent +- InputInvoiceMessageContent */ +export type InputMessageContent = InputTextMessageContent | InputLocationMessageContent | InputVenueMessageContent | InputContactMessageContent | InputInvoiceMessageContent; +/** Represents the content of a text message to be sent as the result of an inline query. */ +export interface InputTextMessageContent { + /** Text of the message to be sent, 1-4096 characters */ + message_text: string; + /** Mode for parsing entities in the message text. See formatting options for more details. */ + parse_mode?: ParseMode; + /** List of special entities that appear in message text, which can be specified instead of parse_mode */ + entities?: MessageEntity[]; + /** Link preview generation options for the message */ + link_preview_options?: LinkPreviewOptions; +} +/** Represents the content of a location message to be sent as the result of an inline query. */ +export interface InputLocationMessageContent { + /** Latitude of the location in degrees */ + latitude: number; + /** Longitude of the location in degrees */ + longitude: number; + /** The radius of uncertainty for the location, measured in meters; 0-1500 */ + horizontal_accuracy?: number; + /** Period in seconds during which the location can be updated, should be between 60 and 86400, or 0x7FFFFFFF for live locations that can be edited indefinitely. */ + live_period?: number; + /** For live locations, a direction in which the user is moving, in degrees. Must be between 1 and 360 if specified. */ + heading?: number; + /** For live locations, a maximum distance for proximity alerts about approaching another chat member, in meters. Must be between 1 and 100000 if specified. */ + proximity_alert_radius?: number; +} +/** Represents the content of a venue message to be sent as the result of an inline query. */ +export interface InputVenueMessageContent { + /** Latitude of the venue in degrees */ + latitude: number; + /** Longitude of the venue in degrees */ + longitude: number; + /** Name of the venue */ + title: string; + /** Address of the venue */ + address: string; + /** Foursquare identifier of the venue, if known */ + foursquare_id?: string; + /** Foursquare type of the venue, if known. (For example, “arts_entertainment/default”, “arts_entertainment/aquarium” or “food/icecream”.) */ + foursquare_type?: string; + /** Google Places identifier of the venue */ + google_place_id?: string; + /** Google Places type of the venue. (See supported types.) */ + google_place_type?: string; +} +/** Represents the content of a contact message to be sent as the result of an inline query. */ +export interface InputContactMessageContent { + /** Contact's phone number */ + phone_number: string; + /** Contact's first name */ + first_name: string; + /** Contact's last name */ + last_name?: string; + /** Additional data about the contact in the form of a vCard, 0-2048 bytes */ + vcard?: string; +} +/** Represents the content of an invoice message to be sent as the result of an inline query. */ +export interface InputInvoiceMessageContent { + /** Product name, 1-32 characters */ + title: string; + /** Product description, 1-255 characters */ + description: string; + /** Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use it for your internal processes. */ + payload: string; + /** Payment provider token, obtained via `@BotFather`. Pass an empty string for payments in Telegram Stars. */ + provider_token?: string; + /** Three-letter ISO 4217 currency code, see more on currencies. Pass “XTR” for payments in Telegram Stars. */ + currency: string; + /** Price breakdown, a JSON-serialized list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.). Must contain exactly one item for payments in Telegram Stars. */ + prices: LabeledPrice[]; + /** The maximum accepted amount for tips in the smallest units of the currency (integer, not float/double). For example, for a maximum tip of US$ 1.45 pass max_tip_amount = 145. See the exp parameter in currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies). Defaults to 0. Not supported for payments in Telegram Stars. */ + max_tip_amount?: number; + /** An array of suggested amounts of tip in the smallest units of the currency (integer, not float/double). At most 4 suggested tip amounts can be specified. The suggested tip amounts must be positive, passed in a strictly increased order and must not exceed max_tip_amount. */ + suggested_tip_amounts?: number[]; + /** Data about the invoice, which will be shared with the payment provider. A detailed description of the required fields should be provided by the payment provider. */ + provider_data?: string; + /** URL of the product photo for the invoice. Can be a photo of the goods or a marketing image for a service. */ + photo_url?: string; + /** Photo size in bytes */ + photo_size?: number; + /** Photo width */ + photo_width?: number; + /** Photo height */ + photo_height?: number; + /** Pass True if you require the user's full name to complete the order. Ignored for payments in Telegram Stars. */ + need_name?: boolean; + /** Pass True if you require the user's phone number to complete the order. Ignored for payments in Telegram Stars. */ + need_phone_number?: boolean; + /** Pass True if you require the user's email address to complete the order. Ignored for payments in Telegram Stars. */ + need_email?: boolean; + /** Pass True if you require the user's shipping address to complete the order. Ignored for payments in Telegram Stars. */ + need_shipping_address?: boolean; + /** Pass True if the user's phone number should be sent to provider. Ignored for payments in Telegram Stars. */ + send_phone_number_to_provider?: boolean; + /** Pass True if the user's email address should be sent to provider. Ignored for payments in Telegram Stars. */ + send_email_to_provider?: boolean; + /** Pass True if the final price depends on the shipping method. Ignored for payments in Telegram Stars. */ + is_flexible?: boolean; +} +/** Represents a result of an inline query that was chosen by the user and sent to their chat partner. + +Note: It is necessary to enable inline feedback via `@BotFather` in order to receive these objects in updates. */ +export interface ChosenInlineResult { + /** The unique identifier for the result that was chosen */ + result_id: string; + /** The user that chose the result */ + from: User; + /** Sender location, only for bots that require user location */ + location?: Location; + /** Identifier of the sent inline message. Available only if there is an inline keyboard attached to the message. Will be also received in callback queries and can be used to edit the message. */ + inline_message_id?: string; + /** The query that was used to obtain the result */ + query: string; +} +/** This object represents a button to be shown above inline query results. You must use exactly one of the optional fields. + +Example: An inline bot that sends YouTube videos can ask the user to connect the bot to their YouTube account to adapt search results accordingly. To do this, it displays a 'Connect your YouTube account' button above the results, or even before showing any. The user presses the button, switches to a private chat with the bot and, in doing so, passes a start parameter that instructs the bot to return an OAuth link. Once done, the bot can offer a switch_inline button so that the user can easily return to the chat where they wanted to use the bot's inline capabilities. */ +export interface InlineQueryResultsButton { + /** Label text on the button */ + text: string; + /** Description of the Web App that will be launched when the user presses the button. The Web App will be able to switch back to the inline mode using the method web_app_switch_inline_query inside the Web App. */ + web_app?: WebAppInfo; + /** Deep-linking parameter for the /start message sent to the bot when a user presses the button. 1-64 characters, only `A-Z`, `a-z`, `0-9`, `_` and `-` are allowed. */ + start_parameter?: string; +} diff --git a/sandbox/tgbot/node_modules/@grammyjs/types/langs.d.ts b/sandbox/tgbot/node_modules/@grammyjs/types/langs.d.ts new file mode 100644 index 0000000..5dd02b6 --- /dev/null +++ b/sandbox/tgbot/node_modules/@grammyjs/types/langs.d.ts @@ -0,0 +1,193 @@ +/** A two-letter ISO 639-1 language code. + * @see https://en.wikipedia.org/wiki/List_of_ISO_639_language_codes + * @see https://www.loc.gov/standards/iso639-2/php/code_list.php + */ +export type LanguageCode = typeof LanguageCodes[keyof typeof LanguageCodes]; +/** + * @see {@link LanguageCode} + */ +export declare const LanguageCodes: { + readonly Abkhazian: "ab"; + readonly Afar: "aa"; + readonly Afrikaans: "af"; + readonly Akan: "ak"; + readonly Albanian: "sq"; + readonly Amharic: "am"; + readonly Arabic: "ar"; + readonly Aragonese: "an"; + readonly Armenian: "hy"; + readonly Assamese: "as"; + readonly Avaric: "av"; + readonly Avestan: "ae"; + readonly Aymara: "ay"; + readonly Azerbaijani: "az"; + readonly Bambara: "bm"; + readonly Bashkir: "ba"; + readonly Basque: "eu"; + readonly Belarusian: "be"; + readonly Bengali: "bn"; + readonly Bislama: "bi"; + readonly Bosnian: "bs"; + readonly Breton: "br"; + readonly Bulgarian: "bg"; + readonly Burmese: "my"; + readonly Catalan: "ca"; + readonly Chamorro: "ch"; + readonly Chechen: "ce"; + readonly Chichewa: "ny"; + readonly Chinese: "zh"; + readonly ChurchSlavonic: "cu"; + readonly Chuvash: "cv"; + readonly Cornish: "kw"; + readonly Corsican: "co"; + readonly Cree: "cr"; + readonly Croatian: "hr"; + readonly Czech: "cs"; + readonly Danish: "da"; + readonly Divehi: "dv"; + readonly Dutch: "nl"; + readonly Dzongkha: "dz"; + readonly English: "en"; + readonly Esperanto: "eo"; + readonly Estonian: "et"; + readonly Ewe: "ee"; + readonly Faroese: "fo"; + readonly Fijian: "fj"; + readonly Finnish: "fi"; + readonly French: "fr"; + readonly WesternFrisian: "fy"; + readonly Fulah: "ff"; + readonly Gaelic: "gd"; + readonly Galician: "gl"; + readonly Ganda: "lg"; + readonly Georgian: "ka"; + readonly German: "de"; + readonly Greek: "el"; + readonly Kalaallisut: "kl"; + readonly Guarani: "gn"; + readonly Gujarati: "gu"; + readonly Haitian: "ht"; + readonly Hausa: "ha"; + readonly Hebrew: "he"; + readonly Herero: "hz"; + readonly Hindi: "hi"; + readonly HiriMotu: "ho"; + readonly Hungarian: "hu"; + readonly Icelandic: "is"; + readonly Ido: "io"; + readonly Igbo: "ig"; + readonly Indonesian: "id"; + readonly Interlingua: "ia"; + readonly Interlingue: "ie"; + readonly Inuktitut: "iu"; + readonly Inupiaq: "ik"; + readonly Irish: "ga"; + readonly Italian: "it"; + readonly Japanese: "ja"; + readonly Javanese: "jv"; + readonly Kannada: "kn"; + readonly Kanuri: "kr"; + readonly Kashmiri: "ks"; + readonly Kazakh: "kk"; + readonly CentralKhmer: "km"; + readonly Kikuyu: "ki"; + readonly Kinyarwanda: "rw"; + readonly Kirghiz: "ky"; + readonly Komi: "kv"; + readonly Kongo: "kg"; + readonly Korean: "ko"; + readonly Kuanyama: "kj"; + readonly Kurdish: "ku"; + readonly Lao: "lo"; + readonly Latin: "la"; + readonly Latvian: "lv"; + readonly Limburgan: "li"; + readonly Lingala: "ln"; + readonly Lithuanian: "lt"; + readonly LubaKatanga: "lu"; + readonly Luxembourgish: "lb"; + readonly Macedonian: "mk"; + readonly Malagasy: "mg"; + readonly Malay: "ms"; + readonly Malayalam: "ml"; + readonly Maltese: "mt"; + readonly Manx: "gv"; + readonly Maori: "mi"; + readonly Marathi: "mr"; + readonly Marshallese: "mh"; + readonly Mongolian: "mn"; + readonly Nauru: "na"; + readonly Navajo: "nv"; + readonly NorthNdebele: "nd"; + readonly SouthNdebele: "nr"; + readonly Ndonga: "ng"; + readonly Nepali: "ne"; + readonly Norwegian: "no"; + readonly NorwegianBokmål: "nb"; + readonly NorwegianNynorsk: "nn"; + readonly SichuanYi: "ii"; + readonly Occitan: "oc"; + readonly Ojibwa: "oj"; + readonly Oriya: "or"; + readonly Oromo: "om"; + readonly Ossetian: "os"; + readonly Pali: "pi"; + readonly Pashto: "ps"; + readonly Persian: "fa"; + readonly Polish: "pl"; + readonly Portuguese: "pt"; + readonly Punjabi: "pa"; + readonly Quechua: "qu"; + readonly Romanian: "ro"; + readonly Romansh: "rm"; + readonly Rundi: "rn"; + readonly Russian: "ru"; + readonly NorthernSami: "se"; + readonly Samoan: "sm"; + readonly Sango: "sg"; + readonly Sanskrit: "sa"; + readonly Sardinian: "sc"; + readonly Serbian: "sr"; + readonly Shona: "sn"; + readonly Sindhi: "sd"; + readonly Sinhala: "si"; + readonly Slovak: "sk"; + readonly Slovenian: "sl"; + readonly Somali: "so"; + readonly SouthernSotho: "st"; + readonly Spanish: "es"; + readonly Sundanese: "su"; + readonly Swahili: "sw"; + readonly Swati: "ss"; + readonly Swedish: "sv"; + readonly Tagalog: "tl"; + readonly Tahitian: "ty"; + readonly Tajik: "tg"; + readonly Tamil: "ta"; + readonly Tatar: "tt"; + readonly Telugu: "te"; + readonly Thai: "th"; + readonly Tibetan: "bo"; + readonly Tigrinya: "ti"; + readonly Tonga: "to"; + readonly Tsonga: "ts"; + readonly Tswana: "tn"; + readonly Turkish: "tr"; + readonly Turkmen: "tk"; + readonly Twi: "tw"; + readonly Uighur: "ug"; + readonly Ukrainian: "uk"; + readonly Urdu: "ur"; + readonly Uzbek: "uz"; + readonly Venda: "ve"; + readonly Vietnamese: "vi"; + readonly Volapük: "vo"; + readonly Walloon: "wa"; + readonly Welsh: "cy"; + readonly Wolof: "wo"; + readonly Xhosa: "xh"; + readonly Yiddish: "yi"; + readonly Yoruba: "yo"; + readonly Zhuang: "za"; + readonly Zulu: "zu"; +}; diff --git a/sandbox/tgbot/node_modules/@grammyjs/types/manage.d.ts b/sandbox/tgbot/node_modules/@grammyjs/types/manage.d.ts new file mode 100644 index 0000000..a6c4cca --- /dev/null +++ b/sandbox/tgbot/node_modules/@grammyjs/types/manage.d.ts @@ -0,0 +1,1058 @@ +import type { Audio, Location, Message, PhotoSize, ReactionType, Sticker } from "./message.js"; +import type { UniqueGiftColors } from "./payment.js"; +import type { Update } from "./update.js"; +/** Describes the current status of a webhook. */ +export interface WebhookInfo { + /** Webhook URL, may be empty if webhook is not set up */ + url?: string; + /** True, if a custom certificate was provided for webhook certificate checks */ + has_custom_certificate: boolean; + /** Number of updates awaiting delivery */ + pending_update_count: number; + /** Currently used webhook IP address */ + ip_address?: string; + /** Unix time for the most recent error that happened when trying to deliver an update via webhook */ + last_error_date?: number; + /** Error message in human-readable format for the most recent error that happened when trying to deliver an update via webhook */ + last_error_message?: string; + /** Unix time of the most recent error that happened when trying to synchronize available updates with Telegram datacenters */ + last_synchronization_error_date?: number; + /** The maximum allowed number of simultaneous HTTPS connections to the webhook for update delivery */ + max_connections?: number; + /** A list of update types the bot is subscribed to. Defaults to all update types except chat_member */ + allowed_updates?: Array>; +} +/** This object describes the types of gifts that can be gifted to a user or a chat. */ +export interface AcceptedGiftTypes { + /** True, if unlimited regular gifts are accepted */ + unlimited_gifts: boolean; + /** True, if limited regular gifts are accepted */ + limited_gifts: boolean; + /** True, if unique gifts or gifts that can be upgraded to unique for free are accepted */ + unique_gifts: boolean; + /** True, if a Telegram Premium subscription is accepted */ + premium_subscription: boolean; + /** True, if transfers of unique gifts from channels are accepted */ + gifts_from_channels: boolean; +} +/** This object represents a Telegram user or bot. */ +export interface User { + /** Unique identifier for this user or bot. */ + id: number; + /** True, if this user is a bot */ + is_bot: boolean; + /** User's or bot's first name */ + first_name: string; + /** User's or bot's last name */ + last_name?: string; + /** User's or bot's username */ + username?: string; + /** IETF language tag of the user's language */ + language_code?: string; + /** True, if this user is a Telegram Premium user */ + is_premium?: true; + /** True, if this user added the bot to the attachment menu */ + added_to_attachment_menu?: true; +} +/** This object represents a Telegram user or bot that was returned by `getMe`. */ +export interface UserFromGetMe extends User { + is_bot: true; + username: string; + /** True, if the bot can be invited to groups. Returned only in getMe. */ + can_join_groups: boolean; + /** True, if privacy mode is disabled for the bot. Returned only in getMe. */ + can_read_all_group_messages: boolean; + /** True, if the bot supports inline queries. Returned only in getMe. */ + supports_inline_queries: boolean; + /** True, if the bot can be connected to a Telegram Business account to receive its messages. Returned only in getMe. */ + can_connect_to_business: boolean; + /** True, if the bot has main Web App. Returned only in getMe. */ + has_main_web_app: boolean; + /** True, if the bot has forum topic mode enabled in private chats. Returned only in getMe. */ + has_topics_enabled: boolean; + /** True, if the bot allows users to create and delete topics in private chats. Returned only in getMe. */ + allows_users_to_create_topics: boolean; +} +/** Describes a service message about the chat owner leaving the chat. */ +export interface ChatOwnerLeft { + /** The user which will be the new owner of the chat if the previous owner does not return to the chat */ + new_owner?: User; +} +/** Describes a service message about an ownership change in the chat. */ +export interface ChatOwnerChanged { + /** The new owner of the chat */ + new_owner: User; +} +/** This object describes the rating of a user based on their Telegram Star spendings. */ +export interface UserRating { + /** Current level of the user, indicating their reliability when purchasing digital goods and services. A higher level suggests a more trustworthy customer; a negative level is likely reason for concern. */ + level: number; + /** Numerical value of the user's rating; the higher the rating, the better */ + rating: number; + /** The rating value required to get the current level */ + current_level_rating: number; + /** The rating value required to get to the next level; omitted if the maximum level was reached */ + next_level_rating?: number; +} +export declare namespace Chat { + /** Internal type for private chats */ + interface PrivateChat { + /** Unique identifier for this chat. */ + id: number; + /** Type of the chat, can be either “private”, “group”, “supergroup” or “channel” */ + type: "private"; + /** Title, for supergroups, channels and group chats */ + title?: undefined; + /** Username, for private chats, supergroups and channels if available */ + username?: string; + /** First name of the other party in a private chat */ + first_name: string; + /** Last name of the other party in a private chat */ + last_name?: string; + /** True, if the supergroup chat is a forum (has topics enabled) */ + is_forum?: undefined; + /** True, if the chat is the direct messages chat of a channel */ + is_direct_messages?: undefined; + } + /** Internal type for group chats */ + interface GroupChat { + /** Unique identifier for this chat. */ + id: number; + /** Type of the chat, can be either “private”, “group”, “supergroup” or “channel” */ + type: "group"; + /** Title, for supergroups, channels and group chats */ + title: string; + /** Username, for private chats, supergroups and channels if available */ + username?: undefined; + /** First name of the other party in a private chat */ + first_name?: undefined; + /** Last name of the other party in a private chat */ + last_name?: undefined; + /** True, if the supergroup chat is a forum (has topics enabled) */ + is_forum?: undefined; + /** True, if the chat is the direct messages chat of a channel */ + is_direct_messages?: undefined; + } + /** Internal type for supergroup chats */ + interface SupergroupChat { + /** Unique identifier for this chat. */ + id: number; + /** Type of the chat, can be either “private”, “group”, “supergroup” or “channel” */ + type: "supergroup"; + /** Title, for supergroups, channels and group chats */ + title: string; + /** Username, for private chats, supergroups and channels if available */ + username?: string; + /** First name of the other party in a private chat */ + first_name?: undefined; + /** Last name of the other party in a private chat */ + last_name?: undefined; + /** True, if the supergroup chat is a forum (has topics enabled) */ + is_forum?: true; + /** True, if the chat is the direct messages chat of a channel */ + is_direct_messages?: true; + } + /** Internal type for channel chats */ + interface ChannelChat { + /** Unique identifier for this chat. */ + id: number; + /** Type of the chat, can be either “private”, “group”, “supergroup” or “channel” */ + type: "channel"; + /** Title, for supergroups, channels and group chats */ + title: string; + /** Username, for private chats, supergroups and channels if available */ + username?: string; + /** First name of the other party in a private chat */ + first_name?: undefined; + /** Last name of the other party in a private chat */ + last_name?: undefined; + /** True, if the supergroup chat is a forum (has topics enabled) */ + is_forum?: undefined; + /** True, if the chat is the direct messages chat of a channel */ + is_direct_messages?: undefined; + } +} +/** This object represents a chat. */ +export type Chat = Chat.PrivateChat | Chat.GroupChat | Chat.SupergroupChat | Chat.ChannelChat; +export declare namespace ChatFullInfo { + /** Internal type for private chats */ + interface PrivateChat { + /** Unique identifier for this chat. */ + id: number; + /** Type of the chat, can be either “private”, “group”, “supergroup” or “channel” */ + type: "private"; + /** Title, for supergroups, channels and group chats */ + title?: undefined; + /** Username, for private chats, supergroups and channels if available */ + username?: string; + /** First name of the other party in a private chat */ + first_name: string; + /** Last name of the other party in a private chat */ + last_name?: string; + /** True, if the supergroup chat is a forum (has topics enabled) */ + is_forum?: undefined; + /** True, if the chat is the direct messages chat of a channel */ + is_direct_messages?: undefined; + /** Identifier of the accent color for the chat name and backgrounds of the chat photo, reply header, and link preview. See accent colors for more details. */ + accent_color_id: number; + /** The maximum number of reactions that can be set on a message in the chat */ + max_reaction_count: number; + /** Chat photo */ + photo?: ChatPhoto; + /** For private chats, the first audio added to the profile of the user */ + first_profile_audio?: Audio; + /** If non-empty, the list of all active chat usernames; for private chats, supergroups and channels */ + active_usernames?: string[]; + /** For private chats, the date of birth of the user */ + birthdate?: Birthdate; + /** For private chats with business accounts, the intro of the business */ + business_intro?: BusinessIntro; + /** For private chats with business accounts, the location of the business */ + business_location?: BusinessLocation; + /** For private chats with business accounts, the opening hours of the business */ + business_opening_hours?: BusinessOpeningHours; + /** For private chats, the rating of the user if any */ + rating?: UserRating; + /** The color scheme based on a unique gift that must be used for the chat's name, message replies and link previews */ + unique_gift_colors?: UniqueGiftColors; + /** For private chats, the personal channel of the user */ + personal_chat?: Chat; + /** Information about the corresponding channel chat; for direct messages chats only */ + parent_chat?: undefined; + /** List of available reactions allowed in the chat. If omitted, then all emoji reactions are allowed. */ + available_reactions?: ReactionType[]; + /** Custom emoji identifier of the emoji chosen by the chat for the reply header and link preview background */ + background_custom_emoji_id?: string; + /** Identifier of the accent color for the chat's profile background. See profile accent colors for more details. */ + profile_accent_color_id?: number; + /** Custom emoji identifier of the emoji chosen by the chat for its profile background */ + profile_background_custom_emoji_id?: string; + /** Custom emoji identifier of the emoji status of the chat or the other party in a private chat */ + emoji_status_custom_emoji_id?: string; + /** Expiration date of the emoji status of the chat or the other party in a private chat, in Unix time, if any */ + emoji_status_expiration_date?: number; + /** Bio of the other party in a private chat */ + bio?: string; + /** True, if privacy settings of the other party in the private chat allows to use tg://user?id= links only in chats with the user */ + has_private_forwards?: true; + /** True, if the privacy settings of the other party restrict sending voice and video note messages in the private chat */ + has_restricted_voice_and_video_messages?: true; + /** True, if users need to join the supergroup before they can send messages */ + join_to_send_messages?: undefined; + /** True, if all users directly joining the supergroup without using an invite link need to be approved by supergroup administrators */ + join_by_request?: undefined; + /** Description, for groups, supergroups and channel chats */ + description?: undefined; + /** Primary invite link, for groups, supergroups and channel chats */ + invite_link?: undefined; + /** The most recent pinned message (by sending date) */ + pinned_message?: Message; + /** Default chat member permissions, for groups and supergroups */ + permissions?: undefined; + /** Information about types of gifts that are accepted by the chat or by the corresponding user for private chats */ + accepted_gift_types: AcceptedGiftTypes; + /** True, if paid media messages can be sent or forwarded to the channel chat. The field is available only for channel chats. */ + can_send_paid_media?: undefined; + /** For supergroups, the minimum allowed delay between consecutive messages sent by each unprivileged user; in seconds */ + slow_mode_delay?: undefined; + /** For supergroups, the minimum number of boosts that a non-administrator user needs to add in order to ignore slow mode and chat permissions */ + unrestrict_boost_count?: undefined; + /** The time after which all messages sent to the chat will be automatically deleted; in seconds */ + message_auto_delete_time?: number; + /** True, if aggressive anti-spam checks are enabled in the supergroup. The field is only available to chat administrators. */ + has_aggressive_anti_spam_enabled?: undefined; + /** True, if non-administrators can only get the list of bots and administrators in the chat */ + has_hidden_members?: undefined; + /** True, if messages from the chat can't be forwarded to other chats */ + has_protected_content?: true; + /** True, if new chat members will have access to old messages; available only to chat administrators */ + has_visible_history?: undefined; + /** For supergroups, name of the group sticker set */ + sticker_set_name?: undefined; + /** True, if the bot can change the group sticker set */ + can_set_sticker_set?: undefined; + /** For supergroups, the name of the group's custom emoji sticker set. Custom emoji from this set can be used by all users and bots in the group. */ + custom_emoji_sticker_set_name?: undefined; + /** Unique identifier for the linked chat, i.e. the discussion group identifier for a channel and vice versa; for supergroups and channel chats. */ + linked_chat_id?: undefined; + /** For supergroups, the location to which the supergroup is connected */ + location?: undefined; + } + /** Internal type for group chats */ + interface GroupChat { + /** Unique identifier for this chat. */ + id: number; + /** Type of the chat, can be either “private”, “group”, “supergroup” or “channel” */ + type: "group"; + /** Title, for supergroups, channels and group chats */ + title: string; + /** Username, for private chats, supergroups and channels if available */ + username?: undefined; + /** First name of the other party in a private chat */ + first_name?: undefined; + /** Last name of the other party in a private chat */ + last_name?: undefined; + /** True, if the supergroup chat is a forum (has topics enabled) */ + is_forum?: undefined; + /** True, if the chat is the direct messages chat of a channel */ + is_direct_messages?: undefined; + /** Identifier of the accent color for the chat name and backgrounds of the chat photo, reply header, and link preview. See accent colors for more details. */ + accent_color_id: number; + /** The maximum number of reactions that can be set on a message in the chat */ + max_reaction_count: number; + /** Chat photo */ + photo?: ChatPhoto; + /** For private chats, the first audio added to the profile of the user */ + first_profile_audio?: undefined; + /** If non-empty, the list of all active chat usernames; for private chats, supergroups and channels */ + active_usernames?: undefined; + /** For private chats, the date of birth of the user */ + birthdate?: undefined; + /** For private chats with business accounts, the intro of the business */ + business_intro?: undefined; + /** For private chats with business accounts, the location of the business */ + business_location?: undefined; + /** For private chats with business accounts, the opening hours of the business */ + business_opening_hours?: undefined; + /** For private chats, the rating of the user if any */ + rating?: undefined; + /** The color scheme based on a unique gift that must be used for the chat's name, message replies and link previews */ + unique_gift_colors?: UniqueGiftColors; + /** For private chats, the personal channel of the user */ + personal_chat?: undefined; + /** Information about the corresponding channel chat; for direct messages chats only */ + parent_chat?: undefined; + /** List of available reactions allowed in the chat. If omitted, then all emoji reactions are allowed. */ + available_reactions?: ReactionType[]; + /** Custom emoji identifier of the emoji chosen by the chat for the reply header and link preview background */ + background_custom_emoji_id?: string; + /** Identifier of the accent color for the chat's profile background. See profile accent colors for more details. */ + profile_accent_color_id?: number; + /** Custom emoji identifier of the emoji chosen by the chat for its profile background */ + profile_background_custom_emoji_id?: string; + /** Custom emoji identifier of the emoji status of the chat or the other party in a private chat */ + emoji_status_custom_emoji_id?: string; + /** Expiration date of the emoji status of the chat or the other party in a private chat, in Unix time, if any */ + emoji_status_expiration_date?: number; + /** Bio of the other party in a private chat */ + bio?: undefined; + /** True, if privacy settings of the other party in the private chat allows to use tg://user?id= links only in chats with the user */ + has_private_forwards?: undefined; + /** True, if the privacy settings of the other party restrict sending voice and video note messages in the private chat */ + has_restricted_voice_and_video_messages?: undefined; + /** True, if users need to join the supergroup before they can send messages */ + join_to_send_messages?: undefined; + /** True, if all users directly joining the supergroup without using an invite link need to be approved by supergroup administrators */ + join_by_request?: undefined; + /** Description, for groups, supergroups and channel chats */ + description?: string; + /** Primary invite link, for groups, supergroups and channel chats */ + invite_link?: string; + /** The most recent pinned message (by sending date) */ + pinned_message?: Message; + /** Default chat member permissions, for groups and supergroups */ + permissions?: ChatPermissions; + /** Information about types of gifts that are accepted by the chat or by the corresponding user for private chats */ + accepted_gift_types: AcceptedGiftTypes; + /** True, if paid media messages can be sent or forwarded to the channel chat. The field is available only for channel chats. */ + can_send_paid_media?: undefined; + /** For supergroups, the minimum allowed delay between consecutive messages sent by each unprivileged user; in seconds */ + slow_mode_delay?: undefined; + /** For supergroups, the minimum number of boosts that a non-administrator user needs to add in order to ignore slow mode and chat permissions */ + unrestrict_boost_count?: undefined; + /** The time after which all messages sent to the chat will be automatically deleted; in seconds */ + message_auto_delete_time?: number; + /** True, if aggressive anti-spam checks are enabled in the supergroup. The field is only available to chat administrators. */ + has_aggressive_anti_spam_enabled?: undefined; + /** True, if non-administrators can only get the list of bots and administrators in the chat */ + has_hidden_members?: true; + /** True, if messages from the chat can't be forwarded to other chats */ + has_protected_content?: true; + /** True, if new chat members will have access to old messages; available only to chat administrators */ + has_visible_history?: true; + /** For supergroups, name of the group sticker set */ + sticker_set_name?: undefined; + /** True, if the bot can change the group sticker set */ + can_set_sticker_set?: true; + /** For supergroups, the name of the group's custom emoji sticker set. Custom emoji from this set can be used by all users and bots in the group. */ + custom_emoji_sticker_set_name?: undefined; + /** Unique identifier for the linked chat, i.e. the discussion group identifier for a channel and vice versa; for supergroups and channel chats. */ + linked_chat_id?: undefined; + /** For supergroups, the location to which the supergroup is connected */ + location?: undefined; + } + /** Internal type for supergroup chats */ + interface SupergroupChat { + /** Unique identifier for this chat. */ + id: number; + /** Type of the chat, can be either “private”, “group”, “supergroup” or “channel” */ + type: "supergroup"; + /** Title, for supergroups, channels and group chats */ + title: string; + /** Username, for private chats, supergroups and channels if available */ + username?: string; + /** First name of the other party in a private chat */ + first_name?: undefined; + /** Last name of the other party in a private chat */ + last_name?: undefined; + /** True, if the supergroup chat is a forum (has topics enabled) */ + is_forum?: true; + /** True, if the chat is the direct messages chat of a channel */ + is_direct_messages?: true; + /** Identifier of the accent color for the chat name and backgrounds of the chat photo, reply header, and link preview. See accent colors for more details. */ + accent_color_id: number; + /** The maximum number of reactions that can be set on a message in the chat */ + max_reaction_count: number; + /** Chat photo */ + photo?: ChatPhoto; + /** For private chats, the first audio added to the profile of the user */ + first_profile_audio?: undefined; + /** If non-empty, the list of all active chat usernames; for private chats, supergroups and channels */ + active_usernames?: string[]; + /** For private chats, the date of birth of the user */ + birthdate?: undefined; + /** For private chats with business accounts, the intro of the business */ + business_intro?: undefined; + /** For private chats with business accounts, the location of the business */ + business_location?: undefined; + /** For private chats with business accounts, the opening hours of the business */ + business_opening_hours?: undefined; + /** For private chats, the rating of the user if any */ + rating?: undefined; + /** The color scheme based on a unique gift that must be used for the chat's name, message replies and link previews */ + unique_gift_colors?: UniqueGiftColors; + /** For private chats, the personal channel of the user */ + personal_chat?: undefined; + /** Information about the corresponding channel chat; for direct messages chats only */ + parent_chat?: Chat.ChannelChat; + /** List of available reactions allowed in the chat. If omitted, then all emoji reactions are allowed. */ + available_reactions?: ReactionType[]; + /** Custom emoji identifier of the emoji chosen by the chat for the reply header and link preview background */ + background_custom_emoji_id?: string; + /** Identifier of the accent color for the chat's profile background. See profile accent colors for more details. */ + profile_accent_color_id?: number; + /** Custom emoji identifier of the emoji chosen by the chat for its profile background */ + profile_background_custom_emoji_id?: string; + /** Custom emoji identifier of the emoji status of the chat or the other party in a private chat */ + emoji_status_custom_emoji_id?: string; + /** Expiration date of the emoji status of the chat or the other party in a private chat, in Unix time, if any */ + emoji_status_expiration_date?: number; + /** Bio of the other party in a private chat */ + bio?: string; + /** True, if privacy settings of the other party in the private chat allows to use tg://user?id= links only in chats with the user */ + has_private_forwards?: undefined; + /** True, if the privacy settings of the other party restrict sending voice and video note messages in the private chat */ + has_restricted_voice_and_video_messages?: undefined; + /** True, if users need to join the supergroup before they can send messages */ + join_to_send_messages?: true; + /** True, if all users directly joining the supergroup without using an invite link need to be approved by supergroup administrators */ + join_by_request?: true; + /** Description, for groups, supergroups and channel chats */ + description?: string; + /** Primary invite link, for groups, supergroups and channel chats */ + invite_link?: string; + /** The most recent pinned message (by sending date) */ + pinned_message?: Message; + /** Default chat member permissions, for groups and supergroups */ + permissions?: ChatPermissions; + /** Information about types of gifts that are accepted by the chat or by the corresponding user for private chats */ + accepted_gift_types: AcceptedGiftTypes; + /** True, if paid media messages can be sent or forwarded to the channel chat. The field is available only for channel chats. */ + can_send_paid_media?: undefined; + /** For supergroups, the minimum allowed delay between consecutive messages sent by each unprivileged user; in seconds */ + slow_mode_delay?: number; + /** For supergroups, the minimum number of boosts that a non-administrator user needs to add in order to ignore slow mode and chat permissions */ + unrestrict_boost_count?: number; + /** The time after which all messages sent to the chat will be automatically deleted; in seconds */ + message_auto_delete_time?: number; + /** True, if aggressive anti-spam checks are enabled in the supergroup. The field is only available to chat administrators. */ + has_aggressive_anti_spam_enabled?: true; + /** True, if non-administrators can only get the list of bots and administrators in the chat */ + has_hidden_members?: true; + /** True, if messages from the chat can't be forwarded to other chats */ + has_protected_content?: true; + /** True, if new chat members will have access to old messages; available only to chat administrators */ + has_visible_history?: true; + /** For supergroups, name of the group sticker set */ + sticker_set_name?: string; + /** True, if the bot can change the group sticker set */ + can_set_sticker_set?: true; + /** For supergroups, the name of the group's custom emoji sticker set. Custom emoji from this set can be used by all users and bots in the group. */ + custom_emoji_sticker_set_name?: string; + /** Unique identifier for the linked chat, i.e. the discussion group identifier for a channel and vice versa; for supergroups and channel chats. */ + linked_chat_id?: number; + /** For supergroups, the location to which the supergroup is connected */ + location?: ChatLocation; + } + /** Internal type for channel chats */ + interface ChannelChat { + /** Unique identifier for this chat. */ + id: number; + /** Type of the chat, can be either “private”, “group”, “supergroup” or “channel” */ + type: "channel"; + /** Title, for supergroups, channels and group chats */ + title: string; + /** Username, for private chats, supergroups and channels if available */ + username?: string; + /** First name of the other party in a private chat */ + first_name?: undefined; + /** Last name of the other party in a private chat */ + last_name?: undefined; + /** True, if the supergroup chat is a forum (has topics enabled) */ + is_forum?: undefined; + /** True, if the chat is the direct messages chat of a channel */ + is_direct_messages?: undefined; + /** Identifier of the accent color for the chat name and backgrounds of the chat photo, reply header, and link preview. See accent colors for more details. */ + accent_color_id: number; + /** The maximum number of reactions that can be set on a message in the chat */ + max_reaction_count: number; + /** Chat photo */ + photo?: ChatPhoto; + /** For private chats, the first audio added to the profile of the user */ + first_profile_audio?: undefined; + /** If non-empty, the list of all active chat usernames; for private chats, supergroups and channels */ + active_usernames?: string[]; + /** For private chats, the date of birth of the user */ + birthdate?: undefined; + /** For private chats with business accounts, the intro of the business */ + business_intro?: undefined; + /** For private chats with business accounts, the location of the business */ + business_location?: undefined; + /** For private chats with business accounts, the opening hours of the business */ + business_opening_hours?: undefined; + /** For private chats, the rating of the user if any */ + rating?: undefined; + /** The color scheme based on a unique gift that must be used for the chat's name, message replies and link previews */ + unique_gift_colors?: UniqueGiftColors; + /** For private chats, the personal channel of the user */ + personal_chat?: undefined; + /** Information about the corresponding channel chat; for direct messages chats only */ + parent_chat?: undefined; + /** List of available reactions allowed in the chat. If omitted, then all emoji reactions are allowed. */ + available_reactions?: ReactionType[]; + /** Custom emoji identifier of the emoji chosen by the chat for the reply header and link preview background */ + background_custom_emoji_id?: string; + /** Identifier of the accent color for the chat's profile background. See profile accent colors for more details. */ + profile_accent_color_id?: number; + /** Custom emoji identifier of the emoji chosen by the chat for its profile background */ + profile_background_custom_emoji_id?: string; + /** Custom emoji identifier of the emoji status of the chat or the other party in a private chat */ + emoji_status_custom_emoji_id?: string; + /** Expiration date of the emoji status of the chat or the other party in a private chat, in Unix time, if any */ + emoji_status_expiration_date?: number; + /** Bio of the other party in a private chat */ + bio?: undefined; + /** True, if privacy settings of the other party in the private chat allows to use tg://user?id= links only in chats with the user */ + has_private_forwards?: undefined; + /** True, if the privacy settings of the other party restrict sending voice and video note messages in the private chat */ + has_restricted_voice_and_video_messages?: undefined; + /** True, if users need to join the supergroup before they can send messages */ + join_to_send_messages?: true; + /** True, if all users directly joining the supergroup without using an invite link need to be approved by supergroup administrators */ + join_by_request?: undefined; + /** Description, for groups, supergroups and channel chats */ + description?: string; + /** Primary invite link, for groups, supergroups and channel chats */ + invite_link?: string; + /** The most recent pinned message (by sending date) */ + pinned_message?: Message; + /** Default chat member permissions, for groups and supergroups */ + permissions?: undefined; + /** Information about types of gifts that are accepted by the chat or by the corresponding user for private chats */ + accepted_gift_types: AcceptedGiftTypes; + /** True, if paid media messages can be sent or forwarded to the channel chat. The field is available only for channel chats. */ + can_send_paid_media?: true; + /** For supergroups, the minimum allowed delay between consecutive messages sent by each unprivileged user; in seconds */ + slow_mode_delay?: undefined; + /** For supergroups, the minimum number of boosts that a non-administrator user needs to add in order to ignore slow mode and chat permissions */ + unrestrict_boost_count?: undefined; + /** The time after which all messages sent to the chat will be automatically deleted; in seconds */ + message_auto_delete_time?: number; + /** True, if aggressive anti-spam checks are enabled in the supergroup. The field is only available to chat administrators. */ + has_aggressive_anti_spam_enabled?: undefined; + /** True, if non-administrators can only get the list of bots and administrators in the chat */ + has_hidden_members?: undefined; + /** True, if messages from the chat can't be forwarded to other chats */ + has_protected_content?: true; + /** True, if new chat members will have access to old messages; available only to chat administrators */ + has_visible_history?: undefined; + /** For supergroups, name of the group sticker set */ + sticker_set_name?: undefined; + /** True, if the bot can change the group sticker set */ + can_set_sticker_set?: undefined; + /** For supergroups, the name of the group's custom emoji sticker set. Custom emoji from this set can be used by all users and bots in the group. */ + custom_emoji_sticker_set_name?: undefined; + /** Unique identifier for the linked chat, i.e. the discussion group identifier for a channel and vice versa; for supergroups and channel chats. */ + linked_chat_id?: number; + /** For supergroups, the location to which the supergroup is connected */ + location?: undefined; + } +} +/** This object contains full information about a chat. */ +export type ChatFullInfo = ChatFullInfo.PrivateChat | ChatFullInfo.GroupChat | ChatFullInfo.SupergroupChat | ChatFullInfo.ChannelChat; +/** @deprecated use ChatFullInfo instead */ +export type ChatFromGetChat = ChatFullInfo; +/** This object represent a user's profile pictures. */ +export interface UserProfilePhotos { + /** Total number of profile pictures the target user has */ + total_count: number; + /** Requested profile pictures (in up to 4 sizes each) */ + photos: PhotoSize[][]; +} +/** This object represents the audios displayed on a user's profile. */ +export interface UserProfileAudios { + /** Total number of profile audios for the target user */ + total_count: number; + /** Requested profile audios */ + audios: Audio[]; +} +/** This object represents a chat photo. */ +export interface ChatPhoto { + /** File identifier of small (160x160) chat photo. This file_id can be used only for photo download and only for as long as the photo is not changed. */ + small_file_id: string; + /** Unique file identifier of small (160x160) chat photo, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file. */ + small_file_unique_id: string; + /** File identifier of big (640x640) chat photo. This file_id can be used only for photo download and only for as long as the photo is not changed. */ + big_file_id: string; + /** Unique file identifier of big (640x640) chat photo, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file. */ + big_file_unique_id: string; +} +/** Represents an invite link for a chat. */ +export interface ChatInviteLink { + /** The invite link. If the link was created by another chat administrator, then the second part of the link will be replaced with "...". */ + invite_link: string; + /** Creator of the link */ + creator: User; + /** True, if users joining the chat via the link need to be approved by chat administrators */ + creates_join_request: boolean; + /** True, if the link is primary */ + is_primary: boolean; + /** True, if the link is revoked */ + is_revoked: boolean; + /** Invite link name */ + name?: string; + /** Point in time (Unix timestamp) when the link will expire or has been expired */ + expire_date?: number; + /** The maximum number of users that can be members of the chat simultaneously after joining the chat via this invite link; 1-99999 */ + member_limit?: number; + /** Number of pending join requests created using this link */ + pending_join_request_count?: number; + /** The number of seconds the subscription will be active for before the next payment */ + subscription_period?: number; + /** The amount of Telegram Stars a user must pay initially and after each subsequent subscription period to be a member of the chat using the link */ + subscription_price?: number; +} +/** Represents the rights of an administrator in a chat. */ +export interface ChatAdministratorRights { + /** True, if the user's presence in the chat is hidden */ + is_anonymous: boolean; + /** True, if the administrator can access the chat event log, get boost list, see hidden supergroup and channel members, report spam messages, ignore slow mode, and send messages to the chat without paying Telegram Stars. Implied by any other administrator privilege. */ + can_manage_chat: boolean; + /** True, if the administrator can delete messages of other users */ + can_delete_messages: boolean; + /** True, if the administrator can manage video chats */ + can_manage_video_chats: boolean; + /** True, if the administrator can restrict, ban or unban chat members, or access supergroup statistics */ + can_restrict_members: boolean; + /** True, if the administrator can add new administrators with a subset of their own privileges or demote administrators that they have promoted, directly or indirectly (promoted by administrators that were appointed by the user) */ + can_promote_members: boolean; + /** True, if the user is allowed to change the chat title, photo and other settings */ + can_change_info: boolean; + /** True, if the user is allowed to invite new users to the chat */ + can_invite_users: boolean; + /** True, if the administrator can post stories to the chat */ + can_post_stories: boolean; + /** True, if the administrator can edit stories posted by other users, post stories to the chat page, pin chat stories, and access the chat's story archive */ + can_edit_stories: boolean; + /** True, if the administrator can delete stories posted by other users */ + can_delete_stories: boolean; + /** True, if the administrator can post messages in the channel, approve suggested posts, or access channel statistics; for channels only */ + can_post_messages?: boolean; + /** True, if the administrator can edit messages of other users and can pin messages; for channels only */ + can_edit_messages?: boolean; + /** True, if the user is allowed to pin messages; for groups and supergroups only */ + can_pin_messages?: boolean; + /** True, if the user is allowed to create, rename, close, and reopen forum topics; for supergroups only */ + can_manage_topics?: boolean; + /** True, if the administrator can manage direct messages of the channel and decline suggested posts; for channels only */ + can_manage_direct_messages?: boolean; +} +/** This object represents changes in the status of a chat member. */ +export interface ChatMemberUpdated { + /** Chat the user belongs to */ + chat: Chat; + /** Performer of the action, which resulted in the change */ + from: User; + /** Date the change was done in Unix time */ + date: number; + /** Previous information about the chat member */ + old_chat_member: ChatMember; + /** New information about the chat member */ + new_chat_member: ChatMember; + /** Chat invite link, which was used by the user to join the chat; for joining by invite link events only. */ + invite_link?: ChatInviteLink; + /** True, if the user joined the chat after sending a direct join request without using an invite link without using an invite link and being approved by an administrator */ + via_join_request?: boolean; + /** True, if the user joined the chat via a chat folder invite link */ + via_chat_folder_invite_link?: boolean; +} +/** This object contains information about one member of a chat. Currently, the following 6 types of chat members are supported: +- ChatMemberOwner +- ChatMemberAdministrator +- ChatMemberMember +- ChatMemberRestricted +- ChatMemberLeft +- ChatMemberBanned */ +export type ChatMember = ChatMemberOwner | ChatMemberAdministrator | ChatMemberMember | ChatMemberRestricted | ChatMemberLeft | ChatMemberBanned; +/** Represents a chat member that owns the chat and has all administrator privileges. */ +export interface ChatMemberOwner { + /** The member's status in the chat, always “creator” */ + status: "creator"; + /** Information about the user */ + user: User; + /** True, if the user's presence in the chat is hidden */ + is_anonymous: boolean; + /** Custom title for this user */ + custom_title?: string; +} +/** Represents a chat member that has some additional privileges. */ +export interface ChatMemberAdministrator { + /** The member's status in the chat, always “administrator” */ + status: "administrator"; + /** Information about the user */ + user: User; + /** True, if the bot is allowed to edit administrator privileges of that user */ + can_be_edited: boolean; + /** True, if the user's presence in the chat is hidden */ + is_anonymous: boolean; + /** True, if the administrator can access the chat event log, get boost list, see hidden supergroup and channel members, report spam messages, ignore slow mode, and send messages to the chat without paying Telegram Stars. Implied by any other administrator privilege. */ + can_manage_chat: boolean; + /** True, if the administrator can delete messages of other users */ + can_delete_messages: boolean; + /** True, if the administrator can manage video chats */ + can_manage_video_chats: boolean; + /** True, if the administrator can restrict, ban or unban chat members, or access supergroup statistics */ + can_restrict_members: boolean; + /** True, if the administrator can add new administrators with a subset of their own privileges or demote administrators that they have promoted, directly or indirectly (promoted by administrators that were appointed by the user) */ + can_promote_members: boolean; + /** True, if the user is allowed to change the chat title, photo and other settings */ + can_change_info: boolean; + /** True, if the user is allowed to invite new users to the chat */ + can_invite_users: boolean; + /** True, if the administrator can post stories to the chat */ + can_post_stories: boolean; + /** True, if the administrator can edit stories posted by other users, post stories to the chat page, pin chat stories, and access the chat's story archive */ + can_edit_stories: boolean; + /** True, if the administrator can delete stories posted by other users */ + can_delete_stories: boolean; + /** True, if the administrator can post messages in the channel, approve suggested posts, or access channel statistics; for channels only */ + can_post_messages?: boolean; + /** True, if the administrator can edit messages of other users and can pin messages; for channels only */ + can_edit_messages?: boolean; + /** True, if the user is allowed to pin messages; for groups and supergroups only */ + can_pin_messages?: boolean; + /** True, if the user is allowed to create, rename, close, and reopen forum topics; for supergroups only */ + can_manage_topics?: boolean; + /** True, if the administrator can manage direct messages of the channel and decline suggested posts; for channels only */ + can_manage_direct_messages?: boolean; + /** Custom title for this user */ + custom_title?: string; +} +/** Represents a chat member that has no additional privileges or restrictions. */ +export interface ChatMemberMember { + /** The member's status in the chat, always “member” */ + status: "member"; + /** Information about the user */ + user: User; + /** Date when the user's subscription will expire; Unix time */ + until_date?: number; +} +/** Represents a chat member that is under certain restrictions in the chat. Supergroups only. */ +export interface ChatMemberRestricted { + /** The member's status in the chat, always “restricted” */ + status: "restricted"; + /** Information about the user */ + user: User; + /** True, if the user is a member of the chat at the moment of the request */ + is_member: boolean; + /** True, if the user is allowed to send text messages, contacts, giveaways, giveaway winners, invoices, locations and venues */ + can_send_messages: boolean; + /** True, if the user is allowed to send audios */ + can_send_audios: boolean; + /** True, if the user is allowed to send documents */ + can_send_documents: boolean; + /** True, if the user is allowed to send photos */ + can_send_photos: boolean; + /** True, if the user is allowed to send videos */ + can_send_videos: boolean; + /** True, if the user is allowed to send video notes */ + can_send_video_notes: boolean; + /** True, if the user is allowed to send voice notes */ + can_send_voice_notes: boolean; + /** True, if the user is allowed to send polls and checklists */ + can_send_polls: boolean; + /** True, if the user is allowed to send animations, games, stickers and use inline bots */ + can_send_other_messages: boolean; + /** True, if the user is allowed to add web page previews to their messages */ + can_add_web_page_previews: boolean; + /** True, if the user is allowed to change the chat title, photo and other settings */ + can_change_info: boolean; + /** True, if the user is allowed to invite new users to the chat */ + can_invite_users: boolean; + /** True, if the user is allowed to pin messages */ + can_pin_messages: boolean; + /** True, if the user is allowed to create forum topics */ + can_manage_topics: boolean; + /** Date when restrictions will be lifted for this user; Unix time. If 0, then the user is restricted forever */ + until_date: number; +} +/** Represents a chat member that isn't currently a member of the chat, but may join it themselves. */ +export interface ChatMemberLeft { + /** The member's status in the chat, always “left” */ + status: "left"; + /** Information about the user */ + user: User; +} +/** Represents a chat member that was banned in the chat and can't return to the chat or view chat messages. */ +export interface ChatMemberBanned { + /** The member's status in the chat, always “kicked” */ + status: "kicked"; + /** Information about the user */ + user: User; + /** Date when restrictions will be lifted for this user; Unix time. If 0, then the user is banned forever */ + until_date: number; +} +/** Represents a join request sent to a chat. */ +export interface ChatJoinRequest { + /** Chat to which the request was sent */ + chat: Chat.SupergroupChat | Chat.ChannelChat; + /** User that sent the join request */ + from: User; + /** Identifier of a private chat with the user who sent the join request. The bot can use this identifier for 5 minutes to send messages until the join request is processed, assuming no other administrator contacted the user. */ + user_chat_id: number; + /** Date the request was sent in Unix time */ + date: number; + /** Bio of the user. */ + bio?: string; + /** Chat invite link that was used by the user to send the join request */ + invite_link?: ChatInviteLink; +} +/** Describes actions that a non-administrator user is allowed to take in a chat. */ +export interface ChatPermissions { + /** True, if the user is allowed to send text messages, contacts, giveaways, giveaway winners, invoices, locations and venues */ + can_send_messages?: boolean; + /** True, if the user is allowed to send audios */ + can_send_audios?: boolean; + /** True, if the user is allowed to send documents */ + can_send_documents?: boolean; + /** True, if the user is allowed to send photos */ + can_send_photos?: boolean; + /** True, if the user is allowed to send videos */ + can_send_videos?: boolean; + /** True, if the user is allowed to send video notes */ + can_send_video_notes?: boolean; + /** True, if the user is allowed to send voice notes */ + can_send_voice_notes?: boolean; + /** True, if the user is allowed to send polls and checklists */ + can_send_polls?: boolean; + /** True, if the user is allowed to send animations, games, stickers and use inline bots */ + can_send_other_messages?: boolean; + /** True, if the user is allowed to add web page previews to their messages */ + can_add_web_page_previews?: boolean; + /** True, if the user is allowed to change the chat title, photo and other settings. Ignored in public supergroups */ + can_change_info?: boolean; + /** True, if the user is allowed to invite new users to the chat */ + can_invite_users?: boolean; + /** True, if the user is allowed to pin messages. Ignored in public supergroups */ + can_pin_messages?: boolean; + /** True, if the user is allowed to create forum topics. If omitted defaults to the value of can_pin_messages */ + can_manage_topics?: boolean; +} +/** Describes the birthdate of a user. */ +export interface Birthdate { + /** Day of the user's birth; 1-31 */ + day: number; + /** Month of the user's birth; 1-12 */ + month: number; + /** Year of the user's birth */ + year?: number; +} +/** Contains information about the start page settings of a Telegram Business account. */ +export interface BusinessIntro { + /** Title text of the business intro */ + title?: string; + /** Message text of the business intro */ + message?: string; + /** Sticker of the business intro */ + sticker?: Sticker; +} +/** Contains information about the location of a Telegram Business account. */ +export interface BusinessLocation { + /** Address of the business */ + address: string; + /** Location of the business */ + location?: Location; +} +/** Describes an interval of time during which a business is open. */ +export interface BusinessOpeningHoursInterval { + /** The minute's sequence number in a week, starting on Monday, marking the start of the time interval during which the business is open; 0 - 7 * 24 * 60 */ + opening_minute: number; + /** The minute's sequence number in a week, starting on Monday, marking the end of the time interval during which the business is open; 0 - 8 * 24 * 60 */ + closing_minute: number; +} +/** Describes the opening hours of a business. */ +export interface BusinessOpeningHours { + /** Unique name of the time zone for which the opening hours are defined */ + time_zone_name: string; + /** List of time intervals describing business opening hours */ + opening_hours: BusinessOpeningHoursInterval[]; +} +/** Represents a location to which a chat is connected. */ +export interface ChatLocation { + /** The location to which the supergroup is connected. Can't be a live location. */ + location: Location; + /** Location address; 1-64 characters, as defined by the chat owner */ + address: string; +} +/** This object represents a forum topic. */ +export interface ForumTopic { + /** Unique identifier of the forum topic */ + message_thread_id: number; + /** Name of the topic */ + name: string; + /** True, if the name of the topic wasn't specified explicitly by its creator and likely needs to be changed by the bot */ + is_name_implicit?: true; + /** Color of the topic icon in RGB format */ + icon_color: number; + /** Unique identifier of the custom emoji shown as the topic icon */ + icon_custom_emoji_id?: string; +} +/** This object represents a bot command. */ +export interface BotCommand { + /** Text of the command; 1-32 characters. Can contain only lowercase English letters, digits and underscores. */ + command: string; + /** Description of the command; 1-256 characters. */ + description: string; +} +/** This object describes the source of a chat boost. It can be one of + +- ChatBoostSourcePremium +- ChatBoostSourceGiftCode +- ChatBoostSourceGiveaway */ +export type ChatBoostSource = ChatBoostSourcePremium | ChatBoostSourceGiftCode | ChatBoostSourceGiveaway; +/** The boost was obtained by subscribing to Telegram Premium or by gifting a Telegram Premium subscription to another user. */ +export interface ChatBoostSourcePremium { + /** Source of the boost, always “premium” */ + source: "premium"; + /** User that boosted the chat */ + user: User; +} +/** The boost was obtained by the creation of Telegram Premium gift codes to boost a chat. Each such code boosts the chat 4 times for the duration of the corresponding Telegram Premium subscription. */ +export interface ChatBoostSourceGiftCode { + /** Source of the boost, always “gift_code” */ + source: "gift_code"; + /** User for which the gift code was created */ + user: User; +} +/** The boost was obtained by the creation of a Telegram Premium or a Telegram Star giveaway. This boosts the chat 4 times for the duration of the corresponding Telegram Premium subscription for Telegram Premium giveaways and prize_star_count / 500 times for one year for Telegram Star giveaways. */ +export interface ChatBoostSourceGiveaway { + /** Source of the boost, always “giveaway” */ + source: "giveaway"; + /** Identifier of a message in the chat with the giveaway; the message could have been deleted already */ + giveaway_message_id: number; + /** User that won the prize in the giveaway if any; for Telegram Premium giveaways only */ + user?: User; + /** The number of Telegram Stars to be split between giveaway winners; for Telegram Star giveaways only */ + prize_star_count?: number; + /** True, if the giveaway was completed, but there was no user to win the prize */ + is_unclaimed?: true; +} +/** This object contains information about a chat boost. */ +export interface ChatBoost { + /** Unique identifier of the boost */ + boost_id: string; + /** Point in time (Unix timestamp) when the chat was boosted */ + add_date: number; + /** Point in time (Unix timestamp) when the boost will automatically expire, unless the booster's Telegram Premium subscription is prolonged */ + expiration_date: number; + /** Source of the added boost */ + source: ChatBoostSource; +} +/** This object represents a boost added to a chat or changed. */ +export interface ChatBoostUpdated { + /** Chat which was boosted */ + chat: Chat; + /** Information about the chat boost */ + boost: ChatBoost; +} +/** This object represents a boost removed from a chat. */ +export interface ChatBoostRemoved { + /** Chat which was boosted */ + chat: Chat; + /** Unique identifier of the boost */ + boost_id: string; + /** Point in time (Unix timestamp) when the boost was removed */ + remove_date: number; + /** Source of the removed boost */ + source: ChatBoostSource; +} +/** This object represents a list of boosts added to a chat by a user. */ +export interface UserChatBoosts { + /** The list of boosts added to the chat by the user */ + boosts: ChatBoost[]; +} +/** Represents the rights of a business bot. */ +export interface BusinessBotRights { + /** True, if the bot can send and edit messages in the private chats that had incoming messages in the last 24 hours */ + can_reply?: true; + /** True, if the bot can mark incoming private messages as read */ + can_read_messages?: true; + /** True, if the bot can delete messages sent by the bot */ + can_delete_outgoing_messages?: true; + /** True, if the bot can delete all private messages in managed chats */ + can_delete_all_messages?: true; + /** True, if the bot can edit the first and last name of the business account */ + can_edit_name?: true; + /** True, if the bot can edit the bio of the business account */ + can_edit_bio?: true; + /** True, if the bot can edit the profile photo of the business account */ + can_edit_profile_photo?: true; + /** True, if the bot can edit the username of the business account */ + can_edit_username?: true; + /** True, if the bot can change the privacy settings pertaining to gifts for the business account */ + can_change_gift_settings?: true; + /** True, if the bot can view gifts and the amount of Telegram Stars owned by the business account */ + can_view_gifts_and_stars?: true; + /** True, if the bot can convert regular gifts owned by the business account to Telegram Stars */ + can_convert_gifts_to_stars?: true; + /** True, if the bot can transfer and upgrade gifts owned by the business account */ + can_transfer_and_upgrade_gifts?: true; + /** True, if the bot can transfer Telegram Stars received by the business account to its own account, or use them to upgrade and transfer gifts */ + can_transfer_stars?: true; + /** True, if the bot can post, edit and delete stories on behalf of the business account */ + can_manage_stories?: true; +} +/** Describes the connection of the bot with a business account. */ +export interface BusinessConnection { + /** Unique identifier of the business connection */ + id: string; + /** Business account user that created the business connection */ + user: User; + /** Identifier of a private chat with the user who created the business connection. */ + user_chat_id: number; + /** Date the connection was established in Unix time */ + date: number; + /** Rights of the business bot */ + rights?: BusinessBotRights; + /** True, if the connection is active */ + is_enabled: boolean; +} +/** This object is received when messages are deleted from a connected business account. */ +export interface BusinessMessagesDeleted { + /** Unique identifier of the business connection */ + business_connection_id: string; + /** Information about a chat in the business account. The bot may not have access to the chat or the corresponding user. */ + chat: Chat.PrivateChat; + /** The list of identifiers of deleted messages in the chat of the business account */ + message_ids: number[]; +} diff --git a/sandbox/tgbot/node_modules/@grammyjs/types/markup.d.ts b/sandbox/tgbot/node_modules/@grammyjs/types/markup.d.ts new file mode 100644 index 0000000..e72710a --- /dev/null +++ b/sandbox/tgbot/node_modules/@grammyjs/types/markup.d.ts @@ -0,0 +1,250 @@ +import type { ChatAdministratorRights, User } from "./manage.js"; +import type { MaybeInaccessibleMessage } from "./message.js"; +/** This object represents one button of an inline keyboard. Exactly one of the optional fields must be used to specify type of the button. */ +export interface InlineKeyboardMarkup { + /** Array of button rows, each represented by an Array of InlineKeyboardButton objects */ + inline_keyboard: InlineKeyboardButton[][]; +} +export declare namespace InlineKeyboardButton { + interface AbstractInlineKeyboardButton { + /** Label text on the button */ + text: string; + /** Unique identifier of the custom emoji shown before the text of the button. Can only be used by bots that purchased additional usernames on Fragment or in the messages directly sent by the bot to private, group and supergroup chats if the owner of the bot has a Telegram Premium subscription. */ + icon_custom_emoji_id?: string; + /** Style of the button. Must be one of “danger” (red), “success” (green) or “primary” (blue). If omitted, then an app-specific style is used. */ + style?: "danger" | "success" | "primary"; + } + interface UrlButton extends AbstractInlineKeyboardButton { + /** HTTP or tg:// URL to be opened when the button is pressed. Links tg://user?id= can be used to mention a user by their identifier without using a username, if this is allowed by their privacy settings. */ + url: string; + } + interface CallbackButton extends AbstractInlineKeyboardButton { + /** Data to be sent in a callback query to the bot when the button is pressed, 1-64 bytes */ + callback_data: string; + } + interface WebAppButton extends AbstractInlineKeyboardButton { + /** Description of the Web App that will be launched when the user presses the button. The Web App will be able to send an arbitrary message on behalf of the user using the method answerWebAppQuery. Available only in private chats between a user and the bot. Not supported for messages sent on behalf of a Telegram Business account. */ + web_app: WebAppInfo; + } + interface LoginButton extends AbstractInlineKeyboardButton { + /** An HTTPS URL used to automatically authorize the user. Can be used as a replacement for the Telegram Login Widget. */ + login_url: LoginUrl; + } + interface SwitchInlineButton extends AbstractInlineKeyboardButton { + /** If set, pressing the button will prompt the user to select one of their chats, open that chat and insert the bot's username and the specified inline query in the input field. May be empty, in which case just the bot's username will be inserted. Not supported for messages sent in channel direct messages chats and on behalf of a Telegram Business account. */ + switch_inline_query: string; + } + interface SwitchInlineCurrentChatButton extends AbstractInlineKeyboardButton { + /** If set, pressing the button will insert the bot's username and the specified inline query in the current chat's input field. May be empty, in which case only the bot's username will be inserted. + + This offers a quick way for the user to open your bot in inline mode in the same chat - good for selecting something from multiple options. Not supported in channels and for messages sent in channel direct messages chats and on behalf of a Telegram Business account. */ + switch_inline_query_current_chat: string; + } + interface SwitchInlineChosenChatButton extends AbstractInlineKeyboardButton { + /** If set, pressing the button will prompt the user to select one of their chats of the specified type, open that chat and insert the bot's username and the specified inline query in the input field. Not supported for messages sent in channel direct messages chats and on behalf of a Telegram Business account. */ + switch_inline_query_chosen_chat: SwitchInlineQueryChosenChat; + } + interface CopyTextButtonButton extends AbstractInlineKeyboardButton { + /** Description of the button that copies the specified text to the clipboard. */ + copy_text: CopyTextButton; + } + interface GameButton extends AbstractInlineKeyboardButton { + /** Description of the game that will be launched when the user presses the button. + + NOTE: This type of button must always be the first button in the first row. */ + callback_game: CallbackGame; + } + interface PayButton extends AbstractInlineKeyboardButton { + /** Specify True, to send a Pay button. Substrings “⭐” and “XTR” in the buttons's text will be replaced with a Telegram Star icon. + + NOTE: This type of button must always be the first button in the first row and can only be used in invoice messages. */ + pay: boolean; + } +} +/** This object represents one button of an inline keyboard. Exactly one of the fields other than text, icon_custom_emoji_id, and style must be used to specify the type of the button. */ +export type InlineKeyboardButton = InlineKeyboardButton.CallbackButton | InlineKeyboardButton.GameButton | InlineKeyboardButton.LoginButton | InlineKeyboardButton.PayButton | InlineKeyboardButton.SwitchInlineButton | InlineKeyboardButton.SwitchInlineCurrentChatButton | InlineKeyboardButton.SwitchInlineChosenChatButton | InlineKeyboardButton.CopyTextButtonButton | InlineKeyboardButton.UrlButton | InlineKeyboardButton.WebAppButton; +/** This object represents a parameter of the inline keyboard button used to automatically authorize a user. Serves as a great replacement for the Telegram Login Widget when the user is coming from Telegram. All the user needs to do is tap/click a button and confirm that they want to log in. +Telegram apps support these buttons as of version 5.7. */ +export interface LoginUrl { + /** An HTTPS URL to be opened with user authorization data added to the query string when the button is pressed. If the user refuses to provide authorization data, the original URL without information about the user will be opened. The data added is the same as described in Receiving authorization data. + + NOTE: You must always check the hash of the received data to verify the authentication and the integrity of the data as described in Checking authorization. */ + url: string; + /** New text of the button in forwarded messages. */ + forward_text?: string; + /** Username of a bot, which will be used for user authorization. See Setting up a bot for more details. If not specified, the current bot's username will be assumed. The url's domain must be the same as the domain linked with the bot. See Linking your domain to the bot for more details. */ + bot_username?: string; + /** Pass True to request the permission for your bot to send messages to the user. */ + request_write_access?: boolean; +} +/** This object represents an inline button that switches the current user to inline mode in a chosen chat, with an optional default inline query. */ +export interface SwitchInlineQueryChosenChat { + /** The default inline query to be inserted in the input field. If left empty, only the bot's username will be inserted */ + query?: string; + /** True, if private chats with users can be chosen */ + allow_user_chats?: boolean; + /** True, if private chats with bots can be chosen */ + allow_bot_chats?: boolean; + /** True, if group and supergroup chats can be chosen */ + allow_group_chats?: boolean; + /** True, if channel chats can be chosen */ + allow_channel_chats?: boolean; +} +/** A placeholder, currently holds no information. Use BotFather to set up your game. */ +export interface CallbackGame { +} +/** This object represents an incoming callback query from a callback button in an inline keyboard. If the button that originated the query was attached to a message sent by the bot, the field message will be present. If the button was attached to a message sent via the bot (in inline mode), the field inline_message_id will be present. Exactly one of the fields data or game_short_name will be present. + + NOTE: After the user presses a callback button, Telegram clients will display a progress bar until you call answerCallbackQuery. It is, therefore, necessary to react by calling answerCallbackQuery even if no notification to the user is needed (e.g., without specifying any of the optional parameters). */ +export interface CallbackQuery { + /** Unique identifier for this query */ + id: string; + /** Sender */ + from: User; + /** Message sent by the bot with the callback button that originated the query */ + message?: MaybeInaccessibleMessage; + /** Identifier of the message sent via the bot in inline mode, that originated the query. */ + inline_message_id?: string; + /** Global identifier, uniquely corresponding to the chat to which the message with the callback button was sent. Useful for high scores in games. */ + chat_instance: string; + /** Data associated with the callback button. Be aware that the message originated the query can contain no callback buttons with this data. */ + data?: string; + /** Short name of a Game to be returned, serves as the unique identifier for the game */ + game_short_name?: string; +} +/** This object represents a custom keyboard with reply options (see Introduction to bots for details and examples). Not supported in channels and for messages sent on behalf of a Telegram Business account. */ +export interface ReplyKeyboardMarkup { + /** Array of button rows, each represented by an Array of KeyboardButton objects */ + keyboard: KeyboardButton[][]; + /** Requests clients to always show the keyboard when the regular keyboard is hidden. Defaults to false, in which case the custom keyboard can be hidden and opened with a keyboard icon. */ + is_persistent?: boolean; + /** Requests clients to resize the keyboard vertically for optimal fit (e.g., make the keyboard smaller if there are just two rows of buttons). Defaults to false, in which case the custom keyboard is always of the same height as the app's standard keyboard. */ + resize_keyboard?: boolean; + /** Requests clients to hide the keyboard as soon as it's been used. The keyboard will still be available, but clients will automatically display the usual letter-keyboard in the chat – the user can press a special button in the input field to see the custom keyboard again. Defaults to false. */ + one_time_keyboard?: boolean; + /** The placeholder to be shown in the input field when the keyboard is active; 1-64 characters */ + input_field_placeholder?: string; + /** Use this parameter if you want to show the keyboard to specific users only. Targets: 1) users that are `@mentioned` in the text of the Message object; 2) if the bot's message is a reply to a message in the same chat and forum topic, sender of the original message. + + Example: A user requests to change the bot's language, bot replies to the request with a keyboard to select the new language. Other users in the group don't see the keyboard. */ + selective?: boolean; +} +export declare namespace KeyboardButton { + interface CommonButton { + /** Text of the button. If none of the fields other than text, icon_custom_emoji_id, and style are used, it will be sent as a message when the button is pressed */ + text: string; + /** Unique identifier of the custom emoji shown before the text of the button. Can only be used by bots that purchased additional usernames on Fragment or in the messages directly sent by the bot to private, group and supergroup chats if the owner of the bot has a Telegram Premium subscription. */ + icon_custom_emoji_id?: string; + /** Style of the button. Must be one of “danger” (red), “success” (green) or “primary” (blue). If omitted, then an app-specific style is used. */ + style?: "danger" | "success" | "primary"; + } + interface RequestUsersButton extends CommonButton { + /** If specified, pressing the button will open a list of suitable users. Identifiers of selected users will be sent to the bot in a “users_shared” service message. Available in private chats only. */ + request_users: KeyboardButtonRequestUsers; + } + interface RequestChatButton extends CommonButton { + /** If specified, pressing the button will open a list of suitable chats. Tapping on a chat will send its identifier to the bot in a “chat_shared” service message. Available in private chats only. */ + request_chat: KeyboardButtonRequestChat; + } + interface RequestContactButton extends CommonButton { + /** If True, the user's phone number will be sent as a contact when the button is pressed. Available in private chats only. */ + request_contact: boolean; + } + interface RequestLocationButton extends CommonButton { + /** If True, the user's current location will be sent when the button is pressed. Available in private chats only. */ + request_location: boolean; + } + interface RequestPollButton extends CommonButton { + /** If specified, the user will be asked to create a poll and send it to the bot when the button is pressed. Available in private chats only. */ + request_poll: KeyboardButtonPollType; + } + interface WebAppButton extends CommonButton { + /** If specified, the described Web App will be launched when the button is pressed. The Web App will be able to send a “web_app_data” service message. Available in private chats only. */ + web_app: WebAppInfo; + } +} +/** This object represents one button of the reply keyboard. At most one of the fields other than text, icon_custom_emoji_id, and style must be used to specify the type of the button. For simple text buttons, String can be used instead of this object to specify the button text. */ +export type KeyboardButton = KeyboardButton.CommonButton | KeyboardButton.RequestUsersButton | KeyboardButton.RequestChatButton | KeyboardButton.RequestContactButton | KeyboardButton.RequestLocationButton | KeyboardButton.RequestPollButton | KeyboardButton.WebAppButton | string; +/** This object represents type of a poll, which is allowed to be created and sent when the corresponding button is pressed. */ +export interface KeyboardButtonPollType { + /** If quiz is passed, the user will be allowed to create only polls in the quiz mode. If regular is passed, only regular polls will be allowed. Otherwise, the user will be allowed to create a poll of any type. */ + type?: "quiz" | "regular"; +} +/** Upon receiving a message with this object, Telegram clients will remove the current custom keyboard and display the default letter-keyboard. By default, custom keyboards are displayed until a new keyboard is sent by a bot. An exception is made for one-time keyboards that are hidden immediately after the user presses a button (see ReplyKeyboardMarkup). Not supported in channels and for messages sent on behalf of a Telegram Business account. */ +export interface ReplyKeyboardRemove { + /** Requests clients to remove the custom keyboard (user will not be able to summon this keyboard; if you want to hide the keyboard from sight but keep it accessible, use one_time_keyboard in ReplyKeyboardMarkup) */ + remove_keyboard: true; + /** Use this parameter if you want to remove the keyboard for specific users only. Targets: 1) users that are `@mentioned` in the text of the Message object; 2) if the bot's message is a reply to a message in the same chat and forum topic, sender of the original message. + + Example: A user votes in a poll, bot returns confirmation message in reply to the vote and removes the keyboard for that user, while still showing the keyboard with poll options to users who haven't voted yet. */ + selective?: boolean; +} +/** Upon receiving a message with this object, Telegram clients will display a reply interface to the user (act as if the user has selected the bot's message and tapped 'Reply'). This can be extremely useful if you want to create user-friendly step-by-step interfaces without having to sacrifice privacy mode. Not supported in channels and for messages sent on behalf of a Telegram Business account. + +Example: A poll bot for groups runs in privacy mode (only receives commands, replies to its messages and mentions). There could be two ways to create a new poll: + +Explain the user how to send a command with parameters (e.g. /newpoll question answer1 answer2). May be appealing for hardcore users but lacks modern day polish. + +Guide the user through a step-by-step process. 'Please send me your question', 'Cool, now let's add the first answer option', 'Great. Keep adding answer options, then send /done when you're ready'. + +The last option is definitely more attractive. And if you use ForceReply in your bot's questions, it will receive the user's answers even if it only receives replies, commands and mentions - without any extra work for the user. */ +export interface ForceReply { + /** Shows reply interface to the user, as if they manually selected the bot's message and tapped 'Reply' */ + force_reply: true; + /** The placeholder to be shown in the input field when the reply is active; 1-64 characters */ + input_field_placeholder?: string; + /** Use this parameter if you want to force reply from specific users only. Targets: 1) users that are `@mentioned` in the text of the Message object; 2) if the bot's message is a reply to a message in the same chat and forum topic, sender of the original message. */ + selective?: boolean; +} +/** This object represents an inline keyboard button that copies specified text to the clipboard. */ +export interface CopyTextButton { + /** The text to be copied to the clipboard; 1-256 characters */ + text: string; +} +/** Describes a Web App. */ +export interface WebAppInfo { + /** An HTTPS URL of a Web App to be opened with additional data as specified in Initializing Web Apps */ + url: string; +} +/** This object defines the criteria used to request suitable users. Information about the selected users will be shared with the bot when the corresponding button is pressed. */ +export interface KeyboardButtonRequestUsers { + /** Signed 32-bit identifier of the request that will be received back in the UsersShared object. Must be unique within the message */ + request_id: number; + /** Pass True to request bots, pass False to request regular users. If not specified, no additional restrictions are applied. */ + user_is_bot?: boolean; + /** Pass True to request premium users, pass False to request non-premium users. If not specified, no additional restrictions are applied. */ + user_is_premium?: boolean; + /** The maximum number of users to be selected; 1-10. Defaults to 1. */ + max_quantity?: number; + /** Pass True to request the users' first and last names */ + request_name?: boolean; + /** Pass True to request the users' usernames */ + request_username?: boolean; + /** Pass True to request the users' photos */ + request_photo?: boolean; +} +/** This object defines the criteria used to request a suitable chat. Information about the selected chat will be shared with the bot when the corresponding button is pressed. The bot will be granted requested rights in the chat if appropriate. */ +export interface KeyboardButtonRequestChat { + /** Signed 32-bit identifier of the request, which will be received back in the ChatShared object. Must be unique within the message */ + request_id: number; + /** Pass True to request a channel chat, pass False to request a group or a supergroup chat. */ + chat_is_channel: boolean; + /** Pass True to request a forum supergroup, pass False to request a non-forum chat. If not specified, no additional restrictions are applied. */ + chat_is_forum?: boolean; + /** Pass True to request a supergroup or a channel with a username, pass False to request a chat without a username. If not specified, no additional restrictions are applied. */ + chat_has_username?: boolean; + /** Pass True to request a chat owned by the user. Otherwise, no additional restrictions are applied. */ + chat_is_created?: boolean; + /** An object listing the required administrator rights of the user in the chat. The rights must be a superset of bot_administrator_rights. If not specified, no additional restrictions are applied. */ + user_administrator_rights?: ChatAdministratorRights; + /** An object listing the required administrator rights of the bot in the chat. The rights must be a subset of user_administrator_rights. If not specified, no additional restrictions are applied. */ + bot_administrator_rights?: ChatAdministratorRights; + /** Pass True to request a chat with the bot as a member. Otherwise, no additional restrictions are applied. */ + bot_is_member?: boolean; + /** Pass True to request the chat's title */ + request_title?: boolean; + /** Pass True to request the chat's username */ + request_username?: boolean; + /** Pass True to request the chat's photo */ + request_photo?: boolean; +} diff --git a/sandbox/tgbot/node_modules/@grammyjs/types/message.d.ts b/sandbox/tgbot/node_modules/@grammyjs/types/message.d.ts new file mode 100644 index 0000000..30175eb --- /dev/null +++ b/sandbox/tgbot/node_modules/@grammyjs/types/message.d.ts @@ -0,0 +1,1362 @@ +import type { Checklist, ChecklistTasksAdded, ChecklistTasksDone } from "./checklist.js"; +import type { Chat, ChatOwnerChanged, ChatOwnerLeft, User } from "./manage.js"; +import type { InlineKeyboardMarkup } from "./markup.js"; +import type { PassportData } from "./passport.js"; +import type { GiftInfo, Invoice, PaidMessagePriceChanged, RefundedPayment, SuccessfulPayment, SuggestedPostApprovalFailed, SuggestedPostApproved, SuggestedPostDeclined, SuggestedPostInfo, SuggestedPostPaid, SuggestedPostPrice, SuggestedPostRefunded, UniqueGiftInfo } from "./payment.js"; +type MsgWith

= Record>; +export declare namespace Message { + interface ServiceMessage { + /** Unique message identifier inside this chat. In specific instances (e.g., message containing a video sent to a big chat), the server might automatically schedule a message instead of sending it immediately. In such cases, this field will be 0 and the relevant message will be unusable until it is actually sent */ + message_id: number; + /** Unique identifier of a message thread or forum topic to which the message belongs; for supergroups and private chats only */ + message_thread_id?: number; + /** Sender of the message; may be empty for messages sent to channels. For backward compatibility, if the message was sent on behalf of a chat, the field contains a fake sender user in non-channel chats */ + from?: User; + /** Sender of the message when sent on behalf of a chat. For example, the supergroup itself for messages sent by its anonymous administrators or a linked channel for messages automatically forwarded to the channel's discussion group. For backward compatibility, if the message was sent on behalf of a chat, the field from contains a fake sender user in non-channel chats. */ + sender_chat?: Chat; + /** Date the message was sent in Unix time. It is always a positive number, representing a valid date. */ + date: number; + /** Unique identifier of the business connection from which the message was received. If non-empty, the message belongs to a chat of the corresponding business account that is independent from any potential bot chat which might share the same identifier. */ + business_connection_id?: string; + /** Chat the message belongs to */ + chat: Chat; + /** True, if the message is sent to a topic in a forum supergroup or a private chat with the bot */ + is_topic_message?: boolean; + /** Information about the direct messages chat topic that contains the message */ + direct_messages_topic?: DirectMessagesTopic; + } + interface CommonMessage extends ServiceMessage { + /** If the sender of the message boosted the chat, the number of boosts added by the user */ + sender_boost_count?: number; + /** The bot that actually sent the message on behalf of the business account. Available only for outgoing messages sent on behalf of the connected business account. */ + sender_business_bot?: User; + /** Information about the original message for forwarded messages */ + forward_origin?: MessageOrigin; + /** True, if the message is a channel post that was automatically forwarded to the connected discussion group */ + is_automatic_forward?: true; + /** For replies in the same chat and message thread, the original message. Note that the Message object in this field will not contain further reply_to_message fields even if it itself is a reply. */ + reply_to_message?: ReplyMessage; + /** Identifier of the specific checklist task that is being replied to */ + reply_to_checklist_task_id?: number; + /** True, if the message is a paid post. Note that such posts must not be deleted for 24 hours to receive the payment and can't be edited. */ + is_paid_post?: true; + /** Information about the message that is being replied to, which may come from another chat or forum topic */ + external_reply?: ExternalReplyInfo; + /** For replies that quote part of the original message, the quoted part of the message */ + quote?: TextQuote; + /** For replies to a story, the original message */ + reply_to_story?: Story; + /** Bot through which the message was sent */ + via_bot?: User; + /** Date the message was last edited in Unix time */ + edit_date?: number; + /** True, if the message can't be forwarded */ + has_protected_content?: true; + /** True, if the caption must be shown above the message media */ + show_caption_above_media?: true; + /** True, if the message was sent by an implicit action, for example, as an away or a greeting business message, or as a scheduled message */ + is_from_offline?: true; + /** Signature of the post author for messages in channels, or the custom title of an anonymous group administrator */ + author_signature?: string; + /** Options used for link preview generation for the message, if it is a text message and link preview options were changed */ + link_preview_options?: LinkPreviewOptions; + /** Unique identifier of the message effect added to the message */ + effect_id?: string; + /** The number of Telegram Stars that were paid by the sender of the message to send it */ + paid_star_count?: number; + /** Inline keyboard attached to the message. login_url buttons are represented as ordinary url buttons. */ + reply_markup?: InlineKeyboardMarkup; + } + interface CaptionableMessage extends CommonMessage { + /** Caption for the animation, audio, document, photo, video or voice */ + caption?: string; + /** For messages with a caption, special entities like usernames, URLs, bot commands, etc. that appear in the caption */ + caption_entities?: MessageEntity[]; + } + interface MediaMessage extends CaptionableMessage { + /** The unique identifier of a media message group this message belongs to */ + media_group_id?: string; + /** True, if the message media is covered by a spoiler animation */ + has_media_spoiler?: true; + } + type TextMessage = CommonMessage & MsgWith<"text"> & Partial>; + type AudioMessage = CaptionableMessage & MsgWith<"audio">; + type DocumentMessage = CaptionableMessage & MsgWith<"document">; + type AnimationMessage = DocumentMessage & MsgWith<"animation">; + type PhotoMessage = MediaMessage & MsgWith<"photo">; + type StickerMessage = CommonMessage & MsgWith<"sticker">; + type StoryMessage = CommonMessage & MsgWith<"story">; + type VideoMessage = MediaMessage & MsgWith<"video">; + type VideoNoteMessage = CommonMessage & MsgWith<"video_note">; + type VoiceMessage = CaptionableMessage & MsgWith<"voice">; + type ContactMessage = CommonMessage & MsgWith<"contact">; + type DiceMessage = CommonMessage & MsgWith<"dice">; + type GameMessage = CommonMessage & MsgWith<"game">; + type PollMessage = CommonMessage & MsgWith<"poll">; + type VenueMessage = LocationMessage & MsgWith<"venue">; + type LocationMessage = CommonMessage & MsgWith<"location">; + type PaidMediaMessage = CommonMessage & MsgWith<"paid_media">; + type DirectMessagePriceChangedMessage = ServiceMessage & MsgWith<"direct_message_price_changed">; + type ChecklistMessage = CommonMessage & MsgWith<"checklist">; + type ChecklistTasksDoneMessage = ServiceMessage & MsgWith<"checklist_tasks_done">; + type ChecklistTasksAddedMessage = ServiceMessage & MsgWith<"checklist_tasks_added">; + type SuggestedPostInfoMessage = ServiceMessage & MsgWith<"suggested_post_info">; + type SuggestedPostApprovedMessage = ServiceMessage & MsgWith<"suggested_post_approved">; + type SuggestedPostApprovalFailedMessage = ServiceMessage & MsgWith<"suggested_post_approval_failed">; + type SuggestedPostDeclinedMessage = ServiceMessage & MsgWith<"suggested_post_declined">; + type SuggestedPostPaidMessage = ServiceMessage & MsgWith<"suggested_post_paid">; + type SuggestedPostRefundedMessage = ServiceMessage & MsgWith<"suggested_post_refunded">; + type ChatOwnerLeftMessage = ServiceMessage & MsgWith<"chat_owner_left">; + type ChatOwnerChangedMessage = ServiceMessage & MsgWith<"chat_owner_changed">; + type NewChatMembersMessage = ServiceMessage & MsgWith<"new_chat_members">; + type LeftChatMemberMessage = ServiceMessage & MsgWith<"left_chat_member">; + type NewChatTitleMessage = ServiceMessage & MsgWith<"new_chat_title">; + type NewChatPhotoMessage = ServiceMessage & MsgWith<"new_chat_photo">; + type DeleteChatPhotoMessage = ServiceMessage & MsgWith<"delete_chat_photo">; + type GroupChatCreatedMessage = ServiceMessage & MsgWith<"group_chat_created">; + type SupergroupChatCreated = ServiceMessage & MsgWith<"supergroup_chat_created">; + type ChannelChatCreatedMessage = ServiceMessage & MsgWith<"channel_chat_created">; + type MessageAutoDeleteTimerChangedMessage = ServiceMessage & MsgWith<"message_auto_delete_timer_changed">; + type MigrateToChatIdMessage = ServiceMessage & MsgWith<"migrate_to_chat_id">; + type MigrateFromChatIdMessage = ServiceMessage & MsgWith<"migrate_from_chat_id">; + type PinnedMessageMessage = ServiceMessage & MsgWith<"pinned_message">; + type InvoiceMessage = ServiceMessage & MsgWith<"invoice">; + type SuccessfulPaymentMessage = ServiceMessage & MsgWith<"successful_payment">; + type RefundedPaymentMessage = ServiceMessage & MsgWith<"refunded_payment">; + type UsersSharedMessage = ServiceMessage & MsgWith<"users_shared">; + type ChatSharedMessage = ServiceMessage & MsgWith<"chat_shared">; + type ConnectedWebsiteMessage = ServiceMessage & MsgWith<"connected_website">; + type WriteAccessAllowedMessage = ServiceMessage & MsgWith<"write_access_allowed">; + type PassportDataMessage = ServiceMessage & MsgWith<"passport_data">; + type ProximityAlertTriggeredMessage = ServiceMessage & MsgWith<"proximity_alert_triggered">; + type BoostAddedMessage = ServiceMessage & MsgWith<"boost_added">; + type ChatBackgroundSetMessage = ServiceMessage & MsgWith<"chat_background_set">; + type ForumTopicCreatedMessage = ServiceMessage & MsgWith<"forum_topic_created">; + type ForumTopicEditedMessage = ServiceMessage & MsgWith<"forum_topic_edited">; + type ForumTopicClosedMessage = ServiceMessage & MsgWith<"forum_topic_closed">; + type ForumTopicReopenedMessage = ServiceMessage & MsgWith<"forum_topic_reopened">; + type GeneralForumTopicHiddenMessage = ServiceMessage & MsgWith<"general_forum_topic_hidden">; + type GeneralForumTopicUnhiddenMessage = ServiceMessage & MsgWith<"general_forum_topic_unhidden">; + type GiveawayCreatedMessage = ServiceMessage & MsgWith<"giveaway_created">; + type GiveawayMessage = ServiceMessage & MsgWith<"giveaway">; + type GiveawayWinnersMessage = ServiceMessage & MsgWith<"giveaway_winners">; + type GiveawayCompletedMessage = ServiceMessage & MsgWith<"giveaway_completed">; + type GiftMessage = ServiceMessage & MsgWith<"gift">; + type UniqueGiftMessage = ServiceMessage & MsgWith<"unique_gift">; + type GiftUpgradeSentMessage = ServiceMessage & MsgWith<"gift_upgrade_sent">; + type PaidMessagePriceChangedMessage = ServiceMessage & MsgWith<"paid_message_price_changed">; + type VideoChatScheduledMessage = ServiceMessage & MsgWith<"video_chat_scheduled">; + type VideoChatStartedMessage = ServiceMessage & MsgWith<"video_chat_started">; + type VideoChatEndedMessage = ServiceMessage & MsgWith<"video_chat_ended">; + type VideoChatParticipantsInvitedMessage = ServiceMessage & MsgWith<"video_chat_participants_invited">; + type WebAppDataMessage = ServiceMessage & MsgWith<"web_app_data">; +} +type ReplyMessage = Message & { + reply_to_message: undefined; +}; +/** This object represents a message. */ +export interface Message extends Message.MediaMessage { + /** For text messages, the actual UTF-8 text of the message */ + text?: string; + /** For text messages, special entities like usernames, URLs, bot commands, etc. that appear in the text */ + entities?: MessageEntity[]; + /** Message is an animation, information about the animation. For backward compatibility, when this field is set, the document field will also be set */ + animation?: Animation; + /** Message is an audio file, information about the file */ + audio?: Audio; + /** Message is a general file, information about the file */ + document?: Document; + /** Message is a photo, available sizes of the photo */ + photo?: PhotoSize[]; + /** Message is a sticker, information about the sticker */ + sticker?: Sticker; + /** Message is a forwarded story */ + story?: Story; + /** Message is a video, information about the video */ + video?: Video; + /** Message is a video note, information about the video message */ + video_note?: VideoNote; + /** Message is a voice message, information about the file */ + voice?: Voice; + /** Message is a shared contact, information about the contact */ + contact?: Contact; + /** Message is a dice with random value */ + dice?: Dice; + /** Message is a game, information about the game. More about games » */ + game?: Game; + /** Message is a native poll, information about the poll */ + poll?: Poll; + /** Message is a venue, information about the venue. For backward compatibility, when this field is set, the location field will also be set */ + venue?: Venue; + /** Message is a shared location, information about the location */ + location?: Location; + /** Message contains paid media; information about the paid media */ + paid_media?: PaidMediaInfo; + /** Message is a checklist */ + checklist?: Checklist; + /** Service message: some tasks in a checklist were marked as done or not done */ + checklist_tasks_done?: ChecklistTasksDone; + /** Service message: tasks were added to a checklist */ + checklist_tasks_added?: ChecklistTasksAdded; + /** Information about suggested post parameters if the message is a suggested post in a channel direct messages chat. If the message is an approved or declined suggested post, then it can't be edited. */ + suggested_post_info?: SuggestedPostInfo; + /** Service message: a suggested post was approved */ + suggested_post_approved?: SuggestedPostApproved; + /** Service message: approval of a suggested post has failed */ + suggested_post_approval_failed?: SuggestedPostApprovalFailed; + /** Service message: a suggested post was declined */ + suggested_post_declined?: SuggestedPostDeclined; + /** Service message: payment for a suggested post was received */ + suggested_post_paid?: SuggestedPostPaid; + /** Service message: payment for a suggested post was refunded */ + suggested_post_refunded?: SuggestedPostRefunded; + /** Service message: chat owner has left */ + chat_owner_left?: ChatOwnerLeft; + /** Service message: chat owner has changed */ + chat_owner_changed?: ChatOwnerChanged; + /** New members that were added to the group or supergroup and information about them (the bot itself may be one of these members) */ + new_chat_members?: User[]; + /** A member was removed from the group, information about them (this member may be the bot itself) */ + left_chat_member?: User; + /** A chat title was changed to this value */ + new_chat_title?: string; + /** A chat photo was change to this value */ + new_chat_photo?: PhotoSize[]; + /** Service message: the chat photo was deleted */ + delete_chat_photo?: true; + /** Service message: the group has been created */ + group_chat_created?: true; + /** Service message: the supergroup has been created. This field can't be received in a message coming through updates, because bot can't be a member of a supergroup when it is created. It can only be found in reply_to_message if someone replies to a very first message in a directly created supergroup. */ + supergroup_chat_created?: true; + /** Service message: the channel has been created. This field can't be received in a message coming through updates, because bot can't be a member of a channel when it is created. It can only be found in reply_to_message if someone replies to a very first message in a channel. */ + channel_chat_created?: true; + /** Service message: auto-delete timer settings changed in the chat */ + message_auto_delete_timer_changed?: MessageAutoDeleteTimerChanged; + /** The group has been migrated to a supergroup with the specified identifier. */ + migrate_to_chat_id?: number; + /** The supergroup has been migrated from a group with the specified identifier. */ + migrate_from_chat_id?: number; + /** Specified message was pinned. Note that the Message object in this field will not contain further reply_to_message fields even if it itself is a reply. */ + pinned_message?: MaybeInaccessibleMessage; + /** Message is an invoice for a payment, information about the invoice. More about payments » */ + invoice?: Invoice; + /** Message is a service message about a successful payment, information about the payment. More about payments » */ + successful_payment?: SuccessfulPayment; + /** Message is a service message about a refunded payment, information about the payment. More about payments » */ + refunded_payment?: RefundedPayment; + /** Service message: users were shared with the bot */ + users_shared?: UsersShared; + /** Service message: a chat was shared with the bot */ + chat_shared?: ChatShared; + /** The domain name of the website on which the user has logged in. More about Telegram Login » */ + connected_website?: string; + /** Service message: the user allowed the bot to write messages after adding it to the attachment or side menu, launching a Web App from a link, or accepting an explicit request from a Web App sent by the method requestWriteAccess */ + write_access_allowed?: WriteAccessAllowed; + /** Telegram Passport data */ + passport_data?: PassportData; + /** Service message. A user in the chat triggered another user's proximity alert while sharing Live Location. */ + proximity_alert_triggered?: ProximityAlertTriggered; + /** Service message: user boosted the chat */ + boost_added?: ChatBoostAdded; + chat_background_set?: ChatBackground; + /** Service message: forum topic created */ + forum_topic_created?: ForumTopicCreated; + /** Service message: forum topic edited */ + forum_topic_edited?: ForumTopicEdited; + /** Service message: forum topic closed */ + forum_topic_closed?: ForumTopicClosed; + /** Service message: forum topic reopened */ + forum_topic_reopened?: ForumTopicReopened; + /** Service message: the 'General' forum topic hidden */ + general_forum_topic_hidden?: GeneralForumTopicHidden; + /** Service message: the 'General' forum topic unhidden */ + general_forum_topic_unhidden?: GeneralForumTopicUnhidden; + /** Service message: a scheduled giveaway was created */ + giveaway_created?: GiveawayCreated; + /** The message is a scheduled giveaway message */ + giveaway?: Giveaway; + /** A giveaway with public winners was completed */ + giveaway_winners?: GiveawayWinners; + /** Service message: a giveaway without public winners was completed */ + giveaway_completed?: GiveawayCompleted; + /** Service message: a regular gift was sent or received */ + gift?: GiftInfo; + /** Service message: upgrade of a gift was purchased after the gift was sent */ + gift_upgrade_sent?: GiftInfo; + /** Service message: a unique gift was sent or received */ + unique_gift?: UniqueGiftInfo; + /** Service message: the price for paid messages has changed in the chat */ + paid_message_price_changed?: PaidMessagePriceChanged; + /** Service message: the price for paid messages in the corresponding direct messages chat of a channel has changed */ + direct_message_price_changed?: DirectMessagePriceChanged; + /** Service message: video chat scheduled */ + video_chat_scheduled?: VideoChatScheduled; + /** Service message: video chat started */ + video_chat_started?: VideoChatStarted; + /** Service message: video chat ended */ + video_chat_ended?: VideoChatEnded; + /** Service message: new participants invited to a video chat */ + video_chat_participants_invited?: VideoChatParticipantsInvited; + /** Service message: data sent by a Web App */ + web_app_data?: WebAppData; +} +/** This object represents a unique message identifier. */ +export interface MessageId { + /** Unique message identifier. In specific instances (e.g., message containing a video sent to a big chat), the server might automatically schedule a message instead of sending it immediately. In such cases, this field will be 0 and the relevant message will be unusable until it is actually sent */ + message_id: number; +} +/** Describes an inline message sent by a Web App on behalf of a user. */ +export interface SentWebAppMessage { + /** Identifier of the sent inline message. Available only if there is an inline keyboard attached to the message. */ + inline_message_id: string; +} +/** This object describes a message that was deleted or is otherwise inaccessible to the bot. */ +export interface InaccessibleMessage extends Omit { + /** Chat the message belonged to */ + chat: Chat; + /** Unique message identifier inside the chat */ + message_id: number; + /** Always 0. The field can be used to differentiate regular and inaccessible messages. */ + date: 0; +} +/** This object describes a message that can be inaccessible to the bot. It can be one of + +- Message +- InaccessibleMessage */ +export type MaybeInaccessibleMessage = Message | InaccessibleMessage; +/** The Bot API supports basic formatting for messages. You can use bold, italic, underlined, strikethrough, spoiler text, block quotations as well as inline links and pre-formatted code in your bots' messages. Telegram clients will render them accordingly. You can specify text entities directly, or use markdown-style or HTML-style formatting. + +Note that Telegram clients will display an **alert** to the user before opening an inline link ('Open this link?' together with the full URL). + +Message entities can be nested, providing following restrictions are met: +- If two entities have common characters, then one of them is fully contained inside another. +- bold, italic, underline, strikethrough, and spoiler entities can contain and can be part of any other entities, except pre and code. +- blockquote and expandable_blockquote entities can't be nested. +- All other entities can't contain each other. + +Links `tg://user?id=` can be used to mention a user by their identifier without using a username. Please note: + +- These links will work only if they are used inside an inline link or in an inline keyboard button. For example, they will not work, when used in a message text. +- Unless the user is a member of the chat where they were mentioned, these mentions are only guaranteed to work if the user has contacted the bot in private in the past or has sent a callback query to the bot via an inline button and doesn't have Forwarded Messages privacy enabled for the bot. + +You can find the list of programming and markup languages for which syntax highlighting is supported at [libprisma#supported-languages](https://github.com/TelegramMessenger/libprisma#supported-languages). + +#### MarkdownV2 style +To use this mode, pass *MarkdownV2* in the *parse_mode* field. Use the following syntax in your message: + +``` +*bold \*text* +_italic \*text_ +__underline__ +~strikethrough~ +||spoiler|| +*bold _italic bold ~italic bold strikethrough ||italic bold strikethrough spoiler||~ __underline italic bold___ bold* +[inline URL](http://www.example.com/) +[inline mention of a user](tg://user?id=123456789) +![👍](tg://emoji?id=5368324170671202286) +`inline fixed-width code` +`​`​` +pre-formatted fixed-width code block +`​`​` +`​`​`python +pre-formatted fixed-width code block written in the Python programming language +`​`​` +>Block quotation started +>Block quotation continued +>Block quotation continued +>Block quotation continued +>The last line of the block quotation +***>The second expandable block quotation started right after the previous +>It is separated from the previous block quotation by an empty bold entity +>Expandable block quotation continued +>Hidden by default part of the expandable block quotation started +>Expandable block quotation continued +>The last line of the expandable block quotation with the expandability mark|| +``` +Please note: + +- Any character with code between 1 and 126 inclusively can be escaped anywhere with a preceding '\' character, in which case it is treated as an ordinary character and not a part of the markup. This implies that '\' character usually must be escaped with a preceding '\' character. +- Inside `pre` and `code` entities, all '`' and '\' characters must be escaped with a preceding '\' character. +- Inside the `(...)` part of the inline link and custom emoji definition, all ')' and '\' must be escaped with a preceding '\' character. +- In all other places characters '_', '*', '[', ']', '(', ')', '~', '`', '>', '#', '+', '-', '=', '|', '{', '}', '.', '!' must be escaped with the preceding character '\'. +- In case of ambiguity between `italic` and `underline` entities `__` is always greedily treated from left to right as beginning or end of an `underline` entity, so instead of `___italic underline___` use `___italic underline_**__`, adding an empty bold entity as a separator. +- A valid emoji must be provided as an alternative value for the custom emoji. The emoji will be shown instead of the custom emoji in places where a custom emoji cannot be displayed (e.g., system notifications) or if the message is forwarded by a non-premium user. It is recommended to use the emoji from the emoji field of the custom emoji sticker. +- Custom emoji entities can only be used by bots that purchased additional usernames on Fragment. + +#### HTML style +To use this mode, pass *HTML* in the *parse_mode* field. The following tags are currently supported: + +```html +bold, bold +italic, italic +underline, underline +strikethrough, strikethrough, strikethrough +spoiler, spoiler +bold italic bold italic bold strikethrough italic bold strikethrough spoiler underline italic bold bold +inline URL +inline mention of a user +👍 +inline fixed-width code +

pre-formatted fixed-width code block
+
pre-formatted fixed-width code block written in the Python programming language
+
Block quotation started\nBlock quotation continued\nThe last line of the block quotation
+
Expandable block quotation started\nExpandable block quotation continued\nExpandable block quotation continued\nHidden by default part of the block quotation started\nExpandable block quotation continued\nThe last line of the block quotation
+``` +Please note: + +- Only the tags mentioned above are currently supported. +- All `<`, `>` and `&` symbols that are not a part of a tag or an HTML entity must be replaced with the corresponding HTML entities (`<` with `<`, `>` with `>` and `&` with `&`). +- All numerical HTML entities are supported. +- The API currently supports only the following named HTML entities: `<`, `>`, `&` and `"`. +- Use nested `pre` and `code` tags, to define programming language for pre entity. +- Programming language can't be specified for standalone `code` tags. +- A valid emoji must be used as the content of the tg-emoji tag. The emoji will be shown instead of the custom emoji in places where a custom emoji cannot be displayed (e.g., system notifications) or if the message is forwarded by a non-premium user. It is recommended to use the emoji from the emoji field of the custom emoji sticker. +- Custom emoji entities can only be used by bots that purchased additional usernames on Fragment. + +#### Markdown style +This is a legacy mode, retained for backward compatibility. To use this mode, pass *Markdown* in the *parse_mode* field. Use the following syntax in your message: + +``` +*bold text* +_italic text_ +[inline URL](http://www.example.com/) +[inline mention of a user](tg://user?id=123456789) +`inline fixed-width code` +`​`​` +pre-formatted fixed-width code block +`​`​` +`​`​`python +pre-formatted fixed-width code block written in the Python programming language +`​`​` +``` +Please note: + +- Entities must not be nested, use parse mode MarkdownV2 instead. +- There is no way to specify “underline”, “strikethrough”, “spoiler”, “blockquote”, “expandable_blockquote” and “custom_emoji” entities, use parse mode MarkdownV2 instead. +- To escape characters '_', '*', '`', '[' outside of an entity, prepend the character '\' before them. +- Escaping inside entities is not allowed, so entity must be closed first and reopened again: use `_snake_\__case_` for italic `snake_case` and `*2*\**2=4*` for bold `2*2=4`. */ +export type ParseMode = "Markdown" | "MarkdownV2" | "HTML"; +export declare namespace MessageEntity { + interface AbstractMessageEntity { + /** Type of the entity. Currently, can be “mention” (`@username`), “hashtag” (#hashtag or `#hashtag@chatusername`), “cashtag” ($USD or `$USD@chatusername`), “bot_command” (`/start@jobs_bot`), “url” (https://telegram.org), “email” (`do-not-reply@telegram.org`), “phone_number” (+1-212-555-0123), “bold” (bold text), “italic” (italic text), “underline” (underlined text), “strikethrough” (strikethrough text), “spoiler” (spoiler message), “blockquote” (block quotation), “expandable_blockquote” (collapsed-by-default block quotation), “code” (monowidth string), “pre” (monowidth block), “text_link” (for clickable text URLs), “text_mention” (for users without usernames), “custom_emoji” (for inline custom emoji stickers) */ + type: string; + /** Offset in UTF-16 code units to the start of the entity */ + offset: number; + /** Length of the entity in UTF-16 code units */ + length: number; + } + interface CommonMessageEntity extends AbstractMessageEntity { + type: "mention" | "hashtag" | "cashtag" | "bot_command" | "url" | "email" | "phone_number" | "bold" | "italic" | "underline" | "strikethrough" | "spoiler" | "blockquote" | "expandable_blockquote" | "code"; + } + interface PreMessageEntity extends AbstractMessageEntity { + type: "pre"; + /** For “pre” only, the programming language of the entity text */ + language?: string; + } + interface TextLinkMessageEntity extends AbstractMessageEntity { + type: "text_link"; + /** For “text_link” only, URL that will be opened after user taps on the text */ + url: string; + } + interface TextMentionMessageEntity extends AbstractMessageEntity { + type: "text_mention"; + /** For “text_mention” only, the mentioned user */ + user: User; + } + interface CustomEmojiMessageEntity extends AbstractMessageEntity { + type: "custom_emoji"; + /** For “custom_emoji” only, unique identifier of the custom emoji. Use getCustomEmojiStickers to get full information about the sticker */ + custom_emoji_id: string; + } +} +/** This object represents one special entity in a text message. For example, hashtags, usernames, URLs, etc. */ +export type MessageEntity = MessageEntity.CommonMessageEntity | MessageEntity.CustomEmojiMessageEntity | MessageEntity.PreMessageEntity | MessageEntity.TextLinkMessageEntity | MessageEntity.TextMentionMessageEntity; +/** This object contains information about the quoted part of a message that is replied to by the given message. */ +export interface TextQuote { + /** Text of the quoted part of a message that is replied to by the given message */ + text: string; + /** Special entities that appear in the quote. Currently, only bold, italic, underline, strikethrough, spoiler, and custom_emoji entities are kept in quotes. */ + entities?: MessageEntity[]; + /** Approximate quote position in the original message in UTF-16 code units as specified by the sender */ + position: number; + /** True, if the quote was chosen manually by the message sender. Otherwise, the quote was added automatically by the server. */ + is_manual?: true; +} +/** This object contains information about a message that is being replied to, which may come from another chat or forum topic. */ +export interface ExternalReplyInfo { + /** Origin of the message replied to by the given message */ + origin: MessageOrigin; + /** Chat the original message belongs to. Available only if the chat is a supergroup or a channel. */ + chat?: Chat; + /** Unique message identifier inside the original chat. Available only if the original chat is a supergroup or a channel. */ + message_id?: number; + /** Options used for link preview generation for the original message, if it is a text message */ + link_preview_options?: LinkPreviewOptions; + /** Message is an animation, information about the animation */ + animation?: Animation; + /** Message is an audio file, information about the file */ + audio?: Audio; + /** Message is a general file, information about the file */ + document?: Document; + /** Message is a photo, available sizes of the photo */ + photo?: PhotoSize[]; + /** Message is a sticker, information about the sticker */ + sticker?: Sticker; + /** Message is a forwarded story */ + story?: Story; + /** Message is a video, information about the video */ + video?: Video; + /** Message is a video note, information about the video message */ + video_note?: VideoNote; + /** Message is a voice message, information about the file */ + voice?: Voice; + /** True, if the message media is covered by a spoiler animation */ + has_media_spoiler?: true; + /** Message is a shared contact, information about the contact */ + contact?: Contact; + /** Message is a dice with random value */ + dice?: Dice; + /** Message is a game, information about the game. More about games » */ + game?: Game; + /** Message is a scheduled giveaway, information about the giveaway */ + giveaway?: Giveaway; + /** A giveaway with public winners was completed */ + giveaway_winners?: GiveawayWinners; + /** Message is an invoice for a payment, information about the invoice. More about payments » */ + invoice?: Invoice; + /** Message is a shared location, information about the location */ + location?: Location; + /** Message contains paid media; information about the paid media */ + paid_media?: PaidMediaInfo; + /** Message is a native poll, information about the poll */ + poll?: Poll; + /** Message is a checklist */ + checklist?: Checklist; + /** Message is a venue, information about the venue */ + venue?: Venue; +} +/** Describes reply parameters for the message that is being sent. */ +export interface ReplyParameters { + /** Identifier of the message that will be replied to in the current chat, or in the chat chat_id if it is specified */ + message_id: number; + /** If the message to be replied to is from a different chat, unique identifier for the chat or username of the channel (in the format `@channelusername`). Not supported for messages sent on behalf of a business account and messages from channel direct messages chats. */ + chat_id?: number | string; + /** Identifier of the specific checklist task to be replied to */ + checklist_task_id?: number; + /** Pass True if the message should be sent even if the specified message to be replied to is not found; can be used only for replies in the same chat and forum topic. Always True for messages sent on behalf of a business account. */ + allow_sending_without_reply?: boolean; + /** Quoted part of the message to be replied to; 0-1024 characters after entities parsing. The quote must be an exact substring of the message to be replied to, including bold, italic, underline, strikethrough, spoiler, and custom_emoji entities. The message will fail to send if the quote isn't found in the original message. */ + quote?: string; + /** Mode for parsing entities in the quote. See formatting options for more details. */ + quote_parse_mode?: ParseMode; + /** A JSON-serialized list of special entities that appear in the quote. It can be specified instead of quote_parse_mode. */ + quote_entities?: MessageEntity[]; + /** Position of the quote in the original message in UTF-16 code units */ + quote_position?: number; +} +/** This object describes the origin of a message. It can be one of + +- MessageOriginUser +- MessageOriginHiddenUser +- MessageOriginChat +- MessageOriginChannel */ +export type MessageOrigin = MessageOriginUser | MessageOriginHiddenUser | MessageOriginChat | MessageOriginChannel; +/** The message was originally sent by a known user. */ +export interface MessageOriginUser { + /** Type of the message origin, always “user” */ + type: "user"; + /** Date the message was sent originally in Unix time */ + date: number; + /** User that sent the message originally */ + sender_user: User; +} +/** The message was originally sent by an unknown user. */ +export interface MessageOriginHiddenUser { + /** Type of the message origin, always “hidden_user” */ + type: "hidden_user"; + /** Date the message was sent originally in Unix time */ + date: number; + /** Name of the user that sent the message originally */ + sender_user_name: string; +} +/** The message was originally sent on behalf of a chat to a group chat. */ +export interface MessageOriginChat { + /** Type of the message origin, always “chat” */ + type: "chat"; + /** Date the message was sent originally in Unix time */ + date: number; + /** Chat that sent the message originally */ + sender_chat: Chat; + /** For messages originally sent by an anonymous chat administrator, original message author signature */ + author_signature?: string; +} +/** The message was originally sent to a channel chat. */ +export interface MessageOriginChannel { + /** Type of the message origin, always “channel” */ + type: "channel"; + /** Date the message was sent originally in Unix time */ + date: number; + /** Channel chat to which the message was originally sent */ + chat: Chat.ChannelChat; + /** Unique message identifier inside the chat */ + message_id: number; + /** Signature of the original post author */ + author_signature?: string; +} +/** This object represents one size of a photo or a file / sticker thumbnail. */ +export interface PhotoSize { + /** Identifier for this file, which can be used to download or reuse the file */ + file_id: string; + /** Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file. */ + file_unique_id: string; + /** Photo width */ + width: number; + /** Photo height */ + height: number; + /** File size in bytes */ + file_size?: number; +} +/** This object represents an animation file (GIF or H.264/MPEG-4 AVC video without sound). */ +export interface Animation { + /** Identifier for this file, which can be used to download or reuse the file */ + file_id: string; + /** Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file. */ + file_unique_id: string; + /** Video width as defined by sender */ + width: number; + /** Video height as defined by sender */ + height: number; + /** Duration of the video in seconds as defined by sender */ + duration: number; + /** Animation thumbnail as defined by sender */ + thumbnail?: PhotoSize; + /** Original animation filename as defined by sender */ + file_name?: string; + /** MIME type of the file as defined by sender */ + mime_type?: string; + /** File size in bytes */ + file_size?: number; +} +/** This object represents an audio file to be treated as music by the Telegram clients. */ +export interface Audio { + /** Identifier for this file, which can be used to download or reuse the file */ + file_id: string; + /** Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file. */ + file_unique_id: string; + /** Duration of the audio in seconds as defined by sender */ + duration: number; + /** Performer of the audio as defined by sender or by audio tags */ + performer?: string; + /** Title of the audio as defined by sender or by audio tags */ + title?: string; + /** Original filename as defined by sender */ + file_name?: string; + /** MIME type of the file as defined by sender */ + mime_type?: string; + /** File size in bytes */ + file_size?: number; + /** Thumbnail of the album cover to which the music file belongs */ + thumbnail?: PhotoSize; +} +/** This object represents a general file (as opposed to photos, voice messages and audio files). */ +export interface Document { + /** Identifier for this file, which can be used to download or reuse the file */ + file_id: string; + /** Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file. */ + file_unique_id: string; + /** Document thumbnail as defined by sender */ + thumbnail?: PhotoSize; + /** Original filename as defined by sender */ + file_name?: string; + /** MIME type of the file as defined by sender */ + mime_type?: string; + /** File size in bytes */ + file_size?: number; +} +/** This object represents a story. */ +export interface Story { + /** Chat that posted the story */ + chat: Chat; + /** Unique identifier for the story in the chat */ + id: number; +} +/** This object represents a video file. */ +export interface Video { + /** Identifier for this file, which can be used to download or reuse the file */ + file_id: string; + /** Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file. */ + file_unique_id: string; + /** Video width as defined by sender */ + width: number; + /** Video height as defined by sender */ + height: number; + /** Duration of the video in seconds as defined by sender */ + duration: number; + /** Video thumbnail */ + thumbnail?: PhotoSize; + /** Available sizes of the cover of the video in the message */ + cover?: PhotoSize[]; + /** Timestamp in seconds from which the video will play in the message */ + start_timestamp?: number; + /** Original filename as defined by sender */ + file_name?: string; + /** MIME type of the file as defined by sender */ + mime_type?: string; + /** File size in bytes */ + file_size?: number; + /** List of available qualities of the video. */ + qualities?: VideoQuality[]; +} +/** This object represents a video file of a specific quality. */ +export interface VideoQuality { + /** Identifier for this file, which can be used to download or reuse the file */ + file_id: string; + /** Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file. */ + file_unique_id: string; + /** Video width */ + width: number; + /** Video height */ + height: number; + /** Codec that was used to encode the video, for example, “h264”, “h265”, or “av01” */ + codec: string; + /** File size in bytes. It can be bigger than 2^31 and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this value. */ + file_size?: number; +} +/** This object represents a video message (available in Telegram apps as of v.4.0). */ +export interface VideoNote { + /** Identifier for this file, which can be used to download or reuse the file */ + file_id: string; + /** Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file. */ + file_unique_id: string; + /** Video width and height (diameter of the video message) as defined by sender */ + length: number; + /** Duration of the video in seconds as defined by sender */ + duration: number; + /** Video thumbnail */ + thumbnail?: PhotoSize; + /** File size in bytes */ + file_size?: number; +} +/** This object represents a voice note. */ +export interface Voice { + /** Identifier for this file, which can be used to download or reuse the file */ + file_id: string; + /** Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file. */ + file_unique_id: string; + /** Duration of the audio in seconds as defined by sender */ + duration: number; + /** MIME type of the file as defined by sender */ + mime_type?: string; + /** File size in bytes */ + file_size?: number; +} +/** This object represents a phone contact. */ +export interface Contact { + /** Contact's phone number */ + phone_number: string; + /** Contact's first name */ + first_name: string; + /** Contact's last name */ + last_name?: string; + /** Contact's user identifier in Telegram. */ + user_id?: number; + /** Additional data about the contact in the form of a vCard */ + vcard?: string; +} +/** This object represents an animated emoji that displays a random value. */ +export interface Dice { + /** Emoji on which the dice throw animation is based */ + emoji: string; + /** Value of the dice, 1-6 for "🎲", "🎯" and "🎳" base emoji, 1-5 for "🏀" and "⚽" base emoji, 1-64 for "🎰" base emoji */ + value: number; +} +/** This object contains information about one answer option in a poll. */ +export interface PollOption { + /** Option text, 1-100 characters */ + text: string; + /** Special entities that appear in the option text. Currently, only custom emoji entities are allowed in poll option texts */ + text_entities?: MessageEntity[]; + /** Number of users that voted for this option */ + voter_count: number; +} +/** This object contains information about one answer option in a poll to send. */ +export interface InputPollOption { + /** Option text, 1-100 characters */ + text: string; + /** Mode for parsing entities in the text. See formatting options for more details. Currently, only custom emoji entities are allowed */ + text_parse_mode?: ParseMode; + /** A list of special entities that appear in the poll option text. It can be specified instead of text_parse_mode */ + text_entities?: MessageEntity[]; +} +/** This object represents an answer of a user in a non-anonymous poll. */ +export interface PollAnswer { + /** Unique poll identifier */ + poll_id: string; + /** The chat that changed the answer to the poll, if the voter is anonymous */ + voter_chat?: Chat; + /** The user that changed the answer to the poll, if the voter isn't anonymous */ + user?: User; + /** 0-based identifiers of chosen answer options. May be empty if the vote was retracted. */ + option_ids: number[]; +} +/** This object contains information about a poll. */ +export interface Poll { + /** Unique poll identifier */ + id: string; + /** Poll question, 1-300 characters */ + question: string; + /** Special entities that appear in the question. Currently, only custom emoji entities are allowed in poll questions */ + question_entities?: MessageEntity[]; + /** List of poll options */ + options: PollOption[]; + /** Total number of users that voted in the poll */ + total_voter_count: number; + /** True, if the poll is closed */ + is_closed: boolean; + /** True, if the poll is anonymous */ + is_anonymous: boolean; + /** Poll type, currently can be “regular” or “quiz” */ + type: "regular" | "quiz"; + /** True, if the poll allows multiple answers */ + allows_multiple_answers: boolean; + /** 0-based identifier of the correct answer option. Available only for polls in the quiz mode, which are closed, or was sent (not forwarded) by the bot or to the private chat with the bot. */ + correct_option_id?: number; + /** Text that is shown when a user chooses an incorrect answer or taps on the lamp icon in a quiz-style poll, 0-200 characters */ + explanation?: string; + /** Special entities like usernames, URLs, bot commands, etc. that appear in the explanation */ + explanation_entities?: MessageEntity[]; + /** Amount of time in seconds the poll will be active after creation */ + open_period?: number; + /** Point in time (Unix timestamp) when the poll will be automatically closed */ + close_date?: number; +} +/** This object represents a point on the map. */ +export interface Location { + /** Latitude as defined by sender */ + latitude: number; + /** Longitude as defined by sender */ + longitude: number; + /** The radius of uncertainty for the location, measured in meters; 0-1500 */ + horizontal_accuracy?: number; + /** Time relative to the message sending date, during which the location can be updated; in seconds. For active live locations only. */ + live_period?: number; + /** The direction in which user is moving, in degrees; 1-360. For active live locations only. */ + heading?: number; + /** The maximum distance for proximity alerts about approaching another chat member, in meters. For sent live locations only. */ + proximity_alert_radius?: number; +} +/** Describes the paid media added to a message. */ +export interface PaidMediaInfo { + /** The number of Telegram Stars that must be paid to buy access to the media */ + star_count: number; + /** Information about the paid media */ + paid_media: PaidMedia[]; +} +/** This object describes paid media. Currently, it can be one of + +- PaidMediaPreview +- PaidMediaPhoto +- PaidMediaVideo */ +export type PaidMedia = PaidMediaPreview | PaidMediaPhoto | PaidMediaVideo; +/** The paid media isn't available before the payment. */ +export interface PaidMediaPreview { + /** Type of the paid media, always “preview” */ + type: "preview"; + /** Media width as defined by the sender */ + width?: number; + /** Media height as defined by the sender */ + height?: number; + /** Duration of the media in seconds as defined by the sender */ + duration?: number; +} +/** The paid media is a photo. */ +export interface PaidMediaPhoto { + /** Type of the paid media, always “photo” */ + type: "photo"; + /** The photo */ + photo: PhotoSize[]; +} +/** The paid media is a video. */ +export interface PaidMediaVideo { + /** Type of the paid media, always “video” */ + type: "video"; + /** The video */ + video: Video; +} +/** This object represents a venue. */ +export interface Venue { + /** Venue location. Can't be a live location */ + location: Location; + /** Name of the venue */ + title: string; + /** Address of the venue */ + address: string; + /** Foursquare identifier of the venue */ + foursquare_id?: string; + /** Foursquare type of the venue. (For example, “arts_entertainment/default”, “arts_entertainment/aquarium” or “food/icecream”.) */ + foursquare_type?: string; + /** Google Places identifier of the venue */ + google_place_id?: string; + /** Google Places type of the venue. (See supported types.) */ + google_place_type?: string; +} +/** Describes data sent from a Web App to the bot. */ +export interface WebAppData { + /** The data. Be aware that a bad client can send arbitrary data in this field. */ + data: string; + /** Text of the web_app keyboard button from which the Web App was opened. Be aware that a bad client can send arbitrary data in this field. */ + button_text: string; +} +/** This object represents the content of a service message, sent whenever a user in the chat triggers a proximity alert set by another user. */ +export interface ProximityAlertTriggered { + /** User that triggered the alert */ + traveler: User; + /** User that set the alert */ + watcher: User; + /** The distance between the users */ + distance: number; +} +/** This object represents a service message about a change in auto-delete timer settings. */ +export interface MessageAutoDeleteTimerChanged { + /** New auto-delete time for messages in the chat; in seconds */ + message_auto_delete_time: number; +} +/** This object represents a service message about a user boosting a chat. */ +export interface ChatBoostAdded { + /** Number of boosts added by the user */ + boost_count: number; +} +/** This object describes the way a background is filled based on the selected colors. Currently, it can be one of + +- BackgroundFillSolid +- BackgroundFillGradient +- BackgroundFillFreeformGradient */ +export type BackgroundFill = BackgroundFillSolid | BackgroundFillGradient | BackgroundFillFreeformGradient; +/** The background is filled using the selected color. */ +export interface BackgroundFillSolid { + /** Type of the background fill, always “solid” */ + type: "solid"; + /** The color of the background fill in the RGB24 format */ + color: number; +} +/** The background is a gradient fill. */ +export interface BackgroundFillGradient { + /** Type of the background fill, always “gradient” */ + type: "gradient"; + /** Top color of the gradient in the RGB24 format */ + top_color: number; + /** Bottom color of the gradient in the RGB24 format */ + bottom_color: number; + /** Clockwise rotation angle of the background fill in degrees; 0-359 */ + rotation_angle: number; +} +/** The background is a freeform gradient that rotates after every message in the chat. */ +export interface BackgroundFillFreeformGradient { + /** Type of the background fill, always “freeform_gradient” */ + type: "freeform_gradient"; + /** A list of the 3 or 4 base colors that are used to generate the freeform gradient in the RGB24 format */ + colors: number[]; +} +/** This object describes the type of a background. Currently, it can be one of + +- BackgroundTypeFill +- BackgroundTypeWallpaper +- BackgroundTypePattern +- BackgroundTypeChatTheme +- BackgroundTypeFill */ +export type BackgroundType = BackgroundTypeFill | BackgroundTypeWallpaper | BackgroundTypePattern | BackgroundTypeChatTheme; +/** The background is automatically filled based on the selected colors. */ +export interface BackgroundTypeFill { + /** Type of the background, always “fill” */ + type: "fill"; + /** The background fill */ + fill: BackgroundFill; + /** Dimming of the background in dark themes, as a percentage; 0-100 */ + dark_theme_dimming: number; +} +/** The background is a wallpaper in the JPEG format. */ +export interface BackgroundTypeWallpaper { + /** Type of the background, always “wallpaper” */ + type: "wallpaper"; + /** Document with the wallpaper */ + document: Document; + /** Dimming of the background in dark themes, as a percentage; 0-100 */ + dark_theme_dimming: number; + /** True, if the wallpaper is downscaled to fit in a 450x450 square and then box-blurred with radius 12 */ + is_blurred?: true; + /** True, if the background moves slightly when the device is tilted */ + is_moving?: true; +} +/** The background is a .PNG or .TGV (gzipped subset of SVG with MIME type “application/x-tgwallpattern”) pattern to be combined with the background fill chosen by the user. */ +export interface BackgroundTypePattern { + /** Type of the background, always “pattern” */ + type: "pattern"; + /** Document with the pattern */ + document: Document; + /** The background fill that is combined with the pattern */ + fill: BackgroundFill; + /** Intensity of the pattern when it is shown above the filled background; 0-100 */ + intensity: number; + /** True, if the background fill must be applied only to the pattern itself. All other pixels are black in this case. For dark themes only */ + is_inverted?: true; + /** True, if the background moves slightly when the device is tilted */ + is_moving?: true; +} +/** The background is taken directly from a built-in chat theme. */ +export interface BackgroundTypeChatTheme { + /** Type of the background, always “chat_theme” */ + type: "chat_theme"; + /** Name of the chat theme, which is usually an emoji */ + theme_name: string; +} +/** This object represents a chat background. */ +export interface ChatBackground { + /** Type of the background*/ + type: BackgroundType; +} +/** This object represents a service message about a new forum topic created in the chat. */ +export interface ForumTopicCreated { + /** Name of the topic */ + name: string; + /** True, if the name of the topic wasn't specified explicitly by its creator and likely needs to be changed by the bot */ + is_name_implicit?: true; + /** Color of the topic icon in RGB format */ + icon_color: number; + /** Unique identifier of the custom emoji shown as the topic icon */ + icon_custom_emoji_id?: string; +} +/** This object represents a service message about an edited forum topic. */ +export interface ForumTopicEdited { + /** New name of the topic, if it was edited */ + name?: string; + /** New identifier of the custom emoji shown as the topic icon, if it was edited; an empty string if the icon was removed */ + icon_custom_emoji_id?: string; +} +/** This object represents a service message about a forum topic closed in the chat. Currently holds no information. */ +export interface ForumTopicClosed { +} +/** This object represents a service message about a forum topic reopened in the chat. Currently holds no information. */ +export interface ForumTopicReopened { +} +/** This object represents a service message about General forum topic hidden in the chat. Currently holds no information. */ +export interface GeneralForumTopicHidden { +} +/** This object represents a service message about General forum topic unhidden in the chat. Currently holds no information. */ +export interface GeneralForumTopicUnhidden { +} +/** This object contains information about a user that was shared with the bot using a KeyboardButtonRequestUsers button. */ +export interface SharedUser { + /** Identifier of the shared user. The bot may not have access to the user and could be unable to use this identifier, unless the user is already known to the bot by some other means. */ + user_id: number; + /** First name of the user, if the name was requested by the bot */ + first_name?: string; + /** Last name of the user, if the name was requested by the bot */ + last_name?: string; + /** Username of the user, if the username was requested by the bot */ + username?: string; + /** Available sizes of the chat photo, if the photo was requested by the bot */ + photo?: PhotoSize[]; +} +/** This object contains information about the user whose identifier was shared with the bot using a KeyboardButtonRequestUsers button. */ +export interface UsersShared { + /** Identifier of the request */ + request_id: number; + /** Information about users shared with the bot. */ + users: SharedUser[]; +} +/** This object contains information about a chat that was shared with the bot using a KeyboardButtonRequestChat button. */ +export interface ChatShared { + /** Identifier of the request */ + request_id: number; + /** Identifier of the shared chat. The bot may not have access to the chat and could be unable to use this identifier, unless the chat is already known to the bot by some other means. */ + chat_id: number; + /** Title of the chat, if the title was requested by the bot. */ + title?: string; + /** Username of the chat, if the username was requested by the bot and available. */ + username?: string; + /** Available sizes of the chat photo, if the photo was requested by the bot */ + photo?: PhotoSize[]; +} +/** This object represents a service message about a user allowing a bot to write messages after adding it to the attachment menu, launching a Web App from a link, or accepting an explicit request from a Web App sent by the method requestWriteAccess. */ +export interface WriteAccessAllowed { + /** True, if the access was granted after the user accepted an explicit request from a Web App sent by the method requestWriteAccess */ + from_request?: boolean; + /** Name of the Web App, if the access was granted when the Web App was launched from a link */ + web_app_name?: string; + /** True, if the access was granted when the bot was added to the attachment or side menu */ + from_attachment_menu?: boolean; +} +/** Describes a service message about a change in the price of direct messages sent to a channel chat. */ +export interface DirectMessagePriceChanged { + /** True, if direct messages are enabled for the channel chat; false otherwise */ + are_direct_messages_enabled: boolean; + /** The new number of Telegram Stars that must be paid by users for each direct message sent to the channel. Defaults to 0. */ + direct_message_star_count?: number; +} +/** This object represents a service message about a video chat scheduled in the chat. */ +export interface VideoChatScheduled { + /** Point in time (Unix timestamp) when the video chat is supposed to be started by a chat administrator */ + start_date: number; +} +/** This object represents a service message about a video chat started in the chat. Currently holds no information. */ +export interface VideoChatStarted { +} +/** This object represents a service message about a video chat ended in the chat. */ +export interface VideoChatEnded { + /** Video chat duration in seconds */ + duration: number; +} +/** This object represents a service message about new members invited to a video chat. */ +export interface VideoChatParticipantsInvited { + /** New members that were invited to the video chat */ + users: User[]; +} +/** This object represents a service message about the creation of a scheduled giveaway. */ +export interface GiveawayCreated { + /** The number of Telegram Stars to be split between giveaway winners; for Telegram Star giveaways only */ + prize_star_count?: number; +} +/** This object represents a message about a scheduled giveaway. */ +export interface Giveaway { + /** The list of chats which the user must join to participate in the giveaway */ + chats: Chat[]; + /** Point in time (Unix timestamp) when winners of the giveaway will be selected */ + winners_selection_date: number; + /** The number of users which are supposed to be selected as winners of the giveaway */ + winner_count: number; + /** True, if only users who join the chats after the giveaway started should be eligible to win */ + only_new_members?: true; + /** True, if the list of giveaway winners will be visible to everyone */ + has_public_winners?: true; + /** Description of additional giveaway prize */ + prize_description?: string; + /** A list of two-letter ISO 3166-1 alpha-2 country codes indicating the countries from which eligible users for the giveaway must come. If empty, then all users can participate in the giveaway. Users with a phone number that was bought on Fragment can always participate in giveaways. */ + country_codes?: string[]; + /** The number of Telegram Stars to be split between giveaway winners; for Telegram Star giveaways only */ + prize_star_count?: number; + /** The number of months the Telegram Premium subscription won from the giveaway will be active for; for Telegram Premium giveaways only */ + premium_subscription_month_count?: number; +} +/** This object represents a message about the completion of a giveaway with public winners. */ +export interface GiveawayWinners { + /** The chat that created the giveaway */ + chat: Chat; + /** Identifier of the message with the giveaway in the chat */ + giveaway_message_id: number; + /** Point in time (Unix timestamp) when winners of the giveaway were selected */ + winners_selection_date: number; + /** Total number of winners in the giveaway */ + winner_count: number; + /** List of up to 100 winners of the giveaway */ + winners: User[]; + /** The number of other chats the user had to join in order to be eligible for the giveaway */ + additional_chat_count?: number; + /** The number of Telegram Stars that were split between giveaway winners; for Telegram Star giveaways only */ + prize_star_count?: number; + /** The number of months the Telegram Premium subscription won from the giveaway will be active for; for Telegram Premium giveaways only */ + premium_subscription_month_count?: number; + /** Number of undistributed prizes */ + unclaimed_prize_count?: number; + /** True, if only users who had joined the chats after the giveaway started were eligible to win */ + only_new_members?: true; + /** True, if the giveaway was canceled because the payment for it was refunded */ + was_refunded?: true; + /** Description of additional giveaway prize */ + prize_description?: string; +} +/** This object represents a service message about the completion of a giveaway without public winners. */ +export interface GiveawayCompleted { + /** Number of winners in the giveaway */ + winner_count: number; + /** Number of undistributed prizes */ + unclaimed_prize_count?: number; + /** Message with the giveaway that was completed, if it wasn't deleted */ + giveaway_message?: Message; + /** True, if the giveaway is a Telegram Star giveaway. Otherwise, currently, the giveaway is a Telegram Premium giveaway. */ + is_star_giveaway?: true; +} +/** Describes the options used for link preview generation. */ +export interface LinkPreviewOptions { + /** True, if the link preview is disabled */ + is_disabled?: boolean; + /** URL to use for the link preview. If empty, then the first URL found in the message text will be used */ + url?: string; + /** True, if the media in the link preview is supposed to be shrunk; ignored if the URL isn't explicitly specified or media size change isn't supported for the preview */ + prefer_small_media?: boolean; + /** True, if the media in the link preview is supposed to be enlarged; ignored if the URL isn't explicitly specified or media size change isn't supported for the preview */ + prefer_large_media?: boolean; + /** True, if the link preview must be shown above the message text; otherwise, the link preview will be shown below the message text */ + show_above_text?: boolean; +} +/** This object represents a sticker. */ +export interface Sticker { + /** Identifier for this file, which can be used to download or reuse the file */ + file_id: string; + /** Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file. */ + file_unique_id: string; + /** Type of the sticker, currently one of “regular”, “mask”, “custom_emoji”. The type of the sticker is independent from its format, which is determined by the fields is_animated and is_video. */ + type: "regular" | "mask" | "custom_emoji"; + /** Sticker width */ + width: number; + /** Sticker height */ + height: number; + /** True, if the sticker is animated */ + is_animated: boolean; + /** True, if the sticker is a video sticker */ + is_video: boolean; + /** Sticker thumbnail in the .WEBP or .JPG format */ + thumbnail?: PhotoSize; + /** Emoji associated with the sticker */ + emoji?: string; + /** Name of the sticker set to which the sticker belongs */ + set_name?: string; + /** For premium regular stickers, premium animation for the sticker */ + premium_animation?: File; + /** For mask stickers, the position where the mask should be placed */ + mask_position?: MaskPosition; + /** For custom emoji stickers, unique identifier of the custom emoji */ + custom_emoji_id?: string; + /** File size in bytes */ + file_size?: number; +} +/** This object represents a sticker set. */ +export interface StickerSet { + /** Sticker set name */ + name: string; + /** Sticker set title */ + title: string; + /** Type of stickers in the set, currently one of “regular”, “mask”, “custom_emoji” */ + sticker_type: "regular" | "mask" | "custom_emoji"; + /** List of all set stickers */ + stickers: Sticker[]; + /** Sticker set thumbnail in the .WEBP, .TGS, or .WEBM format */ + thumbnail?: PhotoSize; +} +/** This object describes the position on faces where a mask should be placed by default. */ +export interface MaskPosition { + /** The part of the face relative to which the mask should be placed. One of “forehead”, “eyes”, “mouth”, or “chin”. */ + point: "forehead" | "eyes" | "mouth" | "chin"; + /** Shift by X-axis measured in widths of the mask scaled to the face size, from left to right. For example, choosing -1.0 will place mask just to the left of the default mask position. */ + x_shift: number; + /** Shift by Y-axis measured in heights of the mask scaled to the face size, from top to bottom. For example, 1.0 will place the mask just below the default mask position. */ + y_shift: number; + /** Mask scaling coefficient. For example, 2.0 means double size. */ + scale: number; +} +/** This object represents a game. Use BotFather to create and edit games, their short names will act as unique identifiers. */ +export interface Game { + /** Title of the game */ + title: string; + /** Description of the game */ + description: string; + /** Photo that will be displayed in the game message in chats. */ + photo: PhotoSize[]; + /** Brief description of the game or high scores included in the game message. Can be automatically edited to include current high scores for the game when the bot calls setGameScore, or manually edited using editMessageText. 0-4096 characters. */ + text: string; + /** Special entities that appear in text, such as usernames, URLs, bot commands, etc. */ + text_entities: MessageEntity[]; + /** Animation that will be displayed in the game message in chats. Upload via BotFather */ + animation: Animation; +} +/** This object represents one row of the high scores table for a game. */ +export interface GameHighScore { + /** Position in high score table for the game */ + position: number; + /** User */ + user: User; + /** Score */ + score: number; +} +/** This object represents a file ready to be downloaded. The file can be downloaded via the link https://api.telegram.org/file/bot/. It is guaranteed that the link will be valid for at least 1 hour. When the link expires, a new one can be requested by calling getFile. */ +export interface File { + /** Identifier for this file, which can be used to download or reuse the file */ + file_id: string; + /** Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file. */ + file_unique_id: string; + /** File size in bytes */ + file_size?: number; + /** File path. Use https://api.telegram.org/file/bot/ to get the file. */ + file_path?: string; +} +/** This object describes the type of a reaction. Currently, it can be one of + +- ReactionTypeEmoji +- ReactionTypeCustomEmoji +- ReactionTypePaid */ +export type ReactionType = ReactionTypeEmoji | ReactionTypeCustomEmoji | ReactionTypePaid; +/** The reaction is based on an emoji. */ +export interface ReactionTypeEmoji { + /** Type of the reaction, always “emoji” */ + type: "emoji"; + /** Reaction emoji. Currently, it can be one of "👍", "👎", "❤", "🔥", "🥰", "👏", "😁", "🤔", "🤯", "😱", "🤬", "😢", "🎉", "🤩", "🤮", "💩", "🙏", "👌", "🕊", "🤡", "🥱", "🥴", "😍", "🐳", "❤‍🔥", "🌚", "🌭", "💯", "🤣", "⚡", "🍌", "🏆", "💔", "🤨", "😐", "🍓", "🍾", "💋", "🖕", "😈", "😴", "😭", "🤓", "👻", "👨‍💻", "👀", "🎃", "🙈", "😇", "😨", "🤝", "✍", "🤗", "🫡", "🎅", "🎄", "☃", "💅", "🤪", "🗿", "🆒", "💘", "🙉", "🦄", "😘", "💊", "🙊", "😎", "👾", "🤷‍♂", "🤷", "🤷‍♀", "😡" */ + emoji: "👍" | "👎" | "❤" | "🔥" | "🥰" | "👏" | "😁" | "🤔" | "🤯" | "😱" | "🤬" | "😢" | "🎉" | "🤩" | "🤮" | "💩" | "🙏" | "👌" | "🕊" | "🤡" | "🥱" | "🥴" | "😍" | "🐳" | "❤‍🔥" | "🌚" | "🌭" | "💯" | "🤣" | "⚡" | "🍌" | "🏆" | "💔" | "🤨" | "😐" | "🍓" | "🍾" | "💋" | "🖕" | "😈" | "😴" | "😭" | "🤓" | "👻" | "👨‍💻" | "👀" | "🎃" | "🙈" | "😇" | "😨" | "🤝" | "✍" | "🤗" | "🫡" | "🎅" | "🎄" | "☃" | "💅" | "🤪" | "🗿" | "🆒" | "💘" | "🙉" | "🦄" | "😘" | "💊" | "🙊" | "😎" | "👾" | "🤷‍♂" | "🤷" | "🤷‍♀" | "😡"; +} +/** The reaction is based on a custom emoji. */ +export interface ReactionTypeCustomEmoji { + /** Type of the reaction, always “custom_emoji” */ + type: "custom_emoji"; + /** Custom emoji identifier */ + custom_emoji_id: string; +} +/** The reaction is paid. */ +export interface ReactionTypePaid { + /** Type of the reaction, always “paid” */ + type: "paid"; +} +/** Represents a reaction added to a message along with the number of times it was added. */ +export interface ReactionCount { + /** Type of the reaction */ + type: ReactionType; + /** Number of times the reaction was added */ + total_count: number; +} +/** This object represents a change of a reaction on a message performed by a user. */ +export interface MessageReactionUpdated { + /** The chat containing the message the user reacted to */ + chat: Chat; + /** Unique identifier of the message inside the chat */ + message_id: number; + /** The user that changed the reaction, if the user isn't anonymous */ + user?: User; + /** The chat on behalf of which the reaction was changed, if the user is anonymous */ + actor_chat?: Chat; + /** Date of the change in Unix time */ + date: number; + /** Previous list of reaction types that were set by the user */ + old_reaction: ReactionType[]; + /** New list of reaction types that have been set by the user */ + new_reaction: ReactionType[]; +} +/** This object represents reaction changes on a message with anonymous reactions. */ +export interface MessageReactionCountUpdated { + /** The chat containing the message */ + chat: Chat; + /** Unique message identifier inside the chat */ + message_id: number; + /** Date of the change in Unix time */ + date: number; + /** List of reactions that are present on the message */ + reactions: ReactionCount[]; +} +/** Describes an inline message to be sent by a user of a Mini App. */ +export interface PreparedInlineMessage { + /** Unique identifier of the prepared message */ + id: string; + /** Expiration date of the prepared message, in Unix time. Expired prepared messages can no longer be used */ + expiration_date: number; +} +/** Describes a topic of a direct messages chat. */ +export interface DirectMessagesTopic { + /** Unique identifier of the topic */ + topic_id: number; + /** Information about the user that created the topic. Currently, it is always present */ + user: User; +} +/** Contains parameters of a post that is being suggested by the bot. */ +export interface SuggestedPostParameters { + /** Proposed price for the post. If the field is omitted, then the post is unpaid. */ + price?: SuggestedPostPrice; + /** Proposed send date of the post. If specified, then the date must be between 300 second and 2678400 seconds (30 days) in the future. If the field is omitted, then the post can be published at any time within 30 days at the sole discretion of the user who approves it. */ + send_date?: number; +} +export {}; diff --git a/sandbox/tgbot/node_modules/@grammyjs/types/methods.d.ts b/sandbox/tgbot/node_modules/@grammyjs/types/methods.d.ts new file mode 100644 index 0000000..6757b4b --- /dev/null +++ b/sandbox/tgbot/node_modules/@grammyjs/types/methods.d.ts @@ -0,0 +1,2429 @@ +import type { InputChecklist } from "./checklist.js"; +import type { InlineQueryResult, InlineQueryResultsButton } from "./inline.js"; +import type { LanguageCode } from "./langs.js"; +import type { AcceptedGiftTypes, BotCommand, BusinessConnection, ChatAdministratorRights, ChatFullInfo, ChatInviteLink, ChatMember, ChatMemberAdministrator, ChatMemberOwner, ChatPermissions, ForumTopic, UserChatBoosts, UserFromGetMe, UserProfileAudios, UserProfilePhotos, WebhookInfo } from "./manage.js"; +import type { ForceReply, InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove } from "./markup.js"; +import type { File, GameHighScore, InputPollOption, LinkPreviewOptions, MaskPosition, Message, MessageEntity, MessageId, ParseMode, Poll, PreparedInlineMessage, ReactionType, ReplyParameters, SentWebAppMessage, Sticker, StickerSet, Story, SuggestedPostParameters } from "./message.js"; +import type { PassportElementError } from "./passport.js"; +import type { Gifts, LabeledPrice, OwnedGifts, ShippingOption, StarAmount, StarTransactions } from "./payment.js"; +import type { BotCommandScope, BotDescription, BotName, BotShortDescription, MenuButton } from "./settings.js"; +import { StoryArea } from "./story.js"; +import type { Update } from "./update.js"; +/** Extracts the parameters of a given method name */ +type Params> = Parameters[M]>; +/** Utility type providing the argument type for the given method name or `{}` if the method does not take any parameters */ +export type Opts = { + [M in keyof ApiMethods]: Params[0] extends undefined ? {} : NonNullable[0]>; +}; +/** Wrapper type to bundle all methods of the Telegram Bot API */ +export type ApiMethods = { + /** Use this method to receive incoming updates using long polling (wiki). Returns an Array of Update objects. + + Notes + 1. This method will not work if an outgoing webhook is set up. + 2. In order to avoid getting duplicate updates, recalculate offset after each server response. */ + getUpdates(args?: { + /** Identifier of the first update to be returned. Must be greater by one than the highest among the identifiers of previously received updates. By default, updates starting with the earliest unconfirmed update are returned. An update is considered confirmed as soon as getUpdates is called with an offset higher than its update_id. The negative offset can be specified to retrieve updates starting from -offset update from the end of the updates queue. All previous updates will be forgotten. */ + offset?: number; + /** Limits the number of updates to be retrieved. Values between 1-100 are accepted. Defaults to 100. */ + limit?: number; + /** Timeout in seconds for long polling. Defaults to 0, i.e. usual short polling. Should be positive, short polling should be used for testing purposes only. */ + timeout?: number; + /** A list of the update types you want your bot to receive. For example, specify ["message", "edited_channel_post", "callback_query"] to only receive updates of these types. See Update for a complete list of available update types. Specify an empty list to receive all update types except chat_member, message_reaction, and message_reaction_count (default). If not specified, the previous setting will be used. + + Please note that this parameter doesn't affect updates created before the call to getUpdates, so unwanted updates may be received for a short period of time. */ + allowed_updates?: ReadonlyArray>; + }): Update[]; + /** Use this method to specify a URL and receive incoming updates via an outgoing webhook. Whenever there is an update for the bot, we will send an HTTPS POST request to the specified URL, containing a JSON-serialized Update. In case of an unsuccessful request (a request with response HTTP status code different from 2XY), we will repeat the request and give up after a reasonable amount of attempts. Returns True on success. + + If you'd like to make sure that the webhook was set by you, you can specify secret data in the parameter secret_token. If specified, the request will contain a header “X-Telegram-Bot-Api-Secret-Token” with the secret token as content. + + Notes + 1. You will not be able to receive updates using getUpdates for as long as an outgoing webhook is set up. + 2. To use a self-signed certificate, you need to upload your public key certificate using certificate parameter. Please upload as InputFile, sending a String will not work. + 3. Ports currently supported for Webhooks: 443, 80, 88, 8443. + + If you're having any trouble setting up webhooks, please check out this amazing guide to webhooks. */ + setWebhook(args: { + /** HTTPS URL to send updates to. Use an empty string to remove webhook integration */ + url: string; + /** Upload your public key certificate so that the root certificate in use can be checked. See our self-signed guide for details. */ + certificate?: F; + /** The fixed IP address which will be used to send webhook requests instead of the IP address resolved through DNS */ + ip_address?: string; + /** The maximum allowed number of simultaneous HTTPS connections to the webhook for update delivery, 1-100. Defaults to 40. Use lower values to limit the load on your bot's server, and higher values to increase your bot's throughput. */ + max_connections?: number; + /** A list of the update types you want your bot to receive. For example, specify ["message", "edited_channel_post", "callback_query"] to only receive updates of these types. See Update for a complete list of available update types. Specify an empty list to receive all update types except chat_member, message_reaction, and message_reaction_count (default). If not specified, the previous setting will be used. + + Please note that this parameter doesn't affect updates created before the call to the setWebhook, so unwanted updates may be received for a short period of time. */ + allowed_updates?: ReadonlyArray>; + /** Pass True to drop all pending updates */ + drop_pending_updates?: boolean; + /** A secret token to be sent in a header “X-Telegram-Bot-Api-Secret-Token” in every webhook request, 1-256 characters. Only characters A-Z, a-z, 0-9, _ and - are allowed. The header is useful to ensure that the request comes from a webhook set by you. */ + secret_token?: string; + }): true; + /** Use this method to remove webhook integration if you decide to switch back to getUpdates. Returns True on success. */ + deleteWebhook(args?: { + /** Pass True to drop all pending updates */ + drop_pending_updates?: boolean; + }): true; + /** Use this method to get current webhook status. Requires no parameters. On success, returns a WebhookInfo object. If the bot is using getUpdates, will return an object with the url field empty. */ + getWebhookInfo(): WebhookInfo; + /** A simple method for testing your bot's authentication token. Requires no parameters. Returns basic information about the bot in form of a User object. */ + getMe(): UserFromGetMe; + /** Use this method to log out from the cloud Bot API server before launching the bot locally. You must log out the bot before running it locally, otherwise there is no guarantee that the bot will receive updates. After a successful call, you can immediately log in on a local server, but will not be able to log in back to the cloud Bot API server for 10 minutes. Returns True on success. Requires no parameters. */ + logOut(): true; + /** Use this method to close the bot instance before moving it from one local server to another. You need to delete the webhook before calling this method to ensure that the bot isn't launched again after server restart. The method will return error 429 in the first 10 minutes after the bot is launched. Returns True on success. Requires no parameters. */ + close(): true; + /** Use this method to send text messages. On success, the sent Message is returned. */ + sendMessage(args: { + /** Unique identifier of the business connection on behalf of which the message will be sent */ + business_connection_id?: string; + /** Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) */ + chat_id: number | string; + /** Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only */ + message_thread_id?: number; + /** Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat */ + direct_messages_topic_id?: number; + /** Text of the message to be sent, 1-4096 characters after entities parsing */ + text: string; + /** Mode for parsing entities in the message text. See formatting options for more details. */ + parse_mode?: ParseMode; + /** A list of special entities that appear in message text, which can be specified instead of parse_mode */ + entities?: MessageEntity[]; + /** Link preview generation options for the message */ + link_preview_options?: LinkPreviewOptions; + /** Sends the message silently. Users will receive a notification with no sound. */ + disable_notification?: boolean; + /** Protects the contents of the sent message from forwarding and saving */ + protect_content?: boolean; + /** Pass True to allow up to 1000 messages per second, ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance */ + allow_paid_broadcast?: boolean; + /** An object containing the parameters of the suggested post to send; for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post is automatically declined. */ + suggested_post_parameters?: SuggestedPostParameters; + /** Unique identifier of the message effect to be added to the message; for private chats only */ + message_effect_id?: string; + /** Description of the message to reply to */ + reply_parameters?: ReplyParameters; + /** Additional interface options. An object for an inline keyboard, custom reply keyboard, instructions to remove a reply keyboard or to force a reply from the user. */ + reply_markup?: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply; + /** @deprecated Use `reply_parameters` instead. */ + reply_to_message_id?: number; + }): Message.TextMessage; + /** Use this method to stream a partial message to a user while the message is being generated; supported only for bots with forum topic mode enabled. Returns True on success. */ + sendMessageDraft(args: { + /** Unique identifier for the target private chat */ + chat_id: number; + /** Unique identifier for the target message thread */ + message_thread_id?: number; + /** Unique identifier of the message draft; must be non-zero. Changes of drafts with the same identifier are animated */ + draft_id: number; + /** Text of the message to be sent, 1-4096 characters after entities parsing */ + text: string; + /** Mode for parsing entities in the message text. See formatting options for more details. */ + parse_mode?: ParseMode; + /** A list of special entities that appear in message text, which can be specified instead of parse_mode */ + entities?: MessageEntity[]; + }): true; + /** Use this method to forward messages of any kind. Service messages and messages with protected content can't be forwarded. On success, the sent Message is returned. */ + forwardMessage(args: { + /** Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) */ + chat_id: number | string; + /** Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only */ + message_thread_id?: number; + /** Identifier of the direct messages topic to which the message will be forwarded; required if the message is forwarded to a direct messages chat */ + direct_messages_topic_id?: number; + /** Unique identifier for the chat where the original message was sent (or channel username in the format `@channelusername`) */ + from_chat_id: number | string; + /** New start timestamp for the copied video in the message */ + video_start_timestamp?: number; + /** Unique identifier of the message effect to be added to the message; only available when forwarding to private chats */ + message_effect_id?: string; + /** An object containing the parameters of the suggested post to send; for direct messages chats only */ + suggested_post_parameters?: SuggestedPostParameters; + /** Sends the message silently. Users will receive a notification with no sound. */ + disable_notification?: boolean; + /** Protects the contents of the forwarded message from forwarding and saving */ + protect_content?: boolean; + /** Message identifier in the chat specified in from_chat_id */ + message_id: number; + }): Message; + /** Use this method to forward multiple messages of any kind. If some of the specified messages can't be found or forwarded, they are skipped. Service messages and messages with protected content can't be forwarded. Album grouping is kept for forwarded messages. On success, an array of MessageId of the sent messages is returned. */ + forwardMessages(args: { + /** Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) */ + chat_id: number | string; + /** Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only */ + message_thread_id?: number; + /** Identifier of the direct messages topic to which the messages will be forwarded; required if the messages are forwarded to a direct messages chat */ + direct_messages_topic_id?: number; + /** Unique identifier for the chat where the original messages were sent (or channel username in the format `@channelusername`) */ + from_chat_id: number | string; + /** A list of 1-100 identifiers of messages in the chat from_chat_id to forward. The identifiers must be specified in a strictly increasing order. */ + message_ids: number[]; + /** Sends the messages silently. Users will receive a notification with no sound. */ + disable_notification?: boolean; + /** Protects the contents of the forwarded messages from forwarding and saving */ + protect_content?: boolean; + }): MessageId[]; + /** Use this method to copy messages of any kind. Service messages, paid media messages, giveaway messages, giveaway winners messages, and invoice messages can't be copied. A quiz poll can be copied only if the value of the field correct_option_id is known to the bot. The method is analogous to the method forwardMessage, but the copied message doesn't have a link to the original message. Returns the MessageId of the sent message on success. */ + copyMessage(args: { + /** Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) */ + chat_id: number | string; + /** Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only */ + message_thread_id?: number; + /** Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat */ + direct_messages_topic_id?: number; + /** Unique identifier for the chat where the original message was sent (or channel username in the format `@channelusername`) */ + from_chat_id: number | string; + /** Message identifier in the chat specified in from_chat_id */ + message_id: number; + /** New start timestamp for the copied video in the message */ + video_start_timestamp?: number; + /** New caption for media, 0-1024 characters after entities parsing. If not specified, the original caption is kept */ + caption?: string; + /** Mode for parsing entities in the new caption. See formatting options for more details. */ + parse_mode?: ParseMode; + /** A list of special entities that appear in the new caption, which can be specified instead of parse_mode */ + caption_entities?: MessageEntity[]; + /** Pass True, if the caption must be shown above the message media. Ignored if a new caption isn't specified. */ + show_caption_above_media?: boolean; + /** Sends the message silently. Users will receive a notification with no sound. */ + disable_notification?: boolean; + /** Protects the contents of the sent message from forwarding and saving */ + protect_content?: boolean; + /** Pass True to allow up to 1000 messages per second, ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance */ + allow_paid_broadcast?: boolean; + /** Unique identifier of the message effect to be added to the message; only available when copying to private chats */ + message_effect_id?: string; + /** An object containing the parameters of the suggested post to send; for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post is automatically declined. */ + suggested_post_parameters?: SuggestedPostParameters; + /** Description of the message to reply to */ + reply_parameters?: ReplyParameters; + /** Additional interface options. An object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user. */ + reply_markup?: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply; + /** @deprecated Use `reply_parameters` instead. */ + reply_to_message_id?: number; + }): MessageId; + /** Use this method to copy messages of any kind. If some of the specified messages can't be found or copied, they are skipped. Service messages, paid media messages, giveaway messages, giveaway winners messages, and invoice messages can't be copied. A quiz poll can be copied only if the value of the field correct_option_id is known to the bot. The method is analogous to the method forwardMessages, but the copied messages don't have a link to the original message. Album grouping is kept for copied messages. On success, an array of MessageId of the sent messages is returned. */ + copyMessages(args: { + /** Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) */ + chat_id: number | string; + /** Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only */ + message_thread_id?: number; + /** Identifier of the direct messages topic to which the messages will be sent; required if the messages are sent to a direct messages chat */ + direct_messages_topic_id?: number; + /** Unique identifier for the chat where the original messages were sent (or channel username in the format `@channelusername`) */ + from_chat_id: number | string; + /** A list of 1-100 identifiers of messages in the chat from_chat_id to copy. The identifiers must be specified in a strictly increasing order. */ + message_ids: number[]; + /** Sends the messages silently. Users will receive a notification with no sound. */ + disable_notification?: boolean; + /** Protects the contents of the sent messages from forwarding and saving */ + protect_content?: boolean; + /** Pass True to copy the messages without their captions */ + remove_caption?: boolean; + }): MessageId[]; + /** Use this method to send photos. On success, the sent Message is returned. */ + sendPhoto(args: { + /** Unique identifier of the business connection on behalf of which the message will be sent */ + business_connection_id?: string; + /** Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) */ + chat_id: number | string; + /** Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only */ + message_thread_id?: number; + /** Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat */ + direct_messages_topic_id?: number; + /** Photo to send. Pass a file_id as String to send a photo that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a photo from the Internet, or upload a new photo using multipart/form-data. The photo must be at most 10 MB in size. The photo's width and height must not exceed 10000 in total. Width and height ratio must be at most 20. */ + photo: F | string; + /** Photo caption (may also be used when resending photos by file_id), 0-1024 characters after entities parsing */ + caption?: string; + /** Mode for parsing entities in the photo caption. See formatting options for more details. */ + parse_mode?: ParseMode; + /** A list of special entities that appear in the caption, which can be specified instead of parse_mode */ + caption_entities?: MessageEntity[]; + /** Pass True, if the caption must be shown above the message media */ + show_caption_above_media?: boolean; + /** Pass True if the photo needs to be covered with a spoiler animation */ + has_spoiler?: boolean; + /** Sends the message silently. Users will receive a notification with no sound. */ + disable_notification?: boolean; + /** Protects the contents of the sent message from forwarding and saving */ + protect_content?: boolean; + /** Pass True to allow up to 1000 messages per second, ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance */ + allow_paid_broadcast?: boolean; + /** An object containing the parameters of the suggested post to send; for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post is automatically declined. */ + suggested_post_parameters?: SuggestedPostParameters; + /** Unique identifier of the message effect to be added to the message; for private chats only */ + message_effect_id?: string; + /** Description of the message to reply to */ + reply_parameters?: ReplyParameters; + /** Additional interface options. An object for an inline keyboard, custom reply keyboard, instructions to remove a reply keyboard or to force a reply from the user. */ + reply_markup?: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply; + /** @deprecated Use `reply_parameters` instead. */ + reply_to_message_id?: number; + }): Message.PhotoMessage; + /** Use this method to send audio files, if you want Telegram clients to display them in the music player. Your audio must be in the .MP3 or .M4A format. On success, the sent Message is returned. Bots can currently send audio files of up to 50 MB in size, this limit may be changed in the future. + + For sending voice messages, use the sendVoice method instead. */ + sendAudio(args: { + /** Unique identifier of the business connection on behalf of which the message will be sent */ + business_connection_id?: string; + /** Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) */ + chat_id: number | string; + /** Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only */ + message_thread_id?: number; + /** Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat */ + direct_messages_topic_id?: number; + /** Audio file to send. Pass a file_id as String to send an audio file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get an audio file from the Internet, or upload a new one using multipart/form-data. */ + audio: F | string; + /** Audio caption, 0-1024 characters after entities parsing */ + caption?: string; + /** Mode for parsing entities in the audio caption. See formatting options for more details. */ + parse_mode?: ParseMode; + /** A list of special entities that appear in the caption, which can be specified instead of parse_mode */ + caption_entities?: MessageEntity[]; + /** Duration of the audio in seconds */ + duration?: number; + /** Performer */ + performer?: string; + /** Track name */ + title?: string; + /** Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass "attach://" if the thumbnail was uploaded using multipart/form-data under . */ + thumbnail?: F; + /** Sends the message silently. Users will receive a notification with no sound. */ + disable_notification?: boolean; + /** Protects the contents of the sent message from forwarding and saving */ + protect_content?: boolean; + /** Pass True to allow up to 1000 messages per second, ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance */ + allow_paid_broadcast?: boolean; + /** An object containing the parameters of the suggested post to send; for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post is automatically declined. */ + suggested_post_parameters?: SuggestedPostParameters; + /** Unique identifier of the message effect to be added to the message; for private chats only */ + message_effect_id?: string; + /** Description of the message to reply to */ + reply_parameters?: ReplyParameters; + /** Additional interface options. An object for an inline keyboard, custom reply keyboard, instructions to remove a reply keyboard or to force a reply from the user. */ + reply_markup?: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply; + /** @deprecated Use `reply_parameters` instead. */ + reply_to_message_id?: number; + }): Message.AudioMessage; + /** Use this method to send general files. On success, the sent Message is returned. Bots can currently send files of any type of up to 50 MB in size, this limit may be changed in the future. */ + sendDocument(args: { + /** Unique identifier of the business connection on behalf of which the message will be sent */ + business_connection_id?: string; + /** Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) */ + chat_id: number | string; + /** Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only */ + message_thread_id?: number; + /** Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat */ + direct_messages_topic_id?: number; + /** File to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. */ + document: F | string; + /** Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass "attach://" if the thumbnail was uploaded using multipart/form-data under . */ + thumbnail?: F; + /** Document caption (may also be used when resending documents by file_id), 0-1024 characters after entities parsing */ + caption?: string; + /** Mode for parsing entities in the document caption. See formatting options for more details. */ + parse_mode?: ParseMode; + /** A list of special entities that appear in the caption, which can be specified instead of parse_mode */ + caption_entities?: MessageEntity[]; + /** Disables automatic server-side content type detection for files uploaded using multipart/form-data. Always true, if the document is sent as part of an album. */ + disable_content_type_detection?: boolean; + /** Sends the message silently. Users will receive a notification with no sound. */ + disable_notification?: boolean; + /** Protects the contents of the sent message from forwarding and saving */ + protect_content?: boolean; + /** Pass True to allow up to 1000 messages per second, ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance */ + allow_paid_broadcast?: boolean; + /** An object containing the parameters of the suggested post to send; for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post is automatically declined. */ + suggested_post_parameters?: SuggestedPostParameters; + /** Unique identifier of the message effect to be added to the message; for private chats only */ + message_effect_id?: string; + /** Description of the message to reply to */ + reply_parameters?: ReplyParameters; + /** Additional interface options. An object for an inline keyboard, custom reply keyboard, instructions to remove a reply keyboard or to force a reply from the user. */ + reply_markup?: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply; + /** @deprecated Use `reply_parameters` instead. */ + reply_to_message_id?: number; + }): Message.DocumentMessage; + /** Use this method to send video files, Telegram clients support MPEG4 videos (other formats may be sent as Document). On success, the sent Message is returned. Bots can currently send video files of up to 50 MB in size, this limit may be changed in the future. */ + sendVideo(args: { + /** Unique identifier of the business connection on behalf of which the message will be sent */ + business_connection_id?: string; + /** Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) */ + chat_id: number | string; + /** Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only */ + message_thread_id?: number; + /** Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat */ + direct_messages_topic_id?: number; + /** Video to send. Pass a file_id as String to send a video that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a video from the Internet, or upload a new video using multipart/form-data. */ + video: F | string; + /** Duration of sent video in seconds */ + duration?: number; + /** Video width */ + width?: number; + /** Video height */ + height?: number; + /** Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass "attach://" if the thumbnail was uploaded using multipart/form-data under . */ + thumbnail?: F; + /** Cover for the video in the message. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass “attach://” to upload a new one using multipart/form-data under name. */ + cover?: F | string; + /** Start timestamp for the video in the message */ + start_timestamp?: number; + /** Video caption (may also be used when resending videos by file_id), 0-1024 characters after entities parsing */ + caption?: string; + /** Mode for parsing entities in the video caption. See formatting options for more details. */ + parse_mode?: ParseMode; + /** A list of special entities that appear in the caption, which can be specified instead of parse_mode */ + caption_entities?: MessageEntity[]; + /** Pass True, if the caption must be shown above the message media */ + show_caption_above_media?: boolean; + /** Pass True if the video needs to be covered with a spoiler animation */ + has_spoiler?: boolean; + /** Pass True if the uploaded video is suitable for streaming */ + supports_streaming?: boolean; + /** Sends the message silently. Users will receive a notification with no sound. */ + disable_notification?: boolean; + /** Protects the contents of the sent message from forwarding and saving */ + protect_content?: boolean; + /** Pass True to allow up to 1000 messages per second, ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance */ + allow_paid_broadcast?: boolean; + /** An object containing the parameters of the suggested post to send; for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post is automatically declined. */ + suggested_post_parameters?: SuggestedPostParameters; + /** Unique identifier of the message effect to be added to the message; for private chats only */ + message_effect_id?: string; + /** Description of the message to reply to */ + reply_parameters?: ReplyParameters; + /** Additional interface options. An object for an inline keyboard, custom reply keyboard, instructions to remove a reply keyboard or to force a reply from the user. */ + reply_markup?: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply; + /** @deprecated Use `reply_parameters` instead. */ + reply_to_message_id?: number; + }): Message.VideoMessage; + /** Use this method to send animation files (GIF or H.264/MPEG-4 AVC video without sound). On success, the sent Message is returned. Bots can currently send animation files of up to 50 MB in size, this limit may be changed in the future. */ + sendAnimation(args: { + /** Unique identifier of the business connection on behalf of which the message will be sent */ + business_connection_id?: string; + /** Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) */ + chat_id: number | string; + /** Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only */ + message_thread_id?: number; + /** Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat */ + direct_messages_topic_id?: number; + /** Animation to send. Pass a file_id as String to send an animation that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get an animation from the Internet, or upload a new animation using multipart/form-data. */ + animation: F | string; + /** Duration of sent animation in seconds */ + duration?: number; + /** Animation width */ + width?: number; + /** Animation height */ + height?: number; + /** Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass "attach://" if the thumbnail was uploaded using multipart/form-data under . */ + thumbnail?: F; + /** Animation caption (may also be used when resending animation by file_id), 0-1024 characters after entities parsing */ + caption?: string; + /** Mode for parsing entities in the animation caption. See formatting options for more details. */ + parse_mode?: ParseMode; + /** A list of special entities that appear in the caption, which can be specified instead of parse_mode */ + caption_entities?: MessageEntity[]; + /** Pass True, if the caption must be shown above the message media */ + show_caption_above_media?: boolean; + /** Pass True if the animation needs to be covered with a spoiler animation */ + has_spoiler?: boolean; + /** Sends the message silently. Users will receive a notification with no sound. */ + disable_notification?: boolean; + /** Protects the contents of the sent message from forwarding and saving */ + protect_content?: boolean; + /** Pass True to allow up to 1000 messages per second, ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance */ + allow_paid_broadcast?: boolean; + /** An object containing the parameters of the suggested post to send; for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post is automatically declined. */ + suggested_post_parameters?: SuggestedPostParameters; + /** Unique identifier of the message effect to be added to the message; for private chats only */ + message_effect_id?: string; + /** Description of the message to reply to */ + reply_parameters?: ReplyParameters; + /** Additional interface options. An object for an inline keyboard, custom reply keyboard, instructions to remove a reply keyboard or to force a reply from the user. */ + reply_markup?: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply; + /** @deprecated Use `reply_parameters` instead. */ + reply_to_message_id?: number; + }): Message.AnimationMessage; + /** Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message. For this to work, your audio must be in an .OGG file encoded with OPUS, or in .MP3 format, or in .M4A format (other formats may be sent as Audio or Document). On success, the sent Message is returned. Bots can currently send voice messages of up to 50 MB in size, this limit may be changed in the future. */ + sendVoice(args: { + /** Unique identifier of the business connection on behalf of which the message will be sent */ + business_connection_id?: string; + /** Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) */ + chat_id: number | string; + /** Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only */ + message_thread_id?: number; + /** Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat */ + direct_messages_topic_id?: number; + /** Audio file to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. */ + voice: F | string; + /** Voice message caption, 0-1024 characters after entities parsing */ + caption?: string; + /** Mode for parsing entities in the voice message caption. See formatting options for more details. */ + parse_mode?: ParseMode; + /** A list of special entities that appear in the caption, which can be specified instead of parse_mode */ + caption_entities?: MessageEntity[]; + /** Duration of the voice message in seconds */ + duration?: number; + /** Sends the message silently. Users will receive a notification with no sound. */ + disable_notification?: boolean; + /** Protects the contents of the sent message from forwarding and saving */ + protect_content?: boolean; + /** Pass True to allow up to 1000 messages per second, ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance */ + allow_paid_broadcast?: boolean; + /** An object containing the parameters of the suggested post to send; for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post is automatically declined. */ + suggested_post_parameters?: SuggestedPostParameters; + /** Unique identifier of the message effect to be added to the message; for private chats only */ + message_effect_id?: string; + /** Description of the message to reply to */ + reply_parameters?: ReplyParameters; + /** Additional interface options. An object for an inline keyboard, custom reply keyboard, instructions to remove a reply keyboard or to force a reply from the user. */ + reply_markup?: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply; + /** @deprecated Use `reply_parameters` instead. */ + reply_to_message_id?: number; + }): Message.VoiceMessage; + /** Use this method to send video messages. On success, the sent Message is returned. + As of v.4.0, Telegram clients support rounded square MPEG4 videos of up to 1 minute long. */ + sendVideoNote(args: { + /** Unique identifier of the business connection on behalf of which the message will be sent */ + business_connection_id?: string; + /** Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) */ + chat_id: number | string; + /** Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only */ + message_thread_id?: number; + /** Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat */ + direct_messages_topic_id?: number; + /** Video note to send. Pass a file_id as String to send a video note that exists on the Telegram servers (recommended) or upload a new video using multipart/form-data.. Sending video notes by a URL is currently unsupported */ + video_note: F | string; + /** Duration of sent video in seconds */ + duration?: number; + /** Video width and height, i.e. diameter of the video message */ + length?: number; + /** Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass "attach://" if the thumbnail was uploaded using multipart/form-data under . */ + thumbnail?: F; + /** Sends the message silently. Users will receive a notification with no sound. */ + disable_notification?: boolean; + /** Protects the contents of the sent message from forwarding and saving */ + protect_content?: boolean; + /** Pass True to allow up to 1000 messages per second, ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance */ + allow_paid_broadcast?: boolean; + /** An object containing the parameters of the suggested post to send; for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post is automatically declined. */ + suggested_post_parameters?: SuggestedPostParameters; + /** Unique identifier of the message effect to be added to the message; for private chats only */ + message_effect_id?: string; + /** Description of the message to reply to */ + reply_parameters?: ReplyParameters; + /** Additional interface options. An object for an inline keyboard, custom reply keyboard, instructions to remove a reply keyboard or to force a reply from the user. */ + reply_markup?: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply; + /** @deprecated Use `reply_parameters` instead. */ + reply_to_message_id?: number; + }): Message.VideoNoteMessage; + /** Use this method to send a group of photos, videos, documents or audios as an album. Documents and audio files can be only grouped in an album with messages of the same type. On success, an array of Messages that were sent is returned. */ + sendMediaGroup(args: { + /** Unique identifier of the business connection on behalf of which the message will be sent */ + business_connection_id?: string; + /** Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) */ + chat_id: number | string; + /** Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only */ + message_thread_id?: number; + /** Identifier of the direct messages topic to which the messages will be sent; required if the messages are sent to a direct messages chat */ + direct_messages_topic_id?: number; + /** An array describing messages to be sent, must include 2-10 items */ + media: ReadonlyArray | InputMediaDocument | InputMediaPhoto | InputMediaVideo>; + /** Sends the messages silently. Users will receive a notification with no sound. */ + disable_notification?: boolean; + /** Protects the contents of the sent messages from forwarding and saving */ + protect_content?: boolean; + /** Pass True to allow up to 1000 messages per second, ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance */ + allow_paid_broadcast?: boolean; + /** Unique identifier of the message effect to be added to the message; for private chats only */ + message_effect_id?: string; + /** Description of the message to reply to */ + reply_parameters?: ReplyParameters; + /** @deprecated Use `reply_parameters` instead. */ + reply_to_message_id?: number; + }): Array; + /** Use this method to send point on the map. On success, the sent Message is returned. */ + sendLocation(args: { + /** Unique identifier of the business connection on behalf of which the message will be sent */ + business_connection_id?: string; + /** Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) */ + chat_id: number | string; + /** Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only */ + message_thread_id?: number; + /** Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat */ + direct_messages_topic_id?: number; + /** Latitude of the location */ + latitude: number; + /** Longitude of the location */ + longitude: number; + /** The radius of uncertainty for the location, measured in meters; 0-1500 */ + horizontal_accuracy?: number; + /** Period in seconds during which the location will be updated (see Live Locations, should be between 60 and 86400, or 0x7FFFFFFF for live locations that can be edited indefinitely. */ + live_period?: number; + /** The direction in which user is moving, in degrees; 1-360. For active live locations only. */ + heading?: number; + /** The maximum distance for proximity alerts about approaching another chat member, in meters. For sent live locations only. */ + proximity_alert_radius?: number; + /** Sends the message silently. Users will receive a notification with no sound. */ + disable_notification?: boolean; + /** Protects the contents of the sent message from forwarding and saving */ + protect_content?: boolean; + /** Pass True to allow up to 1000 messages per second, ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance */ + allow_paid_broadcast?: boolean; + /** An object containing the parameters of the suggested post to send; for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post is automatically declined. */ + suggested_post_parameters?: SuggestedPostParameters; + /** Unique identifier of the message effect to be added to the message; for private chats only */ + message_effect_id?: string; + /** Description of the message to reply to */ + reply_parameters?: ReplyParameters; + /** Additional interface options. An object for an inline keyboard, custom reply keyboard, instructions to remove a reply keyboard or to force a reply from the user. */ + reply_markup?: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply; + /** @deprecated Use `reply_parameters` instead. */ + reply_to_message_id?: number; + }): Message.LocationMessage; + /** Use this method to edit live location messages. A location can be edited until its live_period expires or editing is explicitly disabled by a call to stopMessageLiveLocation. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. */ + editMessageLiveLocation(args: { + /** Unique identifier of the business connection on behalf of which the message to be edited was sent */ + business_connection_id?: string; + /** Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) */ + chat_id?: number | string; + /** Required if inline_message_id is not specified. Identifier of the message to edit */ + message_id?: number; + /** Required if chat_id and message_id are not specified. Identifier of the inline message */ + inline_message_id?: string; + /** Latitude of new location */ + latitude: number; + /** Longitude of new location */ + longitude: number; + /** New period in seconds during which the location can be updated, starting from the message send date. If 0x7FFFFFFF is specified, then the location can be updated forever. Otherwise, the new value must not exceed the current live_period by more than a day, and the live location expiration date must remain within the next 90 days. If not specified, then live_period remains unchanged */ + live_period?: number; + /** The radius of uncertainty for the location, measured in meters; 0-1500 */ + horizontal_accuracy?: number; + /** The direction in which user is moving, in degrees; 1-360. For active live locations only. */ + heading?: number; + /** The maximum distance for proximity alerts about approaching another chat member, in meters. For sent live locations only. */ + proximity_alert_radius?: number; + /** An object for a new inline keyboard. */ + reply_markup?: InlineKeyboardMarkup; + }): (Update.Edited & Message.LocationMessage) | true; + /** Use this method to stop updating a live location message before live_period expires. On success, if the message is not an inline message, the edited Message is returned, otherwise True is returned. */ + stopMessageLiveLocation(args: { + /** Unique identifier of the business connection on behalf of which the message to be edited was sent */ + business_connection_id?: string; + /** Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) */ + chat_id?: number | string; + /** Required if inline_message_id is not specified. Identifier of the message with live location to stop */ + message_id?: number; + /** Required if chat_id and message_id are not specified. Identifier of the inline message */ + inline_message_id?: string; + /** An object for a new inline keyboard. */ + reply_markup?: InlineKeyboardMarkup; + }): (Update.Edited & Message.LocationMessage) | true; + /** Use this method to send paid media. On success, the sent Message is returned. */ + sendPaidMedia(args: { + /** Unique identifier of the business connection on behalf of which the message to be edited was sent */ + business_connection_id?: string; + /** Unique identifier for the target chat or username of the target channel (in the format `@channelusername`). If the chat is a channel, all Telegram Star proceeds from this media will be credited to the chat's balance. Otherwise, they will be credited to the bot's balance. */ + chat_id: number | string; + /** Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only */ + message_thread_id?: number; + /** Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat */ + direct_messages_topic_id?: number; + /** The number of Telegram Stars that must be paid to buy access to the media; 1-2500 */ + star_count: number; + /** An array describing the media to be sent; up to 10 items */ + media: InputPaidMedia[]; + /** Bot-defined paid media payload, 0-128 bytes. This will not be displayed to the user, use it for your internal processes. */ + payload?: string; + /** Media caption, 0-1024 characters after entities parsing */ + caption?: string; + /** Mode for parsing entities in the media caption. See formatting options for more details. */ + parse_mode?: ParseMode; + /** A list of special entities that appear in the caption, which can be specified instead of parse_mode */ + caption_entities?: MessageEntity[]; + /** Pass True, if the caption must be shown above the message media */ + show_caption_above_media?: boolean; + /** Sends the message silently. Users will receive a notification with no sound. */ + disable_notification?: boolean; + /** Protects the contents of the sent message from forwarding and saving */ + protect_content?: boolean; + /** Pass True to allow up to 1000 messages per second, ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance */ + allow_paid_broadcast?: boolean; + /** An object containing the parameters of the suggested post to send; for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post is automatically declined. */ + suggested_post_parameters?: SuggestedPostParameters; + /** Description of the message to reply to */ + reply_parameters?: ReplyParameters; + /** Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove a reply keyboard or to force a reply from the user */ + reply_markup?: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply; + }): Message.PaidMediaMessage; + /** Use this method to send information about a venue. On success, the sent Message is returned. */ + sendVenue(args: { + /** Unique identifier of the business connection on behalf of which the message will be sent */ + business_connection_id?: string; + /** Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) */ + chat_id: number | string; + /** Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only */ + message_thread_id?: number; + /** Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat */ + direct_messages_topic_id?: number; + /** Latitude of the venue */ + latitude: number; + /** Longitude of the venue */ + longitude: number; + /** Name of the venue */ + title: string; + /** Address of the venue */ + address: string; + /** Foursquare identifier of the venue */ + foursquare_id?: string; + /** Foursquare type of the venue, if known. (For example, “arts_entertainment/default”, “arts_entertainment/aquarium” or “food/icecream”.) */ + foursquare_type?: string; + /** Google Places identifier of the venue */ + google_place_id?: string; + /** Google Places type of the venue. (See supported types.) */ + google_place_type?: string; + /** Sends the message silently. Users will receive a notification with no sound. */ + disable_notification?: boolean; + /** Protects the contents of the sent message from forwarding and saving */ + protect_content?: boolean; + /** Pass True to allow up to 1000 messages per second, ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance */ + allow_paid_broadcast?: boolean; + /** An object containing the parameters of the suggested post to send; for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post is automatically declined. */ + suggested_post_parameters?: SuggestedPostParameters; + /** Unique identifier of the message effect to be added to the message; for private chats only */ + message_effect_id?: string; + /** Description of the message to reply to */ + reply_parameters?: ReplyParameters; + /** Additional interface options. An object for an inline keyboard, custom reply keyboard, instructions to remove a reply keyboard or to force a reply from the user. */ + reply_markup?: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply; + /** @deprecated Use `reply_parameters` instead. */ + reply_to_message_id?: number; + }): Message.VenueMessage; + /** Use this method to send phone contacts. On success, the sent Message is returned. */ + sendContact(args: { + /** Unique identifier of the business connection on behalf of which the message will be sent */ + business_connection_id?: string; + /** Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) */ + chat_id: number | string; + /** Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only */ + message_thread_id?: number; + /** Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat */ + direct_messages_topic_id?: number; + /** Contact's phone number */ + phone_number: string; + /** Contact's first name */ + first_name: string; + /** Contact's last name */ + last_name?: string; + /** Additional data about the contact in the form of a vCard, 0-2048 bytes */ + vcard?: string; + /** Sends the message silently. Users will receive a notification with no sound. */ + disable_notification?: boolean; + /** Protects the contents of the sent message from forwarding and saving */ + protect_content?: boolean; + /** Pass True to allow up to 1000 messages per second, ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance */ + allow_paid_broadcast?: boolean; + /** An object containing the parameters of the suggested post to send; for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post is automatically declined. */ + suggested_post_parameters?: SuggestedPostParameters; + /** Unique identifier of the message effect to be added to the message; for private chats only */ + message_effect_id?: string; + /** Description of the message to reply to */ + reply_parameters?: ReplyParameters; + /** Additional interface options. An object for an inline keyboard, custom reply keyboard, instructions to remove a reply keyboard or to force a reply from the user. */ + reply_markup?: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply; + /** @deprecated Use `reply_parameters` instead. */ + reply_to_message_id?: number; + }): Message.ContactMessage; + /** Use this method to send a native poll. On success, the sent Message is returned. */ + sendPoll(args: { + /** Unique identifier of the business connection on behalf of which the message will be sent */ + business_connection_id?: string; + /** Unique identifier for the target chat or username of the target channel (in the format `@channelusername`). Polls can't be sent to channel direct messages chats. */ + chat_id: number | string; + /** Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only */ + message_thread_id?: number; + /** Poll question, 1-300 characters */ + question: string; + /** Mode for parsing entities in the question. See formatting options for more details. Currently, only custom emoji entities are allowed */ + question_parse_mode?: ParseMode; + /** A list of special entities that appear in the poll question. It can be specified instead of question_parse_mode */ + question_entities?: MessageEntity[]; + /** A list of 2-12 answer options */ + options: InputPollOption[]; + /** True, if the poll needs to be anonymous, defaults to True */ + is_anonymous?: boolean; + /** Poll type, “quiz” or “regular”, defaults to “regular” */ + type?: "quiz" | "regular"; + /** True, if the poll allows multiple answers, ignored for polls in quiz mode, defaults to False */ + allows_multiple_answers?: boolean; + /** 0-based identifier of the correct answer option, required for polls in quiz mode */ + correct_option_id?: number; + /** Text that is shown when a user chooses an incorrect answer or taps on the lamp icon in a quiz-style poll, 0-200 characters with at most 2 line feeds after entities parsing */ + explanation?: string; + /** Mode for parsing entities in the explanation. See formatting options for more details. */ + explanation_parse_mode?: ParseMode; + /** A list of special entities that appear in the poll explanation. It can be specified instead of explanation_parse_mode */ + explanation_entities?: MessageEntity[]; + /** Amount of time in seconds the poll will be active after creation, 5-600. Can't be used together with close_date. */ + open_period?: number; + /** Point in time (Unix timestamp) when the poll will be automatically closed. Must be at least 5 and no more than 600 seconds in the future. Can't be used together with open_period. */ + close_date?: number; + /** Pass True if the poll needs to be immediately closed. This can be useful for poll preview. */ + is_closed?: boolean; + /** Sends the message silently. Users will receive a notification with no sound. */ + disable_notification?: boolean; + /** Protects the contents of the sent message from forwarding and saving */ + protect_content?: boolean; + /** Pass True to allow up to 1000 messages per second, ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance */ + allow_paid_broadcast?: boolean; + /** Unique identifier of the message effect to be added to the message; for private chats only */ + message_effect_id?: string; + /** Description of the message to reply to */ + reply_parameters?: ReplyParameters; + /** Additional interface options. An object for an inline keyboard, custom reply keyboard, instructions to remove a reply keyboard or to force a reply from the user. */ + reply_markup?: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply; + /** @deprecated Use `reply_parameters` instead. */ + reply_to_message_id?: number; + }): Message.PollMessage; + /** Use this method to send a checklist on behalf of a connected business account. On success, the sent Message is returned. */ + sendChecklist(args: { + /** Unique identifier of the business connection on behalf of which the message will be sent */ + business_connection_id: string; + /** Unique identifier for the target chat */ + chat_id: number; + /** An object for the checklist to send */ + checklist: InputChecklist; + /** Sends the message silently. Users will receive a notification with no sound. */ + disable_notification?: boolean; + /** Protects the contents of the sent message from forwarding and saving */ + protect_content?: boolean; + /** Unique identifier of the message effect to be added to the message */ + message_effect_id?: string; + /** An object for description of the message to reply to */ + reply_parameters?: ReplyParameters; + /** An object for an inline keyboard */ + reply_markup?: InlineKeyboardMarkup; + }): Message.ChecklistMessage; + /** Use this method to edit a checklist on behalf of a connected business account. On success, the edited Message is returned. */ + editMessageChecklist(args: { + /** Unique identifier of the business connection on behalf of which the message will be sent */ + business_connection_id: string; + /** Unique identifier for the target chat */ + chat_id: number; + /** Unique identifier for the target message */ + message_id: number; + /** An object for the new checklist */ + checklist: InputChecklist; + /** An object for the new inline keyboard for the message */ + reply_markup?: InlineKeyboardMarkup; + }): Message.ChecklistMessage; + /** Use this method to send an animated emoji that will display a random value. On success, the sent Message is returned. */ + sendDice(args: { + /** Unique identifier of the business connection on behalf of which the message will be sent */ + business_connection_id?: string; + /** Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) */ + chat_id: number | string; + /** Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only */ + message_thread_id?: number; + /** Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat */ + direct_messages_topic_id?: number; + /** Emoji on which the dice throw animation is based. Currently, must be one of "🎲", "🎯", "🏀", "⚽", "🎳", or "🎰". Dice can have values 1-6 for "🎲", "🎯" and "🎳", values 1-5 for "🏀" and "⚽", and values 1-64 for "🎰". Defaults to "🎲" */ + emoji?: (string & Record) | "🎲" | "🎯" | "🏀" | "⚽" | "🎳" | "🎰"; + /** Sends the message silently. Users will receive a notification with no sound. */ + disable_notification?: boolean; + /** Protects the contents of the sent message from forwarding */ + protect_content?: boolean; + /** Pass True to allow up to 1000 messages per second, ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance */ + allow_paid_broadcast?: boolean; + /** An object containing the parameters of the suggested post to send; for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post is automatically declined. */ + suggested_post_parameters?: SuggestedPostParameters; + /** Unique identifier of the message effect to be added to the message; for private chats only */ + message_effect_id?: string; + /** Description of the message to reply to */ + reply_parameters?: ReplyParameters; + /** Additional interface options. An object for an inline keyboard, custom reply keyboard, instructions to remove a reply keyboard or to force a reply from the user. */ + reply_markup?: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply; + /** @deprecated Use `reply_parameters` instead. */ + reply_to_message_id?: number; + }): Message.DiceMessage; + /** Use this method when you need to tell the user that something is happening on the bot's side. The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status). Returns True on success. + + Example: The ImageBot needs some time to process a request and upload the image. Instead of sending a text message along the lines of "Retrieving image, please wait...", the bot may use sendChatAction with action = upload_photo. The user will see a "sending photo" status for the bot. + + We only recommend using this method when a response from the bot will take a noticeable amount of time to arrive. */ + sendChatAction(args: { + /** Unique identifier of the business connection on behalf of which the action will be sent */ + business_connection_id?: string; + /** Unique identifier for the target chat or username of the target supergroup (in the format `@supergroupusername`). Channel chats and channel direct messages chats aren't supported. */ + chat_id: number | string; + /** Unique identifier for the target message thread or topic of a forum; for supergroups and private chats of bots with forum topic mode enabled only */ + message_thread_id?: number; + /** Type of action to broadcast. Choose one, depending on what the user is about to receive: typing for text messages, upload_photo for photos, record_video or upload_video for videos, record_voice or upload_voice for voice notes, upload_document for general files, choose_sticker for stickers, find_location for location data, record_video_note or upload_video_note for video notes. */ + action: "typing" | "upload_photo" | "record_video" | "upload_video" | "record_voice" | "upload_voice" | "upload_document" | "choose_sticker" | "find_location" | "record_video_note" | "upload_video_note"; + }): true; + /** Use this method to change the chosen reactions on a message. Service messages of some types can't be reacted to. Automatically forwarded messages from a channel to its discussion group have the same available reactions as messages in the channel. Bots can't use paid reactions. Returns True on success. */ + setMessageReaction(args: { + /** Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) */ + chat_id: number | string; + /** Identifier of the target message */ + message_id: number; + /** A list of reaction types to set on the message. Currently, as non-premium users, bots can set up to one reaction per message. A custom emoji reaction can be used if it is either already present on the message or explicitly allowed by chat administrators. Paid reactions can't be used by bots. */ + reaction?: ReactionType[]; + /** Pass True to set the reaction with a big animation */ + is_big?: boolean; + }): true; + /** Use this method to get a list of profile pictures for a user. Returns a UserProfilePhotos object. */ + getUserProfilePhotos(args: { + /** Unique identifier of the target user */ + user_id: number; + /** Sequential number of the first photo to be returned. By default, all photos are returned. */ + offset?: number; + /** Limits the number of photos to be retrieved. Values between 1-100 are accepted. Defaults to 100. */ + limit?: number; + }): UserProfilePhotos; + /** Use this method to get a list of profile audios for a user. Returns a UserProfileAudios object. */ + getUserProfileAudios(args: { + /** Unique identifier of the target user */ + user_id: number; + /** Sequential number of the first audio to be returned. By default, all audios are returned. */ + offset?: number; + /** Limits the number of audios to be retrieved. Values between 1-100 are accepted. Defaults to 100. */ + limit?: number; + }): UserProfileAudios; + /** Changes the emoji status for a given user that previously allowed the bot to manage their emoji status via the Mini App method requestEmojiStatusAccess. Returns True on success. */ + setUserEmojiStatus(args: { + /** Unique identifier of the target user */ + user_id: number; + /** Custom emoji identifier of the emoji status to set. Pass an empty string to remove the status. */ + emoji_status_custom_emoji_id?: string; + /** Expiration date of the emoji status, if any */ + emoji_status_expiration_date?: number; + }): true; + /** Use this method to get basic information about a file and prepare it for downloading. For the moment, bots can download files of up to 20MB in size. On success, a File object is returned. The file can then be downloaded via the link https://api.telegram.org/file/bot/, where is taken from the response. It is guaranteed that the link will be valid for at least 1 hour. When the link expires, a new one can be requested by calling getFile again. + + Note: This function may not preserve the original file name and MIME type. You should save the file's MIME type and name (if available) when the File object is received. */ + getFile(args: { + /** File identifier to get information about */ + file_id: string; + }): File; + /** Use this method to ban a user in a group, a supergroup or a channel. In the case of supergroups and channels, the user will not be able to return to the chat on their own using invite links, etc., unless unbanned first. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success. + * @deprecated Use `banChatMember` instead. */ + kickChatMember: ApiMethods["banChatMember"]; + /** Use this method to ban a user in a group, a supergroup or a channel. In the case of supergroups and channels, the user will not be able to return to the chat on their own using invite links, etc., unless unbanned first. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success. */ + banChatMember(args: { + /** Unique identifier for the target group or username of the target supergroup or channel (in the format `@channelusername`) */ + chat_id: number | string; + /** Unique identifier of the target user */ + user_id: number; + /** Date when the user will be unbanned; Unix time. If user is banned for more than 366 days or less than 30 seconds from the current time they are considered to be banned forever. Applied for supergroups and channels only. */ + until_date?: number; + /** Pass True to delete all messages from the chat for the user that is being removed. If False, the user will be able to see messages in the group that were sent before the user was removed. Always True for supergroups and channels. */ + revoke_messages?: boolean; + }): true; + /** Use this method to unban a previously banned user in a supergroup or channel. The user will not return to the group or channel automatically, but will be able to join via link, etc. The bot must be an administrator for this to work. By default, this method guarantees that after the call the user is not a member of the chat, but will be able to join it. So if the user is a member of the chat they will also be removed from the chat. If you don't want this, use the parameter only_if_banned. Returns True on success. */ + unbanChatMember(args: { + /** Unique identifier for the target group or username of the target supergroup or channel (in the format `@channelusername`) */ + chat_id: number | string; + /** Unique identifier of the target user */ + user_id: number; + /** Do nothing if the user is not banned */ + only_if_banned?: boolean; + }): true; + /** Use this method to restrict a user in a supergroup. The bot must be an administrator in the supergroup for this to work and must have the appropriate administrator rights. Pass True for all permissions to lift restrictions from a user. Returns True on success. */ + restrictChatMember(args: { + /** Unique identifier for the target chat or username of the target supergroup (in the format `@supergroupusername`) */ + chat_id: number | string; + /** Unique identifier of the target user */ + user_id: number; + /** An object for new user permissions */ + permissions: ChatPermissions; + /** Pass True if chat permissions are set independently. Otherwise, the can_send_other_messages and can_add_web_page_previews permissions will imply the can_send_messages, can_send_audios, can_send_documents, can_send_photos, can_send_videos, can_send_video_notes, and can_send_voice_notes permissions; the can_send_polls permission will imply the can_send_messages permission. */ + use_independent_chat_permissions?: boolean; + /** Date when restrictions will be lifted for the user; Unix time. If user is restricted for more than 366 days or less than 30 seconds from the current time, they are considered to be restricted forever */ + until_date?: number; + }): true; + /** Use this method to promote or demote a user in a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Pass False for all boolean parameters to demote a user. Returns True on success. */ + promoteChatMember(args: { + /** Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) */ + chat_id: number | string; + /** Unique identifier of the target user */ + user_id: number; + /** Pass True if the administrator's presence in the chat is hidden */ + is_anonymous?: boolean; + /** Pass True if the administrator can access the chat event log, get boost list, see hidden supergroup and channel members, report spam messages, ignore slow mode, and send messages to the chat without paying Telegram Stars. Implied by any other administrator privilege. */ + can_manage_chat?: boolean; + /** Pass True if the administrator can delete messages of other users */ + can_delete_messages?: boolean; + /** Pass True if the administrator can manage video chats */ + can_manage_video_chats?: boolean; + /** Pass True if the administrator can restrict, ban or unban chat members, or access supergroup statistics. For backward compatibility, defaults to True for promotions of channel administrators */ + can_restrict_members?: boolean; + /** Pass True if the administrator can add new administrators with a subset of their own privileges or demote administrators that they have promoted, directly or indirectly (promoted by administrators that were appointed by him) */ + can_promote_members?: boolean; + /** Pass True if the administrator can change chat title, photo and other settings */ + can_change_info?: boolean; + /** Pass True if the administrator can invite new users to the chat */ + can_invite_users?: boolean; + /** True if the administrator can post stories to the chat */ + can_post_stories?: boolean; + /** Pass True if the administrator can edit stories posted by other users, post stories to the chat page, pin chat stories, and access the chat's story archive */ + can_edit_stories?: boolean; + /** True if the administrator can delete stories posted by other users */ + can_delete_stories?: boolean; + /** Pass True if the administrator can post messages in the channel, approve suggested posts, or access channel statistics; for channels only */ + can_post_messages?: boolean; + /** True if the administrator can edit messages of other users and can pin messages; for channels only */ + can_edit_messages?: boolean; + /** True if the administrator can pin messages; for supergroups only */ + can_pin_messages?: boolean; + /** True if the user is allowed to create, rename, close, and reopen forum topics; for supergroups only */ + can_manage_topics?: boolean; + /** Pass True if the administrator can manage direct messages within the channel and decline suggested posts; for channels only */ + can_manage_direct_messages?: boolean; + }): true; + /** Use this method to set a custom title for an administrator in a supergroup promoted by the bot. Returns True on success. */ + setChatAdministratorCustomTitle(args: { + /** Unique identifier for the target chat or username of the target supergroup (in the format `@supergroupusername`) */ + chat_id: number | string; + /** Unique identifier of the target user */ + user_id: number; + /** New custom title for the administrator; 0-16 characters, emoji are not allowed */ + custom_title: string; + }): true; + /** Use this method to ban a channel chat in a supergroup or a channel. Until the chat is unbanned, the owner of the banned chat won't be able to send messages on behalf of any of their channels. The bot must be an administrator in the supergroup or channel for this to work and must have the appropriate administrator rights. Returns True on success. */ + banChatSenderChat(args: { + /** Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) */ + chat_id: number | string; + /** Unique identifier of the target sender chat */ + sender_chat_id: number; + }): true; + /** Use this method to unban a previously banned channel chat in a supergroup or channel. The bot must be an administrator for this to work and must have the appropriate administrator rights. Returns True on success. */ + unbanChatSenderChat(args: { + /** Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) */ + chat_id: number | string; + /** Unique identifier of the target sender chat */ + sender_chat_id: number; + }): true; + /** Use this method to set default chat permissions for all members. The bot must be an administrator in the group or a supergroup for this to work and must have the can_restrict_members administrator rights. Returns True on success. */ + setChatPermissions(args: { + /** Unique identifier for the target chat or username of the target supergroup (in the format `@supergroupusername`) */ + chat_id: number | string; + /** An object for new default chat permissions */ + permissions: ChatPermissions; + /** Pass True if chat permissions are set independently. Otherwise, the can_send_other_messages and can_add_web_page_previews permissions will imply the can_send_messages, can_send_audios, can_send_documents, can_send_photos, can_send_videos, can_send_video_notes, and can_send_voice_notes permissions; the can_send_polls permission will imply the can_send_messages permission. */ + use_independent_chat_permissions?: boolean; + }): true; + /** Use this method to generate a new primary invite link for a chat; any previously generated primary link is revoked. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the new invite link as String on success. + + Note: Each administrator in a chat generates their own invite links. Bots can't use invite links generated by other administrators. If you want your bot to work with invite links, it will need to generate its own link using exportChatInviteLink or by calling the getChat method. If your bot needs to generate a new primary invite link replacing its previous one, use exportChatInviteLink again. */ + exportChatInviteLink(args: { + /** Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) */ + chat_id: number | string; + }): string; + /** Use this method to create an additional invite link for a chat. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. The link can be revoked using the method revokeChatInviteLink. Returns the new invite link as ChatInviteLink object. */ + createChatInviteLink(args: { + /** Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) */ + chat_id: number | string; + /** Invite link name; 0-32 characters */ + name?: string; + /** Point in time (Unix timestamp) when the link will expire */ + expire_date?: number; + /** The maximum number of users that can be members of the chat simultaneously after joining the chat via this invite link; 1-99999 */ + member_limit?: number; + /** True, if users joining the chat via the link need to be approved by chat administrators. If True, member_limit can't be specified */ + creates_join_request?: boolean; + }): ChatInviteLink; + /** Use this method to edit a non-primary invite link created by the bot. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the edited invite link as a ChatInviteLink object. */ + editChatInviteLink(args: { + /** Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) */ + chat_id: number | string; + /** The invite link to edit */ + invite_link: string; + /** Invite link name; 0-32 characters */ + name?: string; + /** Point in time (Unix timestamp) when the link will expire */ + expire_date?: number; + /** The maximum number of users that can be members of the chat simultaneously after joining the chat via this invite link; 1-99999 */ + member_limit?: number; + /** True, if users joining the chat via the link need to be approved by chat administrators. If True, member_limit can't be specified */ + creates_join_request?: boolean; + }): ChatInviteLink; + /** Use this method to create a subscription invite link for a channel chat. The bot must have the can_invite_users administrator rights. The link can be edited using the method editChatSubscriptionInviteLink or revoked using the method revokeChatInviteLink. Returns the new invite link as a ChatInviteLink object. */ + createChatSubscriptionInviteLink(args: { + /** Unique identifier for the target channel chat or username of the target channel (in the format `@channelusername`) */ + chat_id: number | string; + /** Invite link name; 0-32 characters */ + name?: string; + /** The number of seconds the subscription will be active for before the next payment. Currently, it must always be 2592000 (30 days). */ + subscription_period: number; + /** The amount of Telegram Stars a user must pay initially and after each subsequent subscription period to be a member of the chat; 1-2500 */ + subscription_price: number; + }): ChatInviteLink; + /** Use this method to edit a subscription invite link created by the bot. The bot must have the can_invite_users administrator rights. Returns the edited invite link as a ChatInviteLink object. */ + editChatSubscriptionInviteLink(args: { + /** Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) */ + chat_id: number | string; + /** The invite link to edit */ + invite_link: string; + /** Invite link name; 0-32 characters */ + name?: string; + }): ChatInviteLink; + /** Use this method to revoke an invite link created by the bot. If the primary link is revoked, a new link is automatically generated. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the revoked invite link as ChatInviteLink object. */ + revokeChatInviteLink(args: { + /** Unique identifier of the target chat or username of the target channel (in the format `@channelusername`) */ + chat_id: number | string; + /** The invite link to revoke */ + invite_link: string; + }): ChatInviteLink; + /** Use this method to approve a chat join request. The bot must be an administrator in the chat for this to work and must have the can_invite_users administrator right. Returns True on success. */ + approveChatJoinRequest(args: { + /** Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) */ + chat_id: number | string; + /** Unique identifier of the target user */ + user_id: number; + }): true; + /** Use this method to decline a chat join request. The bot must be an administrator in the chat for this to work and must have the can_invite_users administrator right. Returns True on success. */ + declineChatJoinRequest(args: { + /** Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) */ + chat_id: number | string; + /** Unique identifier of the target user */ + user_id: number; + }): true; + /** Use this method to approve a suggested post in a direct messages chat. The bot must have the 'can_post_messages' administrator right in the corresponding channel chat. Returns True on success. */ + approveSuggestedPost(args: { + /** Unique identifier for the target direct messages chat */ + chat_id: number; + /** Identifier of a suggested post message to approve */ + message_id: number; + /** Point in time (Unix timestamp) when the post is expected to be published; omit if the date has already been specified when the suggested post was created. If specified, then the date must be not more than 2678400 seconds (30 days) in the future */ + send_date?: number; + }): true; + /** Use this method to decline a suggested post in a direct messages chat. The bot must have the 'can_manage_direct_messages' administrator right in the corresponding channel chat. Returns True on success. */ + declineSuggestedPost(args: { + /** Unique identifier for the target direct messages chat */ + chat_id: number; + /** Identifier of a suggested post message to decline */ + message_id: number; + /** Comment for the creator of the suggested post; 0-128 characters */ + comment?: string; + }): true; + /** Use this method to set a new profile photo for the chat. Photos can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success. */ + setChatPhoto(args: { + /** Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) */ + chat_id: number | string; + /** New chat photo, uploaded using multipart/form-data */ + photo: F; + }): true; + /** Use this method to delete a chat photo. Photos can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success. */ + deleteChatPhoto(args: { + /** Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) */ + chat_id: number | string; + }): true; + /** Use this method to change the title of a chat. Titles can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success. */ + setChatTitle(args: { + /** Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) */ + chat_id: number | string; + /** New chat title, 1-128 characters */ + title: string; + }): true; + /** Use this method to change the description of a group, a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success. */ + setChatDescription(args: { + /** Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) */ + chat_id: number | string; + /** New chat description, 0-255 characters */ + description?: string; + }): true; + /** Use this method to add a message to the list of pinned messages in a chat. In private chats and channel direct messages chats, all non-service messages can be pinned. Conversely, the bot must be an administrator with the 'can_pin_messages' right or the 'can_edit_messages' right to pin messages in groups and channels respectively. Returns True on success. */ + pinChatMessage(args: { + /** Unique identifier of the business connection on behalf of which the message will be pinned */ + business_connection_id?: string; + /** Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) */ + chat_id: number | string; + /** Identifier of a message to pin */ + message_id: number; + /** Pass True if it is not necessary to send a notification to all chat members about the new pinned message. Notifications are always disabled in channels and private chats. */ + disable_notification?: boolean; + }): true; + /** Use this method to remove a message from the list of pinned messages in a chat. In private chats and channel direct messages chats, all messages can be unpinned. Conversely, the bot must be an administrator with the 'can_pin_messages' right or the 'can_edit_messages' right to unpin messages in groups and channels respectively. Returns True on success. */ + unpinChatMessage(args: { + /** Unique identifier of the business connection on behalf of which the message will be unpinned */ + business_connection_id?: string; + /** Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) */ + chat_id: number | string; + /** Identifier of the message to unpin. Required if business_connection_id is specified. If not specified, the most recent pinned message (by sending date) will be unpinned. */ + message_id?: number; + }): true; + /** Use this method to clear the list of pinned messages in a chat. In private chats and channel direct messages chats, no additional rights are required to unpin all pinned messages. Conversely, the bot must be an administrator with the 'can_pin_messages' right or the 'can_edit_messages' right to unpin all pinned messages in groups and channels respectively. Returns True on success. */ + unpinAllChatMessages(args: { + /** Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) */ + chat_id: number | string; + }): true; + /** Use this method for your bot to leave a group, supergroup or channel. Returns True on success. */ + leaveChat(args: { + /** Unique identifier for the target chat or username of the target supergroup or channel (in the format `@channelusername`). Channel direct messages chats aren't supported; leave the corresponding channel instead. */ + chat_id: number | string; + }): true; + /** Use this method to get up-to-date information about the chat. Returns a ChatFullInfo object on success. */ + getChat(args: { + /** Unique identifier for the target chat or username of the target supergroup or channel (in the format `@channelusername`) */ + chat_id: number | string; + }): ChatFullInfo; + /** Use this method to get a list of administrators in a chat, which aren't bots. Returns an Array of ChatMember objects. */ + getChatAdministrators(args: { + /** Unique identifier for the target chat or username of the target supergroup or channel (in the format `@channelusername`) */ + chat_id: number | string; + }): Array; + /** Use this method to get the number of members in a chat. Returns Int on success. + * @deprecated Use `getChatMemberCount` instead. */ + getChatMembersCount: ApiMethods["getChatMemberCount"]; + /** Use this method to get the number of members in a chat. Returns Int on success. */ + getChatMemberCount(args: { + /** Unique identifier for the target chat or username of the target supergroup or channel (in the format `@channelusername`) */ + chat_id: number | string; + }): number; + /** Use this method to get information about a member of a chat. The method is only guaranteed to work for other users if the bot is an administrator in the chat. Returns a ChatMember object on success. */ + getChatMember(args: { + /** Unique identifier for the target chat or username of the target supergroup or channel (in the format `@channelusername`) */ + chat_id: number | string; + /** Unique identifier of the target user */ + user_id: number; + }): ChatMember; + /** Use this method to set a new group sticker set for a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Use the field can_set_sticker_set ly returned in getChat requests to check if the bot can use this method. Returns True on success. */ + setChatStickerSet(args: { + /** Unique identifier for the target chat or username of the target supergroup (in the format `@supergroupusername`) */ + chat_id: number | string; + /** Name of the sticker set to be set as the group sticker set */ + sticker_set_name: string; + }): true; + /** Use this method to delete a group sticker set from a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Use the field can_set_sticker_set ly returned in getChat requests to check if the bot can use this method. Returns True on success. */ + deleteChatStickerSet(args: { + /** Unique identifier for the target chat or username of the target supergroup (in the format `@supergroupusername`) */ + chat_id: number | string; + }): true; + /** Use this method to get custom emoji stickers, which can be used as a forum topic icon by any user. Requires no parameters. Returns an Array of Sticker objects. */ + getForumTopicIconStickers(): Sticker[]; + /** Use this method to create a topic in a forum supergroup chat or a private chat with a user. In the case of a supergroup chat the bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator right. Returns information about the created topic as a ForumTopic object. */ + createForumTopic(args: { + /** Unique identifier for the target chat or username of the target supergroup (in the format `@supergroupusername`) */ + chat_id: number | string; + /** Topic name, 1-128 characters */ + name: string; + /** Color of the topic icon in RGB format. Currently, must be one of 7322096 (0x6FB9F0), 16766590 (0xFFD67E), 13338331 (0xCB86DB), 9367192 (0x8EEE98), 16749490 (0xFF93B2), or 16478047 (0xFB6F5F) */ + icon_color?: 0x6FB9F0 | 0xFFD67E | 0xCB86DB | 0x8EEE98 | 0xFF93B2 | 0xFB6F5F; + /** Unique identifier of the custom emoji shown as the topic icon. Use getForumTopicIconStickers to get all allowed custom emoji identifiers. */ + icon_custom_emoji_id?: string; + }): ForumTopic; + /** Use this method to edit name and icon of a topic in a forum supergroup chat or a private chat with a user. In the case of a supergroup chat the bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights, unless it is the creator of the topic. Returns True on success. */ + editForumTopic(args: { + /** Unique identifier for the target chat or username of the target supergroup (in the format `@supergroupusername`) */ + chat_id: number | string; + /** Unique identifier for the target message thread of the forum topic */ + message_thread_id: number; + /** New topic name, 0-128 characters. If not specified or empty, the current name of the topic will be kept */ + name?: string; + /** New unique identifier of the custom emoji shown as the topic icon. Use getForumTopicIconStickers to get all allowed custom emoji identifiers. Pass an empty string to remove the icon. If not specified, the current icon will be kept */ + icon_custom_emoji_id?: string; + }): true; + /** Use this method to close an open topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights, unless it is the creator of the topic. Returns True on success. */ + closeForumTopic(args: { + /** Unique identifier for the target chat or username of the target supergroup (in the format `@supergroupusername`) */ + chat_id: number | string; + /** Unique identifier for the target message thread of the forum topic */ + message_thread_id: number; + }): true; + /** Use this method to reopen a closed topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights, unless it is the creator of the topic. Returns True on success. */ + reopenForumTopic(args: { + /** Unique identifier for the target chat or username of the target supergroup (in the format `@supergroupusername`) */ + chat_id: number | string; + /** Unique identifier for the target message thread of the forum topic */ + message_thread_id: number; + }): true; + /** Use this method to delete a forum topic along with all its messages in a forum supergroup chat or a private chat with a user. In the case of a supergroup chat the bot must be an administrator in the chat for this to work and must have the can_delete_messages administrator rights. Returns True on success. */ + deleteForumTopic(args: { + /** Unique identifier for the target chat or username of the target supergroup (in the format `@supergroupusername`) */ + chat_id: number | string; + /** Unique identifier for the target message thread of the forum topic */ + message_thread_id: number; + }): true; + /** Use this method to clear the list of pinned messages in a forum topic in a forum supergroup chat or a private chat with a user. In the case of a supergroup chat the bot must be an administrator in the chat for this to work and must have the can_pin_messages administrator right in the supergroup. Returns True on success. */ + unpinAllForumTopicMessages(args: { + /** Unique identifier for the target chat or username of the target supergroup (in the format `@supergroupusername`) */ + chat_id: number | string; + /** Unique identifier for the target message thread of the forum topic */ + message_thread_id: number; + }): true; + /** Use this method to edit the name of the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. Returns True on success. */ + editGeneralForumTopic(args: { + /** Unique identifier for the target chat or username of the target supergroup (in the format `@supergroupusername`) */ + chat_id: number | string; + /** New topic name, 1-128 characters */ + name: string; + }): true; + /** Use this method to close an open 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. Returns True on success. */ + closeGeneralForumTopic(args: { + /** Unique identifier for the target chat or username of the target supergroup (in the format `@supergroupusername`) */ + chat_id: number | string; + }): true; + /** Use this method to reopen a closed 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. The topic will be automatically unhidden if it was hidden. Returns True on success. */ + reopenGeneralForumTopic(args: { + /** Unique identifier for the target chat or username of the target supergroup (in the format `@supergroupusername`) */ + chat_id: number | string; + }): true; + /** Use this method to hide the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. The topic will be automatically closed if it was open. Returns True on success. */ + hideGeneralForumTopic(args: { + /** Unique identifier for the target chat or username of the target supergroup (in the format `@supergroupusername`) */ + chat_id: number | string; + }): true; + /** Use this method to unhide the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. Returns True on success. */ + unhideGeneralForumTopic(args: { + /** Unique identifier for the target chat or username of the target supergroup (in the format `@supergroupusername`) */ + chat_id: number | string; + }): true; + /** Use this method to clear the list of pinned messages in a General forum topic. The bot must be an administrator in the chat for this to work and must have the can_pin_messages administrator right in the supergroup. Returns True on success. */ + unpinAllGeneralForumTopicMessages(args: { + /** Unique identifier for the target chat or username of the target supergroup (in the format `@supergroupusername`) */ + chat_id: number | string; + }): true; + /** Use this method to send answers to callback queries sent from inline keyboards. The answer will be displayed to the user as a notification at the top of the chat screen or as an alert. On success, True is returned. + + Alternatively, the user can be redirected to the specified Game URL. For this option to work, you must first create a game for your bot via `@BotFather` and accept the terms. Otherwise, you may use links like t.me/your_bot?start=XXXX that open your bot with a parameter. */ + answerCallbackQuery(args: { + /** Unique identifier for the query to be answered */ + callback_query_id: string; + /** Text of the notification. If not specified, nothing will be shown to the user, 0-200 characters */ + text?: string; + /** If True, an alert will be shown by the client instead of a notification at the top of the chat screen. Defaults to false. */ + show_alert?: boolean; + /** URL that will be opened by the user's client. If you have created a Game and accepted the conditions via `@BotFather`, specify the URL that opens your game - note that this will only work if the query comes from a callback_game button. + + Otherwise, you may use links like t.me/your_bot?start=XXXX that open your bot with a parameter. */ + url?: string; + /** The maximum amount of time in seconds that the result of the callback query may be cached client-side. Telegram apps will support caching starting in version 3.14. Defaults to 0. */ + cache_time?: number; + }): true; + /** Use this method to get the list of boosts added to a chat by a user. Requires administrator rights in the chat. Returns a UserChatBoosts object. */ + getUserChatBoosts(args: { + /** Unique identifier for the chat or username of the channel (in the format `@channelusername`) */ + chat_id: number | string; + /** Unique identifier of the target user */ + user_id: number; + }): UserChatBoosts; + /** Returns the gifts owned and hosted by a user. Returns OwnedGifts on success. */ + getUserGifts(args: { + /** Unique identifier of the user */ + user_id: number; + /** Pass True to exclude gifts that can be purchased an unlimited number of times */ + exclude_unlimited?: boolean; + /** Pass True to exclude gifts that can be purchased a limited number of times and can be upgraded to unique */ + exclude_limited_upgradable?: boolean; + /** Pass True to exclude gifts that can be purchased a limited number of times and can't be upgraded to unique */ + exclude_limited_non_upgradable?: boolean; + /** Pass True to exclude gifts that were assigned from the TON blockchain and can't be resold or transferred in Telegram */ + exclude_from_blockchain?: boolean; + /** Pass True to exclude unique gifts */ + exclude_unique?: boolean; + /** Pass True to sort results by gift price instead of send date. Sorting is applied before pagination. */ + sort_by_price?: boolean; + /** Offset of the first entry to return as received from the previous request; use an empty string to get the first chunk of results */ + offset?: string; + /** The maximum number of gifts to be returned; 1-100. Defaults to 100 */ + limit?: number; + }): OwnedGifts; + /** Returns the gifts owned by a chat. Returns OwnedGifts on success. */ + getChatGifts(args: { + /** Unique identifier for the target chat or username of the target channel (in the format @channelusername) */ + chat_id: number | string; + /** Pass True to exclude gifts that aren't saved to the chat's profile page. Always True, unless the bot has the can_post_messages administrator right in the channel. */ + exclude_unsaved?: boolean; + /** Pass True to exclude gifts that are saved to the chat's profile page. Always False, unless the bot has the can_post_messages administrator right in the channel. */ + exclude_saved?: boolean; + /** Pass True to exclude gifts that can be purchased an unlimited number of times */ + exclude_unlimited?: boolean; + /** Pass True to exclude gifts that can be purchased a limited number of times and can be upgraded to unique */ + exclude_limited_upgradable?: boolean; + /** Pass True to exclude gifts that can be purchased a limited number of times and can't be upgraded to unique */ + exclude_limited_non_upgradable?: boolean; + /** Pass True to exclude gifts that were assigned from the TON blockchain and can't be resold or transferred in Telegram */ + exclude_from_blockchain?: boolean; + /** Pass True to exclude unique gifts */ + exclude_unique?: boolean; + /** Pass True to sort results by gift price instead of send date. Sorting is applied before pagination. */ + sort_by_price?: boolean; + /** Offset of the first entry to return as received from the previous request; use an empty string to get the first chunk of results */ + offset?: string; + /** The maximum number of gifts to be returned; 1-100. Defaults to 100 */ + limit?: number; + }): OwnedGifts; + /** Use this method to get information about the connection of the bot with a business account. Returns a BusinessConnection object on success. */ + getBusinessConnection(args: { + /** Unique identifier of the business connection */ + business_connection_id: string; + }): BusinessConnection; + /** Use this method to change the list of the bot's commands. See https://core.telegram.org/bots/features#commands for more details about bot commands. Returns True on success. */ + setMyCommands(args: { + /** A list of bot commands to be set as the list of the bot's commands. At most 100 commands can be specified. */ + commands: readonly BotCommand[]; + /** An object, describing scope of users for which the commands are relevant. Defaults to BotCommandScopeDefault. */ + scope?: BotCommandScope; + /** A two-letter ISO 639-1 language code. If empty, commands will be applied to all users from the given scope, for whose language there are no dedicated commands */ + language_code?: LanguageCode; + }): true; + /** Use this method to delete the list of the bot's commands for the given scope and user language. After deletion, higher level commands will be shown to affected users. Returns True on success. */ + deleteMyCommands(args: { + /** An object, describing scope of users for which the commands are relevant. Defaults to BotCommandScopeDefault. */ + scope?: BotCommandScope; + /** A two-letter ISO 639-1 language code. If empty, commands will be applied to all users from the given scope, for whose language there are no dedicated commands */ + language_code?: LanguageCode; + }): true; + /** Use this method to get the current list of the bot's commands for the given scope and user language. Returns an Array of BotCommand objects. If commands aren't set, an empty list is returned. */ + getMyCommands(args: { + /** An object, describing scope of users. Defaults to BotCommandScopeDefault. */ + scope?: BotCommandScope; + /** A two-letter ISO 639-1 language code or an empty string */ + language_code?: LanguageCode; + }): BotCommand[]; + /** Use this method to change the bot's name. Returns True on success. */ + setMyName(args: { + /** New bot name; 0-64 characters. Pass an empty string to remove the dedicated name for the given language. */ + name?: string; + /** A two-letter ISO 639-1 language code. If empty, the name will be shown to all users for whose language there is no dedicated name. */ + language_code?: LanguageCode; + }): true; + /** Use this method to get the current bot name for the given user language. Returns BotName on success. */ + getMyName(args: { + /** A two-letter ISO 639-1 language code or an empty string */ + language_code?: LanguageCode; + }): BotName; + /** Use this method to change the bot's description, which is shown in the chat with the bot if the chat is empty. Returns True on success. */ + setMyDescription(args: { + /** New bot description; 0-512 characters. Pass an empty string to remove the dedicated description for the given language. */ + description?: string; + /** A two-letter ISO 639-1 language code. If empty, the description will be applied to all users for whose language there is no dedicated description. */ + language_code?: LanguageCode; + }): true; + /** Use this method to get the current bot description for the given user language. Returns BotDescription on success. */ + getMyDescription(args: { + /** A two-letter ISO 639-1 language code or an empty string */ + language_code?: LanguageCode; + }): BotDescription; + /** Use this method to change the bot's short description, which is shown on the bot's profile page and is sent together with the link when users share the bot. Returns True on success. */ + setMyShortDescription(args: { + /** New short description for the bot; 0-120 characters. Pass an empty string to remove the dedicated short description for the given language. */ + short_description?: string; + /** A two-letter ISO 639-1 language code. If empty, the short description will be applied to all users for whose language there is no dedicated short description. */ + language_code?: LanguageCode; + }): true; + /** Use this method to get the current bot short description for the given user language. Returns BotShortDescription on success. */ + getMyShortDescription(args: { + /** A two-letter ISO 639-1 language code or an empty string */ + language_code?: LanguageCode; + }): BotShortDescription; + /** Changes the profile photo of the bot. Returns True on success. */ + setMyProfilePhoto(args: { + /** The new profile photo to set */ + photo: InputProfilePhoto; + }): true; + /** Removes the profile photo of the bot. Requires no parameters. Returns True on success. */ + removeMyProfilePhoto(): true; + /** Use this method to change the bot's menu button in a private chat, or the default menu button. Returns True on success. */ + setChatMenuButton(args: { + /** Unique identifier for the target private chat. If not specified, default bot's menu button will be changed */ + chat_id?: number; + /** An object for the bot's new menu button. Defaults to MenuButtonDefault */ + menu_button?: MenuButton; + }): true; + /** Use this method to get the current value of the bot's menu button in a private chat, or the default menu button. Returns MenuButton on success. */ + getChatMenuButton(args: { + /** Unique identifier for the target private chat. If not specified, default bot's menu button will be returned */ + chat_id?: number; + }): MenuButton; + /** Use this method to change the default administrator rights requested by the bot when it's added as an administrator to groups or channels. These rights will be suggested to users, but they are free to modify the list before adding the bot. Returns True on success. */ + setMyDefaultAdministratorRights(args: { + /** An object describing new default administrator rights. If not specified, the default administrator rights will be cleared. */ + rights?: ChatAdministratorRights; + /** Pass True to change the default administrator rights of the bot in channels. Otherwise, the default administrator rights of the bot for groups and supergroups will be changed. */ + for_channels?: boolean; + }): true; + /** Use this method to get the current default administrator rights of the bot. Returns ChatAdministratorRights on success. */ + getMyDefaultAdministratorRights(args: { + /** Pass True to get default administrator rights of the bot in channels. Otherwise, default administrator rights of the bot for groups and supergroups will be returned. */ + for_channels?: boolean; + }): ChatAdministratorRights; + /** A method to get the current Telegram Stars balance of the bot. Requires no parameters. On success, returns a StarAmount object. */ + getMyStarBalance(): StarAmount; + /** Use this method to edit text and game messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent. */ + editMessageText(args: { + /** Unique identifier of the business connection on behalf of which the message to be edited was sent */ + business_connection_id?: string; + /** Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) */ + chat_id?: number | string; + /** Required if inline_message_id is not specified. Identifier of the message to edit */ + message_id?: number; + /** Required if chat_id and message_id are not specified. Identifier of the inline message */ + inline_message_id?: string; + /** New text of the message, 1-4096 characters after entities parsing */ + text: string; + /** Mode for parsing entities in the message text. See formatting options for more details. */ + parse_mode?: ParseMode; + /** A list of special entities that appear in message text, which can be specified instead of parse_mode */ + entities?: MessageEntity[]; + /** Link preview generation options for the message */ + link_preview_options?: LinkPreviewOptions; + /** An object for an inline keyboard. */ + reply_markup?: InlineKeyboardMarkup; + }): (Update.Edited & Message.TextMessage) | true; + /** Use this method to edit captions of messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent. */ + editMessageCaption(args: { + /** Unique identifier of the business connection on behalf of which the message to be edited was sent */ + business_connection_id?: string; + /** Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) */ + chat_id?: number | string; + /** Required if inline_message_id is not specified. Identifier of the message to edit */ + message_id?: number; + /** Required if chat_id and message_id are not specified. Identifier of the inline message */ + inline_message_id?: string; + /** New caption of the message, 0-1024 characters after entities parsing */ + caption?: string; + /** Mode for parsing entities in the message caption. See formatting options for more details. */ + parse_mode?: ParseMode; + /** A list of special entities that appear in the caption, which can be specified instead of parse_mode */ + caption_entities?: MessageEntity[]; + /** Pass True, if the caption must be shown above the message media. Supported only for animation, photo and video messages. */ + show_caption_above_media?: boolean; + /** An object for an inline keyboard. */ + reply_markup?: InlineKeyboardMarkup; + }): (Update.Edited & Message.CaptionableMessage) | true; + /** Use this method to edit animation, audio, document, photo, or video messages, or to add media to text messages. If a message is part of a message album, then it can be edited only to an audio for audio albums, only to a document for document albums and to a photo or a video otherwise. When an inline message is edited, a new file can't be uploaded; use a previously uploaded file via its file_id or specify a URL. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent. */ + editMessageMedia(args: { + /** Unique identifier of the business connection on behalf of which the message to be edited was sent */ + business_connection_id?: string; + /** Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) */ + chat_id?: number | string; + /** Required if inline_message_id is not specified. Identifier of the message to edit */ + message_id?: number; + /** Required if chat_id and message_id are not specified. Identifier of the inline message */ + inline_message_id?: string; + /** An object for a new media content of the message */ + media: InputMedia; + /** An object for a new inline keyboard. */ + reply_markup?: InlineKeyboardMarkup; + }): (Update.Edited & Message) | true; + /** Use this method to edit only the reply markup of messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent. */ + editMessageReplyMarkup(args: { + /** Unique identifier of the business connection on behalf of which the message to be edited was sent */ + business_connection_id?: string; + /** Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) */ + chat_id?: number | string; + /** Required if inline_message_id is not specified. Identifier of the message to edit */ + message_id?: number; + /** Required if chat_id and message_id are not specified. Identifier of the inline message */ + inline_message_id?: string; + /** An object for an inline keyboard. */ + reply_markup?: InlineKeyboardMarkup; + }): (Update.Edited & Message) | true; + /** Use this method to stop a poll which was sent by the bot. On success, the stopped Poll is returned. */ + stopPoll(args: { + /** Unique identifier of the business connection on behalf of which the message to be edited was sent */ + business_connection_id?: string; + /** Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) */ + chat_id: number | string; + /** Identifier of the original message with the poll */ + message_id: number; + /** An object for a new message inline keyboard. */ + reply_markup?: InlineKeyboardMarkup; + }): Poll; + /** Use this method to delete a message, including service messages, with the following limitations: + - A message can only be deleted if it was sent less than 48 hours ago. + - Service messages about a supergroup, channel, or forum topic creation can't be deleted. + - A dice message in a private chat can only be deleted if it was sent more than 24 hours ago. + - Bots can delete outgoing messages in private chats, groups, and supergroups. + - Bots can delete incoming messages in private chats. + - Bots granted can_post_messages permissions can delete outgoing messages in channels. + - If the bot is an administrator of a group, it can delete any message there. + - If the bot has can_delete_messages administrator right in a supergroup or a channel, it can delete any message there. + - If the bot has can_manage_direct_messages administrator right in a channel, it can delete any message in the corresponding direct messages chat. + Returns True on success. */ + deleteMessage(args: { + /** Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) */ + chat_id: number | string; + /** Identifier of the message to delete */ + message_id: number; + }): true; + /** Use this method to delete multiple messages simultaneously. Returns True on success. */ + deleteMessages(args: { + /** Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) */ + chat_id: number | string; + /** A list of 1-100 identifiers of messages to delete. See deleteMessage for limitations on which messages can be deleted */ + message_ids: number[]; + }): true; + /** Delete messages on behalf of a business account. Requires the can_delete_outgoing_messages business bot right to delete messages sent by the bot itself, or the can_delete_all_messages business bot right to delete any message. Returns True on success. */ + deleteBusinessMessages(args: { + /** Unique identifier of the business connection on behalf of which to delete the messages */ + business_connection_id: string; + /** A list of 1-100 identifiers of messages to delete. All messages must be from the same chat. See deleteMessage for limitations on which messages can be deleted */ + message_ids: number[]; + }): true; + /** Changes the first and last name of a managed business account. Requires the can_change_name business bot right. Returns True on success. */ + setBusinessAccountName(args: { + /** Unique identifier of the business connection */ + business_connection_id: string; + /** The new value of the first name for the business account; 1-64 characters */ + first_name: string; + /** The new value of the last name for the business account; 0-64 characters */ + last_name?: string; + }): true; + /** Changes the username of a managed business account. Requires the can_change_username business bot right. Returns True on success. */ + setBusinessAccountUsername(args: { + /** Unique identifier of the business connection */ + business_connection_id: string; + /** The new value of the username for the business account; 0-32 characters */ + username?: string; + }): true; + /** Changes the bio of a managed business account. Requires the can_change_bio business bot right. Returns True on success. */ + setBusinessAccountBio(args: { + /** Unique identifier of the business connection */ + business_connection_id: string; + /** The new value of the bio for the business account; 0-140 characters */ + bio?: string; + }): true; + /** Changes the profile photo of a managed business account. Requires the can_edit_profile_photo business bot right. Returns True on success. */ + setBusinessAccountProfilePhoto(args: { + /** Unique identifier of the business connection */ + business_connection_id: string; + /** The new profile photo to set */ + photo: InputProfilePhoto; + /** Pass True to set the public photo, which will be visible even if the main photo is hidden by the business account's privacy settings. An account can have only one public photo. */ + is_public?: boolean; + }): true; + /** Removes the current profile photo of a managed business account. Requires the can_edit_profile_photo business bot right. Returns True on success. */ + removeBusinessAccountProfilePhoto(args: { + /** Unique identifier of the business connection */ + business_connection_id: string; + /** Pass True to remove the public photo, which is visible even if the main photo is hidden by the business account's privacy settings. After the main photo is removed, the previous profile photo (if present) becomes the main photo. */ + is_public?: boolean; + }): true; + /** Changes the privacy settings pertaining to incoming gifts in a managed business account. Requires the can_change_gift_settings business bot right. Returns True on success. */ + setBusinessAccountGiftSettings(args: { + /** Unique identifier of the business connection */ + business_connection_id: string; + /** Pass True, if a button for sending a gift to the user or by the business account must always be shown in the input field */ + show_gift_button: boolean; + /** Types of gifts accepted by the business account */ + accepted_gift_types: AcceptedGiftTypes; + }): true; + /** Returns the amount of Telegram Stars owned by a managed business account. Requires the can_view_gifts_and_stars business bot right. Returns StarAmount on success. */ + getBusinessAccountStarBalance(args: { + /** Unique identifier of the business connection */ + business_connection_id: string; + }): StarAmount; + /** Transfers Telegram Stars from the business account balance to the bot's balance. Requires the can_transfer_stars business bot right. Returns True on success. */ + transferBusinessAccountStars(args: { + /** Unique identifier of the business connection */ + business_connection_id: string; + /** Number of Telegram Stars to transfer; 1-10000 */ + star_count: number; + }): true; + /** Returns the gifts received and owned by a managed business account. Requires the can_view_gifts_and_stars business bot right. Returns OwnedGifts on success. */ + getBusinessAccountGifts(args: { + /** Unique identifier of the business connection */ + business_connection_id: string; + /** Pass True to exclude gifts that aren't saved to the account's profile page */ + exclude_unsaved?: boolean; + /** Pass True to exclude gifts that are saved to the account's profile page */ + exclude_saved?: boolean; + /** Pass True to exclude gifts that can be purchased an unlimited number of times */ + exclude_unlimited?: boolean; + /** Pass True to exclude gifts that can be purchased a limited number of times and can be upgraded to unique */ + exclude_limited_upgradable?: boolean; + /** Pass True to exclude gifts that can be purchased a limited number of times and can't be upgraded to unique */ + exclude_limited_non_upgradable?: boolean; + /** Pass True to exclude gifts that were assigned from the TON blockchain and can't be resold or transferred in Telegram */ + exclude_from_blockchain?: boolean; + /** Pass True to exclude unique gifts */ + exclude_unique?: boolean; + /** Pass True to sort results by gift price instead of send date. Sorting is applied before pagination. */ + sort_by_price?: boolean; + /** Offset of the first entry to return as received from the previous request; use empty string to get the first chunk of results */ + offset?: string; + /** The maximum number of gifts to be returned; 1-100. Defaults to 100 */ + limit?: number; + }): OwnedGifts; + /** Converts a given regular gift to Telegram Stars. Requires the can_convert_gifts_to_stars business bot right. Returns True on success. */ + convertGiftToStars(args: { + /** Unique identifier of the business connection */ + business_connection_id: string; + /** Unique identifier of the regular gift that should be converted to Telegram Stars */ + owned_gift_id: string; + }): true; + /** Upgrades a given regular gift to a unique gift. Requires the can_transfer_and_upgrade_gifts business bot right. Additionally requires the can_transfer_stars business bot right if the upgrade is paid. Returns True on success. */ + upgradeGift(args: { + /** Unique identifier of the business connection */ + business_connection_id: string; + /** Unique identifier of the regular gift that should be upgraded to a unique one */ + owned_gift_id: string; + /** Pass True to keep the original gift text, sender and receiver in the upgraded gift */ + keep_original_details?: boolean; + /** The amount of Telegram Stars that will be paid for the upgrade from the business account balance. If gift.prepaid_upgrade_star_count > 0, then pass 0, otherwise, the can_transfer_stars business bot right is required and gift.upgrade_star_count must be passed. */ + star_count?: number; + }): true; + /** Transfers an owned unique gift to another user. Requires the can_transfer_and_upgrade_gifts business bot right. Requires can_transfer_stars business bot right if the transfer is paid. Returns True on success. */ + transferGift(args: { + /** Unique identifier of the business connection */ + business_connection_id: string; + /** Unique identifier of the regular gift that should be transferred */ + owned_gift_id: string; + /** Unique identifier of the chat which will own the gift. The chat must be active in the last 24 hours. */ + new_owner_chat_id: number; + /** The amount of Telegram Stars that will be paid for the transfer from the business account balance. If positive, then the can_transfer_stars business bot right is required. */ + star_count: number; + }): true; + /** Posts a story on behalf of a managed business account. Requires the can_manage_stories business bot right. Returns Story on success. */ + postStory(args: { + /** Unique identifier of the business connection */ + business_connection_id: string; + /** Content of the story */ + content: InputStoryContent; + /** Period after which the story is moved to the archive, in seconds; must be one of 6 * 3600, 12 * 3600, 86400, or 2 * 86400 */ + active_period: number; + /** Caption of the story, 0-2048 characters after entities parsing */ + caption?: string; + /** Mode for parsing entities in the story caption. See formatting options for more details. */ + parse_mode?: ParseMode; + /** A list of special entities that appear in the caption, which can be specified instead of parse_mode */ + caption_entities?: MessageEntity[]; + /** A list of clickable areas to be shown on the story */ + areas?: StoryArea[]; + /** Pass True to keep the story accessible after it expires */ + post_to_chat_page?: boolean; + /** Pass True if the content of the story must be protected from forwarding and screenshotting */ + protect_content?: boolean; + }): Story; + /** Reposts a story on behalf of a business account from another business account. Both business accounts must be managed by the same bot, and the story on the source account must have been posted (or reposted) by the bot. Requires the can_manage_stories business bot right for both business accounts. Returns Story on success. */ + repostStory(args: { + /** Unique identifier of the business connection */ + business_connection_id: string; + /** Unique identifier of the chat which posted the story that should be reposted */ + from_chat_id: number; + /** Unique identifier of the story that should be reposted */ + from_story_id: number; + /** Period after which the story is moved to the archive, in seconds; must be one of 6 * 3600, 12 * 3600, 86400, or 2 * 86400 */ + active_period: number; + /** Pass True to keep the story accessible after it expires */ + post_to_chat_page?: boolean; + /** Pass True if the content of the story must be protected from forwarding and screenshotting */ + protect_content?: boolean; + }): Story; + /** Edits a story previously posted by the bot on behalf of a managed business account. Requires the can_manage_stories business bot right. Returns Story on success. */ + editStory(args: { + /** Unique identifier of the business connection */ + business_connection_id: string; + /** Unique identifier of the story to edit */ + story_id: number; + /** Content of the story */ + content: InputStoryContent; + /** Caption of the story, 0-2048 characters after entities parsing */ + caption?: string; + /** Mode for parsing entities in the story caption. See formatting options for more details. */ + parse_mode?: ParseMode; + /** A list of special entities that appear in the caption, which can be specified instead of parse_mode */ + caption_entities?: MessageEntity[]; + /** A list of clickable areas to be shown on the story */ + areas?: StoryArea; + }): Story; + /** Deletes a story previously posted by the bot on behalf of a managed business account. Requires the can_manage_stories business bot right. Returns True on success. */ + deleteStory(args: { + /** Unique identifier of the business connection */ + business_connection_id: string; + /** Unique identifier of the story to delete */ + story_id: number; + }): true; + /** Use this method to send static .WEBP, animated .TGS, or video .WEBM stickers. On success, the sent Message is returned. */ + sendSticker(args: { + /** Unique identifier of the business connection on behalf of which the message will be sent */ + business_connection_id?: string; + /** Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) */ + chat_id: number | string; + /** Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only */ + message_thread_id?: number; + /** Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat */ + direct_messages_topic_id?: number; + /** Sticker to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a .WEBP sticker from the Internet, or upload a new .WEBP, .TGS, or .WEBM sticker using multipart/form-data. Video and animated stickers can't be sent via an HTTP URL. */ + sticker: F | string; + /** Emoji associated with the sticker; only for just uploaded stickers */ + emoji?: string; + /** Sends the message silently. Users will receive a notification with no sound. */ + disable_notification?: boolean; + /** Protects the contents of the sent message from forwarding and saving */ + protect_content?: boolean; + /** Pass True to allow up to 1000 messages per second, ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance */ + allow_paid_broadcast?: boolean; + /** An object containing the parameters of the suggested post to send; for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post is automatically declined. */ + suggested_post_parameters?: SuggestedPostParameters; + /** Unique identifier of the message effect to be added to the message; for private chats only */ + message_effect_id?: string; + /** Description of the message to reply to */ + reply_parameters?: ReplyParameters; + /** Additional interface options. An object for an inline keyboard, custom reply keyboard, instructions to remove a reply keyboard or to force a reply from the user. */ + reply_markup?: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply; + /** @deprecated Use `reply_parameters` instead. */ + reply_to_message_id?: number; + }): Message.StickerMessage; + /** Use this method to get a sticker set. On success, a StickerSet object is returned. */ + getStickerSet(args: { + /** Name of the sticker set */ + name: string; + }): StickerSet; + /** Use this method to get information about custom emoji stickers by their identifiers. Returns an Array of Sticker objects. */ + getCustomEmojiStickers(args: { + /** A list of custom emoji identifiers. At most 200 custom emoji identifiers can be specified. */ + custom_emoji_ids: string[]; + }): Sticker[]; + /** Use this method to upload a file with a sticker for later use in the createNewStickerSet, addStickerToSet, or replaceStickerInSet methods (the file can be used multiple times). Returns the uploaded File on success. */ + uploadStickerFile(args: { + /** User identifier of sticker file owner */ + user_id: number; + /** Format of the sticker, must be one of “static”, “animated”, “video” */ + sticker_format: "static" | "animated" | "video"; + /** A file with the sticker in .WEBP, .PNG, .TGS, or .WEBM format. See https://core.telegram.org/stickers for technical requirements. */ + sticker: F; + }): File; + /** Use this method to create a new sticker set owned by a user. The bot will be able to edit the sticker set thus created. Returns True on success. */ + createNewStickerSet(args: { + /** User identifier of created sticker set owner */ + user_id: number; + /** Short name of sticker set, to be used in t.me/addstickers/ URLs (e.g., animals). Can contain only English letters, digits and underscores. Must begin with a letter, can't contain consecutive underscores and must end in "_by_". is case insensitive. 1-64 characters. */ + name: string; + /** Sticker set title, 1-64 characters */ + title: string; + /** A list of 1-50 initial stickers to be added to the sticker set */ + stickers: InputSticker[]; + /** Type of stickers in the set, pass “regular”, “mask”, or “custom_emoji”. By default, a regular sticker set is created. */ + sticker_type?: "regular" | "mask" | "custom_emoji"; + /** Pass True if stickers in the sticker set must be repainted to the color of text when used in messages, the accent color if used as emoji status, white on chat photos, or another appropriate color based on context; for custom emoji sticker sets only */ + needs_repainting?: boolean; + }): true; + /** Use this method to add a new sticker to a set created by the bot. Emoji sticker sets can have up to 200 stickers. Other sticker sets can have up to 120 stickers. Returns True on success. */ + addStickerToSet(args: { + /** User identifier of sticker set owner */ + user_id: number; + /** Sticker set name */ + name: string; + /** An object with information about the added sticker. If exactly the same sticker had already been added to the set, then the set isn't changed. */ + sticker: InputSticker; + }): true; + /** Use this method to move a sticker in a set created by the bot to a specific position. Returns True on success. */ + setStickerPositionInSet(args: { + /** File identifier of the sticker */ + sticker: string; + /** New sticker position in the set, zero-based */ + position: number; + }): true; + /** Use this method to delete a sticker from a set created by the bot. Returns True on success. */ + deleteStickerFromSet(args: { + /** File identifier of the sticker */ + sticker: string; + }): true; + /** Use this method to replace an existing sticker in a sticker set with a new one. The method is equivalent to calling deleteStickerFromSet, then addStickerToSet, then setStickerPositionInSet. Returns True on success. */ + replaceStickerInSet(args: { + /** User identifier of the sticker set owner */ + user_id: number; + /** Sticker set name */ + name: string; + /** File identifier of the replaced sticker */ + old_sticker: string; + /** An object with information about the added sticker. If exactly the same sticker had already been added to the set, then the set remains unchanged.:x */ + sticker: InputSticker; + }): true; + /** Use this method to change the list of emoji assigned to a regular or custom emoji sticker. The sticker must belong to a sticker set created by the bot. Returns True on success. */ + setStickerEmojiList(args: { + /** File identifier of the sticker */ + sticker: string; + /** A list of 1-20 emoji associated with the sticker */ + emoji_list: string[]; + }): true; + /** Use this method to change search keywords assigned to a regular or custom emoji sticker. The sticker must belong to a sticker set created by the bot. Returns True on success. */ + setStickerKeywords(args: { + /** File identifier of the sticker */ + sticker: string; + /** A list of 0-20 search keywords for the sticker with total length of up to 64 characters */ + keywords?: string[]; + }): true; + /** Use this method to change the mask position of a mask sticker. The sticker must belong to a sticker set that was created by the bot. Returns True on success. */ + setStickerMaskPosition(args: { + /** File identifier of the sticker */ + sticker: string; + /** An object with the position where the mask should be placed on faces. Omit the parameter to remove the mask position. */ + mask_position?: MaskPosition; + }): true; + /** Use this method to set the title of a created sticker set. Returns True on success. */ + setStickerSetTitle(args: { + /** Sticker set name */ + name: string; + /** Sticker set title, 1-64 characters */ + title: string; + }): true; + /** Use this method to delete a sticker set that was created by the bot. Returns True on success. */ + deleteStickerSet(args: { + /** Sticker set name */ + name: string; + }): true; + /** Use this method to set the thumbnail of a regular or mask sticker set. The format of the thumbnail file must match the format of the stickers in the set. Returns True on success. */ + setStickerSetThumbnail(args: { + /** Sticker set name */ + name: string; + /** User identifier of the sticker set owner */ + user_id: number; + /** A .WEBP or .PNG image with the thumbnail, must be up to 128 kilobytes in size and have a width and height of exactly 100px, or a .TGS animation with a thumbnail up to 32 kilobytes in size (see https://core.telegram.org/stickers#animation-requirements for animated sticker technical requirements), or a .WEBM video with the thumbnail up to 32 kilobytes in size; see https://core.telegram.org/stickers#video-requirements for video sticker technical requirements. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. More information on Sending Files ». Animated and video sticker set thumbnails can't be uploaded via HTTP URL. If omitted, then the thumbnail is dropped and the first sticker is used as the thumbnail. */ + thumbnail?: F | string; + /** Format of the thumbnail, must be one of “static” for a .WEBP or .PNG image, “animated” for a .TGS animation, or “video” for a .WEBM video */ + format: "static" | "animated" | "video"; + }): true; + /** Use this method to set the thumbnail of a custom emoji sticker set. Returns True on success. */ + setCustomEmojiStickerSetThumbnail(args: { + /** Sticker set name */ + name: string; + /** Custom emoji identifier of a sticker from the sticker set; pass an empty string to drop the thumbnail and use the first sticker as the thumbnail. */ + custom_emoji_id?: string; + }): true; + /** Returns the list of gifts that can be sent by the bot to users and channel chats. Requires no parameters. Returns a Gifts object. */ + getAvailableGifts(): Gifts; + /** Sends a gift to the given user or channel chat. The gift can't be converted to Telegram Stars by the receiver. Returns True on success. */ + sendGift(args: { + /** Required if chat_id is not specified. Unique identifier of the target user who will receive the gift. */ + user_id?: number; + /** Required if user_id is not specified. Unique identifier for the chat or username of the channel (in the format `@channelusername`) that will receive the gift. */ + chat_id?: number | string; + /** Identifier of the gift */ + gift_id: string; + /** Pass True to pay for the gift upgrade from the bot's balance, thereby making the upgrade free for the receiver */ + pay_for_upgrade?: boolean; + /** Text that will be shown along with the gift; 0-128 characters */ + text?: string; + /** Mode for parsing entities in the text. See formatting options for more details. Entities other than “bold”, “italic”, “underline”, “strikethrough”, “spoiler”, and “custom_emoji” are ignored. */ + text_parse_mode?: ParseMode; + /** A list of special entities that appear in the gift text. It can be specified instead of text_parse_mode. Entities other than “bold”, “italic”, “underline”, “strikethrough”, “spoiler”, and “custom_emoji” are ignored. */ + text_entities?: MessageEntity[]; + }): true; + /** Gifts a Telegram Premium subscription to the given user. Returns True on success. */ + giftPremiumSubscription(args: { + /** Unique identifier of the target user who will receive a Telegram Premium subscription */ + user_id: number; + /** Number of months the Telegram Premium subscription will be active for the user; must be one of 3, 6, or 12 */ + month_count: 3 | 6 | 12; + /** Number of Telegram Stars to pay for the Telegram Premium subscription; must be 1000 for 3 months, 1500 for 6 months, and 2500 for 12 months */ + star_count: 1000 | 1500 | 2500; + /** Text that will be shown along with the service message about the subscription; 0-128 characters */ + text?: string; + /** Mode for parsing entities in the text. See formatting options for more details. Entities other than “bold”, “italic”, “underline”, “strikethrough”, “spoiler”, and “custom_emoji” are ignored. */ + text_parse_mode?: ParseMode; + /** A list of special entities that appear in the gift text. It can be specified instead of text_parse_mode. Entities other than “bold”, “italic”, “underline”, “strikethrough”, “spoiler”, and “custom_emoji” are ignored. */ + text_entities?: MessageEntity[]; + }): true; + /** Use this method to send answers to an inline query. On success, True is returned. + No more than 50 results per query are allowed. + + Example: An inline bot that sends YouTube videos can ask the user to connect the bot to their YouTube account to adapt search results accordingly. To do this, it displays a 'Connect your YouTube account' button above the results, or even before showing any. The user presses the button, switches to a private chat with the bot and, in doing so, passes a start parameter that instructs the bot to return an OAuth link. Once done, the bot can offer a switch_inline button so that the user can easily return to the chat where they wanted to use the bot's inline capabilities. */ + answerInlineQuery(args: { + /** Unique identifier for the answered query */ + inline_query_id: string; + /** An array of results for the inline query */ + results: readonly InlineQueryResult[]; + /** The maximum amount of time in seconds that the result of the inline query may be cached on the server. Defaults to 300. */ + cache_time?: number; + /** Pass True if results may be cached on the server side only for the user that sent the query. By default, results may be returned to any user who sends the same query. */ + is_personal?: boolean; + /** Pass the offset that a client should send in the next query with the same text to receive more results. Pass an empty string if there are no more results or if you don't support pagination. Offset length can't exceed 64 bytes. */ + next_offset?: string; + /** An object describing a button to be shown above inline query results */ + button?: InlineQueryResultsButton; + }): true; + /** Use this method to set the result of an interaction with a Web App and send a corresponding message on behalf of the user to the chat from which the query originated. On success, a SentWebAppMessage object is returned. */ + answerWebAppQuery(args: { + /** Unique identifier for the query to be answered */ + web_app_query_id: string; + /** An object describing the message to be sent */ + result: InlineQueryResult; + }): SentWebAppMessage; + /** Stores a message that can be sent by a user of a Mini App. Returns a PreparedInlineMessage object. */ + savePreparedInlineMessage(args: { + /** Unique identifier of the target user that can use the prepared message */ + user_id: number; + /** An object describing the message to be sent */ + result: InlineQueryResult; + /** Pass True if the message can be sent to private chats with users */ + allow_user_chats?: boolean; + /** Pass True if the message can be sent to private chats with bots */ + allow_bot_chats?: boolean; + /** Pass True if the message can be sent to group and supergroup chats */ + allow_group_chats?: boolean; + /** Pass True if the message can be sent to channel chats */ + allow_channel_chats?: boolean; + }): PreparedInlineMessage; + /** Use this method to send invoices. On success, the sent Message is returned. */ + sendInvoice(args: { + /** Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) */ + chat_id: number | string; + /** Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only */ + message_thread_id?: number; + /** Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat */ + direct_messages_topic_id?: number; + /** Product name, 1-32 characters */ + title: string; + /** Product description, 1-255 characters */ + description: string; + /** Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use it for your internal processes. */ + payload: string; + /** Payment provider token, obtained via BotFather. Pass an empty string for payments in Telegram Stars. */ + provider_token?: string; + /** Three-letter ISO 4217 currency code, see more on currencies. Pass “XTR” for payments in Telegram Stars. */ + currency: string; + /** Price breakdown, a JSON-serialized list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.). Must contain exactly one item for payments in Telegram Stars. */ + prices: readonly LabeledPrice[]; + /** The maximum accepted amount for tips in the smallest units of the currency (integer, not float/double). For example, for a maximum tip of US$ 1.45 pass max_tip_amount = 145. See the exp parameter in currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies). Defaults to 0. Not supported for payments in Telegram Stars. */ + max_tip_amount?: number; + /** An array of suggested amounts of tips in the smallest units of the currency (integer, not float/double). At most 4 suggested tip amounts can be specified. The suggested tip amounts must be positive, passed in a strictly increased order and must not exceed max_tip_amount. */ + suggested_tip_amounts?: number[]; + /** Unique deep-linking parameter. If left empty, forwarded copies of the sent message will have a Pay button, allowing multiple users to pay directly from the forwarded message, using the same invoice. If non-empty, forwarded copies of the sent message will have a URL button with a deep link to the bot (instead of a Pay button), with the value used as the start parameter */ + start_parameter?: string; + /** Data about the invoice, which will be shared with the payment provider. A detailed description of required fields should be provided by the payment provider. */ + provider_data?: string; + /** URL of the product photo for the invoice. Can be a photo of the goods or a marketing image for a service. People like it better when they see what they are paying for. */ + photo_url?: string; + /** Photo size in bytes */ + photo_size?: number; + /** Photo width */ + photo_width?: number; + /** Photo height */ + photo_height?: number; + /** Pass True if you require the user's full name to complete the order. Ignored for payments in Telegram Stars. */ + need_name?: boolean; + /** Pass True if you require the user's phone number to complete the order. Ignored for payments in Telegram Stars. */ + need_phone_number?: boolean; + /** Pass True if you require the user's email address to complete the order. Ignored for payments in Telegram Stars. */ + need_email?: boolean; + /** Pass True if you require the user's shipping address to complete the order. Ignored for payments in Telegram Stars. */ + need_shipping_address?: boolean; + /** Pass True if the user's phone number should be sent to provider. Ignored for payments in Telegram Stars. */ + send_phone_number_to_provider?: boolean; + /** Pass True if the user's email address should be sent to provider. Ignored for payments in Telegram Stars. */ + send_email_to_provider?: boolean; + /** Pass True if the final price depends on the shipping method. Ignored for payments in Telegram Stars. */ + is_flexible?: boolean; + /** An object containing the parameters of the suggested post to send; for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post is automatically declined. */ + suggested_post_parameters?: SuggestedPostParameters; + /** Sends the message silently. Users will receive a notification with no sound. */ + disable_notification?: boolean; + /** Protects the contents of the sent message from forwarding and saving */ + protect_content?: boolean; + /** Pass True to allow up to 1000 messages per second, ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance */ + allow_paid_broadcast?: boolean; + /** Unique identifier of the message effect to be added to the message; for private chats only */ + message_effect_id?: string; + /** Description of the message to reply to */ + reply_parameters?: ReplyParameters; + /** An object for an inline keyboard. If empty, one 'Pay total price' button will be shown. If not empty, the first button must be a Pay button. */ + reply_markup?: InlineKeyboardMarkup; + /** @deprecated Use `reply_parameters` instead. */ + reply_to_message_id?: number; + }): Message.InvoiceMessage; + /** Use this method to create a link for an invoice. Returns the created invoice link as String on success. */ + createInvoiceLink(args: { + /** Unique identifier of the business connection on behalf of which the link will be created */ + business_connection_id?: string; + /** Product name, 1-32 characters */ + title: string; + /** Product description, 1-255 characters */ + description: string; + /** Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use it for your internal processes. */ + payload: string; + /** Payment provider token, obtained via `@BotFather`. Pass an empty string for payments in Telegram Stars. */ + provider_token?: string; + /** Three-letter ISO 4217 currency code, see more on currencies */ + currency: string; + /** Price breakdown, a list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.) */ + prices: LabeledPrice[]; + /** The number of seconds the subscription will be active for before the next payment. The currency must be set to “XTR” (Telegram Stars) if the parameter is used. Currently, it must always be 2592000 (30 days) if specified. */ + subscription_period?: number; + /** The maximum accepted amount for tips in the smallest units of the currency (integer, not float/double). For example, for a maximum tip of US$ 1.45 pass max_tip_amount = 145. See the exp parameter in currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies). Defaults to 0 */ + max_tip_amount?: number; + /** An array of suggested amounts of tips in the smallest units of the currency (integer, not float/double). At most 4 suggested tip amounts can be specified. The suggested tip amounts must be positive, passed in a strictly increased order and must not exceed max_tip_amount. */ + suggested_tip_amounts?: number[]; + /** Data about the invoice, which will be shared with the payment provider. A detailed description of required fields should be provided by the payment provider. */ + provider_data?: string; + /** URL of the product photo for the invoice. Can be a photo of the goods or a marketing image for a service. */ + photo_url?: string; + /** Photo size in bytes */ + photo_size?: number; + /** Photo width */ + photo_width?: number; + /** Photo height */ + photo_height?: number; + /** Pass True if you require the user's full name to complete the order */ + need_name?: boolean; + /** Pass True if you require the user's phone number to complete the order */ + need_phone_number?: boolean; + /** Pass True if you require the user's email address to complete the order */ + need_email?: boolean; + /** Pass True if you require the user's shipping address to complete the order */ + need_shipping_address?: boolean; + /** Pass True if the user's phone number should be sent to the provider */ + send_phone_number_to_provider?: boolean; + /** Pass True if the user's email address should be sent to the provider */ + send_email_to_provider?: boolean; + /** Pass True if the final price depends on the shipping method */ + is_flexible?: boolean; + }): string; + /** If you sent an invoice requesting a shipping address and the parameter is_flexible was specified, the Bot API will send an Update with a shipping_query field to the bot. Use this method to reply to shipping queries. On success, True is returned. */ + answerShippingQuery(args: { + /** Unique identifier for the query to be answered */ + shipping_query_id: string; + /** Pass True if delivery to the specified address is possible and False if there are any problems (for example, if delivery to the specified address is not possible) */ + ok: boolean; + /** Required if ok is True. An array of available shipping options. */ + shipping_options?: readonly ShippingOption[]; + /** Required if ok is False. Error message in human readable form that explains why it is impossible to complete the order (e.g. “Sorry, delivery to your desired address is unavailable”). Telegram will display this message to the user. */ + error_message?: string; + }): true; + /** Once the user has confirmed their payment and shipping details, the Bot API sends the final confirmation in the form of an Update with the field pre_checkout_query. Use this method to respond to such pre-checkout queries. On success, True is returned. Note: The Bot API must receive an answer within 10 seconds after the pre-checkout query was sent. */ + answerPreCheckoutQuery(args: { + /** Unique identifier for the query to be answered */ + pre_checkout_query_id: string; + /** Specify True if everything is alright (goods are available, etc.) and the bot is ready to proceed with the order. Use False if there are any problems. */ + ok: boolean; + /** Required if ok is False. Error message in human readable form that explains the reason for failure to proceed with the checkout (e.g. "Sorry, somebody just bought the last of our amazing black T-shirts while you were busy filling out your payment details. Please choose a different color or garment!"). Telegram will display this message to the user. */ + error_message?: string; + }): true; + /** Returns the bot's Telegram Star transactions in chronological order. On success, returns a StarTransactions object. */ + getStarTransactions(args: { + /** Number of transactions to skip in the response */ + offset?: number; + /** The maximum number of transactions to be retrieved. Values between 1-100 are accepted. Defaults to 100. */ + limit?: number; + }): StarTransactions; + /** Refunds a successful payment in Telegram Stars. Returns True on success. */ + refundStarPayment(args: { + /** Identifier of the user whose payment will be refunded */ + user_id: number; + /** Telegram payment identifier */ + telegram_payment_charge_id: string; + }): true; + /** Allows the bot to cancel or re-enable extension of a subscription paid in Telegram Stars. Returns True on success. */ + editUserStarSubscription(args: { + /** Identifier of the user whose subscription will be edited */ + user_id: number; + /** Telegram payment identifier for the subscription */ + telegram_payment_charge_id: string; + /** Pass True to cancel extension of the user subscription; the subscription must be active up to the end of the current subscription period. Pass False to allow the user to re-enable a subscription that was previously canceled by the bot. */ + is_canceled: boolean; + }): true; + /** Verifies a user on behalf of the organization which is represented by the bot. Returns True on success. */ + verifyUser(args: { + /** Unique identifier of the target user */ + user_id: number; + /** Custom description for the verification; 0-70 characters. Must be empty if the organization isn't allowed to provide a custom verification description. */ + custom_description?: string; + }): true; + /** Verifies a chat on behalf of the organization which is represented by the bot. Returns True on success. */ + verifyChat(args: { + /** Unique identifier for the target chat or username of the target channel (in the format `@channelusername`). Channel direct messages chats can't be verified. */ + chat_id: number | string; + /** Custom description for the verification; 0-70 characters. Must be empty if the organization isn't allowed to provide a custom verification description. */ + custom_description?: string; + }): true; + /** Removes verification from a user who is currently verified on behalf of the organization represented by the bot. Returns True on success. */ + removeUserVerification(args: { + /** Unique identifier of the target user */ + user_id: number; + }): true; + /** Removes verification from a chat that is currently verified on behalf of the organization represented by the bot. Returns True on success. */ + removeChatVerification(args: { + /** Unique identifier for the target chat or username of the target channel (in the format `@channelusername`) */ + chat_id: number | string; + }): true; + /** Marks incoming message as read on behalf of a business account. Requires the can_read_messages business bot right. Returns True on success. */ + readBusinessMessage(args: { + /** Unique identifier of the business connection on behalf of which to read the message */ + business_connection_id: string; + /** Unique identifier of the chat in which the message was received. The chat must have been active in the last 24 hours. */ + chat_id: number; + /** Unique identifier of the message to mark as read */ + message_id: number; + }): true; + /** Informs a user that some of the Telegram Passport elements they provided contains errors. The user will not be able to re-submit their Passport to you until the errors are fixed (the contents of the field for which you returned the error must change). Returns True on success. + + Use this if the data submitted by the user doesn't satisfy the standards your service requires for any reason. For example, if a birthday date seems invalid, a submitted document is blurry, a scan shows evidence of tampering, etc. Supply some details in the error message to make sure the user knows how to correct the issues. */ + setPassportDataErrors(args: { + /** User identifier */ + user_id: number; + /** An array describing the errors */ + errors: readonly PassportElementError[]; + }): true; + /** Use this method to send a game. On success, the sent Message is returned. */ + sendGame(args: { + /** Unique identifier of the business connection on behalf of which the message will be sent */ + business_connection_id?: string; + /** Unique identifier for the target chat. Games can't be sent to channel direct messages chats and channel chats. */ + chat_id: number; + /** Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only */ + message_thread_id?: number; + /** Short name of the game, serves as the unique identifier for the game. Set up your games via BotFather. */ + game_short_name: string; + /** Sends the message silently. Users will receive a notification with no sound. */ + disable_notification?: boolean; + /** Protects the contents of the sent message from forwarding and saving */ + protect_content?: boolean; + /** Pass True to allow up to 1000 messages per second, ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance */ + allow_paid_broadcast?: boolean; + /** Unique identifier of the message effect to be added to the message; for private chats only */ + message_effect_id?: string; + /** Description of the message to reply to */ + reply_parameters?: ReplyParameters; + /** An object for an inline keyboard. If empty, one 'Play game_title' button will be shown. If not empty, the first button must launch the game. */ + reply_markup?: InlineKeyboardMarkup; + /** @deprecated Use `reply_parameters` instead. */ + reply_to_message_id?: number; + }): Message.GameMessage; + /** Use this method to set the score of the specified user in a game message. On success, if the message is not an inline message, the Message is returned, otherwise True is returned. Returns an error, if the new score is not greater than the user's current score in the chat and force is False. */ + setGameScore(args: { + /** User identifier */ + user_id: number; + /** New score, must be non-negative */ + score: number; + /** Pass True if the high score is allowed to decrease. This can be useful when fixing mistakes or banning cheaters */ + force?: boolean; + /** Pass True if the game message should not be automatically edited to include the current scoreboard */ + disable_edit_message?: boolean; + /** Required if inline_message_id is not specified. Unique identifier for the target chat */ + chat_id?: number; + /** Required if inline_message_id is not specified. Identifier of the sent message */ + message_id?: number; + /** Required if chat_id and message_id are not specified. Identifier of the inline message */ + inline_message_id?: string; + }): (Update.Edited & Message.GameMessage) | true; + /** Use this method to get data for high score tables. Will return the score of the specified user and several of their neighbors in a game. Returns an Array of GameHighScore objects. + + This method will currently return scores for the target user, plus two of their closest neighbors on each side. Will also return the top three users if the user and their neighbors are not among them. Please note that this behavior is subject to change. */ + getGameHighScores(args: { + /** Target user id */ + user_id: number; + /** Required if inline_message_id is not specified. Unique identifier for the target chat */ + chat_id?: number; + /** Required if inline_message_id is not specified. Identifier of the sent message */ + message_id?: number; + /** Required if chat_id and message_id are not specified. Identifier of the inline message */ + inline_message_id?: string; + }): GameHighScore[]; +}; +/** This object describes a sticker to be added to a sticker set. */ +export interface InputSticker { + /** The added sticker. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. Animated and video stickers can't be uploaded via HTTP URL. */ + sticker: F | string; + /** Format of the added sticker, must be one of “static” for a .WEBP or .PNG image, “animated” for a .TGS animation, “video” for a .WEBM video */ + format: "static" | "animated" | "video"; + /** List of 1-20 emoji associated with the sticker */ + emoji_list: string[]; + /** Position where the mask should be placed on faces. For “mask” stickers only. */ + mask_position?: MaskPosition; + /** List of 0-20 search keywords for the sticker with total length of up to 64 characters. For “regular” and “custom_emoji” stickers only. */ + keywords?: string[]; +} +/** This object represents the content of a media message to be sent. It should be one of + - InputMediaAnimation + - InputMediaDocument + - InputMediaAudio + - InputMediaPhoto + - InputMediaVideo */ +export type InputMedia = InputMediaAnimation | InputMediaDocument | InputMediaAudio | InputMediaPhoto | InputMediaVideo; +/** Represents a photo to be sent. */ +export interface InputMediaPhoto { + /** Type of the result, must be photo */ + type: "photo"; + /** File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass "attach://" to upload a new one using multipart/form-data under name. */ + media: F | string; + /** Caption of the photo to be sent, 0-1024 characters after entities parsing */ + caption?: string; + /** Pass True, if the caption must be shown above the message media */ + show_caption_above_media?: boolean; + /** Mode for parsing entities in the photo caption. See formatting options for more details. */ + parse_mode?: ParseMode; + /** List of special entities that appear in the caption, which can be specified instead of parse_mode */ + caption_entities?: MessageEntity[]; + /** Pass True if the photo needs to be covered with a spoiler animation */ + has_spoiler?: boolean; +} +/** Represents a video to be sent. */ +export interface InputMediaVideo { + /** Type of the result, must be video */ + type: "video"; + /** File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass "attach://" to upload a new one using multipart/form-data under name. */ + media: F | string; + /** Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass "attach://" if the thumbnail was uploaded using multipart/form-data under . */ + thumbnail?: F; + /** Cover for the video in the message. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass “attach://” to upload a new one using multipart/form-data under name. */ + cover?: F | string; + /** Start timestamp for the video in the message */ + start_timestamp?: number; + /** Caption of the video to be sent, 0-1024 characters after entities parsing */ + caption?: string; + /** Pass True, if the caption must be shown above the message media */ + show_caption_above_media?: boolean; + /** Mode for parsing entities in the video caption. See formatting options for more details. */ + parse_mode?: ParseMode; + /** List of special entities that appear in the caption, which can be specified instead of parse_mode */ + caption_entities?: MessageEntity[]; + /** Video width */ + width?: number; + /** Video height */ + height?: number; + /** Video duration in seconds */ + duration?: number; + /** Pass True if the uploaded video is suitable for streaming */ + supports_streaming?: boolean; + /** Pass True if the photo needs to be covered with a spoiler animation */ + has_spoiler?: boolean; +} +/** Represents an animation file (GIF or H.264/MPEG-4 AVC video without sound) to be sent. */ +export interface InputMediaAnimation { + /** Type of the result, must be animation */ + type: "animation"; + /** File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass "attach://" to upload a new one using multipart/form-data under name. */ + media: F | string; + /** Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass "attach://" if the thumbnail was uploaded using multipart/form-data under . */ + thumbnail?: F; + /** Caption of the animation to be sent, 0-1024 characters after entities parsing */ + caption?: string; + /** Pass True, if the caption must be shown above the message media */ + show_caption_above_media?: boolean; + /** Mode for parsing entities in the animation caption. See formatting options for more details. */ + parse_mode?: ParseMode; + /** List of special entities that appear in the caption, which can be specified instead of parse_mode */ + caption_entities?: MessageEntity[]; + /** Animation width */ + width?: number; + /** Animation height */ + height?: number; + /** Animation duration in seconds */ + duration?: number; + /** Pass True if the photo needs to be covered with a spoiler animation */ + has_spoiler?: boolean; +} +/** Represents an audio file to be treated as music to be sent. */ +export interface InputMediaAudio { + /** Type of the result, must be audio */ + type: "audio"; + /** File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass "attach://" to upload a new one using multipart/form-data under name. */ + media: F | string; + /** Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass "attach://" if the thumbnail was uploaded using multipart/form-data under . */ + thumbnail?: F; + /** Caption of the audio to be sent, 0-1024 characters after entities parsing */ + caption?: string; + /** Mode for parsing entities in the audio caption. See formatting options for more details. */ + parse_mode?: ParseMode; + /** List of special entities that appear in the caption, which can be specified instead of parse_mode */ + caption_entities?: MessageEntity[]; + /** Duration of the audio in seconds */ + duration?: number; + /** Performer of the audio */ + performer?: string; + /** Title of the audio */ + title?: string; +} +/** Represents a general file to be sent. */ +export interface InputMediaDocument { + /** Type of the result, must be document */ + type: "document"; + /** File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass "attach://" to upload a new one using multipart/form-data under name. */ + media: F | string; + /** Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass "attach://" if the thumbnail was uploaded using multipart/form-data under . */ + thumbnail?: F; + /** Caption of the document to be sent, 0-1024 characters after entities parsing */ + caption?: string; + /** Mode for parsing entities in the document caption. See formatting options for more details. */ + parse_mode?: ParseMode; + /** List of special entities that appear in the caption, which can be specified instead of parse_mode */ + caption_entities?: MessageEntity[]; + /** Disables automatic server-side content type detection for files uploaded using multipart/form-data. Always true, if the document is sent as part of an album. */ + disable_content_type_detection?: boolean; +} +/** This object describes the paid media to be sent. Currently, it can be one of + +- InputPaidMediaPhoto +- InputPaidMediaVideo */ +export type InputPaidMedia = InputMediaPhoto | InputPaidMediaVideo; +/** The paid media to send is a photo. */ +export interface InputPaidMediaPhoto { + /** Type of the media, must be photo */ + type: "photo"; + /** File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass “attach://” to upload a new one using multipart/form-data under name. More information on Sending Files » */ + media: F | string; +} +/** The paid media to send is a video. */ +export interface InputPaidMediaVideo { + /** Type of the media, must be video */ + type: "video"; + /** File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass “attach://” to upload a new one using multipart/form-data under name. More information on Sending Files » */ + media: F | string; + /** Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass “attach://” if the thumbnail was uploaded using multipart/form-data under . More information on Sending Files » */ + thumbnail?: F; + /** Cover for the video in the message. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass “attach://” to upload a new one using multipart/form-data under name. */ + cover?: F | string; + /** Start timestamp for the video in the message */ + start_timestamp?: number; + /** Video width */ + width?: number; + /** Video height */ + height?: number; + /** Video duration in seconds */ + duration?: number; + /** Pass True if the uploaded video is suitable for streaming */ + supports_streaming?: boolean; +} +/** This object describes a profile photo to set. Currently, it can be one of + +- InputProfilePhotoStatic +- InputProfilePhotoAnimated */ +export type InputProfilePhoto = InputProfilePhotoStatic | InputProfilePhotoAnimated; +/** A static profile photo in the .JPG format. */ +export interface InputProfilePhotoStatic { + /** Type of the profile photo, must be “static” */ + type: "static"; + /** The static profile photo. Profile photos can't be reused and can only be uploaded as a new file, so you can pass “attach://” if the photo was uploaded using multipart/form-data under . More information on Sending Files » */ + photo: F; +} +/** An animated profile photo in the MPEG4 format. */ +export interface InputProfilePhotoAnimated { + /** Type of the profile photo, must be “animated” */ + type: "animated"; + /** The animated profile photo. Profile photos can't be reused and can only be uploaded as a new file, so you can pass “attach://” if the photo was uploaded using multipart/form-data under . More information on Sending Files » */ + animation: F; + /** Timestamp in seconds of the frame that will be used as the static profile photo. Defaults to 0.0. */ + main_frame_timestamp?: number; +} +/** This object describes the content of a story to post. Currently, it can be one of + +- InputStoryContentPhoto +- InputStoryContentVideo */ +export type InputStoryContent = InputStoryContentPhoto | InputStoryContentVideo; +/** Describes a photo to post as a story. */ +export interface InputStoryContentPhoto { + /** Type of the content, must be “photo” */ + type: "photo"; + /** The photo to post as a story. The photo must be of the size 1080x1920 and must not exceed 10 MB. The photo can't be reused and can only be uploaded as a new file, so you can pass “attach://” if the photo was uploaded using multipart/form-data under . More information on Sending Files » */ + photo: F; +} +/** Describes a video to post as a story. */ +export interface InputStoryContentVideo { + /** Type of the content, must be “video” */ + type: "video"; + /** The video to post as a story. The video must be of the size 720x1280, streamable, encoded with H.265 codec, with key frames added each second in the MPEG4 format, and must not exceed 30 MB. The video can't be reused and can only be uploaded as a new file, so you can pass “attach://” if the video was uploaded using multipart/form-data under . More information on Sending Files » */ + video: F; + /** Precise duration of the video in seconds; 0-60 */ + duration?: number; + /** Timestamp in seconds of the frame that will be used as the static cover for the story. Defaults to 0.0. */ + cover_frame_timestamp?: number; + /** Pass True if the video has no sound */ + is_animation?: boolean; +} +export {}; diff --git a/sandbox/tgbot/node_modules/@grammyjs/types/mod.d.ts b/sandbox/tgbot/node_modules/@grammyjs/types/mod.d.ts new file mode 100644 index 0000000..b7624dc --- /dev/null +++ b/sandbox/tgbot/node_modules/@grammyjs/types/mod.d.ts @@ -0,0 +1,13 @@ +export * from "./api.js"; +export * from "./checklist.js"; +export * from "./inline.js"; +export * from "./manage.js"; +export * from "./markup.js"; +export * from "./message.js"; +export * from "./methods.js"; +export * from "./passport.js"; +export * from "./payment.js"; +export * from "./settings.js"; +export * from "./story.js"; +export * from "./update.js"; +export * from "./langs.js"; diff --git a/sandbox/tgbot/node_modules/@grammyjs/types/mod.js b/sandbox/tgbot/node_modules/@grammyjs/types/mod.js new file mode 100644 index 0000000..066125f --- /dev/null +++ b/sandbox/tgbot/node_modules/@grammyjs/types/mod.js @@ -0,0 +1,2 @@ +/* The comment below makes Vite recognize an empty main file as a valid CJS module. */ +// module.exports diff --git a/sandbox/tgbot/node_modules/@grammyjs/types/package.json b/sandbox/tgbot/node_modules/@grammyjs/types/package.json new file mode 100644 index 0000000..f6b7db9 --- /dev/null +++ b/sandbox/tgbot/node_modules/@grammyjs/types/package.json @@ -0,0 +1,34 @@ +{ + "name": "@grammyjs/types", + "version": "3.24.0", + "description": "Telegram Bot API type declarations for grammY", + "main": "mod.js", + "repository": { + "type": "git", + "url": "git+https://github.com/grammyjs/types.git" + }, + "keywords": [ + "grammy", + "telegram", + "bot", + "api", + "types" + ], + "scripts": { + "prepare": "deno task build" + }, + "author": "KnorpelSenf", + "types": "mod.d.ts", + "license": "MIT", + "bugs": { + "url": "https://github.com/grammyjs/types/issues" + }, + "files": [ + "*.d.ts", + "mod.js" + ], + "homepage": "https://grammy.dev/", + "devDependencies": { + "deno-bin": "^1.31.1" + } +} diff --git a/sandbox/tgbot/node_modules/@grammyjs/types/passport.d.ts b/sandbox/tgbot/node_modules/@grammyjs/types/passport.d.ts new file mode 100644 index 0000000..be783f1 --- /dev/null +++ b/sandbox/tgbot/node_modules/@grammyjs/types/passport.d.ts @@ -0,0 +1,163 @@ +/** Describes Telegram Passport data shared with the bot by the user. */ +export interface PassportData { + /** Array with information about documents and other Telegram Passport elements that was shared with the bot */ + data: EncryptedPassportElement[]; + /** Encrypted credentials required to decrypt the data */ + credentials: EncryptedCredentials; +} +/** This object represents a file uploaded to Telegram Passport. Currently all Telegram Passport files are in JPEG format when decrypted and don't exceed 10MB. */ +export interface PassportFile { + /** Identifier for this file, which can be used to download or reuse the file */ + file_id: string; + /** Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file. */ + file_unique_id: string; + /** File size in bytes */ + file_size: number; + /** Unix time when the file was uploaded */ + file_date: number; +} +/** Describes documents or other Telegram Passport elements shared with the bot by the user. */ +export interface EncryptedPassportElement { + /** Element type. One of “personal_details”, “passport”, “driver_license”, “identity_card”, “internal_passport”, “address”, “utility_bill”, “bank_statement”, “rental_agreement”, “passport_registration”, “temporary_registration”, “phone_number”, “email”. */ + type: "personal_details" | "passport" | "driver_license" | "identity_card" | "internal_passport" | "address" | "utility_bill" | "bank_statement" | "rental_agreement" | "passport_registration" | "temporary_registration" | "phone_number" | "email"; + /** Base64-encoded encrypted Telegram Passport element data provided by the user; available only for “personal_details”, “passport”, “driver_license”, “identity_card”, “internal_passport” and “address” types. Can be decrypted and verified using the accompanying EncryptedCredentials. */ + data?: string; + /** User's verified phone number; available only for “phone_number” type */ + phone_number?: string; + /** User's verified email address; available only for “email” type */ + email?: string; + /** Array of encrypted files with documents provided by the user; available only for “utility_bill”, “bank_statement”, “rental_agreement”, “passport_registration” and “temporary_registration” types. Files can be decrypted and verified using the accompanying EncryptedCredentials. */ + files?: PassportFile[]; + /** Encrypted file with the front side of the document, provided by the user; available only for “passport”, “driver_license”, “identity_card” and “internal_passport”. The file can be decrypted and verified using the accompanying EncryptedCredentials. */ + front_side?: PassportFile; + /** Encrypted file with the reverse side of the document, provided by the user; available only for “driver_license” and “identity_card”. The file can be decrypted and verified using the accompanying EncryptedCredentials. */ + reverse_side?: PassportFile; + /** Encrypted file with the selfie of the user holding a document, provided by the user; available if requested for “passport”, “driver_license”, “identity_card” and “internal_passport”. The file can be decrypted and verified using the accompanying EncryptedCredentials. */ + selfie?: PassportFile; + /** Array of encrypted files with translated versions of documents provided by the user; available if requested for “passport”, “driver_license”, “identity_card”, “internal_passport”, “utility_bill”, “bank_statement”, “rental_agreement”, “passport_registration” and “temporary_registration” types. Files can be decrypted and verified using the accompanying EncryptedCredentials. */ + translation?: PassportFile[]; + /** Base64-encoded element hash for using in PassportElementErrorUnspecified */ + hash: string; +} +/** Describes data required for decrypting and authenticating EncryptedPassportElement. See the Telegram Passport Documentation for a complete description of the data decryption and authentication processes. */ +export interface EncryptedCredentials { + /** Base64-encoded encrypted JSON-serialized data with unique user's payload, data hashes and secrets required for EncryptedPassportElement decryption and authentication */ + data: string; + /** Base64-encoded data hash for data authentication */ + hash: string; + /** Base64-encoded secret, encrypted with the bot's public RSA key, required for data decryption */ + secret: string; +} +/** This object represents an error in the Telegram Passport element which was submitted that should be resolved by the user. It should be one of: +- PassportElementErrorDataField +- PassportElementErrorFrontSide +- PassportElementErrorReverseSide +- PassportElementErrorSelfie +- PassportElementErrorFile +- PassportElementErrorFiles +- PassportElementErrorTranslationFile +- PassportElementErrorTranslationFiles +- PassportElementErrorUnspecified +*/ +export type PassportElementError = PassportElementErrorDataField | PassportElementErrorFrontSide | PassportElementErrorReverseSide | PassportElementErrorSelfie | PassportElementErrorFile | PassportElementErrorFiles | PassportElementErrorTranslationFile | PassportElementErrorTranslationFiles | PassportElementErrorUnspecified; +/** Represents an issue in one of the data fields that was provided by the user. The error is considered resolved when the field's value changes. */ +export interface PassportElementErrorDataField { + /** Error source, must be data */ + source: "data"; + /** The section of the user's Telegram Passport which has the error, one of “personal_details”, “passport”, “driver_license”, “identity_card”, “internal_passport”, “address” */ + type: "personal_details" | "passport" | "driver_license" | "identity_card" | "internal_passport" | "address"; + /** Name of the data field which has the error */ + field_name: string; + /** Base64-encoded data hash */ + data_hash: string; + /** Error message */ + message: string; +} +/** Represents an issue with the front side of a document. The error is considered resolved when the file with the front side of the document changes. */ +export interface PassportElementErrorFrontSide { + /** Error source, must be front_side */ + source: "front_side"; + /** The section of the user's Telegram Passport which has the issue, one of “passport”, “driver_license”, “identity_card”, “internal_passport” */ + type: "passport" | "driver_license" | "identity_card" | "internal_passport"; + /** Base64-encoded hash of the file with the front side of the document */ + file_hash: string; + /** Error message */ + message: string; +} +/** Represents an issue with the reverse side of a document. The error is considered resolved when the file with reverse side of the document changes. */ +export interface PassportElementErrorReverseSide { + /** Error source, must be reverse_side */ + source: "reverse_side"; + /** The section of the user's Telegram Passport which has the issue, one of “driver_license”, “identity_card” */ + type: "driver_license" | "identity_card"; + /** Base64-encoded hash of the file with the reverse side of the document */ + file_hash: string; + /** Error message */ + message: string; +} +/** Represents an issue with the selfie with a document. The error is considered resolved when the file with the selfie changes. */ +export interface PassportElementErrorSelfie { + /** Error source, must be selfie */ + source: "selfie"; + /** The section of the user's Telegram Passport which has the issue, one of “passport”, “driver_license”, “identity_card”, “internal_passport” */ + type: "passport" | "driver_license" | "identity_card" | "internal_passport"; + /** Base64-encoded hash of the file with the selfie */ + file_hash: string; + /** Error message */ + message: string; +} +/** Represents an issue with a document scan. The error is considered resolved when the file with the document scan changes. */ +export interface PassportElementErrorFile { + /** Error source, must be file */ + source: "file"; + /** The section of the user's Telegram Passport which has the issue, one of “utility_bill”, “bank_statement”, “rental_agreement”, “passport_registration”, “temporary_registration” */ + type: "utility_bill" | "bank_statement" | "rental_agreement" | "passport_registration" | "temporary_registration"; + /** Base64-encoded file hash */ + file_hash: string; + /** Error message */ + message: string; +} +/** Represents an issue with a list of scans. The error is considered resolved when the list of files containing the scans changes. */ +export interface PassportElementErrorFiles { + /** Error source, must be files */ + source: "files"; + /** The section of the user's Telegram Passport which has the issue, one of “utility_bill”, “bank_statement”, “rental_agreement”, “passport_registration”, “temporary_registration” */ + type: "utility_bill" | "bank_statement" | "rental_agreement" | "passport_registration" | "temporary_registration"; + /** List of base64-encoded file hashes */ + file_hashes: string[]; + /** Error message */ + message: string; +} +/** Represents an issue with one of the files that constitute the translation of a document. The error is considered resolved when the file changes. */ +export interface PassportElementErrorTranslationFile { + /** Error source, must be translation_file */ + source: "translation_file"; + /** Type of element of the user's Telegram Passport which has the issue, one of “passport”, “driver_license”, “identity_card”, “internal_passport”, “utility_bill”, “bank_statement”, “rental_agreement”, “passport_registration”, “temporary_registration” */ + type: "passport" | "driver_license" | "identity_card" | "internal_passport" | "utility_bill" | "bank_statement" | "rental_agreement" | "passport_registration" | "temporary_registration"; + /** Base64-encoded file hash */ + file_hash: string; + /** Error message */ + message: string; +} +/** Represents an issue with the translated version of a document. The error is considered resolved when a file with the document translation change. */ +export interface PassportElementErrorTranslationFiles { + /** Error source, must be translation_files */ + source: "translation_files"; + /** Type of element of the user's Telegram Passport which has the issue, one of “passport”, “driver_license”, “identity_card”, “internal_passport”, “utility_bill”, “bank_statement”, “rental_agreement”, “passport_registration”, “temporary_registration” */ + type: "passport" | "driver_license" | "identity_card" | "internal_passport" | "utility_bill" | "bank_statement" | "rental_agreement" | "passport_registration" | "temporary_registration"; + /** List of base64-encoded file hashes */ + file_hashes: string[]; + /** Error message */ + message: string; +} +/** Represents an issue in an unspecified place. The error is considered resolved when new data is added. */ +export interface PassportElementErrorUnspecified { + /** Error source, must be unspecified */ + source: "unspecified"; + /** Type of element of the user's Telegram Passport which has the issue */ + type: string; + /** Base64-encoded element hash */ + element_hash: string; + /** Error message */ + message: string; +} diff --git a/sandbox/tgbot/node_modules/@grammyjs/types/payment.d.ts b/sandbox/tgbot/node_modules/@grammyjs/types/payment.d.ts new file mode 100644 index 0000000..4e07921 --- /dev/null +++ b/sandbox/tgbot/node_modules/@grammyjs/types/payment.d.ts @@ -0,0 +1,563 @@ +import type { Chat, User } from "./manage.js"; +import type { Message, MessageEntity, PaidMedia, Sticker } from "./message.js"; +/** This object represents a portion of the price for goods or services. */ +export interface LabeledPrice { + /** Portion label */ + label: string; + /** Price of the product in the smallest units of the currency (integer, not float/double). For example, for a price of US$ 1.45 pass amount = 145. See the exp parameter in currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies). */ + amount: number; +} +/** This object contains basic information about an invoice. */ +export interface Invoice { + /** Product name */ + title: string; + /** Product description */ + description: string; + /** Unique bot deep-linking parameter that can be used to generate this invoice */ + start_parameter: string; + /** Three-letter ISO 4217 currency code, or “XTR” for payments in Telegram Stars */ + currency: string; + /** Total price in the smallest units of the currency (integer, not float/double). For example, for a price of US$ 1.45 pass amount = 145. See the exp parameter in currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies). */ + total_amount: number; +} +/** This object represents a shipping address. */ +export interface ShippingAddress { + /** Two-letter ISO 3166-1 alpha-2 country code */ + country_code: string; + /** State, if applicable */ + state: string; + /** City */ + city: string; + /** First line for the address */ + street_line1: string; + /** Second line for the address */ + street_line2: string; + /** Address post code */ + post_code: string; +} +/** This object represents information about an order. */ +export interface OrderInfo { + /** User name */ + name?: string; + /** User's phone number */ + phone_number?: string; + /** User email */ + email?: string; + /** User shipping address */ + shipping_address?: ShippingAddress; +} +/** This object represents one shipping option. */ +export interface ShippingOption { + /** Shipping option identifier */ + id: string; + /** Option title */ + title: string; + /** List of price portions */ + prices: LabeledPrice[]; +} +/** This object contains basic information about a successful payment. Note that if the buyer initiates a chargeback with the relevant payment provider following this transaction, the funds may be debited from your balance. This is outside of Telegram's control. */ +export interface SuccessfulPayment { + /** Three-letter ISO 4217 currency code, or “XTR” for payments in Telegram Stars */ + currency: string; + /** Total price in the smallest units of the currency (integer, not float/double). For example, for a price of US$ 1.45 pass amount = 145. See the exp parameter in currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies). */ + total_amount: number; + /** Bot specified invoice payload */ + invoice_payload: string; + /** Expiration date of the subscription, in Unix time; for recurring payments only */ + subscription_expiration_date?: number; + /** True, if the payment is a recurring payment for a subscription */ + is_recurring?: true; + /** True, if the payment is the first payment for a subscription */ + is_first_recurring?: true; + /** Identifier of the shipping option chosen by the user */ + shipping_option_id?: string; + /** Order information provided by the user */ + order_info?: OrderInfo; + /** Telegram payment identifier */ + telegram_payment_charge_id: string; + /** Provider payment identifier */ + provider_payment_charge_id: string; +} +/** This object contains basic information about a refunded payment. */ +export interface RefundedPayment { + /** Three-letter ISO 4217 currency code, or “XTR” for payments in Telegram Stars. Currently, always “XTR” */ + currency: string; + /** Total refunded price in the smallest units of the currency (integer, not float/double). For example, for a price of US$ 1.45, total_amount = 145. See the exp parameter in currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies). */ + total_amount: number; + /** Bot-specified invoice payload */ + invoice_payload: string; + /** Telegram payment identifier */ + telegram_payment_charge_id: string; + /** Provider payment identifier */ + provider_payment_charge_id?: string; +} +/** This object contains information about an incoming shipping query. */ +export interface ShippingQuery { + /** Unique query identifier */ + id: string; + /** User who sent the query */ + from: User; + /** Bot specified invoice payload */ + invoice_payload: string; + /** User specified shipping address */ + shipping_address: ShippingAddress; +} +/** This object contains information about an incoming pre-checkout query. */ +export interface PreCheckoutQuery { + /** Unique query identifier */ + id: string; + /** User who sent the query */ + from: User; + /** Three-letter ISO 4217 currency code, or “XTR” for payments in Telegram Stars */ + currency: string; + /** Total price in the smallest units of the currency (integer, not float/double). For example, for a price of US$ 1.45 pass amount = 145. See the exp parameter in currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies). */ + total_amount: number; + /** Bot specified invoice payload */ + invoice_payload: string; + /** Identifier of the shipping option chosen by the user */ + shipping_option_id?: string; + /** Order information provided by the user */ + order_info?: OrderInfo; +} +/** This object describes the state of a revenue withdrawal operation. Currently, it can be one of + +- RevenueWithdrawalStatePending +- RevenueWithdrawalStateSucceeded +- RevenueWithdrawalStateFailed */ +export type RevenueWithdrawalState = RevenueWithdrawalStatePending | RevenueWithdrawalStateSucceeded | RevenueWithdrawalStateFailed; +/** The withdrawal is in progress. */ +export interface RevenueWithdrawalStatePending { + /** Type of the state, always “pending” */ + type: "pending"; +} +/** The withdrawal succeeded. */ +export interface RevenueWithdrawalStateSucceeded { + /** Type of the state, always “succeeded” */ + type: "succeeded"; + /** Date the withdrawal was completed in Unix time */ + date: number; + /** An HTTPS URL that can be used to see transaction details */ + url: string; +} +/** The withdrawal failed and the transaction was refunded. */ +export interface RevenueWithdrawalStateFailed { + /** Type of the state, always “failed” */ + type: "failed"; +} +/** Contains information about the affiliate that received a commission via this transaction. */ +export interface AffiliateInfo { + /** The bot or the user that received an affiliate commission if it was received by a bot or a user */ + affiliate_user?: User; + /** The chat that received an affiliate commission if it was received by a chat */ + affiliate_chat?: Chat; + /** The number of Telegram Stars received by the affiliate for each 1000 Telegram Stars received by the bot from referred users */ + commission_per_mille: number; + /** Integer amount of Telegram Stars received by the affiliate from the transaction, rounded to 0; can be negative for refunds */ + amount: number; + /** The number of 1/1000000000 shares of Telegram Stars received by the affiliate; from -999999999 to 999999999; can be negative for refunds */ + nanostar_amount?: number; +} +/** This object describes the source of a transaction, or its recipient for outgoing transactions. Currently, it can be one of + +- TransactionPartnerUser +- TransactionPartnerChat +- TransactionPartnerAffiliateProgram +- TransactionPartnerFragment +- TransactionPartnerTelegramAds +- TransactionPartnerTelegramApi +- TransactionPartnerOther */ +export type TransactionPartner = TransactionPartnerUser | TransactionPartnerChat | TransactionPartnerAffiliateProgram | TransactionPartnerFragment | TransactionPartnerTelegramAds | TransactionPartnerTelegramApi | TransactionPartnerOther; +/** Describes a transaction with a user. */ +export interface TransactionPartnerUser { + /** Type of the transaction partner, always “user” */ + type: "user"; + /** Type of the transaction, currently one of “invoice_payment” for payments via invoices, “paid_media_payment” for payments for paid media, “gift_purchase” for gifts sent by the bot, “premium_purchase” for Telegram Premium subscriptions gifted by the bot, “business_account_transfer” for direct transfers from managed business accounts */ + transaction_type: "invoice_payment" | "paid_media_payment" | "gift_purchase" | "premium_purchase" | "business_account_transfer"; + /** Information about the user */ + user: User; + /** Information about the affiliate that received a commission via this transaction. Can be available only for “invoice_payment” and “paid_media_payment” transactions. */ + affiliate?: AffiliateInfo; + /** Bot-specified invoice payload. Can be available only for “invoice_payment” transactions. */ + invoice_payload?: string; + /** The duration of the paid subscription. Can be available only for “invoice_payment” transactions. */ + subscription_period?: number; + /** Information about the paid media bought by the user; for “paid_media_payment” transactions only */ + paid_media?: PaidMedia[]; + /** Bot-specified paid media payload. Can be available only for “paid_media_payment” transactions. */ + paid_media_payload?: string; + /** The gift sent to the user by the bot; for “gift_purchase” transactions only */ + gift?: Gift; + /** Number of months the gifted Telegram Premium subscription will be active for; for “premium_purchase” transactions only */ + premium_subscription_duration?: number; +} +/** Describes a transaction with a chat. */ +export interface TransactionPartnerChat { + /** Type of the transaction partner, always “chat” */ + type: "chat"; + /** Information about the chat */ + chat: Chat; + /** The gift sent to the chat by the bot */ + gift?: Gift; +} +/** Describes the affiliate program that issued the affiliate commission received via this transaction. */ +export interface TransactionPartnerAffiliateProgram { + /** Type of the transaction partner, always “affiliate_program” */ + type: "affiliate_program"; + /** Information about the bot that sponsored the affiliate program */ + sponsor_user?: User; + /** The number of Telegram Stars received by the bot for each 1000 Telegram Stars received by the affiliate program sponsor from referred users */ + commission_per_mille: number; +} +/** Describes a withdrawal transaction with Fragment. */ +export interface TransactionPartnerFragment { + /** Type of the transaction partner, always “fragment” */ + type: "fragment"; + /** State of the transaction if the transaction is outgoing */ + withdrawal_state?: RevenueWithdrawalState; +} +/** Describes a withdrawal transaction to the Telegram Ads platform. */ +export interface TransactionPartnerTelegramAds { + /** Type of the transaction partner, always “telegram_ads” */ + type: "telegram_ads"; +} +/** Describes a transaction with payment for paid broadcasting. */ +export interface TransactionPartnerTelegramApi { + /** Type of the transaction partner, always “telegram_api” */ + type: "telegram_api"; + /** The number of successful requests that exceeded regular limits and were therefore billed */ + request_count: number; +} +/** Describes a transaction with an unknown source or recipient. */ +export interface TransactionPartnerOther { + /** Type of the transaction partner, always “other” */ + type: "other"; +} +/** Describes a Telegram Star transaction. Note that if the buyer initiates a chargeback with the payment provider from whom they acquired Stars (e.g., Apple, Google) following this transaction, the refunded Stars will be deducted from the bot's balance. This is outside of Telegram's control. */ +export interface StarTransaction { + /** Unique identifier of the transaction. Coincides with the identifier of the original transaction for refund transactions. Coincides with SuccessfulPayment.telegram_payment_charge_id for successful incoming payments from users. */ + id: string; + /** Integer amount of Telegram Stars transferred by the transaction */ + amount: number; + /** The number of 1/1000000000 shares of Telegram Stars transferred by the transaction; from 0 to 999999999 */ + nanostar_amount?: number; + /** Date the transaction was created in Unix time */ + date: number; + /** Source of an incoming transaction (e.g., a user purchasing goods or services, Fragment refunding a failed withdrawal). Only for incoming transactions */ + source?: TransactionPartner; + /** Receiver of an outgoing transaction (e.g., a user for a purchase refund, Fragment for a withdrawal). Only for outgoing transactions */ + receiver?: TransactionPartner; +} +/** Contains a list of Telegram Star transactions. */ +export interface StarTransactions { + /** The list of transactions */ + transactions: StarTransaction[]; +} +/** This object contains information about a paid media purchase. */ +export interface PaidMediaPurchased { + /** User who purchased the media */ + from: User; + /** Bot-specified paid media payload */ + paid_media_payload: string; +} +/** This object describes the background of a gift. */ +export interface GiftBackground { + /** Center color of the background in RGB format */ + center_color: number; + /** Edge color of the background in RGB format */ + edge_color: number; + /** Text color of the background in RGB format */ + text_color: number; +} +/** This object represents a gift that can be sent by the bot. */ +export interface Gift { + /** Unique identifier of the gift */ + id: string; + /** Information about the chat that published the gift */ + publisher_chat?: Chat; + /** The sticker that represents the gift */ + sticker: Sticker; + /** Background of the gift */ + background?: GiftBackground; + /** True, if the gift can only be purchased by Telegram Premium subscribers */ + is_premium?: true; + /** True, if the gift can be used (after being upgraded) to customize a user's appearance */ + has_colors?: true; + /** The number of Telegram Stars that must be paid to send the sticker */ + star_count: number; + /** The number of Telegram Stars that must be paid to upgrade the gift to a unique one */ + upgrade_star_count?: number; + /** The total number of different unique gifts that can be obtained by upgrading the gift */ + unique_gift_variant_count?: number; + /** The total number of gifts of this type that can be sent by all users; for limited gifts only */ + total_count?: number; + /** The number of remaining gifts of this type that can be sent by all users; for limited gifts only */ + remaining_count?: number; + /** The total number of gifts of this type that can be sent by the bot; for limited gifts only */ + personal_total_count?: number; + /** The number of remaining gifts of this type that can be sent by the bot; for limited gifts only */ + personal_remaining_count?: number; +} +/** This object represent a list of gifts. */ +export interface Gifts { + /** The list of gifts */ + gifts: Gift[]; +} +/** This object describes the model of a unique gift. */ +export interface UniqueGiftModel { + /** Name of the model */ + name: string; + /** The sticker that represents the unique gift */ + sticker: Sticker; + /** The number of unique gifts that receive this model for every 1000 gift upgrades. Always 0 for crafted gifts. */ + rarity_per_mille: number; + /** Rarity of the model if it is a crafted model. Currently, can be “uncommon”, “rare”, “epic”, or “legendary”. */ + rarity?: "uncommon" | "rare" | "epic" | "legendary"; +} +/** This object describes the symbol shown on the pattern of a unique gift. */ +export interface UniqueGiftSymbol { + /** Name of the symbol */ + name: string; + /** The sticker that represents the unique gift */ + sticker: Sticker; + /** The number of unique gifts that receive this model for every 1000 gifts upgraded */ + rarity_per_mille: number; +} +/** This object describes the colors of the backdrop of a unique gift. */ +export interface UniqueGiftBackdropColors { + /** The color in the center of the backdrop in RGB format */ + center_color: number; + /** The color on the edges of the backdrop in RGB format */ + edge_color: number; + /** The color to be applied to the symbol in RGB format */ + symbol_color: number; + /** The color for the text on the backdrop in RGB format */ + text_color: number; +} +/** This object describes the backdrop of a unique gift. */ +export interface UniqueGiftBackdrop { + /** Name of the backdrop */ + name: string; + /** Colors of the backdrop */ + colors: UniqueGiftBackdropColors; + /** The number of unique gifts that receive this backdrop for every 1000 gifts upgraded */ + rarity_per_mille: number; +} +/** This object describes a unique gift that was upgraded from a regular gift. */ +export interface UniqueGift { + /** Identifier of the regular gift from which the gift was upgraded */ + gift_id: string; + /** Human-readable name of the regular gift from which this unique gift was upgraded */ + base_name: string; + /** Unique name of the gift. This name can be used in https://t.me/nft/... links and story areas */ + name: string; + /** Information about the chat that published the gift */ + publisher_chat?: Chat; + /** True, if the original regular gift was exclusively purchaseable by Telegram Premium subscribers */ + is_premium?: true; + /** True, if the gift is assigned from the TON blockchain and can't be resold or transferred in Telegram */ + is_from_blockchain?: true; + /** Unique number of the upgraded gift among gifts upgraded from the same regular gift */ + number: number; + /** Model of the gift */ + model: UniqueGiftModel; + /** Symbol of the gift */ + symbol: UniqueGiftSymbol; + /** Backdrop of the gift */ + backdrop: UniqueGiftBackdrop; + /** The color scheme that can be used by the gift's owner for the chat's name, replies to messages and link previews */ + colors?: UniqueGiftColors; + /** True, if the gift was used to craft another gift and isn't available anymore */ + is_burned?: true; +} +/** This object contains information about the color scheme for a user's name, message replies and link previews based on a unique gift. */ +export interface UniqueGiftColors { + /** Custom emoji identifier of the unique gift's model */ + model_custom_emoji_id: string; + /** Custom emoji identifier of the unique gift's symbol */ + symbol_custom_emoji_id: string; + /** Main color used in light themes; RGB format */ + light_theme_main_color: number; + /** List of 1-3 additional colors used in light themes; RGB format */ + light_theme_other_colors: number[]; + /** Main color used in dark themes; RGB format */ + dark_theme_main_color: number; + /** List of 1-3 additional colors used in dark themes; RGB format */ + dark_theme_other_colors: number[]; +} +/** Describes a service message about a regular gift that was sent or received. */ +export interface GiftInfo { + /** Information about the gift */ + gift: Gift; + /** Unique identifier of the received gift for the bot; only present for gifts received on behalf of business accounts */ + owned_gift_id?: string; + /** Number of Telegram Stars that can be claimed by the receiver by converting the gift; omitted if conversion to Telegram Stars is impossible */ + convert_star_count?: number; + /** Number of Telegram Stars that were prepaid by the sender for the ability to upgrade the gift */ + prepaid_upgrade_star_count?: number; + /** True, if the gift can be upgraded to a unique gift */ + can_be_upgraded?: true; + /** True, if the gift's upgrade was purchased after the gift was sent */ + is_upgrade_separate?: true; + /** Unique number reserved for this gift when upgraded. See the number field in UniqueGift */ + unique_gift_number?: number; + /** Text of the message that was added to the gift */ + text?: string; + /** Special entities that appear in the text */ + entities?: MessageEntity[]; + /** True, if the sender and gift text are shown only to the gift receiver; otherwise, everyone will be able to see them */ + is_private?: true; +} +/** Describes a service message about a unique gift that was sent or received. */ +export interface UniqueGiftInfo { + /** Information about the gift */ + gift: UniqueGift; + /** Origin of the gift. Currently, either “upgrade” for gifts upgraded from regular gifts, “transfer” for gifts transferred from other users or channels, “resale” for gifts bought from other users, “gifted_upgrade” for upgrades purchased after the gift was sent, or “offer” for gifts bought or sold through gift purchase offers */ + origin: "upgrade" | "transfer" | "resale" | "gifted_upgrade" | "offer"; + /** Unique identifier of the received gift for the bot; only present for gifts received on behalf of business accounts */ + owned_gift_id?: string; + /** Number of Telegram Stars that must be paid to transfer the gift; omitted if the bot cannot transfer the gift */ + transfer_star_count?: number; + /** For gifts bought from other users, the currency in which the payment for the gift was done. Currently, one of “XTR” for Telegram Stars or “TON” for toncoins. */ + last_resale_currency?: "XTR" | "TON"; + /** For gifts bought from other users, the price paid for the gift in either Telegram Stars or nanotoncoins */ + last_resale_amount?: number; + /** Point in time (Unix timestamp) when the gift can be transferred. If it is in the past, then the gift can be transferred now */ + next_transfer_date?: number; +} +/** Describes a service message about a change in the price of paid messages within a chat. */ +export interface PaidMessagePriceChanged { + /** The new number of Telegram Stars that must be paid by non-administrator users of the supergroup chat for each sent message */ + paid_message_star_count: number; +} +/** Describes an amount of Telegram Stars. */ +export interface StarAmount { + /** Integer amount of Telegram Stars, rounded to 0; can be negative */ + amount: number; + /** The number of 1/1000000000 shares of Telegram Stars; from -999999999 to 999999999; can be negative if and only if amount is non-positive */ + nanostar_amount?: number; +} +/** This object describes a gift received and owned by a user or a chat. Currently, it can be one of + +- OwnedGiftRegular +- OwnedGiftUnique */ +export type OwnedGift = OwnedGiftRegular | OwnedGiftUnique; +/** Describes a regular gift owned by a user or a chat. */ +export interface OwnedGiftRegular { + /** Type of the gift, always “regular” */ + type: "regular"; + /** Information about the regular gift */ + gift: Gift; + /** Unique identifier of the gift for the bot; for gifts received on behalf of business accounts only */ + owned_gift_id?: string; + /** Sender of the gift if it is a known user */ + sender_user?: User; + /** Date the gift was sent in Unix time */ + send_date: number; + /** Unique number reserved for this gift when upgraded. See the number field in UniqueGift */ + unique_gift_number?: number; + /** Text of the message that was added to the gift */ + text?: string; + /** Special entities that appear in the text */ + entities?: MessageEntity[]; + /** True, if the sender and gift text are shown only to the gift receiver; otherwise, everyone will be able to see them */ + is_private?: true; + /** True, if the gift is displayed on the account's profile page; for gifts received on behalf of business accounts only */ + is_saved?: true; + /** True, if the gift can be upgraded to a unique gift; for gifts received on behalf of business accounts only */ + can_be_upgraded?: true; + /** True, if the gift's upgrade was purchased after the gift was sent */ + is_upgrade_separate?: true; + /** True, if the gift was refunded and isn't available anymore */ + was_refunded?: true; + /** Number of Telegram Stars that can be claimed by the receiver instead of the gift; omitted if the gift cannot be converted to Telegram Stars */ + convert_star_count?: number; + /** Number of Telegram Stars that were paid by the sender for the ability to upgrade the gift */ + prepaid_upgrade_star_count?: number; +} +/** Describes a unique gift received and owned by a user or a chat. */ +export interface OwnedGiftUnique { + /** Type of the gift, always “unique” */ + type: "unique"; + /** Information about the unique gift */ + gift: UniqueGift; + /** Unique identifier of the received gift for the bot; for gifts received on behalf of business accounts only */ + owned_gift_id?: string; + /** Sender of the gift if it is a known user */ + sender_user?: User; + /** Date the gift was sent in Unix time */ + send_date: number; + /** True, if the gift is displayed on the account's profile page; for gifts received on behalf of business accounts only */ + is_saved?: true; + /** True, if the gift can be transferred to another owner; for gifts received on behalf of business accounts only */ + can_be_transferred?: true; + /** Number of Telegram Stars that must be paid to transfer the gift; omitted if the bot cannot transfer the gift */ + transfer_star_count?: number; + /** Point in time (Unix timestamp) when the gift can be transferred. If it is in the past, then the gift can be transferred now */ + next_transfer_date?: number; +} +/** Contains the list of gifts received and owned by a user or a chat. */ +export interface OwnedGifts { + /** The total number of gifts owned by the user or the chat */ + total_count: number; + /** The list of gifts */ + gifts: OwnedGift[]; + /** Offset for the next request. If empty, then there are no more results */ + next_offset?: string; +} +/** Describes the price of a suggested post. */ +export interface SuggestedPostPrice { + /** Currency in which the post will be paid. Currently, must be one of “XTR” for Telegram Stars or “TON” for toncoins */ + currency: "XTR" | "TON"; + /** The amount of the currency that will be paid for the post in the smallest units of the currency, i.e. Telegram Stars or nanotoncoins. Currently, price in Telegram Stars must be between 5 and 100000, and price in nanotoncoins must be between 10000000 and 10000000000000. */ + amount: number; +} +/** Contains information about a suggested post. */ +export interface SuggestedPostInfo { + /** State of the suggested post. Currently, it can be one of “pending”, “approved”, “declined”. */ + state: "pending" | "approved" | "declined"; + /** Proposed price of the post. If the field is omitted, then the post is unpaid. */ + price?: SuggestedPostPrice; + /** Proposed send date of the post. If the field is omitted, then the post can be published at any time within 30 days at the sole discretion of the user or administrator who approves it. */ + send_date?: number; +} +/** Describes a service message about the approval of a suggested post. */ +export interface SuggestedPostApproved { + /** Message containing the suggested post. Note that the Message object in this field will not contain the reply_to_message field even if it itself is a reply. */ + suggested_post_message?: Message; + /** Amount paid for the post */ + price?: SuggestedPostPrice; + /** Date when the post will be published */ + send_date: number; +} +/** Describes a service message about the failed approval of a suggested post. Currently, only caused by insufficient user funds at the time of approval. */ +export interface SuggestedPostApprovalFailed { + /** Message containing the suggested post whose approval has failed. Note that the Message object in this field will not contain the reply_to_message field even if it itself is a reply. */ + suggested_post_message?: Message; + /** Expected price of the post */ + price: SuggestedPostPrice; +} +/** Describes a service message about the rejection of a suggested post. */ +export interface SuggestedPostDeclined { + /** Message containing the suggested post. Note that the Message object in this field will not contain the reply_to_message field even if it itself is a reply. */ + suggested_post_message?: Message; + /** Comment with which the post was declined */ + comment?: string; +} +/** Describes a service message about a successful payment for a suggested post. */ +export interface SuggestedPostPaid { + /** Message containing the suggested post. Note that the Message object in this field will not contain the reply_to_message field even if it itself is a reply. */ + suggested_post_message?: Message; + /** Currency in which the payment was made. Currently, one of “XTR” for Telegram Stars or “TON” for toncoins */ + currency: string; + /** The amount of the currency that was received by the channel in nanotoncoins; for payments in toncoins only */ + amount?: number; + /** The amount of Telegram Stars that was received by the channel; for payments in Telegram Stars only */ + star_amount?: StarAmount; +} +/** Describes a service message about a payment refund for a suggested post. */ +export interface SuggestedPostRefunded { + /** Message containing the suggested post. Note that the Message object in this field will not contain the reply_to_message field even if it itself is a reply. */ + suggested_post_message?: Message; + /** Reason for the refund. Currently, one of “post_deleted” if the post was deleted within 24 hours of being posted or removed from scheduled messages without being posted, or “payment_refunded” if the payer refunded their payment. */ + reason: string; +} diff --git a/sandbox/tgbot/node_modules/@grammyjs/types/settings.d.ts b/sandbox/tgbot/node_modules/@grammyjs/types/settings.d.ts new file mode 100644 index 0000000..fab6b83 --- /dev/null +++ b/sandbox/tgbot/node_modules/@grammyjs/types/settings.d.ts @@ -0,0 +1,120 @@ +import type { WebAppInfo } from "./markup.js"; +/** This object represents the bot's name. */ +export interface BotName { + /** The bot's name */ + name: string; +} +/** This object represents the bot's description. */ +export interface BotDescription { + /** The bot's description */ + description: string; +} +/** This object represents the bot's short description. */ +export interface BotShortDescription { + /** The bot's short description */ + short_description: string; +} +/** This object describes the bot's menu button in a private chat. It should be one of +- MenuButtonCommands +- MenuButtonWebApp +- MenuButtonDefault + +If a menu button other than MenuButtonDefault is set for a private chat, then it is applied in the chat. Otherwise the default menu button is applied. By default, the menu button opens the list of bot commands. */ +export type MenuButton = MenuButtonCommands | MenuButtonWebApp | MenuButtonDefault; +/** Represents a menu button, which opens the bot's list of commands. */ +export interface MenuButtonCommands { + /** Type of the button, must be commands */ + type: "commands"; +} +/** Represents a menu button, which launches a Web App. */ +export interface MenuButtonWebApp { + /** Button type, must be web_app */ + type: "web_app"; + /** Text on the button */ + text: string; + /** Description of the Web App that will be launched when the user presses the button. The Web App will be able to send an arbitrary message on behalf of the user using the method answerWebAppQuery. Alternatively, a t.me link to a Web App can be specified in the object instead of the Web App's URL, in which case the Web App will be opened as if the user pressed the link. */ + web_app: WebAppInfo; +} +/** Describes that no specific value for the menu button was set. */ +export interface MenuButtonDefault { + /** Type of the button, must be default */ + type: "default"; +} +/** This object represents the scope to which bot commands are applied. Currently, the following 7 scopes are supported: +- BotCommandScopeDefault +- BotCommandScopeAllPrivateChats +- BotCommandScopeAllGroupChats +- BotCommandScopeAllChatAdministrators +- BotCommandScopeChat +- BotCommandScopeChatAdministrators +- BotCommandScopeChatMember + +## Determining list of commands + +The following algorithm is used to determine the list of commands for a particular user viewing the bot menu. The first list of commands which is set is returned: + +### Commands in the chat with the bot +- botCommandScopeChat + language_code +- botCommandScopeChat +- botCommandScopeAllPrivateChats + language_code +- botCommandScopeAllPrivateChats +- botCommandScopeDefault + language_code +- botCommandScopeDefault + +### Commands in group and supergroup chats +- botCommandScopeChatMember + language_code +- botCommandScopeChatMember +- botCommandScopeChatAdministrators + language_code (administrators only) +- botCommandScopeChatAdministrators (administrators only) +- botCommandScopeChat + language_code +- botCommandScopeChat +- botCommandScopeAllChatAdministrators + language_code (administrators only) +- botCommandScopeAllChatAdministrators (administrators only) +- botCommandScopeAllGroupChats + language_code +- botCommandScopeAllGroupChats +- botCommandScopeDefault + language_code +- botCommandScopeDefault */ +export type BotCommandScope = BotCommandScopeDefault | BotCommandScopeAllPrivateChats | BotCommandScopeAllGroupChats | BotCommandScopeAllChatAdministrators | BotCommandScopeChat | BotCommandScopeChatAdministrators | BotCommandScopeChatMember; +/** Represents the default scope of bot commands. Default commands are used if no commands with a narrower scope are specified for the user. */ +export interface BotCommandScopeDefault { + /** Scope type, must be default */ + type: "default"; +} +/** Represents the scope of bot commands, covering all private chats. */ +export interface BotCommandScopeAllPrivateChats { + /** Scope type, must be all_private_chats */ + type: "all_private_chats"; +} +/** Represents the scope of bot commands, covering all group and supergroup chats. */ +export interface BotCommandScopeAllGroupChats { + /** Scope type, must be all_group_chats */ + type: "all_group_chats"; +} +/** Represents the scope of bot commands, covering all group and supergroup chat administrators. */ +export interface BotCommandScopeAllChatAdministrators { + /** Scope type, must be all_chat_administrators */ + type: "all_chat_administrators"; +} +/** Represents the scope of bot commands, covering a specific chat. */ +export interface BotCommandScopeChat { + /** Scope type, must be chat */ + type: "chat"; + /** Unique identifier for the target chat or username of the target supergroup (in the format `@supergroupusername`). Channel direct messages chats and channel chats aren't supported. */ + chat_id: number | string; +} +/** Represents the scope of bot commands, covering all administrators of a specific group or supergroup chat. */ +export interface BotCommandScopeChatAdministrators { + /** Scope type, must be chat_administrators */ + type: "chat_administrators"; + /** Unique identifier for the target chat or username of the target supergroup (in the format `@supergroupusername`). Channel direct messages chats and channel chats aren't supported. */ + chat_id: number | string; +} +/** Represents the scope of bot commands, covering a specific member of a group or supergroup chat. */ +export interface BotCommandScopeChatMember { + /** Scope type, must be chat_member */ + type: "chat_member"; + /** Unique identifier for the target chat or username of the target supergroup (in the format `@supergroupusername`). Channel direct messages chats and channel chats aren't supported. */ + chat_id: number | string; + /** Unique identifier of the target user */ + user_id: number; +} diff --git a/sandbox/tgbot/node_modules/@grammyjs/types/story.d.ts b/sandbox/tgbot/node_modules/@grammyjs/types/story.d.ts new file mode 100644 index 0000000..16f7502 --- /dev/null +++ b/sandbox/tgbot/node_modules/@grammyjs/types/story.d.ts @@ -0,0 +1,89 @@ +import type { ReactionType } from "./message.js"; +/** Describes the position of a clickable area within a story. */ +export interface StoryAreaPosition { + /** The abscissa of the area's center, as a percentage of the media width */ + x_percentage: number; + /** The ordinate of the area's center, as a percentage of the media height */ + y_percentage: number; + /** The width of the area's rectangle, as a percentage of the media width */ + width_percentage: number; + /** The height of the area's rectangle, as a percentage of the media height */ + height_percentage: number; + /** The clockwise rotation angle of the rectangle, in degrees; 0-360 */ + rotation_angle: number; + /** The radius of the rectangle corner rounding, as a percentage of the media width */ + corner_radius_percentage: number; +} +/** Describes the physical address of a location. */ +export interface LocationAddress { + /** The two-letter ISO 3166-1 alpha-2 country code of the country where the location is located */ + country_code: string; + /** State of the location */ + state?: string; + /** City of the location */ + city?: string; + /** Street address of the location */ + street?: string; +} +/** Describes the type of a clickable area on a story. Currently, it can be one of + +- StoryAreaTypeLocation +- StoryAreaTypeSuggestedReaction +- StoryAreaTypeLink +- StoryAreaTypeWeather +- StoryAreaTypeUniqueGift */ +export type StoryAreaType = StoryAreaTypeLocation | StoryAreaTypeSuggestedReaction | StoryAreaTypeLink | StoryAreaTypeWeather | StoryAreaTypeUniqueGift; +/** Describes a story area pointing to a location. Currently, a story can have up to 10 location areas. */ +export interface StoryAreaTypeLocation { + /** Type of the area, always “location” */ + type: "location"; + /** Location latitude in degrees */ + latitude: number; + /** Location longitude in degrees */ + longitude: number; + /** Address of the location */ + address?: LocationAddress; +} +/** Describes a story area pointing to a suggested reaction. Currently, a story can have up to 5 suggested reaction areas. */ +export interface StoryAreaTypeSuggestedReaction { + /** Type of the area, always “suggested_reaction” */ + type: "suggested_reaction"; + /** Type of the reaction */ + reaction_type: ReactionType; + /** Pass True if the reaction area has a dark background */ + is_dark?: boolean; + /** Pass True if reaction area corner is flipped */ + is_flipped?: boolean; +} +/** Describes a story area pointing to an HTTP or tg:// link. Currently, a story can have up to 3 link areas. */ +export interface StoryAreaTypeLink { + /** Type of the area, always “link” */ + type: "link"; + /** HTTP or tg:// URL to be opened when the area is clicked */ + url: string; +} +/** Describes a story area containing weather information. Currently, a story can have up to 3 weather areas. */ +export interface StoryAreaTypeWeather { + /** Type of the area, always “weather” */ + type: "weather"; + /** Temperature, in degree Celsius */ + temperature: number; + /** Emoji representing the weather */ + emoji: string; + /** A color of the area background in the ARGB format */ + background_color: number; +} +/** Describes a story area pointing to a unique gift. Currently, a story can have at most 1 unique gift area. */ +export interface StoryAreaTypeUniqueGift { + /** Type of the area, always “unique_gift” */ + type: "unique_gift"; + /** Unique name of the gift */ + name: string; +} +/** Describes a clickable area on a story media. */ +export interface StoryArea { + /** Position of the area */ + position: StoryAreaPosition; + /** Type of the area */ + type: StoryAreaType; +} diff --git a/sandbox/tgbot/node_modules/@grammyjs/types/update.d.ts b/sandbox/tgbot/node_modules/@grammyjs/types/update.d.ts new file mode 100644 index 0000000..2412948 --- /dev/null +++ b/sandbox/tgbot/node_modules/@grammyjs/types/update.d.ts @@ -0,0 +1,78 @@ +import type { ChosenInlineResult, InlineQuery } from "./inline.js"; +import type { BusinessConnection, BusinessMessagesDeleted, Chat, ChatBoostRemoved, ChatBoostUpdated, ChatJoinRequest, ChatMemberUpdated, User } from "./manage.js"; +import type { CallbackQuery } from "./markup.js"; +import type { Message, MessageReactionCountUpdated, MessageReactionUpdated, Poll, PollAnswer } from "./message.js"; +import type { PaidMediaPurchased, PreCheckoutQuery, ShippingQuery } from "./payment.js"; +/** Internal namespace used to make some message types more accurate */ +export declare namespace Update { + /** Internal type holding properties that message updates in private chats share. */ + interface Private { + chat: Chat.PrivateChat; + } + /** Internal type holding properties that message updates in channels share. */ + interface Channel { + chat: Chat.ChannelChat; + } + /** Internal type holding properties that message updates outside of channels share. */ + interface NonChannel { + chat: Exclude; + from: User; + } + /** Internal type holding properties that updates about edited messages share. */ + interface Edited { + /** Date the message was last edited in Unix time */ + edit_date: number; + } +} +/** This object represents an incoming update. +At most one of the optional parameters can be present in any given update. */ +export interface Update { + /** The update's unique identifier. Update identifiers start from a certain positive number and increase sequentially. This identifier becomes especially handy if you're using webhooks, since it allows you to ignore repeated updates or to restore the correct update sequence, should they get out of order. If there are no new updates for at least a week, then identifier of the next update will be chosen randomly instead of sequentially. */ + update_id: number; + /** New incoming message of any kind - text, photo, sticker, etc. */ + message?: Message & Update.NonChannel; + /** New version of a message that is known to the bot and was edited. This update may at times be triggered by changes to message fields that are either unavailable or not actively used by your bot. */ + edited_message?: Message & Update.Edited & Update.NonChannel; + /** New incoming channel post of any kind - text, photo, sticker, etc. */ + channel_post?: Message & Update.Channel; + /** New version of a channel post that is known to the bot and was edited. This update may at times be triggered by changes to message fields that are either unavailable or not actively used by your bot. */ + edited_channel_post?: Message & Update.Edited & Update.Channel; + /** The bot was connected to or disconnected from a business account, or a user edited an existing connection with the bot */ + business_connection?: BusinessConnection; + /** New message from a connected business account */ + business_message?: Message & Update.Private; + /** New version of a message from a connected business account */ + edited_business_message?: Message & Update.Edited & Update.Private; + /** Messages were deleted from a connected business account */ + deleted_business_messages?: BusinessMessagesDeleted; + /** A reaction to a message was changed by a user. The bot must be an administrator in the chat and must explicitly specify "message_reaction" in the list of allowed_updates to receive these updates. The update isn't received for reactions set by bots. */ + message_reaction?: MessageReactionUpdated; + /** Reactions to a message with anonymous reactions were changed. The bot must be an administrator in the chat and must explicitly specify "message_reaction_count" in the list of allowed_updates to receive these updates. The updates are grouped and can be sent with delay up to a few minutes. */ + message_reaction_count?: MessageReactionCountUpdated; + /** New incoming inline query */ + inline_query?: InlineQuery; + /** The result of an inline query that was chosen by a user and sent to their chat partner. Please see our documentation on the feedback collecting for details on how to enable these updates for your bot. */ + chosen_inline_result?: ChosenInlineResult; + /** New incoming callback query */ + callback_query?: CallbackQuery; + /** New incoming shipping query. Only for invoices with flexible price */ + shipping_query?: ShippingQuery; + /** New incoming pre-checkout query. Contains full information about checkout */ + pre_checkout_query?: PreCheckoutQuery; + /** New poll state. Bots receive only updates about manually stopped polls and polls, which are sent by the bot */ + poll?: Poll; + /** A user changed their answer in a non-anonymous poll. Bots receive new votes only in polls that were sent by the bot itself. */ + poll_answer?: PollAnswer; + /** The bot's chat member status was updated in a chat. For private chats, this update is received only when the bot is blocked or unblocked by the user. */ + my_chat_member?: ChatMemberUpdated; + /** A chat member's status was updated in a chat. The bot must be an administrator in the chat and must explicitly specify “chat_member” in the list of allowed_updates to receive these updates. */ + chat_member?: ChatMemberUpdated; + /** A request to join the chat has been sent. The bot must have the can_invite_users administrator right in the chat to receive these updates. */ + chat_join_request?: ChatJoinRequest; + /** A chat boost was added or changed. The bot must be an administrator in the chat to receive these updates. */ + chat_boost?: ChatBoostUpdated; + /** A boost was removed from a chat. The bot must be an administrator in the chat to receive these updates. */ + removed_chat_boost?: ChatBoostRemoved; + /** A user purchased paid media with a non-empty payload sent by the bot in a non-channel chat */ + purchased_paid_media?: PaidMediaPurchased; +} diff --git a/sandbox/tgbot/node_modules/abort-controller/LICENSE b/sandbox/tgbot/node_modules/abort-controller/LICENSE new file mode 100644 index 0000000..c914149 --- /dev/null +++ b/sandbox/tgbot/node_modules/abort-controller/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2017 Toru Nagashima + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/sandbox/tgbot/node_modules/abort-controller/README.md b/sandbox/tgbot/node_modules/abort-controller/README.md new file mode 100644 index 0000000..9de3e45 --- /dev/null +++ b/sandbox/tgbot/node_modules/abort-controller/README.md @@ -0,0 +1,98 @@ +# abort-controller + +[![npm version](https://img.shields.io/npm/v/abort-controller.svg)](https://www.npmjs.com/package/abort-controller) +[![Downloads/month](https://img.shields.io/npm/dm/abort-controller.svg)](http://www.npmtrends.com/abort-controller) +[![Build Status](https://travis-ci.org/mysticatea/abort-controller.svg?branch=master)](https://travis-ci.org/mysticatea/abort-controller) +[![Coverage Status](https://codecov.io/gh/mysticatea/abort-controller/branch/master/graph/badge.svg)](https://codecov.io/gh/mysticatea/abort-controller) +[![Dependency Status](https://david-dm.org/mysticatea/abort-controller.svg)](https://david-dm.org/mysticatea/abort-controller) + +An implementation of [WHATWG AbortController interface](https://dom.spec.whatwg.org/#interface-abortcontroller). + +```js +import AbortController from "abort-controller" + +const controller = new AbortController() +const signal = controller.signal + +signal.addEventListener("abort", () => { + console.log("aborted!") +}) + +controller.abort() +``` + +> https://jsfiddle.net/1r2994qp/1/ + +## 💿 Installation + +Use [npm](https://www.npmjs.com/) to install then use a bundler. + +``` +npm install abort-controller +``` + +Or download from [`dist` directory](./dist). + +- [dist/abort-controller.mjs](dist/abort-controller.mjs) ... ES modules version. +- [dist/abort-controller.js](dist/abort-controller.js) ... Common JS version. +- [dist/abort-controller.umd.js](dist/abort-controller.umd.js) ... UMD (Universal Module Definition) version. This is transpiled by [Babel](https://babeljs.io/) for IE 11. + +## 📖 Usage + +### Basic + +```js +import AbortController from "abort-controller" +// or +const AbortController = require("abort-controller") + +// or UMD version defines a global variable: +const AbortController = window.AbortControllerShim +``` + +If your bundler recognizes `browser` field of `package.json`, the imported `AbortController` is the native one and it doesn't contain shim (even if the native implementation was nothing). +If you wanted to polyfill `AbortController` for IE, use `abort-controller/polyfill`. + +### Polyfilling + +Importing `abort-controller/polyfill` assigns the `AbortController` shim to the `AbortController` global variable if the native implementation was nothing. + +```js +import "abort-controller/polyfill" +// or +require("abort-controller/polyfill") +``` + +### API + +#### AbortController + +> https://dom.spec.whatwg.org/#interface-abortcontroller + +##### controller.signal + +The [AbortSignal](https://dom.spec.whatwg.org/#interface-AbortSignal) object which is associated to this controller. + +##### controller.abort() + +Notify `abort` event to listeners that the `signal` has. + +## 📰 Changelog + +- See [GitHub releases](https://github.com/mysticatea/abort-controller/releases). + +## 🍻 Contributing + +Contributing is welcome ❤️ + +Please use GitHub issues/PRs. + +### Development tools + +- `npm install` installs dependencies for development. +- `npm test` runs tests and measures code coverage. +- `npm run clean` removes temporary files of tests. +- `npm run coverage` opens code coverage of the previous test with your default browser. +- `npm run lint` runs ESLint. +- `npm run build` generates `dist` codes. +- `npm run watch` runs tests on each file change. diff --git a/sandbox/tgbot/node_modules/abort-controller/browser.js b/sandbox/tgbot/node_modules/abort-controller/browser.js new file mode 100644 index 0000000..b0c5ec3 --- /dev/null +++ b/sandbox/tgbot/node_modules/abort-controller/browser.js @@ -0,0 +1,13 @@ +/*globals self, window */ +"use strict" + +/*eslint-disable @mysticatea/prettier */ +const { AbortController, AbortSignal } = + typeof self !== "undefined" ? self : + typeof window !== "undefined" ? window : + /* otherwise */ undefined +/*eslint-enable @mysticatea/prettier */ + +module.exports = AbortController +module.exports.AbortSignal = AbortSignal +module.exports.default = AbortController diff --git a/sandbox/tgbot/node_modules/abort-controller/browser.mjs b/sandbox/tgbot/node_modules/abort-controller/browser.mjs new file mode 100644 index 0000000..a8f321a --- /dev/null +++ b/sandbox/tgbot/node_modules/abort-controller/browser.mjs @@ -0,0 +1,11 @@ +/*globals self, window */ + +/*eslint-disable @mysticatea/prettier */ +const { AbortController, AbortSignal } = + typeof self !== "undefined" ? self : + typeof window !== "undefined" ? window : + /* otherwise */ undefined +/*eslint-enable @mysticatea/prettier */ + +export default AbortController +export { AbortController, AbortSignal } diff --git a/sandbox/tgbot/node_modules/abort-controller/dist/abort-controller.d.ts b/sandbox/tgbot/node_modules/abort-controller/dist/abort-controller.d.ts new file mode 100644 index 0000000..75852fb --- /dev/null +++ b/sandbox/tgbot/node_modules/abort-controller/dist/abort-controller.d.ts @@ -0,0 +1,43 @@ +import { EventTarget } from "event-target-shim" + +type Events = { + abort: any +} +type EventAttributes = { + onabort: any +} +/** + * The signal class. + * @see https://dom.spec.whatwg.org/#abortsignal + */ +declare class AbortSignal extends EventTarget { + /** + * AbortSignal cannot be constructed directly. + */ + constructor() + /** + * Returns `true` if this `AbortSignal`"s `AbortController` has signaled to abort, and `false` otherwise. + */ + readonly aborted: boolean +} +/** + * The AbortController. + * @see https://dom.spec.whatwg.org/#abortcontroller + */ +declare class AbortController { + /** + * Initialize this controller. + */ + constructor() + /** + * Returns the `AbortSignal` object associated with this object. + */ + readonly signal: AbortSignal + /** + * Abort and signal to any observers that the associated activity is to be aborted. + */ + abort(): void +} + +export default AbortController +export { AbortController, AbortSignal } diff --git a/sandbox/tgbot/node_modules/abort-controller/dist/abort-controller.js b/sandbox/tgbot/node_modules/abort-controller/dist/abort-controller.js new file mode 100644 index 0000000..49af739 --- /dev/null +++ b/sandbox/tgbot/node_modules/abort-controller/dist/abort-controller.js @@ -0,0 +1,127 @@ +/** + * @author Toru Nagashima + * See LICENSE file in root directory for full license. + */ +'use strict'; + +Object.defineProperty(exports, '__esModule', { value: true }); + +var eventTargetShim = require('event-target-shim'); + +/** + * The signal class. + * @see https://dom.spec.whatwg.org/#abortsignal + */ +class AbortSignal extends eventTargetShim.EventTarget { + /** + * AbortSignal cannot be constructed directly. + */ + constructor() { + super(); + throw new TypeError("AbortSignal cannot be constructed directly"); + } + /** + * Returns `true` if this `AbortSignal`'s `AbortController` has signaled to abort, and `false` otherwise. + */ + get aborted() { + const aborted = abortedFlags.get(this); + if (typeof aborted !== "boolean") { + throw new TypeError(`Expected 'this' to be an 'AbortSignal' object, but got ${this === null ? "null" : typeof this}`); + } + return aborted; + } +} +eventTargetShim.defineEventAttribute(AbortSignal.prototype, "abort"); +/** + * Create an AbortSignal object. + */ +function createAbortSignal() { + const signal = Object.create(AbortSignal.prototype); + eventTargetShim.EventTarget.call(signal); + abortedFlags.set(signal, false); + return signal; +} +/** + * Abort a given signal. + */ +function abortSignal(signal) { + if (abortedFlags.get(signal) !== false) { + return; + } + abortedFlags.set(signal, true); + signal.dispatchEvent({ type: "abort" }); +} +/** + * Aborted flag for each instances. + */ +const abortedFlags = new WeakMap(); +// Properties should be enumerable. +Object.defineProperties(AbortSignal.prototype, { + aborted: { enumerable: true }, +}); +// `toString()` should return `"[object AbortSignal]"` +if (typeof Symbol === "function" && typeof Symbol.toStringTag === "symbol") { + Object.defineProperty(AbortSignal.prototype, Symbol.toStringTag, { + configurable: true, + value: "AbortSignal", + }); +} + +/** + * The AbortController. + * @see https://dom.spec.whatwg.org/#abortcontroller + */ +class AbortController { + /** + * Initialize this controller. + */ + constructor() { + signals.set(this, createAbortSignal()); + } + /** + * Returns the `AbortSignal` object associated with this object. + */ + get signal() { + return getSignal(this); + } + /** + * Abort and signal to any observers that the associated activity is to be aborted. + */ + abort() { + abortSignal(getSignal(this)); + } +} +/** + * Associated signals. + */ +const signals = new WeakMap(); +/** + * Get the associated signal of a given controller. + */ +function getSignal(controller) { + const signal = signals.get(controller); + if (signal == null) { + throw new TypeError(`Expected 'this' to be an 'AbortController' object, but got ${controller === null ? "null" : typeof controller}`); + } + return signal; +} +// Properties should be enumerable. +Object.defineProperties(AbortController.prototype, { + signal: { enumerable: true }, + abort: { enumerable: true }, +}); +if (typeof Symbol === "function" && typeof Symbol.toStringTag === "symbol") { + Object.defineProperty(AbortController.prototype, Symbol.toStringTag, { + configurable: true, + value: "AbortController", + }); +} + +exports.AbortController = AbortController; +exports.AbortSignal = AbortSignal; +exports.default = AbortController; + +module.exports = AbortController +module.exports.AbortController = module.exports["default"] = AbortController +module.exports.AbortSignal = AbortSignal +//# sourceMappingURL=abort-controller.js.map diff --git a/sandbox/tgbot/node_modules/abort-controller/dist/abort-controller.js.map b/sandbox/tgbot/node_modules/abort-controller/dist/abort-controller.js.map new file mode 100644 index 0000000..cfdcafd --- /dev/null +++ b/sandbox/tgbot/node_modules/abort-controller/dist/abort-controller.js.map @@ -0,0 +1 @@ +{"version":3,"file":"abort-controller.js","sources":["../src/abort-signal.ts","../src/abort-controller.ts"],"sourcesContent":["import {\n // Event,\n EventTarget,\n // Type,\n defineEventAttribute,\n} from \"event-target-shim\"\n\n// Known Limitation\n// Use `any` because the type of `AbortSignal` in `lib.dom.d.ts` is wrong and\n// to make assignable our `AbortSignal` into that.\n// https://github.com/Microsoft/TSJS-lib-generator/pull/623\ntype Events = {\n abort: any // Event & Type<\"abort\">\n}\ntype EventAttributes = {\n onabort: any // Event & Type<\"abort\">\n}\n\n/**\n * The signal class.\n * @see https://dom.spec.whatwg.org/#abortsignal\n */\nexport default class AbortSignal extends EventTarget {\n /**\n * AbortSignal cannot be constructed directly.\n */\n public constructor() {\n super()\n throw new TypeError(\"AbortSignal cannot be constructed directly\")\n }\n\n /**\n * Returns `true` if this `AbortSignal`'s `AbortController` has signaled to abort, and `false` otherwise.\n */\n public get aborted(): boolean {\n const aborted = abortedFlags.get(this)\n if (typeof aborted !== \"boolean\") {\n throw new TypeError(\n `Expected 'this' to be an 'AbortSignal' object, but got ${\n this === null ? \"null\" : typeof this\n }`,\n )\n }\n return aborted\n }\n}\ndefineEventAttribute(AbortSignal.prototype, \"abort\")\n\n/**\n * Create an AbortSignal object.\n */\nexport function createAbortSignal(): AbortSignal {\n const signal = Object.create(AbortSignal.prototype)\n EventTarget.call(signal)\n abortedFlags.set(signal, false)\n return signal\n}\n\n/**\n * Abort a given signal.\n */\nexport function abortSignal(signal: AbortSignal): void {\n if (abortedFlags.get(signal) !== false) {\n return\n }\n\n abortedFlags.set(signal, true)\n signal.dispatchEvent<\"abort\">({ type: \"abort\" })\n}\n\n/**\n * Aborted flag for each instances.\n */\nconst abortedFlags = new WeakMap()\n\n// Properties should be enumerable.\nObject.defineProperties(AbortSignal.prototype, {\n aborted: { enumerable: true },\n})\n\n// `toString()` should return `\"[object AbortSignal]\"`\nif (typeof Symbol === \"function\" && typeof Symbol.toStringTag === \"symbol\") {\n Object.defineProperty(AbortSignal.prototype, Symbol.toStringTag, {\n configurable: true,\n value: \"AbortSignal\",\n })\n}\n","import AbortSignal, { abortSignal, createAbortSignal } from \"./abort-signal\"\n\n/**\n * The AbortController.\n * @see https://dom.spec.whatwg.org/#abortcontroller\n */\nexport default class AbortController {\n /**\n * Initialize this controller.\n */\n public constructor() {\n signals.set(this, createAbortSignal())\n }\n\n /**\n * Returns the `AbortSignal` object associated with this object.\n */\n public get signal(): AbortSignal {\n return getSignal(this)\n }\n\n /**\n * Abort and signal to any observers that the associated activity is to be aborted.\n */\n public abort(): void {\n abortSignal(getSignal(this))\n }\n}\n\n/**\n * Associated signals.\n */\nconst signals = new WeakMap()\n\n/**\n * Get the associated signal of a given controller.\n */\nfunction getSignal(controller: AbortController): AbortSignal {\n const signal = signals.get(controller)\n if (signal == null) {\n throw new TypeError(\n `Expected 'this' to be an 'AbortController' object, but got ${\n controller === null ? \"null\" : typeof controller\n }`,\n )\n }\n return signal\n}\n\n// Properties should be enumerable.\nObject.defineProperties(AbortController.prototype, {\n signal: { enumerable: true },\n abort: { enumerable: true },\n})\n\nif (typeof Symbol === \"function\" && typeof Symbol.toStringTag === \"symbol\") {\n Object.defineProperty(AbortController.prototype, Symbol.toStringTag, {\n configurable: true,\n value: \"AbortController\",\n })\n}\n\nexport { AbortController, AbortSignal }\n"],"names":["EventTarget","defineEventAttribute"],"mappings":";;;;;;;;;;AAkBA;;;;AAIA,MAAqB,WAAY,SAAQA,2BAAoC;;;;IAIzE;QACI,KAAK,EAAE,CAAA;QACP,MAAM,IAAI,SAAS,CAAC,4CAA4C,CAAC,CAAA;KACpE;;;;IAKD,IAAW,OAAO;QACd,MAAM,OAAO,GAAG,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;QACtC,IAAI,OAAO,OAAO,KAAK,SAAS,EAAE;YAC9B,MAAM,IAAI,SAAS,CACf,0DACI,IAAI,KAAK,IAAI,GAAG,MAAM,GAAG,OAAO,IACpC,EAAE,CACL,CAAA;SACJ;QACD,OAAO,OAAO,CAAA;KACjB;CACJ;AACDC,oCAAoB,CAAC,WAAW,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;;;;AAKpD,SAAgB,iBAAiB;IAC7B,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,CAAA;IACnDD,2BAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IACxB,YAAY,CAAC,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;IAC/B,OAAO,MAAM,CAAA;CAChB;;;;AAKD,SAAgB,WAAW,CAAC,MAAmB;IAC3C,IAAI,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,KAAK,EAAE;QACpC,OAAM;KACT;IAED,YAAY,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;IAC9B,MAAM,CAAC,aAAa,CAAU,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAA;CACnD;;;;AAKD,MAAM,YAAY,GAAG,IAAI,OAAO,EAAwB,CAAA;;AAGxD,MAAM,CAAC,gBAAgB,CAAC,WAAW,CAAC,SAAS,EAAE;IAC3C,OAAO,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;CAChC,CAAC,CAAA;;AAGF,IAAI,OAAO,MAAM,KAAK,UAAU,IAAI,OAAO,MAAM,CAAC,WAAW,KAAK,QAAQ,EAAE;IACxE,MAAM,CAAC,cAAc,CAAC,WAAW,CAAC,SAAS,EAAE,MAAM,CAAC,WAAW,EAAE;QAC7D,YAAY,EAAE,IAAI;QAClB,KAAK,EAAE,aAAa;KACvB,CAAC,CAAA;CACL;;ACpFD;;;;AAIA,MAAqB,eAAe;;;;IAIhC;QACI,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,iBAAiB,EAAE,CAAC,CAAA;KACzC;;;;IAKD,IAAW,MAAM;QACb,OAAO,SAAS,CAAC,IAAI,CAAC,CAAA;KACzB;;;;IAKM,KAAK;QACR,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAA;KAC/B;CACJ;;;;AAKD,MAAM,OAAO,GAAG,IAAI,OAAO,EAAgC,CAAA;;;;AAK3D,SAAS,SAAS,CAAC,UAA2B;IAC1C,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAA;IACtC,IAAI,MAAM,IAAI,IAAI,EAAE;QAChB,MAAM,IAAI,SAAS,CACf,8DACI,UAAU,KAAK,IAAI,GAAG,MAAM,GAAG,OAAO,UAC1C,EAAE,CACL,CAAA;KACJ;IACD,OAAO,MAAM,CAAA;CAChB;;AAGD,MAAM,CAAC,gBAAgB,CAAC,eAAe,CAAC,SAAS,EAAE;IAC/C,MAAM,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;IAC5B,KAAK,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;CAC9B,CAAC,CAAA;AAEF,IAAI,OAAO,MAAM,KAAK,UAAU,IAAI,OAAO,MAAM,CAAC,WAAW,KAAK,QAAQ,EAAE;IACxE,MAAM,CAAC,cAAc,CAAC,eAAe,CAAC,SAAS,EAAE,MAAM,CAAC,WAAW,EAAE;QACjE,YAAY,EAAE,IAAI;QAClB,KAAK,EAAE,iBAAiB;KAC3B,CAAC,CAAA;CACL;;;;;;;;;;;;;"} \ No newline at end of file diff --git a/sandbox/tgbot/node_modules/abort-controller/dist/abort-controller.mjs b/sandbox/tgbot/node_modules/abort-controller/dist/abort-controller.mjs new file mode 100644 index 0000000..88ba22d --- /dev/null +++ b/sandbox/tgbot/node_modules/abort-controller/dist/abort-controller.mjs @@ -0,0 +1,118 @@ +/** + * @author Toru Nagashima + * See LICENSE file in root directory for full license. + */ +import { EventTarget, defineEventAttribute } from 'event-target-shim'; + +/** + * The signal class. + * @see https://dom.spec.whatwg.org/#abortsignal + */ +class AbortSignal extends EventTarget { + /** + * AbortSignal cannot be constructed directly. + */ + constructor() { + super(); + throw new TypeError("AbortSignal cannot be constructed directly"); + } + /** + * Returns `true` if this `AbortSignal`'s `AbortController` has signaled to abort, and `false` otherwise. + */ + get aborted() { + const aborted = abortedFlags.get(this); + if (typeof aborted !== "boolean") { + throw new TypeError(`Expected 'this' to be an 'AbortSignal' object, but got ${this === null ? "null" : typeof this}`); + } + return aborted; + } +} +defineEventAttribute(AbortSignal.prototype, "abort"); +/** + * Create an AbortSignal object. + */ +function createAbortSignal() { + const signal = Object.create(AbortSignal.prototype); + EventTarget.call(signal); + abortedFlags.set(signal, false); + return signal; +} +/** + * Abort a given signal. + */ +function abortSignal(signal) { + if (abortedFlags.get(signal) !== false) { + return; + } + abortedFlags.set(signal, true); + signal.dispatchEvent({ type: "abort" }); +} +/** + * Aborted flag for each instances. + */ +const abortedFlags = new WeakMap(); +// Properties should be enumerable. +Object.defineProperties(AbortSignal.prototype, { + aborted: { enumerable: true }, +}); +// `toString()` should return `"[object AbortSignal]"` +if (typeof Symbol === "function" && typeof Symbol.toStringTag === "symbol") { + Object.defineProperty(AbortSignal.prototype, Symbol.toStringTag, { + configurable: true, + value: "AbortSignal", + }); +} + +/** + * The AbortController. + * @see https://dom.spec.whatwg.org/#abortcontroller + */ +class AbortController { + /** + * Initialize this controller. + */ + constructor() { + signals.set(this, createAbortSignal()); + } + /** + * Returns the `AbortSignal` object associated with this object. + */ + get signal() { + return getSignal(this); + } + /** + * Abort and signal to any observers that the associated activity is to be aborted. + */ + abort() { + abortSignal(getSignal(this)); + } +} +/** + * Associated signals. + */ +const signals = new WeakMap(); +/** + * Get the associated signal of a given controller. + */ +function getSignal(controller) { + const signal = signals.get(controller); + if (signal == null) { + throw new TypeError(`Expected 'this' to be an 'AbortController' object, but got ${controller === null ? "null" : typeof controller}`); + } + return signal; +} +// Properties should be enumerable. +Object.defineProperties(AbortController.prototype, { + signal: { enumerable: true }, + abort: { enumerable: true }, +}); +if (typeof Symbol === "function" && typeof Symbol.toStringTag === "symbol") { + Object.defineProperty(AbortController.prototype, Symbol.toStringTag, { + configurable: true, + value: "AbortController", + }); +} + +export default AbortController; +export { AbortController, AbortSignal }; +//# sourceMappingURL=abort-controller.mjs.map diff --git a/sandbox/tgbot/node_modules/abort-controller/dist/abort-controller.mjs.map b/sandbox/tgbot/node_modules/abort-controller/dist/abort-controller.mjs.map new file mode 100644 index 0000000..1e8fa6b --- /dev/null +++ b/sandbox/tgbot/node_modules/abort-controller/dist/abort-controller.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"abort-controller.mjs","sources":["../src/abort-signal.ts","../src/abort-controller.ts"],"sourcesContent":["import {\n // Event,\n EventTarget,\n // Type,\n defineEventAttribute,\n} from \"event-target-shim\"\n\n// Known Limitation\n// Use `any` because the type of `AbortSignal` in `lib.dom.d.ts` is wrong and\n// to make assignable our `AbortSignal` into that.\n// https://github.com/Microsoft/TSJS-lib-generator/pull/623\ntype Events = {\n abort: any // Event & Type<\"abort\">\n}\ntype EventAttributes = {\n onabort: any // Event & Type<\"abort\">\n}\n\n/**\n * The signal class.\n * @see https://dom.spec.whatwg.org/#abortsignal\n */\nexport default class AbortSignal extends EventTarget {\n /**\n * AbortSignal cannot be constructed directly.\n */\n public constructor() {\n super()\n throw new TypeError(\"AbortSignal cannot be constructed directly\")\n }\n\n /**\n * Returns `true` if this `AbortSignal`'s `AbortController` has signaled to abort, and `false` otherwise.\n */\n public get aborted(): boolean {\n const aborted = abortedFlags.get(this)\n if (typeof aborted !== \"boolean\") {\n throw new TypeError(\n `Expected 'this' to be an 'AbortSignal' object, but got ${\n this === null ? \"null\" : typeof this\n }`,\n )\n }\n return aborted\n }\n}\ndefineEventAttribute(AbortSignal.prototype, \"abort\")\n\n/**\n * Create an AbortSignal object.\n */\nexport function createAbortSignal(): AbortSignal {\n const signal = Object.create(AbortSignal.prototype)\n EventTarget.call(signal)\n abortedFlags.set(signal, false)\n return signal\n}\n\n/**\n * Abort a given signal.\n */\nexport function abortSignal(signal: AbortSignal): void {\n if (abortedFlags.get(signal) !== false) {\n return\n }\n\n abortedFlags.set(signal, true)\n signal.dispatchEvent<\"abort\">({ type: \"abort\" })\n}\n\n/**\n * Aborted flag for each instances.\n */\nconst abortedFlags = new WeakMap()\n\n// Properties should be enumerable.\nObject.defineProperties(AbortSignal.prototype, {\n aborted: { enumerable: true },\n})\n\n// `toString()` should return `\"[object AbortSignal]\"`\nif (typeof Symbol === \"function\" && typeof Symbol.toStringTag === \"symbol\") {\n Object.defineProperty(AbortSignal.prototype, Symbol.toStringTag, {\n configurable: true,\n value: \"AbortSignal\",\n })\n}\n","import AbortSignal, { abortSignal, createAbortSignal } from \"./abort-signal\"\n\n/**\n * The AbortController.\n * @see https://dom.spec.whatwg.org/#abortcontroller\n */\nexport default class AbortController {\n /**\n * Initialize this controller.\n */\n public constructor() {\n signals.set(this, createAbortSignal())\n }\n\n /**\n * Returns the `AbortSignal` object associated with this object.\n */\n public get signal(): AbortSignal {\n return getSignal(this)\n }\n\n /**\n * Abort and signal to any observers that the associated activity is to be aborted.\n */\n public abort(): void {\n abortSignal(getSignal(this))\n }\n}\n\n/**\n * Associated signals.\n */\nconst signals = new WeakMap()\n\n/**\n * Get the associated signal of a given controller.\n */\nfunction getSignal(controller: AbortController): AbortSignal {\n const signal = signals.get(controller)\n if (signal == null) {\n throw new TypeError(\n `Expected 'this' to be an 'AbortController' object, but got ${\n controller === null ? \"null\" : typeof controller\n }`,\n )\n }\n return signal\n}\n\n// Properties should be enumerable.\nObject.defineProperties(AbortController.prototype, {\n signal: { enumerable: true },\n abort: { enumerable: true },\n})\n\nif (typeof Symbol === \"function\" && typeof Symbol.toStringTag === \"symbol\") {\n Object.defineProperty(AbortController.prototype, Symbol.toStringTag, {\n configurable: true,\n value: \"AbortController\",\n })\n}\n\nexport { AbortController, AbortSignal }\n"],"names":[],"mappings":";;;;;;AAkBA;;;;AAIA,MAAqB,WAAY,SAAQ,WAAoC;;;;IAIzE;QACI,KAAK,EAAE,CAAA;QACP,MAAM,IAAI,SAAS,CAAC,4CAA4C,CAAC,CAAA;KACpE;;;;IAKD,IAAW,OAAO;QACd,MAAM,OAAO,GAAG,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;QACtC,IAAI,OAAO,OAAO,KAAK,SAAS,EAAE;YAC9B,MAAM,IAAI,SAAS,CACf,0DACI,IAAI,KAAK,IAAI,GAAG,MAAM,GAAG,OAAO,IACpC,EAAE,CACL,CAAA;SACJ;QACD,OAAO,OAAO,CAAA;KACjB;CACJ;AACD,oBAAoB,CAAC,WAAW,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;;;;AAKpD,SAAgB,iBAAiB;IAC7B,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,CAAA;IACnD,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IACxB,YAAY,CAAC,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;IAC/B,OAAO,MAAM,CAAA;CAChB;;;;AAKD,SAAgB,WAAW,CAAC,MAAmB;IAC3C,IAAI,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,KAAK,EAAE;QACpC,OAAM;KACT;IAED,YAAY,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;IAC9B,MAAM,CAAC,aAAa,CAAU,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAA;CACnD;;;;AAKD,MAAM,YAAY,GAAG,IAAI,OAAO,EAAwB,CAAA;;AAGxD,MAAM,CAAC,gBAAgB,CAAC,WAAW,CAAC,SAAS,EAAE;IAC3C,OAAO,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;CAChC,CAAC,CAAA;;AAGF,IAAI,OAAO,MAAM,KAAK,UAAU,IAAI,OAAO,MAAM,CAAC,WAAW,KAAK,QAAQ,EAAE;IACxE,MAAM,CAAC,cAAc,CAAC,WAAW,CAAC,SAAS,EAAE,MAAM,CAAC,WAAW,EAAE;QAC7D,YAAY,EAAE,IAAI;QAClB,KAAK,EAAE,aAAa;KACvB,CAAC,CAAA;CACL;;ACpFD;;;;AAIA,MAAqB,eAAe;;;;IAIhC;QACI,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,iBAAiB,EAAE,CAAC,CAAA;KACzC;;;;IAKD,IAAW,MAAM;QACb,OAAO,SAAS,CAAC,IAAI,CAAC,CAAA;KACzB;;;;IAKM,KAAK;QACR,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAA;KAC/B;CACJ;;;;AAKD,MAAM,OAAO,GAAG,IAAI,OAAO,EAAgC,CAAA;;;;AAK3D,SAAS,SAAS,CAAC,UAA2B;IAC1C,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAA;IACtC,IAAI,MAAM,IAAI,IAAI,EAAE;QAChB,MAAM,IAAI,SAAS,CACf,8DACI,UAAU,KAAK,IAAI,GAAG,MAAM,GAAG,OAAO,UAC1C,EAAE,CACL,CAAA;KACJ;IACD,OAAO,MAAM,CAAA;CAChB;;AAGD,MAAM,CAAC,gBAAgB,CAAC,eAAe,CAAC,SAAS,EAAE;IAC/C,MAAM,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;IAC5B,KAAK,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;CAC9B,CAAC,CAAA;AAEF,IAAI,OAAO,MAAM,KAAK,UAAU,IAAI,OAAO,MAAM,CAAC,WAAW,KAAK,QAAQ,EAAE;IACxE,MAAM,CAAC,cAAc,CAAC,eAAe,CAAC,SAAS,EAAE,MAAM,CAAC,WAAW,EAAE;QACjE,YAAY,EAAE,IAAI;QAClB,KAAK,EAAE,iBAAiB;KAC3B,CAAC,CAAA;CACL;;;;;"} \ No newline at end of file diff --git a/sandbox/tgbot/node_modules/abort-controller/dist/abort-controller.umd.js b/sandbox/tgbot/node_modules/abort-controller/dist/abort-controller.umd.js new file mode 100644 index 0000000..f643cfd --- /dev/null +++ b/sandbox/tgbot/node_modules/abort-controller/dist/abort-controller.umd.js @@ -0,0 +1,5 @@ +/** + * @author Toru Nagashima + * See LICENSE file in root directory for full license. + */(function(a,b){"object"==typeof exports&&"undefined"!=typeof module?b(exports):"function"==typeof define&&define.amd?define(["exports"],b):(a=a||self,b(a.AbortControllerShim={}))})(this,function(a){'use strict';function b(a){return b="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},b(a)}function c(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function d(a,b){for(var c,d=0;d\n * @copyright 2015 Toru Nagashima. All rights reserved.\n * See LICENSE file in root directory for full license.\n */\n/**\n * @typedef {object} PrivateData\n * @property {EventTarget} eventTarget The event target.\n * @property {{type:string}} event The original event object.\n * @property {number} eventPhase The current event phase.\n * @property {EventTarget|null} currentTarget The current event target.\n * @property {boolean} canceled The flag to prevent default.\n * @property {boolean} stopped The flag to stop propagation.\n * @property {boolean} immediateStopped The flag to stop propagation immediately.\n * @property {Function|null} passiveListener The listener if the current listener is passive. Otherwise this is null.\n * @property {number} timeStamp The unix time.\n * @private\n */\n\n/**\n * Private data for event wrappers.\n * @type {WeakMap}\n * @private\n */\nconst privateData = new WeakMap();\n\n/**\n * Cache for wrapper classes.\n * @type {WeakMap}\n * @private\n */\nconst wrappers = new WeakMap();\n\n/**\n * Get private data.\n * @param {Event} event The event object to get private data.\n * @returns {PrivateData} The private data of the event.\n * @private\n */\nfunction pd(event) {\n const retv = privateData.get(event);\n console.assert(\n retv != null,\n \"'this' is expected an Event object, but got\",\n event\n );\n return retv\n}\n\n/**\n * https://dom.spec.whatwg.org/#set-the-canceled-flag\n * @param data {PrivateData} private data.\n */\nfunction setCancelFlag(data) {\n if (data.passiveListener != null) {\n if (\n typeof console !== \"undefined\" &&\n typeof console.error === \"function\"\n ) {\n console.error(\n \"Unable to preventDefault inside passive event listener invocation.\",\n data.passiveListener\n );\n }\n return\n }\n if (!data.event.cancelable) {\n return\n }\n\n data.canceled = true;\n if (typeof data.event.preventDefault === \"function\") {\n data.event.preventDefault();\n }\n}\n\n/**\n * @see https://dom.spec.whatwg.org/#interface-event\n * @private\n */\n/**\n * The event wrapper.\n * @constructor\n * @param {EventTarget} eventTarget The event target of this dispatching.\n * @param {Event|{type:string}} event The original event to wrap.\n */\nfunction Event(eventTarget, event) {\n privateData.set(this, {\n eventTarget,\n event,\n eventPhase: 2,\n currentTarget: eventTarget,\n canceled: false,\n stopped: false,\n immediateStopped: false,\n passiveListener: null,\n timeStamp: event.timeStamp || Date.now(),\n });\n\n // https://heycam.github.io/webidl/#Unforgeable\n Object.defineProperty(this, \"isTrusted\", { value: false, enumerable: true });\n\n // Define accessors\n const keys = Object.keys(event);\n for (let i = 0; i < keys.length; ++i) {\n const key = keys[i];\n if (!(key in this)) {\n Object.defineProperty(this, key, defineRedirectDescriptor(key));\n }\n }\n}\n\n// Should be enumerable, but class methods are not enumerable.\nEvent.prototype = {\n /**\n * The type of this event.\n * @type {string}\n */\n get type() {\n return pd(this).event.type\n },\n\n /**\n * The target of this event.\n * @type {EventTarget}\n */\n get target() {\n return pd(this).eventTarget\n },\n\n /**\n * The target of this event.\n * @type {EventTarget}\n */\n get currentTarget() {\n return pd(this).currentTarget\n },\n\n /**\n * @returns {EventTarget[]} The composed path of this event.\n */\n composedPath() {\n const currentTarget = pd(this).currentTarget;\n if (currentTarget == null) {\n return []\n }\n return [currentTarget]\n },\n\n /**\n * Constant of NONE.\n * @type {number}\n */\n get NONE() {\n return 0\n },\n\n /**\n * Constant of CAPTURING_PHASE.\n * @type {number}\n */\n get CAPTURING_PHASE() {\n return 1\n },\n\n /**\n * Constant of AT_TARGET.\n * @type {number}\n */\n get AT_TARGET() {\n return 2\n },\n\n /**\n * Constant of BUBBLING_PHASE.\n * @type {number}\n */\n get BUBBLING_PHASE() {\n return 3\n },\n\n /**\n * The target of this event.\n * @type {number}\n */\n get eventPhase() {\n return pd(this).eventPhase\n },\n\n /**\n * Stop event bubbling.\n * @returns {void}\n */\n stopPropagation() {\n const data = pd(this);\n\n data.stopped = true;\n if (typeof data.event.stopPropagation === \"function\") {\n data.event.stopPropagation();\n }\n },\n\n /**\n * Stop event bubbling.\n * @returns {void}\n */\n stopImmediatePropagation() {\n const data = pd(this);\n\n data.stopped = true;\n data.immediateStopped = true;\n if (typeof data.event.stopImmediatePropagation === \"function\") {\n data.event.stopImmediatePropagation();\n }\n },\n\n /**\n * The flag to be bubbling.\n * @type {boolean}\n */\n get bubbles() {\n return Boolean(pd(this).event.bubbles)\n },\n\n /**\n * The flag to be cancelable.\n * @type {boolean}\n */\n get cancelable() {\n return Boolean(pd(this).event.cancelable)\n },\n\n /**\n * Cancel this event.\n * @returns {void}\n */\n preventDefault() {\n setCancelFlag(pd(this));\n },\n\n /**\n * The flag to indicate cancellation state.\n * @type {boolean}\n */\n get defaultPrevented() {\n return pd(this).canceled\n },\n\n /**\n * The flag to be composed.\n * @type {boolean}\n */\n get composed() {\n return Boolean(pd(this).event.composed)\n },\n\n /**\n * The unix time of this event.\n * @type {number}\n */\n get timeStamp() {\n return pd(this).timeStamp\n },\n\n /**\n * The target of this event.\n * @type {EventTarget}\n * @deprecated\n */\n get srcElement() {\n return pd(this).eventTarget\n },\n\n /**\n * The flag to stop event bubbling.\n * @type {boolean}\n * @deprecated\n */\n get cancelBubble() {\n return pd(this).stopped\n },\n set cancelBubble(value) {\n if (!value) {\n return\n }\n const data = pd(this);\n\n data.stopped = true;\n if (typeof data.event.cancelBubble === \"boolean\") {\n data.event.cancelBubble = true;\n }\n },\n\n /**\n * The flag to indicate cancellation state.\n * @type {boolean}\n * @deprecated\n */\n get returnValue() {\n return !pd(this).canceled\n },\n set returnValue(value) {\n if (!value) {\n setCancelFlag(pd(this));\n }\n },\n\n /**\n * Initialize this event object. But do nothing under event dispatching.\n * @param {string} type The event type.\n * @param {boolean} [bubbles=false] The flag to be possible to bubble up.\n * @param {boolean} [cancelable=false] The flag to be possible to cancel.\n * @deprecated\n */\n initEvent() {\n // Do nothing.\n },\n};\n\n// `constructor` is not enumerable.\nObject.defineProperty(Event.prototype, \"constructor\", {\n value: Event,\n configurable: true,\n writable: true,\n});\n\n// Ensure `event instanceof window.Event` is `true`.\nif (typeof window !== \"undefined\" && typeof window.Event !== \"undefined\") {\n Object.setPrototypeOf(Event.prototype, window.Event.prototype);\n\n // Make association for wrappers.\n wrappers.set(window.Event.prototype, Event);\n}\n\n/**\n * Get the property descriptor to redirect a given property.\n * @param {string} key Property name to define property descriptor.\n * @returns {PropertyDescriptor} The property descriptor to redirect the property.\n * @private\n */\nfunction defineRedirectDescriptor(key) {\n return {\n get() {\n return pd(this).event[key]\n },\n set(value) {\n pd(this).event[key] = value;\n },\n configurable: true,\n enumerable: true,\n }\n}\n\n/**\n * Get the property descriptor to call a given method property.\n * @param {string} key Property name to define property descriptor.\n * @returns {PropertyDescriptor} The property descriptor to call the method property.\n * @private\n */\nfunction defineCallDescriptor(key) {\n return {\n value() {\n const event = pd(this).event;\n return event[key].apply(event, arguments)\n },\n configurable: true,\n enumerable: true,\n }\n}\n\n/**\n * Define new wrapper class.\n * @param {Function} BaseEvent The base wrapper class.\n * @param {Object} proto The prototype of the original event.\n * @returns {Function} The defined wrapper class.\n * @private\n */\nfunction defineWrapper(BaseEvent, proto) {\n const keys = Object.keys(proto);\n if (keys.length === 0) {\n return BaseEvent\n }\n\n /** CustomEvent */\n function CustomEvent(eventTarget, event) {\n BaseEvent.call(this, eventTarget, event);\n }\n\n CustomEvent.prototype = Object.create(BaseEvent.prototype, {\n constructor: { value: CustomEvent, configurable: true, writable: true },\n });\n\n // Define accessors.\n for (let i = 0; i < keys.length; ++i) {\n const key = keys[i];\n if (!(key in BaseEvent.prototype)) {\n const descriptor = Object.getOwnPropertyDescriptor(proto, key);\n const isFunc = typeof descriptor.value === \"function\";\n Object.defineProperty(\n CustomEvent.prototype,\n key,\n isFunc\n ? defineCallDescriptor(key)\n : defineRedirectDescriptor(key)\n );\n }\n }\n\n return CustomEvent\n}\n\n/**\n * Get the wrapper class of a given prototype.\n * @param {Object} proto The prototype of the original event to get its wrapper.\n * @returns {Function} The wrapper class.\n * @private\n */\nfunction getWrapper(proto) {\n if (proto == null || proto === Object.prototype) {\n return Event\n }\n\n let wrapper = wrappers.get(proto);\n if (wrapper == null) {\n wrapper = defineWrapper(getWrapper(Object.getPrototypeOf(proto)), proto);\n wrappers.set(proto, wrapper);\n }\n return wrapper\n}\n\n/**\n * Wrap a given event to management a dispatching.\n * @param {EventTarget} eventTarget The event target of this dispatching.\n * @param {Object} event The event to wrap.\n * @returns {Event} The wrapper instance.\n * @private\n */\nfunction wrapEvent(eventTarget, event) {\n const Wrapper = getWrapper(Object.getPrototypeOf(event));\n return new Wrapper(eventTarget, event)\n}\n\n/**\n * Get the immediateStopped flag of a given event.\n * @param {Event} event The event to get.\n * @returns {boolean} The flag to stop propagation immediately.\n * @private\n */\nfunction isStopped(event) {\n return pd(event).immediateStopped\n}\n\n/**\n * Set the current event phase of a given event.\n * @param {Event} event The event to set current target.\n * @param {number} eventPhase New event phase.\n * @returns {void}\n * @private\n */\nfunction setEventPhase(event, eventPhase) {\n pd(event).eventPhase = eventPhase;\n}\n\n/**\n * Set the current target of a given event.\n * @param {Event} event The event to set current target.\n * @param {EventTarget|null} currentTarget New current target.\n * @returns {void}\n * @private\n */\nfunction setCurrentTarget(event, currentTarget) {\n pd(event).currentTarget = currentTarget;\n}\n\n/**\n * Set a passive listener of a given event.\n * @param {Event} event The event to set current target.\n * @param {Function|null} passiveListener New passive listener.\n * @returns {void}\n * @private\n */\nfunction setPassiveListener(event, passiveListener) {\n pd(event).passiveListener = passiveListener;\n}\n\n/**\n * @typedef {object} ListenerNode\n * @property {Function} listener\n * @property {1|2|3} listenerType\n * @property {boolean} passive\n * @property {boolean} once\n * @property {ListenerNode|null} next\n * @private\n */\n\n/**\n * @type {WeakMap>}\n * @private\n */\nconst listenersMap = new WeakMap();\n\n// Listener types\nconst CAPTURE = 1;\nconst BUBBLE = 2;\nconst ATTRIBUTE = 3;\n\n/**\n * Check whether a given value is an object or not.\n * @param {any} x The value to check.\n * @returns {boolean} `true` if the value is an object.\n */\nfunction isObject(x) {\n return x !== null && typeof x === \"object\" //eslint-disable-line no-restricted-syntax\n}\n\n/**\n * Get listeners.\n * @param {EventTarget} eventTarget The event target to get.\n * @returns {Map} The listeners.\n * @private\n */\nfunction getListeners(eventTarget) {\n const listeners = listenersMap.get(eventTarget);\n if (listeners == null) {\n throw new TypeError(\n \"'this' is expected an EventTarget object, but got another value.\"\n )\n }\n return listeners\n}\n\n/**\n * Get the property descriptor for the event attribute of a given event.\n * @param {string} eventName The event name to get property descriptor.\n * @returns {PropertyDescriptor} The property descriptor.\n * @private\n */\nfunction defineEventAttributeDescriptor(eventName) {\n return {\n get() {\n const listeners = getListeners(this);\n let node = listeners.get(eventName);\n while (node != null) {\n if (node.listenerType === ATTRIBUTE) {\n return node.listener\n }\n node = node.next;\n }\n return null\n },\n\n set(listener) {\n if (typeof listener !== \"function\" && !isObject(listener)) {\n listener = null; // eslint-disable-line no-param-reassign\n }\n const listeners = getListeners(this);\n\n // Traverse to the tail while removing old value.\n let prev = null;\n let node = listeners.get(eventName);\n while (node != null) {\n if (node.listenerType === ATTRIBUTE) {\n // Remove old value.\n if (prev !== null) {\n prev.next = node.next;\n } else if (node.next !== null) {\n listeners.set(eventName, node.next);\n } else {\n listeners.delete(eventName);\n }\n } else {\n prev = node;\n }\n\n node = node.next;\n }\n\n // Add new value.\n if (listener !== null) {\n const newNode = {\n listener,\n listenerType: ATTRIBUTE,\n passive: false,\n once: false,\n next: null,\n };\n if (prev === null) {\n listeners.set(eventName, newNode);\n } else {\n prev.next = newNode;\n }\n }\n },\n configurable: true,\n enumerable: true,\n }\n}\n\n/**\n * Define an event attribute (e.g. `eventTarget.onclick`).\n * @param {Object} eventTargetPrototype The event target prototype to define an event attrbite.\n * @param {string} eventName The event name to define.\n * @returns {void}\n */\nfunction defineEventAttribute(eventTargetPrototype, eventName) {\n Object.defineProperty(\n eventTargetPrototype,\n `on${eventName}`,\n defineEventAttributeDescriptor(eventName)\n );\n}\n\n/**\n * Define a custom EventTarget with event attributes.\n * @param {string[]} eventNames Event names for event attributes.\n * @returns {EventTarget} The custom EventTarget.\n * @private\n */\nfunction defineCustomEventTarget(eventNames) {\n /** CustomEventTarget */\n function CustomEventTarget() {\n EventTarget.call(this);\n }\n\n CustomEventTarget.prototype = Object.create(EventTarget.prototype, {\n constructor: {\n value: CustomEventTarget,\n configurable: true,\n writable: true,\n },\n });\n\n for (let i = 0; i < eventNames.length; ++i) {\n defineEventAttribute(CustomEventTarget.prototype, eventNames[i]);\n }\n\n return CustomEventTarget\n}\n\n/**\n * EventTarget.\n *\n * - This is constructor if no arguments.\n * - This is a function which returns a CustomEventTarget constructor if there are arguments.\n *\n * For example:\n *\n * class A extends EventTarget {}\n * class B extends EventTarget(\"message\") {}\n * class C extends EventTarget(\"message\", \"error\") {}\n * class D extends EventTarget([\"message\", \"error\"]) {}\n */\nfunction EventTarget() {\n /*eslint-disable consistent-return */\n if (this instanceof EventTarget) {\n listenersMap.set(this, new Map());\n return\n }\n if (arguments.length === 1 && Array.isArray(arguments[0])) {\n return defineCustomEventTarget(arguments[0])\n }\n if (arguments.length > 0) {\n const types = new Array(arguments.length);\n for (let i = 0; i < arguments.length; ++i) {\n types[i] = arguments[i];\n }\n return defineCustomEventTarget(types)\n }\n throw new TypeError(\"Cannot call a class as a function\")\n /*eslint-enable consistent-return */\n}\n\n// Should be enumerable, but class methods are not enumerable.\nEventTarget.prototype = {\n /**\n * Add a given listener to this event target.\n * @param {string} eventName The event name to add.\n * @param {Function} listener The listener to add.\n * @param {boolean|{capture?:boolean,passive?:boolean,once?:boolean}} [options] The options for this listener.\n * @returns {void}\n */\n addEventListener(eventName, listener, options) {\n if (listener == null) {\n return\n }\n if (typeof listener !== \"function\" && !isObject(listener)) {\n throw new TypeError(\"'listener' should be a function or an object.\")\n }\n\n const listeners = getListeners(this);\n const optionsIsObj = isObject(options);\n const capture = optionsIsObj\n ? Boolean(options.capture)\n : Boolean(options);\n const listenerType = capture ? CAPTURE : BUBBLE;\n const newNode = {\n listener,\n listenerType,\n passive: optionsIsObj && Boolean(options.passive),\n once: optionsIsObj && Boolean(options.once),\n next: null,\n };\n\n // Set it as the first node if the first node is null.\n let node = listeners.get(eventName);\n if (node === undefined) {\n listeners.set(eventName, newNode);\n return\n }\n\n // Traverse to the tail while checking duplication..\n let prev = null;\n while (node != null) {\n if (\n node.listener === listener &&\n node.listenerType === listenerType\n ) {\n // Should ignore duplication.\n return\n }\n prev = node;\n node = node.next;\n }\n\n // Add it.\n prev.next = newNode;\n },\n\n /**\n * Remove a given listener from this event target.\n * @param {string} eventName The event name to remove.\n * @param {Function} listener The listener to remove.\n * @param {boolean|{capture?:boolean,passive?:boolean,once?:boolean}} [options] The options for this listener.\n * @returns {void}\n */\n removeEventListener(eventName, listener, options) {\n if (listener == null) {\n return\n }\n\n const listeners = getListeners(this);\n const capture = isObject(options)\n ? Boolean(options.capture)\n : Boolean(options);\n const listenerType = capture ? CAPTURE : BUBBLE;\n\n let prev = null;\n let node = listeners.get(eventName);\n while (node != null) {\n if (\n node.listener === listener &&\n node.listenerType === listenerType\n ) {\n if (prev !== null) {\n prev.next = node.next;\n } else if (node.next !== null) {\n listeners.set(eventName, node.next);\n } else {\n listeners.delete(eventName);\n }\n return\n }\n\n prev = node;\n node = node.next;\n }\n },\n\n /**\n * Dispatch a given event.\n * @param {Event|{type:string}} event The event to dispatch.\n * @returns {boolean} `false` if canceled.\n */\n dispatchEvent(event) {\n if (event == null || typeof event.type !== \"string\") {\n throw new TypeError('\"event.type\" should be a string.')\n }\n\n // If listeners aren't registered, terminate.\n const listeners = getListeners(this);\n const eventName = event.type;\n let node = listeners.get(eventName);\n if (node == null) {\n return true\n }\n\n // Since we cannot rewrite several properties, so wrap object.\n const wrappedEvent = wrapEvent(this, event);\n\n // This doesn't process capturing phase and bubbling phase.\n // This isn't participating in a tree.\n let prev = null;\n while (node != null) {\n // Remove this listener if it's once\n if (node.once) {\n if (prev !== null) {\n prev.next = node.next;\n } else if (node.next !== null) {\n listeners.set(eventName, node.next);\n } else {\n listeners.delete(eventName);\n }\n } else {\n prev = node;\n }\n\n // Call this listener\n setPassiveListener(\n wrappedEvent,\n node.passive ? node.listener : null\n );\n if (typeof node.listener === \"function\") {\n try {\n node.listener.call(this, wrappedEvent);\n } catch (err) {\n if (\n typeof console !== \"undefined\" &&\n typeof console.error === \"function\"\n ) {\n console.error(err);\n }\n }\n } else if (\n node.listenerType !== ATTRIBUTE &&\n typeof node.listener.handleEvent === \"function\"\n ) {\n node.listener.handleEvent(wrappedEvent);\n }\n\n // Break if `event.stopImmediatePropagation` was called.\n if (isStopped(wrappedEvent)) {\n break\n }\n\n node = node.next;\n }\n setPassiveListener(wrappedEvent, null);\n setEventPhase(wrappedEvent, 0);\n setCurrentTarget(wrappedEvent, null);\n\n return !wrappedEvent.defaultPrevented\n },\n};\n\n// `constructor` is not enumerable.\nObject.defineProperty(EventTarget.prototype, \"constructor\", {\n value: EventTarget,\n configurable: true,\n writable: true,\n});\n\n// Ensure `eventTarget instanceof window.EventTarget` is `true`.\nif (\n typeof window !== \"undefined\" &&\n typeof window.EventTarget !== \"undefined\"\n) {\n Object.setPrototypeOf(EventTarget.prototype, window.EventTarget.prototype);\n}\n\nexport default EventTarget;\nexport { defineEventAttribute, EventTarget };\n//# sourceMappingURL=event-target-shim.mjs.map\n","import {\n // Event,\n EventTarget,\n // Type,\n defineEventAttribute,\n} from \"event-target-shim\"\n\n// Known Limitation\n// Use `any` because the type of `AbortSignal` in `lib.dom.d.ts` is wrong and\n// to make assignable our `AbortSignal` into that.\n// https://github.com/Microsoft/TSJS-lib-generator/pull/623\ntype Events = {\n abort: any // Event & Type<\"abort\">\n}\ntype EventAttributes = {\n onabort: any // Event & Type<\"abort\">\n}\n\n/**\n * The signal class.\n * @see https://dom.spec.whatwg.org/#abortsignal\n */\nexport default class AbortSignal extends EventTarget {\n /**\n * AbortSignal cannot be constructed directly.\n */\n public constructor() {\n super()\n throw new TypeError(\"AbortSignal cannot be constructed directly\")\n }\n\n /**\n * Returns `true` if this `AbortSignal`'s `AbortController` has signaled to abort, and `false` otherwise.\n */\n public get aborted(): boolean {\n const aborted = abortedFlags.get(this)\n if (typeof aborted !== \"boolean\") {\n throw new TypeError(\n `Expected 'this' to be an 'AbortSignal' object, but got ${\n this === null ? \"null\" : typeof this\n }`,\n )\n }\n return aborted\n }\n}\ndefineEventAttribute(AbortSignal.prototype, \"abort\")\n\n/**\n * Create an AbortSignal object.\n */\nexport function createAbortSignal(): AbortSignal {\n const signal = Object.create(AbortSignal.prototype)\n EventTarget.call(signal)\n abortedFlags.set(signal, false)\n return signal\n}\n\n/**\n * Abort a given signal.\n */\nexport function abortSignal(signal: AbortSignal): void {\n if (abortedFlags.get(signal) !== false) {\n return\n }\n\n abortedFlags.set(signal, true)\n signal.dispatchEvent<\"abort\">({ type: \"abort\" })\n}\n\n/**\n * Aborted flag for each instances.\n */\nconst abortedFlags = new WeakMap()\n\n// Properties should be enumerable.\nObject.defineProperties(AbortSignal.prototype, {\n aborted: { enumerable: true },\n})\n\n// `toString()` should return `\"[object AbortSignal]\"`\nif (typeof Symbol === \"function\" && typeof Symbol.toStringTag === \"symbol\") {\n Object.defineProperty(AbortSignal.prototype, Symbol.toStringTag, {\n configurable: true,\n value: \"AbortSignal\",\n })\n}\n","import AbortSignal, { abortSignal, createAbortSignal } from \"./abort-signal\"\n\n/**\n * The AbortController.\n * @see https://dom.spec.whatwg.org/#abortcontroller\n */\nexport default class AbortController {\n /**\n * Initialize this controller.\n */\n public constructor() {\n signals.set(this, createAbortSignal())\n }\n\n /**\n * Returns the `AbortSignal` object associated with this object.\n */\n public get signal(): AbortSignal {\n return getSignal(this)\n }\n\n /**\n * Abort and signal to any observers that the associated activity is to be aborted.\n */\n public abort(): void {\n abortSignal(getSignal(this))\n }\n}\n\n/**\n * Associated signals.\n */\nconst signals = new WeakMap()\n\n/**\n * Get the associated signal of a given controller.\n */\nfunction getSignal(controller: AbortController): AbortSignal {\n const signal = signals.get(controller)\n if (signal == null) {\n throw new TypeError(\n `Expected 'this' to be an 'AbortController' object, but got ${\n controller === null ? \"null\" : typeof controller\n }`,\n )\n }\n return signal\n}\n\n// Properties should be enumerable.\nObject.defineProperties(AbortController.prototype, {\n signal: { enumerable: true },\n abort: { enumerable: true },\n})\n\nif (typeof Symbol === \"function\" && typeof Symbol.toStringTag === \"symbol\") {\n Object.defineProperty(AbortController.prototype, Symbol.toStringTag, {\n configurable: true,\n value: \"AbortController\",\n })\n}\n\nexport { AbortController, AbortSignal }\n"],"names":["pd","event","retv","privateData","get","console","assert","setCancelFlag","data","passiveListener","cancelable","canceled","preventDefault","error","Event","eventTarget","set","eventPhase","currentTarget","stopped","immediateStopped","timeStamp","Date","now","Object","defineProperty","value","enumerable","key","keys","i","length","defineRedirectDescriptor","configurable","defineCallDescriptor","apply","arguments","defineWrapper","BaseEvent","proto","CustomEvent","call","prototype","create","constructor","writable","descriptor","getOwnPropertyDescriptor","isFunc","getWrapper","wrapper","wrappers","getPrototypeOf","wrapEvent","Wrapper","isStopped","setEventPhase","setCurrentTarget","setPassiveListener","createAbortSignal","signal","AbortSignal","EventTarget","abortedFlags","abortSignal","dispatchEvent","type","getSignal","controller","signals","TypeError","WeakMap","target","composedPath","NONE","CAPTURING_PHASE","AT_TARGET","BUBBLING_PHASE","stopPropagation","stopImmediatePropagation","bubbles","defaultPrevented","composed","srcElement","cancelBubble","returnValue","initEvent","window","setPrototypeOf","aborted","defineEventAttribute","defineProperties","Symbol","_typeof","toStringTag","AbortController","abort"],"mappings":";;;+3CAkCA,QAASA,CAAAA,CAAT,CAAYC,CAAZ,CAAmB,IACTC,CAAAA,CAAI,CAAGC,CAAW,CAACC,GAAZ,CAAgBH,CAAhB,QACbI,CAAAA,OAAO,CAACC,MAAR,CACY,IAAR,EAAAJ,CADJ,CAEI,6CAFJ,CAGID,CAHJ,EAKOC,EAOX,QAASK,CAAAA,CAAT,CAAuBC,CAAvB,CAA6B,OACG,KAAxB,EAAAA,CAAI,CAACC,eADgB,MAarB,CAACD,CAAI,CAACP,KAAL,CAAWS,UAbS,GAiBzBF,CAAI,CAACG,QAAL,GAjByB,CAkBgB,UAArC,QAAOH,CAAAA,CAAI,CAACP,KAAL,CAAWW,cAlBG,EAmBrBJ,CAAI,CAACP,KAAL,CAAWW,cAAX,EAnBqB,QAGE,WAAnB,QAAOP,CAAAA,OAAP,EACyB,UAAzB,QAAOA,CAAAA,OAAO,CAACQ,KAJE,EAMjBR,OAAO,CAACQ,KAAR,CACI,oEADJ,CAEIL,CAAI,CAACC,eAFT,CANiB,EAiC7B,QAASK,CAAAA,CAAT,CAAeC,CAAf,CAA4Bd,CAA5B,CAAmC,CAC/BE,CAAW,CAACa,GAAZ,CAAgB,IAAhB,CAAsB,CAClBD,WAAW,CAAXA,CADkB,CAElBd,KAAK,CAALA,CAFkB,CAGlBgB,UAAU,CAAE,CAHM,CAIlBC,aAAa,CAAEH,CAJG,CAKlBJ,QAAQ,GALU,CAMlBQ,OAAO,GANW,CAOlBC,gBAAgB,GAPE,CAQlBX,eAAe,CAAE,IARC,CASlBY,SAAS,CAAEpB,CAAK,CAACoB,SAAN,EAAmBC,IAAI,CAACC,GAAL,EATZ,CAAtB,CAD+B,CAc/BC,MAAM,CAACC,cAAP,CAAsB,IAAtB,CAA4B,WAA5B,CAAyC,CAAEC,KAAK,GAAP,CAAgBC,UAAU,GAA1B,CAAzC,CAd+B,QAmBrBC,CAAAA,EAFJC,CAAI,CAAGL,MAAM,CAACK,IAAP,CAAY5B,CAAZ,EACJ6B,CAAC,CAAG,EAAGA,CAAC,CAAGD,CAAI,CAACE,OAAQ,EAAED,EACzBF,EAAMC,CAAI,CAACC,CAAD,EACVF,CAAG,GAAI,OACTJ,MAAM,CAACC,cAAP,CAAsB,IAAtB,CAA4BG,CAA5B,CAAiCI,CAAwB,CAACJ,CAAD,CAAzD,EAyOZ,QAASI,CAAAA,CAAT,CAAkCJ,CAAlC,CAAuC,OAC5B,CACHxB,GADG,WACG,OACKJ,CAAAA,CAAE,CAAC,IAAD,CAAF,CAASC,KAAT,CAAe2B,CAAf,CAFR,CAAA,CAIHZ,GAJG,UAICU,EAAO,CACP1B,CAAE,CAAC,IAAD,CAAF,CAASC,KAAT,CAAe2B,CAAf,EAAsBF,CALvB,CAAA,CAOHO,YAAY,GAPT,CAQHN,UAAU,GARP,EAkBX,QAASO,CAAAA,CAAT,CAA8BN,CAA9B,CAAmC,OACxB,CACHF,KADG,WACK,IACEzB,CAAAA,CAAK,CAAGD,CAAE,CAAC,IAAD,CAAF,CAASC,YAChBA,CAAAA,CAAK,CAAC2B,CAAD,CAAL,CAAWO,KAAX,CAAiBlC,CAAjB,CAAwBmC,SAAxB,CAHR,CAAA,CAKHH,YAAY,GALT,CAMHN,UAAU,GANP,EAiBX,QAASU,CAAAA,CAAT,CAAuBC,CAAvB,CAAkCC,CAAlC,CAAyC,SAO5BC,CAAAA,EAAYzB,EAAad,EAAO,CACrCqC,CAAS,CAACG,IAAV,CAAe,IAAf,CAAqB1B,CAArB,CAAkCd,CAAlC,KAPE4B,CAAAA,CAAI,CAAGL,MAAM,CAACK,IAAP,CAAYU,CAAZ,KACO,CAAhB,GAAAV,CAAI,CAACE,aACEO,CAAAA,EAQXE,CAAW,CAACE,SAAZ,CAAwBlB,MAAM,CAACmB,MAAP,CAAcL,CAAS,CAACI,SAAxB,CAAmC,CACvDE,WAAW,CAAE,CAAElB,KAAK,CAAEc,CAAT,CAAsBP,YAAY,GAAlC,CAA0CY,QAAQ,GAAlD,CAD0C,CAAnC,CAXa,KAgBhC,GACKjB,CAAAA,CADL,CAAIE,CAAC,CAAG,EAAGA,CAAC,CAAGD,CAAI,CAACE,OAAQ,EAAED,KACzBF,EAAMC,CAAI,CAACC,CAAD,EACZ,EAAEF,CAAG,GAAIU,CAAAA,CAAS,CAACI,SAAnB,EAA+B,IACzBI,CAAAA,CAAU,CAAGtB,MAAM,CAACuB,wBAAP,CAAgCR,CAAhC,CAAuCX,CAAvC,CADY,CAEzBoB,CAAM,CAA+B,UAA5B,QAAOF,CAAAA,CAAU,CAACpB,KAFF,CAG/BF,MAAM,CAACC,cAAP,CACIe,CAAW,CAACE,SADhB,CAEId,CAFJ,CAGIoB,CAAM,CACAd,CAAoB,CAACN,CAAD,CADpB,CAEAI,CAAwB,CAACJ,CAAD,CALlC,QAUDY,CAAAA,EASX,QAASS,CAAAA,CAAT,CAAoBV,CAApB,CAA2B,IACV,IAAT,EAAAA,CAAK,EAAYA,CAAK,GAAKf,MAAM,CAACkB,gBAC3B5B,CAAAA,KAGPoC,CAAAA,CAAO,CAAGC,CAAQ,CAAC/C,GAAT,CAAamC,CAAb,QACC,KAAX,EAAAW,IACAA,CAAO,CAAGb,CAAa,CAACY,CAAU,CAACzB,MAAM,CAAC4B,cAAP,CAAsBb,CAAtB,CAAD,CAAX,CAA2CA,CAA3C,EACvBY,CAAQ,CAACnC,GAAT,CAAauB,CAAb,CAAoBW,CAApB,GAEGA,EAUJ,QAASG,CAAAA,CAAT,CAAmBtC,CAAnB,CAAgCd,CAAhC,CAAuC,IACpCqD,CAAAA,CAAO,CAAGL,CAAU,CAACzB,MAAM,CAAC4B,cAAP,CAAsBnD,CAAtB,CAAD,QACnB,IAAIqD,CAAAA,CAAJ,CAAYvC,CAAZ,CAAyBd,CAAzB,EASJ,QAASsD,CAAAA,CAAT,CAAmBtD,CAAnB,CAA0B,OACtBD,CAAAA,CAAE,CAACC,CAAD,CAAF,CAAUmB,iBAUd,QAASoC,CAAAA,CAAT,CAAuBvD,CAAvB,CAA8BgB,CAA9B,CAA0C,CAC7CjB,CAAE,CAACC,CAAD,CAAF,CAAUgB,UAAV,CAAuBA,EAUpB,QAASwC,CAAAA,CAAT,CAA0BxD,CAA1B,CAAiCiB,CAAjC,CAAgD,CACnDlB,CAAE,CAACC,CAAD,CAAF,CAAUiB,aAAV,CAA0BA,EAUvB,QAASwC,CAAAA,CAAT,CAA4BzD,CAA5B,CAAmCQ,CAAnC,CAAoD,CACvDT,CAAE,CAACC,CAAD,CAAF,CAAUQ,eAAV,CAA4BA,ysCC1ahBkD,CAAAA,OACNC,CAAAA,CAAM,CAAGpC,MAAM,CAACmB,MAAPnB,CAAcqC,CAAW,CAACnB,SAA1BlB,QACfsC,CAAAA,CAAW,CAACrB,IAAZqB,CAAiBF,CAAjBE,EACAC,CAAY,CAAC/C,GAAb+C,CAAiBH,CAAjBG,KACOH,UAMKI,CAAAA,EAAYJ,GACpBG,KAAAA,CAAY,CAAC3D,GAAb2D,CAAiBH,CAAjBG,IAIJA,CAAY,CAAC/C,GAAb+C,CAAiBH,CAAjBG,KACAH,CAAM,CAACK,aAAPL,CAA8B,CAAEM,IAAI,CAAE,OAAR,CAA9BN,GC9BJ,QAASO,CAAAA,CAAT,CAAmBC,CAAnB,KACUR,CAAAA,CAAM,CAAGS,CAAO,CAACjE,GAARiE,CAAYD,CAAZC,KACD,IAAVT,EAAAA,OACM,IAAIU,CAAAA,SAAJ,sEAEiB,IAAfF,GAAAA,CAAU,CAAY,MAAZ,GAA4BA,GAFxC,QAMHR,CAAAA,KF3BLzD,CAAAA,CAAW,CAAG,GAAIoE,CAAAA,QAOlBpB,CAAQ,CAAG,GAAIoB,CAAAA,QAkFrBzD,CAAK,CAAC4B,SAAN,CAAkB,IAKVwB,CAAAA,MAAO,OACAlE,CAAAA,CAAE,CAAC,IAAD,CAAF,CAASC,KAAT,CAAeiE,IANZ,CAAA,IAaVM,CAAAA,QAAS,OACFxE,CAAAA,CAAE,CAAC,IAAD,CAAF,CAASe,WAdN,CAAA,IAqBVG,CAAAA,eAAgB,OACTlB,CAAAA,CAAE,CAAC,IAAD,CAAF,CAASkB,aAtBN,CAAA,CA4BduD,YA5Bc,WA4BC,IACLvD,CAAAA,CAAa,CAAGlB,CAAE,CAAC,IAAD,CAAF,CAASkB,cADpB,MAEU,KAAjB,EAAAA,CAFO,CAGA,EAHA,CAKJ,CAACA,CAAD,CAjCG,CAAA,IAwCVwD,CAAAA,MAAO,OACA,EAzCG,CAAA,IAgDVC,CAAAA,iBAAkB,OACX,EAjDG,CAAA,IAwDVC,CAAAA,WAAY,OACL,EAzDG,CAAA,IAgEVC,CAAAA,gBAAiB,OACV,EAjEG,CAAA,IAwEV5D,CAAAA,YAAa,OACNjB,CAAAA,CAAE,CAAC,IAAD,CAAF,CAASiB,UAzEN,CAAA,CAgFd6D,eAhFc,WAgFI,IACRtE,CAAAA,CAAI,CAAGR,CAAE,CAAC,IAAD,EAEfQ,CAAI,CAACW,OAAL,GAHc,CAI4B,UAAtC,QAAOX,CAAAA,CAAI,CAACP,KAAL,CAAW6E,eAJR,EAKVtE,CAAI,CAACP,KAAL,CAAW6E,eAAX,EArFM,CAAA,CA6FdC,wBA7Fc,WA6Fa,IACjBvE,CAAAA,CAAI,CAAGR,CAAE,CAAC,IAAD,EAEfQ,CAAI,CAACW,OAAL,GAHuB,CAIvBX,CAAI,CAACY,gBAAL,GAJuB,CAK4B,UAA/C,QAAOZ,CAAAA,CAAI,CAACP,KAAL,CAAW8E,wBALC,EAMnBvE,CAAI,CAACP,KAAL,CAAW8E,wBAAX,EAnGM,CAAA,IA2GVC,CAAAA,SAAU,SACKhF,CAAE,CAAC,IAAD,CAAF,CAASC,KAAT,CAAe+E,OA5GpB,CAAA,IAmHVtE,CAAAA,YAAa,SACEV,CAAE,CAAC,IAAD,CAAF,CAASC,KAAT,CAAeS,UApHpB,CAAA,CA2HdE,cA3Hc,WA2HG,CACbL,CAAa,CAACP,CAAE,CAAC,IAAD,CAAH,CA5HH,CAAA,IAmIViF,CAAAA,kBAAmB,OACZjF,CAAAA,CAAE,CAAC,IAAD,CAAF,CAASW,QApIN,CAAA,IA2IVuE,CAAAA,UAAW,SACIlF,CAAE,CAAC,IAAD,CAAF,CAASC,KAAT,CAAeiF,QA5IpB,CAAA,IAmJV7D,CAAAA,WAAY,OACLrB,CAAAA,CAAE,CAAC,IAAD,CAAF,CAASqB,SApJN,CAAA,IA4JV8D,CAAAA,YAAa,OACNnF,CAAAA,CAAE,CAAC,IAAD,CAAF,CAASe,WA7JN,CAAA,IAqKVqE,CAAAA,cAAe,OACRpF,CAAAA,CAAE,CAAC,IAAD,CAAF,CAASmB,OAtKN,CAAA,IAwKViE,CAAAA,aAAa1D,EAAO,IACfA,MAGClB,CAAAA,CAAI,CAAGR,CAAE,CAAC,IAAD,EAEfQ,CAAI,CAACW,OAAL,IACuC,SAAnC,QAAOX,CAAAA,CAAI,CAACP,KAAL,CAAWmF,eAClB5E,CAAI,CAACP,KAAL,CAAWmF,YAAX,KAhLM,CAAA,IAyLVC,CAAAA,aAAc,OACP,CAACrF,CAAE,CAAC,IAAD,CAAF,CAASW,QA1LP,CAAA,IA4LV0E,CAAAA,YAAY3D,EAAO,CACdA,CADc,EAEfnB,CAAa,CAACP,CAAE,CAAC,IAAD,CAAH,CA9LP,CAAA,CAyMdsF,SAzMc,WAyMF,EAzME,EA+MlB9D,MAAM,CAACC,cAAP,CAAsBX,CAAK,CAAC4B,SAA5B,CAAuC,aAAvC,CAAsD,CAClDhB,KAAK,CAAEZ,CAD2C,CAElDmB,YAAY,GAFsC,CAGlDY,QAAQ,GAH0C,CAAtD,EAOsB,WAAlB,QAAO0C,CAAAA,MAAP,EAAyD,WAAxB,QAAOA,CAAAA,MAAM,CAACzE,QAC/CU,MAAM,CAACgE,cAAP,CAAsB1E,CAAK,CAAC4B,SAA5B,CAAuC6C,MAAM,CAACzE,KAAP,CAAa4B,SAApD,EAGAS,CAAQ,CAACnC,GAAT,CAAauE,MAAM,CAACzE,KAAP,CAAa4B,SAA1B,CAAqC5B,CAArC,wiDChTiB+C,CAAAA,2EAMP,GAAIS,CAAAA,SAAJ,CAAc,4CAAd,sDAOAmB,CAAAA,CAAO,CAAG1B,CAAY,CAAC3D,GAAb2D,CAAiB,IAAjBA,KACO,SAAnB,QAAO0B,CAAAA,OACD,IAAInB,CAAAA,SAAJ,kEAEW,IAAT,QAAgB,MAAhB,GAAgC,MAFlC,QAMHmB,CAAAA,SArB0B3B,GAwBzC4B,CAAoB,CAAC7B,CAAW,CAACnB,SAAb,CAAwB,OAAxB,EA2BpB,GAAMqB,CAAAA,CAAY,CAAG,GAAIQ,CAAAA,OAAzB,CAGA/C,MAAM,CAACmE,gBAAPnE,CAAwBqC,CAAW,CAACnB,SAApClB,CAA+C,CAC3CiE,OAAO,CAAE,CAAE9D,UAAU,GAAZ,CADkC,CAA/CH,EAKsB,UAAlB,QAAOoE,CAAAA,MAAP,EAA8D,QAA9B,GAAAC,EAAOD,MAAM,CAACE,cAC9CtE,MAAM,CAACC,cAAPD,CAAsBqC,CAAW,CAACnB,SAAlClB,CAA6CoE,MAAM,CAACE,WAApDtE,CAAiE,CAC7DS,YAAY,GADiD,CAE7DP,KAAK,CAAE,aAFsD,CAAjEF,KC5EiBuE,CAAAA,oCAKb1B,CAAO,CAACrD,GAARqD,CAAY,IAAZA,CAAkBV,CAAiB,EAAnCU,4CAcAL,CAAW,CAACG,CAAS,CAAC,IAAD,CAAV,uCAPJA,CAAAA,CAAS,CAAC,IAAD,WAclBE,CAAO,CAAG,GAAIE,CAAAA,WAkBpB/C,MAAM,CAACmE,gBAAPnE,CAAwBuE,CAAe,CAACrD,SAAxClB,CAAmD,CAC/CoC,MAAM,CAAE,CAAEjC,UAAU,GAAZ,CADuC,CAE/CqE,KAAK,CAAE,CAAErE,UAAU,GAAZ,CAFwC,CAAnDH,EAKsB,UAAlB,QAAOoE,CAAAA,MAAP,EAA8D,QAA9B,GAAAC,EAAOD,MAAM,CAACE,cAC9CtE,MAAM,CAACC,cAAPD,CAAsBuE,CAAe,CAACrD,SAAtClB,CAAiDoE,MAAM,CAACE,WAAxDtE,CAAqE,CACjES,YAAY,GADqD,CAEjEP,KAAK,CAAE,iBAF0D,CAArEF"} \ No newline at end of file diff --git a/sandbox/tgbot/node_modules/abort-controller/package.json b/sandbox/tgbot/node_modules/abort-controller/package.json new file mode 100644 index 0000000..fc705e0 --- /dev/null +++ b/sandbox/tgbot/node_modules/abort-controller/package.json @@ -0,0 +1,97 @@ +{ + "name": "abort-controller", + "version": "3.0.0", + "description": "An implementation of WHATWG AbortController interface.", + "main": "dist/abort-controller", + "files": [ + "dist", + "polyfill.*", + "browser.*" + ], + "engines": { + "node": ">=6.5" + }, + "dependencies": { + "event-target-shim": "^5.0.0" + }, + "browser": "./browser.js", + "devDependencies": { + "@babel/core": "^7.2.2", + "@babel/plugin-transform-modules-commonjs": "^7.2.0", + "@babel/preset-env": "^7.3.0", + "@babel/register": "^7.0.0", + "@mysticatea/eslint-plugin": "^8.0.1", + "@mysticatea/spy": "^0.1.2", + "@types/mocha": "^5.2.5", + "@types/node": "^10.12.18", + "assert": "^1.4.1", + "codecov": "^3.1.0", + "dts-bundle-generator": "^2.0.0", + "eslint": "^5.12.1", + "karma": "^3.1.4", + "karma-chrome-launcher": "^2.2.0", + "karma-coverage": "^1.1.2", + "karma-firefox-launcher": "^1.1.0", + "karma-growl-reporter": "^1.0.0", + "karma-ie-launcher": "^1.0.0", + "karma-mocha": "^1.3.0", + "karma-rollup-preprocessor": "^7.0.0-rc.2", + "mocha": "^5.2.0", + "npm-run-all": "^4.1.5", + "nyc": "^13.1.0", + "opener": "^1.5.1", + "rimraf": "^2.6.3", + "rollup": "^1.1.2", + "rollup-plugin-babel": "^4.3.2", + "rollup-plugin-babel-minify": "^7.0.0", + "rollup-plugin-commonjs": "^9.2.0", + "rollup-plugin-node-resolve": "^4.0.0", + "rollup-plugin-sourcemaps": "^0.4.2", + "rollup-plugin-typescript": "^1.0.0", + "rollup-watch": "^4.3.1", + "ts-node": "^8.0.1", + "type-tester": "^1.0.0", + "typescript": "^3.2.4" + }, + "scripts": { + "preversion": "npm test", + "version": "npm run -s build && git add dist/*", + "postversion": "git push && git push --tags", + "clean": "rimraf .nyc_output coverage", + "coverage": "opener coverage/lcov-report/index.html", + "lint": "eslint . --ext .ts", + "build": "run-s -s build:*", + "build:rollup": "rollup -c", + "build:dts": "dts-bundle-generator -o dist/abort-controller.d.ts src/abort-controller.ts && ts-node scripts/fix-dts", + "test": "run-s -s lint test:*", + "test:mocha": "nyc mocha test/*.ts", + "test:karma": "karma start --single-run", + "watch": "run-p -s watch:*", + "watch:mocha": "mocha test/*.ts --require ts-node/register --watch-extensions ts --watch --growl", + "watch:karma": "karma start --watch", + "codecov": "codecov" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/mysticatea/abort-controller.git" + }, + "keywords": [ + "w3c", + "whatwg", + "event", + "events", + "abort", + "cancel", + "abortcontroller", + "abortsignal", + "controller", + "signal", + "shim" + ], + "author": "Toru Nagashima (https://github.com/mysticatea)", + "license": "MIT", + "bugs": { + "url": "https://github.com/mysticatea/abort-controller/issues" + }, + "homepage": "https://github.com/mysticatea/abort-controller#readme" +} diff --git a/sandbox/tgbot/node_modules/abort-controller/polyfill.js b/sandbox/tgbot/node_modules/abort-controller/polyfill.js new file mode 100644 index 0000000..3ca8923 --- /dev/null +++ b/sandbox/tgbot/node_modules/abort-controller/polyfill.js @@ -0,0 +1,21 @@ +/*globals require, self, window */ +"use strict" + +const ac = require("./dist/abort-controller") + +/*eslint-disable @mysticatea/prettier */ +const g = + typeof self !== "undefined" ? self : + typeof window !== "undefined" ? window : + typeof global !== "undefined" ? global : + /* otherwise */ undefined +/*eslint-enable @mysticatea/prettier */ + +if (g) { + if (typeof g.AbortController === "undefined") { + g.AbortController = ac.AbortController + } + if (typeof g.AbortSignal === "undefined") { + g.AbortSignal = ac.AbortSignal + } +} diff --git a/sandbox/tgbot/node_modules/abort-controller/polyfill.mjs b/sandbox/tgbot/node_modules/abort-controller/polyfill.mjs new file mode 100644 index 0000000..0602a64 --- /dev/null +++ b/sandbox/tgbot/node_modules/abort-controller/polyfill.mjs @@ -0,0 +1,19 @@ +/*globals self, window */ +import * as ac from "./dist/abort-controller" + +/*eslint-disable @mysticatea/prettier */ +const g = + typeof self !== "undefined" ? self : + typeof window !== "undefined" ? window : + typeof global !== "undefined" ? global : + /* otherwise */ undefined +/*eslint-enable @mysticatea/prettier */ + +if (g) { + if (typeof g.AbortController === "undefined") { + g.AbortController = ac.AbortController + } + if (typeof g.AbortSignal === "undefined") { + g.AbortSignal = ac.AbortSignal + } +} diff --git a/sandbox/tgbot/node_modules/debug/LICENSE b/sandbox/tgbot/node_modules/debug/LICENSE new file mode 100644 index 0000000..1a9820e --- /dev/null +++ b/sandbox/tgbot/node_modules/debug/LICENSE @@ -0,0 +1,20 @@ +(The MIT License) + +Copyright (c) 2014-2017 TJ Holowaychuk +Copyright (c) 2018-2021 Josh Junon + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software +and associated documentation files (the 'Software'), to deal in the Software without restriction, +including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, +and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial +portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT +LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + diff --git a/sandbox/tgbot/node_modules/debug/README.md b/sandbox/tgbot/node_modules/debug/README.md new file mode 100644 index 0000000..9ebdfbf --- /dev/null +++ b/sandbox/tgbot/node_modules/debug/README.md @@ -0,0 +1,481 @@ +# debug +[![OpenCollective](https://opencollective.com/debug/backers/badge.svg)](#backers) +[![OpenCollective](https://opencollective.com/debug/sponsors/badge.svg)](#sponsors) + + + +A tiny JavaScript debugging utility modelled after Node.js core's debugging +technique. Works in Node.js and web browsers. + +## Installation + +```bash +$ npm install debug +``` + +## Usage + +`debug` exposes a function; simply pass this function the name of your module, and it will return a decorated version of `console.error` for you to pass debug statements to. This will allow you to toggle the debug output for different parts of your module as well as the module as a whole. + +Example [_app.js_](./examples/node/app.js): + +```js +var debug = require('debug')('http') + , http = require('http') + , name = 'My App'; + +// fake app + +debug('booting %o', name); + +http.createServer(function(req, res){ + debug(req.method + ' ' + req.url); + res.end('hello\n'); +}).listen(3000, function(){ + debug('listening'); +}); + +// fake worker of some kind + +require('./worker'); +``` + +Example [_worker.js_](./examples/node/worker.js): + +```js +var a = require('debug')('worker:a') + , b = require('debug')('worker:b'); + +function work() { + a('doing lots of uninteresting work'); + setTimeout(work, Math.random() * 1000); +} + +work(); + +function workb() { + b('doing some work'); + setTimeout(workb, Math.random() * 2000); +} + +workb(); +``` + +The `DEBUG` environment variable is then used to enable these based on space or +comma-delimited names. + +Here are some examples: + +screen shot 2017-08-08 at 12 53 04 pm +screen shot 2017-08-08 at 12 53 38 pm +screen shot 2017-08-08 at 12 53 25 pm + +#### Windows command prompt notes + +##### CMD + +On Windows the environment variable is set using the `set` command. + +```cmd +set DEBUG=*,-not_this +``` + +Example: + +```cmd +set DEBUG=* & node app.js +``` + +##### PowerShell (VS Code default) + +PowerShell uses different syntax to set environment variables. + +```cmd +$env:DEBUG = "*,-not_this" +``` + +Example: + +```cmd +$env:DEBUG='app';node app.js +``` + +Then, run the program to be debugged as usual. + +npm script example: +```js + "windowsDebug": "@powershell -Command $env:DEBUG='*';node app.js", +``` + +## Namespace Colors + +Every debug instance has a color generated for it based on its namespace name. +This helps when visually parsing the debug output to identify which debug instance +a debug line belongs to. + +#### Node.js + +In Node.js, colors are enabled when stderr is a TTY. You also _should_ install +the [`supports-color`](https://npmjs.org/supports-color) module alongside debug, +otherwise debug will only use a small handful of basic colors. + + + +#### Web Browser + +Colors are also enabled on "Web Inspectors" that understand the `%c` formatting +option. These are WebKit web inspectors, Firefox ([since version +31](https://hacks.mozilla.org/2014/05/editable-box-model-multiple-selection-sublime-text-keys-much-more-firefox-developer-tools-episode-31/)) +and the Firebug plugin for Firefox (any version). + + + + +## Millisecond diff + +When actively developing an application it can be useful to see when the time spent between one `debug()` call and the next. Suppose for example you invoke `debug()` before requesting a resource, and after as well, the "+NNNms" will show you how much time was spent between calls. + + + +When stdout is not a TTY, `Date#toISOString()` is used, making it more useful for logging the debug information as shown below: + + + + +## Conventions + +If you're using this in one or more of your libraries, you _should_ use the name of your library so that developers may toggle debugging as desired without guessing names. If you have more than one debuggers you _should_ prefix them with your library name and use ":" to separate features. For example "bodyParser" from Connect would then be "connect:bodyParser". If you append a "*" to the end of your name, it will always be enabled regardless of the setting of the DEBUG environment variable. You can then use it for normal output as well as debug output. + +## Wildcards + +The `*` character may be used as a wildcard. Suppose for example your library has +debuggers named "connect:bodyParser", "connect:compress", "connect:session", +instead of listing all three with +`DEBUG=connect:bodyParser,connect:compress,connect:session`, you may simply do +`DEBUG=connect:*`, or to run everything using this module simply use `DEBUG=*`. + +You can also exclude specific debuggers by prefixing them with a "-" character. +For example, `DEBUG=*,-connect:*` would include all debuggers except those +starting with "connect:". + +## Environment Variables + +When running through Node.js, you can set a few environment variables that will +change the behavior of the debug logging: + +| Name | Purpose | +|-----------|-------------------------------------------------| +| `DEBUG` | Enables/disables specific debugging namespaces. | +| `DEBUG_HIDE_DATE` | Hide date from debug output (non-TTY). | +| `DEBUG_COLORS`| Whether or not to use colors in the debug output. | +| `DEBUG_DEPTH` | Object inspection depth. | +| `DEBUG_SHOW_HIDDEN` | Shows hidden properties on inspected objects. | + + +__Note:__ The environment variables beginning with `DEBUG_` end up being +converted into an Options object that gets used with `%o`/`%O` formatters. +See the Node.js documentation for +[`util.inspect()`](https://nodejs.org/api/util.html#util_util_inspect_object_options) +for the complete list. + +## Formatters + +Debug uses [printf-style](https://wikipedia.org/wiki/Printf_format_string) formatting. +Below are the officially supported formatters: + +| Formatter | Representation | +|-----------|----------------| +| `%O` | Pretty-print an Object on multiple lines. | +| `%o` | Pretty-print an Object all on a single line. | +| `%s` | String. | +| `%d` | Number (both integer and float). | +| `%j` | JSON. Replaced with the string '[Circular]' if the argument contains circular references. | +| `%%` | Single percent sign ('%'). This does not consume an argument. | + + +### Custom formatters + +You can add custom formatters by extending the `debug.formatters` object. +For example, if you wanted to add support for rendering a Buffer as hex with +`%h`, you could do something like: + +```js +const createDebug = require('debug') +createDebug.formatters.h = (v) => { + return v.toString('hex') +} + +// …elsewhere +const debug = createDebug('foo') +debug('this is hex: %h', new Buffer('hello world')) +// foo this is hex: 68656c6c6f20776f726c6421 +0ms +``` + + +## Browser Support + +You can build a browser-ready script using [browserify](https://github.com/substack/node-browserify), +or just use the [browserify-as-a-service](https://wzrd.in/) [build](https://wzrd.in/standalone/debug@latest), +if you don't want to build it yourself. + +Debug's enable state is currently persisted by `localStorage`. +Consider the situation shown below where you have `worker:a` and `worker:b`, +and wish to debug both. You can enable this using `localStorage.debug`: + +```js +localStorage.debug = 'worker:*' +``` + +And then refresh the page. + +```js +a = debug('worker:a'); +b = debug('worker:b'); + +setInterval(function(){ + a('doing some work'); +}, 1000); + +setInterval(function(){ + b('doing some work'); +}, 1200); +``` + +In Chromium-based web browsers (e.g. Brave, Chrome, and Electron), the JavaScript console will—by default—only show messages logged by `debug` if the "Verbose" log level is _enabled_. + + + +## Output streams + + By default `debug` will log to stderr, however this can be configured per-namespace by overriding the `log` method: + +Example [_stdout.js_](./examples/node/stdout.js): + +```js +var debug = require('debug'); +var error = debug('app:error'); + +// by default stderr is used +error('goes to stderr!'); + +var log = debug('app:log'); +// set this namespace to log via console.log +log.log = console.log.bind(console); // don't forget to bind to console! +log('goes to stdout'); +error('still goes to stderr!'); + +// set all output to go via console.info +// overrides all per-namespace log settings +debug.log = console.info.bind(console); +error('now goes to stdout via console.info'); +log('still goes to stdout, but via console.info now'); +``` + +## Extend +You can simply extend debugger +```js +const log = require('debug')('auth'); + +//creates new debug instance with extended namespace +const logSign = log.extend('sign'); +const logLogin = log.extend('login'); + +log('hello'); // auth hello +logSign('hello'); //auth:sign hello +logLogin('hello'); //auth:login hello +``` + +## Set dynamically + +You can also enable debug dynamically by calling the `enable()` method : + +```js +let debug = require('debug'); + +console.log(1, debug.enabled('test')); + +debug.enable('test'); +console.log(2, debug.enabled('test')); + +debug.disable(); +console.log(3, debug.enabled('test')); + +``` + +print : +``` +1 false +2 true +3 false +``` + +Usage : +`enable(namespaces)` +`namespaces` can include modes separated by a colon and wildcards. + +Note that calling `enable()` completely overrides previously set DEBUG variable : + +``` +$ DEBUG=foo node -e 'var dbg = require("debug"); dbg.enable("bar"); console.log(dbg.enabled("foo"))' +=> false +``` + +`disable()` + +Will disable all namespaces. The functions returns the namespaces currently +enabled (and skipped). This can be useful if you want to disable debugging +temporarily without knowing what was enabled to begin with. + +For example: + +```js +let debug = require('debug'); +debug.enable('foo:*,-foo:bar'); +let namespaces = debug.disable(); +debug.enable(namespaces); +``` + +Note: There is no guarantee that the string will be identical to the initial +enable string, but semantically they will be identical. + +## Checking whether a debug target is enabled + +After you've created a debug instance, you can determine whether or not it is +enabled by checking the `enabled` property: + +```javascript +const debug = require('debug')('http'); + +if (debug.enabled) { + // do stuff... +} +``` + +You can also manually toggle this property to force the debug instance to be +enabled or disabled. + +## Usage in child processes + +Due to the way `debug` detects if the output is a TTY or not, colors are not shown in child processes when `stderr` is piped. A solution is to pass the `DEBUG_COLORS=1` environment variable to the child process. +For example: + +```javascript +worker = fork(WORKER_WRAP_PATH, [workerPath], { + stdio: [ + /* stdin: */ 0, + /* stdout: */ 'pipe', + /* stderr: */ 'pipe', + 'ipc', + ], + env: Object.assign({}, process.env, { + DEBUG_COLORS: 1 // without this settings, colors won't be shown + }), +}); + +worker.stderr.pipe(process.stderr, { end: false }); +``` + + +## Authors + + - TJ Holowaychuk + - Nathan Rajlich + - Andrew Rhyne + - Josh Junon + +## Backers + +Support us with a monthly donation and help us continue our activities. [[Become a backer](https://opencollective.com/debug#backer)] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +## Sponsors + +Become a sponsor and get your logo on our README on Github with a link to your site. [[Become a sponsor](https://opencollective.com/debug#sponsor)] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +## License + +(The MIT License) + +Copyright (c) 2014-2017 TJ Holowaychuk <tj@vision-media.ca> +Copyright (c) 2018-2021 Josh Junon + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +'Software'), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/sandbox/tgbot/node_modules/debug/package.json b/sandbox/tgbot/node_modules/debug/package.json new file mode 100644 index 0000000..ee8abb5 --- /dev/null +++ b/sandbox/tgbot/node_modules/debug/package.json @@ -0,0 +1,64 @@ +{ + "name": "debug", + "version": "4.4.3", + "repository": { + "type": "git", + "url": "git://github.com/debug-js/debug.git" + }, + "description": "Lightweight debugging utility for Node.js and the browser", + "keywords": [ + "debug", + "log", + "debugger" + ], + "files": [ + "src", + "LICENSE", + "README.md" + ], + "author": "Josh Junon (https://github.com/qix-)", + "contributors": [ + "TJ Holowaychuk ", + "Nathan Rajlich (http://n8.io)", + "Andrew Rhyne " + ], + "license": "MIT", + "scripts": { + "lint": "xo", + "test": "npm run test:node && npm run test:browser && npm run lint", + "test:node": "mocha test.js test.node.js", + "test:browser": "karma start --single-run", + "test:coverage": "cat ./coverage/lcov.info | coveralls" + }, + "dependencies": { + "ms": "^2.1.3" + }, + "devDependencies": { + "brfs": "^2.0.1", + "browserify": "^16.2.3", + "coveralls": "^3.0.2", + "karma": "^3.1.4", + "karma-browserify": "^6.0.0", + "karma-chrome-launcher": "^2.2.0", + "karma-mocha": "^1.3.0", + "mocha": "^5.2.0", + "mocha-lcov-reporter": "^1.2.0", + "sinon": "^14.0.0", + "xo": "^0.23.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + }, + "main": "./src/index.js", + "browser": "./src/browser.js", + "engines": { + "node": ">=6.0" + }, + "xo": { + "rules": { + "import/extensions": "off" + } + } +} diff --git a/sandbox/tgbot/node_modules/debug/src/browser.js b/sandbox/tgbot/node_modules/debug/src/browser.js new file mode 100644 index 0000000..5993451 --- /dev/null +++ b/sandbox/tgbot/node_modules/debug/src/browser.js @@ -0,0 +1,272 @@ +/* eslint-env browser */ + +/** + * This is the web browser implementation of `debug()`. + */ + +exports.formatArgs = formatArgs; +exports.save = save; +exports.load = load; +exports.useColors = useColors; +exports.storage = localstorage(); +exports.destroy = (() => { + let warned = false; + + return () => { + if (!warned) { + warned = true; + console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'); + } + }; +})(); + +/** + * Colors. + */ + +exports.colors = [ + '#0000CC', + '#0000FF', + '#0033CC', + '#0033FF', + '#0066CC', + '#0066FF', + '#0099CC', + '#0099FF', + '#00CC00', + '#00CC33', + '#00CC66', + '#00CC99', + '#00CCCC', + '#00CCFF', + '#3300CC', + '#3300FF', + '#3333CC', + '#3333FF', + '#3366CC', + '#3366FF', + '#3399CC', + '#3399FF', + '#33CC00', + '#33CC33', + '#33CC66', + '#33CC99', + '#33CCCC', + '#33CCFF', + '#6600CC', + '#6600FF', + '#6633CC', + '#6633FF', + '#66CC00', + '#66CC33', + '#9900CC', + '#9900FF', + '#9933CC', + '#9933FF', + '#99CC00', + '#99CC33', + '#CC0000', + '#CC0033', + '#CC0066', + '#CC0099', + '#CC00CC', + '#CC00FF', + '#CC3300', + '#CC3333', + '#CC3366', + '#CC3399', + '#CC33CC', + '#CC33FF', + '#CC6600', + '#CC6633', + '#CC9900', + '#CC9933', + '#CCCC00', + '#CCCC33', + '#FF0000', + '#FF0033', + '#FF0066', + '#FF0099', + '#FF00CC', + '#FF00FF', + '#FF3300', + '#FF3333', + '#FF3366', + '#FF3399', + '#FF33CC', + '#FF33FF', + '#FF6600', + '#FF6633', + '#FF9900', + '#FF9933', + '#FFCC00', + '#FFCC33' +]; + +/** + * Currently only WebKit-based Web Inspectors, Firefox >= v31, + * and the Firebug extension (any Firefox version) are known + * to support "%c" CSS customizations. + * + * TODO: add a `localStorage` variable to explicitly enable/disable colors + */ + +// eslint-disable-next-line complexity +function useColors() { + // NB: In an Electron preload script, document will be defined but not fully + // initialized. Since we know we're in Chrome, we'll just detect this case + // explicitly + if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) { + return true; + } + + // Internet Explorer and Edge do not support colors. + if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) { + return false; + } + + let m; + + // Is webkit? http://stackoverflow.com/a/16459606/376773 + // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632 + // eslint-disable-next-line no-return-assign + return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) || + // Is firebug? http://stackoverflow.com/a/398120/376773 + (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) || + // Is firefox >= v31? + // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages + (typeof navigator !== 'undefined' && navigator.userAgent && (m = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) && parseInt(m[1], 10) >= 31) || + // Double check webkit in userAgent just in case we are in a worker + (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)); +} + +/** + * Colorize log arguments if enabled. + * + * @api public + */ + +function formatArgs(args) { + args[0] = (this.useColors ? '%c' : '') + + this.namespace + + (this.useColors ? ' %c' : ' ') + + args[0] + + (this.useColors ? '%c ' : ' ') + + '+' + module.exports.humanize(this.diff); + + if (!this.useColors) { + return; + } + + const c = 'color: ' + this.color; + args.splice(1, 0, c, 'color: inherit'); + + // The final "%c" is somewhat tricky, because there could be other + // arguments passed either before or after the %c, so we need to + // figure out the correct index to insert the CSS into + let index = 0; + let lastC = 0; + args[0].replace(/%[a-zA-Z%]/g, match => { + if (match === '%%') { + return; + } + index++; + if (match === '%c') { + // We only are interested in the *last* %c + // (the user may have provided their own) + lastC = index; + } + }); + + args.splice(lastC, 0, c); +} + +/** + * Invokes `console.debug()` when available. + * No-op when `console.debug` is not a "function". + * If `console.debug` is not available, falls back + * to `console.log`. + * + * @api public + */ +exports.log = console.debug || console.log || (() => {}); + +/** + * Save `namespaces`. + * + * @param {String} namespaces + * @api private + */ +function save(namespaces) { + try { + if (namespaces) { + exports.storage.setItem('debug', namespaces); + } else { + exports.storage.removeItem('debug'); + } + } catch (error) { + // Swallow + // XXX (@Qix-) should we be logging these? + } +} + +/** + * Load `namespaces`. + * + * @return {String} returns the previously persisted debug modes + * @api private + */ +function load() { + let r; + try { + r = exports.storage.getItem('debug') || exports.storage.getItem('DEBUG') ; + } catch (error) { + // Swallow + // XXX (@Qix-) should we be logging these? + } + + // If debug isn't set in LS, and we're in Electron, try to load $DEBUG + if (!r && typeof process !== 'undefined' && 'env' in process) { + r = process.env.DEBUG; + } + + return r; +} + +/** + * Localstorage attempts to return the localstorage. + * + * This is necessary because safari throws + * when a user disables cookies/localstorage + * and you attempt to access it. + * + * @return {LocalStorage} + * @api private + */ + +function localstorage() { + try { + // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context + // The Browser also has localStorage in the global context. + return localStorage; + } catch (error) { + // Swallow + // XXX (@Qix-) should we be logging these? + } +} + +module.exports = require('./common')(exports); + +const {formatters} = module.exports; + +/** + * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default. + */ + +formatters.j = function (v) { + try { + return JSON.stringify(v); + } catch (error) { + return '[UnexpectedJSONParseError]: ' + error.message; + } +}; diff --git a/sandbox/tgbot/node_modules/debug/src/common.js b/sandbox/tgbot/node_modules/debug/src/common.js new file mode 100644 index 0000000..141cb57 --- /dev/null +++ b/sandbox/tgbot/node_modules/debug/src/common.js @@ -0,0 +1,292 @@ + +/** + * This is the common logic for both the Node.js and web browser + * implementations of `debug()`. + */ + +function setup(env) { + createDebug.debug = createDebug; + createDebug.default = createDebug; + createDebug.coerce = coerce; + createDebug.disable = disable; + createDebug.enable = enable; + createDebug.enabled = enabled; + createDebug.humanize = require('ms'); + createDebug.destroy = destroy; + + Object.keys(env).forEach(key => { + createDebug[key] = env[key]; + }); + + /** + * The currently active debug mode names, and names to skip. + */ + + createDebug.names = []; + createDebug.skips = []; + + /** + * Map of special "%n" handling functions, for the debug "format" argument. + * + * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N". + */ + createDebug.formatters = {}; + + /** + * Selects a color for a debug namespace + * @param {String} namespace The namespace string for the debug instance to be colored + * @return {Number|String} An ANSI color code for the given namespace + * @api private + */ + function selectColor(namespace) { + let hash = 0; + + for (let i = 0; i < namespace.length; i++) { + hash = ((hash << 5) - hash) + namespace.charCodeAt(i); + hash |= 0; // Convert to 32bit integer + } + + return createDebug.colors[Math.abs(hash) % createDebug.colors.length]; + } + createDebug.selectColor = selectColor; + + /** + * Create a debugger with the given `namespace`. + * + * @param {String} namespace + * @return {Function} + * @api public + */ + function createDebug(namespace) { + let prevTime; + let enableOverride = null; + let namespacesCache; + let enabledCache; + + function debug(...args) { + // Disabled? + if (!debug.enabled) { + return; + } + + const self = debug; + + // Set `diff` timestamp + const curr = Number(new Date()); + const ms = curr - (prevTime || curr); + self.diff = ms; + self.prev = prevTime; + self.curr = curr; + prevTime = curr; + + args[0] = createDebug.coerce(args[0]); + + if (typeof args[0] !== 'string') { + // Anything else let's inspect with %O + args.unshift('%O'); + } + + // Apply any `formatters` transformations + let index = 0; + args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => { + // If we encounter an escaped % then don't increase the array index + if (match === '%%') { + return '%'; + } + index++; + const formatter = createDebug.formatters[format]; + if (typeof formatter === 'function') { + const val = args[index]; + match = formatter.call(self, val); + + // Now we need to remove `args[index]` since it's inlined in the `format` + args.splice(index, 1); + index--; + } + return match; + }); + + // Apply env-specific formatting (colors, etc.) + createDebug.formatArgs.call(self, args); + + const logFn = self.log || createDebug.log; + logFn.apply(self, args); + } + + debug.namespace = namespace; + debug.useColors = createDebug.useColors(); + debug.color = createDebug.selectColor(namespace); + debug.extend = extend; + debug.destroy = createDebug.destroy; // XXX Temporary. Will be removed in the next major release. + + Object.defineProperty(debug, 'enabled', { + enumerable: true, + configurable: false, + get: () => { + if (enableOverride !== null) { + return enableOverride; + } + if (namespacesCache !== createDebug.namespaces) { + namespacesCache = createDebug.namespaces; + enabledCache = createDebug.enabled(namespace); + } + + return enabledCache; + }, + set: v => { + enableOverride = v; + } + }); + + // Env-specific initialization logic for debug instances + if (typeof createDebug.init === 'function') { + createDebug.init(debug); + } + + return debug; + } + + function extend(namespace, delimiter) { + const newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace); + newDebug.log = this.log; + return newDebug; + } + + /** + * Enables a debug mode by namespaces. This can include modes + * separated by a colon and wildcards. + * + * @param {String} namespaces + * @api public + */ + function enable(namespaces) { + createDebug.save(namespaces); + createDebug.namespaces = namespaces; + + createDebug.names = []; + createDebug.skips = []; + + const split = (typeof namespaces === 'string' ? namespaces : '') + .trim() + .replace(/\s+/g, ',') + .split(',') + .filter(Boolean); + + for (const ns of split) { + if (ns[0] === '-') { + createDebug.skips.push(ns.slice(1)); + } else { + createDebug.names.push(ns); + } + } + } + + /** + * Checks if the given string matches a namespace template, honoring + * asterisks as wildcards. + * + * @param {String} search + * @param {String} template + * @return {Boolean} + */ + function matchesTemplate(search, template) { + let searchIndex = 0; + let templateIndex = 0; + let starIndex = -1; + let matchIndex = 0; + + while (searchIndex < search.length) { + if (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === '*')) { + // Match character or proceed with wildcard + if (template[templateIndex] === '*') { + starIndex = templateIndex; + matchIndex = searchIndex; + templateIndex++; // Skip the '*' + } else { + searchIndex++; + templateIndex++; + } + } else if (starIndex !== -1) { // eslint-disable-line no-negated-condition + // Backtrack to the last '*' and try to match more characters + templateIndex = starIndex + 1; + matchIndex++; + searchIndex = matchIndex; + } else { + return false; // No match + } + } + + // Handle trailing '*' in template + while (templateIndex < template.length && template[templateIndex] === '*') { + templateIndex++; + } + + return templateIndex === template.length; + } + + /** + * Disable debug output. + * + * @return {String} namespaces + * @api public + */ + function disable() { + const namespaces = [ + ...createDebug.names, + ...createDebug.skips.map(namespace => '-' + namespace) + ].join(','); + createDebug.enable(''); + return namespaces; + } + + /** + * Returns true if the given mode name is enabled, false otherwise. + * + * @param {String} name + * @return {Boolean} + * @api public + */ + function enabled(name) { + for (const skip of createDebug.skips) { + if (matchesTemplate(name, skip)) { + return false; + } + } + + for (const ns of createDebug.names) { + if (matchesTemplate(name, ns)) { + return true; + } + } + + return false; + } + + /** + * Coerce `val`. + * + * @param {Mixed} val + * @return {Mixed} + * @api private + */ + function coerce(val) { + if (val instanceof Error) { + return val.stack || val.message; + } + return val; + } + + /** + * XXX DO NOT USE. This is a temporary stub function. + * XXX It WILL be removed in the next major release. + */ + function destroy() { + console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'); + } + + createDebug.enable(createDebug.load()); + + return createDebug; +} + +module.exports = setup; diff --git a/sandbox/tgbot/node_modules/debug/src/index.js b/sandbox/tgbot/node_modules/debug/src/index.js new file mode 100644 index 0000000..bf4c57f --- /dev/null +++ b/sandbox/tgbot/node_modules/debug/src/index.js @@ -0,0 +1,10 @@ +/** + * Detect Electron renderer / nwjs process, which is node, but we should + * treat as a browser. + */ + +if (typeof process === 'undefined' || process.type === 'renderer' || process.browser === true || process.__nwjs) { + module.exports = require('./browser.js'); +} else { + module.exports = require('./node.js'); +} diff --git a/sandbox/tgbot/node_modules/debug/src/node.js b/sandbox/tgbot/node_modules/debug/src/node.js new file mode 100644 index 0000000..715560a --- /dev/null +++ b/sandbox/tgbot/node_modules/debug/src/node.js @@ -0,0 +1,263 @@ +/** + * Module dependencies. + */ + +const tty = require('tty'); +const util = require('util'); + +/** + * This is the Node.js implementation of `debug()`. + */ + +exports.init = init; +exports.log = log; +exports.formatArgs = formatArgs; +exports.save = save; +exports.load = load; +exports.useColors = useColors; +exports.destroy = util.deprecate( + () => {}, + 'Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.' +); + +/** + * Colors. + */ + +exports.colors = [6, 2, 3, 4, 5, 1]; + +try { + // Optional dependency (as in, doesn't need to be installed, NOT like optionalDependencies in package.json) + // eslint-disable-next-line import/no-extraneous-dependencies + const supportsColor = require('supports-color'); + + if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) { + exports.colors = [ + 20, + 21, + 26, + 27, + 32, + 33, + 38, + 39, + 40, + 41, + 42, + 43, + 44, + 45, + 56, + 57, + 62, + 63, + 68, + 69, + 74, + 75, + 76, + 77, + 78, + 79, + 80, + 81, + 92, + 93, + 98, + 99, + 112, + 113, + 128, + 129, + 134, + 135, + 148, + 149, + 160, + 161, + 162, + 163, + 164, + 165, + 166, + 167, + 168, + 169, + 170, + 171, + 172, + 173, + 178, + 179, + 184, + 185, + 196, + 197, + 198, + 199, + 200, + 201, + 202, + 203, + 204, + 205, + 206, + 207, + 208, + 209, + 214, + 215, + 220, + 221 + ]; + } +} catch (error) { + // Swallow - we only care if `supports-color` is available; it doesn't have to be. +} + +/** + * Build up the default `inspectOpts` object from the environment variables. + * + * $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js + */ + +exports.inspectOpts = Object.keys(process.env).filter(key => { + return /^debug_/i.test(key); +}).reduce((obj, key) => { + // Camel-case + const prop = key + .substring(6) + .toLowerCase() + .replace(/_([a-z])/g, (_, k) => { + return k.toUpperCase(); + }); + + // Coerce string value into JS value + let val = process.env[key]; + if (/^(yes|on|true|enabled)$/i.test(val)) { + val = true; + } else if (/^(no|off|false|disabled)$/i.test(val)) { + val = false; + } else if (val === 'null') { + val = null; + } else { + val = Number(val); + } + + obj[prop] = val; + return obj; +}, {}); + +/** + * Is stdout a TTY? Colored output is enabled when `true`. + */ + +function useColors() { + return 'colors' in exports.inspectOpts ? + Boolean(exports.inspectOpts.colors) : + tty.isatty(process.stderr.fd); +} + +/** + * Adds ANSI color escape codes if enabled. + * + * @api public + */ + +function formatArgs(args) { + const {namespace: name, useColors} = this; + + if (useColors) { + const c = this.color; + const colorCode = '\u001B[3' + (c < 8 ? c : '8;5;' + c); + const prefix = ` ${colorCode};1m${name} \u001B[0m`; + + args[0] = prefix + args[0].split('\n').join('\n' + prefix); + args.push(colorCode + 'm+' + module.exports.humanize(this.diff) + '\u001B[0m'); + } else { + args[0] = getDate() + name + ' ' + args[0]; + } +} + +function getDate() { + if (exports.inspectOpts.hideDate) { + return ''; + } + return new Date().toISOString() + ' '; +} + +/** + * Invokes `util.formatWithOptions()` with the specified arguments and writes to stderr. + */ + +function log(...args) { + return process.stderr.write(util.formatWithOptions(exports.inspectOpts, ...args) + '\n'); +} + +/** + * Save `namespaces`. + * + * @param {String} namespaces + * @api private + */ +function save(namespaces) { + if (namespaces) { + process.env.DEBUG = namespaces; + } else { + // If you set a process.env field to null or undefined, it gets cast to the + // string 'null' or 'undefined'. Just delete instead. + delete process.env.DEBUG; + } +} + +/** + * Load `namespaces`. + * + * @return {String} returns the previously persisted debug modes + * @api private + */ + +function load() { + return process.env.DEBUG; +} + +/** + * Init logic for `debug` instances. + * + * Create a new `inspectOpts` object in case `useColors` is set + * differently for a particular `debug` instance. + */ + +function init(debug) { + debug.inspectOpts = {}; + + const keys = Object.keys(exports.inspectOpts); + for (let i = 0; i < keys.length; i++) { + debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]]; + } +} + +module.exports = require('./common')(exports); + +const {formatters} = module.exports; + +/** + * Map %o to `util.inspect()`, all on a single line. + */ + +formatters.o = function (v) { + this.inspectOpts.colors = this.useColors; + return util.inspect(v, this.inspectOpts) + .split('\n') + .map(str => str.trim()) + .join(' '); +}; + +/** + * Map %O to `util.inspect()`, allowing multiple lines if needed. + */ + +formatters.O = function (v) { + this.inspectOpts.colors = this.useColors; + return util.inspect(v, this.inspectOpts); +}; diff --git a/sandbox/tgbot/node_modules/event-target-shim/LICENSE b/sandbox/tgbot/node_modules/event-target-shim/LICENSE new file mode 100644 index 0000000..c39e694 --- /dev/null +++ b/sandbox/tgbot/node_modules/event-target-shim/LICENSE @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) 2015 Toru Nagashima + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + diff --git a/sandbox/tgbot/node_modules/event-target-shim/README.md b/sandbox/tgbot/node_modules/event-target-shim/README.md new file mode 100644 index 0000000..a4f9c1b --- /dev/null +++ b/sandbox/tgbot/node_modules/event-target-shim/README.md @@ -0,0 +1,293 @@ +# event-target-shim + +[![npm version](https://img.shields.io/npm/v/event-target-shim.svg)](https://www.npmjs.com/package/event-target-shim) +[![Downloads/month](https://img.shields.io/npm/dm/event-target-shim.svg)](http://www.npmtrends.com/event-target-shim) +[![Build Status](https://travis-ci.org/mysticatea/event-target-shim.svg?branch=master)](https://travis-ci.org/mysticatea/event-target-shim) +[![Coverage Status](https://codecov.io/gh/mysticatea/event-target-shim/branch/master/graph/badge.svg)](https://codecov.io/gh/mysticatea/event-target-shim) +[![Dependency Status](https://david-dm.org/mysticatea/event-target-shim.svg)](https://david-dm.org/mysticatea/event-target-shim) + +An implementation of [WHATWG EventTarget interface](https://dom.spec.whatwg.org/#interface-eventtarget), plus few extensions. + +- This provides `EventTarget` constructor that can inherit for your custom object. +- This provides an utility that defines properties of attribute listeners (e.g. `obj.onclick`). + +```js +import {EventTarget, defineEventAttribute} from "event-target-shim" + +class Foo extends EventTarget { + // ... +} + +// Define `foo.onhello` property. +defineEventAttribute(Foo.prototype, "hello") + +// Use +const foo = new Foo() +foo.addEventListener("hello", e => console.log("hello", e)) +foo.onhello = e => console.log("onhello:", e) +foo.dispatchEvent(new CustomEvent("hello")) +``` + +## 💿 Installation + +Use [npm](https://www.npmjs.com/) to install then use a bundler. + +``` +npm install event-target-shim +``` + +Or download from [`dist` directory](./dist). + +- [dist/event-target-shim.mjs](dist/event-target-shim.mjs) ... ES modules version. +- [dist/event-target-shim.js](dist/event-target-shim.js) ... Common JS version. +- [dist/event-target-shim.umd.js](dist/event-target-shim.umd.js) ... UMD (Universal Module Definition) version. This is transpiled by [Babel](https://babeljs.io/) for IE 11. + +## 📖 Usage + +```js +import {EventTarget, defineEventAttribute} from "event-target-shim" +// or +const {EventTarget, defineEventAttribute} = require("event-target-shim") + +// or UMD version defines a global variable: +const {EventTarget, defineEventAttribute} = window.EventTargetShim +``` + +### EventTarget + +> https://dom.spec.whatwg.org/#interface-eventtarget + +#### eventTarget.addEventListener(type, callback, options) + +Register an event listener. + +- `type` is a string. This is the event name to register. +- `callback` is a function. This is the event listener to register. +- `options` is a boolean or an object `{ capture?: boolean, passive?: boolean, once?: boolean }`. If this is a boolean, it's same meaning as `{ capture: options }`. + - `capture` is the flag to register the event listener for capture phase. + - `passive` is the flag to ignore `event.preventDefault()` method in the event listener. + - `once` is the flag to remove the event listener automatically after the first call. + +#### eventTarget.removeEventListener(type, callback, options) + +Unregister an event listener. + +- `type` is a string. This is the event name to unregister. +- `callback` is a function. This is the event listener to unregister. +- `options` is a boolean or an object `{ capture?: boolean }`. If this is a boolean, it's same meaning as `{ capture: options }`. + - `capture` is the flag to register the event listener for capture phase. + +#### eventTarget.dispatchEvent(event) + +Dispatch an event. + +- `event` is a [Event](https://dom.spec.whatwg.org/#event) object or an object `{ type: string, [key: string]: any }`. The latter is non-standard but useful. In both cases, listeners receive the event as implementing [Event](https://dom.spec.whatwg.org/#event) interface. + +### defineEventAttribute(proto, type) + +Define an event attribute (e.g. `onclick`) to `proto`. This is non-standard. + +- `proto` is an object (assuming it's a prototype object). This function defines a getter/setter pair for the event attribute. +- `type` is a string. This is the event name to define. + +For example: + +```js +class AbortSignal extends EventTarget { + constructor() { + this.aborted = false + } +} +// Define `onabort` property. +defineEventAttribute(AbortSignal.prototype, "abort") +``` + +### EventTarget(types) + +Define a custom `EventTarget` class with event attributes. This is non-standard. + +- `types` is a string or an array of strings. This is the event name to define. + +For example: + +```js +// This has `onabort` property. +class AbortSignal extends EventTarget("abort") { + constructor() { + this.aborted = false + } +} +``` + +## 📚 Examples + +### ES2015 and later + +> https://jsfiddle.net/636vea92/ + +```js +const {EventTarget, defineEventAttribute} = EventTargetShim + +// Define a derived class. +class Foo extends EventTarget { + // ... +} + +// Define `foo.onhello` property. +defineEventAttribute(Foo.prototype, "hello") + +// Register event listeners. +const foo = new Foo() +foo.addEventListener("hello", (e) => { + console.log("hello", e) +}) +foo.onhello = (e) => { + console.log("onhello", e) +} + +// Dispatching events +foo.dispatchEvent(new CustomEvent("hello", { detail: "detail" })) +``` + +### Typescript + +```ts +import { EventTarget, defineEventAttribute } from "event-target-shim"; + +// Define events +type FooEvents = { + hello: CustomEvent +} +type FooEventAttributes = { + onhello: CustomEvent +} + +// Define a derived class. +class Foo extends EventTarget { + // ... +} +// Define `foo.onhello` property's implementation. +defineEventAttribute(Foo.prototype, "hello") + +// Register event listeners. +const foo = new Foo() +foo.addEventListener("hello", (e) => { + console.log("hello", e.detail) +}) +foo.onhello = (e) => { + console.log("onhello", e.detail) +} + +// Dispatching events +foo.dispatchEvent(new CustomEvent("hello", { detail: "detail" })) +``` + +Unfortunately, both `FooEvents` and `FooEventAttributes` are needed because TypeScript doesn't allow the mutation of string literal types. If TypeScript allowed us to compute `"onhello"` from `"hello"` in types, `FooEventAttributes` will be optional. + +This `EventTarget` type is compatible with `EventTarget` interface of `lib.dom.d.ts`. + +#### To disallow unknown events + +By default, methods such as `addEventListener` accept unknown events. You can disallow unknown events by the third type parameter `"strict"`. + +```ts +type FooEvents = { + hello: CustomEvent +} +class Foo extends EventTarget { + // ... +} + +// OK because `hello` is defined in FooEvents. +foo.addEventListener("hello", (e) => { +}) +// Error because `unknown` is not defined in FooEvents. +foo.addEventListener("unknown", (e) => { +}) +``` + +However, if you use `"strict"` parameter, it loses compatibility with `EventTarget` interface of `lib.dom.d.ts`. + +#### To infer the type of `dispatchEvent()` method + +TypeScript cannot infer the event type of `dispatchEvent()` method properly from the argument in most cases. You can improve this behavior with the following steps: + +1. Use the third type parameter `"strict"`. This prevents inferring to `dispatchEvent()`. +2. Make the `type` property of event definitions stricter. + +```ts +type FooEvents = { + hello: CustomEvent & { type: "hello" } + hey: Event & { type: "hey" } +} +class Foo extends EventTarget { + // ... +} + +// Error because `detail` property is lacking. +foo.dispatchEvent({ type: "hello" }) +``` + +### ES5 + +> https://jsfiddle.net/522zc9de/ + +```js +// Define a derived class. +function Foo() { + EventTarget.call(this) +} +Foo.prototype = Object.create(EventTarget.prototype, { + constructor: { value: Foo, configurable: true, writable: true } + // ... +}) + +// Define `foo.onhello` property. +defineEventAttribute(Foo.prototype, "hello") + +// Register event listeners. +var foo = new Foo() +foo.addEventListener("hello", function(e) { + console.log("hello", e) +}) +foo.onhello = function(e) { + console.log("onhello", e) +} + +// Dispatching events +function isSupportEventConstrucor() { // IE does not support. + try { + new CusomEvent("hello") + return true + } catch (_err) { + return false + } +} +if (isSupportEventConstrucor()) { + foo.dispatchEvent(new CustomEvent("hello", { detail: "detail" })) +} else { + var e = document.createEvent("CustomEvent") + e.initCustomEvent("hello", false, false, "detail") + foo.dispatchEvent(e) +} +``` + +## 📰 Changelog + +- See [GitHub releases](https://github.com/mysticatea/event-target-shim/releases). + +## 🍻 Contributing + +Contributing is welcome ❤️ + +Please use GitHub issues/PRs. + +### Development tools + +- `npm install` installs dependencies for development. +- `npm test` runs tests and measures code coverage. +- `npm run clean` removes temporary files of tests. +- `npm run coverage` opens code coverage of the previous test with your default browser. +- `npm run lint` runs ESLint. +- `npm run build` generates `dist` codes. +- `npm run watch` runs tests on each file change. diff --git a/sandbox/tgbot/node_modules/event-target-shim/dist/event-target-shim.js b/sandbox/tgbot/node_modules/event-target-shim/dist/event-target-shim.js new file mode 100644 index 0000000..53ce220 --- /dev/null +++ b/sandbox/tgbot/node_modules/event-target-shim/dist/event-target-shim.js @@ -0,0 +1,871 @@ +/** + * @author Toru Nagashima + * @copyright 2015 Toru Nagashima. All rights reserved. + * See LICENSE file in root directory for full license. + */ +'use strict'; + +Object.defineProperty(exports, '__esModule', { value: true }); + +/** + * @typedef {object} PrivateData + * @property {EventTarget} eventTarget The event target. + * @property {{type:string}} event The original event object. + * @property {number} eventPhase The current event phase. + * @property {EventTarget|null} currentTarget The current event target. + * @property {boolean} canceled The flag to prevent default. + * @property {boolean} stopped The flag to stop propagation. + * @property {boolean} immediateStopped The flag to stop propagation immediately. + * @property {Function|null} passiveListener The listener if the current listener is passive. Otherwise this is null. + * @property {number} timeStamp The unix time. + * @private + */ + +/** + * Private data for event wrappers. + * @type {WeakMap} + * @private + */ +const privateData = new WeakMap(); + +/** + * Cache for wrapper classes. + * @type {WeakMap} + * @private + */ +const wrappers = new WeakMap(); + +/** + * Get private data. + * @param {Event} event The event object to get private data. + * @returns {PrivateData} The private data of the event. + * @private + */ +function pd(event) { + const retv = privateData.get(event); + console.assert( + retv != null, + "'this' is expected an Event object, but got", + event + ); + return retv +} + +/** + * https://dom.spec.whatwg.org/#set-the-canceled-flag + * @param data {PrivateData} private data. + */ +function setCancelFlag(data) { + if (data.passiveListener != null) { + if ( + typeof console !== "undefined" && + typeof console.error === "function" + ) { + console.error( + "Unable to preventDefault inside passive event listener invocation.", + data.passiveListener + ); + } + return + } + if (!data.event.cancelable) { + return + } + + data.canceled = true; + if (typeof data.event.preventDefault === "function") { + data.event.preventDefault(); + } +} + +/** + * @see https://dom.spec.whatwg.org/#interface-event + * @private + */ +/** + * The event wrapper. + * @constructor + * @param {EventTarget} eventTarget The event target of this dispatching. + * @param {Event|{type:string}} event The original event to wrap. + */ +function Event(eventTarget, event) { + privateData.set(this, { + eventTarget, + event, + eventPhase: 2, + currentTarget: eventTarget, + canceled: false, + stopped: false, + immediateStopped: false, + passiveListener: null, + timeStamp: event.timeStamp || Date.now(), + }); + + // https://heycam.github.io/webidl/#Unforgeable + Object.defineProperty(this, "isTrusted", { value: false, enumerable: true }); + + // Define accessors + const keys = Object.keys(event); + for (let i = 0; i < keys.length; ++i) { + const key = keys[i]; + if (!(key in this)) { + Object.defineProperty(this, key, defineRedirectDescriptor(key)); + } + } +} + +// Should be enumerable, but class methods are not enumerable. +Event.prototype = { + /** + * The type of this event. + * @type {string} + */ + get type() { + return pd(this).event.type + }, + + /** + * The target of this event. + * @type {EventTarget} + */ + get target() { + return pd(this).eventTarget + }, + + /** + * The target of this event. + * @type {EventTarget} + */ + get currentTarget() { + return pd(this).currentTarget + }, + + /** + * @returns {EventTarget[]} The composed path of this event. + */ + composedPath() { + const currentTarget = pd(this).currentTarget; + if (currentTarget == null) { + return [] + } + return [currentTarget] + }, + + /** + * Constant of NONE. + * @type {number} + */ + get NONE() { + return 0 + }, + + /** + * Constant of CAPTURING_PHASE. + * @type {number} + */ + get CAPTURING_PHASE() { + return 1 + }, + + /** + * Constant of AT_TARGET. + * @type {number} + */ + get AT_TARGET() { + return 2 + }, + + /** + * Constant of BUBBLING_PHASE. + * @type {number} + */ + get BUBBLING_PHASE() { + return 3 + }, + + /** + * The target of this event. + * @type {number} + */ + get eventPhase() { + return pd(this).eventPhase + }, + + /** + * Stop event bubbling. + * @returns {void} + */ + stopPropagation() { + const data = pd(this); + + data.stopped = true; + if (typeof data.event.stopPropagation === "function") { + data.event.stopPropagation(); + } + }, + + /** + * Stop event bubbling. + * @returns {void} + */ + stopImmediatePropagation() { + const data = pd(this); + + data.stopped = true; + data.immediateStopped = true; + if (typeof data.event.stopImmediatePropagation === "function") { + data.event.stopImmediatePropagation(); + } + }, + + /** + * The flag to be bubbling. + * @type {boolean} + */ + get bubbles() { + return Boolean(pd(this).event.bubbles) + }, + + /** + * The flag to be cancelable. + * @type {boolean} + */ + get cancelable() { + return Boolean(pd(this).event.cancelable) + }, + + /** + * Cancel this event. + * @returns {void} + */ + preventDefault() { + setCancelFlag(pd(this)); + }, + + /** + * The flag to indicate cancellation state. + * @type {boolean} + */ + get defaultPrevented() { + return pd(this).canceled + }, + + /** + * The flag to be composed. + * @type {boolean} + */ + get composed() { + return Boolean(pd(this).event.composed) + }, + + /** + * The unix time of this event. + * @type {number} + */ + get timeStamp() { + return pd(this).timeStamp + }, + + /** + * The target of this event. + * @type {EventTarget} + * @deprecated + */ + get srcElement() { + return pd(this).eventTarget + }, + + /** + * The flag to stop event bubbling. + * @type {boolean} + * @deprecated + */ + get cancelBubble() { + return pd(this).stopped + }, + set cancelBubble(value) { + if (!value) { + return + } + const data = pd(this); + + data.stopped = true; + if (typeof data.event.cancelBubble === "boolean") { + data.event.cancelBubble = true; + } + }, + + /** + * The flag to indicate cancellation state. + * @type {boolean} + * @deprecated + */ + get returnValue() { + return !pd(this).canceled + }, + set returnValue(value) { + if (!value) { + setCancelFlag(pd(this)); + } + }, + + /** + * Initialize this event object. But do nothing under event dispatching. + * @param {string} type The event type. + * @param {boolean} [bubbles=false] The flag to be possible to bubble up. + * @param {boolean} [cancelable=false] The flag to be possible to cancel. + * @deprecated + */ + initEvent() { + // Do nothing. + }, +}; + +// `constructor` is not enumerable. +Object.defineProperty(Event.prototype, "constructor", { + value: Event, + configurable: true, + writable: true, +}); + +// Ensure `event instanceof window.Event` is `true`. +if (typeof window !== "undefined" && typeof window.Event !== "undefined") { + Object.setPrototypeOf(Event.prototype, window.Event.prototype); + + // Make association for wrappers. + wrappers.set(window.Event.prototype, Event); +} + +/** + * Get the property descriptor to redirect a given property. + * @param {string} key Property name to define property descriptor. + * @returns {PropertyDescriptor} The property descriptor to redirect the property. + * @private + */ +function defineRedirectDescriptor(key) { + return { + get() { + return pd(this).event[key] + }, + set(value) { + pd(this).event[key] = value; + }, + configurable: true, + enumerable: true, + } +} + +/** + * Get the property descriptor to call a given method property. + * @param {string} key Property name to define property descriptor. + * @returns {PropertyDescriptor} The property descriptor to call the method property. + * @private + */ +function defineCallDescriptor(key) { + return { + value() { + const event = pd(this).event; + return event[key].apply(event, arguments) + }, + configurable: true, + enumerable: true, + } +} + +/** + * Define new wrapper class. + * @param {Function} BaseEvent The base wrapper class. + * @param {Object} proto The prototype of the original event. + * @returns {Function} The defined wrapper class. + * @private + */ +function defineWrapper(BaseEvent, proto) { + const keys = Object.keys(proto); + if (keys.length === 0) { + return BaseEvent + } + + /** CustomEvent */ + function CustomEvent(eventTarget, event) { + BaseEvent.call(this, eventTarget, event); + } + + CustomEvent.prototype = Object.create(BaseEvent.prototype, { + constructor: { value: CustomEvent, configurable: true, writable: true }, + }); + + // Define accessors. + for (let i = 0; i < keys.length; ++i) { + const key = keys[i]; + if (!(key in BaseEvent.prototype)) { + const descriptor = Object.getOwnPropertyDescriptor(proto, key); + const isFunc = typeof descriptor.value === "function"; + Object.defineProperty( + CustomEvent.prototype, + key, + isFunc + ? defineCallDescriptor(key) + : defineRedirectDescriptor(key) + ); + } + } + + return CustomEvent +} + +/** + * Get the wrapper class of a given prototype. + * @param {Object} proto The prototype of the original event to get its wrapper. + * @returns {Function} The wrapper class. + * @private + */ +function getWrapper(proto) { + if (proto == null || proto === Object.prototype) { + return Event + } + + let wrapper = wrappers.get(proto); + if (wrapper == null) { + wrapper = defineWrapper(getWrapper(Object.getPrototypeOf(proto)), proto); + wrappers.set(proto, wrapper); + } + return wrapper +} + +/** + * Wrap a given event to management a dispatching. + * @param {EventTarget} eventTarget The event target of this dispatching. + * @param {Object} event The event to wrap. + * @returns {Event} The wrapper instance. + * @private + */ +function wrapEvent(eventTarget, event) { + const Wrapper = getWrapper(Object.getPrototypeOf(event)); + return new Wrapper(eventTarget, event) +} + +/** + * Get the immediateStopped flag of a given event. + * @param {Event} event The event to get. + * @returns {boolean} The flag to stop propagation immediately. + * @private + */ +function isStopped(event) { + return pd(event).immediateStopped +} + +/** + * Set the current event phase of a given event. + * @param {Event} event The event to set current target. + * @param {number} eventPhase New event phase. + * @returns {void} + * @private + */ +function setEventPhase(event, eventPhase) { + pd(event).eventPhase = eventPhase; +} + +/** + * Set the current target of a given event. + * @param {Event} event The event to set current target. + * @param {EventTarget|null} currentTarget New current target. + * @returns {void} + * @private + */ +function setCurrentTarget(event, currentTarget) { + pd(event).currentTarget = currentTarget; +} + +/** + * Set a passive listener of a given event. + * @param {Event} event The event to set current target. + * @param {Function|null} passiveListener New passive listener. + * @returns {void} + * @private + */ +function setPassiveListener(event, passiveListener) { + pd(event).passiveListener = passiveListener; +} + +/** + * @typedef {object} ListenerNode + * @property {Function} listener + * @property {1|2|3} listenerType + * @property {boolean} passive + * @property {boolean} once + * @property {ListenerNode|null} next + * @private + */ + +/** + * @type {WeakMap>} + * @private + */ +const listenersMap = new WeakMap(); + +// Listener types +const CAPTURE = 1; +const BUBBLE = 2; +const ATTRIBUTE = 3; + +/** + * Check whether a given value is an object or not. + * @param {any} x The value to check. + * @returns {boolean} `true` if the value is an object. + */ +function isObject(x) { + return x !== null && typeof x === "object" //eslint-disable-line no-restricted-syntax +} + +/** + * Get listeners. + * @param {EventTarget} eventTarget The event target to get. + * @returns {Map} The listeners. + * @private + */ +function getListeners(eventTarget) { + const listeners = listenersMap.get(eventTarget); + if (listeners == null) { + throw new TypeError( + "'this' is expected an EventTarget object, but got another value." + ) + } + return listeners +} + +/** + * Get the property descriptor for the event attribute of a given event. + * @param {string} eventName The event name to get property descriptor. + * @returns {PropertyDescriptor} The property descriptor. + * @private + */ +function defineEventAttributeDescriptor(eventName) { + return { + get() { + const listeners = getListeners(this); + let node = listeners.get(eventName); + while (node != null) { + if (node.listenerType === ATTRIBUTE) { + return node.listener + } + node = node.next; + } + return null + }, + + set(listener) { + if (typeof listener !== "function" && !isObject(listener)) { + listener = null; // eslint-disable-line no-param-reassign + } + const listeners = getListeners(this); + + // Traverse to the tail while removing old value. + let prev = null; + let node = listeners.get(eventName); + while (node != null) { + if (node.listenerType === ATTRIBUTE) { + // Remove old value. + if (prev !== null) { + prev.next = node.next; + } else if (node.next !== null) { + listeners.set(eventName, node.next); + } else { + listeners.delete(eventName); + } + } else { + prev = node; + } + + node = node.next; + } + + // Add new value. + if (listener !== null) { + const newNode = { + listener, + listenerType: ATTRIBUTE, + passive: false, + once: false, + next: null, + }; + if (prev === null) { + listeners.set(eventName, newNode); + } else { + prev.next = newNode; + } + } + }, + configurable: true, + enumerable: true, + } +} + +/** + * Define an event attribute (e.g. `eventTarget.onclick`). + * @param {Object} eventTargetPrototype The event target prototype to define an event attrbite. + * @param {string} eventName The event name to define. + * @returns {void} + */ +function defineEventAttribute(eventTargetPrototype, eventName) { + Object.defineProperty( + eventTargetPrototype, + `on${eventName}`, + defineEventAttributeDescriptor(eventName) + ); +} + +/** + * Define a custom EventTarget with event attributes. + * @param {string[]} eventNames Event names for event attributes. + * @returns {EventTarget} The custom EventTarget. + * @private + */ +function defineCustomEventTarget(eventNames) { + /** CustomEventTarget */ + function CustomEventTarget() { + EventTarget.call(this); + } + + CustomEventTarget.prototype = Object.create(EventTarget.prototype, { + constructor: { + value: CustomEventTarget, + configurable: true, + writable: true, + }, + }); + + for (let i = 0; i < eventNames.length; ++i) { + defineEventAttribute(CustomEventTarget.prototype, eventNames[i]); + } + + return CustomEventTarget +} + +/** + * EventTarget. + * + * - This is constructor if no arguments. + * - This is a function which returns a CustomEventTarget constructor if there are arguments. + * + * For example: + * + * class A extends EventTarget {} + * class B extends EventTarget("message") {} + * class C extends EventTarget("message", "error") {} + * class D extends EventTarget(["message", "error"]) {} + */ +function EventTarget() { + /*eslint-disable consistent-return */ + if (this instanceof EventTarget) { + listenersMap.set(this, new Map()); + return + } + if (arguments.length === 1 && Array.isArray(arguments[0])) { + return defineCustomEventTarget(arguments[0]) + } + if (arguments.length > 0) { + const types = new Array(arguments.length); + for (let i = 0; i < arguments.length; ++i) { + types[i] = arguments[i]; + } + return defineCustomEventTarget(types) + } + throw new TypeError("Cannot call a class as a function") + /*eslint-enable consistent-return */ +} + +// Should be enumerable, but class methods are not enumerable. +EventTarget.prototype = { + /** + * Add a given listener to this event target. + * @param {string} eventName The event name to add. + * @param {Function} listener The listener to add. + * @param {boolean|{capture?:boolean,passive?:boolean,once?:boolean}} [options] The options for this listener. + * @returns {void} + */ + addEventListener(eventName, listener, options) { + if (listener == null) { + return + } + if (typeof listener !== "function" && !isObject(listener)) { + throw new TypeError("'listener' should be a function or an object.") + } + + const listeners = getListeners(this); + const optionsIsObj = isObject(options); + const capture = optionsIsObj + ? Boolean(options.capture) + : Boolean(options); + const listenerType = capture ? CAPTURE : BUBBLE; + const newNode = { + listener, + listenerType, + passive: optionsIsObj && Boolean(options.passive), + once: optionsIsObj && Boolean(options.once), + next: null, + }; + + // Set it as the first node if the first node is null. + let node = listeners.get(eventName); + if (node === undefined) { + listeners.set(eventName, newNode); + return + } + + // Traverse to the tail while checking duplication.. + let prev = null; + while (node != null) { + if ( + node.listener === listener && + node.listenerType === listenerType + ) { + // Should ignore duplication. + return + } + prev = node; + node = node.next; + } + + // Add it. + prev.next = newNode; + }, + + /** + * Remove a given listener from this event target. + * @param {string} eventName The event name to remove. + * @param {Function} listener The listener to remove. + * @param {boolean|{capture?:boolean,passive?:boolean,once?:boolean}} [options] The options for this listener. + * @returns {void} + */ + removeEventListener(eventName, listener, options) { + if (listener == null) { + return + } + + const listeners = getListeners(this); + const capture = isObject(options) + ? Boolean(options.capture) + : Boolean(options); + const listenerType = capture ? CAPTURE : BUBBLE; + + let prev = null; + let node = listeners.get(eventName); + while (node != null) { + if ( + node.listener === listener && + node.listenerType === listenerType + ) { + if (prev !== null) { + prev.next = node.next; + } else if (node.next !== null) { + listeners.set(eventName, node.next); + } else { + listeners.delete(eventName); + } + return + } + + prev = node; + node = node.next; + } + }, + + /** + * Dispatch a given event. + * @param {Event|{type:string}} event The event to dispatch. + * @returns {boolean} `false` if canceled. + */ + dispatchEvent(event) { + if (event == null || typeof event.type !== "string") { + throw new TypeError('"event.type" should be a string.') + } + + // If listeners aren't registered, terminate. + const listeners = getListeners(this); + const eventName = event.type; + let node = listeners.get(eventName); + if (node == null) { + return true + } + + // Since we cannot rewrite several properties, so wrap object. + const wrappedEvent = wrapEvent(this, event); + + // This doesn't process capturing phase and bubbling phase. + // This isn't participating in a tree. + let prev = null; + while (node != null) { + // Remove this listener if it's once + if (node.once) { + if (prev !== null) { + prev.next = node.next; + } else if (node.next !== null) { + listeners.set(eventName, node.next); + } else { + listeners.delete(eventName); + } + } else { + prev = node; + } + + // Call this listener + setPassiveListener( + wrappedEvent, + node.passive ? node.listener : null + ); + if (typeof node.listener === "function") { + try { + node.listener.call(this, wrappedEvent); + } catch (err) { + if ( + typeof console !== "undefined" && + typeof console.error === "function" + ) { + console.error(err); + } + } + } else if ( + node.listenerType !== ATTRIBUTE && + typeof node.listener.handleEvent === "function" + ) { + node.listener.handleEvent(wrappedEvent); + } + + // Break if `event.stopImmediatePropagation` was called. + if (isStopped(wrappedEvent)) { + break + } + + node = node.next; + } + setPassiveListener(wrappedEvent, null); + setEventPhase(wrappedEvent, 0); + setCurrentTarget(wrappedEvent, null); + + return !wrappedEvent.defaultPrevented + }, +}; + +// `constructor` is not enumerable. +Object.defineProperty(EventTarget.prototype, "constructor", { + value: EventTarget, + configurable: true, + writable: true, +}); + +// Ensure `eventTarget instanceof window.EventTarget` is `true`. +if ( + typeof window !== "undefined" && + typeof window.EventTarget !== "undefined" +) { + Object.setPrototypeOf(EventTarget.prototype, window.EventTarget.prototype); +} + +exports.defineEventAttribute = defineEventAttribute; +exports.EventTarget = EventTarget; +exports.default = EventTarget; + +module.exports = EventTarget +module.exports.EventTarget = module.exports["default"] = EventTarget +module.exports.defineEventAttribute = defineEventAttribute +//# sourceMappingURL=event-target-shim.js.map diff --git a/sandbox/tgbot/node_modules/event-target-shim/dist/event-target-shim.js.map b/sandbox/tgbot/node_modules/event-target-shim/dist/event-target-shim.js.map new file mode 100644 index 0000000..83c5f62 --- /dev/null +++ b/sandbox/tgbot/node_modules/event-target-shim/dist/event-target-shim.js.map @@ -0,0 +1 @@ +{"version":3,"file":"event-target-shim.js","sources":["../src/event.mjs","../src/event-target.mjs"],"sourcesContent":["/**\n * @typedef {object} PrivateData\n * @property {EventTarget} eventTarget The event target.\n * @property {{type:string}} event The original event object.\n * @property {number} eventPhase The current event phase.\n * @property {EventTarget|null} currentTarget The current event target.\n * @property {boolean} canceled The flag to prevent default.\n * @property {boolean} stopped The flag to stop propagation.\n * @property {boolean} immediateStopped The flag to stop propagation immediately.\n * @property {Function|null} passiveListener The listener if the current listener is passive. Otherwise this is null.\n * @property {number} timeStamp The unix time.\n * @private\n */\n\n/**\n * Private data for event wrappers.\n * @type {WeakMap}\n * @private\n */\nconst privateData = new WeakMap()\n\n/**\n * Cache for wrapper classes.\n * @type {WeakMap}\n * @private\n */\nconst wrappers = new WeakMap()\n\n/**\n * Get private data.\n * @param {Event} event The event object to get private data.\n * @returns {PrivateData} The private data of the event.\n * @private\n */\nfunction pd(event) {\n const retv = privateData.get(event)\n console.assert(\n retv != null,\n \"'this' is expected an Event object, but got\",\n event\n )\n return retv\n}\n\n/**\n * https://dom.spec.whatwg.org/#set-the-canceled-flag\n * @param data {PrivateData} private data.\n */\nfunction setCancelFlag(data) {\n if (data.passiveListener != null) {\n if (\n typeof console !== \"undefined\" &&\n typeof console.error === \"function\"\n ) {\n console.error(\n \"Unable to preventDefault inside passive event listener invocation.\",\n data.passiveListener\n )\n }\n return\n }\n if (!data.event.cancelable) {\n return\n }\n\n data.canceled = true\n if (typeof data.event.preventDefault === \"function\") {\n data.event.preventDefault()\n }\n}\n\n/**\n * @see https://dom.spec.whatwg.org/#interface-event\n * @private\n */\n/**\n * The event wrapper.\n * @constructor\n * @param {EventTarget} eventTarget The event target of this dispatching.\n * @param {Event|{type:string}} event The original event to wrap.\n */\nfunction Event(eventTarget, event) {\n privateData.set(this, {\n eventTarget,\n event,\n eventPhase: 2,\n currentTarget: eventTarget,\n canceled: false,\n stopped: false,\n immediateStopped: false,\n passiveListener: null,\n timeStamp: event.timeStamp || Date.now(),\n })\n\n // https://heycam.github.io/webidl/#Unforgeable\n Object.defineProperty(this, \"isTrusted\", { value: false, enumerable: true })\n\n // Define accessors\n const keys = Object.keys(event)\n for (let i = 0; i < keys.length; ++i) {\n const key = keys[i]\n if (!(key in this)) {\n Object.defineProperty(this, key, defineRedirectDescriptor(key))\n }\n }\n}\n\n// Should be enumerable, but class methods are not enumerable.\nEvent.prototype = {\n /**\n * The type of this event.\n * @type {string}\n */\n get type() {\n return pd(this).event.type\n },\n\n /**\n * The target of this event.\n * @type {EventTarget}\n */\n get target() {\n return pd(this).eventTarget\n },\n\n /**\n * The target of this event.\n * @type {EventTarget}\n */\n get currentTarget() {\n return pd(this).currentTarget\n },\n\n /**\n * @returns {EventTarget[]} The composed path of this event.\n */\n composedPath() {\n const currentTarget = pd(this).currentTarget\n if (currentTarget == null) {\n return []\n }\n return [currentTarget]\n },\n\n /**\n * Constant of NONE.\n * @type {number}\n */\n get NONE() {\n return 0\n },\n\n /**\n * Constant of CAPTURING_PHASE.\n * @type {number}\n */\n get CAPTURING_PHASE() {\n return 1\n },\n\n /**\n * Constant of AT_TARGET.\n * @type {number}\n */\n get AT_TARGET() {\n return 2\n },\n\n /**\n * Constant of BUBBLING_PHASE.\n * @type {number}\n */\n get BUBBLING_PHASE() {\n return 3\n },\n\n /**\n * The target of this event.\n * @type {number}\n */\n get eventPhase() {\n return pd(this).eventPhase\n },\n\n /**\n * Stop event bubbling.\n * @returns {void}\n */\n stopPropagation() {\n const data = pd(this)\n\n data.stopped = true\n if (typeof data.event.stopPropagation === \"function\") {\n data.event.stopPropagation()\n }\n },\n\n /**\n * Stop event bubbling.\n * @returns {void}\n */\n stopImmediatePropagation() {\n const data = pd(this)\n\n data.stopped = true\n data.immediateStopped = true\n if (typeof data.event.stopImmediatePropagation === \"function\") {\n data.event.stopImmediatePropagation()\n }\n },\n\n /**\n * The flag to be bubbling.\n * @type {boolean}\n */\n get bubbles() {\n return Boolean(pd(this).event.bubbles)\n },\n\n /**\n * The flag to be cancelable.\n * @type {boolean}\n */\n get cancelable() {\n return Boolean(pd(this).event.cancelable)\n },\n\n /**\n * Cancel this event.\n * @returns {void}\n */\n preventDefault() {\n setCancelFlag(pd(this))\n },\n\n /**\n * The flag to indicate cancellation state.\n * @type {boolean}\n */\n get defaultPrevented() {\n return pd(this).canceled\n },\n\n /**\n * The flag to be composed.\n * @type {boolean}\n */\n get composed() {\n return Boolean(pd(this).event.composed)\n },\n\n /**\n * The unix time of this event.\n * @type {number}\n */\n get timeStamp() {\n return pd(this).timeStamp\n },\n\n /**\n * The target of this event.\n * @type {EventTarget}\n * @deprecated\n */\n get srcElement() {\n return pd(this).eventTarget\n },\n\n /**\n * The flag to stop event bubbling.\n * @type {boolean}\n * @deprecated\n */\n get cancelBubble() {\n return pd(this).stopped\n },\n set cancelBubble(value) {\n if (!value) {\n return\n }\n const data = pd(this)\n\n data.stopped = true\n if (typeof data.event.cancelBubble === \"boolean\") {\n data.event.cancelBubble = true\n }\n },\n\n /**\n * The flag to indicate cancellation state.\n * @type {boolean}\n * @deprecated\n */\n get returnValue() {\n return !pd(this).canceled\n },\n set returnValue(value) {\n if (!value) {\n setCancelFlag(pd(this))\n }\n },\n\n /**\n * Initialize this event object. But do nothing under event dispatching.\n * @param {string} type The event type.\n * @param {boolean} [bubbles=false] The flag to be possible to bubble up.\n * @param {boolean} [cancelable=false] The flag to be possible to cancel.\n * @deprecated\n */\n initEvent() {\n // Do nothing.\n },\n}\n\n// `constructor` is not enumerable.\nObject.defineProperty(Event.prototype, \"constructor\", {\n value: Event,\n configurable: true,\n writable: true,\n})\n\n// Ensure `event instanceof window.Event` is `true`.\nif (typeof window !== \"undefined\" && typeof window.Event !== \"undefined\") {\n Object.setPrototypeOf(Event.prototype, window.Event.prototype)\n\n // Make association for wrappers.\n wrappers.set(window.Event.prototype, Event)\n}\n\n/**\n * Get the property descriptor to redirect a given property.\n * @param {string} key Property name to define property descriptor.\n * @returns {PropertyDescriptor} The property descriptor to redirect the property.\n * @private\n */\nfunction defineRedirectDescriptor(key) {\n return {\n get() {\n return pd(this).event[key]\n },\n set(value) {\n pd(this).event[key] = value\n },\n configurable: true,\n enumerable: true,\n }\n}\n\n/**\n * Get the property descriptor to call a given method property.\n * @param {string} key Property name to define property descriptor.\n * @returns {PropertyDescriptor} The property descriptor to call the method property.\n * @private\n */\nfunction defineCallDescriptor(key) {\n return {\n value() {\n const event = pd(this).event\n return event[key].apply(event, arguments)\n },\n configurable: true,\n enumerable: true,\n }\n}\n\n/**\n * Define new wrapper class.\n * @param {Function} BaseEvent The base wrapper class.\n * @param {Object} proto The prototype of the original event.\n * @returns {Function} The defined wrapper class.\n * @private\n */\nfunction defineWrapper(BaseEvent, proto) {\n const keys = Object.keys(proto)\n if (keys.length === 0) {\n return BaseEvent\n }\n\n /** CustomEvent */\n function CustomEvent(eventTarget, event) {\n BaseEvent.call(this, eventTarget, event)\n }\n\n CustomEvent.prototype = Object.create(BaseEvent.prototype, {\n constructor: { value: CustomEvent, configurable: true, writable: true },\n })\n\n // Define accessors.\n for (let i = 0; i < keys.length; ++i) {\n const key = keys[i]\n if (!(key in BaseEvent.prototype)) {\n const descriptor = Object.getOwnPropertyDescriptor(proto, key)\n const isFunc = typeof descriptor.value === \"function\"\n Object.defineProperty(\n CustomEvent.prototype,\n key,\n isFunc\n ? defineCallDescriptor(key)\n : defineRedirectDescriptor(key)\n )\n }\n }\n\n return CustomEvent\n}\n\n/**\n * Get the wrapper class of a given prototype.\n * @param {Object} proto The prototype of the original event to get its wrapper.\n * @returns {Function} The wrapper class.\n * @private\n */\nfunction getWrapper(proto) {\n if (proto == null || proto === Object.prototype) {\n return Event\n }\n\n let wrapper = wrappers.get(proto)\n if (wrapper == null) {\n wrapper = defineWrapper(getWrapper(Object.getPrototypeOf(proto)), proto)\n wrappers.set(proto, wrapper)\n }\n return wrapper\n}\n\n/**\n * Wrap a given event to management a dispatching.\n * @param {EventTarget} eventTarget The event target of this dispatching.\n * @param {Object} event The event to wrap.\n * @returns {Event} The wrapper instance.\n * @private\n */\nexport function wrapEvent(eventTarget, event) {\n const Wrapper = getWrapper(Object.getPrototypeOf(event))\n return new Wrapper(eventTarget, event)\n}\n\n/**\n * Get the immediateStopped flag of a given event.\n * @param {Event} event The event to get.\n * @returns {boolean} The flag to stop propagation immediately.\n * @private\n */\nexport function isStopped(event) {\n return pd(event).immediateStopped\n}\n\n/**\n * Set the current event phase of a given event.\n * @param {Event} event The event to set current target.\n * @param {number} eventPhase New event phase.\n * @returns {void}\n * @private\n */\nexport function setEventPhase(event, eventPhase) {\n pd(event).eventPhase = eventPhase\n}\n\n/**\n * Set the current target of a given event.\n * @param {Event} event The event to set current target.\n * @param {EventTarget|null} currentTarget New current target.\n * @returns {void}\n * @private\n */\nexport function setCurrentTarget(event, currentTarget) {\n pd(event).currentTarget = currentTarget\n}\n\n/**\n * Set a passive listener of a given event.\n * @param {Event} event The event to set current target.\n * @param {Function|null} passiveListener New passive listener.\n * @returns {void}\n * @private\n */\nexport function setPassiveListener(event, passiveListener) {\n pd(event).passiveListener = passiveListener\n}\n","import {\n isStopped,\n setCurrentTarget,\n setEventPhase,\n setPassiveListener,\n wrapEvent,\n} from \"./event.mjs\"\n\n/**\n * @typedef {object} ListenerNode\n * @property {Function} listener\n * @property {1|2|3} listenerType\n * @property {boolean} passive\n * @property {boolean} once\n * @property {ListenerNode|null} next\n * @private\n */\n\n/**\n * @type {WeakMap>}\n * @private\n */\nconst listenersMap = new WeakMap()\n\n// Listener types\nconst CAPTURE = 1\nconst BUBBLE = 2\nconst ATTRIBUTE = 3\n\n/**\n * Check whether a given value is an object or not.\n * @param {any} x The value to check.\n * @returns {boolean} `true` if the value is an object.\n */\nfunction isObject(x) {\n return x !== null && typeof x === \"object\" //eslint-disable-line no-restricted-syntax\n}\n\n/**\n * Get listeners.\n * @param {EventTarget} eventTarget The event target to get.\n * @returns {Map} The listeners.\n * @private\n */\nfunction getListeners(eventTarget) {\n const listeners = listenersMap.get(eventTarget)\n if (listeners == null) {\n throw new TypeError(\n \"'this' is expected an EventTarget object, but got another value.\"\n )\n }\n return listeners\n}\n\n/**\n * Get the property descriptor for the event attribute of a given event.\n * @param {string} eventName The event name to get property descriptor.\n * @returns {PropertyDescriptor} The property descriptor.\n * @private\n */\nfunction defineEventAttributeDescriptor(eventName) {\n return {\n get() {\n const listeners = getListeners(this)\n let node = listeners.get(eventName)\n while (node != null) {\n if (node.listenerType === ATTRIBUTE) {\n return node.listener\n }\n node = node.next\n }\n return null\n },\n\n set(listener) {\n if (typeof listener !== \"function\" && !isObject(listener)) {\n listener = null // eslint-disable-line no-param-reassign\n }\n const listeners = getListeners(this)\n\n // Traverse to the tail while removing old value.\n let prev = null\n let node = listeners.get(eventName)\n while (node != null) {\n if (node.listenerType === ATTRIBUTE) {\n // Remove old value.\n if (prev !== null) {\n prev.next = node.next\n } else if (node.next !== null) {\n listeners.set(eventName, node.next)\n } else {\n listeners.delete(eventName)\n }\n } else {\n prev = node\n }\n\n node = node.next\n }\n\n // Add new value.\n if (listener !== null) {\n const newNode = {\n listener,\n listenerType: ATTRIBUTE,\n passive: false,\n once: false,\n next: null,\n }\n if (prev === null) {\n listeners.set(eventName, newNode)\n } else {\n prev.next = newNode\n }\n }\n },\n configurable: true,\n enumerable: true,\n }\n}\n\n/**\n * Define an event attribute (e.g. `eventTarget.onclick`).\n * @param {Object} eventTargetPrototype The event target prototype to define an event attrbite.\n * @param {string} eventName The event name to define.\n * @returns {void}\n */\nfunction defineEventAttribute(eventTargetPrototype, eventName) {\n Object.defineProperty(\n eventTargetPrototype,\n `on${eventName}`,\n defineEventAttributeDescriptor(eventName)\n )\n}\n\n/**\n * Define a custom EventTarget with event attributes.\n * @param {string[]} eventNames Event names for event attributes.\n * @returns {EventTarget} The custom EventTarget.\n * @private\n */\nfunction defineCustomEventTarget(eventNames) {\n /** CustomEventTarget */\n function CustomEventTarget() {\n EventTarget.call(this)\n }\n\n CustomEventTarget.prototype = Object.create(EventTarget.prototype, {\n constructor: {\n value: CustomEventTarget,\n configurable: true,\n writable: true,\n },\n })\n\n for (let i = 0; i < eventNames.length; ++i) {\n defineEventAttribute(CustomEventTarget.prototype, eventNames[i])\n }\n\n return CustomEventTarget\n}\n\n/**\n * EventTarget.\n *\n * - This is constructor if no arguments.\n * - This is a function which returns a CustomEventTarget constructor if there are arguments.\n *\n * For example:\n *\n * class A extends EventTarget {}\n * class B extends EventTarget(\"message\") {}\n * class C extends EventTarget(\"message\", \"error\") {}\n * class D extends EventTarget([\"message\", \"error\"]) {}\n */\nfunction EventTarget() {\n /*eslint-disable consistent-return */\n if (this instanceof EventTarget) {\n listenersMap.set(this, new Map())\n return\n }\n if (arguments.length === 1 && Array.isArray(arguments[0])) {\n return defineCustomEventTarget(arguments[0])\n }\n if (arguments.length > 0) {\n const types = new Array(arguments.length)\n for (let i = 0; i < arguments.length; ++i) {\n types[i] = arguments[i]\n }\n return defineCustomEventTarget(types)\n }\n throw new TypeError(\"Cannot call a class as a function\")\n /*eslint-enable consistent-return */\n}\n\n// Should be enumerable, but class methods are not enumerable.\nEventTarget.prototype = {\n /**\n * Add a given listener to this event target.\n * @param {string} eventName The event name to add.\n * @param {Function} listener The listener to add.\n * @param {boolean|{capture?:boolean,passive?:boolean,once?:boolean}} [options] The options for this listener.\n * @returns {void}\n */\n addEventListener(eventName, listener, options) {\n if (listener == null) {\n return\n }\n if (typeof listener !== \"function\" && !isObject(listener)) {\n throw new TypeError(\"'listener' should be a function or an object.\")\n }\n\n const listeners = getListeners(this)\n const optionsIsObj = isObject(options)\n const capture = optionsIsObj\n ? Boolean(options.capture)\n : Boolean(options)\n const listenerType = capture ? CAPTURE : BUBBLE\n const newNode = {\n listener,\n listenerType,\n passive: optionsIsObj && Boolean(options.passive),\n once: optionsIsObj && Boolean(options.once),\n next: null,\n }\n\n // Set it as the first node if the first node is null.\n let node = listeners.get(eventName)\n if (node === undefined) {\n listeners.set(eventName, newNode)\n return\n }\n\n // Traverse to the tail while checking duplication..\n let prev = null\n while (node != null) {\n if (\n node.listener === listener &&\n node.listenerType === listenerType\n ) {\n // Should ignore duplication.\n return\n }\n prev = node\n node = node.next\n }\n\n // Add it.\n prev.next = newNode\n },\n\n /**\n * Remove a given listener from this event target.\n * @param {string} eventName The event name to remove.\n * @param {Function} listener The listener to remove.\n * @param {boolean|{capture?:boolean,passive?:boolean,once?:boolean}} [options] The options for this listener.\n * @returns {void}\n */\n removeEventListener(eventName, listener, options) {\n if (listener == null) {\n return\n }\n\n const listeners = getListeners(this)\n const capture = isObject(options)\n ? Boolean(options.capture)\n : Boolean(options)\n const listenerType = capture ? CAPTURE : BUBBLE\n\n let prev = null\n let node = listeners.get(eventName)\n while (node != null) {\n if (\n node.listener === listener &&\n node.listenerType === listenerType\n ) {\n if (prev !== null) {\n prev.next = node.next\n } else if (node.next !== null) {\n listeners.set(eventName, node.next)\n } else {\n listeners.delete(eventName)\n }\n return\n }\n\n prev = node\n node = node.next\n }\n },\n\n /**\n * Dispatch a given event.\n * @param {Event|{type:string}} event The event to dispatch.\n * @returns {boolean} `false` if canceled.\n */\n dispatchEvent(event) {\n if (event == null || typeof event.type !== \"string\") {\n throw new TypeError('\"event.type\" should be a string.')\n }\n\n // If listeners aren't registered, terminate.\n const listeners = getListeners(this)\n const eventName = event.type\n let node = listeners.get(eventName)\n if (node == null) {\n return true\n }\n\n // Since we cannot rewrite several properties, so wrap object.\n const wrappedEvent = wrapEvent(this, event)\n\n // This doesn't process capturing phase and bubbling phase.\n // This isn't participating in a tree.\n let prev = null\n while (node != null) {\n // Remove this listener if it's once\n if (node.once) {\n if (prev !== null) {\n prev.next = node.next\n } else if (node.next !== null) {\n listeners.set(eventName, node.next)\n } else {\n listeners.delete(eventName)\n }\n } else {\n prev = node\n }\n\n // Call this listener\n setPassiveListener(\n wrappedEvent,\n node.passive ? node.listener : null\n )\n if (typeof node.listener === \"function\") {\n try {\n node.listener.call(this, wrappedEvent)\n } catch (err) {\n if (\n typeof console !== \"undefined\" &&\n typeof console.error === \"function\"\n ) {\n console.error(err)\n }\n }\n } else if (\n node.listenerType !== ATTRIBUTE &&\n typeof node.listener.handleEvent === \"function\"\n ) {\n node.listener.handleEvent(wrappedEvent)\n }\n\n // Break if `event.stopImmediatePropagation` was called.\n if (isStopped(wrappedEvent)) {\n break\n }\n\n node = node.next\n }\n setPassiveListener(wrappedEvent, null)\n setEventPhase(wrappedEvent, 0)\n setCurrentTarget(wrappedEvent, null)\n\n return !wrappedEvent.defaultPrevented\n },\n}\n\n// `constructor` is not enumerable.\nObject.defineProperty(EventTarget.prototype, \"constructor\", {\n value: EventTarget,\n configurable: true,\n writable: true,\n})\n\n// Ensure `eventTarget instanceof window.EventTarget` is `true`.\nif (\n typeof window !== \"undefined\" &&\n typeof window.EventTarget !== \"undefined\"\n) {\n Object.setPrototypeOf(EventTarget.prototype, window.EventTarget.prototype)\n}\n\nexport { defineEventAttribute, EventTarget }\nexport default EventTarget\n"],"names":[],"mappings":";;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;AAmBA,MAAM,WAAW,GAAG,IAAI,OAAO,GAAE;;;;;;;AAOjC,MAAM,QAAQ,GAAG,IAAI,OAAO,GAAE;;;;;;;;AAQ9B,SAAS,EAAE,CAAC,KAAK,EAAE;IACf,MAAM,IAAI,GAAG,WAAW,CAAC,GAAG,CAAC,KAAK,EAAC;IACnC,OAAO,CAAC,MAAM;QACV,IAAI,IAAI,IAAI;QACZ,6CAA6C;QAC7C,KAAK;MACR;IACD,OAAO,IAAI;CACd;;;;;;AAMD,SAAS,aAAa,CAAC,IAAI,EAAE;IACzB,IAAI,IAAI,CAAC,eAAe,IAAI,IAAI,EAAE;QAC9B;YACI,OAAO,OAAO,KAAK,WAAW;YAC9B,OAAO,OAAO,CAAC,KAAK,KAAK,UAAU;UACrC;YACE,OAAO,CAAC,KAAK;gBACT,oEAAoE;gBACpE,IAAI,CAAC,eAAe;cACvB;SACJ;QACD,MAAM;KACT;IACD,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE;QACxB,MAAM;KACT;;IAED,IAAI,CAAC,QAAQ,GAAG,KAAI;IACpB,IAAI,OAAO,IAAI,CAAC,KAAK,CAAC,cAAc,KAAK,UAAU,EAAE;QACjD,IAAI,CAAC,KAAK,CAAC,cAAc,GAAE;KAC9B;CACJ;;;;;;;;;;;;AAYD,SAAS,KAAK,CAAC,WAAW,EAAE,KAAK,EAAE;IAC/B,WAAW,CAAC,GAAG,CAAC,IAAI,EAAE;QAClB,WAAW;QACX,KAAK;QACL,UAAU,EAAE,CAAC;QACb,aAAa,EAAE,WAAW;QAC1B,QAAQ,EAAE,KAAK;QACf,OAAO,EAAE,KAAK;QACd,gBAAgB,EAAE,KAAK;QACvB,eAAe,EAAE,IAAI;QACrB,SAAS,EAAE,KAAK,CAAC,SAAS,IAAI,IAAI,CAAC,GAAG,EAAE;KAC3C,EAAC;;;IAGF,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,WAAW,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,EAAC;;;IAG5E,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,EAAC;IAC/B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE;QAClC,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,EAAC;QACnB,IAAI,EAAE,GAAG,IAAI,IAAI,CAAC,EAAE;YAChB,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,EAAE,wBAAwB,CAAC,GAAG,CAAC,EAAC;SAClE;KACJ;CACJ;;;AAGD,KAAK,CAAC,SAAS,GAAG;;;;;IAKd,IAAI,IAAI,GAAG;QACP,OAAO,EAAE,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,IAAI;KAC7B;;;;;;IAMD,IAAI,MAAM,GAAG;QACT,OAAO,EAAE,CAAC,IAAI,CAAC,CAAC,WAAW;KAC9B;;;;;;IAMD,IAAI,aAAa,GAAG;QAChB,OAAO,EAAE,CAAC,IAAI,CAAC,CAAC,aAAa;KAChC;;;;;IAKD,YAAY,GAAG;QACX,MAAM,aAAa,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,cAAa;QAC5C,IAAI,aAAa,IAAI,IAAI,EAAE;YACvB,OAAO,EAAE;SACZ;QACD,OAAO,CAAC,aAAa,CAAC;KACzB;;;;;;IAMD,IAAI,IAAI,GAAG;QACP,OAAO,CAAC;KACX;;;;;;IAMD,IAAI,eAAe,GAAG;QAClB,OAAO,CAAC;KACX;;;;;;IAMD,IAAI,SAAS,GAAG;QACZ,OAAO,CAAC;KACX;;;;;;IAMD,IAAI,cAAc,GAAG;QACjB,OAAO,CAAC;KACX;;;;;;IAMD,IAAI,UAAU,GAAG;QACb,OAAO,EAAE,CAAC,IAAI,CAAC,CAAC,UAAU;KAC7B;;;;;;IAMD,eAAe,GAAG;QACd,MAAM,IAAI,GAAG,EAAE,CAAC,IAAI,EAAC;;QAErB,IAAI,CAAC,OAAO,GAAG,KAAI;QACnB,IAAI,OAAO,IAAI,CAAC,KAAK,CAAC,eAAe,KAAK,UAAU,EAAE;YAClD,IAAI,CAAC,KAAK,CAAC,eAAe,GAAE;SAC/B;KACJ;;;;;;IAMD,wBAAwB,GAAG;QACvB,MAAM,IAAI,GAAG,EAAE,CAAC,IAAI,EAAC;;QAErB,IAAI,CAAC,OAAO,GAAG,KAAI;QACnB,IAAI,CAAC,gBAAgB,GAAG,KAAI;QAC5B,IAAI,OAAO,IAAI,CAAC,KAAK,CAAC,wBAAwB,KAAK,UAAU,EAAE;YAC3D,IAAI,CAAC,KAAK,CAAC,wBAAwB,GAAE;SACxC;KACJ;;;;;;IAMD,IAAI,OAAO,GAAG;QACV,OAAO,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC;KACzC;;;;;;IAMD,IAAI,UAAU,GAAG;QACb,OAAO,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC;KAC5C;;;;;;IAMD,cAAc,GAAG;QACb,aAAa,CAAC,EAAE,CAAC,IAAI,CAAC,EAAC;KAC1B;;;;;;IAMD,IAAI,gBAAgB,GAAG;QACnB,OAAO,EAAE,CAAC,IAAI,CAAC,CAAC,QAAQ;KAC3B;;;;;;IAMD,IAAI,QAAQ,GAAG;QACX,OAAO,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC;KAC1C;;;;;;IAMD,IAAI,SAAS,GAAG;QACZ,OAAO,EAAE,CAAC,IAAI,CAAC,CAAC,SAAS;KAC5B;;;;;;;IAOD,IAAI,UAAU,GAAG;QACb,OAAO,EAAE,CAAC,IAAI,CAAC,CAAC,WAAW;KAC9B;;;;;;;IAOD,IAAI,YAAY,GAAG;QACf,OAAO,EAAE,CAAC,IAAI,CAAC,CAAC,OAAO;KAC1B;IACD,IAAI,YAAY,CAAC,KAAK,EAAE;QACpB,IAAI,CAAC,KAAK,EAAE;YACR,MAAM;SACT;QACD,MAAM,IAAI,GAAG,EAAE,CAAC,IAAI,EAAC;;QAErB,IAAI,CAAC,OAAO,GAAG,KAAI;QACnB,IAAI,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,KAAK,SAAS,EAAE;YAC9C,IAAI,CAAC,KAAK,CAAC,YAAY,GAAG,KAAI;SACjC;KACJ;;;;;;;IAOD,IAAI,WAAW,GAAG;QACd,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,QAAQ;KAC5B;IACD,IAAI,WAAW,CAAC,KAAK,EAAE;QACnB,IAAI,CAAC,KAAK,EAAE;YACR,aAAa,CAAC,EAAE,CAAC,IAAI,CAAC,EAAC;SAC1B;KACJ;;;;;;;;;IASD,SAAS,GAAG;;KAEX;EACJ;;;AAGD,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,SAAS,EAAE,aAAa,EAAE;IAClD,KAAK,EAAE,KAAK;IACZ,YAAY,EAAE,IAAI;IAClB,QAAQ,EAAE,IAAI;CACjB,EAAC;;;AAGF,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,MAAM,CAAC,KAAK,KAAK,WAAW,EAAE;IACtE,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,SAAS,EAAE,MAAM,CAAC,KAAK,CAAC,SAAS,EAAC;;;IAG9D,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,EAAE,KAAK,EAAC;CAC9C;;;;;;;;AAQD,SAAS,wBAAwB,CAAC,GAAG,EAAE;IACnC,OAAO;QACH,GAAG,GAAG;YACF,OAAO,EAAE,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC;SAC7B;QACD,GAAG,CAAC,KAAK,EAAE;YACP,EAAE,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,MAAK;SAC9B;QACD,YAAY,EAAE,IAAI;QAClB,UAAU,EAAE,IAAI;KACnB;CACJ;;;;;;;;AAQD,SAAS,oBAAoB,CAAC,GAAG,EAAE;IAC/B,OAAO;QACH,KAAK,GAAG;YACJ,MAAM,KAAK,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,MAAK;YAC5B,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,KAAK,EAAE,SAAS,CAAC;SAC5C;QACD,YAAY,EAAE,IAAI;QAClB,UAAU,EAAE,IAAI;KACnB;CACJ;;;;;;;;;AASD,SAAS,aAAa,CAAC,SAAS,EAAE,KAAK,EAAE;IACrC,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,EAAC;IAC/B,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE;QACnB,OAAO,SAAS;KACnB;;;IAGD,SAAS,WAAW,CAAC,WAAW,EAAE,KAAK,EAAE;QACrC,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,WAAW,EAAE,KAAK,EAAC;KAC3C;;IAED,WAAW,CAAC,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,SAAS,EAAE;QACvD,WAAW,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE;KAC1E,EAAC;;;IAGF,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE;QAClC,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,EAAC;QACnB,IAAI,EAAE,GAAG,IAAI,SAAS,CAAC,SAAS,CAAC,EAAE;YAC/B,MAAM,UAAU,GAAG,MAAM,CAAC,wBAAwB,CAAC,KAAK,EAAE,GAAG,EAAC;YAC9D,MAAM,MAAM,GAAG,OAAO,UAAU,CAAC,KAAK,KAAK,WAAU;YACrD,MAAM,CAAC,cAAc;gBACjB,WAAW,CAAC,SAAS;gBACrB,GAAG;gBACH,MAAM;sBACA,oBAAoB,CAAC,GAAG,CAAC;sBACzB,wBAAwB,CAAC,GAAG,CAAC;cACtC;SACJ;KACJ;;IAED,OAAO,WAAW;CACrB;;;;;;;;AAQD,SAAS,UAAU,CAAC,KAAK,EAAE;IACvB,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,KAAK,MAAM,CAAC,SAAS,EAAE;QAC7C,OAAO,KAAK;KACf;;IAED,IAAI,OAAO,GAAG,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAC;IACjC,IAAI,OAAO,IAAI,IAAI,EAAE;QACjB,OAAO,GAAG,aAAa,CAAC,UAAU,CAAC,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,EAAC;QACxE,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,EAAC;KAC/B;IACD,OAAO,OAAO;CACjB;;;;;;;;;AASD,AAAO,SAAS,SAAS,CAAC,WAAW,EAAE,KAAK,EAAE;IAC1C,MAAM,OAAO,GAAG,UAAU,CAAC,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,EAAC;IACxD,OAAO,IAAI,OAAO,CAAC,WAAW,EAAE,KAAK,CAAC;CACzC;;;;;;;;AAQD,AAAO,SAAS,SAAS,CAAC,KAAK,EAAE;IAC7B,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC,gBAAgB;CACpC;;;;;;;;;AASD,AAAO,SAAS,aAAa,CAAC,KAAK,EAAE,UAAU,EAAE;IAC7C,EAAE,CAAC,KAAK,CAAC,CAAC,UAAU,GAAG,WAAU;CACpC;;;;;;;;;AASD,AAAO,SAAS,gBAAgB,CAAC,KAAK,EAAE,aAAa,EAAE;IACnD,EAAE,CAAC,KAAK,CAAC,CAAC,aAAa,GAAG,cAAa;CAC1C;;;;;;;;;AASD,AAAO,SAAS,kBAAkB,CAAC,KAAK,EAAE,eAAe,EAAE;IACvD,EAAE,CAAC,KAAK,CAAC,CAAC,eAAe,GAAG,gBAAe;CAC9C;;ACtdD;;;;;;;;;;;;;;AAcA,MAAM,YAAY,GAAG,IAAI,OAAO,GAAE;;;AAGlC,MAAM,OAAO,GAAG,EAAC;AACjB,MAAM,MAAM,GAAG,EAAC;AAChB,MAAM,SAAS,GAAG,EAAC;;;;;;;AAOnB,SAAS,QAAQ,CAAC,CAAC,EAAE;IACjB,OAAO,CAAC,KAAK,IAAI,IAAI,OAAO,CAAC,KAAK,QAAQ;CAC7C;;;;;;;;AAQD,SAAS,YAAY,CAAC,WAAW,EAAE;IAC/B,MAAM,SAAS,GAAG,YAAY,CAAC,GAAG,CAAC,WAAW,EAAC;IAC/C,IAAI,SAAS,IAAI,IAAI,EAAE;QACnB,MAAM,IAAI,SAAS;YACf,kEAAkE;SACrE;KACJ;IACD,OAAO,SAAS;CACnB;;;;;;;;AAQD,SAAS,8BAA8B,CAAC,SAAS,EAAE;IAC/C,OAAO;QACH,GAAG,GAAG;YACF,MAAM,SAAS,GAAG,YAAY,CAAC,IAAI,EAAC;YACpC,IAAI,IAAI,GAAG,SAAS,CAAC,GAAG,CAAC,SAAS,EAAC;YACnC,OAAO,IAAI,IAAI,IAAI,EAAE;gBACjB,IAAI,IAAI,CAAC,YAAY,KAAK,SAAS,EAAE;oBACjC,OAAO,IAAI,CAAC,QAAQ;iBACvB;gBACD,IAAI,GAAG,IAAI,CAAC,KAAI;aACnB;YACD,OAAO,IAAI;SACd;;QAED,GAAG,CAAC,QAAQ,EAAE;YACV,IAAI,OAAO,QAAQ,KAAK,UAAU,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE;gBACvD,QAAQ,GAAG,KAAI;aAClB;YACD,MAAM,SAAS,GAAG,YAAY,CAAC,IAAI,EAAC;;;YAGpC,IAAI,IAAI,GAAG,KAAI;YACf,IAAI,IAAI,GAAG,SAAS,CAAC,GAAG,CAAC,SAAS,EAAC;YACnC,OAAO,IAAI,IAAI,IAAI,EAAE;gBACjB,IAAI,IAAI,CAAC,YAAY,KAAK,SAAS,EAAE;;oBAEjC,IAAI,IAAI,KAAK,IAAI,EAAE;wBACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,KAAI;qBACxB,MAAM,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI,EAAE;wBAC3B,SAAS,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,EAAC;qBACtC,MAAM;wBACH,SAAS,CAAC,MAAM,CAAC,SAAS,EAAC;qBAC9B;iBACJ,MAAM;oBACH,IAAI,GAAG,KAAI;iBACd;;gBAED,IAAI,GAAG,IAAI,CAAC,KAAI;aACnB;;;YAGD,IAAI,QAAQ,KAAK,IAAI,EAAE;gBACnB,MAAM,OAAO,GAAG;oBACZ,QAAQ;oBACR,YAAY,EAAE,SAAS;oBACvB,OAAO,EAAE,KAAK;oBACd,IAAI,EAAE,KAAK;oBACX,IAAI,EAAE,IAAI;kBACb;gBACD,IAAI,IAAI,KAAK,IAAI,EAAE;oBACf,SAAS,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,EAAC;iBACpC,MAAM;oBACH,IAAI,CAAC,IAAI,GAAG,QAAO;iBACtB;aACJ;SACJ;QACD,YAAY,EAAE,IAAI;QAClB,UAAU,EAAE,IAAI;KACnB;CACJ;;;;;;;;AAQD,SAAS,oBAAoB,CAAC,oBAAoB,EAAE,SAAS,EAAE;IAC3D,MAAM,CAAC,cAAc;QACjB,oBAAoB;QACpB,CAAC,EAAE,EAAE,SAAS,CAAC,CAAC;QAChB,8BAA8B,CAAC,SAAS,CAAC;MAC5C;CACJ;;;;;;;;AAQD,SAAS,uBAAuB,CAAC,UAAU,EAAE;;IAEzC,SAAS,iBAAiB,GAAG;QACzB,WAAW,CAAC,IAAI,CAAC,IAAI,EAAC;KACzB;;IAED,iBAAiB,CAAC,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,SAAS,EAAE;QAC/D,WAAW,EAAE;YACT,KAAK,EAAE,iBAAiB;YACxB,YAAY,EAAE,IAAI;YAClB,QAAQ,EAAE,IAAI;SACjB;KACJ,EAAC;;IAEF,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE;QACxC,oBAAoB,CAAC,iBAAiB,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC,EAAC;KACnE;;IAED,OAAO,iBAAiB;CAC3B;;;;;;;;;;;;;;;AAeD,SAAS,WAAW,GAAG;;IAEnB,IAAI,IAAI,YAAY,WAAW,EAAE;QAC7B,YAAY,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,GAAG,EAAE,EAAC;QACjC,MAAM;KACT;IACD,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE;QACvD,OAAO,uBAAuB,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;KAC/C;IACD,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE;QACtB,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,SAAS,CAAC,MAAM,EAAC;QACzC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE;YACvC,KAAK,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,EAAC;SAC1B;QACD,OAAO,uBAAuB,CAAC,KAAK,CAAC;KACxC;IACD,MAAM,IAAI,SAAS,CAAC,mCAAmC,CAAC;;CAE3D;;;AAGD,WAAW,CAAC,SAAS,GAAG;;;;;;;;IAQpB,gBAAgB,CAAC,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE;QAC3C,IAAI,QAAQ,IAAI,IAAI,EAAE;YAClB,MAAM;SACT;QACD,IAAI,OAAO,QAAQ,KAAK,UAAU,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE;YACvD,MAAM,IAAI,SAAS,CAAC,+CAA+C,CAAC;SACvE;;QAED,MAAM,SAAS,GAAG,YAAY,CAAC,IAAI,EAAC;QACpC,MAAM,YAAY,GAAG,QAAQ,CAAC,OAAO,EAAC;QACtC,MAAM,OAAO,GAAG,YAAY;cACtB,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC;cACxB,OAAO,CAAC,OAAO,EAAC;QACtB,MAAM,YAAY,GAAG,OAAO,GAAG,OAAO,GAAG,OAAM;QAC/C,MAAM,OAAO,GAAG;YACZ,QAAQ;YACR,YAAY;YACZ,OAAO,EAAE,YAAY,IAAI,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC;YACjD,IAAI,EAAE,YAAY,IAAI,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC;YAC3C,IAAI,EAAE,IAAI;UACb;;;QAGD,IAAI,IAAI,GAAG,SAAS,CAAC,GAAG,CAAC,SAAS,EAAC;QACnC,IAAI,IAAI,KAAK,SAAS,EAAE;YACpB,SAAS,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,EAAC;YACjC,MAAM;SACT;;;QAGD,IAAI,IAAI,GAAG,KAAI;QACf,OAAO,IAAI,IAAI,IAAI,EAAE;YACjB;gBACI,IAAI,CAAC,QAAQ,KAAK,QAAQ;gBAC1B,IAAI,CAAC,YAAY,KAAK,YAAY;cACpC;;gBAEE,MAAM;aACT;YACD,IAAI,GAAG,KAAI;YACX,IAAI,GAAG,IAAI,CAAC,KAAI;SACnB;;;QAGD,IAAI,CAAC,IAAI,GAAG,QAAO;KACtB;;;;;;;;;IASD,mBAAmB,CAAC,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE;QAC9C,IAAI,QAAQ,IAAI,IAAI,EAAE;YAClB,MAAM;SACT;;QAED,MAAM,SAAS,GAAG,YAAY,CAAC,IAAI,EAAC;QACpC,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC;cAC3B,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC;cACxB,OAAO,CAAC,OAAO,EAAC;QACtB,MAAM,YAAY,GAAG,OAAO,GAAG,OAAO,GAAG,OAAM;;QAE/C,IAAI,IAAI,GAAG,KAAI;QACf,IAAI,IAAI,GAAG,SAAS,CAAC,GAAG,CAAC,SAAS,EAAC;QACnC,OAAO,IAAI,IAAI,IAAI,EAAE;YACjB;gBACI,IAAI,CAAC,QAAQ,KAAK,QAAQ;gBAC1B,IAAI,CAAC,YAAY,KAAK,YAAY;cACpC;gBACE,IAAI,IAAI,KAAK,IAAI,EAAE;oBACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,KAAI;iBACxB,MAAM,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI,EAAE;oBAC3B,SAAS,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,EAAC;iBACtC,MAAM;oBACH,SAAS,CAAC,MAAM,CAAC,SAAS,EAAC;iBAC9B;gBACD,MAAM;aACT;;YAED,IAAI,GAAG,KAAI;YACX,IAAI,GAAG,IAAI,CAAC,KAAI;SACnB;KACJ;;;;;;;IAOD,aAAa,CAAC,KAAK,EAAE;QACjB,IAAI,KAAK,IAAI,IAAI,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,EAAE;YACjD,MAAM,IAAI,SAAS,CAAC,kCAAkC,CAAC;SAC1D;;;QAGD,MAAM,SAAS,GAAG,YAAY,CAAC,IAAI,EAAC;QACpC,MAAM,SAAS,GAAG,KAAK,CAAC,KAAI;QAC5B,IAAI,IAAI,GAAG,SAAS,CAAC,GAAG,CAAC,SAAS,EAAC;QACnC,IAAI,IAAI,IAAI,IAAI,EAAE;YACd,OAAO,IAAI;SACd;;;QAGD,MAAM,YAAY,GAAG,SAAS,CAAC,IAAI,EAAE,KAAK,EAAC;;;;QAI3C,IAAI,IAAI,GAAG,KAAI;QACf,OAAO,IAAI,IAAI,IAAI,EAAE;;YAEjB,IAAI,IAAI,CAAC,IAAI,EAAE;gBACX,IAAI,IAAI,KAAK,IAAI,EAAE;oBACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,KAAI;iBACxB,MAAM,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI,EAAE;oBAC3B,SAAS,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,EAAC;iBACtC,MAAM;oBACH,SAAS,CAAC,MAAM,CAAC,SAAS,EAAC;iBAC9B;aACJ,MAAM;gBACH,IAAI,GAAG,KAAI;aACd;;;YAGD,kBAAkB;gBACd,YAAY;gBACZ,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,QAAQ,GAAG,IAAI;cACtC;YACD,IAAI,OAAO,IAAI,CAAC,QAAQ,KAAK,UAAU,EAAE;gBACrC,IAAI;oBACA,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,YAAY,EAAC;iBACzC,CAAC,OAAO,GAAG,EAAE;oBACV;wBACI,OAAO,OAAO,KAAK,WAAW;wBAC9B,OAAO,OAAO,CAAC,KAAK,KAAK,UAAU;sBACrC;wBACE,OAAO,CAAC,KAAK,CAAC,GAAG,EAAC;qBACrB;iBACJ;aACJ,MAAM;gBACH,IAAI,CAAC,YAAY,KAAK,SAAS;gBAC/B,OAAO,IAAI,CAAC,QAAQ,CAAC,WAAW,KAAK,UAAU;cACjD;gBACE,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,YAAY,EAAC;aAC1C;;;YAGD,IAAI,SAAS,CAAC,YAAY,CAAC,EAAE;gBACzB,KAAK;aACR;;YAED,IAAI,GAAG,IAAI,CAAC,KAAI;SACnB;QACD,kBAAkB,CAAC,YAAY,EAAE,IAAI,EAAC;QACtC,aAAa,CAAC,YAAY,EAAE,CAAC,EAAC;QAC9B,gBAAgB,CAAC,YAAY,EAAE,IAAI,EAAC;;QAEpC,OAAO,CAAC,YAAY,CAAC,gBAAgB;KACxC;EACJ;;;AAGD,MAAM,CAAC,cAAc,CAAC,WAAW,CAAC,SAAS,EAAE,aAAa,EAAE;IACxD,KAAK,EAAE,WAAW;IAClB,YAAY,EAAE,IAAI;IAClB,QAAQ,EAAE,IAAI;CACjB,EAAC;;;AAGF;IACI,OAAO,MAAM,KAAK,WAAW;IAC7B,OAAO,MAAM,CAAC,WAAW,KAAK,WAAW;EAC3C;IACE,MAAM,CAAC,cAAc,CAAC,WAAW,CAAC,SAAS,EAAE,MAAM,CAAC,WAAW,CAAC,SAAS,EAAC;CAC7E;;;;;;;;;;;;;"} \ No newline at end of file diff --git a/sandbox/tgbot/node_modules/event-target-shim/dist/event-target-shim.mjs b/sandbox/tgbot/node_modules/event-target-shim/dist/event-target-shim.mjs new file mode 100644 index 0000000..114f3a1 --- /dev/null +++ b/sandbox/tgbot/node_modules/event-target-shim/dist/event-target-shim.mjs @@ -0,0 +1,862 @@ +/** + * @author Toru Nagashima + * @copyright 2015 Toru Nagashima. All rights reserved. + * See LICENSE file in root directory for full license. + */ +/** + * @typedef {object} PrivateData + * @property {EventTarget} eventTarget The event target. + * @property {{type:string}} event The original event object. + * @property {number} eventPhase The current event phase. + * @property {EventTarget|null} currentTarget The current event target. + * @property {boolean} canceled The flag to prevent default. + * @property {boolean} stopped The flag to stop propagation. + * @property {boolean} immediateStopped The flag to stop propagation immediately. + * @property {Function|null} passiveListener The listener if the current listener is passive. Otherwise this is null. + * @property {number} timeStamp The unix time. + * @private + */ + +/** + * Private data for event wrappers. + * @type {WeakMap} + * @private + */ +const privateData = new WeakMap(); + +/** + * Cache for wrapper classes. + * @type {WeakMap} + * @private + */ +const wrappers = new WeakMap(); + +/** + * Get private data. + * @param {Event} event The event object to get private data. + * @returns {PrivateData} The private data of the event. + * @private + */ +function pd(event) { + const retv = privateData.get(event); + console.assert( + retv != null, + "'this' is expected an Event object, but got", + event + ); + return retv +} + +/** + * https://dom.spec.whatwg.org/#set-the-canceled-flag + * @param data {PrivateData} private data. + */ +function setCancelFlag(data) { + if (data.passiveListener != null) { + if ( + typeof console !== "undefined" && + typeof console.error === "function" + ) { + console.error( + "Unable to preventDefault inside passive event listener invocation.", + data.passiveListener + ); + } + return + } + if (!data.event.cancelable) { + return + } + + data.canceled = true; + if (typeof data.event.preventDefault === "function") { + data.event.preventDefault(); + } +} + +/** + * @see https://dom.spec.whatwg.org/#interface-event + * @private + */ +/** + * The event wrapper. + * @constructor + * @param {EventTarget} eventTarget The event target of this dispatching. + * @param {Event|{type:string}} event The original event to wrap. + */ +function Event(eventTarget, event) { + privateData.set(this, { + eventTarget, + event, + eventPhase: 2, + currentTarget: eventTarget, + canceled: false, + stopped: false, + immediateStopped: false, + passiveListener: null, + timeStamp: event.timeStamp || Date.now(), + }); + + // https://heycam.github.io/webidl/#Unforgeable + Object.defineProperty(this, "isTrusted", { value: false, enumerable: true }); + + // Define accessors + const keys = Object.keys(event); + for (let i = 0; i < keys.length; ++i) { + const key = keys[i]; + if (!(key in this)) { + Object.defineProperty(this, key, defineRedirectDescriptor(key)); + } + } +} + +// Should be enumerable, but class methods are not enumerable. +Event.prototype = { + /** + * The type of this event. + * @type {string} + */ + get type() { + return pd(this).event.type + }, + + /** + * The target of this event. + * @type {EventTarget} + */ + get target() { + return pd(this).eventTarget + }, + + /** + * The target of this event. + * @type {EventTarget} + */ + get currentTarget() { + return pd(this).currentTarget + }, + + /** + * @returns {EventTarget[]} The composed path of this event. + */ + composedPath() { + const currentTarget = pd(this).currentTarget; + if (currentTarget == null) { + return [] + } + return [currentTarget] + }, + + /** + * Constant of NONE. + * @type {number} + */ + get NONE() { + return 0 + }, + + /** + * Constant of CAPTURING_PHASE. + * @type {number} + */ + get CAPTURING_PHASE() { + return 1 + }, + + /** + * Constant of AT_TARGET. + * @type {number} + */ + get AT_TARGET() { + return 2 + }, + + /** + * Constant of BUBBLING_PHASE. + * @type {number} + */ + get BUBBLING_PHASE() { + return 3 + }, + + /** + * The target of this event. + * @type {number} + */ + get eventPhase() { + return pd(this).eventPhase + }, + + /** + * Stop event bubbling. + * @returns {void} + */ + stopPropagation() { + const data = pd(this); + + data.stopped = true; + if (typeof data.event.stopPropagation === "function") { + data.event.stopPropagation(); + } + }, + + /** + * Stop event bubbling. + * @returns {void} + */ + stopImmediatePropagation() { + const data = pd(this); + + data.stopped = true; + data.immediateStopped = true; + if (typeof data.event.stopImmediatePropagation === "function") { + data.event.stopImmediatePropagation(); + } + }, + + /** + * The flag to be bubbling. + * @type {boolean} + */ + get bubbles() { + return Boolean(pd(this).event.bubbles) + }, + + /** + * The flag to be cancelable. + * @type {boolean} + */ + get cancelable() { + return Boolean(pd(this).event.cancelable) + }, + + /** + * Cancel this event. + * @returns {void} + */ + preventDefault() { + setCancelFlag(pd(this)); + }, + + /** + * The flag to indicate cancellation state. + * @type {boolean} + */ + get defaultPrevented() { + return pd(this).canceled + }, + + /** + * The flag to be composed. + * @type {boolean} + */ + get composed() { + return Boolean(pd(this).event.composed) + }, + + /** + * The unix time of this event. + * @type {number} + */ + get timeStamp() { + return pd(this).timeStamp + }, + + /** + * The target of this event. + * @type {EventTarget} + * @deprecated + */ + get srcElement() { + return pd(this).eventTarget + }, + + /** + * The flag to stop event bubbling. + * @type {boolean} + * @deprecated + */ + get cancelBubble() { + return pd(this).stopped + }, + set cancelBubble(value) { + if (!value) { + return + } + const data = pd(this); + + data.stopped = true; + if (typeof data.event.cancelBubble === "boolean") { + data.event.cancelBubble = true; + } + }, + + /** + * The flag to indicate cancellation state. + * @type {boolean} + * @deprecated + */ + get returnValue() { + return !pd(this).canceled + }, + set returnValue(value) { + if (!value) { + setCancelFlag(pd(this)); + } + }, + + /** + * Initialize this event object. But do nothing under event dispatching. + * @param {string} type The event type. + * @param {boolean} [bubbles=false] The flag to be possible to bubble up. + * @param {boolean} [cancelable=false] The flag to be possible to cancel. + * @deprecated + */ + initEvent() { + // Do nothing. + }, +}; + +// `constructor` is not enumerable. +Object.defineProperty(Event.prototype, "constructor", { + value: Event, + configurable: true, + writable: true, +}); + +// Ensure `event instanceof window.Event` is `true`. +if (typeof window !== "undefined" && typeof window.Event !== "undefined") { + Object.setPrototypeOf(Event.prototype, window.Event.prototype); + + // Make association for wrappers. + wrappers.set(window.Event.prototype, Event); +} + +/** + * Get the property descriptor to redirect a given property. + * @param {string} key Property name to define property descriptor. + * @returns {PropertyDescriptor} The property descriptor to redirect the property. + * @private + */ +function defineRedirectDescriptor(key) { + return { + get() { + return pd(this).event[key] + }, + set(value) { + pd(this).event[key] = value; + }, + configurable: true, + enumerable: true, + } +} + +/** + * Get the property descriptor to call a given method property. + * @param {string} key Property name to define property descriptor. + * @returns {PropertyDescriptor} The property descriptor to call the method property. + * @private + */ +function defineCallDescriptor(key) { + return { + value() { + const event = pd(this).event; + return event[key].apply(event, arguments) + }, + configurable: true, + enumerable: true, + } +} + +/** + * Define new wrapper class. + * @param {Function} BaseEvent The base wrapper class. + * @param {Object} proto The prototype of the original event. + * @returns {Function} The defined wrapper class. + * @private + */ +function defineWrapper(BaseEvent, proto) { + const keys = Object.keys(proto); + if (keys.length === 0) { + return BaseEvent + } + + /** CustomEvent */ + function CustomEvent(eventTarget, event) { + BaseEvent.call(this, eventTarget, event); + } + + CustomEvent.prototype = Object.create(BaseEvent.prototype, { + constructor: { value: CustomEvent, configurable: true, writable: true }, + }); + + // Define accessors. + for (let i = 0; i < keys.length; ++i) { + const key = keys[i]; + if (!(key in BaseEvent.prototype)) { + const descriptor = Object.getOwnPropertyDescriptor(proto, key); + const isFunc = typeof descriptor.value === "function"; + Object.defineProperty( + CustomEvent.prototype, + key, + isFunc + ? defineCallDescriptor(key) + : defineRedirectDescriptor(key) + ); + } + } + + return CustomEvent +} + +/** + * Get the wrapper class of a given prototype. + * @param {Object} proto The prototype of the original event to get its wrapper. + * @returns {Function} The wrapper class. + * @private + */ +function getWrapper(proto) { + if (proto == null || proto === Object.prototype) { + return Event + } + + let wrapper = wrappers.get(proto); + if (wrapper == null) { + wrapper = defineWrapper(getWrapper(Object.getPrototypeOf(proto)), proto); + wrappers.set(proto, wrapper); + } + return wrapper +} + +/** + * Wrap a given event to management a dispatching. + * @param {EventTarget} eventTarget The event target of this dispatching. + * @param {Object} event The event to wrap. + * @returns {Event} The wrapper instance. + * @private + */ +function wrapEvent(eventTarget, event) { + const Wrapper = getWrapper(Object.getPrototypeOf(event)); + return new Wrapper(eventTarget, event) +} + +/** + * Get the immediateStopped flag of a given event. + * @param {Event} event The event to get. + * @returns {boolean} The flag to stop propagation immediately. + * @private + */ +function isStopped(event) { + return pd(event).immediateStopped +} + +/** + * Set the current event phase of a given event. + * @param {Event} event The event to set current target. + * @param {number} eventPhase New event phase. + * @returns {void} + * @private + */ +function setEventPhase(event, eventPhase) { + pd(event).eventPhase = eventPhase; +} + +/** + * Set the current target of a given event. + * @param {Event} event The event to set current target. + * @param {EventTarget|null} currentTarget New current target. + * @returns {void} + * @private + */ +function setCurrentTarget(event, currentTarget) { + pd(event).currentTarget = currentTarget; +} + +/** + * Set a passive listener of a given event. + * @param {Event} event The event to set current target. + * @param {Function|null} passiveListener New passive listener. + * @returns {void} + * @private + */ +function setPassiveListener(event, passiveListener) { + pd(event).passiveListener = passiveListener; +} + +/** + * @typedef {object} ListenerNode + * @property {Function} listener + * @property {1|2|3} listenerType + * @property {boolean} passive + * @property {boolean} once + * @property {ListenerNode|null} next + * @private + */ + +/** + * @type {WeakMap>} + * @private + */ +const listenersMap = new WeakMap(); + +// Listener types +const CAPTURE = 1; +const BUBBLE = 2; +const ATTRIBUTE = 3; + +/** + * Check whether a given value is an object or not. + * @param {any} x The value to check. + * @returns {boolean} `true` if the value is an object. + */ +function isObject(x) { + return x !== null && typeof x === "object" //eslint-disable-line no-restricted-syntax +} + +/** + * Get listeners. + * @param {EventTarget} eventTarget The event target to get. + * @returns {Map} The listeners. + * @private + */ +function getListeners(eventTarget) { + const listeners = listenersMap.get(eventTarget); + if (listeners == null) { + throw new TypeError( + "'this' is expected an EventTarget object, but got another value." + ) + } + return listeners +} + +/** + * Get the property descriptor for the event attribute of a given event. + * @param {string} eventName The event name to get property descriptor. + * @returns {PropertyDescriptor} The property descriptor. + * @private + */ +function defineEventAttributeDescriptor(eventName) { + return { + get() { + const listeners = getListeners(this); + let node = listeners.get(eventName); + while (node != null) { + if (node.listenerType === ATTRIBUTE) { + return node.listener + } + node = node.next; + } + return null + }, + + set(listener) { + if (typeof listener !== "function" && !isObject(listener)) { + listener = null; // eslint-disable-line no-param-reassign + } + const listeners = getListeners(this); + + // Traverse to the tail while removing old value. + let prev = null; + let node = listeners.get(eventName); + while (node != null) { + if (node.listenerType === ATTRIBUTE) { + // Remove old value. + if (prev !== null) { + prev.next = node.next; + } else if (node.next !== null) { + listeners.set(eventName, node.next); + } else { + listeners.delete(eventName); + } + } else { + prev = node; + } + + node = node.next; + } + + // Add new value. + if (listener !== null) { + const newNode = { + listener, + listenerType: ATTRIBUTE, + passive: false, + once: false, + next: null, + }; + if (prev === null) { + listeners.set(eventName, newNode); + } else { + prev.next = newNode; + } + } + }, + configurable: true, + enumerable: true, + } +} + +/** + * Define an event attribute (e.g. `eventTarget.onclick`). + * @param {Object} eventTargetPrototype The event target prototype to define an event attrbite. + * @param {string} eventName The event name to define. + * @returns {void} + */ +function defineEventAttribute(eventTargetPrototype, eventName) { + Object.defineProperty( + eventTargetPrototype, + `on${eventName}`, + defineEventAttributeDescriptor(eventName) + ); +} + +/** + * Define a custom EventTarget with event attributes. + * @param {string[]} eventNames Event names for event attributes. + * @returns {EventTarget} The custom EventTarget. + * @private + */ +function defineCustomEventTarget(eventNames) { + /** CustomEventTarget */ + function CustomEventTarget() { + EventTarget.call(this); + } + + CustomEventTarget.prototype = Object.create(EventTarget.prototype, { + constructor: { + value: CustomEventTarget, + configurable: true, + writable: true, + }, + }); + + for (let i = 0; i < eventNames.length; ++i) { + defineEventAttribute(CustomEventTarget.prototype, eventNames[i]); + } + + return CustomEventTarget +} + +/** + * EventTarget. + * + * - This is constructor if no arguments. + * - This is a function which returns a CustomEventTarget constructor if there are arguments. + * + * For example: + * + * class A extends EventTarget {} + * class B extends EventTarget("message") {} + * class C extends EventTarget("message", "error") {} + * class D extends EventTarget(["message", "error"]) {} + */ +function EventTarget() { + /*eslint-disable consistent-return */ + if (this instanceof EventTarget) { + listenersMap.set(this, new Map()); + return + } + if (arguments.length === 1 && Array.isArray(arguments[0])) { + return defineCustomEventTarget(arguments[0]) + } + if (arguments.length > 0) { + const types = new Array(arguments.length); + for (let i = 0; i < arguments.length; ++i) { + types[i] = arguments[i]; + } + return defineCustomEventTarget(types) + } + throw new TypeError("Cannot call a class as a function") + /*eslint-enable consistent-return */ +} + +// Should be enumerable, but class methods are not enumerable. +EventTarget.prototype = { + /** + * Add a given listener to this event target. + * @param {string} eventName The event name to add. + * @param {Function} listener The listener to add. + * @param {boolean|{capture?:boolean,passive?:boolean,once?:boolean}} [options] The options for this listener. + * @returns {void} + */ + addEventListener(eventName, listener, options) { + if (listener == null) { + return + } + if (typeof listener !== "function" && !isObject(listener)) { + throw new TypeError("'listener' should be a function or an object.") + } + + const listeners = getListeners(this); + const optionsIsObj = isObject(options); + const capture = optionsIsObj + ? Boolean(options.capture) + : Boolean(options); + const listenerType = capture ? CAPTURE : BUBBLE; + const newNode = { + listener, + listenerType, + passive: optionsIsObj && Boolean(options.passive), + once: optionsIsObj && Boolean(options.once), + next: null, + }; + + // Set it as the first node if the first node is null. + let node = listeners.get(eventName); + if (node === undefined) { + listeners.set(eventName, newNode); + return + } + + // Traverse to the tail while checking duplication.. + let prev = null; + while (node != null) { + if ( + node.listener === listener && + node.listenerType === listenerType + ) { + // Should ignore duplication. + return + } + prev = node; + node = node.next; + } + + // Add it. + prev.next = newNode; + }, + + /** + * Remove a given listener from this event target. + * @param {string} eventName The event name to remove. + * @param {Function} listener The listener to remove. + * @param {boolean|{capture?:boolean,passive?:boolean,once?:boolean}} [options] The options for this listener. + * @returns {void} + */ + removeEventListener(eventName, listener, options) { + if (listener == null) { + return + } + + const listeners = getListeners(this); + const capture = isObject(options) + ? Boolean(options.capture) + : Boolean(options); + const listenerType = capture ? CAPTURE : BUBBLE; + + let prev = null; + let node = listeners.get(eventName); + while (node != null) { + if ( + node.listener === listener && + node.listenerType === listenerType + ) { + if (prev !== null) { + prev.next = node.next; + } else if (node.next !== null) { + listeners.set(eventName, node.next); + } else { + listeners.delete(eventName); + } + return + } + + prev = node; + node = node.next; + } + }, + + /** + * Dispatch a given event. + * @param {Event|{type:string}} event The event to dispatch. + * @returns {boolean} `false` if canceled. + */ + dispatchEvent(event) { + if (event == null || typeof event.type !== "string") { + throw new TypeError('"event.type" should be a string.') + } + + // If listeners aren't registered, terminate. + const listeners = getListeners(this); + const eventName = event.type; + let node = listeners.get(eventName); + if (node == null) { + return true + } + + // Since we cannot rewrite several properties, so wrap object. + const wrappedEvent = wrapEvent(this, event); + + // This doesn't process capturing phase and bubbling phase. + // This isn't participating in a tree. + let prev = null; + while (node != null) { + // Remove this listener if it's once + if (node.once) { + if (prev !== null) { + prev.next = node.next; + } else if (node.next !== null) { + listeners.set(eventName, node.next); + } else { + listeners.delete(eventName); + } + } else { + prev = node; + } + + // Call this listener + setPassiveListener( + wrappedEvent, + node.passive ? node.listener : null + ); + if (typeof node.listener === "function") { + try { + node.listener.call(this, wrappedEvent); + } catch (err) { + if ( + typeof console !== "undefined" && + typeof console.error === "function" + ) { + console.error(err); + } + } + } else if ( + node.listenerType !== ATTRIBUTE && + typeof node.listener.handleEvent === "function" + ) { + node.listener.handleEvent(wrappedEvent); + } + + // Break if `event.stopImmediatePropagation` was called. + if (isStopped(wrappedEvent)) { + break + } + + node = node.next; + } + setPassiveListener(wrappedEvent, null); + setEventPhase(wrappedEvent, 0); + setCurrentTarget(wrappedEvent, null); + + return !wrappedEvent.defaultPrevented + }, +}; + +// `constructor` is not enumerable. +Object.defineProperty(EventTarget.prototype, "constructor", { + value: EventTarget, + configurable: true, + writable: true, +}); + +// Ensure `eventTarget instanceof window.EventTarget` is `true`. +if ( + typeof window !== "undefined" && + typeof window.EventTarget !== "undefined" +) { + Object.setPrototypeOf(EventTarget.prototype, window.EventTarget.prototype); +} + +export default EventTarget; +export { defineEventAttribute, EventTarget }; +//# sourceMappingURL=event-target-shim.mjs.map diff --git a/sandbox/tgbot/node_modules/event-target-shim/dist/event-target-shim.mjs.map b/sandbox/tgbot/node_modules/event-target-shim/dist/event-target-shim.mjs.map new file mode 100644 index 0000000..57b3e8f --- /dev/null +++ b/sandbox/tgbot/node_modules/event-target-shim/dist/event-target-shim.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"event-target-shim.mjs","sources":["../src/event.mjs","../src/event-target.mjs"],"sourcesContent":["/**\n * @typedef {object} PrivateData\n * @property {EventTarget} eventTarget The event target.\n * @property {{type:string}} event The original event object.\n * @property {number} eventPhase The current event phase.\n * @property {EventTarget|null} currentTarget The current event target.\n * @property {boolean} canceled The flag to prevent default.\n * @property {boolean} stopped The flag to stop propagation.\n * @property {boolean} immediateStopped The flag to stop propagation immediately.\n * @property {Function|null} passiveListener The listener if the current listener is passive. Otherwise this is null.\n * @property {number} timeStamp The unix time.\n * @private\n */\n\n/**\n * Private data for event wrappers.\n * @type {WeakMap}\n * @private\n */\nconst privateData = new WeakMap()\n\n/**\n * Cache for wrapper classes.\n * @type {WeakMap}\n * @private\n */\nconst wrappers = new WeakMap()\n\n/**\n * Get private data.\n * @param {Event} event The event object to get private data.\n * @returns {PrivateData} The private data of the event.\n * @private\n */\nfunction pd(event) {\n const retv = privateData.get(event)\n console.assert(\n retv != null,\n \"'this' is expected an Event object, but got\",\n event\n )\n return retv\n}\n\n/**\n * https://dom.spec.whatwg.org/#set-the-canceled-flag\n * @param data {PrivateData} private data.\n */\nfunction setCancelFlag(data) {\n if (data.passiveListener != null) {\n if (\n typeof console !== \"undefined\" &&\n typeof console.error === \"function\"\n ) {\n console.error(\n \"Unable to preventDefault inside passive event listener invocation.\",\n data.passiveListener\n )\n }\n return\n }\n if (!data.event.cancelable) {\n return\n }\n\n data.canceled = true\n if (typeof data.event.preventDefault === \"function\") {\n data.event.preventDefault()\n }\n}\n\n/**\n * @see https://dom.spec.whatwg.org/#interface-event\n * @private\n */\n/**\n * The event wrapper.\n * @constructor\n * @param {EventTarget} eventTarget The event target of this dispatching.\n * @param {Event|{type:string}} event The original event to wrap.\n */\nfunction Event(eventTarget, event) {\n privateData.set(this, {\n eventTarget,\n event,\n eventPhase: 2,\n currentTarget: eventTarget,\n canceled: false,\n stopped: false,\n immediateStopped: false,\n passiveListener: null,\n timeStamp: event.timeStamp || Date.now(),\n })\n\n // https://heycam.github.io/webidl/#Unforgeable\n Object.defineProperty(this, \"isTrusted\", { value: false, enumerable: true })\n\n // Define accessors\n const keys = Object.keys(event)\n for (let i = 0; i < keys.length; ++i) {\n const key = keys[i]\n if (!(key in this)) {\n Object.defineProperty(this, key, defineRedirectDescriptor(key))\n }\n }\n}\n\n// Should be enumerable, but class methods are not enumerable.\nEvent.prototype = {\n /**\n * The type of this event.\n * @type {string}\n */\n get type() {\n return pd(this).event.type\n },\n\n /**\n * The target of this event.\n * @type {EventTarget}\n */\n get target() {\n return pd(this).eventTarget\n },\n\n /**\n * The target of this event.\n * @type {EventTarget}\n */\n get currentTarget() {\n return pd(this).currentTarget\n },\n\n /**\n * @returns {EventTarget[]} The composed path of this event.\n */\n composedPath() {\n const currentTarget = pd(this).currentTarget\n if (currentTarget == null) {\n return []\n }\n return [currentTarget]\n },\n\n /**\n * Constant of NONE.\n * @type {number}\n */\n get NONE() {\n return 0\n },\n\n /**\n * Constant of CAPTURING_PHASE.\n * @type {number}\n */\n get CAPTURING_PHASE() {\n return 1\n },\n\n /**\n * Constant of AT_TARGET.\n * @type {number}\n */\n get AT_TARGET() {\n return 2\n },\n\n /**\n * Constant of BUBBLING_PHASE.\n * @type {number}\n */\n get BUBBLING_PHASE() {\n return 3\n },\n\n /**\n * The target of this event.\n * @type {number}\n */\n get eventPhase() {\n return pd(this).eventPhase\n },\n\n /**\n * Stop event bubbling.\n * @returns {void}\n */\n stopPropagation() {\n const data = pd(this)\n\n data.stopped = true\n if (typeof data.event.stopPropagation === \"function\") {\n data.event.stopPropagation()\n }\n },\n\n /**\n * Stop event bubbling.\n * @returns {void}\n */\n stopImmediatePropagation() {\n const data = pd(this)\n\n data.stopped = true\n data.immediateStopped = true\n if (typeof data.event.stopImmediatePropagation === \"function\") {\n data.event.stopImmediatePropagation()\n }\n },\n\n /**\n * The flag to be bubbling.\n * @type {boolean}\n */\n get bubbles() {\n return Boolean(pd(this).event.bubbles)\n },\n\n /**\n * The flag to be cancelable.\n * @type {boolean}\n */\n get cancelable() {\n return Boolean(pd(this).event.cancelable)\n },\n\n /**\n * Cancel this event.\n * @returns {void}\n */\n preventDefault() {\n setCancelFlag(pd(this))\n },\n\n /**\n * The flag to indicate cancellation state.\n * @type {boolean}\n */\n get defaultPrevented() {\n return pd(this).canceled\n },\n\n /**\n * The flag to be composed.\n * @type {boolean}\n */\n get composed() {\n return Boolean(pd(this).event.composed)\n },\n\n /**\n * The unix time of this event.\n * @type {number}\n */\n get timeStamp() {\n return pd(this).timeStamp\n },\n\n /**\n * The target of this event.\n * @type {EventTarget}\n * @deprecated\n */\n get srcElement() {\n return pd(this).eventTarget\n },\n\n /**\n * The flag to stop event bubbling.\n * @type {boolean}\n * @deprecated\n */\n get cancelBubble() {\n return pd(this).stopped\n },\n set cancelBubble(value) {\n if (!value) {\n return\n }\n const data = pd(this)\n\n data.stopped = true\n if (typeof data.event.cancelBubble === \"boolean\") {\n data.event.cancelBubble = true\n }\n },\n\n /**\n * The flag to indicate cancellation state.\n * @type {boolean}\n * @deprecated\n */\n get returnValue() {\n return !pd(this).canceled\n },\n set returnValue(value) {\n if (!value) {\n setCancelFlag(pd(this))\n }\n },\n\n /**\n * Initialize this event object. But do nothing under event dispatching.\n * @param {string} type The event type.\n * @param {boolean} [bubbles=false] The flag to be possible to bubble up.\n * @param {boolean} [cancelable=false] The flag to be possible to cancel.\n * @deprecated\n */\n initEvent() {\n // Do nothing.\n },\n}\n\n// `constructor` is not enumerable.\nObject.defineProperty(Event.prototype, \"constructor\", {\n value: Event,\n configurable: true,\n writable: true,\n})\n\n// Ensure `event instanceof window.Event` is `true`.\nif (typeof window !== \"undefined\" && typeof window.Event !== \"undefined\") {\n Object.setPrototypeOf(Event.prototype, window.Event.prototype)\n\n // Make association for wrappers.\n wrappers.set(window.Event.prototype, Event)\n}\n\n/**\n * Get the property descriptor to redirect a given property.\n * @param {string} key Property name to define property descriptor.\n * @returns {PropertyDescriptor} The property descriptor to redirect the property.\n * @private\n */\nfunction defineRedirectDescriptor(key) {\n return {\n get() {\n return pd(this).event[key]\n },\n set(value) {\n pd(this).event[key] = value\n },\n configurable: true,\n enumerable: true,\n }\n}\n\n/**\n * Get the property descriptor to call a given method property.\n * @param {string} key Property name to define property descriptor.\n * @returns {PropertyDescriptor} The property descriptor to call the method property.\n * @private\n */\nfunction defineCallDescriptor(key) {\n return {\n value() {\n const event = pd(this).event\n return event[key].apply(event, arguments)\n },\n configurable: true,\n enumerable: true,\n }\n}\n\n/**\n * Define new wrapper class.\n * @param {Function} BaseEvent The base wrapper class.\n * @param {Object} proto The prototype of the original event.\n * @returns {Function} The defined wrapper class.\n * @private\n */\nfunction defineWrapper(BaseEvent, proto) {\n const keys = Object.keys(proto)\n if (keys.length === 0) {\n return BaseEvent\n }\n\n /** CustomEvent */\n function CustomEvent(eventTarget, event) {\n BaseEvent.call(this, eventTarget, event)\n }\n\n CustomEvent.prototype = Object.create(BaseEvent.prototype, {\n constructor: { value: CustomEvent, configurable: true, writable: true },\n })\n\n // Define accessors.\n for (let i = 0; i < keys.length; ++i) {\n const key = keys[i]\n if (!(key in BaseEvent.prototype)) {\n const descriptor = Object.getOwnPropertyDescriptor(proto, key)\n const isFunc = typeof descriptor.value === \"function\"\n Object.defineProperty(\n CustomEvent.prototype,\n key,\n isFunc\n ? defineCallDescriptor(key)\n : defineRedirectDescriptor(key)\n )\n }\n }\n\n return CustomEvent\n}\n\n/**\n * Get the wrapper class of a given prototype.\n * @param {Object} proto The prototype of the original event to get its wrapper.\n * @returns {Function} The wrapper class.\n * @private\n */\nfunction getWrapper(proto) {\n if (proto == null || proto === Object.prototype) {\n return Event\n }\n\n let wrapper = wrappers.get(proto)\n if (wrapper == null) {\n wrapper = defineWrapper(getWrapper(Object.getPrototypeOf(proto)), proto)\n wrappers.set(proto, wrapper)\n }\n return wrapper\n}\n\n/**\n * Wrap a given event to management a dispatching.\n * @param {EventTarget} eventTarget The event target of this dispatching.\n * @param {Object} event The event to wrap.\n * @returns {Event} The wrapper instance.\n * @private\n */\nexport function wrapEvent(eventTarget, event) {\n const Wrapper = getWrapper(Object.getPrototypeOf(event))\n return new Wrapper(eventTarget, event)\n}\n\n/**\n * Get the immediateStopped flag of a given event.\n * @param {Event} event The event to get.\n * @returns {boolean} The flag to stop propagation immediately.\n * @private\n */\nexport function isStopped(event) {\n return pd(event).immediateStopped\n}\n\n/**\n * Set the current event phase of a given event.\n * @param {Event} event The event to set current target.\n * @param {number} eventPhase New event phase.\n * @returns {void}\n * @private\n */\nexport function setEventPhase(event, eventPhase) {\n pd(event).eventPhase = eventPhase\n}\n\n/**\n * Set the current target of a given event.\n * @param {Event} event The event to set current target.\n * @param {EventTarget|null} currentTarget New current target.\n * @returns {void}\n * @private\n */\nexport function setCurrentTarget(event, currentTarget) {\n pd(event).currentTarget = currentTarget\n}\n\n/**\n * Set a passive listener of a given event.\n * @param {Event} event The event to set current target.\n * @param {Function|null} passiveListener New passive listener.\n * @returns {void}\n * @private\n */\nexport function setPassiveListener(event, passiveListener) {\n pd(event).passiveListener = passiveListener\n}\n","import {\n isStopped,\n setCurrentTarget,\n setEventPhase,\n setPassiveListener,\n wrapEvent,\n} from \"./event.mjs\"\n\n/**\n * @typedef {object} ListenerNode\n * @property {Function} listener\n * @property {1|2|3} listenerType\n * @property {boolean} passive\n * @property {boolean} once\n * @property {ListenerNode|null} next\n * @private\n */\n\n/**\n * @type {WeakMap>}\n * @private\n */\nconst listenersMap = new WeakMap()\n\n// Listener types\nconst CAPTURE = 1\nconst BUBBLE = 2\nconst ATTRIBUTE = 3\n\n/**\n * Check whether a given value is an object or not.\n * @param {any} x The value to check.\n * @returns {boolean} `true` if the value is an object.\n */\nfunction isObject(x) {\n return x !== null && typeof x === \"object\" //eslint-disable-line no-restricted-syntax\n}\n\n/**\n * Get listeners.\n * @param {EventTarget} eventTarget The event target to get.\n * @returns {Map} The listeners.\n * @private\n */\nfunction getListeners(eventTarget) {\n const listeners = listenersMap.get(eventTarget)\n if (listeners == null) {\n throw new TypeError(\n \"'this' is expected an EventTarget object, but got another value.\"\n )\n }\n return listeners\n}\n\n/**\n * Get the property descriptor for the event attribute of a given event.\n * @param {string} eventName The event name to get property descriptor.\n * @returns {PropertyDescriptor} The property descriptor.\n * @private\n */\nfunction defineEventAttributeDescriptor(eventName) {\n return {\n get() {\n const listeners = getListeners(this)\n let node = listeners.get(eventName)\n while (node != null) {\n if (node.listenerType === ATTRIBUTE) {\n return node.listener\n }\n node = node.next\n }\n return null\n },\n\n set(listener) {\n if (typeof listener !== \"function\" && !isObject(listener)) {\n listener = null // eslint-disable-line no-param-reassign\n }\n const listeners = getListeners(this)\n\n // Traverse to the tail while removing old value.\n let prev = null\n let node = listeners.get(eventName)\n while (node != null) {\n if (node.listenerType === ATTRIBUTE) {\n // Remove old value.\n if (prev !== null) {\n prev.next = node.next\n } else if (node.next !== null) {\n listeners.set(eventName, node.next)\n } else {\n listeners.delete(eventName)\n }\n } else {\n prev = node\n }\n\n node = node.next\n }\n\n // Add new value.\n if (listener !== null) {\n const newNode = {\n listener,\n listenerType: ATTRIBUTE,\n passive: false,\n once: false,\n next: null,\n }\n if (prev === null) {\n listeners.set(eventName, newNode)\n } else {\n prev.next = newNode\n }\n }\n },\n configurable: true,\n enumerable: true,\n }\n}\n\n/**\n * Define an event attribute (e.g. `eventTarget.onclick`).\n * @param {Object} eventTargetPrototype The event target prototype to define an event attrbite.\n * @param {string} eventName The event name to define.\n * @returns {void}\n */\nfunction defineEventAttribute(eventTargetPrototype, eventName) {\n Object.defineProperty(\n eventTargetPrototype,\n `on${eventName}`,\n defineEventAttributeDescriptor(eventName)\n )\n}\n\n/**\n * Define a custom EventTarget with event attributes.\n * @param {string[]} eventNames Event names for event attributes.\n * @returns {EventTarget} The custom EventTarget.\n * @private\n */\nfunction defineCustomEventTarget(eventNames) {\n /** CustomEventTarget */\n function CustomEventTarget() {\n EventTarget.call(this)\n }\n\n CustomEventTarget.prototype = Object.create(EventTarget.prototype, {\n constructor: {\n value: CustomEventTarget,\n configurable: true,\n writable: true,\n },\n })\n\n for (let i = 0; i < eventNames.length; ++i) {\n defineEventAttribute(CustomEventTarget.prototype, eventNames[i])\n }\n\n return CustomEventTarget\n}\n\n/**\n * EventTarget.\n *\n * - This is constructor if no arguments.\n * - This is a function which returns a CustomEventTarget constructor if there are arguments.\n *\n * For example:\n *\n * class A extends EventTarget {}\n * class B extends EventTarget(\"message\") {}\n * class C extends EventTarget(\"message\", \"error\") {}\n * class D extends EventTarget([\"message\", \"error\"]) {}\n */\nfunction EventTarget() {\n /*eslint-disable consistent-return */\n if (this instanceof EventTarget) {\n listenersMap.set(this, new Map())\n return\n }\n if (arguments.length === 1 && Array.isArray(arguments[0])) {\n return defineCustomEventTarget(arguments[0])\n }\n if (arguments.length > 0) {\n const types = new Array(arguments.length)\n for (let i = 0; i < arguments.length; ++i) {\n types[i] = arguments[i]\n }\n return defineCustomEventTarget(types)\n }\n throw new TypeError(\"Cannot call a class as a function\")\n /*eslint-enable consistent-return */\n}\n\n// Should be enumerable, but class methods are not enumerable.\nEventTarget.prototype = {\n /**\n * Add a given listener to this event target.\n * @param {string} eventName The event name to add.\n * @param {Function} listener The listener to add.\n * @param {boolean|{capture?:boolean,passive?:boolean,once?:boolean}} [options] The options for this listener.\n * @returns {void}\n */\n addEventListener(eventName, listener, options) {\n if (listener == null) {\n return\n }\n if (typeof listener !== \"function\" && !isObject(listener)) {\n throw new TypeError(\"'listener' should be a function or an object.\")\n }\n\n const listeners = getListeners(this)\n const optionsIsObj = isObject(options)\n const capture = optionsIsObj\n ? Boolean(options.capture)\n : Boolean(options)\n const listenerType = capture ? CAPTURE : BUBBLE\n const newNode = {\n listener,\n listenerType,\n passive: optionsIsObj && Boolean(options.passive),\n once: optionsIsObj && Boolean(options.once),\n next: null,\n }\n\n // Set it as the first node if the first node is null.\n let node = listeners.get(eventName)\n if (node === undefined) {\n listeners.set(eventName, newNode)\n return\n }\n\n // Traverse to the tail while checking duplication..\n let prev = null\n while (node != null) {\n if (\n node.listener === listener &&\n node.listenerType === listenerType\n ) {\n // Should ignore duplication.\n return\n }\n prev = node\n node = node.next\n }\n\n // Add it.\n prev.next = newNode\n },\n\n /**\n * Remove a given listener from this event target.\n * @param {string} eventName The event name to remove.\n * @param {Function} listener The listener to remove.\n * @param {boolean|{capture?:boolean,passive?:boolean,once?:boolean}} [options] The options for this listener.\n * @returns {void}\n */\n removeEventListener(eventName, listener, options) {\n if (listener == null) {\n return\n }\n\n const listeners = getListeners(this)\n const capture = isObject(options)\n ? Boolean(options.capture)\n : Boolean(options)\n const listenerType = capture ? CAPTURE : BUBBLE\n\n let prev = null\n let node = listeners.get(eventName)\n while (node != null) {\n if (\n node.listener === listener &&\n node.listenerType === listenerType\n ) {\n if (prev !== null) {\n prev.next = node.next\n } else if (node.next !== null) {\n listeners.set(eventName, node.next)\n } else {\n listeners.delete(eventName)\n }\n return\n }\n\n prev = node\n node = node.next\n }\n },\n\n /**\n * Dispatch a given event.\n * @param {Event|{type:string}} event The event to dispatch.\n * @returns {boolean} `false` if canceled.\n */\n dispatchEvent(event) {\n if (event == null || typeof event.type !== \"string\") {\n throw new TypeError('\"event.type\" should be a string.')\n }\n\n // If listeners aren't registered, terminate.\n const listeners = getListeners(this)\n const eventName = event.type\n let node = listeners.get(eventName)\n if (node == null) {\n return true\n }\n\n // Since we cannot rewrite several properties, so wrap object.\n const wrappedEvent = wrapEvent(this, event)\n\n // This doesn't process capturing phase and bubbling phase.\n // This isn't participating in a tree.\n let prev = null\n while (node != null) {\n // Remove this listener if it's once\n if (node.once) {\n if (prev !== null) {\n prev.next = node.next\n } else if (node.next !== null) {\n listeners.set(eventName, node.next)\n } else {\n listeners.delete(eventName)\n }\n } else {\n prev = node\n }\n\n // Call this listener\n setPassiveListener(\n wrappedEvent,\n node.passive ? node.listener : null\n )\n if (typeof node.listener === \"function\") {\n try {\n node.listener.call(this, wrappedEvent)\n } catch (err) {\n if (\n typeof console !== \"undefined\" &&\n typeof console.error === \"function\"\n ) {\n console.error(err)\n }\n }\n } else if (\n node.listenerType !== ATTRIBUTE &&\n typeof node.listener.handleEvent === \"function\"\n ) {\n node.listener.handleEvent(wrappedEvent)\n }\n\n // Break if `event.stopImmediatePropagation` was called.\n if (isStopped(wrappedEvent)) {\n break\n }\n\n node = node.next\n }\n setPassiveListener(wrappedEvent, null)\n setEventPhase(wrappedEvent, 0)\n setCurrentTarget(wrappedEvent, null)\n\n return !wrappedEvent.defaultPrevented\n },\n}\n\n// `constructor` is not enumerable.\nObject.defineProperty(EventTarget.prototype, \"constructor\", {\n value: EventTarget,\n configurable: true,\n writable: true,\n})\n\n// Ensure `eventTarget instanceof window.EventTarget` is `true`.\nif (\n typeof window !== \"undefined\" &&\n typeof window.EventTarget !== \"undefined\"\n) {\n Object.setPrototypeOf(EventTarget.prototype, window.EventTarget.prototype)\n}\n\nexport { defineEventAttribute, EventTarget }\nexport default EventTarget\n"],"names":[],"mappings":";;;;;AAAA;;;;;;;;;;;;;;;;;;;AAmBA,MAAM,WAAW,GAAG,IAAI,OAAO,GAAE;;;;;;;AAOjC,MAAM,QAAQ,GAAG,IAAI,OAAO,GAAE;;;;;;;;AAQ9B,SAAS,EAAE,CAAC,KAAK,EAAE;IACf,MAAM,IAAI,GAAG,WAAW,CAAC,GAAG,CAAC,KAAK,EAAC;IACnC,OAAO,CAAC,MAAM;QACV,IAAI,IAAI,IAAI;QACZ,6CAA6C;QAC7C,KAAK;MACR;IACD,OAAO,IAAI;CACd;;;;;;AAMD,SAAS,aAAa,CAAC,IAAI,EAAE;IACzB,IAAI,IAAI,CAAC,eAAe,IAAI,IAAI,EAAE;QAC9B;YACI,OAAO,OAAO,KAAK,WAAW;YAC9B,OAAO,OAAO,CAAC,KAAK,KAAK,UAAU;UACrC;YACE,OAAO,CAAC,KAAK;gBACT,oEAAoE;gBACpE,IAAI,CAAC,eAAe;cACvB;SACJ;QACD,MAAM;KACT;IACD,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE;QACxB,MAAM;KACT;;IAED,IAAI,CAAC,QAAQ,GAAG,KAAI;IACpB,IAAI,OAAO,IAAI,CAAC,KAAK,CAAC,cAAc,KAAK,UAAU,EAAE;QACjD,IAAI,CAAC,KAAK,CAAC,cAAc,GAAE;KAC9B;CACJ;;;;;;;;;;;;AAYD,SAAS,KAAK,CAAC,WAAW,EAAE,KAAK,EAAE;IAC/B,WAAW,CAAC,GAAG,CAAC,IAAI,EAAE;QAClB,WAAW;QACX,KAAK;QACL,UAAU,EAAE,CAAC;QACb,aAAa,EAAE,WAAW;QAC1B,QAAQ,EAAE,KAAK;QACf,OAAO,EAAE,KAAK;QACd,gBAAgB,EAAE,KAAK;QACvB,eAAe,EAAE,IAAI;QACrB,SAAS,EAAE,KAAK,CAAC,SAAS,IAAI,IAAI,CAAC,GAAG,EAAE;KAC3C,EAAC;;;IAGF,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,WAAW,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,EAAC;;;IAG5E,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,EAAC;IAC/B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE;QAClC,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,EAAC;QACnB,IAAI,EAAE,GAAG,IAAI,IAAI,CAAC,EAAE;YAChB,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,EAAE,wBAAwB,CAAC,GAAG,CAAC,EAAC;SAClE;KACJ;CACJ;;;AAGD,KAAK,CAAC,SAAS,GAAG;;;;;IAKd,IAAI,IAAI,GAAG;QACP,OAAO,EAAE,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,IAAI;KAC7B;;;;;;IAMD,IAAI,MAAM,GAAG;QACT,OAAO,EAAE,CAAC,IAAI,CAAC,CAAC,WAAW;KAC9B;;;;;;IAMD,IAAI,aAAa,GAAG;QAChB,OAAO,EAAE,CAAC,IAAI,CAAC,CAAC,aAAa;KAChC;;;;;IAKD,YAAY,GAAG;QACX,MAAM,aAAa,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,cAAa;QAC5C,IAAI,aAAa,IAAI,IAAI,EAAE;YACvB,OAAO,EAAE;SACZ;QACD,OAAO,CAAC,aAAa,CAAC;KACzB;;;;;;IAMD,IAAI,IAAI,GAAG;QACP,OAAO,CAAC;KACX;;;;;;IAMD,IAAI,eAAe,GAAG;QAClB,OAAO,CAAC;KACX;;;;;;IAMD,IAAI,SAAS,GAAG;QACZ,OAAO,CAAC;KACX;;;;;;IAMD,IAAI,cAAc,GAAG;QACjB,OAAO,CAAC;KACX;;;;;;IAMD,IAAI,UAAU,GAAG;QACb,OAAO,EAAE,CAAC,IAAI,CAAC,CAAC,UAAU;KAC7B;;;;;;IAMD,eAAe,GAAG;QACd,MAAM,IAAI,GAAG,EAAE,CAAC,IAAI,EAAC;;QAErB,IAAI,CAAC,OAAO,GAAG,KAAI;QACnB,IAAI,OAAO,IAAI,CAAC,KAAK,CAAC,eAAe,KAAK,UAAU,EAAE;YAClD,IAAI,CAAC,KAAK,CAAC,eAAe,GAAE;SAC/B;KACJ;;;;;;IAMD,wBAAwB,GAAG;QACvB,MAAM,IAAI,GAAG,EAAE,CAAC,IAAI,EAAC;;QAErB,IAAI,CAAC,OAAO,GAAG,KAAI;QACnB,IAAI,CAAC,gBAAgB,GAAG,KAAI;QAC5B,IAAI,OAAO,IAAI,CAAC,KAAK,CAAC,wBAAwB,KAAK,UAAU,EAAE;YAC3D,IAAI,CAAC,KAAK,CAAC,wBAAwB,GAAE;SACxC;KACJ;;;;;;IAMD,IAAI,OAAO,GAAG;QACV,OAAO,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC;KACzC;;;;;;IAMD,IAAI,UAAU,GAAG;QACb,OAAO,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC;KAC5C;;;;;;IAMD,cAAc,GAAG;QACb,aAAa,CAAC,EAAE,CAAC,IAAI,CAAC,EAAC;KAC1B;;;;;;IAMD,IAAI,gBAAgB,GAAG;QACnB,OAAO,EAAE,CAAC,IAAI,CAAC,CAAC,QAAQ;KAC3B;;;;;;IAMD,IAAI,QAAQ,GAAG;QACX,OAAO,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC;KAC1C;;;;;;IAMD,IAAI,SAAS,GAAG;QACZ,OAAO,EAAE,CAAC,IAAI,CAAC,CAAC,SAAS;KAC5B;;;;;;;IAOD,IAAI,UAAU,GAAG;QACb,OAAO,EAAE,CAAC,IAAI,CAAC,CAAC,WAAW;KAC9B;;;;;;;IAOD,IAAI,YAAY,GAAG;QACf,OAAO,EAAE,CAAC,IAAI,CAAC,CAAC,OAAO;KAC1B;IACD,IAAI,YAAY,CAAC,KAAK,EAAE;QACpB,IAAI,CAAC,KAAK,EAAE;YACR,MAAM;SACT;QACD,MAAM,IAAI,GAAG,EAAE,CAAC,IAAI,EAAC;;QAErB,IAAI,CAAC,OAAO,GAAG,KAAI;QACnB,IAAI,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,KAAK,SAAS,EAAE;YAC9C,IAAI,CAAC,KAAK,CAAC,YAAY,GAAG,KAAI;SACjC;KACJ;;;;;;;IAOD,IAAI,WAAW,GAAG;QACd,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,QAAQ;KAC5B;IACD,IAAI,WAAW,CAAC,KAAK,EAAE;QACnB,IAAI,CAAC,KAAK,EAAE;YACR,aAAa,CAAC,EAAE,CAAC,IAAI,CAAC,EAAC;SAC1B;KACJ;;;;;;;;;IASD,SAAS,GAAG;;KAEX;EACJ;;;AAGD,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,SAAS,EAAE,aAAa,EAAE;IAClD,KAAK,EAAE,KAAK;IACZ,YAAY,EAAE,IAAI;IAClB,QAAQ,EAAE,IAAI;CACjB,EAAC;;;AAGF,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,MAAM,CAAC,KAAK,KAAK,WAAW,EAAE;IACtE,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,SAAS,EAAE,MAAM,CAAC,KAAK,CAAC,SAAS,EAAC;;;IAG9D,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,EAAE,KAAK,EAAC;CAC9C;;;;;;;;AAQD,SAAS,wBAAwB,CAAC,GAAG,EAAE;IACnC,OAAO;QACH,GAAG,GAAG;YACF,OAAO,EAAE,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC;SAC7B;QACD,GAAG,CAAC,KAAK,EAAE;YACP,EAAE,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,MAAK;SAC9B;QACD,YAAY,EAAE,IAAI;QAClB,UAAU,EAAE,IAAI;KACnB;CACJ;;;;;;;;AAQD,SAAS,oBAAoB,CAAC,GAAG,EAAE;IAC/B,OAAO;QACH,KAAK,GAAG;YACJ,MAAM,KAAK,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,MAAK;YAC5B,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,KAAK,EAAE,SAAS,CAAC;SAC5C;QACD,YAAY,EAAE,IAAI;QAClB,UAAU,EAAE,IAAI;KACnB;CACJ;;;;;;;;;AASD,SAAS,aAAa,CAAC,SAAS,EAAE,KAAK,EAAE;IACrC,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,EAAC;IAC/B,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE;QACnB,OAAO,SAAS;KACnB;;;IAGD,SAAS,WAAW,CAAC,WAAW,EAAE,KAAK,EAAE;QACrC,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,WAAW,EAAE,KAAK,EAAC;KAC3C;;IAED,WAAW,CAAC,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,SAAS,EAAE;QACvD,WAAW,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE;KAC1E,EAAC;;;IAGF,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE;QAClC,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,EAAC;QACnB,IAAI,EAAE,GAAG,IAAI,SAAS,CAAC,SAAS,CAAC,EAAE;YAC/B,MAAM,UAAU,GAAG,MAAM,CAAC,wBAAwB,CAAC,KAAK,EAAE,GAAG,EAAC;YAC9D,MAAM,MAAM,GAAG,OAAO,UAAU,CAAC,KAAK,KAAK,WAAU;YACrD,MAAM,CAAC,cAAc;gBACjB,WAAW,CAAC,SAAS;gBACrB,GAAG;gBACH,MAAM;sBACA,oBAAoB,CAAC,GAAG,CAAC;sBACzB,wBAAwB,CAAC,GAAG,CAAC;cACtC;SACJ;KACJ;;IAED,OAAO,WAAW;CACrB;;;;;;;;AAQD,SAAS,UAAU,CAAC,KAAK,EAAE;IACvB,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,KAAK,MAAM,CAAC,SAAS,EAAE;QAC7C,OAAO,KAAK;KACf;;IAED,IAAI,OAAO,GAAG,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAC;IACjC,IAAI,OAAO,IAAI,IAAI,EAAE;QACjB,OAAO,GAAG,aAAa,CAAC,UAAU,CAAC,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,EAAC;QACxE,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,EAAC;KAC/B;IACD,OAAO,OAAO;CACjB;;;;;;;;;AASD,AAAO,SAAS,SAAS,CAAC,WAAW,EAAE,KAAK,EAAE;IAC1C,MAAM,OAAO,GAAG,UAAU,CAAC,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,EAAC;IACxD,OAAO,IAAI,OAAO,CAAC,WAAW,EAAE,KAAK,CAAC;CACzC;;;;;;;;AAQD,AAAO,SAAS,SAAS,CAAC,KAAK,EAAE;IAC7B,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC,gBAAgB;CACpC;;;;;;;;;AASD,AAAO,SAAS,aAAa,CAAC,KAAK,EAAE,UAAU,EAAE;IAC7C,EAAE,CAAC,KAAK,CAAC,CAAC,UAAU,GAAG,WAAU;CACpC;;;;;;;;;AASD,AAAO,SAAS,gBAAgB,CAAC,KAAK,EAAE,aAAa,EAAE;IACnD,EAAE,CAAC,KAAK,CAAC,CAAC,aAAa,GAAG,cAAa;CAC1C;;;;;;;;;AASD,AAAO,SAAS,kBAAkB,CAAC,KAAK,EAAE,eAAe,EAAE;IACvD,EAAE,CAAC,KAAK,CAAC,CAAC,eAAe,GAAG,gBAAe;CAC9C;;ACtdD;;;;;;;;;;;;;;AAcA,MAAM,YAAY,GAAG,IAAI,OAAO,GAAE;;;AAGlC,MAAM,OAAO,GAAG,EAAC;AACjB,MAAM,MAAM,GAAG,EAAC;AAChB,MAAM,SAAS,GAAG,EAAC;;;;;;;AAOnB,SAAS,QAAQ,CAAC,CAAC,EAAE;IACjB,OAAO,CAAC,KAAK,IAAI,IAAI,OAAO,CAAC,KAAK,QAAQ;CAC7C;;;;;;;;AAQD,SAAS,YAAY,CAAC,WAAW,EAAE;IAC/B,MAAM,SAAS,GAAG,YAAY,CAAC,GAAG,CAAC,WAAW,EAAC;IAC/C,IAAI,SAAS,IAAI,IAAI,EAAE;QACnB,MAAM,IAAI,SAAS;YACf,kEAAkE;SACrE;KACJ;IACD,OAAO,SAAS;CACnB;;;;;;;;AAQD,SAAS,8BAA8B,CAAC,SAAS,EAAE;IAC/C,OAAO;QACH,GAAG,GAAG;YACF,MAAM,SAAS,GAAG,YAAY,CAAC,IAAI,EAAC;YACpC,IAAI,IAAI,GAAG,SAAS,CAAC,GAAG,CAAC,SAAS,EAAC;YACnC,OAAO,IAAI,IAAI,IAAI,EAAE;gBACjB,IAAI,IAAI,CAAC,YAAY,KAAK,SAAS,EAAE;oBACjC,OAAO,IAAI,CAAC,QAAQ;iBACvB;gBACD,IAAI,GAAG,IAAI,CAAC,KAAI;aACnB;YACD,OAAO,IAAI;SACd;;QAED,GAAG,CAAC,QAAQ,EAAE;YACV,IAAI,OAAO,QAAQ,KAAK,UAAU,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE;gBACvD,QAAQ,GAAG,KAAI;aAClB;YACD,MAAM,SAAS,GAAG,YAAY,CAAC,IAAI,EAAC;;;YAGpC,IAAI,IAAI,GAAG,KAAI;YACf,IAAI,IAAI,GAAG,SAAS,CAAC,GAAG,CAAC,SAAS,EAAC;YACnC,OAAO,IAAI,IAAI,IAAI,EAAE;gBACjB,IAAI,IAAI,CAAC,YAAY,KAAK,SAAS,EAAE;;oBAEjC,IAAI,IAAI,KAAK,IAAI,EAAE;wBACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,KAAI;qBACxB,MAAM,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI,EAAE;wBAC3B,SAAS,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,EAAC;qBACtC,MAAM;wBACH,SAAS,CAAC,MAAM,CAAC,SAAS,EAAC;qBAC9B;iBACJ,MAAM;oBACH,IAAI,GAAG,KAAI;iBACd;;gBAED,IAAI,GAAG,IAAI,CAAC,KAAI;aACnB;;;YAGD,IAAI,QAAQ,KAAK,IAAI,EAAE;gBACnB,MAAM,OAAO,GAAG;oBACZ,QAAQ;oBACR,YAAY,EAAE,SAAS;oBACvB,OAAO,EAAE,KAAK;oBACd,IAAI,EAAE,KAAK;oBACX,IAAI,EAAE,IAAI;kBACb;gBACD,IAAI,IAAI,KAAK,IAAI,EAAE;oBACf,SAAS,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,EAAC;iBACpC,MAAM;oBACH,IAAI,CAAC,IAAI,GAAG,QAAO;iBACtB;aACJ;SACJ;QACD,YAAY,EAAE,IAAI;QAClB,UAAU,EAAE,IAAI;KACnB;CACJ;;;;;;;;AAQD,SAAS,oBAAoB,CAAC,oBAAoB,EAAE,SAAS,EAAE;IAC3D,MAAM,CAAC,cAAc;QACjB,oBAAoB;QACpB,CAAC,EAAE,EAAE,SAAS,CAAC,CAAC;QAChB,8BAA8B,CAAC,SAAS,CAAC;MAC5C;CACJ;;;;;;;;AAQD,SAAS,uBAAuB,CAAC,UAAU,EAAE;;IAEzC,SAAS,iBAAiB,GAAG;QACzB,WAAW,CAAC,IAAI,CAAC,IAAI,EAAC;KACzB;;IAED,iBAAiB,CAAC,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,SAAS,EAAE;QAC/D,WAAW,EAAE;YACT,KAAK,EAAE,iBAAiB;YACxB,YAAY,EAAE,IAAI;YAClB,QAAQ,EAAE,IAAI;SACjB;KACJ,EAAC;;IAEF,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE;QACxC,oBAAoB,CAAC,iBAAiB,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC,EAAC;KACnE;;IAED,OAAO,iBAAiB;CAC3B;;;;;;;;;;;;;;;AAeD,SAAS,WAAW,GAAG;;IAEnB,IAAI,IAAI,YAAY,WAAW,EAAE;QAC7B,YAAY,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,GAAG,EAAE,EAAC;QACjC,MAAM;KACT;IACD,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE;QACvD,OAAO,uBAAuB,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;KAC/C;IACD,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE;QACtB,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,SAAS,CAAC,MAAM,EAAC;QACzC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE;YACvC,KAAK,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,EAAC;SAC1B;QACD,OAAO,uBAAuB,CAAC,KAAK,CAAC;KACxC;IACD,MAAM,IAAI,SAAS,CAAC,mCAAmC,CAAC;;CAE3D;;;AAGD,WAAW,CAAC,SAAS,GAAG;;;;;;;;IAQpB,gBAAgB,CAAC,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE;QAC3C,IAAI,QAAQ,IAAI,IAAI,EAAE;YAClB,MAAM;SACT;QACD,IAAI,OAAO,QAAQ,KAAK,UAAU,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE;YACvD,MAAM,IAAI,SAAS,CAAC,+CAA+C,CAAC;SACvE;;QAED,MAAM,SAAS,GAAG,YAAY,CAAC,IAAI,EAAC;QACpC,MAAM,YAAY,GAAG,QAAQ,CAAC,OAAO,EAAC;QACtC,MAAM,OAAO,GAAG,YAAY;cACtB,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC;cACxB,OAAO,CAAC,OAAO,EAAC;QACtB,MAAM,YAAY,GAAG,OAAO,GAAG,OAAO,GAAG,OAAM;QAC/C,MAAM,OAAO,GAAG;YACZ,QAAQ;YACR,YAAY;YACZ,OAAO,EAAE,YAAY,IAAI,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC;YACjD,IAAI,EAAE,YAAY,IAAI,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC;YAC3C,IAAI,EAAE,IAAI;UACb;;;QAGD,IAAI,IAAI,GAAG,SAAS,CAAC,GAAG,CAAC,SAAS,EAAC;QACnC,IAAI,IAAI,KAAK,SAAS,EAAE;YACpB,SAAS,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,EAAC;YACjC,MAAM;SACT;;;QAGD,IAAI,IAAI,GAAG,KAAI;QACf,OAAO,IAAI,IAAI,IAAI,EAAE;YACjB;gBACI,IAAI,CAAC,QAAQ,KAAK,QAAQ;gBAC1B,IAAI,CAAC,YAAY,KAAK,YAAY;cACpC;;gBAEE,MAAM;aACT;YACD,IAAI,GAAG,KAAI;YACX,IAAI,GAAG,IAAI,CAAC,KAAI;SACnB;;;QAGD,IAAI,CAAC,IAAI,GAAG,QAAO;KACtB;;;;;;;;;IASD,mBAAmB,CAAC,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE;QAC9C,IAAI,QAAQ,IAAI,IAAI,EAAE;YAClB,MAAM;SACT;;QAED,MAAM,SAAS,GAAG,YAAY,CAAC,IAAI,EAAC;QACpC,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC;cAC3B,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC;cACxB,OAAO,CAAC,OAAO,EAAC;QACtB,MAAM,YAAY,GAAG,OAAO,GAAG,OAAO,GAAG,OAAM;;QAE/C,IAAI,IAAI,GAAG,KAAI;QACf,IAAI,IAAI,GAAG,SAAS,CAAC,GAAG,CAAC,SAAS,EAAC;QACnC,OAAO,IAAI,IAAI,IAAI,EAAE;YACjB;gBACI,IAAI,CAAC,QAAQ,KAAK,QAAQ;gBAC1B,IAAI,CAAC,YAAY,KAAK,YAAY;cACpC;gBACE,IAAI,IAAI,KAAK,IAAI,EAAE;oBACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,KAAI;iBACxB,MAAM,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI,EAAE;oBAC3B,SAAS,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,EAAC;iBACtC,MAAM;oBACH,SAAS,CAAC,MAAM,CAAC,SAAS,EAAC;iBAC9B;gBACD,MAAM;aACT;;YAED,IAAI,GAAG,KAAI;YACX,IAAI,GAAG,IAAI,CAAC,KAAI;SACnB;KACJ;;;;;;;IAOD,aAAa,CAAC,KAAK,EAAE;QACjB,IAAI,KAAK,IAAI,IAAI,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,EAAE;YACjD,MAAM,IAAI,SAAS,CAAC,kCAAkC,CAAC;SAC1D;;;QAGD,MAAM,SAAS,GAAG,YAAY,CAAC,IAAI,EAAC;QACpC,MAAM,SAAS,GAAG,KAAK,CAAC,KAAI;QAC5B,IAAI,IAAI,GAAG,SAAS,CAAC,GAAG,CAAC,SAAS,EAAC;QACnC,IAAI,IAAI,IAAI,IAAI,EAAE;YACd,OAAO,IAAI;SACd;;;QAGD,MAAM,YAAY,GAAG,SAAS,CAAC,IAAI,EAAE,KAAK,EAAC;;;;QAI3C,IAAI,IAAI,GAAG,KAAI;QACf,OAAO,IAAI,IAAI,IAAI,EAAE;;YAEjB,IAAI,IAAI,CAAC,IAAI,EAAE;gBACX,IAAI,IAAI,KAAK,IAAI,EAAE;oBACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,KAAI;iBACxB,MAAM,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI,EAAE;oBAC3B,SAAS,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,EAAC;iBACtC,MAAM;oBACH,SAAS,CAAC,MAAM,CAAC,SAAS,EAAC;iBAC9B;aACJ,MAAM;gBACH,IAAI,GAAG,KAAI;aACd;;;YAGD,kBAAkB;gBACd,YAAY;gBACZ,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,QAAQ,GAAG,IAAI;cACtC;YACD,IAAI,OAAO,IAAI,CAAC,QAAQ,KAAK,UAAU,EAAE;gBACrC,IAAI;oBACA,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,YAAY,EAAC;iBACzC,CAAC,OAAO,GAAG,EAAE;oBACV;wBACI,OAAO,OAAO,KAAK,WAAW;wBAC9B,OAAO,OAAO,CAAC,KAAK,KAAK,UAAU;sBACrC;wBACE,OAAO,CAAC,KAAK,CAAC,GAAG,EAAC;qBACrB;iBACJ;aACJ,MAAM;gBACH,IAAI,CAAC,YAAY,KAAK,SAAS;gBAC/B,OAAO,IAAI,CAAC,QAAQ,CAAC,WAAW,KAAK,UAAU;cACjD;gBACE,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,YAAY,EAAC;aAC1C;;;YAGD,IAAI,SAAS,CAAC,YAAY,CAAC,EAAE;gBACzB,KAAK;aACR;;YAED,IAAI,GAAG,IAAI,CAAC,KAAI;SACnB;QACD,kBAAkB,CAAC,YAAY,EAAE,IAAI,EAAC;QACtC,aAAa,CAAC,YAAY,EAAE,CAAC,EAAC;QAC9B,gBAAgB,CAAC,YAAY,EAAE,IAAI,EAAC;;QAEpC,OAAO,CAAC,YAAY,CAAC,gBAAgB;KACxC;EACJ;;;AAGD,MAAM,CAAC,cAAc,CAAC,WAAW,CAAC,SAAS,EAAE,aAAa,EAAE;IACxD,KAAK,EAAE,WAAW;IAClB,YAAY,EAAE,IAAI;IAClB,QAAQ,EAAE,IAAI;CACjB,EAAC;;;AAGF;IACI,OAAO,MAAM,KAAK,WAAW;IAC7B,OAAO,MAAM,CAAC,WAAW,KAAK,WAAW;EAC3C;IACE,MAAM,CAAC,cAAc,CAAC,WAAW,CAAC,SAAS,EAAE,MAAM,CAAC,WAAW,CAAC,SAAS,EAAC;CAC7E;;;;;"} \ No newline at end of file diff --git a/sandbox/tgbot/node_modules/event-target-shim/dist/event-target-shim.umd.js b/sandbox/tgbot/node_modules/event-target-shim/dist/event-target-shim.umd.js new file mode 100644 index 0000000..e7cf5d4 --- /dev/null +++ b/sandbox/tgbot/node_modules/event-target-shim/dist/event-target-shim.umd.js @@ -0,0 +1,6 @@ +/** + * @author Toru Nagashima + * @copyright 2015 Toru Nagashima. All rights reserved. + * See LICENSE file in root directory for full license. + */(function(a,b){"object"==typeof exports&&"undefined"!=typeof module?b(exports):"function"==typeof define&&define.amd?define(["exports"],b):(a=a||self,b(a.EventTargetShim={}))})(this,function(a){"use strict";function b(a){return b="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},b(a)}function c(a){var b=u.get(a);return console.assert(null!=b,"'this' is expected an Event object, but got",a),b}function d(a){return null==a.passiveListener?void(!a.event.cancelable||(a.canceled=!0,"function"==typeof a.event.preventDefault&&a.event.preventDefault())):void("undefined"!=typeof console&&"function"==typeof console.error&&console.error("Unable to preventDefault inside passive event listener invocation.",a.passiveListener))}function e(a,b){u.set(this,{eventTarget:a,event:b,eventPhase:2,currentTarget:a,canceled:!1,stopped:!1,immediateStopped:!1,passiveListener:null,timeStamp:b.timeStamp||Date.now()}),Object.defineProperty(this,"isTrusted",{value:!1,enumerable:!0});for(var c,d=Object.keys(b),e=0;e}\n * @private\n */\nconst privateData = new WeakMap()\n\n/**\n * Cache for wrapper classes.\n * @type {WeakMap}\n * @private\n */\nconst wrappers = new WeakMap()\n\n/**\n * Get private data.\n * @param {Event} event The event object to get private data.\n * @returns {PrivateData} The private data of the event.\n * @private\n */\nfunction pd(event) {\n const retv = privateData.get(event)\n console.assert(\n retv != null,\n \"'this' is expected an Event object, but got\",\n event\n )\n return retv\n}\n\n/**\n * https://dom.spec.whatwg.org/#set-the-canceled-flag\n * @param data {PrivateData} private data.\n */\nfunction setCancelFlag(data) {\n if (data.passiveListener != null) {\n if (\n typeof console !== \"undefined\" &&\n typeof console.error === \"function\"\n ) {\n console.error(\n \"Unable to preventDefault inside passive event listener invocation.\",\n data.passiveListener\n )\n }\n return\n }\n if (!data.event.cancelable) {\n return\n }\n\n data.canceled = true\n if (typeof data.event.preventDefault === \"function\") {\n data.event.preventDefault()\n }\n}\n\n/**\n * @see https://dom.spec.whatwg.org/#interface-event\n * @private\n */\n/**\n * The event wrapper.\n * @constructor\n * @param {EventTarget} eventTarget The event target of this dispatching.\n * @param {Event|{type:string}} event The original event to wrap.\n */\nfunction Event(eventTarget, event) {\n privateData.set(this, {\n eventTarget,\n event,\n eventPhase: 2,\n currentTarget: eventTarget,\n canceled: false,\n stopped: false,\n immediateStopped: false,\n passiveListener: null,\n timeStamp: event.timeStamp || Date.now(),\n })\n\n // https://heycam.github.io/webidl/#Unforgeable\n Object.defineProperty(this, \"isTrusted\", { value: false, enumerable: true })\n\n // Define accessors\n const keys = Object.keys(event)\n for (let i = 0; i < keys.length; ++i) {\n const key = keys[i]\n if (!(key in this)) {\n Object.defineProperty(this, key, defineRedirectDescriptor(key))\n }\n }\n}\n\n// Should be enumerable, but class methods are not enumerable.\nEvent.prototype = {\n /**\n * The type of this event.\n * @type {string}\n */\n get type() {\n return pd(this).event.type\n },\n\n /**\n * The target of this event.\n * @type {EventTarget}\n */\n get target() {\n return pd(this).eventTarget\n },\n\n /**\n * The target of this event.\n * @type {EventTarget}\n */\n get currentTarget() {\n return pd(this).currentTarget\n },\n\n /**\n * @returns {EventTarget[]} The composed path of this event.\n */\n composedPath() {\n const currentTarget = pd(this).currentTarget\n if (currentTarget == null) {\n return []\n }\n return [currentTarget]\n },\n\n /**\n * Constant of NONE.\n * @type {number}\n */\n get NONE() {\n return 0\n },\n\n /**\n * Constant of CAPTURING_PHASE.\n * @type {number}\n */\n get CAPTURING_PHASE() {\n return 1\n },\n\n /**\n * Constant of AT_TARGET.\n * @type {number}\n */\n get AT_TARGET() {\n return 2\n },\n\n /**\n * Constant of BUBBLING_PHASE.\n * @type {number}\n */\n get BUBBLING_PHASE() {\n return 3\n },\n\n /**\n * The target of this event.\n * @type {number}\n */\n get eventPhase() {\n return pd(this).eventPhase\n },\n\n /**\n * Stop event bubbling.\n * @returns {void}\n */\n stopPropagation() {\n const data = pd(this)\n\n data.stopped = true\n if (typeof data.event.stopPropagation === \"function\") {\n data.event.stopPropagation()\n }\n },\n\n /**\n * Stop event bubbling.\n * @returns {void}\n */\n stopImmediatePropagation() {\n const data = pd(this)\n\n data.stopped = true\n data.immediateStopped = true\n if (typeof data.event.stopImmediatePropagation === \"function\") {\n data.event.stopImmediatePropagation()\n }\n },\n\n /**\n * The flag to be bubbling.\n * @type {boolean}\n */\n get bubbles() {\n return Boolean(pd(this).event.bubbles)\n },\n\n /**\n * The flag to be cancelable.\n * @type {boolean}\n */\n get cancelable() {\n return Boolean(pd(this).event.cancelable)\n },\n\n /**\n * Cancel this event.\n * @returns {void}\n */\n preventDefault() {\n setCancelFlag(pd(this))\n },\n\n /**\n * The flag to indicate cancellation state.\n * @type {boolean}\n */\n get defaultPrevented() {\n return pd(this).canceled\n },\n\n /**\n * The flag to be composed.\n * @type {boolean}\n */\n get composed() {\n return Boolean(pd(this).event.composed)\n },\n\n /**\n * The unix time of this event.\n * @type {number}\n */\n get timeStamp() {\n return pd(this).timeStamp\n },\n\n /**\n * The target of this event.\n * @type {EventTarget}\n * @deprecated\n */\n get srcElement() {\n return pd(this).eventTarget\n },\n\n /**\n * The flag to stop event bubbling.\n * @type {boolean}\n * @deprecated\n */\n get cancelBubble() {\n return pd(this).stopped\n },\n set cancelBubble(value) {\n if (!value) {\n return\n }\n const data = pd(this)\n\n data.stopped = true\n if (typeof data.event.cancelBubble === \"boolean\") {\n data.event.cancelBubble = true\n }\n },\n\n /**\n * The flag to indicate cancellation state.\n * @type {boolean}\n * @deprecated\n */\n get returnValue() {\n return !pd(this).canceled\n },\n set returnValue(value) {\n if (!value) {\n setCancelFlag(pd(this))\n }\n },\n\n /**\n * Initialize this event object. But do nothing under event dispatching.\n * @param {string} type The event type.\n * @param {boolean} [bubbles=false] The flag to be possible to bubble up.\n * @param {boolean} [cancelable=false] The flag to be possible to cancel.\n * @deprecated\n */\n initEvent() {\n // Do nothing.\n },\n}\n\n// `constructor` is not enumerable.\nObject.defineProperty(Event.prototype, \"constructor\", {\n value: Event,\n configurable: true,\n writable: true,\n})\n\n// Ensure `event instanceof window.Event` is `true`.\nif (typeof window !== \"undefined\" && typeof window.Event !== \"undefined\") {\n Object.setPrototypeOf(Event.prototype, window.Event.prototype)\n\n // Make association for wrappers.\n wrappers.set(window.Event.prototype, Event)\n}\n\n/**\n * Get the property descriptor to redirect a given property.\n * @param {string} key Property name to define property descriptor.\n * @returns {PropertyDescriptor} The property descriptor to redirect the property.\n * @private\n */\nfunction defineRedirectDescriptor(key) {\n return {\n get() {\n return pd(this).event[key]\n },\n set(value) {\n pd(this).event[key] = value\n },\n configurable: true,\n enumerable: true,\n }\n}\n\n/**\n * Get the property descriptor to call a given method property.\n * @param {string} key Property name to define property descriptor.\n * @returns {PropertyDescriptor} The property descriptor to call the method property.\n * @private\n */\nfunction defineCallDescriptor(key) {\n return {\n value() {\n const event = pd(this).event\n return event[key].apply(event, arguments)\n },\n configurable: true,\n enumerable: true,\n }\n}\n\n/**\n * Define new wrapper class.\n * @param {Function} BaseEvent The base wrapper class.\n * @param {Object} proto The prototype of the original event.\n * @returns {Function} The defined wrapper class.\n * @private\n */\nfunction defineWrapper(BaseEvent, proto) {\n const keys = Object.keys(proto)\n if (keys.length === 0) {\n return BaseEvent\n }\n\n /** CustomEvent */\n function CustomEvent(eventTarget, event) {\n BaseEvent.call(this, eventTarget, event)\n }\n\n CustomEvent.prototype = Object.create(BaseEvent.prototype, {\n constructor: { value: CustomEvent, configurable: true, writable: true },\n })\n\n // Define accessors.\n for (let i = 0; i < keys.length; ++i) {\n const key = keys[i]\n if (!(key in BaseEvent.prototype)) {\n const descriptor = Object.getOwnPropertyDescriptor(proto, key)\n const isFunc = typeof descriptor.value === \"function\"\n Object.defineProperty(\n CustomEvent.prototype,\n key,\n isFunc\n ? defineCallDescriptor(key)\n : defineRedirectDescriptor(key)\n )\n }\n }\n\n return CustomEvent\n}\n\n/**\n * Get the wrapper class of a given prototype.\n * @param {Object} proto The prototype of the original event to get its wrapper.\n * @returns {Function} The wrapper class.\n * @private\n */\nfunction getWrapper(proto) {\n if (proto == null || proto === Object.prototype) {\n return Event\n }\n\n let wrapper = wrappers.get(proto)\n if (wrapper == null) {\n wrapper = defineWrapper(getWrapper(Object.getPrototypeOf(proto)), proto)\n wrappers.set(proto, wrapper)\n }\n return wrapper\n}\n\n/**\n * Wrap a given event to management a dispatching.\n * @param {EventTarget} eventTarget The event target of this dispatching.\n * @param {Object} event The event to wrap.\n * @returns {Event} The wrapper instance.\n * @private\n */\nexport function wrapEvent(eventTarget, event) {\n const Wrapper = getWrapper(Object.getPrototypeOf(event))\n return new Wrapper(eventTarget, event)\n}\n\n/**\n * Get the immediateStopped flag of a given event.\n * @param {Event} event The event to get.\n * @returns {boolean} The flag to stop propagation immediately.\n * @private\n */\nexport function isStopped(event) {\n return pd(event).immediateStopped\n}\n\n/**\n * Set the current event phase of a given event.\n * @param {Event} event The event to set current target.\n * @param {number} eventPhase New event phase.\n * @returns {void}\n * @private\n */\nexport function setEventPhase(event, eventPhase) {\n pd(event).eventPhase = eventPhase\n}\n\n/**\n * Set the current target of a given event.\n * @param {Event} event The event to set current target.\n * @param {EventTarget|null} currentTarget New current target.\n * @returns {void}\n * @private\n */\nexport function setCurrentTarget(event, currentTarget) {\n pd(event).currentTarget = currentTarget\n}\n\n/**\n * Set a passive listener of a given event.\n * @param {Event} event The event to set current target.\n * @param {Function|null} passiveListener New passive listener.\n * @returns {void}\n * @private\n */\nexport function setPassiveListener(event, passiveListener) {\n pd(event).passiveListener = passiveListener\n}\n","import {\n isStopped,\n setCurrentTarget,\n setEventPhase,\n setPassiveListener,\n wrapEvent,\n} from \"./event.mjs\"\n\n/**\n * @typedef {object} ListenerNode\n * @property {Function} listener\n * @property {1|2|3} listenerType\n * @property {boolean} passive\n * @property {boolean} once\n * @property {ListenerNode|null} next\n * @private\n */\n\n/**\n * @type {WeakMap>}\n * @private\n */\nconst listenersMap = new WeakMap()\n\n// Listener types\nconst CAPTURE = 1\nconst BUBBLE = 2\nconst ATTRIBUTE = 3\n\n/**\n * Check whether a given value is an object or not.\n * @param {any} x The value to check.\n * @returns {boolean} `true` if the value is an object.\n */\nfunction isObject(x) {\n return x !== null && typeof x === \"object\" //eslint-disable-line no-restricted-syntax\n}\n\n/**\n * Get listeners.\n * @param {EventTarget} eventTarget The event target to get.\n * @returns {Map} The listeners.\n * @private\n */\nfunction getListeners(eventTarget) {\n const listeners = listenersMap.get(eventTarget)\n if (listeners == null) {\n throw new TypeError(\n \"'this' is expected an EventTarget object, but got another value.\"\n )\n }\n return listeners\n}\n\n/**\n * Get the property descriptor for the event attribute of a given event.\n * @param {string} eventName The event name to get property descriptor.\n * @returns {PropertyDescriptor} The property descriptor.\n * @private\n */\nfunction defineEventAttributeDescriptor(eventName) {\n return {\n get() {\n const listeners = getListeners(this)\n let node = listeners.get(eventName)\n while (node != null) {\n if (node.listenerType === ATTRIBUTE) {\n return node.listener\n }\n node = node.next\n }\n return null\n },\n\n set(listener) {\n if (typeof listener !== \"function\" && !isObject(listener)) {\n listener = null // eslint-disable-line no-param-reassign\n }\n const listeners = getListeners(this)\n\n // Traverse to the tail while removing old value.\n let prev = null\n let node = listeners.get(eventName)\n while (node != null) {\n if (node.listenerType === ATTRIBUTE) {\n // Remove old value.\n if (prev !== null) {\n prev.next = node.next\n } else if (node.next !== null) {\n listeners.set(eventName, node.next)\n } else {\n listeners.delete(eventName)\n }\n } else {\n prev = node\n }\n\n node = node.next\n }\n\n // Add new value.\n if (listener !== null) {\n const newNode = {\n listener,\n listenerType: ATTRIBUTE,\n passive: false,\n once: false,\n next: null,\n }\n if (prev === null) {\n listeners.set(eventName, newNode)\n } else {\n prev.next = newNode\n }\n }\n },\n configurable: true,\n enumerable: true,\n }\n}\n\n/**\n * Define an event attribute (e.g. `eventTarget.onclick`).\n * @param {Object} eventTargetPrototype The event target prototype to define an event attrbite.\n * @param {string} eventName The event name to define.\n * @returns {void}\n */\nfunction defineEventAttribute(eventTargetPrototype, eventName) {\n Object.defineProperty(\n eventTargetPrototype,\n `on${eventName}`,\n defineEventAttributeDescriptor(eventName)\n )\n}\n\n/**\n * Define a custom EventTarget with event attributes.\n * @param {string[]} eventNames Event names for event attributes.\n * @returns {EventTarget} The custom EventTarget.\n * @private\n */\nfunction defineCustomEventTarget(eventNames) {\n /** CustomEventTarget */\n function CustomEventTarget() {\n EventTarget.call(this)\n }\n\n CustomEventTarget.prototype = Object.create(EventTarget.prototype, {\n constructor: {\n value: CustomEventTarget,\n configurable: true,\n writable: true,\n },\n })\n\n for (let i = 0; i < eventNames.length; ++i) {\n defineEventAttribute(CustomEventTarget.prototype, eventNames[i])\n }\n\n return CustomEventTarget\n}\n\n/**\n * EventTarget.\n *\n * - This is constructor if no arguments.\n * - This is a function which returns a CustomEventTarget constructor if there are arguments.\n *\n * For example:\n *\n * class A extends EventTarget {}\n * class B extends EventTarget(\"message\") {}\n * class C extends EventTarget(\"message\", \"error\") {}\n * class D extends EventTarget([\"message\", \"error\"]) {}\n */\nfunction EventTarget() {\n /*eslint-disable consistent-return */\n if (this instanceof EventTarget) {\n listenersMap.set(this, new Map())\n return\n }\n if (arguments.length === 1 && Array.isArray(arguments[0])) {\n return defineCustomEventTarget(arguments[0])\n }\n if (arguments.length > 0) {\n const types = new Array(arguments.length)\n for (let i = 0; i < arguments.length; ++i) {\n types[i] = arguments[i]\n }\n return defineCustomEventTarget(types)\n }\n throw new TypeError(\"Cannot call a class as a function\")\n /*eslint-enable consistent-return */\n}\n\n// Should be enumerable, but class methods are not enumerable.\nEventTarget.prototype = {\n /**\n * Add a given listener to this event target.\n * @param {string} eventName The event name to add.\n * @param {Function} listener The listener to add.\n * @param {boolean|{capture?:boolean,passive?:boolean,once?:boolean}} [options] The options for this listener.\n * @returns {void}\n */\n addEventListener(eventName, listener, options) {\n if (listener == null) {\n return\n }\n if (typeof listener !== \"function\" && !isObject(listener)) {\n throw new TypeError(\"'listener' should be a function or an object.\")\n }\n\n const listeners = getListeners(this)\n const optionsIsObj = isObject(options)\n const capture = optionsIsObj\n ? Boolean(options.capture)\n : Boolean(options)\n const listenerType = capture ? CAPTURE : BUBBLE\n const newNode = {\n listener,\n listenerType,\n passive: optionsIsObj && Boolean(options.passive),\n once: optionsIsObj && Boolean(options.once),\n next: null,\n }\n\n // Set it as the first node if the first node is null.\n let node = listeners.get(eventName)\n if (node === undefined) {\n listeners.set(eventName, newNode)\n return\n }\n\n // Traverse to the tail while checking duplication..\n let prev = null\n while (node != null) {\n if (\n node.listener === listener &&\n node.listenerType === listenerType\n ) {\n // Should ignore duplication.\n return\n }\n prev = node\n node = node.next\n }\n\n // Add it.\n prev.next = newNode\n },\n\n /**\n * Remove a given listener from this event target.\n * @param {string} eventName The event name to remove.\n * @param {Function} listener The listener to remove.\n * @param {boolean|{capture?:boolean,passive?:boolean,once?:boolean}} [options] The options for this listener.\n * @returns {void}\n */\n removeEventListener(eventName, listener, options) {\n if (listener == null) {\n return\n }\n\n const listeners = getListeners(this)\n const capture = isObject(options)\n ? Boolean(options.capture)\n : Boolean(options)\n const listenerType = capture ? CAPTURE : BUBBLE\n\n let prev = null\n let node = listeners.get(eventName)\n while (node != null) {\n if (\n node.listener === listener &&\n node.listenerType === listenerType\n ) {\n if (prev !== null) {\n prev.next = node.next\n } else if (node.next !== null) {\n listeners.set(eventName, node.next)\n } else {\n listeners.delete(eventName)\n }\n return\n }\n\n prev = node\n node = node.next\n }\n },\n\n /**\n * Dispatch a given event.\n * @param {Event|{type:string}} event The event to dispatch.\n * @returns {boolean} `false` if canceled.\n */\n dispatchEvent(event) {\n if (event == null || typeof event.type !== \"string\") {\n throw new TypeError('\"event.type\" should be a string.')\n }\n\n // If listeners aren't registered, terminate.\n const listeners = getListeners(this)\n const eventName = event.type\n let node = listeners.get(eventName)\n if (node == null) {\n return true\n }\n\n // Since we cannot rewrite several properties, so wrap object.\n const wrappedEvent = wrapEvent(this, event)\n\n // This doesn't process capturing phase and bubbling phase.\n // This isn't participating in a tree.\n let prev = null\n while (node != null) {\n // Remove this listener if it's once\n if (node.once) {\n if (prev !== null) {\n prev.next = node.next\n } else if (node.next !== null) {\n listeners.set(eventName, node.next)\n } else {\n listeners.delete(eventName)\n }\n } else {\n prev = node\n }\n\n // Call this listener\n setPassiveListener(\n wrappedEvent,\n node.passive ? node.listener : null\n )\n if (typeof node.listener === \"function\") {\n try {\n node.listener.call(this, wrappedEvent)\n } catch (err) {\n if (\n typeof console !== \"undefined\" &&\n typeof console.error === \"function\"\n ) {\n console.error(err)\n }\n }\n } else if (\n node.listenerType !== ATTRIBUTE &&\n typeof node.listener.handleEvent === \"function\"\n ) {\n node.listener.handleEvent(wrappedEvent)\n }\n\n // Break if `event.stopImmediatePropagation` was called.\n if (isStopped(wrappedEvent)) {\n break\n }\n\n node = node.next\n }\n setPassiveListener(wrappedEvent, null)\n setEventPhase(wrappedEvent, 0)\n setCurrentTarget(wrappedEvent, null)\n\n return !wrappedEvent.defaultPrevented\n },\n}\n\n// `constructor` is not enumerable.\nObject.defineProperty(EventTarget.prototype, \"constructor\", {\n value: EventTarget,\n configurable: true,\n writable: true,\n})\n\n// Ensure `eventTarget instanceof window.EventTarget` is `true`.\nif (\n typeof window !== \"undefined\" &&\n typeof window.EventTarget !== \"undefined\"\n) {\n Object.setPrototypeOf(EventTarget.prototype, window.EventTarget.prototype)\n}\n\nexport { defineEventAttribute, EventTarget }\nexport default EventTarget\n"],"names":["pd","event","retv","privateData","get","console","assert","setCancelFlag","data","passiveListener","cancelable","canceled","preventDefault","error","Event","eventTarget","set","eventPhase","currentTarget","stopped","immediateStopped","timeStamp","Date","now","Object","defineProperty","value","enumerable","key","keys","i","length","defineRedirectDescriptor","configurable","defineCallDescriptor","apply","arguments","defineWrapper","BaseEvent","proto","CustomEvent","call","prototype","create","constructor","writable","descriptor","getOwnPropertyDescriptor","isFunc","getWrapper","wrapper","wrappers","getPrototypeOf","wrapEvent","Wrapper","isStopped","setEventPhase","setCurrentTarget","setPassiveListener","isObject","x","_typeof","getListeners","listeners","listenersMap","TypeError","defineEventAttributeDescriptor","eventName","node","listenerType","listener","next","prev","delete","newNode","passive","once","defineEventAttribute","eventTargetPrototype","defineCustomEventTarget","eventNames","CustomEventTarget","EventTarget","Map","Array","isArray","types","WeakMap","type","target","composedPath","NONE","CAPTURING_PHASE","AT_TARGET","BUBBLING_PHASE","stopPropagation","stopImmediatePropagation","bubbles","defaultPrevented","composed","srcElement","cancelBubble","returnValue","initEvent","window","setPrototypeOf","CAPTURE","BUBBLE","addEventListener","options","optionsIsObj","capture","removeEventListener","dispatchEvent","wrappedEvent","err","handleEvent"],"mappings":";;;;wbAkCA,QAASA,CAAAA,CAAT,CAAYC,CAAZ,CAAmB,IACTC,CAAAA,CAAI,CAAGC,CAAW,CAACC,GAAZD,CAAgBF,CAAhBE,QACbE,CAAAA,OAAO,CAACC,MAARD,CACY,IAARH,EAAAA,CADJG,CAEI,6CAFJA,CAGIJ,CAHJI,EAKOH,EAOX,QAASK,CAAAA,CAAT,CAAuBC,CAAvB,CAA6B,OACG,KAAxBA,EAAAA,CAAI,CAACC,eADgB,MAarB,CAACD,CAAI,CAACP,KAALO,CAAWE,UAbS,GAiBzBF,CAAI,CAACG,QAALH,GAjByB,CAkBgB,UAArC,QAAOA,CAAAA,CAAI,CAACP,KAALO,CAAWI,cAlBG,EAmBrBJ,CAAI,CAACP,KAALO,CAAWI,cAAXJ,EAnBqB,QAGE,WAAnB,QAAOH,CAAAA,OAAP,EACyB,UAAzB,QAAOA,CAAAA,OAAO,CAACQ,KAJE,EAMjBR,OAAO,CAACQ,KAARR,CACI,oEADJA,CAEIG,CAAI,CAACC,eAFTJ,CANiB,EAiC7B,QAASS,CAAAA,CAAT,CAAeC,CAAf,CAA4Bd,CAA5B,CAAmC,CAC/BE,CAAW,CAACa,GAAZb,CAAgB,IAAhBA,CAAsB,CAClBY,WAAW,CAAXA,CADkB,CAElBd,KAAK,CAALA,CAFkB,CAGlBgB,UAAU,CAAE,CAHM,CAIlBC,aAAa,CAAEH,CAJG,CAKlBJ,QAAQ,GALU,CAMlBQ,OAAO,GANW,CAOlBC,gBAAgB,GAPE,CAQlBX,eAAe,CAAE,IARC,CASlBY,SAAS,CAAEpB,CAAK,CAACoB,SAANpB,EAAmBqB,IAAI,CAACC,GAALD,EATZ,CAAtBnB,CAD+B,CAc/BqB,MAAM,CAACC,cAAPD,CAAsB,IAAtBA,CAA4B,WAA5BA,CAAyC,CAAEE,KAAK,GAAP,CAAgBC,UAAU,GAA1B,CAAzCH,CAd+B,QAmBrBI,CAAAA,EAFJC,CAAI,CAAGL,MAAM,CAACK,IAAPL,CAAYvB,CAAZuB,EACJM,CAAC,CAAG,EAAGA,CAAC,CAAGD,CAAI,CAACE,OAAQ,EAAED,EACzBF,EAAMC,CAAI,CAACC,CAAD,EACVF,CAAG,GAAI,OACTJ,MAAM,CAACC,cAAPD,CAAsB,IAAtBA,CAA4BI,CAA5BJ,CAAiCQ,CAAwB,CAACJ,CAAD,CAAzDJ,EAyOZ,QAASQ,CAAAA,CAAT,CAAkCJ,CAAlC,CAAuC,OAC5B,CACHxB,GADG,WACG,OACKJ,CAAAA,CAAE,CAAC,IAAD,CAAFA,CAASC,KAATD,CAAe4B,CAAf5B,CAFR,CAAA,CAIHgB,GAJG,UAICU,EAAO,CACP1B,CAAE,CAAC,IAAD,CAAFA,CAASC,KAATD,CAAe4B,CAAf5B,EAAsB0B,CALvB,CAAA,CAOHO,YAAY,GAPT,CAQHN,UAAU,GARP,EAkBX,QAASO,CAAAA,CAAT,CAA8BN,CAA9B,CAAmC,OACxB,CACHF,KADG,WACK,IACEzB,CAAAA,CAAK,CAAGD,CAAE,CAAC,IAAD,CAAFA,CAASC,YAChBA,CAAAA,CAAK,CAAC2B,CAAD,CAAL3B,CAAWkC,KAAXlC,CAAiBA,CAAjBA,CAAwBmC,SAAxBnC,CAHR,CAAA,CAKHgC,YAAY,GALT,CAMHN,UAAU,GANP,EAiBX,QAASU,CAAAA,CAAT,CAAuBC,CAAvB,CAAkCC,CAAlC,CAAyC,SAO5BC,CAAAA,EAAYzB,EAAad,EAAO,CACrCqC,CAAS,CAACG,IAAVH,CAAe,IAAfA,CAAqBvB,CAArBuB,CAAkCrC,CAAlCqC,KAPET,CAAAA,CAAI,CAAGL,MAAM,CAACK,IAAPL,CAAYe,CAAZf,KACO,CAAhBK,GAAAA,CAAI,CAACE,aACEO,CAAAA,EAQXE,CAAW,CAACE,SAAZF,CAAwBhB,MAAM,CAACmB,MAAPnB,CAAcc,CAAS,CAACI,SAAxBlB,CAAmC,CACvDoB,WAAW,CAAE,CAAElB,KAAK,CAAEc,CAAT,CAAsBP,YAAY,GAAlC,CAA0CY,QAAQ,GAAlD,CAD0C,CAAnCrB,CAXa,KAgBhC,GACKI,CAAAA,CADL,CAAIE,CAAC,CAAG,EAAGA,CAAC,CAAGD,CAAI,CAACE,OAAQ,EAAED,KACzBF,EAAMC,CAAI,CAACC,CAAD,EACZ,EAAEF,CAAG,GAAIU,CAAAA,CAAS,CAACI,SAAnB,EAA+B,IACzBI,CAAAA,CAAU,CAAGtB,MAAM,CAACuB,wBAAPvB,CAAgCe,CAAhCf,CAAuCI,CAAvCJ,CADY,CAEzBwB,CAAM,CAA+B,UAA5B,QAAOF,CAAAA,CAAU,CAACpB,KAFF,CAG/BF,MAAM,CAACC,cAAPD,CACIgB,CAAW,CAACE,SADhBlB,CAEII,CAFJJ,CAGIwB,CAAM,CACAd,CAAoB,CAACN,CAAD,CADpB,CAEAI,CAAwB,CAACJ,CAAD,CALlCJ,QAUDgB,CAAAA,EASX,QAASS,CAAAA,CAAT,CAAoBV,CAApB,CAA2B,IACV,IAATA,EAAAA,CAAK,EAAYA,CAAK,GAAKf,MAAM,CAACkB,gBAC3B5B,CAAAA,KAGPoC,CAAAA,CAAO,CAAGC,CAAQ,CAAC/C,GAAT+C,CAAaZ,CAAbY,QACC,KAAXD,EAAAA,IACAA,CAAO,CAAGb,CAAa,CAACY,CAAU,CAACzB,MAAM,CAAC4B,cAAP5B,CAAsBe,CAAtBf,CAAD,CAAX,CAA2Ce,CAA3C,EACvBY,CAAQ,CAACnC,GAATmC,CAAaZ,CAAbY,CAAoBD,CAApBC,GAEGD,EAUJ,QAASG,CAAAA,CAAT,CAAmBtC,CAAnB,CAAgCd,CAAhC,CAAuC,IACpCqD,CAAAA,CAAO,CAAGL,CAAU,CAACzB,MAAM,CAAC4B,cAAP5B,CAAsBvB,CAAtBuB,CAAD,QACnB,IAAI8B,CAAAA,CAAJ,CAAYvC,CAAZ,CAAyBd,CAAzB,EASJ,QAASsD,CAAAA,CAAT,CAAmBtD,CAAnB,CAA0B,OACtBD,CAAAA,CAAE,CAACC,CAAD,CAAFD,CAAUoB,iBAUd,QAASoC,CAAAA,CAAT,CAAuBvD,CAAvB,CAA8BgB,CAA9B,CAA0C,CAC7CjB,CAAE,CAACC,CAAD,CAAFD,CAAUiB,UAAVjB,CAAuBiB,EAUpB,QAASwC,CAAAA,CAAT,CAA0BxD,CAA1B,CAAiCiB,CAAjC,CAAgD,CACnDlB,CAAE,CAACC,CAAD,CAAFD,CAAUkB,aAAVlB,CAA0BkB,EAUvB,QAASwC,CAAAA,CAAT,CAA4BzD,CAA5B,CAAmCQ,CAAnC,CAAoD,CACvDT,CAAE,CAACC,CAAD,CAAFD,CAAUS,eAAVT,CAA4BS,EC3bhC,QAASkD,CAAAA,CAAT,CAAkBC,CAAlB,CAAqB,OACJ,KAANA,GAAAA,CAAC,EAA0B,QAAb,GAAAC,EAAOD,GAShC,QAASE,CAAAA,CAAT,CAAsB/C,CAAtB,CAAmC,IACzBgD,CAAAA,CAAS,CAAGC,CAAY,CAAC5D,GAAb4D,CAAiBjD,CAAjBiD,KACD,IAAbD,EAAAA,OACM,IAAIE,CAAAA,SAAJ,CACF,kEADE,QAIHF,CAAAA,EASX,QAASG,CAAAA,CAAT,CAAwCC,CAAxC,CAAmD,OACxC,CACH/D,GADG,WACG,QACI2D,CAAAA,CAAS,CAAGD,CAAY,CAAC,IAAD,CAD5B,CAEEM,CAAI,CAAGL,CAAS,CAAC3D,GAAV2D,CAAcI,CAAdJ,CAFT,CAGa,IAARK,EAAAA,CAHL,EAGmB,IACbA,IAAAA,CAAI,CAACC,mBACED,CAAAA,CAAI,CAACE,SAEhBF,CAAI,CAAGA,CAAI,CAACG,WAET,KAVR,CAAA,CAaHvD,GAbG,UAaCsD,EAAU,CACc,UAApB,QAAOA,CAAAA,CAAP,EAAmCX,CAAQ,CAACW,CAAD,CADrC,GAENA,CAAQ,CAAG,IAFL,SAIJP,CAAAA,CAAS,CAAGD,CAAY,CAAC,IAAD,CAJpB,CAONU,CAAI,CAAG,IAPD,CAQNJ,CAAI,CAAGL,CAAS,CAAC3D,GAAV2D,CAAcI,CAAdJ,CARD,CASK,IAARK,EAAAA,CATG,EAUFA,IAAAA,CAAI,CAACC,YAVH,CAYW,IAATG,GAAAA,CAZF,CAcuB,IAAdJ,GAAAA,CAAI,CAACG,IAdd,CAiBER,CAAS,CAACU,MAAVV,CAAiBI,CAAjBJ,CAjBF,CAeEA,CAAS,CAAC/C,GAAV+C,CAAcI,CAAdJ,CAAyBK,CAAI,CAACG,IAA9BR,CAfF,CAaES,CAAI,CAACD,IAALC,CAAYJ,CAAI,CAACG,IAbnB,CAoBFC,CAAI,CAAGJ,CApBL,CAuBNA,CAAI,CAAGA,CAAI,CAACG,IAvBN,IA2BO,IAAbD,GAAAA,EAAmB,IACbI,CAAAA,CAAO,CAAG,CACZJ,QAAQ,CAARA,CADY,CAEZD,YAAY,EAFA,CAGZM,OAAO,GAHK,CAIZC,IAAI,GAJQ,CAKZL,IAAI,CAAE,IALM,EAOH,IAATC,GAAAA,CARe,CASfT,CAAS,CAAC/C,GAAV+C,CAAcI,CAAdJ,CAAyBW,CAAzBX,CATe,CAWfS,CAAI,CAACD,IAALC,CAAYE,EAnDrB,CAAA,CAuDHzC,YAAY,GAvDT,CAwDHN,UAAU,GAxDP,EAkEX,QAASkD,CAAAA,CAAT,CAA8BC,CAA9B,CAAoDX,CAApD,CAA+D,CAC3D3C,MAAM,CAACC,cAAPD,CACIsD,CADJtD,aAES2C,EAFT3C,CAGI0C,CAA8B,CAACC,CAAD,CAHlC3C,EAaJ,QAASuD,CAAAA,CAAT,CAAiCC,CAAjC,CAA6C,SAEhCC,CAAAA,GAAoB,CACzBC,CAAW,CAACzC,IAAZyC,CAAiB,IAAjBA,EAGJD,CAAiB,CAACvC,SAAlBuC,CAA8BzD,MAAM,CAACmB,MAAPnB,CAAc0D,CAAW,CAACxC,SAA1BlB,CAAqC,CAC/DoB,WAAW,CAAE,CACTlB,KAAK,CAAEuD,CADE,CAEThD,YAAY,GAFH,CAGTY,QAAQ,GAHC,CADkD,CAArCrB,CANW,KAcpC,GAAIM,CAAAA,CAAC,CAAG,EAAGA,CAAC,CAAGkD,CAAU,CAACjD,OAAQ,EAAED,EACrC+C,CAAoB,CAACI,CAAiB,CAACvC,SAAnB,CAA8BsC,CAAU,CAAClD,CAAD,CAAxC,CAApB+C,OAGGI,CAAAA,EAgBX,QAASC,CAAAA,CAAT,EAAuB,IAEf,eAAgBA,CAAAA,aAChBlB,CAAAA,CAAY,CAAChD,GAAbgD,CAAiB,IAAjBA,CAAuB,GAAImB,CAAAA,GAA3BnB,KAGqB,CAArB5B,GAAAA,SAAS,CAACL,MAAVK,EAA0BgD,KAAK,CAACC,OAAND,CAAchD,SAAS,CAAC,CAAD,CAAvBgD,QACnBL,CAAAA,CAAuB,CAAC3C,SAAS,CAAC,CAAD,CAAV,KAEX,CAAnBA,CAAAA,SAAS,CAACL,OAAY,QAChBuD,CAAAA,CAAK,CAAOF,KAAP,CAAahD,SAAS,CAACL,MAAvB,EACFD,CAAC,CAAG,EAAGA,CAAC,CAAGM,SAAS,CAACL,OAAQ,EAAED,EACpCwD,CAAK,CAACxD,CAAD,CAALwD,CAAWlD,SAAS,CAACN,CAAD,CAApBwD,OAEGP,CAAAA,CAAuB,CAACO,CAAD,OAE5B,IAAIrB,CAAAA,SAAJ,CAAc,mCAAd,KD5KJ9D,CAAAA,CAAW,CAAG,GAAIoF,CAAAA,QAOlBpC,CAAQ,CAAG,GAAIoC,CAAAA,QAkFrBzE,CAAK,CAAC4B,SAAN5B,CAAkB,IAKV0E,CAAAA,MAAO,OACAxF,CAAAA,CAAE,CAAC,IAAD,CAAFA,CAASC,KAATD,CAAewF,IANZ,CAAA,IAaVC,CAAAA,QAAS,OACFzF,CAAAA,CAAE,CAAC,IAAD,CAAFA,CAASe,WAdN,CAAA,IAqBVG,CAAAA,eAAgB,OACTlB,CAAAA,CAAE,CAAC,IAAD,CAAFA,CAASkB,aAtBN,CAAA,CA4BdwE,YA5Bc,WA4BC,IACLxE,CAAAA,CAAa,CAAGlB,CAAE,CAAC,IAAD,CAAFA,CAASkB,cADpB,MAEU,KAAjBA,EAAAA,CAFO,CAGA,EAHA,CAKJ,CAACA,CAAD,CAjCG,CAAA,IAwCVyE,CAAAA,MAAO,OACA,EAzCG,CAAA,IAgDVC,CAAAA,iBAAkB,OACX,EAjDG,CAAA,IAwDVC,CAAAA,WAAY,OACL,EAzDG,CAAA,IAgEVC,CAAAA,gBAAiB,OACV,EAjEG,CAAA,IAwEV7E,CAAAA,YAAa,OACNjB,CAAAA,CAAE,CAAC,IAAD,CAAFA,CAASiB,UAzEN,CAAA,CAgFd8E,eAhFc,WAgFI,IACRvF,CAAAA,CAAI,CAAGR,CAAE,CAAC,IAAD,EAEfQ,CAAI,CAACW,OAALX,GAHc,CAI4B,UAAtC,QAAOA,CAAAA,CAAI,CAACP,KAALO,CAAWuF,eAJR,EAKVvF,CAAI,CAACP,KAALO,CAAWuF,eAAXvF,EArFM,CAAA,CA6FdwF,wBA7Fc,WA6Fa,IACjBxF,CAAAA,CAAI,CAAGR,CAAE,CAAC,IAAD,EAEfQ,CAAI,CAACW,OAALX,GAHuB,CAIvBA,CAAI,CAACY,gBAALZ,GAJuB,CAK4B,UAA/C,QAAOA,CAAAA,CAAI,CAACP,KAALO,CAAWwF,wBALC,EAMnBxF,CAAI,CAACP,KAALO,CAAWwF,wBAAXxF,EAnGM,CAAA,IA2GVyF,CAAAA,SAAU,SACKjG,CAAE,CAAC,IAAD,CAAFA,CAASC,KAATD,CAAeiG,OA5GpB,CAAA,IAmHVvF,CAAAA,YAAa,SACEV,CAAE,CAAC,IAAD,CAAFA,CAASC,KAATD,CAAeU,UApHpB,CAAA,CA2HdE,cA3Hc,WA2HG,CACbL,CAAa,CAACP,CAAE,CAAC,IAAD,CAAH,CA5HH,CAAA,IAmIVkG,CAAAA,kBAAmB,OACZlG,CAAAA,CAAE,CAAC,IAAD,CAAFA,CAASW,QApIN,CAAA,IA2IVwF,CAAAA,UAAW,SACInG,CAAE,CAAC,IAAD,CAAFA,CAASC,KAATD,CAAemG,QA5IpB,CAAA,IAmJV9E,CAAAA,WAAY,OACLrB,CAAAA,CAAE,CAAC,IAAD,CAAFA,CAASqB,SApJN,CAAA,IA4JV+E,CAAAA,YAAa,OACNpG,CAAAA,CAAE,CAAC,IAAD,CAAFA,CAASe,WA7JN,CAAA,IAqKVsF,CAAAA,cAAe,OACRrG,CAAAA,CAAE,CAAC,IAAD,CAAFA,CAASmB,OAtKN,CAAA,IAwKVkF,CAAAA,aAAa3E,EAAO,IACfA,MAGClB,CAAAA,CAAI,CAAGR,CAAE,CAAC,IAAD,EAEfQ,CAAI,CAACW,OAALX,IACuC,SAAnC,QAAOA,CAAAA,CAAI,CAACP,KAALO,CAAW6F,eAClB7F,CAAI,CAACP,KAALO,CAAW6F,YAAX7F,KAhLM,CAAA,IAyLV8F,CAAAA,aAAc,OACP,CAACtG,CAAE,CAAC,IAAD,CAAFA,CAASW,QA1LP,CAAA,IA4LV2F,CAAAA,YAAY5E,EAAO,CACdA,CADc,EAEfnB,CAAa,CAACP,CAAE,CAAC,IAAD,CAAH,CA9LP,CAAA,CAyMduG,SAzMc,WAyMF,EAzME,EA+MlB/E,MAAM,CAACC,cAAPD,CAAsBV,CAAK,CAAC4B,SAA5BlB,CAAuC,aAAvCA,CAAsD,CAClDE,KAAK,CAAEZ,CAD2C,CAElDmB,YAAY,GAFsC,CAGlDY,QAAQ,GAH0C,CAAtDrB,EAOsB,WAAlB,QAAOgF,CAAAA,MAAP,EAAyD,WAAxB,QAAOA,CAAAA,MAAM,CAAC1F,QAC/CU,MAAM,CAACiF,cAAPjF,CAAsBV,CAAK,CAAC4B,SAA5BlB,CAAuCgF,MAAM,CAAC1F,KAAP0F,CAAa9D,SAApDlB,EAGA2B,CAAQ,CAACnC,GAATmC,CAAaqD,MAAM,CAAC1F,KAAP0F,CAAa9D,SAA1BS,CAAqCrC,CAArCqC,MChTEa,CAAAA,CAAY,CAAG,GAAIuB,CAAAA,QAGnBmB,CAAO,CAAG,EACVC,CAAM,CAAG,KA0KfzB,CAAW,CAACxC,SAAZwC,CAAwB,CAQpB0B,gBARoB,UAQHzC,EAAWG,EAAUuC,EAAS,IAC3B,IAAZvC,EAAAA,MAGoB,UAApB,QAAOA,CAAAA,CAAP,EAAkC,CAACX,CAAQ,CAACW,CAAD,OACrC,IAAIL,CAAAA,SAAJ,CAAc,+CAAd,KAGJF,CAAAA,CAAS,CAAGD,CAAY,CAAC,IAAD,EACxBgD,CAAY,CAAGnD,CAAQ,CAACkD,CAAD,EACvBE,CAAO,CAAGD,CAAY,GACdD,CAAO,CAACE,OADM,GAEdF,EACRxC,CAAY,CAAG0C,CAAO,CAAGL,CAAH,CAAaC,EACnCjC,CAAO,CAAG,CACZJ,QAAQ,CAARA,CADY,CAEZD,YAAY,CAAZA,CAFY,CAGZM,OAAO,CAAEmC,CAAY,IAAYD,CAAO,CAAClC,OAH7B,CAIZC,IAAI,CAAEkC,CAAY,IAAYD,CAAO,CAACjC,IAJ1B,CAKZL,IAAI,CAAE,IALM,EASZH,CAAI,CAAGL,CAAS,CAAC3D,GAAV2D,CAAcI,CAAdJ,KACPK,SAAAA,aACAL,CAAAA,CAAS,CAAC/C,GAAV+C,CAAcI,CAAdJ,CAAyBW,CAAzBX,SAKAS,CAAAA,CAAI,CAAG,KACI,IAARJ,EAAAA,GAAc,IAEbA,CAAI,CAACE,QAALF,GAAkBE,CAAlBF,EACAA,CAAI,CAACC,YAALD,GAAsBC,SAK1BG,CAAI,CAAGJ,CARU,CASjBA,CAAI,CAAGA,CAAI,CAACG,IAxC2B,CA4C3CC,CAAI,CAACD,IAALC,CAAYE,EApDI,CAAA,CA8DpBsC,mBA9DoB,UA8DA7C,EAAWG,EAAUuC,EAAS,IAC9B,IAAZvC,EAAAA,SAIEP,CAAAA,CAAS,CAAGD,CAAY,CAAC,IAAD,EACxBiD,CAAO,CAAGpD,CAAQ,CAACkD,CAAD,CAARlD,GACFkD,CAAO,CAACE,OADNpD,GAEFkD,EACRxC,CAAY,CAAG0C,CAAO,CAAGL,CAAH,CAAaC,EAErCnC,CAAI,CAAG,KACPJ,CAAI,CAAGL,CAAS,CAAC3D,GAAV2D,CAAcI,CAAdJ,EACI,IAARK,EAAAA,GAAc,IAEbA,CAAI,CAACE,QAALF,GAAkBE,CAAlBF,EACAA,CAAI,CAACC,YAALD,GAAsBC,cAET,IAATG,GAAAA,EAEqB,IAAdJ,GAAAA,CAAI,CAACG,KAGZR,CAAS,CAACU,MAAVV,CAAiBI,CAAjBJ,EAFAA,CAAS,CAAC/C,GAAV+C,CAAcI,CAAdJ,CAAyBK,CAAI,CAACG,IAA9BR,EAFAS,CAAI,CAACD,IAALC,CAAYJ,CAAI,CAACG,MASzBC,CAAI,CAAGJ,CAfU,CAgBjBA,CAAI,CAAGA,CAAI,CAACG,KA3FA,CAAA,CAoGpB0C,aApGoB,UAoGNhH,EAAO,IACJ,IAATA,EAAAA,CAAK,EAAkC,QAAtB,QAAOA,CAAAA,CAAK,CAACuF,UACxB,IAAIvB,CAAAA,SAAJ,CAAc,oCAAd,EAFO,GAMXF,CAAAA,CAAS,CAAGD,CAAY,CAAC,IAAD,CANb,CAOXK,CAAS,CAAGlE,CAAK,CAACuF,IAPP,CAQbpB,CAAI,CAAGL,CAAS,CAAC3D,GAAV2D,CAAcI,CAAdJ,CARM,IASL,IAARK,EAAAA,WATa,OAcX8C,CAAAA,CAAY,CAAG7D,CAAS,CAAC,IAAD,CAAOpD,CAAP,CAdb,CAkBbuE,CAAI,CAAG,IAlBM,CAmBF,IAARJ,EAAAA,CAnBU,EAmBI,IAEbA,CAAI,CAACQ,KACQ,IAATJ,GAAAA,EAEqB,IAAdJ,GAAAA,CAAI,CAACG,KAGZR,CAAS,CAACU,MAAVV,CAAiBI,CAAjBJ,EAFAA,CAAS,CAAC/C,GAAV+C,CAAcI,CAAdJ,CAAyBK,CAAI,CAACG,IAA9BR,EAFAS,CAAI,CAACD,IAALC,CAAYJ,CAAI,CAACG,KAOrBC,CAAI,CAAGJ,EAIXV,CAAkB,CACdwD,CADc,CAEd9C,CAAI,CAACO,OAALP,CAAeA,CAAI,CAACE,QAApBF,CAA+B,IAFjB,EAIW,UAAzB,QAAOA,CAAAA,CAAI,CAACE,YACR,CACAF,CAAI,CAACE,QAALF,CAAc3B,IAAd2B,CAAmB,IAAnBA,CAAyB8C,CAAzB9C,CADJ,CAEE,MAAO+C,CAAP,CAAY,CAEa,WAAnB,QAAO9G,CAAAA,OAAP,EACyB,UAAzB,QAAOA,CAAAA,OAAO,CAACQ,KAHT,EAKNR,OAAO,CAACQ,KAARR,CAAc8G,CAAd9G,MAIR+D,CAAAA,CAAI,CAACC,YAALD,GA/TE,CA+TFA,EACqC,UAArC,QAAOA,CAAAA,CAAI,CAACE,QAALF,CAAcgD,aAErBhD,CAAI,CAACE,QAALF,CAAcgD,WAAdhD,CAA0B8C,CAA1B9C,KAIAb,CAAS,CAAC2D,CAAD,QAIb9C,CAAI,CAAGA,CAAI,CAACG,WAEhBb,CAAAA,CAAkB,CAACwD,CAAD,CAAe,IAAf,EAClB1D,CAAa,CAAC0D,CAAD,CAAe,CAAf,EACbzD,CAAgB,CAACyD,CAAD,CAAe,IAAf,EAET,CAACA,CAAY,CAAChB,iBAvKL,EA4KxB1E,MAAM,CAACC,cAAPD,CAAsB0D,CAAW,CAACxC,SAAlClB,CAA6C,aAA7CA,CAA4D,CACxDE,KAAK,CAAEwD,CADiD,CAExDjD,YAAY,GAF4C,CAGxDY,QAAQ,GAHgD,CAA5DrB,EAQsB,WAAlB,QAAOgF,CAAAA,MAAP,EAC8B,WAA9B,QAAOA,CAAAA,MAAM,CAACtB,aAEd1D,MAAM,CAACiF,cAAPjF,CAAsB0D,CAAW,CAACxC,SAAlClB,CAA6CgF,MAAM,CAACtB,WAAPsB,CAAmB9D,SAAhElB"} \ No newline at end of file diff --git a/sandbox/tgbot/node_modules/event-target-shim/index.d.ts b/sandbox/tgbot/node_modules/event-target-shim/index.d.ts new file mode 100644 index 0000000..a303097 --- /dev/null +++ b/sandbox/tgbot/node_modules/event-target-shim/index.d.ts @@ -0,0 +1,399 @@ +export as namespace EventTargetShim + +/** + * `Event` interface. + * @see https://dom.spec.whatwg.org/#event + */ +export interface Event { + /** + * The type of this event. + */ + readonly type: string + + /** + * The target of this event. + */ + readonly target: EventTarget<{}, {}, "standard"> | null + + /** + * The current target of this event. + */ + readonly currentTarget: EventTarget<{}, {}, "standard"> | null + + /** + * The target of this event. + * @deprecated + */ + readonly srcElement: any | null + + /** + * The composed path of this event. + */ + composedPath(): EventTarget<{}, {}, "standard">[] + + /** + * Constant of NONE. + */ + readonly NONE: number + + /** + * Constant of CAPTURING_PHASE. + */ + readonly CAPTURING_PHASE: number + + /** + * Constant of BUBBLING_PHASE. + */ + readonly BUBBLING_PHASE: number + + /** + * Constant of AT_TARGET. + */ + readonly AT_TARGET: number + + /** + * Indicates which phase of the event flow is currently being evaluated. + */ + readonly eventPhase: number + + /** + * Stop event bubbling. + */ + stopPropagation(): void + + /** + * Stop event bubbling. + */ + stopImmediatePropagation(): void + + /** + * Initialize event. + * @deprecated + */ + initEvent(type: string, bubbles?: boolean, cancelable?: boolean): void + + /** + * The flag indicating bubbling. + */ + readonly bubbles: boolean + + /** + * Stop event bubbling. + * @deprecated + */ + cancelBubble: boolean + + /** + * Set or get cancellation flag. + * @deprecated + */ + returnValue: boolean + + /** + * The flag indicating whether the event can be canceled. + */ + readonly cancelable: boolean + + /** + * Cancel this event. + */ + preventDefault(): void + + /** + * The flag to indicating whether the event was canceled. + */ + readonly defaultPrevented: boolean + + /** + * The flag to indicating if event is composed. + */ + readonly composed: boolean + + /** + * Indicates whether the event was dispatched by the user agent. + */ + readonly isTrusted: boolean + + /** + * The unix time of this event. + */ + readonly timeStamp: number +} + +/** + * The constructor of `EventTarget` interface. + */ +export type EventTargetConstructor< + TEvents extends EventTarget.EventDefinition = {}, + TEventAttributes extends EventTarget.EventDefinition = {}, + TMode extends EventTarget.Mode = "loose" +> = { + prototype: EventTarget + new(): EventTarget +} + +/** + * `EventTarget` interface. + * @see https://dom.spec.whatwg.org/#interface-eventtarget + */ +export type EventTarget< + TEvents extends EventTarget.EventDefinition = {}, + TEventAttributes extends EventTarget.EventDefinition = {}, + TMode extends EventTarget.Mode = "loose" +> = EventTarget.EventAttributes & { + /** + * Add a given listener to this event target. + * @param eventName The event name to add. + * @param listener The listener to add. + * @param options The options for this listener. + */ + addEventListener>( + type: TEventType, + listener: + | EventTarget.Listener> + | null, + options?: boolean | EventTarget.AddOptions + ): void + + /** + * Remove a given listener from this event target. + * @param eventName The event name to remove. + * @param listener The listener to remove. + * @param options The options for this listener. + */ + removeEventListener>( + type: TEventType, + listener: + | EventTarget.Listener> + | null, + options?: boolean | EventTarget.RemoveOptions + ): void + + /** + * Dispatch a given event. + * @param event The event to dispatch. + * @returns `false` if canceled. + */ + dispatchEvent>( + event: EventTarget.EventData + ): boolean +} + +export const EventTarget: EventTargetConstructor & { + /** + * Create an `EventTarget` instance with detailed event definition. + * + * The detailed event definition requires to use `defineEventAttribute()` + * function later. + * + * Unfortunately, the second type parameter `TEventAttributes` was needed + * because we cannot compute string literal types. + * + * @example + * const signal = new EventTarget<{ abort: Event }, { onabort: Event }>() + * defineEventAttribute(signal, "abort") + */ + new < + TEvents extends EventTarget.EventDefinition, + TEventAttributes extends EventTarget.EventDefinition, + TMode extends EventTarget.Mode = "loose" + >(): EventTarget + + /** + * Define an `EventTarget` constructor with attribute events and detailed event definition. + * + * Unfortunately, the second type parameter `TEventAttributes` was needed + * because we cannot compute string literal types. + * + * @example + * class AbortSignal extends EventTarget<{ abort: Event }, { onabort: Event }>("abort") { + * abort(): void {} + * } + * + * @param events Optional event attributes (e.g. passing in `"click"` adds `onclick` to prototype). + */ + < + TEvents extends EventTarget.EventDefinition = {}, + TEventAttributes extends EventTarget.EventDefinition = {}, + TMode extends EventTarget.Mode = "loose" + >(events: string[]): EventTargetConstructor< + TEvents, + TEventAttributes, + TMode + > + + /** + * Define an `EventTarget` constructor with attribute events and detailed event definition. + * + * Unfortunately, the second type parameter `TEventAttributes` was needed + * because we cannot compute string literal types. + * + * @example + * class AbortSignal extends EventTarget<{ abort: Event }, { onabort: Event }>("abort") { + * abort(): void {} + * } + * + * @param events Optional event attributes (e.g. passing in `"click"` adds `onclick` to prototype). + */ + < + TEvents extends EventTarget.EventDefinition = {}, + TEventAttributes extends EventTarget.EventDefinition = {}, + TMode extends EventTarget.Mode = "loose" + >(event0: string, ...events: string[]): EventTargetConstructor< + TEvents, + TEventAttributes, + TMode + > +} + +export namespace EventTarget { + /** + * Options of `removeEventListener()` method. + */ + export interface RemoveOptions { + /** + * The flag to indicate that the listener is for the capturing phase. + */ + capture?: boolean + } + + /** + * Options of `addEventListener()` method. + */ + export interface AddOptions extends RemoveOptions { + /** + * The flag to indicate that the listener doesn't support + * `event.preventDefault()` operation. + */ + passive?: boolean + /** + * The flag to indicate that the listener will be removed on the first + * event. + */ + once?: boolean + } + + /** + * The type of regular listeners. + */ + export interface FunctionListener { + (event: TEvent): void + } + + /** + * The type of object listeners. + */ + export interface ObjectListener { + handleEvent(event: TEvent): void + } + + /** + * The type of listeners. + */ + export type Listener = + | FunctionListener + | ObjectListener + + /** + * Event definition. + */ + export type EventDefinition = { + readonly [key: string]: Event + } + + /** + * Mapped type for event attributes. + */ + export type EventAttributes = { + [P in keyof TEventAttributes]: + | FunctionListener + | null + } + + /** + * The type of event data for `dispatchEvent()` method. + */ + export type EventData< + TEvents extends EventDefinition, + TEventType extends keyof TEvents | string, + TMode extends Mode + > = + TEventType extends keyof TEvents + ? ( + // Require properties which are not generated automatically. + & Pick< + TEvents[TEventType], + Exclude + > + // Properties which are generated automatically are optional. + & Partial> + ) + : ( + TMode extends "standard" + ? Event + : Event | NonStandardEvent + ) + + /** + * The string literal types of the properties which are generated + * automatically in `dispatchEvent()` method. + */ + export type OmittableEventKeys = Exclude + + /** + * The type of event data. + */ + export type NonStandardEvent = { + [key: string]: any + type: string + } + + /** + * The type of listeners. + */ + export type PickEvent< + TEvents extends EventDefinition, + TEventType extends keyof TEvents | string, + > = + TEventType extends keyof TEvents + ? TEvents[TEventType] + : Event + + /** + * Event type candidates. + */ + export type EventType< + TEvents extends EventDefinition, + TMode extends Mode + > = + TMode extends "strict" + ? keyof TEvents + : keyof TEvents | string + + /** + * - `"strict"` ..... Methods don't accept unknown events. + * `dispatchEvent()` accepts partial objects. + * - `"loose"` ...... Methods accept unknown events. + * `dispatchEvent()` accepts partial objects. + * - `"standard"` ... Methods accept unknown events. + * `dispatchEvent()` doesn't accept partial objects. + */ + export type Mode = "strict" | "standard" | "loose" +} + +/** + * Specialized `type` property. + */ +export type Type = { type: T } + +/** + * Define an event attribute (e.g. `eventTarget.onclick`). + * @param prototype The event target prototype to define an event attribute. + * @param eventName The event name to define. + */ +export function defineEventAttribute( + prototype: EventTarget, + eventName: string +): void + +export default EventTarget diff --git a/sandbox/tgbot/node_modules/event-target-shim/package.json b/sandbox/tgbot/node_modules/event-target-shim/package.json new file mode 100644 index 0000000..40326f3 --- /dev/null +++ b/sandbox/tgbot/node_modules/event-target-shim/package.json @@ -0,0 +1,82 @@ +{ + "name": "event-target-shim", + "version": "5.0.1", + "description": "An implementation of WHATWG EventTarget interface.", + "main": "dist/event-target-shim", + "types": "index.d.ts", + "files": [ + "dist", + "index.d.ts" + ], + "engines": { + "node": ">=6" + }, + "scripts": { + "preversion": "npm test", + "version": "npm run build && git add dist/*", + "postversion": "git push && git push --tags", + "clean": "rimraf .nyc_output coverage", + "coverage": "nyc report --reporter lcov && opener coverage/lcov-report/index.html", + "lint": "eslint src test scripts --ext .js,.mjs", + "build": "rollup -c scripts/rollup.config.js", + "pretest": "npm run lint", + "test": "run-s test:*", + "test:mocha": "nyc --require ./scripts/babel-register mocha test/*.mjs", + "test:karma": "karma start scripts/karma.conf.js --single-run", + "watch": "run-p watch:*", + "watch:mocha": "mocha test/*.mjs --require ./scripts/babel-register --watch --watch-extensions js,mjs --growl", + "watch:karma": "karma start scripts/karma.conf.js --watch", + "codecov": "codecov" + }, + "devDependencies": { + "@babel/core": "^7.2.2", + "@babel/plugin-transform-modules-commonjs": "^7.2.0", + "@babel/preset-env": "^7.2.3", + "@babel/register": "^7.0.0", + "@mysticatea/eslint-plugin": "^8.0.1", + "@mysticatea/spy": "^0.1.2", + "assert": "^1.4.1", + "codecov": "^3.1.0", + "eslint": "^5.12.1", + "karma": "^3.1.4", + "karma-chrome-launcher": "^2.2.0", + "karma-coverage": "^1.1.2", + "karma-firefox-launcher": "^1.0.0", + "karma-growl-reporter": "^1.0.0", + "karma-ie-launcher": "^1.0.0", + "karma-mocha": "^1.3.0", + "karma-rollup-preprocessor": "^7.0.0-rc.2", + "mocha": "^5.2.0", + "npm-run-all": "^4.1.5", + "nyc": "^13.1.0", + "opener": "^1.5.1", + "rimraf": "^2.6.3", + "rollup": "^1.1.1", + "rollup-plugin-babel": "^4.3.2", + "rollup-plugin-babel-minify": "^7.0.0", + "rollup-plugin-commonjs": "^9.2.0", + "rollup-plugin-json": "^3.1.0", + "rollup-plugin-node-resolve": "^4.0.0", + "rollup-watch": "^4.3.1", + "type-tester": "^1.0.0", + "typescript": "^3.2.4" + }, + "repository": { + "type": "git", + "url": "https://github.com/mysticatea/event-target-shim.git" + }, + "keywords": [ + "w3c", + "whatwg", + "eventtarget", + "event", + "events", + "shim" + ], + "author": "Toru Nagashima", + "license": "MIT", + "bugs": { + "url": "https://github.com/mysticatea/event-target-shim/issues" + }, + "homepage": "https://github.com/mysticatea/event-target-shim" +} diff --git a/sandbox/tgbot/node_modules/grammy/LICENSE b/sandbox/tgbot/node_modules/grammy/LICENSE new file mode 100644 index 0000000..b9a5b7b --- /dev/null +++ b/sandbox/tgbot/node_modules/grammy/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2021-2024 KnorpelSenf + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/sandbox/tgbot/node_modules/grammy/README.md b/sandbox/tgbot/node_modules/grammy/README.md new file mode 100644 index 0000000..8b9fcc5 --- /dev/null +++ b/sandbox/tgbot/node_modules/grammy/README.md @@ -0,0 +1,347 @@ +
grammY
+ +
+ +# The Telegram Bot Framework + +
+ +
+ + + +[![Bot API](https://img.shields.io/badge/Bot%20API-9.4-blue?logo=telegram&style=flat&labelColor=000&color=3b82f6)](https://core.telegram.org/bots/api) +[![Deno](https://shield.deno.dev/x/grammy)](https://deno.land/x/grammy) +[![npm](https://img.shields.io/npm/v/grammy?logo=npm&style=flat&labelColor=000&color=3b82f6)](https://www.npmjs.org/package/grammy) +[![All Contributors](https://img.shields.io/github/all-contributors/grammyjs/grammy?style=flat&labelColor=000&color=3b82f6)](#contributors-) + + + +## _[docs.](https://grammy.dev) [reference.](https://grammy.dev/ref) [chat.](https://telegram.me/grammyjs) [news.](https://telegram.me/grammyjs_news)_ + +
+ +**grammY makes it easy to create Telegram bots.** Both for beginners and at scale. + +You want grammY because it is easy to use. It is very powerful and always up to date. It has the best [documentation](https://grammy.dev) in town. It is extremely efficient and scales up effortlessly. It has a thriving ecosystem of plugins, a friendly community chat, seamless integrations with web frameworks and databases, and so much more. + +Are you ready? 🤖🚀 + +Bots are written in [TypeScript](https://www.typescriptlang.org/) (or JavaScript) and run on [Node.js](https://nodejs.org/) or [Deno](#deno-support). + +## Quickstart + +> If you are new to Telegram bots, read the official [Introduction for Developers](https://core.telegram.org/bots) written by the Telegram team. + +Visit [@BotFather](https://t.me/BotFather) and create a new bot. You will obtain a **bot token**. + +Create a new directory and run + +```bash +npm install grammy +``` + +inside it. Then create a file `bot.js` with this content: + +```ts +const { Bot } = require("grammy"); + +// Create a bot object +const bot = new Bot(""); // <-- place your bot token in this string + +// Register listeners to handle messages +bot.on("message:text", (ctx) => ctx.reply("Echo: " + ctx.message.text)); + +// Start the bot (using long polling) +bot.start(); +``` + +Now you can run the bot via + +```bash +node bot.js +``` + +and it will echo all received text messages. + +Congrats! You just wrote a Telegram bot :) + +## Going Further + +grammY has an excellent [documentation](https://grammy.dev), and an [API Reference](https://grammy.dev/ref). It even integrates with your code editor, e.g. [VS Code](https://code.visualstudio.com/). You can hover over any element of grammY to get a detailed description of what that thing does or means. + +If you are still stuck, just join the [Telegram chat](https://t.me/grammyjs) and ask for help. People are nice there and we appreciate your question, no matter what it is :) + +Here are some more resources to support you: + +## Resources + +### [grammY website](https://grammy.dev) + +—main project website and documentation. +Gets you started and explains all concepts. + +### [grammY API reference](https://grammy.dev/ref) + +—reference of everything that grammY exports. +Useful to look up descriptions about any element of grammY. + +### [grammY examples](https://github.com/grammyjs/examples) + +—repository full of example bots. +Includes a setup to easily run any of them. + +### [Awesome grammY](https://github.com/grammyjs/awesome-grammY) + +—list of awesome projects built with grammY. +Helpful if you want to see some real-world usage. + +### [grammY chat](https://t.me/grammyjs) + +—The chat where you can ask any question about grammY or bots in general. +We are also open for feedback, ideas, and contributions! + +The Russian community chat can be found [here](https://t.me/grammyjs_ru). + +### [grammY news](https://t.me/grammyjs_news) + +—The channel where updates to grammY and the ecosystem are posted. + +### [Telegram Bot API Reference](https://core.telegram.org/bots/api) + +—documentation of the API that Telegram offers, and that grammY connects to under the hood. + +## Deno Support + +All grammY packages published by [@grammyjs](https://github.com/grammyjs) run natively on [Deno](https://deno.land). We are compiling every codebase to still run on Node.js. + +However, given that most bot developers are still using Node.js, all documentation is written Node.js-first. We may migrate it if Deno overtakes Node.js. If you are already on Deno today, import grammY from [`https://deno.land/x/grammy/mod.ts`](https://deno.land/x/grammy). + +You may also be interested in [why we support Deno](https://grammy.dev/resources/faq.html#why-do-you-support-deno). + +## JavaScript Bundles + +The grammY core package in this repository is available as a JavaScript bundle via . +This lets you transpile all published versions including current `main` branch to standalone JavaScript files. +For example, the most recent source on `main` is available from . + +Being compatible with browsers is especially useful for running bots on Cloudflare Workers. +For this reason, we also include a web bundle in our npm package. +You can simply do `import { Bot } from "grammy/web"`. + +## [Contribution Guide »](./CONTRIBUTING.md) + +## Contributors ✨ + +Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)): + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
KnorpelSenf
KnorpelSenf

🤔 💻 📖 🎨 💡 ⚠️ 🔌 📦 👀 🧑‍🏫 📆 🚇 🔊 ️️️️♿️ 📢
Heero
Heero

🔌 📓 💡 📖 👀 💻 🤔
Wojciech Pawlik
Wojciech Pawlik

🤔 👀 🚇 📦 🔧 💻
Alessandro Bertozzi
Alessandro Bertozzi

📖
trgwii
trgwii

💻 👀
KnightNiwrem
KnightNiwrem

💻 🐛 🔌 📖 💡 👀 🧑‍🏫
Muthu Kumar
Muthu Kumar

👀 🐛 💻
EdJoPaTo
EdJoPaTo

🔌 📖 🤔 👀 🐛 💻
Amir Zouerami
Amir Zouerami

📖 🔌 💡
Roj
Roj

📖 👀 🚇 🌍 💻 🤔 🧑‍🏫 💡
jokasimr
jokasimr

🐛
Ciki Momogi
Ciki Momogi

📖 🌍
AndreoliBR
AndreoliBR

👀
Kirill Loskutov
Kirill Loskutov

📖 🐛 🤔 🎨 💬 👀 💻 🔌
Andrew Lane
Andrew Lane

🐛 👀
code-withAshish
code-withAshish

📖 💬 🐛 👀
Stephane Mensah
Stephane Mensah

🐛 🔌
Asaku01
Asaku01

📖
ppsimn
ppsimn

🐛
Satont
Satont

🔌 📖
deptyped
deptyped

💡 📖 🐛 🌍
Jacek Nowacki
Jacek Nowacki

📖 💻 🐛 👀 🤔
Outvi V
Outvi V

💻
Ikko Ashimine
Ikko Ashimine

📖
Yevhen Denesiuk
Yevhen Denesiuk

👀 🐛 💻
prastian
prastian

🐛 💻
Sayem Chowdhury
Sayem Chowdhury

🤔
kospra
kospra

🤔 💻
Chimit
Chimit

📖
Calsi
Calsi

📖
Jonas Zohren
Jonas Zohren

🐛 💻
linbuxiao
linbuxiao

📖 🌍
JiquanWang99
JiquanWang99

📖 🌍
Borhan Hafez
Borhan Hafez

🔌
WingLim
WingLim

📖 🌍 💻 🔌 🤔
taotie111
taotie111

📖 🌍
Merlin
Merlin

📖
Darvesh
Darvesh

🐛 💻 👀
dcdunkan
dcdunkan

🐛 💻 🔌 👀 📖 🤔 🚇 🔧 🧑‍🏫 🚧
Kid
Kid

📖 🌍
Slava Fomin II
Slava Fomin II

🐛 📖
Kiko Beats
Kiko Beats

📖
Vsevolod
Vsevolod

💻 🤔 👀
Habemuscode
Habemuscode

👀 📖 🌍 🚧
Nikita Kolmogorov
Nikita Kolmogorov

🔌
Vitaliy Meshchaninov
Vitaliy Meshchaninov

🐛 💻
Дилян Палаузов
Дилян Палаузов

🐛 💻
lmx-Hexagram
lmx-Hexagram

📖
Ilya Semenov
Ilya Semenov

🤔 👀 💻
abdollahzadehAli
abdollahzadehAli

📖 💡
Saeed Nasiri
Saeed Nasiri

📖
Hesoyam
Hesoyam

📖
yrzam
yrzam

🐛
drmikecrowe
drmikecrowe

👀
Martin
Martin

📖 🐛 👀
Pavel
Pavel

💡
Thor 雷神 Schaeff
Thor 雷神 Schaeff

💡
x066it
x066it

🐛 👀
kolay
kolay

👀
Evgeny Nepomnyashchiy
Evgeny Nepomnyashchiy

👀
Ananta Krsna dasa
Ananta Krsna dasa

📖
Mighty Ali
Mighty Ali

💻 👀 🤔
三三
三三

🐛 💻
Roz
Roz

🐛 💻 👀 🚇 🤔 🧑‍🏫 🔌
Dani Haro
Dani Haro

💻 🔌 📖
Ryukaizen
Ryukaizen

📖
Alisher Ortiqov
Alisher Ortiqov

📖
Tony Tkachenko
Tony Tkachenko

📖
Ra
Ra

💻
sartoshi-foot-dao
sartoshi-foot-dao

📖
Yoel Navas E.
Yoel Navas E.

🤔
Vitor Gomes
Vitor Gomes

🐛 💻
Aditya
Aditya

🐛 👀
Udit Karode
Udit Karode

👀
Mike Rockétt
Mike Rockétt

👀 🐛
Srinivasa IK Varanasi
Srinivasa IK Varanasi

💻
abdoo9
abdoo9

🐛 💻 👀 📖
ak4zh
ak4zh

👀 🤔 💻
Nikolay Lapshin
Nikolay Lapshin

💻
Aquatica
Aquatica

📖 💬
Fa Dzikri
Fa Dzikri

👀 📖 🌍
Chandler Lattin
Chandler Lattin

💻 👀 🔌
Sergey Parfenyuk
Sergey Parfenyuk

🐛
Émerson Felinto
Émerson Felinto

🐛
Petr Stankin
Petr Stankin

🐛
Maxim Lebedev
Maxim Lebedev

🤔 💻
Madnex
Madnex

📖
Svyatoslav Tupchienko
Svyatoslav Tupchienko

💻
Vladislav Deryabkin
Vladislav Deryabkin

🐛 💻 👀
Kashyap Sharma
Kashyap Sharma

💡
AlexOwl
AlexOwl

🐛 💻
Shrimadhav U K
Shrimadhav U K

💻 🤔 ⚠️
Binamra Lamsal
Binamra Lamsal

🤔
gertminov
gertminov

📖
Stephan Psaras
Stephan Psaras

🐛
shevernitskiy
shevernitskiy

🐛 👀 💻
mrmaster009
mrmaster009

📖
Andrii Zontov
Andrii Zontov

🐛 💻 💬 🤔 📖 🌍
Abbass Al-Musawi
Abbass Al-Musawi

📖 🐛 💻
ArunR
ArunR

🐛 💻
NDA
NDA

🐛 🤔 💻
MatyiFKBT
MatyiFKBT

📖
Chris Andrew C. L.
Chris Andrew C. L.

🐛 💻 👀
Islam Kiiasov
Islam Kiiasov

💻
Shane Avery Sistoza
Shane Avery Sistoza

🤔 💻 ⚠️
Maicol
Maicol

💻
Nazar Antoniuk
Nazar Antoniuk

📖 🌍 🚧
Aleksei Ivanov
Aleksei Ivanov

👀
Vladislav Ponomarev
Vladislav Ponomarev

⚠️ 💻 📦
Louie Tan
Louie Tan

👀
Leandro Vargas
Leandro Vargas

🐛 💻
Sean Yap
Sean Yap

🐛 💻
Sergey Solovev
Sergey Solovev

🤔 👀
Sree (Taylor's Version)
Sree (Taylor's Version)

🐛 💻
Yaroslav Vovchenko
Yaroslav Vovchenko

🐛 💻
gabe
gabe

👀
Lavrentiy Rubtsov
Lavrentiy Rubtsov

📖
Josh Gillies
Josh Gillies

💻
Uladzislau Hramyka
Uladzislau Hramyka

🐛
Gabriele Belluardo
Gabriele Belluardo

🐛 💻
Dim Chen
Dim Chen

🐛 💻
fwqaaq
fwqaaq

🤔 💻
Janek Szynal
Janek Szynal

🤔
Alexander Mordvinov
Alexander Mordvinov

🤔
Ash
Ash

👀
Winston H.
Winston H.

🤔 💻 👀 ⚠️
Hero Protagonist
Hero Protagonist

💻 🐛 🤔 🔌
Mobin Askari
Mobin Askari

🔌 👀
Ubertao
Ubertao

🤔 💻
Grigory
Grigory

🤔 💻 📖
aleveha
aleveha

💻
barinbritva
barinbritva

👀
Lyudmil Ivanov
Lyudmil Ivanov

💡
lexomis
lexomis

👀
Andrew Sologor
Andrew Sologor

👀
rayz
rayz

💬 🤔 💻 📖
Zaid
Zaid

🔧
Mat Milbury
Mat Milbury

🐛 💻
Shibo Lyu
Shibo Lyu

💻
Mased
Mased

🌍 📖
Artem Prokop
Artem Prokop

📓
Sérgio Rebelo
Sérgio Rebelo

👀
Igor Katsuba
Igor Katsuba

🤔 💻
Oyatillo
Oyatillo

👀 🐛 💻
Mordechai Dror
Mordechai Dror

👀
mahovich
mahovich

📖
Thành Hoàng Trần
Thành Hoàng Trần

📖
ikelax
ikelax

📖
Lutymane
Lutymane

💻
Thada Wangthammang
Thada Wangthammang

🐛 ⚠️ 👀
Konstantin Ryshkov
Konstantin Ryshkov

🐛 📖
mish
mish

🐛 💻
Dmytro Tiapukhin
Dmytro Tiapukhin

📖
Alexander
Alexander

📖
Codinary
Codinary

👀
.vhs
.vhs

🐛 👀
agoudbg
agoudbg

🐛 💻
ArunR
ArunR

🤔 💻 ⚠️
A
A

🐛 👀
+ + + + + + +This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. +Contributions of any kind welcome! diff --git a/sandbox/tgbot/node_modules/grammy/out/bot.d.ts b/sandbox/tgbot/node_modules/grammy/out/bot.d.ts new file mode 100644 index 0000000..9368a5a --- /dev/null +++ b/sandbox/tgbot/node_modules/grammy/out/bot.d.ts @@ -0,0 +1,314 @@ +import { BotError, Composer, type Middleware, type ReactionMiddleware } from "./composer.js"; +import { Context, type MaybeArray, type ReactionContext } from "./context.js"; +import { Api } from "./core/api.js"; +import { type ApiClientOptions, type WebhookReplyEnvelope } from "./core/client.js"; +import { type Filter, type FilterQuery } from "./filter.js"; +import { type ReactionType, type ReactionTypeEmoji, type Update, type UserFromGetMe } from "./types.js"; +export declare const DEFAULT_UPDATE_TYPES: readonly ["message", "edited_message", "channel_post", "edited_channel_post", "business_connection", "business_message", "edited_business_message", "deleted_business_messages", "inline_query", "chosen_inline_result", "callback_query", "shipping_query", "pre_checkout_query", "purchased_paid_media", "poll", "poll_answer", "my_chat_member", "chat_join_request", "chat_boost", "removed_chat_boost"]; +/** + * Options that can be specified when running the bot via simple long polling. + */ +export interface PollingOptions { + /** + * Limits the number of updates to be retrieved per `getUpdates` call. + * Values between 1-100 are accepted. Defaults to 100. + */ + limit?: number; + /** + * Timeout in seconds for long polling. grammY uses 30 seconds as a default + * value. + */ + timeout?: number; + /** + * A list of the update types you want your bot to receive. For example, + * specify ["message", "edited_channel_post", "callback_query"] to only + * receive updates of these types. See Update for a complete list of + * available update types. Specify an empty list to receive all update types + * except chat_member, message_reaction, and message_reaction_count + * (default). If not specified, the previous setting will be used. + * + * Please note that this parameter doesn't affect updates created before the + * call to the getUpdates, so unwanted updates may be received for a short + * period of time. + */ + allowed_updates?: ReadonlyArray>; + /** + * Pass True to drop all pending updates before starting the long polling. + */ + drop_pending_updates?: boolean; + /** + * A callback function that is useful for logging (or setting up middleware + * if you did not do this before). It will be executed after the setup of + * the bot has completed, and immediately before the first updates are being + * fetched. The bot information `bot.botInfo` will be available when the + * function is run. For convenience, the callback function receives the + * value of `bot.botInfo` as an argument. + * + * When this function is invoked, the bot already signals that it is + * running. In other words, `bot.isRunning()` already returns true. + */ + onStart?: (botInfo: UserFromGetMe) => void | Promise; +} +export { BotError }; +/** + * Error handler that can be installed on a bot to catch error thrown by + * middleware. + */ +export type ErrorHandler = (error: BotError) => unknown; +/** + * Options to pass to the bot when creating it. + */ +export interface BotConfig { + /** + * You can specify a number of advanced options under the `client` property. + * The options will be passed to the grammY client—this is the part of + * grammY that actually connects to the Telegram Bot API server in the end + * when making HTTP requests. + */ + client?: ApiClientOptions; + /** + * grammY automatically calls `getMe` when starting up to make sure that + * your bot has access to the bot's own information. If you restart your bot + * often, for example because it is running in a serverless environment, + * then you may want to skip this initial API call. + * + * Set this property of the options to pre-initialize the bot with cached + * values. If you use this option, grammY will not attempt to make a `getMe` + * call but use the provided data instead. + */ + botInfo?: UserFromGetMe; + /** + * Pass the constructor of a custom context object that will be used when + * creating the context for each incoming update. + */ + ContextConstructor?: new (...args: ConstructorParameters) => C; +} +/** + * This is the single most important class of grammY. It represents your bot. + * + * First, you must create a bot by talking to @BotFather, check out + * https://t.me/BotFather. Once it is ready, you obtain a secret token for your + * bot. grammY will use that token to identify as your bot when talking to the + * Telegram servers. Got the token? You are now ready to write some code and run + * your bot! + * + * You should do three things to run your bot: + * ```ts + * // 1. Create a bot instance + * const bot = new Bot('') + * // 2. Listen for updates + * bot.on('message:text', ctx => ctx.reply('You wrote: ' + ctx.message.text)) + * // 3. Launch it! + * bot.start() + * ``` + */ +export declare class Bot extends Composer { + readonly token: string; + private pollingRunning; + private pollingAbortController; + private lastTriedUpdateId; + /** + * Gives you full access to the Telegram Bot API. + * ```ts + * // This is how to call the Bot API methods: + * bot.api.sendMessage(chat_id, 'Hello, grammY!') + * ``` + * + * Use this only outside of your middleware. If you have access to `ctx`, + * then using `ctx.api` instead of `bot.api` is preferred. + */ + readonly api: A; + private me; + private mePromise; + private readonly clientConfig; + private readonly ContextConstructor; + /** Used to log a warning if some update types are not in allowed_updates */ + private observedUpdateTypes; + /** + * Holds the bot's error handler that is invoked whenever middleware throws + * (rejects). If you set your own error handler via `bot.catch`, all that + * happens is that this variable is assigned. + */ + errorHandler: ErrorHandler; + /** + * Creates a new Bot with the given token. + * + * Remember that you can listen for messages by calling + * ```ts + * bot.on('message', ctx => { ... }) + * ``` + * or similar methods. + * + * The simplest way to start your bot is via simple long polling: + * ```ts + * bot.start() + * ``` + * + * @param token The bot's token as acquired from https://t.me/BotFather + * @param config Optional configuration properties for the bot + */ + constructor(token: string, config?: BotConfig); + /** + * Information about the bot itself as retrieved from `api.getMe()`. Only + * available after the bot has been initialized via `await bot.init()`, or + * after the value has been set manually. + * + * Starting the bot will always perform the initialization automatically, + * unless a manual value is already set. + * + * Note that the recommended way to set a custom bot information object is + * to pass it to the configuration object of the `new Bot()` instantiation, + * rather than assigning this property. + */ + set botInfo(botInfo: UserFromGetMe); + get botInfo(): UserFromGetMe; + /** + * @inheritdoc + */ + on(filter: Q | Q[], ...middleware: Array>>): Composer>; + /** + * @inheritdoc + */ + reaction(reaction: MaybeArray, ...middleware: Array>): Composer>; + /** + * Checks if the bot has been initialized. A bot is initialized if the bot + * information is set. The bot information can either be set automatically + * by calling `bot.init`, or manually through the bot constructor. Note that + * usually, initialization is done automatically and you do not have to care + * about this method. + * + * @returns true if the bot is initialized, and false otherwise + */ + isInited(): boolean; + /** + * Initializes the bot, i.e. fetches information about the bot itself. This + * method is called automatically, you usually don't have to call it + * manually. + * + * @param signal Optional `AbortSignal` to cancel the initialization + */ + init(signal?: AbortSignal): Promise; + /** + * Internal. Do not call. Handles an update batch sequentially by supplying + * it one-by-one to the middleware. Handles middleware errors and stores the + * last update identifier that was being tried to handle. + * + * @param updates An array of updates to handle + */ + private handleUpdates; + /** + * This is an internal method that you probably will not ever need to call. + * It is used whenever a new update arrives from the Telegram servers that + * your bot will handle. + * + * If you're writing a library on top of grammY, check out the + * [documentation](https://grammy.dev/plugins/runner) of the runner + * plugin for an example that uses this method. + * + * @param update An update from the Telegram Bot API + * @param webhookReplyEnvelope An optional webhook reply envelope + */ + handleUpdate(update: Update, webhookReplyEnvelope?: WebhookReplyEnvelope): Promise; + /** + * Starts your bot using long polling. + * + * > This method returns a `Promise` that will never resolve except if your + * > bot is stopped. **You don't need to `await` the call to `bot.start`**, + * > but remember to catch potential errors by calling `bot.catch`. + * > Otherwise your bot will crash (and stop) if something goes wrong in + * > your code. + * + * This method effectively enters a loop that will repeatedly call + * `getUpdates` and run your middleware for every received update, allowing + * your bot to respond to messages. + * + * If your bot is already running, this method does nothing. + * + * **Note that this starts your bot using a very simple long polling + * implementation.** `bot.start` should only be used for small bots. While + * the rest of grammY was built to perform well even under extreme loads, + * simple long polling is not capable of scaling up in a similar fashion. + * You should switch over to using `@grammyjs/runner` if you are running a + * bot with high load. + * + * What exactly _high load_ means differs from bot to bot, but as a rule of + * thumb, simple long polling should not be processing more than ~5K + * messages every hour. Also, if your bot has long-running operations such + * as large file transfers that block the middleware from completing, this + * will impact the responsiveness negatively, so it makes sense to use the + * `@grammyjs/runner` package even if you receive much fewer messages. If + * you worry about how much load your bot can handle, check out the grammY + * [documentation](https://grammy.dev/advanced/scaling) about scaling + * up. + * + * @param options Options to use for simple long polling + */ + start(options?: PollingOptions): Promise; + /** + * Stops the bot from long polling. + * + * All middleware that is currently being executed may complete, but no + * further `getUpdates` calls will be performed. The current `getUpdates` + * request will be cancelled. + * + * In addition, this method will _confirm_ the last received update to the + * Telegram servers by calling `getUpdates` one last time with the latest + * offset value. If any updates are received in this call, they are + * discarded and will be fetched again when the bot starts up the next time. + * Confer the official documentation on confirming updates if you want to + * know more: https://core.telegram.org/bots/api#getupdates + * + * > Note that this method will not wait for the middleware stack to finish. + * > If you need to run code after all middleware is done, consider waiting + * > for the promise returned by `bot.start()` to resolve. + */ + stop(): Promise; + /** + * Returns true if the bot is currently running via built-in long polling, + * and false otherwise. + * + * If this method returns true, it means that `bot.start()` has been called, + * and that the bot has neither crashed nor was it stopped via a call to + * `bot.stop()`. This also means that you cannot use this method to check if + * a webhook server is running, or if grammY runner was started. + * + * Note that this method will already begin to return true even before the + * call to `bot.start()` has completed its initialization phase (and hence + * before `bot.isInited()` returns true). By extension, this method + * returns true before `onStart` callback of `bot.start()` is invoked. + */ + isRunning(): boolean; + /** + * Sets the bots error handler that is used during long polling. + * + * You should call this method to set an error handler if you are using long + * polling, no matter whether you use `bot.start` or the `@grammyjs/runner` + * package to run your bot. + * + * Calling `bot.catch` when using other means of running your bot (or + * webhooks) has no effect. + * + * @param errorHandler A function that handles potential middleware errors + */ + catch(errorHandler: ErrorHandler): void; + /** + * Internal. Do not call. Enters a loop that will perform long polling until + * the bot is stopped. + */ + private loop; + /** + * Internal. Do not call. Reliably fetches an update batch via `getUpdates`. + * Handles all known errors. Returns `undefined` if the bot is stopped and + * the call gets cancelled. + * + * @param options Polling options + * @returns An array of updates, or `undefined` if the bot is stopped. + */ + private fetchUpdates; + /** + * Internal. Do not call. Handles an error that occurred during long + * polling. + */ + private handlePollingError; +} +import { AbortSignal } from "./shim.node.js"; diff --git a/sandbox/tgbot/node_modules/grammy/out/bot.js b/sandbox/tgbot/node_modules/grammy/out/bot.js new file mode 100644 index 0000000..4d425d3 --- /dev/null +++ b/sandbox/tgbot/node_modules/grammy/out/bot.js @@ -0,0 +1,590 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Bot = exports.BotError = exports.DEFAULT_UPDATE_TYPES = void 0; +// deno-lint-ignore-file camelcase +const composer_js_1 = require("./composer.js"); +Object.defineProperty(exports, "BotError", { enumerable: true, get: function () { return composer_js_1.BotError; } }); +const context_js_1 = require("./context.js"); +const api_js_1 = require("./core/api.js"); +const error_js_1 = require("./core/error.js"); +const filter_js_1 = require("./filter.js"); +const platform_node_js_1 = require("./platform.node.js"); +const debug = (0, platform_node_js_1.debug)("grammy:bot"); +const debugWarn = (0, platform_node_js_1.debug)("grammy:warn"); +const debugErr = (0, platform_node_js_1.debug)("grammy:error"); +exports.DEFAULT_UPDATE_TYPES = [ + "message", + "edited_message", + "channel_post", + "edited_channel_post", + "business_connection", + "business_message", + "edited_business_message", + "deleted_business_messages", + "inline_query", + "chosen_inline_result", + "callback_query", + "shipping_query", + "pre_checkout_query", + "purchased_paid_media", + "poll", + "poll_answer", + "my_chat_member", + "chat_join_request", + "chat_boost", + "removed_chat_boost", +]; +/** + * This is the single most important class of grammY. It represents your bot. + * + * First, you must create a bot by talking to @BotFather, check out + * https://t.me/BotFather. Once it is ready, you obtain a secret token for your + * bot. grammY will use that token to identify as your bot when talking to the + * Telegram servers. Got the token? You are now ready to write some code and run + * your bot! + * + * You should do three things to run your bot: + * ```ts + * // 1. Create a bot instance + * const bot = new Bot('') + * // 2. Listen for updates + * bot.on('message:text', ctx => ctx.reply('You wrote: ' + ctx.message.text)) + * // 3. Launch it! + * bot.start() + * ``` + */ +class Bot extends composer_js_1.Composer { + /** + * Creates a new Bot with the given token. + * + * Remember that you can listen for messages by calling + * ```ts + * bot.on('message', ctx => { ... }) + * ``` + * or similar methods. + * + * The simplest way to start your bot is via simple long polling: + * ```ts + * bot.start() + * ``` + * + * @param token The bot's token as acquired from https://t.me/BotFather + * @param config Optional configuration properties for the bot + */ + constructor(token, config) { + var _a; + super(); + this.token = token; + this.pollingRunning = false; + this.lastTriedUpdateId = 0; + /** Used to log a warning if some update types are not in allowed_updates */ + this.observedUpdateTypes = new Set(); + /** + * Holds the bot's error handler that is invoked whenever middleware throws + * (rejects). If you set your own error handler via `bot.catch`, all that + * happens is that this variable is assigned. + */ + this.errorHandler = async (err) => { + var _a, _b; + console.error("Error in middleware while handling update", (_b = (_a = err.ctx) === null || _a === void 0 ? void 0 : _a.update) === null || _b === void 0 ? void 0 : _b.update_id, err.error); + console.error("No error handler was set!"); + console.error("Set your own error handler with `bot.catch = ...`"); + if (this.pollingRunning) { + console.error("Stopping bot"); + await this.stop(); + } + throw err; + }; + if (!token) + throw new Error("Empty token!"); + this.me = config === null || config === void 0 ? void 0 : config.botInfo; + this.clientConfig = config === null || config === void 0 ? void 0 : config.client; + this.ContextConstructor = (_a = config === null || config === void 0 ? void 0 : config.ContextConstructor) !== null && _a !== void 0 ? _a : context_js_1.Context; + this.api = new api_js_1.Api(token, this.clientConfig); + } + /** + * Information about the bot itself as retrieved from `api.getMe()`. Only + * available after the bot has been initialized via `await bot.init()`, or + * after the value has been set manually. + * + * Starting the bot will always perform the initialization automatically, + * unless a manual value is already set. + * + * Note that the recommended way to set a custom bot information object is + * to pass it to the configuration object of the `new Bot()` instantiation, + * rather than assigning this property. + */ + set botInfo(botInfo) { + this.me = botInfo; + } + get botInfo() { + if (this.me === undefined) { + throw new Error("Bot information unavailable! Make sure to call `await bot.init()` before accessing `bot.botInfo`!"); + } + return this.me; + } + /** + * @inheritdoc + */ + on(filter, ...middleware) { + for (const [u] of (0, filter_js_1.parse)(filter).flatMap(filter_js_1.preprocess)) { + this.observedUpdateTypes.add(u); + } + return super.on(filter, ...middleware); + } + /** + * @inheritdoc + */ + reaction(reaction, ...middleware) { + this.observedUpdateTypes.add("message_reaction"); + return super.reaction(reaction, ...middleware); + } + /** + * Checks if the bot has been initialized. A bot is initialized if the bot + * information is set. The bot information can either be set automatically + * by calling `bot.init`, or manually through the bot constructor. Note that + * usually, initialization is done automatically and you do not have to care + * about this method. + * + * @returns true if the bot is initialized, and false otherwise + */ + isInited() { + return this.me !== undefined; + } + /** + * Initializes the bot, i.e. fetches information about the bot itself. This + * method is called automatically, you usually don't have to call it + * manually. + * + * @param signal Optional `AbortSignal` to cancel the initialization + */ + async init(signal) { + var _a; + if (!this.isInited()) { + debug("Initializing bot"); + (_a = this.mePromise) !== null && _a !== void 0 ? _a : (this.mePromise = withRetries(() => this.api.getMe(signal), signal)); + let me; + try { + me = await this.mePromise; + } + finally { + this.mePromise = undefined; + } + if (this.me === undefined) + this.me = me; + else + debug("Bot info was set by now, will not overwrite"); + } + debug(`I am ${this.me.username}!`); + } + /** + * Internal. Do not call. Handles an update batch sequentially by supplying + * it one-by-one to the middleware. Handles middleware errors and stores the + * last update identifier that was being tried to handle. + * + * @param updates An array of updates to handle + */ + async handleUpdates(updates) { + // handle updates sequentially (!) + for (const update of updates) { + this.lastTriedUpdateId = update.update_id; + try { + await this.handleUpdate(update); + } + catch (err) { + // should always be true + if (err instanceof composer_js_1.BotError) { + await this.errorHandler(err); + } + else { + console.error("FATAL: grammY unable to handle:", err); + throw err; + } + } + } + } + /** + * This is an internal method that you probably will not ever need to call. + * It is used whenever a new update arrives from the Telegram servers that + * your bot will handle. + * + * If you're writing a library on top of grammY, check out the + * [documentation](https://grammy.dev/plugins/runner) of the runner + * plugin for an example that uses this method. + * + * @param update An update from the Telegram Bot API + * @param webhookReplyEnvelope An optional webhook reply envelope + */ + async handleUpdate(update, webhookReplyEnvelope) { + if (this.me === undefined) { + throw new Error("Bot not initialized! Either call `await bot.init()`, \ +or directly set the `botInfo` option in the `Bot` constructor to specify \ +a known bot info object."); + } + debug(`Processing update ${update.update_id}`); + // create API object + const api = new api_js_1.Api(this.token, this.clientConfig, webhookReplyEnvelope); + // configure it with the same transformers as bot.api + const t = this.api.config.installedTransformers(); + if (t.length > 0) + api.config.use(...t); + // create context object + const ctx = new this.ContextConstructor(update, api, this.me); + try { + // run middleware stack + await (0, composer_js_1.run)(this.middleware(), ctx); + } + catch (err) { + debugErr(`Error in middleware for update ${update.update_id}`); + throw new composer_js_1.BotError(err, ctx); + } + } + /** + * Starts your bot using long polling. + * + * > This method returns a `Promise` that will never resolve except if your + * > bot is stopped. **You don't need to `await` the call to `bot.start`**, + * > but remember to catch potential errors by calling `bot.catch`. + * > Otherwise your bot will crash (and stop) if something goes wrong in + * > your code. + * + * This method effectively enters a loop that will repeatedly call + * `getUpdates` and run your middleware for every received update, allowing + * your bot to respond to messages. + * + * If your bot is already running, this method does nothing. + * + * **Note that this starts your bot using a very simple long polling + * implementation.** `bot.start` should only be used for small bots. While + * the rest of grammY was built to perform well even under extreme loads, + * simple long polling is not capable of scaling up in a similar fashion. + * You should switch over to using `@grammyjs/runner` if you are running a + * bot with high load. + * + * What exactly _high load_ means differs from bot to bot, but as a rule of + * thumb, simple long polling should not be processing more than ~5K + * messages every hour. Also, if your bot has long-running operations such + * as large file transfers that block the middleware from completing, this + * will impact the responsiveness negatively, so it makes sense to use the + * `@grammyjs/runner` package even if you receive much fewer messages. If + * you worry about how much load your bot can handle, check out the grammY + * [documentation](https://grammy.dev/advanced/scaling) about scaling + * up. + * + * @param options Options to use for simple long polling + */ + async start(options) { + var _a, _b, _c; + // Perform setup + const setup = []; + if (!this.isInited()) { + setup.push(this.init((_a = this.pollingAbortController) === null || _a === void 0 ? void 0 : _a.signal)); + } + if (this.pollingRunning) { + await Promise.all(setup); + debug("Simple long polling already running!"); + return; + } + this.pollingRunning = true; + this.pollingAbortController = new shim_node_js_1.AbortController(); + try { + setup.push(withRetries(async () => { + var _a; + await this.api.deleteWebhook({ + drop_pending_updates: options === null || options === void 0 ? void 0 : options.drop_pending_updates, + }, (_a = this.pollingAbortController) === null || _a === void 0 ? void 0 : _a.signal); + }, (_b = this.pollingAbortController) === null || _b === void 0 ? void 0 : _b.signal)); + await Promise.all(setup); + // All async ops of setup complete, run callback + await ((_c = options === null || options === void 0 ? void 0 : options.onStart) === null || _c === void 0 ? void 0 : _c.call(options, this.botInfo)); + } + catch (err) { + this.pollingRunning = false; + this.pollingAbortController = undefined; + throw err; + } + // Bot was stopped during `onStart` + if (!this.pollingRunning) + return; + // Prevent common misuse that leads to missing updates + validateAllowedUpdates(this.observedUpdateTypes, options === null || options === void 0 ? void 0 : options.allowed_updates); + // Prevent common misuse that causes memory leak + this.use = noUseFunction; + // Start polling + debug("Starting simple long polling"); + await this.loop(options); + debug("Middleware is done running"); + } + /** + * Stops the bot from long polling. + * + * All middleware that is currently being executed may complete, but no + * further `getUpdates` calls will be performed. The current `getUpdates` + * request will be cancelled. + * + * In addition, this method will _confirm_ the last received update to the + * Telegram servers by calling `getUpdates` one last time with the latest + * offset value. If any updates are received in this call, they are + * discarded and will be fetched again when the bot starts up the next time. + * Confer the official documentation on confirming updates if you want to + * know more: https://core.telegram.org/bots/api#getupdates + * + * > Note that this method will not wait for the middleware stack to finish. + * > If you need to run code after all middleware is done, consider waiting + * > for the promise returned by `bot.start()` to resolve. + */ + async stop() { + var _a; + if (this.pollingRunning) { + debug("Stopping bot, saving update offset"); + this.pollingRunning = false; + (_a = this.pollingAbortController) === null || _a === void 0 ? void 0 : _a.abort(); + const offset = this.lastTriedUpdateId + 1; + await this.api.getUpdates({ offset, limit: 1 }) + .finally(() => this.pollingAbortController = undefined); + } + else { + debug("Bot is not running!"); + } + } + /** + * Returns true if the bot is currently running via built-in long polling, + * and false otherwise. + * + * If this method returns true, it means that `bot.start()` has been called, + * and that the bot has neither crashed nor was it stopped via a call to + * `bot.stop()`. This also means that you cannot use this method to check if + * a webhook server is running, or if grammY runner was started. + * + * Note that this method will already begin to return true even before the + * call to `bot.start()` has completed its initialization phase (and hence + * before `bot.isInited()` returns true). By extension, this method + * returns true before `onStart` callback of `bot.start()` is invoked. + */ + isRunning() { + return this.pollingRunning; + } + /** + * Sets the bots error handler that is used during long polling. + * + * You should call this method to set an error handler if you are using long + * polling, no matter whether you use `bot.start` or the `@grammyjs/runner` + * package to run your bot. + * + * Calling `bot.catch` when using other means of running your bot (or + * webhooks) has no effect. + * + * @param errorHandler A function that handles potential middleware errors + */ + catch(errorHandler) { + this.errorHandler = errorHandler; + } + /** + * Internal. Do not call. Enters a loop that will perform long polling until + * the bot is stopped. + */ + async loop(options) { + var _a, _b; + const limit = options === null || options === void 0 ? void 0 : options.limit; + const timeout = (_a = options === null || options === void 0 ? void 0 : options.timeout) !== null && _a !== void 0 ? _a : 30; // seconds + let allowed_updates = (_b = options === null || options === void 0 ? void 0 : options.allowed_updates) !== null && _b !== void 0 ? _b : []; // reset to default if unspecified + try { + while (this.pollingRunning) { + // fetch updates + const updates = await this.fetchUpdates({ limit, timeout, allowed_updates }); + // check if polling stopped + if (updates === undefined) + break; + // handle updates + await this.handleUpdates(updates); + // Telegram uses the last setting if `allowed_updates` is omitted so + // we can save some traffic by only sending it in the first request + allowed_updates = undefined; + } + } + finally { + this.pollingRunning = false; + } + } + /** + * Internal. Do not call. Reliably fetches an update batch via `getUpdates`. + * Handles all known errors. Returns `undefined` if the bot is stopped and + * the call gets cancelled. + * + * @param options Polling options + * @returns An array of updates, or `undefined` if the bot is stopped. + */ + async fetchUpdates({ limit, timeout, allowed_updates }) { + var _a; + const offset = this.lastTriedUpdateId + 1; + let updates = undefined; + do { + try { + updates = await this.api.getUpdates({ offset, limit, timeout, allowed_updates }, (_a = this.pollingAbortController) === null || _a === void 0 ? void 0 : _a.signal); + } + catch (error) { + await this.handlePollingError(error); + } + } while (updates === undefined && this.pollingRunning); + return updates; + } + /** + * Internal. Do not call. Handles an error that occurred during long + * polling. + */ + async handlePollingError(error) { + var _a; + if (!this.pollingRunning) { + debug("Pending getUpdates request cancelled"); + return; + } + let sleepSeconds = 3; + if (error instanceof error_js_1.GrammyError) { + debugErr(error.message); + // rethrow upon unauthorized or conflict + if (error.error_code === 401 || error.error_code === 409) { + throw error; + } + else if (error.error_code === 429) { + debugErr("Bot API server is closing."); + sleepSeconds = (_a = error.parameters.retry_after) !== null && _a !== void 0 ? _a : sleepSeconds; + } + } + else + debugErr(error); + debugErr(`Call to getUpdates failed, retrying in ${sleepSeconds} seconds ...`); + await sleep(sleepSeconds); + } +} +exports.Bot = Bot; +/** + * Performs a network call task, retrying upon known errors until success. + * + * If the task errors and a retry_after value can be used, a subsequent retry + * will be delayed by the specified period of time. + * + * Otherwise, if the first attempt at running the task fails, the task is + * retried immediately. If second attempt fails, too, waits for 100 ms, and then + * doubles this delay for every subsequent attempt. Never waits longer than 1 + * hour before retrying. + * + * @param task Async task to perform + * @param signal Optional `AbortSignal` to prevent further retries + */ +async function withRetries(task, signal) { + // Set up delays between retries + const INITIAL_DELAY = 50; // ms + let lastDelay = INITIAL_DELAY; + // Define error handler + /** + * Determines the error handling strategy based on various error types. + * Sleeps if necessary, and returns whether to retry or rethrow an error. + */ + async function handleError(error) { + let delay = false; + let strategy = "rethrow"; + if (error instanceof error_js_1.HttpError) { + delay = true; + strategy = "retry"; + } + else if (error instanceof error_js_1.GrammyError) { + if (error.error_code >= 500) { + delay = true; + strategy = "retry"; + } + else if (error.error_code === 429) { + const retryAfter = error.parameters.retry_after; + if (typeof retryAfter === "number") { + // ignore the backoff for sleep, then reset it + await sleep(retryAfter, signal); + lastDelay = INITIAL_DELAY; + } + else { + delay = true; + } + strategy = "retry"; + } + } + if (delay) { + // Do not sleep for the first retry + if (lastDelay !== INITIAL_DELAY) { + await sleep(lastDelay, signal); + } + const TWENTY_MINUTES = 20 * 60 * 1000; // ms + lastDelay = Math.min(TWENTY_MINUTES, 2 * lastDelay); + } + return strategy; + } + // Perform the actual task with retries + let result = { ok: false }; + while (!result.ok) { + try { + result = { ok: true, value: await task() }; + } + catch (error) { + debugErr(error); + const strategy = await handleError(error); + switch (strategy) { + case "retry": + continue; + case "rethrow": + throw error; + } + } + } + return result.value; +} +/** + * Returns a new promise that resolves after the specified number of seconds, or + * rejects as soon as the given signal is aborted. + */ +async function sleep(seconds, signal) { + let handle; + let reject; + function abort() { + reject === null || reject === void 0 ? void 0 : reject(new Error("Aborted delay")); + if (handle !== undefined) + clearTimeout(handle); + } + try { + await new Promise((res, rej) => { + reject = rej; + if (signal === null || signal === void 0 ? void 0 : signal.aborted) { + abort(); + return; + } + signal === null || signal === void 0 ? void 0 : signal.addEventListener("abort", abort); + handle = setTimeout(res, 1000 * seconds); + }); + } + finally { + signal === null || signal === void 0 ? void 0 : signal.removeEventListener("abort", abort); + } +} +/** + * Takes a set of observed update types and a list of allowed updates and logs a + * warning in debug mode if some update types were observed that have not been + * allowed. + */ +function validateAllowedUpdates(updates, allowed = exports.DEFAULT_UPDATE_TYPES) { + const impossible = Array.from(updates).filter((u) => !allowed.includes(u)); + if (impossible.length > 0) { + debugWarn(`You registered listeners for the following update types, \ +but you did not specify them in \`allowed_updates\` \ +so they may not be received: ${impossible.map((u) => `'${u}'`).join(", ")}`); + } +} +function noUseFunction() { + throw new Error(`It looks like you are registering more listeners \ +on your bot from within other listeners! This means that every time your bot \ +handles a message like this one, new listeners will be added. This list grows until \ +your machine crashes, so grammY throws this error to tell you that you should \ +probably do things a bit differently. If you're unsure how to resolve this problem, \ +you can ask in the group chat: https://telegram.me/grammyjs + +On the other hand, if you actually know what you're doing and you do need to install \ +further middleware while your bot is running, consider installing a composer \ +instance on your bot, and in turn augment the composer after the fact. This way, \ +you can circumvent this protection against memory leaks.`); +} +const shim_node_js_1 = require("./shim.node.js"); diff --git a/sandbox/tgbot/node_modules/grammy/out/composer.d.ts b/sandbox/tgbot/node_modules/grammy/out/composer.d.ts new file mode 100644 index 0000000..08d109b --- /dev/null +++ b/sandbox/tgbot/node_modules/grammy/out/composer.d.ts @@ -0,0 +1,764 @@ +import { type CallbackQueryContext, type ChatTypeContext, type ChosenInlineResultContext, type CommandContext, Context, type GameQueryContext, type HearsContext, type InlineQueryContext, type MaybeArray, type PreCheckoutQueryContext, type ReactionContext, type ShippingQueryContext, type StringWithCommandSuggestions } from "./context.js"; +import { type Filter, type FilterQuery } from "./filter.js"; +import { type Chat, type ReactionType, type ReactionTypeEmoji } from "./types.js"; +type MaybePromise = T | Promise; +/** + * A function of this type is passed as the second parameter to all middleware. + * Invoke it to call the downstream middleware and pass on the control flow. + * + * In other words, if your middleware is done handling the context object, and + * other middleware should take over, this function should be called and + * `await`ed. + * + * Once the `Promise` returned by this function resolves, the downstream + * middleware is done executing, hence returning the control. + */ +export type NextFunction = () => Promise; +/** + * Middleware in the form of a function. + */ +export type MiddlewareFn = (ctx: C, next: NextFunction) => MaybePromise; +/** + * Middleware in the form of a container for a function. + */ +export interface MiddlewareObj { + /** + * Returns the contained middleware. + */ + middleware: () => MiddlewareFn; +} +/** + * Middleware for grammY, either as a function or as a container for a function. + * + * Simply put, middleware is just a fancy term for a _listener_. You can + * register middleware on a bot to listen for updates. Example: + * + * ```ts + * bot.on('message', ctx => ctx.reply('I got your message!')) + * // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * // ^ + * // | + * // This is middleware! + * ``` + * + * Middleware receives one object that we call the _context object_. This is + * another fancy term for a simple object that holds information about the + * update you're processing. For instance, the context object gives you access + * to the message that was sent to your bot (`ctx.message`), including the text + * (or photo or whatever message the user has sent). The context object is + * commonly named `ctx`. + * + * It also provides you with the `ctx.api` object that you also find on + * `bot.api`. As a result, you can call `ctx.api.sendMessage` instead of + * `bot.api.sendMessage`. This prevents you from having to pass around your + * `bot` instance all over your code. + * + * Most importantly, the context object gives you a handful of really useful + * shortcuts, such as a `reply` method (see above). This method is nothing else + * than a wrapper around `ctx.api.sendMessage`—but with some arguments + * pre-filled for you. As you can see above, you no longer have to specify a + * `chat_id` or anything; the context object knows which chat it belongs to, so + * when you call `reply`, the context will call `sendMessage` with the correct + * `chat_id`, namely the one for the same chat that the incoming message + * originates from. This makes it very convenient to reply to a message. + * + * Middleware is an extremely powerful concept and this short explanation only + * scratched the surface of what is possible with grammY. If you want to know + * more advanced things about middleware, check out the + * [documentation](https://grammy.dev/guide/middleware) on the website. + */ +export type Middleware = MiddlewareFn | MiddlewareObj; +/** + * This error is thrown when middleware throws. It simply wraps the original + * error (accessible via the `error` property), but also provides access to the + * respective context object that was processed while the error occurred. + */ +export declare class BotError extends Error { + readonly error: unknown; + readonly ctx: C; + constructor(error: unknown, ctx: C); +} +/** + * Runs some given middleware function with a given context object. + * + * @param middleware The middleware to run + * @param ctx The context to use + */ +export declare function run(middleware: MiddlewareFn, ctx: C): Promise; +/** + * The composer is the heart of the middleware system in grammY. It is also the + * superclass of `Bot`. Whenever you call `use` or `on` or some of the other + * methods on your bot, you are in fact using the underlying composer instance + * to register your middleware. + * + * If you're just getting started, you do not need to worry about what + * middleware is, or about how to use a composer. + * + * On the other hand, if you want to dig deeper into how grammY implements + * middleware, check out the + * [documentation](https://grammy.dev/advanced/middleware) on the website. + */ +export declare class Composer implements MiddlewareObj { + private handler; + /** + * Constructs a new composer based on the provided middleware. If no + * middleware is given, the composer instance will simply make all context + * objects pass through without touching them. + * + * @param middleware The middleware to compose + */ + constructor(...middleware: Array>); + middleware(): MiddlewareFn; + /** + * Registers some middleware that receives all updates. It is installed by + * concatenating it to the end of all previously installed middleware. + * + * Often, this method is used to install middleware that behaves like a + * plugin, for example session middleware. + * ```ts + * bot.use(session()) + * ``` + * + * This method returns a new instance of composer. The returned instance can + * be further extended, and all changes will be regarded here. Confer the + * [documentation](https://grammy.dev/advanced/middleware) on the + * website if you want to know more about how the middleware system in + * grammY works, especially when it comes to chaining the method calls + * (`use( ... ).use( ... ).use( ... )`). + * + * @param middleware The middleware to register + */ + use(...middleware: Array>): Composer; + /** + * Registers some middleware that will only be executed for some specific + * updates, namely those matching the provided filter query. Filter queries + * are a concise way to specify which updates you are interested in. + * + * Here are some examples of valid filter queries: + * ```ts + * // All kinds of message updates + * bot.on('message', ctx => { ... }) + * + * // Only text messages + * bot.on('message:text', ctx => { ... }) + * + * // Only text messages with URL + * bot.on('message:entities:url', ctx => { ... }) + * + * // Text messages and text channel posts + * bot.on(':text', ctx => { ... }) + * + * // Messages with URL in text or caption (i.e. entities or caption entities) + * bot.on('message::url', ctx => { ... }) + * + * // Messages or channel posts with URL in text or caption + * bot.on('::url', ctx => { ... }) + * ``` + * + * You can use autocomplete in VS Code to see all available filter queries. + * Check out the + * [documentation](https://grammy.dev/guide/filter-queries) on the + * website to learn more about filter queries in grammY. + * + * It is possible to pass multiple filter queries in an array, i.e. + * ```ts + * // Matches all text messages and edited text messages that contain a URL + * bot.on(['message:entities:url', 'edited_message:entities:url'], ctx => { ... }) + * ``` + * + * Your middleware will be executed if _any of the provided filter queries_ + * matches (logical OR). + * + * If you instead want to match _all of the provided filter queries_ + * (logical AND), you can chain the `.on` calls: + * ```ts + * // Matches all messages and channel posts that both a) contain a URL and b) are forwards + * bot.on('::url').on(':forward_origin', ctx => { ... }) + * ``` + * + * @param filter The filter query to use, may also be an array of queries + * @param middleware The middleware to register behind the given filter + */ + on(filter: Q | Q[], ...middleware: Array>>): Composer>; + /** + * Registers some middleware that will only be executed when the message + * contains some text. Is it possible to pass a regular expression to match: + * ```ts + * // Match some text (exact match) + * bot.hears('I love grammY', ctx => ctx.reply('And grammY loves you! <3')) + * // Match a regular expression + * bot.hears(/\/echo (.+)/, ctx => ctx.reply(ctx.match[1])) + * ``` + * Note how `ctx.match` will contain the result of the regular expression. + * Here it is a `RegExpMatchArray` object, so `ctx.match[1]` refers to the + * part of the regex that was matched by `(.+)`, i.e. the text that comes + * after “/echo”. + * + * You can pass an array of triggers. Your middleware will be executed if at + * least one of them matches. + * + * Both text and captions of the received messages will be scanned. For + * example, when a photo is sent to the chat and its caption matches the + * trigger, your middleware will be executed. + * + * If you only want to match text messages and not captions, you can do + * this: + * ```ts + * // Only matches text messages (and channel posts) for the regex + * bot.on(':text').hears(/\/echo (.+)/, ctx => { ... }) + * ``` + * + * @param trigger The text to look for + * @param middleware The middleware to register + */ + hears(trigger: MaybeArray, ...middleware: Array>): Composer>; + /** + * Registers some middleware that will only be executed when a certain + * command is found. + * ```ts + * // Reacts to /start commands + * bot.command('start', ctx => { ... }) + * // Reacts to /help commands + * bot.command('help', ctx => { ... }) + * ``` + * + * The rest of the message (excluding the command, and trimmed) is provided + * via `ctx.match`. + * + * > **Did you know?** You can use deep linking + * > (https://core.telegram.org/bots/features#deep-linking) to let users + * > start your bot with a custom payload. As an example, send someone the + * > link https://t.me/name-of-your-bot?start=custom-payload and register a + * > start command handler on your bot with grammY. As soon as the user + * > starts your bot, you will receive `custom-payload` in the `ctx.match` + * > property! + * > ```ts + * > bot.command('start', ctx => { + * > const payload = ctx.match // will be 'custom-payload' + * > }) + * > ``` + * + * Note that commands are not matched in captions or in the middle of the + * text. + * ```ts + * bot.command('start', ctx => { ... }) + * // ... does not match: + * // A message saying: “some text /start some more text” + * // A photo message with the caption “/start” + * ``` + * + * By default, commands are detected in channel posts, too. This means that + * `ctx.message` is potentially `undefined`, so you should use `ctx.msg` + * instead to grab both messages and channel posts. Alternatively, if you + * want to limit your bot to finding commands only in private and group + * chats, you can use `bot.on('message').command('start', ctx => { ... })`, + * or even store a message-only version of your bot in a variable like so: + * ```ts + * const m = bot.on('message') + * + * m.command('start', ctx => { ... }) + * m.command('help', ctx => { ... }) + * // etc + * ``` + * + * If you need more freedom matching your commands, check out the `commands` + * plugin. + * + * @param command The command to look for + * @param middleware The middleware to register + */ + command(command: MaybeArray, ...middleware: Array>): Composer>; + /** + * Registers some middleware that will only be added when a new reaction of + * the given type is added to a message. + * ```ts + * // Reacts to new '👍' reactions + * bot.reaction('👍', ctx => { ... }) + * // Reacts to new '👍' or '👎' reactions + * bot.reaction(['👍', '👎'], ctx => { ... }) + * ``` + * + * > Note that you have to enable `message_reaction` updates in + * `allowed_updates` if you want your bot to receive updates about message + * reactions. + * + * `bot.reaction` will trigger if: + * - a new emoji reaction is added to a message + * - a new custom emoji reaction is added a message + * + * `bot.reaction` will not trigger if: + * - a reaction is removed + * - an anonymous reaction count is updated, such as on channel posts + * - `message_reaction` updates are not enabled for your bot + * + * @param reaction The reaction to look for + * @param middleware The middleware to register + */ + reaction(reaction: MaybeArray, ...middleware: Array>): Composer>; + /** + * Registers some middleware for certain chat types only. For example, you + * can use this method to only receive updates from private chats. The four + * chat types are `"channel"`, `"supergroup"`, `"group"`, and `"private"`. + * This is especially useful when combined with other filtering logic. For + * example, this is how can you respond to `/start` commands only from + * private chats: + * ```ts + * bot.chatType("private").command("start", ctx => { ... }) + * ``` + * + * Naturally, you can also use this method on its own. + * ```ts + * // Private chats only + * bot.chatType("private", ctx => { ... }); + * // Channels only + * bot.chatType("channel", ctx => { ... }); + * ``` + * + * You can pass an array of chat types if you want your middleware to run + * for any of several provided chat types. + * ```ts + * // Groups and supergroups only + * bot.chatType(["group", "supergroup"], ctx => { ... }); + * ``` + * [Remember](https://grammy.dev/guide/context#shortcuts) also that you + * can access the chat type via `ctx.chat.type`. + * + * @param chatType The chat type + * @param middleware The middleware to register + */ + chatType(chatType: MaybeArray, ...middleware: Array>>): Composer>; + /** + * Registers some middleware for callback queries, i.e. the updates that + * Telegram delivers to your bot when a user clicks an inline button (that + * is a button under a message). + * + * This method is essentially the same as calling + * ```ts + * bot.on('callback_query:data', ctx => { ... }) + * ``` + * but it also allows you to match the query data against a given text or + * regular expression. + * + * ```ts + * // Create an inline keyboard + * const keyboard = new InlineKeyboard().text('Go!', 'button-payload') + * // Send a message with the keyboard + * await bot.api.sendMessage(chat_id, 'Press a button!', { + * reply_markup: keyboard + * }) + * // Listen to users pressing buttons with that specific payload + * bot.callbackQuery('button-payload', ctx => { ... }) + * + * // Listen to users pressing any button your bot ever sent + * bot.on('callback_query:data', ctx => { ... }) + * ``` + * + * Always remember to call `answerCallbackQuery`—even if you don't perform + * any action: https://core.telegram.org/bots/api#answercallbackquery + * ```ts + * bot.on('callback_query:data', async ctx => { + * await ctx.answerCallbackQuery() + * }) + * ``` + * + * You can pass an array of triggers. Your middleware will be executed if at + * least one of them matches. + * + * @param trigger The string to look for in the payload + * @param middleware The middleware to register + */ + callbackQuery(trigger: MaybeArray, ...middleware: Array>): Composer>; + /** + * Registers some middleware for game queries, i.e. the updates that + * Telegram delivers to your bot when a user clicks an inline button for the + * HTML5 games platform on Telegram. + * + * This method is essentially the same as calling + * ```ts + * bot.on('callback_query:game_short_name', ctx => { ... }) + * ``` + * but it also allows you to match the query data against a given text or + * regular expression. + * + * You can pass an array of triggers. Your middleware will be executed if at + * least one of them matches. + * + * @param trigger The string to look for in the payload + * @param middleware The middleware to register + */ + gameQuery(trigger: MaybeArray, ...middleware: Array>): Composer>; + /** + * Registers middleware for inline queries. Telegram sends an inline query + * to your bot whenever a user types “@your_bot_name ...” into a text field + * in Telegram. You bot will then receive the entered search query and can + * respond with a number of results (text, images, etc) that the user can + * pick from to send a message _via_ your bot to the respective chat. Check + * out https://core.telegram.org/bots/inline to read more about inline bots. + * + * > Note that you have to enable inline mode for you bot by contacting + * > @BotFather first. + * + * ```ts + * // Listen for users typing “@your_bot_name query” + * bot.inlineQuery('query', async ctx => { + * // Answer the inline query, confer https://core.telegram.org/bots/api#answerinlinequery + * await ctx.answerInlineQuery( ... ) + * }) + * ``` + * + * @param trigger The inline query text to match + * @param middleware The middleware to register + */ + inlineQuery(trigger: MaybeArray, ...middleware: Array>): Composer>; + /** + * Registers middleware for the ChosenInlineResult by the given id or ids. + * ChosenInlineResult represents a result of an inline query that was chosen + * by the user and sent to their chat partner. Check out + * https://core.telegram.org/bots/api#choseninlineresult to read more about + * chosen inline results. + * + * ```ts + * bot.chosenInlineResult('id', async ctx => { + * const id = ctx.result_id; + * // Your code + * }) + * ``` + * + * @param resultId An id or array of ids + * @param middleware The middleware to register + */ + chosenInlineResult(resultId: MaybeArray, ...middleware: Array>): Composer>; + /** + * Registers middleware for pre-checkout queries. Telegram sends a + * pre-checkout query to your bot whenever a user has confirmed their + * payment and shipping details. You bot will then receive all information + * about the order and has to respond within 10 seconds with a confirmation + * of whether everything is alright (goods are available, etc.) and the bot + * is ready to proceed with the order. Check out + * https://core.telegram.org/bots/api#precheckoutquery to read more about + * pre-checkout queries. + * + * ```ts + * bot.preCheckoutQuery('invoice_payload', async ctx => { + * // Answer the pre-checkout query, confer https://core.telegram.org/bots/api#answerprecheckoutquery + * await ctx.answerPreCheckoutQuery( ... ) + * }) + * ``` + * + * @param trigger The string to look for in the invoice payload + * @param middleware The middleware to register + */ + preCheckoutQuery(trigger: MaybeArray, ...middleware: Array>): Composer>; + /** + * Registers middleware for shipping queries. If you sent an invoice + * requesting a shipping address and the parameter _is_flexible_ was + * specified, Telegram will send a shipping query to your bot whenever a + * user has confirmed their shipping details. You bot will then receive the + * shipping information and can respond with a confirmation of whether + * delivery to the specified address is possible. Check out + * https://core.telegram.org/bots/api#shippingquery to read more about + * shipping queries. + * + * ```ts + * bot.shippingQuery('invoice_payload', async ctx => { + * // Answer the shipping query, confer https://core.telegram.org/bots/api#answershippingquery + * await ctx.answerShippingQuery( ... ) + * }) + * ``` + * + * @param trigger The string to look for in the invoice payload + * @param middleware The middleware to register + */ + shippingQuery(trigger: MaybeArray, ...middleware: Array>): Composer>; + /** + * > This is an advanced method of grammY. + * + * Registers middleware behind a custom filter function that operates on the + * context object and decides whether or not to execute the middleware. In + * other words, the middleware will only be executed if the given predicate + * returns `true` for the given context object. Otherwise, it will be + * skipped and the next middleware will be executed. + * + * This method has two signatures. The first one is straightforward, it is + * the one described above. Note that the predicate may be asynchronous, + * i.e. it can return a Promise of a boolean. + * + * Alternatively, you can pass a function that has a type predicate as + * return type. This will allow you to narrow down the context object. The + * installed middleware is then able to operate on this constrained context + * object. + * ```ts + * // NORMAL USAGE + * // Only process every second update + * bot.filter(ctx => ctx.update.update_id % 2 === 0, ctx => { ... }) + * + * // TYPE PREDICATE USAGE + * function predicate(ctx): ctx is Context & { message: undefined } { + * return ctx.message === undefined + * } + * // Only process updates where `message` is `undefined` + * bot.filter(predicate, ctx => { + * const m = ctx.message // inferred as always undefined! + * const m2 = ctx.update.message // also inferred as always undefined! + * }) + * ``` + * + * @param predicate The predicate to check + * @param middleware The middleware to register + */ + filter(predicate: (ctx: C) => ctx is D, ...middleware: Array>): Composer; + filter(predicate: (ctx: C) => MaybePromise, ...middleware: Array>): Composer; + /** + * > This is an advanced method of grammY. + * + * Registers middleware behind a custom filter function that operates on the + * context object and decides whether or not to execute the middleware. In + * other words, the middleware will only be executed if the given predicate + * returns `false` for the given context object. Otherwise, it will be + * skipped and the next middleware will be executed. Note that the predicate + * may be asynchronous, i.e. it can return a Promise of a boolean. + * + * This method is the same using `filter` (normal usage) with a negated + * predicate. + * + * @param predicate The predicate to check + * @param middleware The middleware to register + */ + drop(predicate: (ctx: C) => MaybePromise, ...middleware: Array>): Composer; + /** + * > This is an advanced method of grammY. + * + * Registers some middleware that runs concurrently to the executing + * middleware stack. + * ```ts + * bot.use( ... ) // will run first + * bot.fork( ... ) // will be started second, but run concurrently + * bot.use( ... ) // will also be run second + * ``` + * In the first middleware, as soon as `next`'s Promise resolves, both forks + * have completed. + * + * Both the fork and the downstream middleware are awaited with + * `Promise.all`, so you will only be able to catch at most one error (the + * one that is thrown first). + * + * In contrast to the other middleware methods on composer, `fork` does not + * simply return the composer connected to the main middleware stack. + * Instead, it returns the created composer _of the fork_ connected to the + * middleware stack. This allows for the following pattern. + * ```ts + * // Middleware will be run concurrently! + * bot.fork().on('message', ctx => { ... }) + * ``` + * + * @param middleware The middleware to run concurrently + */ + fork(...middleware: Array>): Composer; + /** + * > This is an advanced method of grammY. + * + * Executes some middleware that can be generated on the fly for each + * context. Pass a factory function that creates some middleware (or a + * middleware array even). The factory function will be called once per + * context, and its result will be executed with the context object. + * ```ts + * // The middleware returned by `createMyMiddleware` will be used only once + * bot.lazy(ctx => createMyMiddleware(ctx)) + * ``` + * + * You may generate this middleware in an `async` fashion. + * + * You can decide to return an empty array (`[]`) if you don't want to run + * any middleware for a given context object. This is equivalent to + * returning an empty instance of `Composer`. + * + * @param middlewareFactory The factory function creating the middleware + */ + lazy(middlewareFactory: (ctx: C) => MaybePromise>>): Composer; + /** + * > This is an advanced method of grammY. + * + * _Not to be confused with the `router` plugin._ + * + * This method is an alternative to the `router` plugin. It allows you to + * branch between different middleware per context object. You can pass two + * things to it: + * 1. A routing function + * 2. Different middleware identified by key + * + * The routing function decides based on the context object which middleware + * to run. Each middleware is identified by a key, so the routing function + * simply returns the key of that middleware. + * ```ts + * // Define different route handlers + * const routeHandlers = { + * evenUpdates: (ctx: Context) => { ... } + * oddUpdates: (ctx: Context) => { ... } + * } + * // Decide for a context object which one to pick + * const router = (ctx: Context) => ctx.update.update_id % 2 === 0 + * ? 'evenUpdates' + * : 'oddUpdates' + * // Route it! + * bot.route(router, routeHandlers) + * ``` + * + * Optionally, you can pass a third option that is used as fallback + * middleware if your route function returns `undefined`, or if the key + * returned by your router has no middleware associated with it. + * + * This method may need less setup than first instantiating a `Router`, but + * for more complex setups, having a `Router` may be more readable. + * + * @param router The routing function to use + * @param routeHandlers Handlers for every route + * @param fallback Optional fallback middleware if no route matches + */ + route>>(router: (ctx: C) => MaybePromise, routeHandlers: R, fallback?: Middleware): Composer; + /** + * > This is an advanced method of grammY. + * + * Allows you to branch between two cases for a given context object. + * + * This method takes a predicate function that is tested once per context + * object. If it returns `true`, the first supplied middleware is executed. + * If it returns `false`, the second supplied middleware is executed. Note + * that the predicate may be asynchronous, i.e. it can return a Promise of a + * boolean. + * + * @param predicate The predicate to check + * @param trueMiddleware The middleware for the `true` case + * @param falseMiddleware The middleware for the `false` case + */ + branch(predicate: (ctx: C) => MaybePromise, trueMiddleware: MaybeArray>, falseMiddleware: MaybeArray>): Composer; + /** + * > This is an advanced function of grammY. + * + * Installs an error boundary that catches errors that happen only inside + * the given middleware. This allows you to install custom error handlers + * that protect some parts of your bot. Errors will not be able to bubble + * out of this part of your middleware system, unless the supplied error + * handler rethrows them, in which case the next surrounding error boundary + * will catch the error. + * + * Example usage: + * ```ts + * function errHandler(err: BotError) { + * console.error('Error boundary caught error!', err) + * } + * + * const safe = + * // All passed middleware will be protected by the error boundary. + * bot.errorBoundary(errHandler, middleware0, middleware1, middleware2) + * + * // Those will also be protected! + * safe.on('message', middleware3) + * + * // No error from `middleware4` will reach the `errHandler` from above, + * // as errors are suppressed. + * + * // do nothing on error (suppress error), and run outside middleware + * const suppress = (_err: BotError, next: NextFunction) => { return next() } + * safe.errorBoundary(suppress).on('edited_message', middleware4) + * ``` + * + * Check out the + * [documentation](https://grammy.dev/guide/errors#error-boundaries) on + * the website to learn more about error boundaries. + * + * @param errorHandler The error handler to use + * @param middleware The middleware to protect + */ + errorBoundary(errorHandler: (error: BotError, next: NextFunction) => MaybePromise, ...middleware: Array>): Composer; +} +/** + * Type of the middleware that can be passed to `bot.hears`. + * + * This helper type can be used to annotate middleware functions that are + * defined in one place, so that they have the correct type when passed to + * `bot.hears` in a different place. For instance, this allows for more modular + * code where handlers are defined in separate files. + */ +export type HearsMiddleware = Middleware>; +/** + * Type of the middleware that can be passed to `bot.command`. + * + * This helper type can be used to annotate middleware functions that are + * defined in one place, so that they have the correct type when passed to + * `bot.command` in a different place. For instance, this allows for more + * modular code where handlers are defined in separate files. + */ +export type CommandMiddleware = Middleware>; +/** + * Type of the middleware that can be passed to `bot.reaction`. + * + * This helper type can be used to annotate middleware functions that are + * defined in one place, so that they have the correct type when passed to + * `bot.reaction` in a different place. For instance, this allows for more + * modular code where handlers are defined in separate files. + */ +export type ReactionMiddleware = Middleware>; +/** + * Type of the middleware that can be passed to `bot.callbackQuery`. + * + * This helper type can be used to annotate middleware functions that are + * defined in one place, so that they have the correct type when passed to + * `bot.callbackQuery` in a different place. For instance, this allows for more + * modular code where handlers are defined in separate files. + */ +export type CallbackQueryMiddleware = Middleware>; +/** + * Type of the middleware that can be passed to `bot.gameQuery`. + * + * This helper type can be used to annotate middleware functions that are + * defined in one place, so that they have the correct type when passed to + * `bot.gameQuery` in a different place. For instance, this allows for more + * modular code where handlers are defined in separate files. + */ +export type GameQueryMiddleware = Middleware>; +/** + * Type of the middleware that can be passed to `bot.inlineQuery`. + * + * This helper type can be used to annotate middleware functions that are + * defined in one place, so that they have the correct type when passed to + * `bot.inlineQuery` in a different place. For instance, this allows for more + * modular code where handlers are defined in separate files. + */ +export type InlineQueryMiddleware = Middleware>; +/** + * Type of the middleware that can be passed to `bot.chosenInlineResult`. + * + * This helper type can be used to annotate middleware functions that are + * defined in one place, so that they have the correct type when passed to + * `bot.chosenInlineResult` in a different place. For instance, this allows for + * more modular code where handlers are defined in separate files. + */ +export type ChosenInlineResultMiddleware = Middleware>; +/** + * Type of the middleware that can be passed to `bot.preCheckoutQuery`. + * + * This helper type can be used to annotate middleware functions that are + * defined in one place, so that they have the correct type when passed to + * `bot.preCheckoutQuery` in a different place. For instance, this allows for + * more modular code where handlers are defined in separate files. + */ +export type PreCheckoutQueryMiddleware = Middleware>; +/** + * Type of the middleware that can be passed to `bot.shippingQuery`. + * + * This helper type can be used to annotate middleware functions that are + * defined in one place, so that they have the correct type when passed to + * `bot.shippingQuery` in a different place. For instance, this allows for more + * modular code where handlers are defined in separate files. + */ +export type ShippingQueryMiddleware = Middleware>; +/** + * Type of the middleware that can be passed to `bot.chatType`. + * + * This helper type can be used to annotate middleware functions that are + * defined in one place, so that they have the correct type when passed to + * `bot.chatType` in a different place. For instance, this allows for more + * modular code where handlers are defined in separate files. + */ +export type ChatTypeMiddleware = Middleware>; +export {}; diff --git a/sandbox/tgbot/node_modules/grammy/out/composer.js b/sandbox/tgbot/node_modules/grammy/out/composer.js new file mode 100644 index 0000000..f5b3e9a --- /dev/null +++ b/sandbox/tgbot/node_modules/grammy/out/composer.js @@ -0,0 +1,704 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Composer = exports.BotError = void 0; +exports.run = run; +const context_js_1 = require("./context.js"); +// === Middleware errors +/** + * This error is thrown when middleware throws. It simply wraps the original + * error (accessible via the `error` property), but also provides access to the + * respective context object that was processed while the error occurred. + */ +class BotError extends Error { + constructor(error, ctx) { + super(generateBotErrorMessage(error)); + this.error = error; + this.ctx = ctx; + this.name = "BotError"; + if (error instanceof Error) + this.stack = error.stack; + } +} +exports.BotError = BotError; +function generateBotErrorMessage(error) { + let msg; + if (error instanceof Error) { + msg = `${error.name} in middleware: ${error.message}`; + } + else { + const type = typeof error; + msg = `Non-error value of type ${type} thrown in middleware`; + switch (type) { + case "bigint": + case "boolean": + case "number": + case "symbol": + msg += `: ${error}`; + break; + case "string": + msg += `: ${String(error).substring(0, 50)}`; + break; + default: + msg += "!"; + break; + } + } + return msg; +} +// === Middleware base functions +function flatten(mw) { + return typeof mw === "function" + ? mw + : (ctx, next) => mw.middleware()(ctx, next); +} +function concat(first, andThen) { + return async (ctx, next) => { + let nextCalled = false; + await first(ctx, async () => { + if (nextCalled) + throw new Error("`next` already called before!"); + else + nextCalled = true; + await andThen(ctx, next); + }); + }; +} +function pass(_ctx, next) { + return next(); +} +const leaf = () => Promise.resolve(); +/** + * Runs some given middleware function with a given context object. + * + * @param middleware The middleware to run + * @param ctx The context to use + */ +async function run(middleware, ctx) { + await middleware(ctx, leaf); +} +// === Composer +/** + * The composer is the heart of the middleware system in grammY. It is also the + * superclass of `Bot`. Whenever you call `use` or `on` or some of the other + * methods on your bot, you are in fact using the underlying composer instance + * to register your middleware. + * + * If you're just getting started, you do not need to worry about what + * middleware is, or about how to use a composer. + * + * On the other hand, if you want to dig deeper into how grammY implements + * middleware, check out the + * [documentation](https://grammy.dev/advanced/middleware) on the website. + */ +class Composer { + /** + * Constructs a new composer based on the provided middleware. If no + * middleware is given, the composer instance will simply make all context + * objects pass through without touching them. + * + * @param middleware The middleware to compose + */ + constructor(...middleware) { + this.handler = middleware.length === 0 + ? pass + : middleware.map(flatten).reduce(concat); + } + middleware() { + return this.handler; + } + /** + * Registers some middleware that receives all updates. It is installed by + * concatenating it to the end of all previously installed middleware. + * + * Often, this method is used to install middleware that behaves like a + * plugin, for example session middleware. + * ```ts + * bot.use(session()) + * ``` + * + * This method returns a new instance of composer. The returned instance can + * be further extended, and all changes will be regarded here. Confer the + * [documentation](https://grammy.dev/advanced/middleware) on the + * website if you want to know more about how the middleware system in + * grammY works, especially when it comes to chaining the method calls + * (`use( ... ).use( ... ).use( ... )`). + * + * @param middleware The middleware to register + */ + use(...middleware) { + const composer = new Composer(...middleware); + this.handler = concat(this.handler, flatten(composer)); + return composer; + } + /** + * Registers some middleware that will only be executed for some specific + * updates, namely those matching the provided filter query. Filter queries + * are a concise way to specify which updates you are interested in. + * + * Here are some examples of valid filter queries: + * ```ts + * // All kinds of message updates + * bot.on('message', ctx => { ... }) + * + * // Only text messages + * bot.on('message:text', ctx => { ... }) + * + * // Only text messages with URL + * bot.on('message:entities:url', ctx => { ... }) + * + * // Text messages and text channel posts + * bot.on(':text', ctx => { ... }) + * + * // Messages with URL in text or caption (i.e. entities or caption entities) + * bot.on('message::url', ctx => { ... }) + * + * // Messages or channel posts with URL in text or caption + * bot.on('::url', ctx => { ... }) + * ``` + * + * You can use autocomplete in VS Code to see all available filter queries. + * Check out the + * [documentation](https://grammy.dev/guide/filter-queries) on the + * website to learn more about filter queries in grammY. + * + * It is possible to pass multiple filter queries in an array, i.e. + * ```ts + * // Matches all text messages and edited text messages that contain a URL + * bot.on(['message:entities:url', 'edited_message:entities:url'], ctx => { ... }) + * ``` + * + * Your middleware will be executed if _any of the provided filter queries_ + * matches (logical OR). + * + * If you instead want to match _all of the provided filter queries_ + * (logical AND), you can chain the `.on` calls: + * ```ts + * // Matches all messages and channel posts that both a) contain a URL and b) are forwards + * bot.on('::url').on(':forward_origin', ctx => { ... }) + * ``` + * + * @param filter The filter query to use, may also be an array of queries + * @param middleware The middleware to register behind the given filter + */ + on(filter, ...middleware) { + return this.filter(context_js_1.Context.has.filterQuery(filter), ...middleware); + } + /** + * Registers some middleware that will only be executed when the message + * contains some text. Is it possible to pass a regular expression to match: + * ```ts + * // Match some text (exact match) + * bot.hears('I love grammY', ctx => ctx.reply('And grammY loves you! <3')) + * // Match a regular expression + * bot.hears(/\/echo (.+)/, ctx => ctx.reply(ctx.match[1])) + * ``` + * Note how `ctx.match` will contain the result of the regular expression. + * Here it is a `RegExpMatchArray` object, so `ctx.match[1]` refers to the + * part of the regex that was matched by `(.+)`, i.e. the text that comes + * after “/echo”. + * + * You can pass an array of triggers. Your middleware will be executed if at + * least one of them matches. + * + * Both text and captions of the received messages will be scanned. For + * example, when a photo is sent to the chat and its caption matches the + * trigger, your middleware will be executed. + * + * If you only want to match text messages and not captions, you can do + * this: + * ```ts + * // Only matches text messages (and channel posts) for the regex + * bot.on(':text').hears(/\/echo (.+)/, ctx => { ... }) + * ``` + * + * @param trigger The text to look for + * @param middleware The middleware to register + */ + hears(trigger, ...middleware) { + return this.filter(context_js_1.Context.has.text(trigger), ...middleware); + } + /** + * Registers some middleware that will only be executed when a certain + * command is found. + * ```ts + * // Reacts to /start commands + * bot.command('start', ctx => { ... }) + * // Reacts to /help commands + * bot.command('help', ctx => { ... }) + * ``` + * + * The rest of the message (excluding the command, and trimmed) is provided + * via `ctx.match`. + * + * > **Did you know?** You can use deep linking + * > (https://core.telegram.org/bots/features#deep-linking) to let users + * > start your bot with a custom payload. As an example, send someone the + * > link https://t.me/name-of-your-bot?start=custom-payload and register a + * > start command handler on your bot with grammY. As soon as the user + * > starts your bot, you will receive `custom-payload` in the `ctx.match` + * > property! + * > ```ts + * > bot.command('start', ctx => { + * > const payload = ctx.match // will be 'custom-payload' + * > }) + * > ``` + * + * Note that commands are not matched in captions or in the middle of the + * text. + * ```ts + * bot.command('start', ctx => { ... }) + * // ... does not match: + * // A message saying: “some text /start some more text” + * // A photo message with the caption “/start” + * ``` + * + * By default, commands are detected in channel posts, too. This means that + * `ctx.message` is potentially `undefined`, so you should use `ctx.msg` + * instead to grab both messages and channel posts. Alternatively, if you + * want to limit your bot to finding commands only in private and group + * chats, you can use `bot.on('message').command('start', ctx => { ... })`, + * or even store a message-only version of your bot in a variable like so: + * ```ts + * const m = bot.on('message') + * + * m.command('start', ctx => { ... }) + * m.command('help', ctx => { ... }) + * // etc + * ``` + * + * If you need more freedom matching your commands, check out the `commands` + * plugin. + * + * @param command The command to look for + * @param middleware The middleware to register + */ + command(command, ...middleware) { + return this.filter(context_js_1.Context.has.command(command), ...middleware); + } + /** + * Registers some middleware that will only be added when a new reaction of + * the given type is added to a message. + * ```ts + * // Reacts to new '👍' reactions + * bot.reaction('👍', ctx => { ... }) + * // Reacts to new '👍' or '👎' reactions + * bot.reaction(['👍', '👎'], ctx => { ... }) + * ``` + * + * > Note that you have to enable `message_reaction` updates in + * `allowed_updates` if you want your bot to receive updates about message + * reactions. + * + * `bot.reaction` will trigger if: + * - a new emoji reaction is added to a message + * - a new custom emoji reaction is added a message + * + * `bot.reaction` will not trigger if: + * - a reaction is removed + * - an anonymous reaction count is updated, such as on channel posts + * - `message_reaction` updates are not enabled for your bot + * + * @param reaction The reaction to look for + * @param middleware The middleware to register + */ + reaction(reaction, ...middleware) { + return this.filter(context_js_1.Context.has.reaction(reaction), ...middleware); + } + /** + * Registers some middleware for certain chat types only. For example, you + * can use this method to only receive updates from private chats. The four + * chat types are `"channel"`, `"supergroup"`, `"group"`, and `"private"`. + * This is especially useful when combined with other filtering logic. For + * example, this is how can you respond to `/start` commands only from + * private chats: + * ```ts + * bot.chatType("private").command("start", ctx => { ... }) + * ``` + * + * Naturally, you can also use this method on its own. + * ```ts + * // Private chats only + * bot.chatType("private", ctx => { ... }); + * // Channels only + * bot.chatType("channel", ctx => { ... }); + * ``` + * + * You can pass an array of chat types if you want your middleware to run + * for any of several provided chat types. + * ```ts + * // Groups and supergroups only + * bot.chatType(["group", "supergroup"], ctx => { ... }); + * ``` + * [Remember](https://grammy.dev/guide/context#shortcuts) also that you + * can access the chat type via `ctx.chat.type`. + * + * @param chatType The chat type + * @param middleware The middleware to register + */ + chatType(chatType, ...middleware) { + return this.filter(context_js_1.Context.has.chatType(chatType), ...middleware); + } + /** + * Registers some middleware for callback queries, i.e. the updates that + * Telegram delivers to your bot when a user clicks an inline button (that + * is a button under a message). + * + * This method is essentially the same as calling + * ```ts + * bot.on('callback_query:data', ctx => { ... }) + * ``` + * but it also allows you to match the query data against a given text or + * regular expression. + * + * ```ts + * // Create an inline keyboard + * const keyboard = new InlineKeyboard().text('Go!', 'button-payload') + * // Send a message with the keyboard + * await bot.api.sendMessage(chat_id, 'Press a button!', { + * reply_markup: keyboard + * }) + * // Listen to users pressing buttons with that specific payload + * bot.callbackQuery('button-payload', ctx => { ... }) + * + * // Listen to users pressing any button your bot ever sent + * bot.on('callback_query:data', ctx => { ... }) + * ``` + * + * Always remember to call `answerCallbackQuery`—even if you don't perform + * any action: https://core.telegram.org/bots/api#answercallbackquery + * ```ts + * bot.on('callback_query:data', async ctx => { + * await ctx.answerCallbackQuery() + * }) + * ``` + * + * You can pass an array of triggers. Your middleware will be executed if at + * least one of them matches. + * + * @param trigger The string to look for in the payload + * @param middleware The middleware to register + */ + callbackQuery(trigger, ...middleware) { + return this.filter(context_js_1.Context.has.callbackQuery(trigger), ...middleware); + } + /** + * Registers some middleware for game queries, i.e. the updates that + * Telegram delivers to your bot when a user clicks an inline button for the + * HTML5 games platform on Telegram. + * + * This method is essentially the same as calling + * ```ts + * bot.on('callback_query:game_short_name', ctx => { ... }) + * ``` + * but it also allows you to match the query data against a given text or + * regular expression. + * + * You can pass an array of triggers. Your middleware will be executed if at + * least one of them matches. + * + * @param trigger The string to look for in the payload + * @param middleware The middleware to register + */ + gameQuery(trigger, ...middleware) { + return this.filter(context_js_1.Context.has.gameQuery(trigger), ...middleware); + } + /** + * Registers middleware for inline queries. Telegram sends an inline query + * to your bot whenever a user types “@your_bot_name ...” into a text field + * in Telegram. You bot will then receive the entered search query and can + * respond with a number of results (text, images, etc) that the user can + * pick from to send a message _via_ your bot to the respective chat. Check + * out https://core.telegram.org/bots/inline to read more about inline bots. + * + * > Note that you have to enable inline mode for you bot by contacting + * > @BotFather first. + * + * ```ts + * // Listen for users typing “@your_bot_name query” + * bot.inlineQuery('query', async ctx => { + * // Answer the inline query, confer https://core.telegram.org/bots/api#answerinlinequery + * await ctx.answerInlineQuery( ... ) + * }) + * ``` + * + * @param trigger The inline query text to match + * @param middleware The middleware to register + */ + inlineQuery(trigger, ...middleware) { + return this.filter(context_js_1.Context.has.inlineQuery(trigger), ...middleware); + } + /** + * Registers middleware for the ChosenInlineResult by the given id or ids. + * ChosenInlineResult represents a result of an inline query that was chosen + * by the user and sent to their chat partner. Check out + * https://core.telegram.org/bots/api#choseninlineresult to read more about + * chosen inline results. + * + * ```ts + * bot.chosenInlineResult('id', async ctx => { + * const id = ctx.result_id; + * // Your code + * }) + * ``` + * + * @param resultId An id or array of ids + * @param middleware The middleware to register + */ + chosenInlineResult(resultId, ...middleware) { + return this.filter(context_js_1.Context.has.chosenInlineResult(resultId), ...middleware); + } + /** + * Registers middleware for pre-checkout queries. Telegram sends a + * pre-checkout query to your bot whenever a user has confirmed their + * payment and shipping details. You bot will then receive all information + * about the order and has to respond within 10 seconds with a confirmation + * of whether everything is alright (goods are available, etc.) and the bot + * is ready to proceed with the order. Check out + * https://core.telegram.org/bots/api#precheckoutquery to read more about + * pre-checkout queries. + * + * ```ts + * bot.preCheckoutQuery('invoice_payload', async ctx => { + * // Answer the pre-checkout query, confer https://core.telegram.org/bots/api#answerprecheckoutquery + * await ctx.answerPreCheckoutQuery( ... ) + * }) + * ``` + * + * @param trigger The string to look for in the invoice payload + * @param middleware The middleware to register + */ + preCheckoutQuery(trigger, ...middleware) { + return this.filter(context_js_1.Context.has.preCheckoutQuery(trigger), ...middleware); + } + /** + * Registers middleware for shipping queries. If you sent an invoice + * requesting a shipping address and the parameter _is_flexible_ was + * specified, Telegram will send a shipping query to your bot whenever a + * user has confirmed their shipping details. You bot will then receive the + * shipping information and can respond with a confirmation of whether + * delivery to the specified address is possible. Check out + * https://core.telegram.org/bots/api#shippingquery to read more about + * shipping queries. + * + * ```ts + * bot.shippingQuery('invoice_payload', async ctx => { + * // Answer the shipping query, confer https://core.telegram.org/bots/api#answershippingquery + * await ctx.answerShippingQuery( ... ) + * }) + * ``` + * + * @param trigger The string to look for in the invoice payload + * @param middleware The middleware to register + */ + shippingQuery(trigger, ...middleware) { + return this.filter(context_js_1.Context.has.shippingQuery(trigger), ...middleware); + } + filter(predicate, ...middleware) { + const composer = new Composer(...middleware); + this.branch(predicate, composer, pass); + return composer; + } + /** + * > This is an advanced method of grammY. + * + * Registers middleware behind a custom filter function that operates on the + * context object and decides whether or not to execute the middleware. In + * other words, the middleware will only be executed if the given predicate + * returns `false` for the given context object. Otherwise, it will be + * skipped and the next middleware will be executed. Note that the predicate + * may be asynchronous, i.e. it can return a Promise of a boolean. + * + * This method is the same using `filter` (normal usage) with a negated + * predicate. + * + * @param predicate The predicate to check + * @param middleware The middleware to register + */ + drop(predicate, ...middleware) { + return this.filter(async (ctx) => !(await predicate(ctx)), ...middleware); + } + /** + * > This is an advanced method of grammY. + * + * Registers some middleware that runs concurrently to the executing + * middleware stack. + * ```ts + * bot.use( ... ) // will run first + * bot.fork( ... ) // will be started second, but run concurrently + * bot.use( ... ) // will also be run second + * ``` + * In the first middleware, as soon as `next`'s Promise resolves, both forks + * have completed. + * + * Both the fork and the downstream middleware are awaited with + * `Promise.all`, so you will only be able to catch at most one error (the + * one that is thrown first). + * + * In contrast to the other middleware methods on composer, `fork` does not + * simply return the composer connected to the main middleware stack. + * Instead, it returns the created composer _of the fork_ connected to the + * middleware stack. This allows for the following pattern. + * ```ts + * // Middleware will be run concurrently! + * bot.fork().on('message', ctx => { ... }) + * ``` + * + * @param middleware The middleware to run concurrently + */ + fork(...middleware) { + const composer = new Composer(...middleware); + const fork = flatten(composer); + this.use((ctx, next) => Promise.all([next(), run(fork, ctx)])); + return composer; + } + /** + * > This is an advanced method of grammY. + * + * Executes some middleware that can be generated on the fly for each + * context. Pass a factory function that creates some middleware (or a + * middleware array even). The factory function will be called once per + * context, and its result will be executed with the context object. + * ```ts + * // The middleware returned by `createMyMiddleware` will be used only once + * bot.lazy(ctx => createMyMiddleware(ctx)) + * ``` + * + * You may generate this middleware in an `async` fashion. + * + * You can decide to return an empty array (`[]`) if you don't want to run + * any middleware for a given context object. This is equivalent to + * returning an empty instance of `Composer`. + * + * @param middlewareFactory The factory function creating the middleware + */ + lazy(middlewareFactory) { + return this.use(async (ctx, next) => { + const middleware = await middlewareFactory(ctx); + const arr = Array.isArray(middleware) ? middleware : [middleware]; + await flatten(new Composer(...arr))(ctx, next); + }); + } + /** + * > This is an advanced method of grammY. + * + * _Not to be confused with the `router` plugin._ + * + * This method is an alternative to the `router` plugin. It allows you to + * branch between different middleware per context object. You can pass two + * things to it: + * 1. A routing function + * 2. Different middleware identified by key + * + * The routing function decides based on the context object which middleware + * to run. Each middleware is identified by a key, so the routing function + * simply returns the key of that middleware. + * ```ts + * // Define different route handlers + * const routeHandlers = { + * evenUpdates: (ctx: Context) => { ... } + * oddUpdates: (ctx: Context) => { ... } + * } + * // Decide for a context object which one to pick + * const router = (ctx: Context) => ctx.update.update_id % 2 === 0 + * ? 'evenUpdates' + * : 'oddUpdates' + * // Route it! + * bot.route(router, routeHandlers) + * ``` + * + * Optionally, you can pass a third option that is used as fallback + * middleware if your route function returns `undefined`, or if the key + * returned by your router has no middleware associated with it. + * + * This method may need less setup than first instantiating a `Router`, but + * for more complex setups, having a `Router` may be more readable. + * + * @param router The routing function to use + * @param routeHandlers Handlers for every route + * @param fallback Optional fallback middleware if no route matches + */ + route(router, routeHandlers, fallback = pass) { + return this.lazy(async (ctx) => { + var _a; + const route = await router(ctx); + return (_a = (route === undefined || !routeHandlers[route] + ? fallback + : routeHandlers[route])) !== null && _a !== void 0 ? _a : []; + }); + } + /** + * > This is an advanced method of grammY. + * + * Allows you to branch between two cases for a given context object. + * + * This method takes a predicate function that is tested once per context + * object. If it returns `true`, the first supplied middleware is executed. + * If it returns `false`, the second supplied middleware is executed. Note + * that the predicate may be asynchronous, i.e. it can return a Promise of a + * boolean. + * + * @param predicate The predicate to check + * @param trueMiddleware The middleware for the `true` case + * @param falseMiddleware The middleware for the `false` case + */ + branch(predicate, trueMiddleware, falseMiddleware) { + return this.lazy(async (ctx) => (await predicate(ctx)) ? trueMiddleware : falseMiddleware); + } + /** + * > This is an advanced function of grammY. + * + * Installs an error boundary that catches errors that happen only inside + * the given middleware. This allows you to install custom error handlers + * that protect some parts of your bot. Errors will not be able to bubble + * out of this part of your middleware system, unless the supplied error + * handler rethrows them, in which case the next surrounding error boundary + * will catch the error. + * + * Example usage: + * ```ts + * function errHandler(err: BotError) { + * console.error('Error boundary caught error!', err) + * } + * + * const safe = + * // All passed middleware will be protected by the error boundary. + * bot.errorBoundary(errHandler, middleware0, middleware1, middleware2) + * + * // Those will also be protected! + * safe.on('message', middleware3) + * + * // No error from `middleware4` will reach the `errHandler` from above, + * // as errors are suppressed. + * + * // do nothing on error (suppress error), and run outside middleware + * const suppress = (_err: BotError, next: NextFunction) => { return next() } + * safe.errorBoundary(suppress).on('edited_message', middleware4) + * ``` + * + * Check out the + * [documentation](https://grammy.dev/guide/errors#error-boundaries) on + * the website to learn more about error boundaries. + * + * @param errorHandler The error handler to use + * @param middleware The middleware to protect + */ + errorBoundary(errorHandler, ...middleware) { + const composer = new Composer(...middleware); + const bound = flatten(composer); + this.use(async (ctx, next) => { + let nextCalled = false; + const cont = () => ((nextCalled = true), Promise.resolve()); + try { + await bound(ctx, cont); + } + catch (err) { + nextCalled = false; + await errorHandler(new BotError(err, ctx), cont); + } + if (nextCalled) + await next(); + }); + return composer; + } +} +exports.Composer = Composer; diff --git a/sandbox/tgbot/node_modules/grammy/out/context.d.ts b/sandbox/tgbot/node_modules/grammy/out/context.d.ts new file mode 100644 index 0000000..42602a6 --- /dev/null +++ b/sandbox/tgbot/node_modules/grammy/out/context.d.ts @@ -0,0 +1,1878 @@ +import { type Api, type Other as OtherApi } from "./core/api.js"; +import { type Methods, type RawApi } from "./core/client.js"; +import { type Filter, type FilterCore, type FilterQuery } from "./filter.js"; +import { type AcceptedGiftTypes, type Chat, type ChatPermissions, type InlineQueryResult, type InputChecklist, type InputFile, type InputMedia, type InputMediaAudio, type InputMediaDocument, type InputMediaPhoto, type InputMediaVideo, type InputPaidMedia, type InputPollOption, type InputProfilePhoto, type InputStoryContent, type LabeledPrice, type Message, type MessageEntity, type PassportElementError, type ReactionType, type ReactionTypeEmoji, type Update, type User, type UserFromGetMe } from "./types.js"; +export type MaybeArray = T | T[]; +/** permits `string` but gives hints */ +export type StringWithCommandSuggestions = (string & Record) | "start" | "help" | "settings" | "privacy" | "developer_info"; +type Other, X extends string = never> = OtherApi; +type SnakeToCamelCase = S extends `${infer L}_${infer R}` ? `${L}${Capitalize>}` : S; +type AliasProps = { + [K in string & keyof U as SnakeToCamelCase]: U[K]; +}; +type RenamedUpdate = AliasProps>; +interface StaticHas { + /** + * Generates a predicate function that can test context objects for matching + * the given filter query. This uses the same logic as `bot.on`. + * + * @param filter The filter query to check + */ + filterQuery(filter: Q | Q[]): (ctx: C) => ctx is Filter; + /** + * Generates a predicate function that can test context objects for + * containing the given text, or for the text to match the given regular + * expression. This uses the same logic as `bot.hears`. + * + * @param trigger The string or regex to match + */ + text(trigger: MaybeArray): (ctx: C) => ctx is HearsContext; + /** + * Generates a predicate function that can test context objects for + * containing a command. This uses the same logic as `bot.command`. + * + * @param command The command to match + */ + command(command: MaybeArray): (ctx: C) => ctx is CommandContext; + /** + * Generates a predicate function that can test context objects for + * containing a message reaction update. This uses the same logic as + * `bot.reaction`. + * + * @param reaction The reaction to test against + */ + reaction(reaction: MaybeArray): (ctx: C) => ctx is ReactionContext; + /** + * Generates a predicate function that can test context objects for + * belonging to a chat with the given chat type. This uses the same logic as + * `bot.chatType`. + * + * @param chatType The chat type to match + */ + chatType(chatType: MaybeArray): (ctx: C) => ctx is ChatTypeContext; + /** + * Generates a predicate function that can test context objects for + * containing the given callback query, or for the callback query data to + * match the given regular expression. This uses the same logic as + * `bot.callbackQuery`. + * + * @param trigger The string or regex to match + */ + callbackQuery(trigger: MaybeArray): (ctx: C) => ctx is CallbackQueryContext; + /** + * Generates a predicate function that can test context objects for + * containing the given game query, or for the game name to match the given + * regular expression. This uses the same logic as `bot.gameQuery`. + * + * @param trigger The string or regex to match + */ + gameQuery(trigger: MaybeArray): (ctx: C) => ctx is GameQueryContext; + /** + * Generates a predicate function that can test context objects for + * containing the given inline query, or for the inline query to match the + * given regular expression. This uses the same logic as `bot.inlineQuery`. + * + * @param trigger The string or regex to match + */ + inlineQuery(trigger: MaybeArray): (ctx: C) => ctx is InlineQueryContext; + /** + * Generates a predicate function that can test context objects for + * containing the chosen inline result, or for the chosen inline result to + * match the given regular expression. + * + * @param trigger The string or regex to match + */ + chosenInlineResult(trigger: MaybeArray): (ctx: C) => ctx is ChosenInlineResultContext; + /** + * Generates a predicate function that can test context objects for + * containing the given pre-checkout query, or for the pre-checkout query + * payload to match the given regular expression. This uses the same logic + * as `bot.preCheckoutQuery`. + * + * @param trigger The string or regex to match + */ + preCheckoutQuery(trigger: MaybeArray): (ctx: C) => ctx is PreCheckoutQueryContext; + /** + * Generates a predicate function that can test context objects for + * containing the given shipping query, or for the shipping query to match + * the given regular expression. This uses the same logic as + * `bot.shippingQuery`. + * + * @param trigger The string or regex to match + */ + shippingQuery(trigger: MaybeArray): (ctx: C) => ctx is ShippingQueryContext; +} +/** + * When your bot receives a message, Telegram sends an update object to your + * bot. The update contains information about the chat, the user, and of course + * the message itself. There are numerous other updates, too: + * https://core.telegram.org/bots/api#update + * + * When grammY receives an update, it wraps this update into a context object + * for you. Context objects are commonly named `ctx`. A context object does two + * things: + * 1. **`ctx.update`** holds the update object that you can use to process the + * message. This includes providing useful shortcuts for the update, for + * instance, `ctx.msg` is a shortcut that gives you the message object from + * the update—no matter whether it is contained in `ctx.update.message`, or + * `ctx.update.edited_message`, or `ctx.update.channel_post`, or + * `ctx.update.edited_channel_post`. + * 2. **`ctx.api`** gives you access to the full Telegram Bot API so that you + * can directly call any method, such as responding via + * `ctx.api.sendMessage`. Also here, the context objects has some useful + * shortcuts for you. For instance, if you want to send a message to the same + * chat that a message comes from (i.e. just respond to a user) you can call + * `ctx.reply`. This is nothing but a wrapper for `ctx.api.sendMessage` with + * the right `chat_id` pre-filled for you. Almost all methods of the Telegram + * Bot API have their own shortcut directly on the context object, so you + * probably never really have to use `ctx.api` at all. + * + * This context object is then passed to all of the listeners (called + * middleware) that you register on your bot. Because this is so useful, the + * context object is often used to hold more information. One example are + * sessions (a chat-specific data storage that is stored in a database), and + * another example is `ctx.match` that is used by `bot.command` and other + * methods to keep information about how a regular expression was matched. + * + * Read up about middleware on the + * [website](https://grammy.dev/guide/context) if you want to know more + * about the powerful opportunities that lie in context objects, and about how + * grammY implements them. + */ +export declare class Context implements RenamedUpdate { + /** + * The update object that is contained in the context. + */ + readonly update: Update; + /** + * An API instance that allows you to call any method of the Telegram + * Bot API. + */ + readonly api: Api; + /** + * Information about the bot itself. + */ + readonly me: UserFromGetMe; + /** + * Used by some middleware to store information about how a certain string + * or regular expression was matched. + */ + match: string | RegExpMatchArray | undefined; + constructor( + /** + * The update object that is contained in the context. + */ + update: Update, + /** + * An API instance that allows you to call any method of the Telegram + * Bot API. + */ + api: Api, + /** + * Information about the bot itself. + */ + me: UserFromGetMe); + /** Alias for `ctx.update.message` */ + get message(): (Message & Update.NonChannel) | undefined; + /** Alias for `ctx.update.edited_message` */ + get editedMessage(): (Message & Update.Edited & Update.NonChannel) | undefined; + /** Alias for `ctx.update.channel_post` */ + get channelPost(): (Message & Update.Channel) | undefined; + /** Alias for `ctx.update.edited_channel_post` */ + get editedChannelPost(): (Message & Update.Edited & Update.Channel) | undefined; + /** Alias for `ctx.update.business_connection` */ + get businessConnection(): import("@grammyjs/types/manage.js").BusinessConnection | undefined; + /** Alias for `ctx.update.business_message` */ + get businessMessage(): (Message & Update.Private) | undefined; + /** Alias for `ctx.update.edited_business_message` */ + get editedBusinessMessage(): (Message & Update.Edited & Update.Private) | undefined; + /** Alias for `ctx.update.deleted_business_messages` */ + get deletedBusinessMessages(): import("@grammyjs/types/manage.js").BusinessMessagesDeleted | undefined; + /** Alias for `ctx.update.message_reaction` */ + get messageReaction(): import("@grammyjs/types/message.js").MessageReactionUpdated | undefined; + /** Alias for `ctx.update.message_reaction_count` */ + get messageReactionCount(): import("@grammyjs/types/message.js").MessageReactionCountUpdated | undefined; + /** Alias for `ctx.update.inline_query` */ + get inlineQuery(): import("@grammyjs/types/inline.js").InlineQuery | undefined; + /** Alias for `ctx.update.chosen_inline_result` */ + get chosenInlineResult(): import("@grammyjs/types/inline.js").ChosenInlineResult | undefined; + /** Alias for `ctx.update.callback_query` */ + get callbackQuery(): import("@grammyjs/types/markup.js").CallbackQuery | undefined; + /** Alias for `ctx.update.shipping_query` */ + get shippingQuery(): import("@grammyjs/types/payment.js").ShippingQuery | undefined; + /** Alias for `ctx.update.pre_checkout_query` */ + get preCheckoutQuery(): import("@grammyjs/types/payment.js").PreCheckoutQuery | undefined; + /** Alias for `ctx.update.poll` */ + get poll(): import("@grammyjs/types/message.js").Poll | undefined; + /** Alias for `ctx.update.poll_answer` */ + get pollAnswer(): import("@grammyjs/types/message.js").PollAnswer | undefined; + /** Alias for `ctx.update.my_chat_member` */ + get myChatMember(): import("@grammyjs/types/manage.js").ChatMemberUpdated | undefined; + /** Alias for `ctx.update.chat_member` */ + get chatMember(): import("@grammyjs/types/manage.js").ChatMemberUpdated | undefined; + /** Alias for `ctx.update.chat_join_request` */ + get chatJoinRequest(): import("@grammyjs/types/manage.js").ChatJoinRequest | undefined; + /** Alias for `ctx.update.chat_boost` */ + get chatBoost(): import("@grammyjs/types/manage.js").ChatBoostUpdated | undefined; + /** Alias for `ctx.update.removed_chat_boost` */ + get removedChatBoost(): import("@grammyjs/types/manage.js").ChatBoostRemoved | undefined; + /** Alias for `ctx.update.purchased_paid_media` */ + get purchasedPaidMedia(): import("@grammyjs/types/payment.js").PaidMediaPurchased | undefined; + /** + * Get the message object from wherever possible. Alias for `this.message ?? + * this.editedMessage ?? this.channelPost ?? this.editedChannelPost ?? + * this.businessMessage ?? this.editedBusinessMessage ?? + * this.callbackQuery?.message`. + */ + get msg(): Message | undefined; + /** + * Get the chat object from wherever possible. Alias for `(this.msg ?? + * this.deletedBusinessMessages ?? this.messageReaction ?? + * this.messageReactionCount ?? this.myChatMember ?? this.chatMember ?? + * this.chatJoinRequest ?? this.chatBoost ?? this.removedChatBoost)?.chat`. + */ + get chat(): Chat | undefined; + /** + * Get the sender chat object from wherever possible. Alias for + * `ctx.msg?.sender_chat`. + */ + get senderChat(): Chat | undefined; + /** + * Get the user object from wherever possible. Alias for + * `(this.businessConnection ?? this.messageReaction ?? + * (this.chatBoost?.boost ?? this.removedChatBoost)?.source)?.user ?? + * (this.callbackQuery ?? this.msg ?? this.inlineQuery ?? + * this.chosenInlineResult ?? this.shippingQuery ?? this.preCheckoutQuery ?? + * this.myChatMember ?? this.chatMember ?? this.chatJoinRequest ?? + * this.purchasedPaidMedia)?.from`. + */ + get from(): User | undefined; + /** + * Get the message identifier from wherever possible. Alias for + * `this.msg?.message_id ?? this.messageReaction?.message_id ?? + * this.messageReactionCount?.message_id`. + */ + get msgId(): number | undefined; + /** + * Gets the chat identifier from wherever possible. Alias for `this.chat?.id + * ?? this.businessConnection?.user_chat_id`. + */ + get chatId(): number | undefined; + /** + * Get the inline message identifier from wherever possible. Alias for + * `(ctx.callbackQuery ?? ctx.chosenInlineResult)?.inline_message_id`. + */ + get inlineMessageId(): string | undefined; + /** + * Get the business connection identifier from wherever possible. Alias for + * `this.msg?.business_connection_id ?? this.businessConnection?.id ?? + * this.deletedBusinessMessages?.business_connection_id`. + */ + get businessConnectionId(): string | undefined; + /** + * Get entities and their text. Extracts the text from `ctx.msg.text` or + * `ctx.msg.caption`. Returns an empty array if one of `ctx.msg`, + * `ctx.msg.text` or `ctx.msg.entities` is undefined. + * + * You can filter specific entity types by passing the `types` parameter. + * Example: + * + * ```ts + * ctx.entities() // Returns all entity types + * ctx.entities('url') // Returns only url entities + * ctx.entities(['url', 'email']) // Returns url and email entities + * ``` + * + * @param types Types of entities to return. Omit to get all entities. + * @returns Array of entities and their texts, or empty array when there's no text + */ + entities(): Array; + entities(types: MaybeArray): Array; + /** + * Find out which reactions were added and removed in a `message_reaction` + * update. This method looks at `ctx.messageReaction` and computes the + * difference between the old reaction and the new reaction. It also groups + * the reactions by emoji reactions and custom emoji reactions. For example, + * the resulting object could look like this: + * ```ts + * { + * emoji: ['👍', '🎉'] + * emojiAdded: ['🎉'], + * emojiKept: ['👍'], + * emojiRemoved: [], + * customEmoji: [], + * customEmojiAdded: [], + * customEmojiKept: [], + * customEmojiRemoved: ['id0123'], + * paid: true, + * paidAdded: false, + * paidRemoved: false, + * } + * ``` + * In the above example, a tada reaction was added by the user, and a custom + * emoji reaction with the custom emoji 'id0123' was removed in the same + * update. The user had already reacted with a thumbs up reaction and a paid + * star reaction, which they left both unchanged. As a result, the current + * reaction by the user is thumbs up, tada, and a paid reaction. Note that + * the current reaction (all emoji reactions regardless of type in one list) + * can also be obtained from `ctx.messageReaction.new_reaction`. + * + * Remember that reaction updates only include information about the + * reaction of a specific user. The respective message may have many more + * reactions by other people which will not be included in this update. + * + * @returns An object containing information about the reaction update + */ + reactions(): { + /** Emoji currently present in this user's reaction */ + emoji: ReactionTypeEmoji["emoji"][]; + /** Emoji newly added to this user's reaction */ + emojiAdded: ReactionTypeEmoji["emoji"][]; + /** Emoji not changed by the update to this user's reaction */ + emojiKept: ReactionTypeEmoji["emoji"][]; + /** Emoji removed from this user's reaction */ + emojiRemoved: ReactionTypeEmoji["emoji"][]; + /** Custom emoji currently present in this user's reaction */ + customEmoji: string[]; + /** Custom emoji newly added to this user's reaction */ + customEmojiAdded: string[]; + /** Custom emoji not changed by the update to this user's reaction */ + customEmojiKept: string[]; + /** Custom emoji removed from this user's reaction */ + customEmojiRemoved: string[]; + /** + * `true` if a paid reaction is currently present in this user's + * reaction, and `false` otherwise + */ + paid: boolean; + /** + * `true` if a paid reaction was newly added to this user's reaction, + * and `false` otherwise + */ + paidAdded: boolean; + }; + /** + * `Context.has` is an object that contains a number of useful functions for + * probing context objects. Each of these functions can generate a predicate + * function, to which you can pass context objects in order to check if a + * condition holds for the respective context object. + * + * For example, you can call `Context.has.filterQuery(":text")` to generate + * a predicate function that tests context objects for containing text: + * ```ts + * const hasText = Context.has.filterQuery(":text"); + * + * if (hasText(ctx0)) {} // `ctx0` matches the filter query `:text` + * if (hasText(ctx1)) {} // `ctx1` matches the filter query `:text` + * if (hasText(ctx2)) {} // `ctx2` matches the filter query `:text` + * ``` + * These predicate functions are used internally by the has-methods that are + * installed on every context object. This means that calling + * `ctx.has(":text")` is equivalent to + * `Context.has.filterQuery(":text")(ctx)`. + */ + static has: StaticHas; + /** + * Returns `true` if this context object matches the given filter query, and + * `false` otherwise. This uses the same logic as `bot.on`. + * + * @param filter The filter query to check + */ + has(filter: Q | Q[]): this is FilterCore; + /** + * Returns `true` if this context object contains the given text, or if it + * contains text that matches the given regular expression. It returns + * `false` otherwise. This uses the same logic as `bot.hears`. + * + * @param trigger The string or regex to match + */ + hasText(trigger: MaybeArray): this is HearsContextCore; + /** + * Returns `true` if this context object contains the given command, and + * `false` otherwise. This uses the same logic as `bot.command`. + * + * @param command The command to match + */ + hasCommand(command: MaybeArray): this is CommandContextCore; + hasReaction(reaction: MaybeArray): this is ReactionContextCore; + /** + * Returns `true` if this context object belongs to a chat with the given + * chat type, and `false` otherwise. This uses the same logic as + * `bot.chatType`. + * + * @param chatType The chat type to match + */ + hasChatType(chatType: MaybeArray): this is ChatTypeContextCore; + /** + * Returns `true` if this context object contains the given callback query, + * or if the contained callback query data matches the given regular + * expression. It returns `false` otherwise. This uses the same logic as + * `bot.callbackQuery`. + * + * @param trigger The string or regex to match + */ + hasCallbackQuery(trigger: MaybeArray): this is CallbackQueryContextCore; + /** + * Returns `true` if this context object contains the given game query, or + * if the contained game query matches the given regular expression. It + * returns `false` otherwise. This uses the same logic as `bot.gameQuery`. + * + * @param trigger The string or regex to match + */ + hasGameQuery(trigger: MaybeArray): this is GameQueryContextCore; + /** + * Returns `true` if this context object contains the given inline query, or + * if the contained inline query matches the given regular expression. It + * returns `false` otherwise. This uses the same logic as `bot.inlineQuery`. + * + * @param trigger The string or regex to match + */ + hasInlineQuery(trigger: MaybeArray): this is InlineQueryContextCore; + /** + * Returns `true` if this context object contains the chosen inline result, + * or if the contained chosen inline result matches the given regular + * expression. It returns `false` otherwise. This uses the same logic as + * `bot.chosenInlineResult`. + * + * @param trigger The string or regex to match + */ + hasChosenInlineResult(trigger: MaybeArray): this is ChosenInlineResultContextCore; + /** + * Returns `true` if this context object contains the given pre-checkout + * query, or if the contained pre-checkout query matches the given regular + * expression. It returns `false` otherwise. This uses the same logic as + * `bot.preCheckoutQuery`. + * + * @param trigger The string or regex to match + */ + hasPreCheckoutQuery(trigger: MaybeArray): this is PreCheckoutQueryContextCore; + /** + * Returns `true` if this context object contains the given shipping query, + * or if the contained shipping query matches the given regular expression. + * It returns `false` otherwise. This uses the same logic as + * `bot.shippingQuery`. + * + * @param trigger The string or regex to match + */ + hasShippingQuery(trigger: MaybeArray): this is ShippingQueryContextCore; + /** + * Context-aware alias for `api.sendMessage`. Use this method to send text messages. On success, the sent Message is returned. + * + * @param text Text of the message to be sent, 1-4096 characters after entities parsing + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendmessage + */ + reply(text: string, other?: Other<"sendMessage", "chat_id" | "text">, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.sendMessageDraft`. Use this method to stream a partial message to a user while the message is being generated; supported only for bots with forum topic mode enabled. Returns True on success. + * + * @param text Text of the message to be sent, 1-4096 characters after entities parsing + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendmessagedraft + */ + replyWithDraft(text: string, other?: Other<"sendMessageDraft", "chat_id" | "text">, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.forwardMessage`. Use this method to forward messages of any kind. Service messages and messages with protected content can't be forwarded. On success, the sent Message is returned. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#forwardmessage + */ + forwardMessage(chat_id: number | string, other?: Other<"forwardMessage", "chat_id" | "from_chat_id" | "message_id">, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.forwardMessages`. Use this method to forward multiple messages of any kind. If some of the specified messages can't be found or forwarded, they are skipped. Service messages and messages with protected content can't be forwarded. Album grouping is kept for forwarded messages. On success, an array of MessageId of the sent messages is returned. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param message_ids A list of 1-100 identifiers of messages in the current chat to forward. The identifiers must be specified in a strictly increasing order. + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#forwardmessages + */ + forwardMessages(chat_id: number | string, message_ids: number[], other?: Other<"forwardMessages", "chat_id" | "from_chat_id" | "message_ids">, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.copyMessage`. Use this method to copy messages of any kind. Service messages, paid media messages, giveaway messages, giveaway winners messages, and invoice messages can't be copied. A quiz poll can be copied only if the value of the field correct_option_id is known to the bot. The method is analogous to the method forwardMessage, but the copied message doesn't have a link to the original message. Returns the MessageId of the sent message on success. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#copymessage + */ + copyMessage(chat_id: number | string, other?: Other<"copyMessage", "chat_id" | "from_chat_id" | "message_id">, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.copyMessages`. Use this method to copy messages of any kind. If some of the specified messages can't be found or copied, they are skipped. Service messages, paid media messages, giveaway messages, giveaway winners messages, and invoice messages can't be copied. A quiz poll can be copied only if the value of the field correct_option_id is known to the bot. The method is analogous to the method forwardMessages, but the copied messages don't have a link to the original message. Album grouping is kept for copied messages. On success, an array of MessageId of the sent messages is returned. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param message_ids A list of 1-100 identifiers of messages in the current chat to copy. The identifiers must be specified in a strictly increasing order. + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#copymessages + */ + copyMessages(chat_id: number | string, message_ids: number[], other?: Other<"copyMessages", "chat_id" | "from_chat_id" | "message_ids">, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.sendPhoto`. Use this method to send photos. On success, the sent Message is returned. + * + * @param photo Photo to send. Pass a file_id as String to send a photo that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a photo from the Internet, or upload a new photo using multipart/form-data. The photo must be at most 10 MB in size. The photo's width and height must not exceed 10000 in total. Width and height ratio must be at most 20. + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendphoto + */ + replyWithPhoto(photo: InputFile | string, other?: Other<"sendPhoto", "chat_id" | "photo">, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.sendAudio`. Use this method to send audio files, if you want Telegram clients to display them in the music player. Your audio must be in the .MP3 or .M4A format. On success, the sent Message is returned. Bots can currently send audio files of up to 50 MB in size, this limit may be changed in the future. + * + * For sending voice messages, use the sendVoice method instead. + * + * @param audio Audio file to send. Pass a file_id as String to send an audio file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get an audio file from the Internet, or upload a new one using multipart/form-data. + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendaudio + */ + replyWithAudio(audio: InputFile | string, other?: Other<"sendAudio", "chat_id" | "audio">, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.sendDocument`. Use this method to send general files. On success, the sent Message is returned. Bots can currently send files of any type of up to 50 MB in size, this limit may be changed in the future. + * + * @param document File to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#senddocument + */ + replyWithDocument(document: InputFile | string, other?: Other<"sendDocument", "chat_id" | "document">, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.sendVideo`. Use this method to send video files, Telegram clients support mp4 videos (other formats may be sent as Document). On success, the sent Message is returned. Bots can currently send video files of up to 50 MB in size, this limit may be changed in the future. + * + * @param video Video to send. Pass a file_id as String to send a video that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a video from the Internet, or upload a new video using multipart/form-data. + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendvideo + */ + replyWithVideo(video: InputFile | string, other?: Other<"sendVideo", "chat_id" | "video">, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.sendAnimation`. Use this method to send animation files (GIF or H.264/MPEG-4 AVC video without sound). On success, the sent Message is returned. Bots can currently send animation files of up to 50 MB in size, this limit may be changed in the future. + * + * @param animation Animation to send. Pass a file_id as String to send an animation that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get an animation from the Internet, or upload a new animation using multipart/form-data. + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendanimation + */ + replyWithAnimation(animation: InputFile | string, other?: Other<"sendAnimation", "chat_id" | "animation">, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.sendVoice`. Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message. For this to work, your audio must be in an .OGG file encoded with OPUS (other formats may be sent as Audio or Document). On success, the sent Message is returned. Bots can currently send voice messages of up to 50 MB in size, this limit may be changed in the future. + * + * @param voice Audio file to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendvoice + */ + replyWithVoice(voice: InputFile | string, other?: Other<"sendVoice", "chat_id" | "voice">, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.sendVideoNote`. Use this method to send video messages. On success, the sent Message is returned. + * As of v.4.0, Telegram clients support rounded square mp4 videos of up to 1 minute long. + * + * @param video_note Video note to send. Pass a file_id as String to send a video note that exists on the Telegram servers (recommended) or upload a new video using multipart/form-data.. Sending video notes by a URL is currently unsupported + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendvideonote + */ + replyWithVideoNote(video_note: InputFile | string, other?: Other<"sendVideoNote", "chat_id" | "video_note">, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.sendMediaGroup`. Use this method to send a group of photos, videos, documents or audios as an album. Documents and audio files can be only grouped in an album with messages of the same type. On success, an array of Messages that were sent is returned. + * + * @param media An array describing messages to be sent, must include 2-10 items + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendmediagroup + */ + replyWithMediaGroup(media: ReadonlyArray, other?: Other<"sendMediaGroup", "chat_id" | "media">, signal?: AbortSignal): Promise<(Message.PhotoMessage | Message.AudioMessage | Message.DocumentMessage | Message.VideoMessage)[]>; + /** + * Context-aware alias for `api.sendLocation`. Use this method to send point on the map. On success, the sent Message is returned. + * + * @param latitude Latitude of the location + * @param longitude Longitude of the location + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendlocation + */ + replyWithLocation(latitude: number, longitude: number, other?: Other<"sendLocation", "chat_id" | "latitude" | "longitude">, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.editMessageLiveLocation`. Use this method to edit live location messages. A location can be edited until its live_period expires or editing is explicitly disabled by a call to stopMessageLiveLocation. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. + * + * @param latitude Latitude of new location + * @param longitude Longitude of new location + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#editmessagelivelocation + */ + editMessageLiveLocation(latitude: number, longitude: number, other?: Other<"editMessageLiveLocation", "chat_id" | "message_id" | "inline_message_id" | "latitude" | "longitude">, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.stopMessageLiveLocation`. Use this method to stop updating a live location message before live_period expires. On success, if the message is not an inline message, the edited Message is returned, otherwise True is returned. + * + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#stopmessagelivelocation + */ + stopMessageLiveLocation(other?: Other<"stopMessageLiveLocation", "chat_id" | "message_id" | "inline_message_id">, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.sendPaidMedia`. Use this method to send paid media. On success, the sent Message is returned. + * + * @param star_count The number of Telegram Stars that must be paid to buy access to the media + * @param media An array describing the media to be sent; up to 10 items + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendpaidmedia + */ + sendPaidMedia(star_count: number, media: InputPaidMedia[], other?: Other<"sendPaidMedia", "chat_id" | "star_count" | "media">, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.sendVenue`. Use this method to send information about a venue. On success, the sent Message is returned. + * + * @param latitude Latitude of the venue + * @param longitude Longitude of the venue + * @param title Name of the venue + * @param address Address of the venue + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendvenue + */ + replyWithVenue(latitude: number, longitude: number, title: string, address: string, other?: Other<"sendVenue", "chat_id" | "latitude" | "longitude" | "title" | "address">, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.sendContact`. Use this method to send phone contacts. On success, the sent Message is returned. + * + * @param phone_number Contact's phone number + * @param first_name Contact's first name + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendcontact + */ + replyWithContact(phone_number: string, first_name: string, other?: Other<"sendContact", "chat_id" | "phone_number" | "first_name">, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.sendPoll`. Use this method to send a native poll. On success, the sent Message is returned. + * + * @param question Poll question, 1-300 characters + * @param options A list of answer options, 2-12 strings 1-100 characters each + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendpoll + */ + replyWithPoll(question: string, options: (string | InputPollOption)[], other?: Other<"sendPoll", "chat_id" | "question" | "options">, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.sendChecklist`. Use this method to send a checklist on behalf of a connected business account. On success, the sent Message is returned. + * + * @param checklist An object for the checklist to send + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendchecklist + */ + replyWithChecklist(checklist: InputChecklist, other?: Other<"sendChecklist", "business_connection_id" | "chat_id" | "checklist">, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.editMessageChecklist`. Use this method to edit a checklist on behalf of a connected business account. On success, the edited Message is returned. + * + * @param checklist An object for the new checklist + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#editmessagechecklist + */ + editMessageChecklist(checklist: InputChecklist, other?: Other<"editMessageChecklist", "business_connection_id" | "chat_id" | "messaage_id" | "checklist">, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.sendDice`. Use this method to send an animated emoji that will display a random value. On success, the sent Message is returned. + * + * @param emoji Emoji on which the dice throw animation is based. Currently, must be one of “🎲”, “🎯”, “🏀”, “⚽”, “🎳”, or “🎰”. Dice can have values 1-6 for “🎲”, “🎯” and “🎳”, values 1-5 for “🏀” and “⚽”, and values 1-64 for “🎰”. Defaults to “🎲” + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#senddice + */ + replyWithDice(emoji: (string & Record) | "🎲" | "🎯" | "🏀" | "⚽" | "🎳" | "🎰", other?: Other<"sendDice", "chat_id" | "emoji">, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.sendChatAction`. Use this method when you need to tell the user that something is happening on the bot's side. The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status). Returns True on success. + * + * Example: The ImageBot needs some time to process a request and upload the image. Instead of sending a text message along the lines of “Retrieving image, please wait…”, the bot may use sendChatAction with action = upload_photo. The user will see a “sending photo” status for the bot. + * + * We only recommend using this method when a response from the bot will take a noticeable amount of time to arrive. + * + * @param action Type of action to broadcast. Choose one, depending on what the user is about to receive: typing for text messages, upload_photo for photos, record_video or upload_video for videos, record_voice or upload_voice for voice notes, upload_document for general files, choose_sticker for stickers, find_location for location data, record_video_note or upload_video_note for video notes. + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendchataction + */ + replyWithChatAction(action: "typing" | "upload_photo" | "record_video" | "upload_video" | "record_voice" | "upload_voice" | "upload_document" | "choose_sticker" | "find_location" | "record_video_note" | "upload_video_note", other?: Other<"sendChatAction", "chat_id" | "action">, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.setMessageReaction`. Use this method to change the chosen reactions on a message. Service messages of some types can't be reacted to. Automatically forwarded messages from a channel to its discussion group have the same available reactions as messages in the channel. Bots can't use paid reactions. Returns True on success. + * + * @param reaction A list of reaction types to set on the message. Currently, as non-premium users, bots can set up to one reaction per message. A custom emoji reaction can be used if it is either already present on the message or explicitly allowed by chat administrators. Paid reactions can't be used by bots. + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setmessagereaction + */ + react(reaction: MaybeArray, other?: Other<"setMessageReaction", "chat_id" | "message_id" | "reaction">, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.getUserProfilePhotos`. Use this method to get a list of profile pictures for a user. Returns a UserProfilePhotos object. + * + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getuserprofilephotos + */ + getUserProfilePhotos(other?: Other<"getUserProfilePhotos", "user_id">, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.getUserProfileAudios`. Use this method to get a list of profile audios for a user. Returns a UserProfileAudios object. + * + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getuserprofileaudios + */ + getUserProfileAudios(other?: Other<"getUserProfileAudios", "user_id">, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.serUserEmojiStatus`. Changes the emoji status for a given user that previously allowed the bot to manage their emoji status via the Mini App method requestEmojiStatusAccess. Returns True on success. + * + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setuseremojistatus + */ + setUserEmojiStatus(other?: Other<"setUserEmojiStatus", "user_id">, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.getUserChatBoosts`. Use this method to get the list of boosts added to a chat by a user. Requires administrator rights in the chat. Returns a UserChatBoosts object. + * + * @param chat_id Unique identifier for the chat or username of the channel (in the format @channelusername) + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getuserchatboosts + */ + getUserChatBoosts(chat_id?: number | string, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.getUserGifts`. Returns the gifts owned and hosted by a user. Returns OwnedGifts on success. + * + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getusergifts + */ + getUserGifts(other?: Other<"getUserGifts", "user_id">, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.getChatGifts`. Returns the gifts owned by a chat. Returns OwnedGifts on success. + * + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getchatgifts + */ + getChatGifts(other?: Other<"getChatGifts", "chat_id">, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.getBusinessConnection`. Use this method to get information about the connection of the bot with a business account. Returns a BusinessConnection object on success. + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getbusinessconnection + */ + getBusinessConnection(signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.getFile`. Use this method to get basic info about a file and prepare it for downloading. For the moment, bots can download files of up to 20MB in size. On success, a File object is returned. The file can then be downloaded via the link https://api.telegram.org/file/bot/, where is taken from the response. It is guaranteed that the link will be valid for at least 1 hour. When the link expires, a new one can be requested by calling getFile again. + * + * Note: This function may not preserve the original file name and MIME type. You should save the file's MIME type and name (if available) when the File object is received. + * + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getfile + */ + getFile(signal?: AbortSignal): Promise; + /** @deprecated Use `banAuthor` instead. */ + kickAuthor(...args: Parameters): Promise; + /** + * Context-aware alias for `api.banChatMember`. Use this method to ban a user in a group, a supergroup or a channel. In the case of supergroups and channels, the user will not be able to return to the chat on their own using invite links, etc., unless unbanned first. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success. + * + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#banchatmember + */ + banAuthor(other?: Other<"banChatMember", "chat_id" | "user_id">, signal?: AbortSignal): Promise; + /** @deprecated Use `banChatMember` instead. */ + kickChatMember(...args: Parameters): Promise; + /** + * Context-aware alias for `api.banChatMember`. Use this method to ban a user in a group, a supergroup or a channel. In the case of supergroups and channels, the user will not be able to return to the chat on their own using invite links, etc., unless unbanned first. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success. + * + * @param user_id Unique identifier of the target user + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#banchatmember + */ + banChatMember(user_id: number, other?: Other<"banChatMember", "chat_id" | "user_id">, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.unbanChatMember`. Use this method to unban a previously banned user in a supergroup or channel. The user will not return to the group or channel automatically, but will be able to join via link, etc. The bot must be an administrator for this to work. By default, this method guarantees that after the call the user is not a member of the chat, but will be able to join it. So if the user is a member of the chat they will also be removed from the chat. If you don't want this, use the parameter only_if_banned. Returns True on success. + * + * @param user_id Unique identifier of the target user + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#unbanchatmember + */ + unbanChatMember(user_id: number, other?: Other<"unbanChatMember", "chat_id" | "user_id">, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.restrictChatMember`. Use this method to restrict a user in a supergroup. The bot must be an administrator in the supergroup for this to work and must have the appropriate administrator rights. Pass True for all permissions to lift restrictions from a user. Returns True on success. + * + * @param permissions An object for new user permissions + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#restrictchatmember + */ + restrictAuthor(permissions: ChatPermissions, other?: Other<"restrictChatMember", "chat_id" | "user_id" | "permissions">, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.restrictChatMember`. Use this method to restrict a user in a supergroup. The bot must be an administrator in the supergroup for this to work and must have the appropriate administrator rights. Pass True for all permissions to lift restrictions from a user. Returns True on success. + * + * @param user_id Unique identifier of the target user + * @param permissions An object for new user permissions + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#restrictchatmember + */ + restrictChatMember(user_id: number, permissions: ChatPermissions, other?: Other<"restrictChatMember", "chat_id" | "user_id" | "permissions">, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.promoteChatMember`. Use this method to promote or demote a user in a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Pass False for all boolean parameters to demote a user. Returns True on success. + * + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#promotechatmember + */ + promoteAuthor(other?: Other<"promoteChatMember", "chat_id" | "user_id">, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.promoteChatMember`. Use this method to promote or demote a user in a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Pass False for all boolean parameters to demote a user. Returns True on success. + * + * @param user_id Unique identifier of the target user + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#promotechatmember + */ + promoteChatMember(user_id: number, other?: Other<"promoteChatMember", "chat_id" | "user_id">, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.setChatAdministratorCustomTitle`. Use this method to set a custom title for an administrator in a supergroup promoted by the bot. Returns True on success. + * + * @param custom_title New custom title for the administrator; 0-16 characters, emoji are not allowed + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setchatadministratorcustomtitle + */ + setChatAdministratorAuthorCustomTitle(custom_title: string, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.setChatAdministratorCustomTitle`. Use this method to set a custom title for an administrator in a supergroup promoted by the bot. Returns True on success. + * + * @param user_id Unique identifier of the target user + * @param custom_title New custom title for the administrator; 0-16 characters, emoji are not allowed + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setchatadministratorcustomtitle + */ + setChatAdministratorCustomTitle(user_id: number, custom_title: string, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.banChatSenderChat`. Use this method to ban a channel chat in a supergroup or a channel. Until the chat is unbanned, the owner of the banned chat won't be able to send messages on behalf of any of their channels. The bot must be an administrator in the supergroup or channel for this to work and must have the appropriate administrator rights. Returns True on success. + * + * @param sender_chat_id Unique identifier of the target sender chat + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#banchatsenderchat + */ + banChatSenderChat(sender_chat_id: number, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.unbanChatSenderChat`. Use this method to unban a previously banned channel chat in a supergroup or channel. The bot must be an administrator for this to work and must have the appropriate administrator rights. Returns True on success. + * + * @param sender_chat_id Unique identifier of the target sender chat + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#unbanchatsenderchat + */ + unbanChatSenderChat(sender_chat_id: number, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.setChatPermissions`. Use this method to set default chat permissions for all members. The bot must be an administrator in the group or a supergroup for this to work and must have the can_restrict_members administrator rights. Returns True on success. + * + * @param permissions New default chat permissions + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setchatpermissions + */ + setChatPermissions(permissions: ChatPermissions, other?: Other<"setChatPermissions", "chat_id" | "permissions">, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.exportChatInviteLink`. Use this method to generate a new primary invite link for a chat; any previously generated primary link is revoked. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the new invite link as String on success. + * + * Note: Each administrator in a chat generates their own invite links. Bots can't use invite links generated by other administrators. If you want your bot to work with invite links, it will need to generate its own link using exportChatInviteLink or by calling the getChat method. If your bot needs to generate a new primary invite link replacing its previous one, use exportChatInviteLink again. + * + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#exportchatinvitelink + */ + exportChatInviteLink(signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.createChatInviteLink`. Use this method to create an additional invite link for a chat. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. The link can be revoked using the method revokeChatInviteLink. Returns the new invite link as ChatInviteLink object. + * + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#createchatinvitelink + */ + createChatInviteLink(other?: Other<"createChatInviteLink", "chat_id">, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.editChatInviteLink`. Use this method to edit a non-primary invite link created by the bot. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the edited invite link as a ChatInviteLink object. + * + * @param invite_link The invite link to edit + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#editchatinvitelink + */ + editChatInviteLink(invite_link: string, other?: Other<"editChatInviteLink", "chat_id" | "invite_link">, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.createChatSubscriptionInviteLink`. Use this method to create a subscription invite link for a channel chat. The bot must have the can_invite_users administrator rights. The link can be edited using the method editChatSubscriptionInviteLink or revoked using the method revokeChatInviteLink. Returns the new invite link as a ChatInviteLink object. + * + * @param subscription_period The number of seconds the subscription will be active for before the next payment. Currently, it must always be 2592000 (30 days). + * @param subscription_price The amount of Telegram Stars a user must pay initially and after each subsequent subscription period to be a member of the chat; 1-2500 + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#createchatsubscriptioninvitelink + */ + createChatSubscriptionInviteLink(subscription_period: number, subscription_price: number, other?: Other<"createChatSubscriptionInviteLink", "chat_id" | "subscription_period" | "subscription_price">, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.editChatSubscriptionInviteLink`. Use this method to edit a subscription invite link created by the bot. The bot must have the can_invite_users administrator rights. Returns the edited invite link as a ChatInviteLink object. + * + * @param invite_link The invite link to edit + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#editchatsubscriptioninvitelink + */ + editChatSubscriptionInviteLink(invite_link: string, other?: Other<"editChatSubscriptionInviteLink", "chat_id" | "invite_link">, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.revokeChatInviteLink`. Use this method to revoke an invite link created by the bot. If the primary link is revoked, a new link is automatically generated. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the revoked invite link as ChatInviteLink object. + * + * @param invite_link The invite link to revoke + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#revokechatinvitelink + */ + revokeChatInviteLink(invite_link: string, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.approveChatJoinRequest`. Use this method to approve a chat join request. The bot must be an administrator in the chat for this to work and must have the can_invite_users administrator right. Returns True on success. + * + * @param user_id Unique identifier of the target user + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#approvechatjoinrequest + */ + approveChatJoinRequest(user_id: number, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.declineChatJoinRequest`. Use this method to decline a chat join request. The bot must be an administrator in the chat for this to work and must have the can_invite_users administrator right. Returns True on success. + * + * @param user_id Unique identifier of the target user + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#declinechatjoinrequest + */ + declineChatJoinRequest(user_id: number, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.approveSuggestedPost`. Use this method to approve a suggested post in a direct messages chat. The bot must have the 'can_post_messages' administrator right in the corresponding channel chat. Returns True on success. + * + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#approvesuggestedpost + */ + approveSuggestedPost(other?: Other<"approveSuggestedPost", "chat_id" | "message_id">, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.declineSuggestedPost`. Use this method to decline a suggested post in a direct messages chat. The bot must have the 'can_manage_direct_messages' administrator right in the corresponding channel chat. Returns True on success. + * + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#declinesuggestedpost + */ + declineSuggestedPost(other?: Other<"declineSuggestedPost", "chat_id" | "message_id">, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.setChatPhoto`. Use this method to set a new profile photo for the chat. Photos can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success. + * + * @param photo New chat photo, uploaded using multipart/form-data + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setchatphoto + */ + setChatPhoto(photo: InputFile, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.deleteChatPhoto`. Use this method to delete a chat photo. Photos can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success. + * + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#deletechatphoto + */ + deleteChatPhoto(signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.setChatTitle`. Use this method to change the title of a chat. Titles can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success. + * + * @param title New chat title, 1-255 characters + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setchattitle + */ + setChatTitle(title: string, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.setChatDescription`. Use this method to change the description of a group, a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success. + * + * @param description New chat description, 0-255 characters + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setchatdescription + */ + setChatDescription(description: string | undefined, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.pinChatMessage`. Use this method to add a message to the list of pinned messages in a chat. In private chats and channel direct messages chats, all non-service messages can be pinned. Conversely, the bot must be an administrator with the 'can_pin_messages' right or the 'can_edit_messages' right to pin messages in groups and channels respectively. Returns True on success. + * + * @param message_id Identifier of a message to pin + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#pinchatmessage + */ + pinChatMessage(message_id: number, other?: Other<"pinChatMessage", "chat_id" | "message_id">, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.unpinChatMessage`. Use this method to remove a message from the list of pinned messages in a chat. In private chats and channel direct messages chats, all messages can be unpinned. Conversely, the bot must be an administrator with the 'can_pin_messages' right or the 'can_edit_messages' right to unpin messages in groups and channels respectively. Returns True on success. + * + * @param message_id Identifier of a message to unpin. If not specified, the most recent pinned message (by sending date) will be unpinned. + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#unpinchatmessage + */ + unpinChatMessage(message_id?: number, other?: Other<"unpinChatMessage", "chat_id" | "message_id">, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.unpinAllChatMessages`. Use this method to clear the list of pinned messages in a chat. In private chats and channel direct messages chats, no additional rights are required to unpin all pinned messages. Conversely, the bot must be an administrator with the 'can_pin_messages' right or the 'can_edit_messages' right to unpin all pinned messages in groups and channels respectively. Returns True on success. + * + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#unpinallchatmessages + */ + unpinAllChatMessages(signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.leaveChat`. Use this method for your bot to leave a group, supergroup or channel. Returns True on success. + * + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#leavechat + */ + leaveChat(signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.getChat`. Use this method to get up to date information about the chat (current name of the user for one-on-one conversations, current username of a user, group or channel, etc.). Returns a Chat object on success. + * + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getchat + */ + getChat(signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.getChatAdministrators`. Use this method to get a list of administrators in a chat, which aren't bots. Returns an Array of ChatMember objects. + * + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getchatadministrators + */ + getChatAdministrators(signal?: AbortSignal): Promise<(import("@grammyjs/types/manage.js").ChatMemberOwner | import("@grammyjs/types/manage.js").ChatMemberAdministrator)[]>; + /** @deprecated Use `getChatMemberCount` instead. */ + getChatMembersCount(...args: Parameters): Promise; + /** + * Context-aware alias for `api.getChatMemberCount`. Use this method to get the number of members in a chat. Returns Int on success. + * + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getchatmembercount + */ + getChatMemberCount(signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.getChatMember`. Use this method to get information about a member of a chat. The method is guaranteed to work only if the bot is an administrator in the chat. Returns a ChatMember object on success. + * + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getchatmember + */ + getAuthor(signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.getChatMember`. Use this method to get information about a member of a chat. The method is guaranteed to work only if the bot is an administrator in the chat. Returns a ChatMember object on success. + * + * @param user_id Unique identifier of the target user + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getchatmember + */ + getChatMember(user_id: number, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.setChatStickerSet`. Use this method to set a new group sticker set for a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Use the field can_set_sticker_set ly returned in getChat requests to check if the bot can use this method. Returns True on success. + * + * @param sticker_set_name Name of the sticker set to be set as the group sticker set + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setchatstickerset + */ + setChatStickerSet(sticker_set_name: string, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.deleteChatStickerSet`. Use this method to delete a group sticker set from a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Use the field can_set_sticker_set ly returned in getChat requests to check if the bot can use this method. Returns True on success. + * + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#deletechatstickerset + */ + deleteChatStickerSet(signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.createForumTopic`. Use this method to create a topic in a forum supergroup chat or a private chat with a user. In the case of a supergroup chat the bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator right. Returns information about the created topic as a ForumTopic object. + * + * @param name Topic name, 1-128 characters + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#createforumtopic + */ + createForumTopic(name: string, other?: Other<"createForumTopic", "chat_id" | "name">, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.editForumTopic`. Use this method to edit name and icon of a topic in a forum supergroup chat or a private chat with a user. In the case of a supergroup chat the bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights, unless it is the creator of the topic. Returns True on success. + * + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#editforumtopic + */ + editForumTopic(other?: Other<"editForumTopic", "chat_id" | "message_thread_id">, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.closeForumTopic`. Use this method to close an open topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights, unless it is the creator of the topic. Returns True on success. + * + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#closeforumtopic + */ + closeForumTopic(signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.reopenForumTopic`. Use this method to reopen a closed topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights, unless it is the creator of the topic. Returns True on success. + * + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#reopenforumtopic + */ + reopenForumTopic(signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.deleteForumTopic`. Use this method to delete a forum topic along with all its messages in a forum supergroup chat or a private chat with a user. In the case of a supergroup chat the bot must be an administrator in the chat for this to work and must have the can_delete_messages administrator rights. Returns True on success. + * + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#deleteforumtopic + */ + deleteForumTopic(signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.unpinAllForumTopicMessages`. Use this method to clear the list of pinned messages in a forum topic in a forum supergroup chat or a private chat with a user. In the case of a supergroup chat the bot must be an administrator in the chat for this to work and must have the can_pin_messages administrator right in the supergroup. Returns True on success. + * + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#unpinallforumtopicmessages + */ + unpinAllForumTopicMessages(signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.editGeneralForumTopic`. Use this method to edit the name of the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. Returns True on success. + * + * @param name New topic name, 1-128 characters + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#editgeneralforumtopic + */ + editGeneralForumTopic(name: string, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.closeGeneralForumTopic`. Use this method to close an open 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. Returns True on success. + * + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#closegeneralforumtopic + */ + closeGeneralForumTopic(signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.reopenGeneralForumTopic`. Use this method to reopen a closed 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. The topic will be automatically unhidden if it was hidden. Returns True on success. * + * + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#reopengeneralforumtopic + */ + reopenGeneralForumTopic(signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.hideGeneralForumTopic`. Use this method to hide the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. The topic will be automatically closed if it was open. Returns True on success. + * + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#hidegeneralforumtopic + */ + hideGeneralForumTopic(signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.unhideGeneralForumTopic`. Use this method to unhide the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. Returns True on success. + * + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#unhidegeneralforumtopic + */ + unhideGeneralForumTopic(signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.unpinAllGeneralForumTopicMessages`. Use this method to clear the list of pinned messages in a General forum topic. The bot must be an administrator in the chat for this to work and must have the can_pin_messages administrator right in the supergroup. Returns True on success. + * + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#unpinallgeneralforumtopicmessages + */ + unpinAllGeneralForumTopicMessages(signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.answerCallbackQuery`. Use this method to send answers to callback queries sent from inline keyboards. The answer will be displayed to the user as a notification at the top of the chat screen or as an alert. On success, True is returned. + * + * Alternatively, the user can be redirected to the specified Game URL. For this option to work, you must first create a game for your bot via @BotFather and accept the terms. Otherwise, you may use links like t.me/your_bot?start=XXXX that open your bot with a parameter. + * + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#answercallbackquery + */ + answerCallbackQuery(other?: string | Other<"answerCallbackQuery", "callback_query_id">, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.setChatMenuButton`. Use this method to change the bot's menu button in a private chat, or the default menu button. Returns True on success. + * + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setchatmenubutton + */ + setChatMenuButton(other?: Other<"setChatMenuButton">, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.getChatMenuButton`. Use this method to get the current value of the bot's menu button in a private chat, or the default menu button. Returns MenuButton on success. + * + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getchatmenubutton + */ + getChatMenuButton(other?: Other<"getChatMenuButton">, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.setMyDefaultAdministratorRights`. Use this method to the change the default administrator rights requested by the bot when it's added as an administrator to groups or channels. These rights will be suggested to users, but they are are free to modify the list before adding the bot. Returns True on success. + * + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setmydefaultadministratorrights + */ + setMyDefaultAdministratorRights(other?: Other<"setMyDefaultAdministratorRights">, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.getMyDefaultAdministratorRights`. Use this method to get the current default administrator rights of the bot. Returns ChatAdministratorRights on success. + * + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + */ + getMyDefaultAdministratorRights(other?: Other<"getMyDefaultAdministratorRights">, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.editMessageText`. Use this method to edit text and game messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent. + * + * @param text New text of the message, 1-4096 characters after entities parsing + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#editmessagetext + */ + editMessageText(text: string, other?: Other<"editMessageText", "chat_id" | "message_id" | "inline_message_id" | "text">, signal?: AbortSignal): Promise)>; + /** + * Context-aware alias for `api.editMessageCaption`. Use this method to edit captions of messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent. + * + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#editmessagecaption + */ + editMessageCaption(other?: Other<"editMessageCaption", "chat_id" | "message_id" | "inline_message_id">, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.editMessageMedia`. Use this method to edit animation, audio, document, photo, or video messages, or to add media to text messages. If a message is part of a message album, then it can be edited only to an audio for audio albums, only to a document for document albums and to a photo or a video otherwise. When an inline message is edited, a new file can't be uploaded; use a previously uploaded file via its file_id or specify a URL. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent. + * + * @param media An object for a new media content of the message + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#editmessagemedia + */ + editMessageMedia(media: InputMedia, other?: Other<"editMessageMedia", "chat_id" | "message_id" | "inline_message_id" | "media">, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.editMessageReplyMarkup`. Use this method to edit only the reply markup of messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent. + * + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#editmessagereplymarkup + */ + editMessageReplyMarkup(other?: Other<"editMessageReplyMarkup", "chat_id" | "message_id" | "inline_message_id">, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.stopPoll`. Use this method to stop a poll which was sent by the bot. On success, the stopped Poll is returned. + * + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#stoppoll + */ + stopPoll(other?: Other<"stopPoll", "chat_id" | "message_id">, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.deleteMessage`. Use this method to delete a message, including service messages, with the following limitations: + * - A message can only be deleted if it was sent less than 48 hours ago. + * - A dice message in a private chat can only be deleted if it was sent more than 24 hours ago. + * - Bots can delete outgoing messages in private chats, groups, and supergroups. + * - Bots can delete incoming messages in private chats. + * - Bots granted can_post_messages permissions can delete outgoing messages in channels. + * - If the bot is an administrator of a group, it can delete any message there. + * - If the bot has can_delete_messages administrator right in a supergroup or a channel, it can delete any message there. + * - If the bot has can_manage_direct_messages administrator right in a channel, it can delete any message in the corresponding direct messages chat. + * Returns True on success. + * + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#deletemessage + */ + deleteMessage(signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.deleteMessages`. Use this method to delete multiple messages simultaneously. Returns True on success. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param message_ids A list of 1-100 identifiers of messages to delete. See deleteMessage for limitations on which messages can be deleted + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#deletemessages + */ + deleteMessages(message_ids: number[], signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.deleteBusinessMessages`. Delete messages on behalf of a business account. Requires the can_delete_outgoing_messages business bot right to delete messages sent by the bot itself, or the can_delete_all_messages business bot right to delete any message. Returns True on success. + * + * @param message_ids A list of 1-100 identifiers of messages to delete. All messages must be from the same chat. See deleteMessage for limitations on which messages can be deleted + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#deletebusinessmessages + */ + deleteBusinessMessages(message_ids: number[], signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.setBusinessAccountName`. Changes the first and last name of a managed business account. Requires the can_change_name business bot right. Returns True on success. + * + * @param first_name The new value of the first name for the business account; 1-64 characters + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setbusinessaccountname + */ + setBusinessAccountName(first_name: string, other: Other<"setBusinessAccountName", "business_connection_id" | "first_name">, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.setBusinessAccountUsername`. Changes the username of a managed business account. Requires the can_change_username business bot right. Returns True on success. + * + * @param username The new value of the username for the business account; 0-32 characters + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setbusinessaccountusername + */ + setBusinessAccountUsername(username: string, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.setBusinessAccountBio`. Changes the bio of a managed business account. Requires the can_change_bio business bot right. Returns True on success. + * + * @param bio The new value of the bio for the business account; 0-140 characters + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setbusinessaccountbio + */ + setBusinessAccountBio(bio: string, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.setBusinessAccountProfilePhoto`. CsetBusinessAccountProfilePhotohanges the profile photo of a managed business account. Requires the can_edit_profile_photo business bot right. Returns True on success. + * + * @param photo The new profile photo to set + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setbusinessaccountprofilephoto + */ + setBusinessAccountProfilePhoto(photo: InputProfilePhoto, other: Other<"setBusinessAccountProfilePhoto", "business_connection_id" | "photo">, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.removeBusinessAccountProfilePhoto`. Removes the current profile photo of a managed business account. Requires the can_edit_profile_photo business bot right. Returns True on success. + * + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#removebusinessaccountprofilephoto + */ + removeBusinessAccountProfilePhoto(other: Other<"removeBusinessAccountProfilePhoto", "business_connection_id">, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.setBusinessAccountGiftSettings`. Changes the privacy settings pertaining to incoming gifts in a managed business account. Requires the can_change_gift_settings business bot right. Returns True on success. + * + * @param show_gift_button Pass True, if a button for sending a gift to the user or by the business account must always be shown in the input field + * @param accepted_gift_types Types of gifts accepted by the business account + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setbusinessaccountgiftsettings + */ + setBusinessAccountGiftSettings(show_gift_button: boolean, accepted_gift_types: AcceptedGiftTypes, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.getBusinessAccountStarBalance`. Returns the amount of Telegram Stars owned by a managed business account. Requires the can_view_gifts_and_stars business bot right. Returns StarAmount on success. + * + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getbusinessaccountstarbalance + */ + getBusinessAccountStarBalance(signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.transferBusinessAccountStars`. Transfers Telegram Stars from the business account balance to the bot's balance. Requires the can_transfer_stars business bot right. Returns True on success. + * + * @param star_count Number of Telegram Stars to transfer; 1-10000 + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#transferbusinessaccountstars + */ + transferBusinessAccountStars(star_count: number, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.getBusinessAccountGifts`. Returns the gifts received and owned by a managed business account. Requires the can_view_gifts_and_stars business bot right. Returns OwnedGifts on success. + * + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getbusinessaccountgifts + */ + getBusinessAccountGifts(other: Other<"getBusinessAccountGifts", "business_connection_id">, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.convertGiftToStars`. Converts a given regular gift to Telegram Stars. Requires the can_convert_gifts_to_stars business bot right. Returns True on success. + * + * @param owned_gift_id Unique identifier of the regular gift that should be converted to Telegram Stars + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#convertgifttostars + */ + convertGiftToStars(owned_gift_id: string, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.upgradeGift`. Upgrades a given regular gift to a unique gift. Requires the can_transfer_and_upgrade_gifts business bot right. Additionally requires the can_transfer_stars business bot right if the upgrade is paid. Returns True on success. + * + * @param owned_gift_id Unique identifier of the regular gift that should be upgraded to a unique one + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#upgradegift + */ + upgradeGift(owned_gift_id: string, other: Other<"getBusinessAccountGifts", "business_connection_id" | "owned_gift_id">, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.transferGift`. Transfers an owned unique gift to another user. Requires the can_transfer_and_upgrade_gifts business bot right. Requires can_transfer_stars business bot right if the transfer is paid. Returns True on success. + * + * @param owned_gift_id Unique identifier of the regular gift that should be transferred + * @param new_owner_chat_id Unique identifier of the chat which will own the gift. The chat must be active in the last 24 hours. + * @param star_count The amount of Telegram Stars that will be paid for the transfer from the business account balance. If positive, then the can_transfer_stars business bot right is required. + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#transfergift + */ + transferGift(owned_gift_id: string, new_owner_chat_id: number, star_count: number, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.postStory`. Posts a story on behalf of a managed business account. Requires the can_manage_stories business bot right. Returns Story on success. + * + * @param content Content of the story + * @param active_period Period after which the story is moved to the archive, in seconds; must be one of 6 * 3600, 12 * 3600, 86400, or 2 * 86400 + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#poststory + */ + postStory(content: InputStoryContent, active_period: number, other: Other<"postStory", "business_connection_id" | "content" | "active_period">, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.repostStory`. Reposts a story on behalf of a business account from another business account. Both business accounts must be managed by the same bot, and the story on the source account must have been posted (or reposted) by the bot. Requires the can_manage_stories business bot right for both business accounts. Returns Story on success. + * + * @param active_period Period after which the story is moved to the archive, in seconds; must be one of 6 * 3600, 12 * 3600, 86400, or 2 * 86400 + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#repoststory + */ + repostStory(active_period: number, other: Other<"repostStory", "business_connection_id" | "from_chat_id" | "from_story_id" | "active_period">, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.editStory`. Edits a story previously posted by the bot on behalf of a managed business account. Requires the can_manage_stories business bot right. Returns Story on success. + * + * @param story_id Unique identifier of the story to edit + * @param content Content of the story + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#editstory + */ + editStory(story_id: number, content: InputStoryContent, other: Other<"editStory", "business_connection_id" | "story_id" | "content">, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.deleteStory`. Deletes a story previously posted by the bot on behalf of a managed business account. Requires the can_manage_stories business bot right. Returns True on success. + * + * @param story_id Unique identifier of the story to delete + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#deletestory + */ + deleteStory(story_id: number, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.sendSticker`. Use this method to send static .WEBP, animated .TGS, or video .WEBM stickers. On success, the sent Message is returned. + * + * @param sticker Sticker to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a .WEBP sticker from the Internet, or upload a new .WEBP, .TGS, or .WEBM sticker using multipart/form-data. Video and animated stickers can't be sent via an HTTP URL. + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendsticker + */ + replyWithSticker(sticker: InputFile | string, other?: Other<"sendSticker", "chat_id" | "sticker">, signal?: AbortSignal): Promise; + /** + * Use this method to get information about custom emoji stickers by their identifiers. Returns an Array of Sticker objects. + * + * @param custom_emoji_ids A list of custom emoji identifiers + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getcustomemojistickers + */ + getCustomEmojiStickers(signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.sendGift`. Sends a gift to the given user. The gift can't be converted to Telegram Stars by the receiver. Returns True on success. + * + * @param gift_id Identifier of the gift + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendgift + */ + replyWithGift(gift_id: string, other?: Other<"sendGift", "user_id" | "chat_id" | "gift_id">, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.giftPremiumSubscription`. Gifts a Telegram Premium subscription to the given user. Returns True on success. + * + * @param month_count Number of months the Telegram Premium subscription will be active for the user; must be one of 3, 6, or 12 + * @param star_count Number of Telegram Stars to pay for the Telegram Premium subscription; must be 1000 for 3 months, 1500 for 6 months, and 2500 for 12 months + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#giftpremiumsubscription + */ + giftPremiumSubscription(month_count: 3 | 6 | 12, star_count: 1000 | 1500 | 2500, other?: Other<"giftPremiumSubscription", "user_id" | "month_count" | "star_count">, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.sendGift`. Sends a gift to the given channel chat. The gift can't be converted to Telegram Stars by the receiver. Returns True on success. + * + * @param gift_id Identifier of the gift + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendgift + */ + replyWithGiftToChannel(gift_id: string, other?: Other<"sendGift", "user_id" | "chat_id" | "gift_id">, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.answerInlineQuery`. Use this method to send answers to an inline query. On success, True is returned. + * No more than 50 results per query are allowed. + * + * Example: An inline bot that sends YouTube videos can ask the user to connect the bot to their YouTube account to adapt search results accordingly. To do this, it displays a 'Connect your YouTube account' button above the results, or even before showing any. The user presses the button, switches to a private chat with the bot and, in doing so, passes a start parameter that instructs the bot to return an OAuth link. Once done, the bot can offer a switch_inline button so that the user can easily return to the chat where they wanted to use the bot's inline capabilities. + * + * @param results An array of results for the inline query + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#answerinlinequery + */ + answerInlineQuery(results: readonly InlineQueryResult[], other?: Other<"answerInlineQuery", "inline_query_id" | "results">, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.savePreparedInlineMessage`. Stores a message that can be sent by a user of a Mini App. Returns a PreparedInlineMessage object. + * + * @param result An object describing the message to be sent + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#savepreparedinlinemessage + */ + savePreparedInlineMessage(result: InlineQueryResult, other?: Other<"savePreparedInlineMessage", "user_id" | "result">, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.sendInvoice`. Use this method to send invoices. On success, the sent Message is returned. + * + * @param title Product name, 1-32 characters + * @param description Product description, 1-255 characters + * @param payload Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes. + * @param currency Three-letter ISO 4217 currency code, see more on currencies + * @param prices Price breakdown, a list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.) + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendinvoice + */ + replyWithInvoice(title: string, description: string, payload: string, currency: string, prices: readonly LabeledPrice[], other?: Other<"sendInvoice", "chat_id" | "title" | "description" | "payload" | "currency" | "prices">, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.answerShippingQuery`. If you sent an invoice requesting a shipping address and the parameter is_flexible was specified, the Bot API will send an Update with a shipping_query field to the bot. Use this method to reply to shipping queries. On success, True is returned. + * + * @param shipping_query_id Unique identifier for the query to be answered + * @param ok Pass True if delivery to the specified address is possible and False if there are any problems (for example, if delivery to the specified address is not possible) + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#answershippingquery + */ + answerShippingQuery(ok: boolean, other?: Other<"answerShippingQuery", "shipping_query_id" | "ok">, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.answerPreCheckoutQuery`. Once the user has confirmed their payment and shipping details, the Bot API sends the final confirmation in the form of an Update with the field pre_checkout_query. Use this method to respond to such pre-checkout queries. On success, True is returned. Note: The Bot API must receive an answer within 10 seconds after the pre-checkout query was sent. + * + * @param ok Specify True if everything is alright (goods are available, etc.) and the bot is ready to proceed with the order. Use False if there are any problems. + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#answerprecheckoutquery + */ + answerPreCheckoutQuery(ok: boolean, other?: string | Other<"answerPreCheckoutQuery", "pre_checkout_query_id" | "ok">, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.refundStarPayment`. Refunds a successful payment in Telegram Stars. + * + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#refundstarpayment + */ + refundStarPayment(signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.editUserStarSubscription`. Allows the bot to cancel or re-enable extension of a subscription paid in Telegram Stars. Returns True on success. + * + * @param telegram_payment_charge_id Telegram payment identifier for the subscription + * @param is_canceled Pass True to cancel extension of the user subscription; the subscription must be active up to the end of the current subscription period. Pass False to allow the user to re-enable a subscription that was previously canceled by the bot. + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#edituserstarsubscription + */ + editUserStarSubscription(telegram_payment_charge_id: string, is_canceled: boolean, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.verifyUser`. Verifies a user on behalf of the organization which is represented by the bot. Returns True on success. + * + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#verifyuser + */ + verifyUser(other?: Other<"verifyUser">, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.verifyChat`. Verifies a chat on behalf of the organization which is represented by the bot. Returns True on success. + * + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#verifychat + */ + verifyChat(other?: Other<"verifyChat">, signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.removeUserVerification`. Removes verification from a user who is currently verified on behalf of the organization represented by the bot. Returns True on success. + * + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#removeuserverification + */ + removeUserVerification(signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.removeChatVerification`. Removes verification from a chat that is currently verified on behalf of the organization represented by the bot. Returns True on success. + * + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#removechatverification + */ + removeChatVerification(signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.readBusinessMessage`. Marks incoming message as read on behalf of a business account. Requires the can_read_messages business bot right. Returns True on success. + * + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#readbusinessmessage + */ + readBusinessMessage(signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.setPassportDataErrors`. Informs a user that some of the Telegram Passport elements they provided contains errors. The user will not be able to re-submit their Passport to you until the errors are fixed (the contents of the field for which you returned the error must change). Returns True on success. + * + * Use this if the data submitted by the user doesn't satisfy the standards your service requires for any reason. For example, if a birthday date seems invalid, a submitted document is blurry, a scan shows evidence of tampering, etc. Supply some details in the error message to make sure the user knows how to correct the issues. + * + * @param errors An array describing the errors + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setpassportdataerrors + */ + setPassportDataErrors(errors: readonly PassportElementError[], signal?: AbortSignal): Promise; + /** + * Context-aware alias for `api.sendGame`. Use this method to send a game. On success, the sent Message is returned. + * + * @param game_short_name Short name of the game, serves as the unique identifier for the game. Set up your games via BotFather. + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendgame + */ + replyWithGame(game_short_name: string, other?: Other<"sendGame", "chat_id" | "game_short_name">, signal?: AbortSignal): Promise; +} +type HearsContextCore = FilterCore<":text" | ":caption"> & NarrowMatchCore; +/** + * Type of the context object that is available inside the handlers for + * `bot.hears`. + * + * This helper type can be used to narrow down context objects the same way how + * `bot.hears` does it. This allows you to annotate context objects in + * middleware that is not directly passed to `bot.hears`, hence not inferring + * the correct type automatically. That way, handlers can be defined in separate + * files and still have the correct types. + */ +export type HearsContext = Filter, ":text" | ":caption">; +type CommandContextCore = FilterCore<":entities:bot_command"> & NarrowMatchCore; +/** + * Type of the context object that is available inside the handlers for + * `bot.command`. + * + * This helper type can be used to narrow down context objects the same way how + * `bot.command` does it. This allows you to annotate context objects in + * middleware that is not directly passed to `bot.command`, hence not inferring + * the correct type automatically. That way, handlers can be defined in separate + * files and still have the correct types. + */ +export type CommandContext = Filter, ":entities:bot_command">; +type NarrowMatchCore = { + match: T; +}; +type NarrowMatch = { + [K in keyof C]: K extends "match" ? (T extends C[K] ? T : never) : C[K]; +}; +type CallbackQueryContextCore = FilterCore<"callback_query:data">; +/** + * Type of the context object that is available inside the handlers for + * `bot.callbackQuery`. + * + * This helper type can be used to annotate narrow down context objects the same + * way `bot.callbackQuery` does it. This allows you to how context objects in + * middleware that is not directly passed to `bot.callbackQuery`, hence not + * inferring the correct type automatically. That way, handlers can be defined + * in separate files and still have the correct types. + */ +export type CallbackQueryContext = Filter, "callback_query:data">; +type GameQueryContextCore = FilterCore<"callback_query:game_short_name">; +/** + * Type of the context object that is available inside the handlers for + * `bot.gameQuery`. + * + * This helper type can be used to narrow down context objects the same way how + * `bot.gameQuery` does it. This allows you to annotate context objects in + * middleware that is not directly passed to `bot.gameQuery`, hence not + * inferring the correct type automatically. That way, handlers can be defined + * in separate files and still have the correct types. + */ +export type GameQueryContext = Filter, "callback_query:game_short_name">; +type InlineQueryContextCore = FilterCore<"inline_query">; +/** + * Type of the context object that is available inside the handlers for + * `bot.inlineQuery`. + * + * This helper type can be used to narrow down context objects the same way how + * annotate `bot.inlineQuery` does it. This allows you to context objects in + * middleware that is not directly passed to `bot.inlineQuery`, hence not + * inferring the correct type automatically. That way, handlers can be defined + * in separate files and still have the correct types. + */ +export type InlineQueryContext = Filter, "inline_query">; +type ReactionContextCore = FilterCore<"message_reaction">; +/** + * Type of the context object that is available inside the handlers for + * `bot.reaction`. + * + * This helper type can be used to narrow down context objects the same way how + * annotate `bot.reaction` does it. This allows you to context objects in + * middleware that is not directly passed to `bot.reaction`, hence not inferring + * the correct type automatically. That way, handlers can be defined in separate + * files and still have the correct types. + */ +export type ReactionContext = Filter; +type ChosenInlineResultContextCore = FilterCore<"chosen_inline_result">; +/** + * Type of the context object that is available inside the handlers for + * `bot.chosenInlineResult`. + * + * This helper type can be used to narrow down context objects the same way how + * annotate `bot.chosenInlineResult` does it. This allows you to context objects in + * middleware that is not directly passed to `bot.chosenInlineResult`, hence not + * inferring the correct type automatically. That way, handlers can be defined + * in separate files and still have the correct types. + */ +export type ChosenInlineResultContext = Filter, "chosen_inline_result">; +type PreCheckoutQueryContextCore = FilterCore<"pre_checkout_query">; +/** + * Type of the context object that is available inside the handlers for + * `bot.preCheckoutQuery`. + * + * This helper type can be used to narrow down context objects the same way how + * annotate `bot.preCheckoutQuery` does it. This allows you to context objects in + * middleware that is not directly passed to `bot.preCheckoutQuery`, hence not + * inferring the correct type automatically. That way, handlers can be defined + * in separate files and still have the correct types. + */ +export type PreCheckoutQueryContext = Filter, "pre_checkout_query">; +type ShippingQueryContextCore = FilterCore<"shipping_query">; +/** + * Type of the context object that is available inside the handlers for + * `bot.shippingQuery`. + * + * This helper type can be used to narrow down context objects the same way how + * annotate `bot.shippingQuery` does it. This allows you to context objects in + * middleware that is not directly passed to `bot.shippingQuery`, hence not + * inferring the correct type automatically. That way, handlers can be defined + * in separate files and still have the correct types. + */ +export type ShippingQueryContext = Filter, "shipping_query">; +type ChatTypeContextCore = T extends unknown ? Record<"update", ChatTypeUpdate> & ChatType & Record<"chatId", number> & ChatFrom & ChatTypeRecord<"msg", T> & AliasProps> : never; +/** + * Type of the context object that is available inside the handlers for + * `bot.chatType`. + * + * This helper type can be used to narrow down context objects the same way how + * `bot.chatType` does it. This allows you to annotate context objects in + * middleware that is not directly passed to `bot.chatType`, hence not inferring + * the correct type automatically. That way, handlers can be defined in separate + * files and still have the correct types. + */ +export type ChatTypeContext = T extends unknown ? C & ChatTypeContextCore : never; +type ChatTypeUpdate = ChatTypeRecord<"message" | "edited_message" | "channel_post" | "edited_channel_post" | "my_chat_member" | "chat_member" | "chat_join_request", T> & Partial>> & ConstrainUpdatesByChatType; +type ConstrainUpdatesByChatType = Record<[ + T +] extends ["channel"] ? "message" | "edited_message" : "channel_post" | "edited_channel_post", undefined>; +type ChatTypeRecord = Partial>>; +interface ChatType { + chat: { + type: T; + }; +} +interface ChatFrom { + from: [T] extends ["private"] ? {} : unknown; +} +import { AbortSignal } from "./shim.node.js"; +export {}; diff --git a/sandbox/tgbot/node_modules/grammy/out/context.js b/sandbox/tgbot/node_modules/grammy/out/context.js new file mode 100644 index 0000000..e4e64b8 --- /dev/null +++ b/sandbox/tgbot/node_modules/grammy/out/context.js @@ -0,0 +1,2481 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Context = void 0; +const filter_js_1 = require("./filter.js"); +const checker = { + filterQuery(filter) { + const pred = (0, filter_js_1.matchFilter)(filter); + return (ctx) => pred(ctx); + }, + text(trigger) { + const hasText = checker.filterQuery([":text", ":caption"]); + const trg = triggerFn(trigger); + return (ctx) => { + var _a, _b; + if (!hasText(ctx)) + return false; + const msg = (_a = ctx.message) !== null && _a !== void 0 ? _a : ctx.channelPost; + const txt = (_b = msg.text) !== null && _b !== void 0 ? _b : msg.caption; + return match(ctx, txt, trg); + }; + }, + command(command) { + const hasEntities = checker.filterQuery(":entities:bot_command"); + const atCommands = new Set(); + const noAtCommands = new Set(); + toArray(command).forEach((cmd) => { + if (cmd.startsWith("/")) { + throw new Error(`Do not include '/' when registering command handlers (use '${cmd.substring(1)}' not '${cmd}')`); + } + const set = cmd.includes("@") ? atCommands : noAtCommands; + set.add(cmd); + }); + return (ctx) => { + var _a, _b; + if (!hasEntities(ctx)) + return false; + const msg = (_a = ctx.message) !== null && _a !== void 0 ? _a : ctx.channelPost; + const txt = (_b = msg.text) !== null && _b !== void 0 ? _b : msg.caption; + return msg.entities.some((e) => { + if (e.type !== "bot_command") + return false; + if (e.offset !== 0) + return false; + const cmd = txt.substring(1, e.length); + if (noAtCommands.has(cmd) || atCommands.has(cmd)) { + ctx.match = txt.substring(cmd.length + 1).trimStart(); + return true; + } + const index = cmd.indexOf("@"); + if (index === -1) + return false; + const atTarget = cmd.substring(index + 1).toLowerCase(); + const username = ctx.me.username.toLowerCase(); + if (atTarget !== username) + return false; + const atCommand = cmd.substring(0, index); + if (noAtCommands.has(atCommand)) { + ctx.match = txt.substring(cmd.length + 1).trimStart(); + return true; + } + return false; + }); + }; + }, + reaction(reaction) { + const hasMessageReaction = checker.filterQuery("message_reaction"); + const normalized = typeof reaction === "string" + ? [{ type: "emoji", emoji: reaction }] + : (Array.isArray(reaction) ? reaction : [reaction]).map((emoji) => typeof emoji === "string" ? { type: "emoji", emoji } : emoji); + const emoji = new Set(normalized.filter((r) => r.type === "emoji") + .map((r) => r.emoji)); + const customEmoji = new Set(normalized.filter((r) => r.type === "custom_emoji") + .map((r) => r.custom_emoji_id)); + const paid = normalized.some((r) => r.type === "paid"); + return (ctx) => { + if (!hasMessageReaction(ctx)) + return false; + const { old_reaction, new_reaction } = ctx.messageReaction; + // try to find a wanted reaction that is new and not old + for (const reaction of new_reaction) { + // first check if the reaction existed previously + let isOld = false; + if (reaction.type === "emoji") { + for (const old of old_reaction) { + if (old.type !== "emoji") + continue; + if (old.emoji === reaction.emoji) { + isOld = true; + break; + } + } + } + else if (reaction.type === "custom_emoji") { + for (const old of old_reaction) { + if (old.type !== "custom_emoji") + continue; + if (old.custom_emoji_id === reaction.custom_emoji_id) { + isOld = true; + break; + } + } + } + else if (reaction.type === "paid") { + for (const old of old_reaction) { + if (old.type !== "paid") + continue; + isOld = true; + break; + } + } + else { + // always regard unsupported emoji types as new + } + // disregard reaction if it is not new + if (isOld) + continue; + // check if the new reaction is wanted and short-circuit + if (reaction.type === "emoji") { + if (emoji.has(reaction.emoji)) + return true; + } + else if (reaction.type === "custom_emoji") { + if (customEmoji.has(reaction.custom_emoji_id)) + return true; + } + else if (reaction.type === "paid") { + if (paid) + return true; + } + else { + // always regard unsupported emoji types as new + return true; + } + // new reaction not wanted, check next one + } + return false; + }; + }, + chatType(chatType) { + const set = new Set(toArray(chatType)); + return (ctx) => { var _a; return ((_a = ctx.chat) === null || _a === void 0 ? void 0 : _a.type) !== undefined && set.has(ctx.chat.type); }; + }, + callbackQuery(trigger) { + const hasCallbackQuery = checker.filterQuery("callback_query:data"); + const trg = triggerFn(trigger); + return (ctx) => hasCallbackQuery(ctx) && match(ctx, ctx.callbackQuery.data, trg); + }, + gameQuery(trigger) { + const hasGameQuery = checker.filterQuery("callback_query:game_short_name"); + const trg = triggerFn(trigger); + return (ctx) => hasGameQuery(ctx) && + match(ctx, ctx.callbackQuery.game_short_name, trg); + }, + inlineQuery(trigger) { + const hasInlineQuery = checker.filterQuery("inline_query"); + const trg = triggerFn(trigger); + return (ctx) => hasInlineQuery(ctx) && match(ctx, ctx.inlineQuery.query, trg); + }, + chosenInlineResult(trigger) { + const hasChosenInlineResult = checker.filterQuery("chosen_inline_result"); + const trg = triggerFn(trigger); + return (ctx) => hasChosenInlineResult(ctx) && + match(ctx, ctx.chosenInlineResult.result_id, trg); + }, + preCheckoutQuery(trigger) { + const hasPreCheckoutQuery = checker.filterQuery("pre_checkout_query"); + const trg = triggerFn(trigger); + return (ctx) => hasPreCheckoutQuery(ctx) && + match(ctx, ctx.preCheckoutQuery.invoice_payload, trg); + }, + shippingQuery(trigger) { + const hasShippingQuery = checker.filterQuery("shipping_query"); + const trg = triggerFn(trigger); + return (ctx) => hasShippingQuery(ctx) && + match(ctx, ctx.shippingQuery.invoice_payload, trg); + }, +}; +// === Context class +/** + * When your bot receives a message, Telegram sends an update object to your + * bot. The update contains information about the chat, the user, and of course + * the message itself. There are numerous other updates, too: + * https://core.telegram.org/bots/api#update + * + * When grammY receives an update, it wraps this update into a context object + * for you. Context objects are commonly named `ctx`. A context object does two + * things: + * 1. **`ctx.update`** holds the update object that you can use to process the + * message. This includes providing useful shortcuts for the update, for + * instance, `ctx.msg` is a shortcut that gives you the message object from + * the update—no matter whether it is contained in `ctx.update.message`, or + * `ctx.update.edited_message`, or `ctx.update.channel_post`, or + * `ctx.update.edited_channel_post`. + * 2. **`ctx.api`** gives you access to the full Telegram Bot API so that you + * can directly call any method, such as responding via + * `ctx.api.sendMessage`. Also here, the context objects has some useful + * shortcuts for you. For instance, if you want to send a message to the same + * chat that a message comes from (i.e. just respond to a user) you can call + * `ctx.reply`. This is nothing but a wrapper for `ctx.api.sendMessage` with + * the right `chat_id` pre-filled for you. Almost all methods of the Telegram + * Bot API have their own shortcut directly on the context object, so you + * probably never really have to use `ctx.api` at all. + * + * This context object is then passed to all of the listeners (called + * middleware) that you register on your bot. Because this is so useful, the + * context object is often used to hold more information. One example are + * sessions (a chat-specific data storage that is stored in a database), and + * another example is `ctx.match` that is used by `bot.command` and other + * methods to keep information about how a regular expression was matched. + * + * Read up about middleware on the + * [website](https://grammy.dev/guide/context) if you want to know more + * about the powerful opportunities that lie in context objects, and about how + * grammY implements them. + */ +class Context { + constructor( + /** + * The update object that is contained in the context. + */ + update, + /** + * An API instance that allows you to call any method of the Telegram + * Bot API. + */ + api, + /** + * Information about the bot itself. + */ + me) { + this.update = update; + this.api = api; + this.me = me; + } + // UPDATE SHORTCUTS + // Keep in sync with types in `filter.ts`. + /** Alias for `ctx.update.message` */ + get message() { + return this.update.message; + } + /** Alias for `ctx.update.edited_message` */ + get editedMessage() { + return this.update.edited_message; + } + /** Alias for `ctx.update.channel_post` */ + get channelPost() { + return this.update.channel_post; + } + /** Alias for `ctx.update.edited_channel_post` */ + get editedChannelPost() { + return this.update.edited_channel_post; + } + /** Alias for `ctx.update.business_connection` */ + get businessConnection() { + return this.update.business_connection; + } + /** Alias for `ctx.update.business_message` */ + get businessMessage() { + return this.update.business_message; + } + /** Alias for `ctx.update.edited_business_message` */ + get editedBusinessMessage() { + return this.update.edited_business_message; + } + /** Alias for `ctx.update.deleted_business_messages` */ + get deletedBusinessMessages() { + return this.update.deleted_business_messages; + } + /** Alias for `ctx.update.message_reaction` */ + get messageReaction() { + return this.update.message_reaction; + } + /** Alias for `ctx.update.message_reaction_count` */ + get messageReactionCount() { + return this.update.message_reaction_count; + } + /** Alias for `ctx.update.inline_query` */ + get inlineQuery() { + return this.update.inline_query; + } + /** Alias for `ctx.update.chosen_inline_result` */ + get chosenInlineResult() { + return this.update.chosen_inline_result; + } + /** Alias for `ctx.update.callback_query` */ + get callbackQuery() { + return this.update.callback_query; + } + /** Alias for `ctx.update.shipping_query` */ + get shippingQuery() { + return this.update.shipping_query; + } + /** Alias for `ctx.update.pre_checkout_query` */ + get preCheckoutQuery() { + return this.update.pre_checkout_query; + } + /** Alias for `ctx.update.poll` */ + get poll() { + return this.update.poll; + } + /** Alias for `ctx.update.poll_answer` */ + get pollAnswer() { + return this.update.poll_answer; + } + /** Alias for `ctx.update.my_chat_member` */ + get myChatMember() { + return this.update.my_chat_member; + } + /** Alias for `ctx.update.chat_member` */ + get chatMember() { + return this.update.chat_member; + } + /** Alias for `ctx.update.chat_join_request` */ + get chatJoinRequest() { + return this.update.chat_join_request; + } + /** Alias for `ctx.update.chat_boost` */ + get chatBoost() { + return this.update.chat_boost; + } + /** Alias for `ctx.update.removed_chat_boost` */ + get removedChatBoost() { + return this.update.removed_chat_boost; + } + /** Alias for `ctx.update.purchased_paid_media` */ + get purchasedPaidMedia() { + return this.update.purchased_paid_media; + } + // AGGREGATION SHORTCUTS + /** + * Get the message object from wherever possible. Alias for `this.message ?? + * this.editedMessage ?? this.channelPost ?? this.editedChannelPost ?? + * this.businessMessage ?? this.editedBusinessMessage ?? + * this.callbackQuery?.message`. + */ + get msg() { + var _a, _b, _c, _d, _e, _f, _g; + // Keep in sync with types in `filter.ts`. + return ((_f = (_e = (_d = (_c = (_b = (_a = this.message) !== null && _a !== void 0 ? _a : this.editedMessage) !== null && _b !== void 0 ? _b : this.channelPost) !== null && _c !== void 0 ? _c : this.editedChannelPost) !== null && _d !== void 0 ? _d : this.businessMessage) !== null && _e !== void 0 ? _e : this.editedBusinessMessage) !== null && _f !== void 0 ? _f : (_g = this.callbackQuery) === null || _g === void 0 ? void 0 : _g.message); + } + /** + * Get the chat object from wherever possible. Alias for `(this.msg ?? + * this.deletedBusinessMessages ?? this.messageReaction ?? + * this.messageReactionCount ?? this.myChatMember ?? this.chatMember ?? + * this.chatJoinRequest ?? this.chatBoost ?? this.removedChatBoost)?.chat`. + */ + get chat() { + var _a, _b, _c, _d, _e, _f, _g, _h, _j; + // Keep in sync with types in `filter.ts`. + return (_j = ((_h = (_g = (_f = (_e = (_d = (_c = (_b = (_a = this.msg) !== null && _a !== void 0 ? _a : this.deletedBusinessMessages) !== null && _b !== void 0 ? _b : this.messageReaction) !== null && _c !== void 0 ? _c : this.messageReactionCount) !== null && _d !== void 0 ? _d : this.myChatMember) !== null && _e !== void 0 ? _e : this.chatMember) !== null && _f !== void 0 ? _f : this.chatJoinRequest) !== null && _g !== void 0 ? _g : this.chatBoost) !== null && _h !== void 0 ? _h : this.removedChatBoost)) === null || _j === void 0 ? void 0 : _j.chat; + } + /** + * Get the sender chat object from wherever possible. Alias for + * `ctx.msg?.sender_chat`. + */ + get senderChat() { + var _a; + // Keep in sync with types in `filter.ts`. + return (_a = this.msg) === null || _a === void 0 ? void 0 : _a.sender_chat; + } + /** + * Get the user object from wherever possible. Alias for + * `(this.businessConnection ?? this.messageReaction ?? + * (this.chatBoost?.boost ?? this.removedChatBoost)?.source)?.user ?? + * (this.callbackQuery ?? this.msg ?? this.inlineQuery ?? + * this.chosenInlineResult ?? this.shippingQuery ?? this.preCheckoutQuery ?? + * this.myChatMember ?? this.chatMember ?? this.chatJoinRequest ?? + * this.purchasedPaidMedia)?.from`. + */ + get from() { + var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s; + // Keep in sync with types in `filter.ts`. + return (_g = (_f = ((_b = (_a = this.businessConnection) !== null && _a !== void 0 ? _a : this.messageReaction) !== null && _b !== void 0 ? _b : (_e = ((_d = (_c = this.chatBoost) === null || _c === void 0 ? void 0 : _c.boost) !== null && _d !== void 0 ? _d : this.removedChatBoost)) === null || _e === void 0 ? void 0 : _e.source)) === null || _f === void 0 ? void 0 : _f.user) !== null && _g !== void 0 ? _g : (_s = ((_r = (_q = (_p = (_o = (_m = (_l = (_k = (_j = (_h = this.callbackQuery) !== null && _h !== void 0 ? _h : this.msg) !== null && _j !== void 0 ? _j : this.inlineQuery) !== null && _k !== void 0 ? _k : this.chosenInlineResult) !== null && _l !== void 0 ? _l : this.shippingQuery) !== null && _m !== void 0 ? _m : this.preCheckoutQuery) !== null && _o !== void 0 ? _o : this.myChatMember) !== null && _p !== void 0 ? _p : this.chatMember) !== null && _q !== void 0 ? _q : this.chatJoinRequest) !== null && _r !== void 0 ? _r : this.purchasedPaidMedia)) === null || _s === void 0 ? void 0 : _s.from; + } + /** + * Get the message identifier from wherever possible. Alias for + * `this.msg?.message_id ?? this.messageReaction?.message_id ?? + * this.messageReactionCount?.message_id`. + */ + get msgId() { + var _a, _b, _c, _d, _e; + // Keep in sync with types in `filter.ts`. + return (_d = (_b = (_a = this.msg) === null || _a === void 0 ? void 0 : _a.message_id) !== null && _b !== void 0 ? _b : (_c = this.messageReaction) === null || _c === void 0 ? void 0 : _c.message_id) !== null && _d !== void 0 ? _d : (_e = this.messageReactionCount) === null || _e === void 0 ? void 0 : _e.message_id; + } + /** + * Gets the chat identifier from wherever possible. Alias for `this.chat?.id + * ?? this.businessConnection?.user_chat_id`. + */ + get chatId() { + var _a, _b, _c; + // Keep in sync with types in `filter.ts`. + return (_b = (_a = this.chat) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : (_c = this.businessConnection) === null || _c === void 0 ? void 0 : _c.user_chat_id; + } + /** + * Get the inline message identifier from wherever possible. Alias for + * `(ctx.callbackQuery ?? ctx.chosenInlineResult)?.inline_message_id`. + */ + get inlineMessageId() { + var _a, _b, _c; + return ((_b = (_a = this.callbackQuery) === null || _a === void 0 ? void 0 : _a.inline_message_id) !== null && _b !== void 0 ? _b : (_c = this.chosenInlineResult) === null || _c === void 0 ? void 0 : _c.inline_message_id); + } + /** + * Get the business connection identifier from wherever possible. Alias for + * `this.msg?.business_connection_id ?? this.businessConnection?.id ?? + * this.deletedBusinessMessages?.business_connection_id`. + */ + get businessConnectionId() { + var _a, _b, _c, _d, _e; + return (_d = (_b = (_a = this.msg) === null || _a === void 0 ? void 0 : _a.business_connection_id) !== null && _b !== void 0 ? _b : (_c = this.businessConnection) === null || _c === void 0 ? void 0 : _c.id) !== null && _d !== void 0 ? _d : (_e = this.deletedBusinessMessages) === null || _e === void 0 ? void 0 : _e.business_connection_id; + } + entities(types) { + var _a, _b; + const message = this.msg; + if (message === undefined) + return []; + const text = (_a = message.text) !== null && _a !== void 0 ? _a : message.caption; + if (text === undefined) + return []; + let entities = (_b = message.entities) !== null && _b !== void 0 ? _b : message.caption_entities; + if (entities === undefined) + return []; + if (types !== undefined) { + const filters = new Set(toArray(types)); + entities = entities.filter((entity) => filters.has(entity.type)); + } + return entities.map((entity) => ({ + ...entity, + text: text.substring(entity.offset, entity.offset + entity.length), + })); + } + /** + * Find out which reactions were added and removed in a `message_reaction` + * update. This method looks at `ctx.messageReaction` and computes the + * difference between the old reaction and the new reaction. It also groups + * the reactions by emoji reactions and custom emoji reactions. For example, + * the resulting object could look like this: + * ```ts + * { + * emoji: ['👍', '🎉'] + * emojiAdded: ['🎉'], + * emojiKept: ['👍'], + * emojiRemoved: [], + * customEmoji: [], + * customEmojiAdded: [], + * customEmojiKept: [], + * customEmojiRemoved: ['id0123'], + * paid: true, + * paidAdded: false, + * paidRemoved: false, + * } + * ``` + * In the above example, a tada reaction was added by the user, and a custom + * emoji reaction with the custom emoji 'id0123' was removed in the same + * update. The user had already reacted with a thumbs up reaction and a paid + * star reaction, which they left both unchanged. As a result, the current + * reaction by the user is thumbs up, tada, and a paid reaction. Note that + * the current reaction (all emoji reactions regardless of type in one list) + * can also be obtained from `ctx.messageReaction.new_reaction`. + * + * Remember that reaction updates only include information about the + * reaction of a specific user. The respective message may have many more + * reactions by other people which will not be included in this update. + * + * @returns An object containing information about the reaction update + */ + reactions() { + const emoji = []; + const emojiAdded = []; + const emojiKept = []; + const emojiRemoved = []; + const customEmoji = []; + const customEmojiAdded = []; + const customEmojiKept = []; + const customEmojiRemoved = []; + let paid = false; + let paidAdded = false; + const r = this.messageReaction; + if (r !== undefined) { + const { old_reaction, new_reaction } = r; + // group all current emoji in `emoji` and `customEmoji` + for (const reaction of new_reaction) { + if (reaction.type === "emoji") { + emoji.push(reaction.emoji); + } + else if (reaction.type === "custom_emoji") { + customEmoji.push(reaction.custom_emoji_id); + } + else if (reaction.type === "paid") { + paid = paidAdded = true; + } + } + // temporarily move all old emoji to the *Removed arrays + for (const reaction of old_reaction) { + if (reaction.type === "emoji") { + emojiRemoved.push(reaction.emoji); + } + else if (reaction.type === "custom_emoji") { + customEmojiRemoved.push(reaction.custom_emoji_id); + } + else if (reaction.type === "paid") { + paidAdded = false; + } + } + // temporarily move all new emoji to the *Added arrays + emojiAdded.push(...emoji); + customEmojiAdded.push(...customEmoji); + // drop common emoji from both lists and add them to `emojiKept` + for (let i = 0; i < emojiRemoved.length; i++) { + const len = emojiAdded.length; + if (len === 0) + break; + const rem = emojiRemoved[i]; + for (let j = 0; j < len; j++) { + if (rem === emojiAdded[j]) { + emojiKept.push(rem); + emojiRemoved.splice(i, 1); + emojiAdded.splice(j, 1); + i--; + break; + } + } + } + // drop common custom emoji from both lists and add them to `customEmojiKept` + for (let i = 0; i < customEmojiRemoved.length; i++) { + const len = customEmojiAdded.length; + if (len === 0) + break; + const rem = customEmojiRemoved[i]; + for (let j = 0; j < len; j++) { + if (rem === customEmojiAdded[j]) { + customEmojiKept.push(rem); + customEmojiRemoved.splice(i, 1); + customEmojiAdded.splice(j, 1); + i--; + break; + } + } + } + } + return { + emoji, + emojiAdded, + emojiKept, + emojiRemoved, + customEmoji, + customEmojiAdded, + customEmojiKept, + customEmojiRemoved, + paid, + paidAdded, + }; + } + /** + * Returns `true` if this context object matches the given filter query, and + * `false` otherwise. This uses the same logic as `bot.on`. + * + * @param filter The filter query to check + */ + has(filter) { + return Context.has.filterQuery(filter)(this); + } + /** + * Returns `true` if this context object contains the given text, or if it + * contains text that matches the given regular expression. It returns + * `false` otherwise. This uses the same logic as `bot.hears`. + * + * @param trigger The string or regex to match + */ + hasText(trigger) { + return Context.has.text(trigger)(this); + } + /** + * Returns `true` if this context object contains the given command, and + * `false` otherwise. This uses the same logic as `bot.command`. + * + * @param command The command to match + */ + hasCommand(command) { + return Context.has.command(command)(this); + } + hasReaction(reaction) { + return Context.has.reaction(reaction)(this); + } + /** + * Returns `true` if this context object belongs to a chat with the given + * chat type, and `false` otherwise. This uses the same logic as + * `bot.chatType`. + * + * @param chatType The chat type to match + */ + hasChatType(chatType) { + return Context.has.chatType(chatType)(this); + } + /** + * Returns `true` if this context object contains the given callback query, + * or if the contained callback query data matches the given regular + * expression. It returns `false` otherwise. This uses the same logic as + * `bot.callbackQuery`. + * + * @param trigger The string or regex to match + */ + hasCallbackQuery(trigger) { + return Context.has.callbackQuery(trigger)(this); + } + /** + * Returns `true` if this context object contains the given game query, or + * if the contained game query matches the given regular expression. It + * returns `false` otherwise. This uses the same logic as `bot.gameQuery`. + * + * @param trigger The string or regex to match + */ + hasGameQuery(trigger) { + return Context.has.gameQuery(trigger)(this); + } + /** + * Returns `true` if this context object contains the given inline query, or + * if the contained inline query matches the given regular expression. It + * returns `false` otherwise. This uses the same logic as `bot.inlineQuery`. + * + * @param trigger The string or regex to match + */ + hasInlineQuery(trigger) { + return Context.has.inlineQuery(trigger)(this); + } + /** + * Returns `true` if this context object contains the chosen inline result, + * or if the contained chosen inline result matches the given regular + * expression. It returns `false` otherwise. This uses the same logic as + * `bot.chosenInlineResult`. + * + * @param trigger The string or regex to match + */ + hasChosenInlineResult(trigger) { + return Context.has.chosenInlineResult(trigger)(this); + } + /** + * Returns `true` if this context object contains the given pre-checkout + * query, or if the contained pre-checkout query matches the given regular + * expression. It returns `false` otherwise. This uses the same logic as + * `bot.preCheckoutQuery`. + * + * @param trigger The string or regex to match + */ + hasPreCheckoutQuery(trigger) { + return Context.has.preCheckoutQuery(trigger)(this); + } + /** + * Returns `true` if this context object contains the given shipping query, + * or if the contained shipping query matches the given regular expression. + * It returns `false` otherwise. This uses the same logic as + * `bot.shippingQuery`. + * + * @param trigger The string or regex to match + */ + hasShippingQuery(trigger) { + return Context.has.shippingQuery(trigger)(this); + } + // API + /** + * Context-aware alias for `api.sendMessage`. Use this method to send text messages. On success, the sent Message is returned. + * + * @param text Text of the message to be sent, 1-4096 characters after entities parsing + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendmessage + */ + reply(text, other, signal) { + var _a; + const msg = this.msg; + return this.api.sendMessage(orThrow(this.chatId, "sendMessage"), text, { + business_connection_id: this.businessConnectionId, + ...((msg === null || msg === void 0 ? void 0 : msg.is_topic_message) + ? { message_thread_id: msg.message_thread_id } + : {}), + direct_messages_topic_id: (_a = msg === null || msg === void 0 ? void 0 : msg.direct_messages_topic) === null || _a === void 0 ? void 0 : _a.topic_id, + ...other, + }, signal); + } + /** + * Context-aware alias for `api.sendMessageDraft`. Use this method to stream a partial message to a user while the message is being generated; supported only for bots with forum topic mode enabled. Returns True on success. + * + * @param text Text of the message to be sent, 1-4096 characters after entities parsing + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendmessagedraft + */ + replyWithDraft(text, other, signal) { + const msg = this.msg; + return this.api.sendMessageDraft(orThrow(this.chatId, "sendMessageDraft"), this.update.update_id, text, { + ...((msg === null || msg === void 0 ? void 0 : msg.is_topic_message) + ? { message_thread_id: msg === null || msg === void 0 ? void 0 : msg.message_thread_id } + : {}), + ...other, + }, signal); + } + /** + * Context-aware alias for `api.forwardMessage`. Use this method to forward messages of any kind. Service messages and messages with protected content can't be forwarded. On success, the sent Message is returned. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#forwardmessage + */ + forwardMessage(chat_id, other, signal) { + var _a; + const msg = this.msg; + return this.api.forwardMessage(chat_id, orThrow(this.chatId, "forwardMessage"), orThrow(this.msgId, "forwardMessage"), { + direct_messages_topic_id: (_a = msg === null || msg === void 0 ? void 0 : msg.direct_messages_topic) === null || _a === void 0 ? void 0 : _a.topic_id, + ...other, + }, signal); + } + /** + * Context-aware alias for `api.forwardMessages`. Use this method to forward multiple messages of any kind. If some of the specified messages can't be found or forwarded, they are skipped. Service messages and messages with protected content can't be forwarded. Album grouping is kept for forwarded messages. On success, an array of MessageId of the sent messages is returned. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param message_ids A list of 1-100 identifiers of messages in the current chat to forward. The identifiers must be specified in a strictly increasing order. + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#forwardmessages + */ + forwardMessages(chat_id, message_ids, other, signal) { + var _a; + const msg = this.msg; + return this.api.forwardMessages(chat_id, orThrow(this.chatId, "forwardMessages"), message_ids, { + direct_messages_topic_id: (_a = msg === null || msg === void 0 ? void 0 : msg.direct_messages_topic) === null || _a === void 0 ? void 0 : _a.topic_id, + ...other, + }, signal); + } + /** + * Context-aware alias for `api.copyMessage`. Use this method to copy messages of any kind. Service messages, paid media messages, giveaway messages, giveaway winners messages, and invoice messages can't be copied. A quiz poll can be copied only if the value of the field correct_option_id is known to the bot. The method is analogous to the method forwardMessage, but the copied message doesn't have a link to the original message. Returns the MessageId of the sent message on success. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#copymessage + */ + copyMessage(chat_id, other, signal) { + var _a; + const msg = this.msg; + return this.api.copyMessage(chat_id, orThrow(this.chatId, "copyMessage"), orThrow(this.msgId, "copyMessage"), { + direct_messages_topic_id: (_a = msg === null || msg === void 0 ? void 0 : msg.direct_messages_topic) === null || _a === void 0 ? void 0 : _a.topic_id, + ...other, + }, signal); + } + /** + * Context-aware alias for `api.copyMessages`. Use this method to copy messages of any kind. If some of the specified messages can't be found or copied, they are skipped. Service messages, paid media messages, giveaway messages, giveaway winners messages, and invoice messages can't be copied. A quiz poll can be copied only if the value of the field correct_option_id is known to the bot. The method is analogous to the method forwardMessages, but the copied messages don't have a link to the original message. Album grouping is kept for copied messages. On success, an array of MessageId of the sent messages is returned. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param message_ids A list of 1-100 identifiers of messages in the current chat to copy. The identifiers must be specified in a strictly increasing order. + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#copymessages + */ + copyMessages(chat_id, message_ids, other, signal) { + var _a; + const msg = this.msg; + return this.api.copyMessages(chat_id, orThrow(this.chatId, "copyMessages"), message_ids, { + direct_messages_topic_id: (_a = msg === null || msg === void 0 ? void 0 : msg.direct_messages_topic) === null || _a === void 0 ? void 0 : _a.topic_id, + ...other, + }, signal); + } + /** + * Context-aware alias for `api.sendPhoto`. Use this method to send photos. On success, the sent Message is returned. + * + * @param photo Photo to send. Pass a file_id as String to send a photo that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a photo from the Internet, or upload a new photo using multipart/form-data. The photo must be at most 10 MB in size. The photo's width and height must not exceed 10000 in total. Width and height ratio must be at most 20. + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendphoto + */ + replyWithPhoto(photo, other, signal) { + var _a; + const msg = this.msg; + return this.api.sendPhoto(orThrow(this.chatId, "sendPhoto"), photo, { + business_connection_id: this.businessConnectionId, + ...((msg === null || msg === void 0 ? void 0 : msg.is_topic_message) + ? { message_thread_id: msg.message_thread_id } + : {}), + direct_messages_topic_id: (_a = msg === null || msg === void 0 ? void 0 : msg.direct_messages_topic) === null || _a === void 0 ? void 0 : _a.topic_id, + ...other, + }, signal); + } + /** + * Context-aware alias for `api.sendAudio`. Use this method to send audio files, if you want Telegram clients to display them in the music player. Your audio must be in the .MP3 or .M4A format. On success, the sent Message is returned. Bots can currently send audio files of up to 50 MB in size, this limit may be changed in the future. + * + * For sending voice messages, use the sendVoice method instead. + * + * @param audio Audio file to send. Pass a file_id as String to send an audio file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get an audio file from the Internet, or upload a new one using multipart/form-data. + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendaudio + */ + replyWithAudio(audio, other, signal) { + var _a; + const msg = this.msg; + return this.api.sendAudio(orThrow(this.chatId, "sendAudio"), audio, { + business_connection_id: this.businessConnectionId, + ...((msg === null || msg === void 0 ? void 0 : msg.is_topic_message) + ? { message_thread_id: msg.message_thread_id } + : {}), + direct_messages_topic_id: (_a = msg === null || msg === void 0 ? void 0 : msg.direct_messages_topic) === null || _a === void 0 ? void 0 : _a.topic_id, + ...other, + }, signal); + } + /** + * Context-aware alias for `api.sendDocument`. Use this method to send general files. On success, the sent Message is returned. Bots can currently send files of any type of up to 50 MB in size, this limit may be changed in the future. + * + * @param document File to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#senddocument + */ + replyWithDocument(document, other, signal) { + var _a; + const msg = this.msg; + return this.api.sendDocument(orThrow(this.chatId, "sendDocument"), document, { + business_connection_id: this.businessConnectionId, + ...((msg === null || msg === void 0 ? void 0 : msg.is_topic_message) + ? { message_thread_id: msg.message_thread_id } + : {}), + direct_messages_topic_id: (_a = msg === null || msg === void 0 ? void 0 : msg.direct_messages_topic) === null || _a === void 0 ? void 0 : _a.topic_id, + ...other, + }, signal); + } + /** + * Context-aware alias for `api.sendVideo`. Use this method to send video files, Telegram clients support mp4 videos (other formats may be sent as Document). On success, the sent Message is returned. Bots can currently send video files of up to 50 MB in size, this limit may be changed in the future. + * + * @param video Video to send. Pass a file_id as String to send a video that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a video from the Internet, or upload a new video using multipart/form-data. + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendvideo + */ + replyWithVideo(video, other, signal) { + var _a; + const msg = this.msg; + return this.api.sendVideo(orThrow(this.chatId, "sendVideo"), video, { + business_connection_id: this.businessConnectionId, + ...((msg === null || msg === void 0 ? void 0 : msg.is_topic_message) + ? { message_thread_id: msg.message_thread_id } + : {}), + direct_messages_topic_id: (_a = msg === null || msg === void 0 ? void 0 : msg.direct_messages_topic) === null || _a === void 0 ? void 0 : _a.topic_id, + ...other, + }, signal); + } + /** + * Context-aware alias for `api.sendAnimation`. Use this method to send animation files (GIF or H.264/MPEG-4 AVC video without sound). On success, the sent Message is returned. Bots can currently send animation files of up to 50 MB in size, this limit may be changed in the future. + * + * @param animation Animation to send. Pass a file_id as String to send an animation that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get an animation from the Internet, or upload a new animation using multipart/form-data. + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendanimation + */ + replyWithAnimation(animation, other, signal) { + var _a; + const msg = this.msg; + return this.api.sendAnimation(orThrow(this.chatId, "sendAnimation"), animation, { + business_connection_id: this.businessConnectionId, + ...((msg === null || msg === void 0 ? void 0 : msg.is_topic_message) + ? { message_thread_id: msg.message_thread_id } + : {}), + direct_messages_topic_id: (_a = msg === null || msg === void 0 ? void 0 : msg.direct_messages_topic) === null || _a === void 0 ? void 0 : _a.topic_id, + ...other, + }, signal); + } + /** + * Context-aware alias for `api.sendVoice`. Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message. For this to work, your audio must be in an .OGG file encoded with OPUS (other formats may be sent as Audio or Document). On success, the sent Message is returned. Bots can currently send voice messages of up to 50 MB in size, this limit may be changed in the future. + * + * @param voice Audio file to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendvoice + */ + replyWithVoice(voice, other, signal) { + var _a; + const msg = this.msg; + return this.api.sendVoice(orThrow(this.chatId, "sendVoice"), voice, { + business_connection_id: this.businessConnectionId, + ...((msg === null || msg === void 0 ? void 0 : msg.is_topic_message) + ? { message_thread_id: msg.message_thread_id } + : {}), + direct_messages_topic_id: (_a = msg === null || msg === void 0 ? void 0 : msg.direct_messages_topic) === null || _a === void 0 ? void 0 : _a.topic_id, + ...other, + }, signal); + } + /** + * Context-aware alias for `api.sendVideoNote`. Use this method to send video messages. On success, the sent Message is returned. + * As of v.4.0, Telegram clients support rounded square mp4 videos of up to 1 minute long. + * + * @param video_note Video note to send. Pass a file_id as String to send a video note that exists on the Telegram servers (recommended) or upload a new video using multipart/form-data.. Sending video notes by a URL is currently unsupported + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendvideonote + */ + replyWithVideoNote(video_note, other, signal) { + var _a; + const msg = this.msg; + return this.api.sendVideoNote(orThrow(this.chatId, "sendVideoNote"), video_note, { + business_connection_id: this.businessConnectionId, + ...((msg === null || msg === void 0 ? void 0 : msg.is_topic_message) + ? { message_thread_id: msg.message_thread_id } + : {}), + direct_messages_topic_id: (_a = msg === null || msg === void 0 ? void 0 : msg.direct_messages_topic) === null || _a === void 0 ? void 0 : _a.topic_id, + ...other, + }, signal); + } + /** + * Context-aware alias for `api.sendMediaGroup`. Use this method to send a group of photos, videos, documents or audios as an album. Documents and audio files can be only grouped in an album with messages of the same type. On success, an array of Messages that were sent is returned. + * + * @param media An array describing messages to be sent, must include 2-10 items + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendmediagroup + */ + replyWithMediaGroup(media, other, signal) { + var _a; + const msg = this.msg; + return this.api.sendMediaGroup(orThrow(this.chatId, "sendMediaGroup"), media, { + business_connection_id: this.businessConnectionId, + ...((msg === null || msg === void 0 ? void 0 : msg.is_topic_message) + ? { message_thread_id: msg.message_thread_id } + : {}), + direct_messages_topic_id: (_a = msg === null || msg === void 0 ? void 0 : msg.direct_messages_topic) === null || _a === void 0 ? void 0 : _a.topic_id, + ...other, + }, signal); + } + /** + * Context-aware alias for `api.sendLocation`. Use this method to send point on the map. On success, the sent Message is returned. + * + * @param latitude Latitude of the location + * @param longitude Longitude of the location + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendlocation + */ + replyWithLocation(latitude, longitude, other, signal) { + var _a; + const msg = this.msg; + return this.api.sendLocation(orThrow(this.chatId, "sendLocation"), latitude, longitude, { + business_connection_id: this.businessConnectionId, + ...((msg === null || msg === void 0 ? void 0 : msg.is_topic_message) + ? { message_thread_id: msg.message_thread_id } + : {}), + direct_messages_topic_id: (_a = msg === null || msg === void 0 ? void 0 : msg.direct_messages_topic) === null || _a === void 0 ? void 0 : _a.topic_id, + ...other, + }, signal); + } + /** + * Context-aware alias for `api.editMessageLiveLocation`. Use this method to edit live location messages. A location can be edited until its live_period expires or editing is explicitly disabled by a call to stopMessageLiveLocation. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. + * + * @param latitude Latitude of new location + * @param longitude Longitude of new location + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#editmessagelivelocation + */ + editMessageLiveLocation(latitude, longitude, other, signal) { + const inlineId = this.inlineMessageId; + return inlineId !== undefined + ? this.api.editMessageLiveLocationInline(inlineId, latitude, longitude, { business_connection_id: this.businessConnectionId, ...other }, signal) + : this.api.editMessageLiveLocation(orThrow(this.chatId, "editMessageLiveLocation"), orThrow(this.msgId, "editMessageLiveLocation"), latitude, longitude, { business_connection_id: this.businessConnectionId, ...other }, signal); + } + /** + * Context-aware alias for `api.stopMessageLiveLocation`. Use this method to stop updating a live location message before live_period expires. On success, if the message is not an inline message, the edited Message is returned, otherwise True is returned. + * + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#stopmessagelivelocation + */ + stopMessageLiveLocation(other, signal) { + const inlineId = this.inlineMessageId; + return inlineId !== undefined + ? this.api.stopMessageLiveLocationInline(inlineId, { business_connection_id: this.businessConnectionId, ...other }, signal) + : this.api.stopMessageLiveLocation(orThrow(this.chatId, "stopMessageLiveLocation"), orThrow(this.msgId, "stopMessageLiveLocation"), { business_connection_id: this.businessConnectionId, ...other }, signal); + } + /** + * Context-aware alias for `api.sendPaidMedia`. Use this method to send paid media. On success, the sent Message is returned. + * + * @param star_count The number of Telegram Stars that must be paid to buy access to the media + * @param media An array describing the media to be sent; up to 10 items + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendpaidmedia + */ + sendPaidMedia(star_count, media, other, signal) { + var _a, _b; + const msg = this.msg; + return this.api.sendPaidMedia(orThrow(this.chatId, "sendPaidMedia"), star_count, media, { + business_connection_id: this.businessConnectionId, + ...((msg === null || msg === void 0 ? void 0 : msg.is_topic_message) + ? { message_thread_id: msg.message_thread_id } + : {}), + direct_messages_topic_id: (_b = (_a = this.msg) === null || _a === void 0 ? void 0 : _a.direct_messages_topic) === null || _b === void 0 ? void 0 : _b.topic_id, + ...other, + }, signal); + } + /** + * Context-aware alias for `api.sendVenue`. Use this method to send information about a venue. On success, the sent Message is returned. + * + * @param latitude Latitude of the venue + * @param longitude Longitude of the venue + * @param title Name of the venue + * @param address Address of the venue + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendvenue + */ + replyWithVenue(latitude, longitude, title, address, other, signal) { + var _a; + const msg = this.msg; + return this.api.sendVenue(orThrow(this.chatId, "sendVenue"), latitude, longitude, title, address, { + business_connection_id: this.businessConnectionId, + ...((msg === null || msg === void 0 ? void 0 : msg.is_topic_message) + ? { message_thread_id: msg.message_thread_id } + : {}), + direct_messages_topic_id: (_a = msg === null || msg === void 0 ? void 0 : msg.direct_messages_topic) === null || _a === void 0 ? void 0 : _a.topic_id, + ...other, + }, signal); + } + /** + * Context-aware alias for `api.sendContact`. Use this method to send phone contacts. On success, the sent Message is returned. + * + * @param phone_number Contact's phone number + * @param first_name Contact's first name + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendcontact + */ + replyWithContact(phone_number, first_name, other, signal) { + var _a; + const msg = this.msg; + return this.api.sendContact(orThrow(this.chatId, "sendContact"), phone_number, first_name, { + business_connection_id: this.businessConnectionId, + ...((msg === null || msg === void 0 ? void 0 : msg.is_topic_message) + ? { message_thread_id: msg.message_thread_id } + : {}), + direct_messages_topic_id: (_a = msg === null || msg === void 0 ? void 0 : msg.direct_messages_topic) === null || _a === void 0 ? void 0 : _a.topic_id, + ...other, + }, signal); + } + /** + * Context-aware alias for `api.sendPoll`. Use this method to send a native poll. On success, the sent Message is returned. + * + * @param question Poll question, 1-300 characters + * @param options A list of answer options, 2-12 strings 1-100 characters each + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendpoll + */ + replyWithPoll(question, options, other, signal) { + const msg = this.msg; + return this.api.sendPoll(orThrow(this.chatId, "sendPoll"), question, options, { + business_connection_id: this.businessConnectionId, + ...((msg === null || msg === void 0 ? void 0 : msg.is_topic_message) + ? { message_thread_id: msg.message_thread_id } + : {}), + ...other, + }, signal); + } + /** + * Context-aware alias for `api.sendChecklist`. Use this method to send a checklist on behalf of a connected business account. On success, the sent Message is returned. + * + * @param checklist An object for the checklist to send + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendchecklist + */ + replyWithChecklist(checklist, other, signal) { + return this.api.sendChecklist(orThrow(this.businessConnectionId, "sendChecklist"), orThrow(this.chatId, "sendChecklist"), checklist, other, signal); + } + /** + * Context-aware alias for `api.editMessageChecklist`. Use this method to edit a checklist on behalf of a connected business account. On success, the edited Message is returned. + * + * @param checklist An object for the new checklist + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#editmessagechecklist + */ + editMessageChecklist(checklist, other, signal) { + var _a, _b, _c, _d; + const msg = orThrow(this.msg, "editMessageChecklist"); + const target = (_d = (_b = (_a = msg.checklist_tasks_done) === null || _a === void 0 ? void 0 : _a.checklist_message) !== null && _b !== void 0 ? _b : (_c = msg.checklist_tasks_added) === null || _c === void 0 ? void 0 : _c.checklist_message) !== null && _d !== void 0 ? _d : msg; + return this.api.editMessageChecklist(orThrow(this.businessConnectionId, "editMessageChecklist"), orThrow(target.chat.id, "editMessageChecklist"), orThrow(target.message_id, "editMessageChecklist"), checklist, other, signal); + } + /** + * Context-aware alias for `api.sendDice`. Use this method to send an animated emoji that will display a random value. On success, the sent Message is returned. + * + * @param emoji Emoji on which the dice throw animation is based. Currently, must be one of “🎲”, “🎯”, “🏀”, “⚽”, “🎳”, or “🎰”. Dice can have values 1-6 for “🎲”, “🎯” and “🎳”, values 1-5 for “🏀” and “⚽”, and values 1-64 for “🎰”. Defaults to “🎲” + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#senddice + */ + replyWithDice(emoji, other, signal) { + var _a; + const msg = this.msg; + return this.api.sendDice(orThrow(this.chatId, "sendDice"), emoji, { + business_connection_id: this.businessConnectionId, + ...((msg === null || msg === void 0 ? void 0 : msg.is_topic_message) + ? { message_thread_id: msg.message_thread_id } + : {}), + direct_messages_topic_id: (_a = msg === null || msg === void 0 ? void 0 : msg.direct_messages_topic) === null || _a === void 0 ? void 0 : _a.topic_id, + ...other, + }, signal); + } + /** + * Context-aware alias for `api.sendChatAction`. Use this method when you need to tell the user that something is happening on the bot's side. The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status). Returns True on success. + * + * Example: The ImageBot needs some time to process a request and upload the image. Instead of sending a text message along the lines of “Retrieving image, please wait…”, the bot may use sendChatAction with action = upload_photo. The user will see a “sending photo” status for the bot. + * + * We only recommend using this method when a response from the bot will take a noticeable amount of time to arrive. + * + * @param action Type of action to broadcast. Choose one, depending on what the user is about to receive: typing for text messages, upload_photo for photos, record_video or upload_video for videos, record_voice or upload_voice for voice notes, upload_document for general files, choose_sticker for stickers, find_location for location data, record_video_note or upload_video_note for video notes. + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendchataction + */ + replyWithChatAction(action, other, signal) { + const msg = this.msg; + return this.api.sendChatAction(orThrow(this.chatId, "sendChatAction"), action, { + business_connection_id: this.businessConnectionId, + message_thread_id: msg === null || msg === void 0 ? void 0 : msg.message_thread_id, + ...other, + }, signal); + } + /** + * Context-aware alias for `api.setMessageReaction`. Use this method to change the chosen reactions on a message. Service messages of some types can't be reacted to. Automatically forwarded messages from a channel to its discussion group have the same available reactions as messages in the channel. Bots can't use paid reactions. Returns True on success. + * + * @param reaction A list of reaction types to set on the message. Currently, as non-premium users, bots can set up to one reaction per message. A custom emoji reaction can be used if it is either already present on the message or explicitly allowed by chat administrators. Paid reactions can't be used by bots. + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setmessagereaction + */ + react(reaction, other, signal) { + return this.api.setMessageReaction(orThrow(this.chatId, "setMessageReaction"), orThrow(this.msgId, "setMessageReaction"), typeof reaction === "string" + ? [{ type: "emoji", emoji: reaction }] + : (Array.isArray(reaction) ? reaction : [reaction]) + .map((emoji) => typeof emoji === "string" + ? { type: "emoji", emoji } + : emoji), other, signal); + } + /** + * Context-aware alias for `api.getUserProfilePhotos`. Use this method to get a list of profile pictures for a user. Returns a UserProfilePhotos object. + * + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getuserprofilephotos + */ + getUserProfilePhotos(other, signal) { + return this.api.getUserProfilePhotos(orThrow(this.from, "getUserProfilePhotos").id, other, signal); + } + /** + * Context-aware alias for `api.getUserProfileAudios`. Use this method to get a list of profile audios for a user. Returns a UserProfileAudios object. + * + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getuserprofileaudios + */ + getUserProfileAudios(other, signal) { + return this.api.getUserProfileAudios(orThrow(this.from, "getUserProfileAudios").id, other, signal); + } + /** + * Context-aware alias for `api.serUserEmojiStatus`. Changes the emoji status for a given user that previously allowed the bot to manage their emoji status via the Mini App method requestEmojiStatusAccess. Returns True on success. + * + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setuseremojistatus + */ + setUserEmojiStatus(other, signal) { + return this.api.setUserEmojiStatus(orThrow(this.from, "setUserEmojiStatus").id, other, signal); + } + /** + * Context-aware alias for `api.getUserChatBoosts`. Use this method to get the list of boosts added to a chat by a user. Requires administrator rights in the chat. Returns a UserChatBoosts object. + * + * @param chat_id Unique identifier for the chat or username of the channel (in the format @channelusername) + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getuserchatboosts + */ + getUserChatBoosts(chat_id, signal) { + return this.api.getUserChatBoosts(chat_id !== null && chat_id !== void 0 ? chat_id : orThrow(this.chatId, "getUserChatBoosts"), orThrow(this.from, "getUserChatBoosts").id, signal); + } + /** + * Context-aware alias for `api.getUserGifts`. Returns the gifts owned and hosted by a user. Returns OwnedGifts on success. + * + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getusergifts + */ + getUserGifts(other, signal) { + return this.api.getUserGifts(orThrow(this.from, "getUserGifts").id, other, signal); + } + /** + * Context-aware alias for `api.getChatGifts`. Returns the gifts owned by a chat. Returns OwnedGifts on success. + * + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getchatgifts + */ + getChatGifts(other, signal) { + return this.api.getChatGifts(orThrow(this.chatId, "getChatGifts"), other, signal); + } + /** + * Context-aware alias for `api.getBusinessConnection`. Use this method to get information about the connection of the bot with a business account. Returns a BusinessConnection object on success. + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getbusinessconnection + */ + getBusinessConnection(signal) { + return this.api.getBusinessConnection(orThrow(this.businessConnectionId, "getBusinessConnection"), signal); + } + /** + * Context-aware alias for `api.getFile`. Use this method to get basic info about a file and prepare it for downloading. For the moment, bots can download files of up to 20MB in size. On success, a File object is returned. The file can then be downloaded via the link https://api.telegram.org/file/bot/, where is taken from the response. It is guaranteed that the link will be valid for at least 1 hour. When the link expires, a new one can be requested by calling getFile again. + * + * Note: This function may not preserve the original file name and MIME type. You should save the file's MIME type and name (if available) when the File object is received. + * + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getfile + */ + getFile(signal) { + var _a, _b, _c, _d, _e, _f; + const m = orThrow(this.msg, "getFile"); + const file = m.photo !== undefined + ? m.photo[m.photo.length - 1] + : (_f = (_e = (_d = (_c = (_b = (_a = m.animation) !== null && _a !== void 0 ? _a : m.audio) !== null && _b !== void 0 ? _b : m.document) !== null && _c !== void 0 ? _c : m.video) !== null && _d !== void 0 ? _d : m.video_note) !== null && _e !== void 0 ? _e : m.voice) !== null && _f !== void 0 ? _f : m.sticker; + return this.api.getFile(orThrow(file, "getFile").file_id, signal); + } + /** @deprecated Use `banAuthor` instead. */ + kickAuthor(...args) { + return this.banAuthor(...args); + } + /** + * Context-aware alias for `api.banChatMember`. Use this method to ban a user in a group, a supergroup or a channel. In the case of supergroups and channels, the user will not be able to return to the chat on their own using invite links, etc., unless unbanned first. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success. + * + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#banchatmember + */ + banAuthor(other, signal) { + return this.api.banChatMember(orThrow(this.chatId, "banAuthor"), orThrow(this.from, "banAuthor").id, other, signal); + } + /** @deprecated Use `banChatMember` instead. */ + kickChatMember(...args) { + return this.banChatMember(...args); + } + /** + * Context-aware alias for `api.banChatMember`. Use this method to ban a user in a group, a supergroup or a channel. In the case of supergroups and channels, the user will not be able to return to the chat on their own using invite links, etc., unless unbanned first. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success. + * + * @param user_id Unique identifier of the target user + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#banchatmember + */ + banChatMember(user_id, other, signal) { + return this.api.banChatMember(orThrow(this.chatId, "banChatMember"), user_id, other, signal); + } + /** + * Context-aware alias for `api.unbanChatMember`. Use this method to unban a previously banned user in a supergroup or channel. The user will not return to the group or channel automatically, but will be able to join via link, etc. The bot must be an administrator for this to work. By default, this method guarantees that after the call the user is not a member of the chat, but will be able to join it. So if the user is a member of the chat they will also be removed from the chat. If you don't want this, use the parameter only_if_banned. Returns True on success. + * + * @param user_id Unique identifier of the target user + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#unbanchatmember + */ + unbanChatMember(user_id, other, signal) { + return this.api.unbanChatMember(orThrow(this.chatId, "unbanChatMember"), user_id, other, signal); + } + /** + * Context-aware alias for `api.restrictChatMember`. Use this method to restrict a user in a supergroup. The bot must be an administrator in the supergroup for this to work and must have the appropriate administrator rights. Pass True for all permissions to lift restrictions from a user. Returns True on success. + * + * @param permissions An object for new user permissions + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#restrictchatmember + */ + restrictAuthor(permissions, other, signal) { + return this.api.restrictChatMember(orThrow(this.chatId, "restrictAuthor"), orThrow(this.from, "restrictAuthor").id, permissions, other, signal); + } + /** + * Context-aware alias for `api.restrictChatMember`. Use this method to restrict a user in a supergroup. The bot must be an administrator in the supergroup for this to work and must have the appropriate administrator rights. Pass True for all permissions to lift restrictions from a user. Returns True on success. + * + * @param user_id Unique identifier of the target user + * @param permissions An object for new user permissions + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#restrictchatmember + */ + restrictChatMember(user_id, permissions, other, signal) { + return this.api.restrictChatMember(orThrow(this.chatId, "restrictChatMember"), user_id, permissions, other, signal); + } + /** + * Context-aware alias for `api.promoteChatMember`. Use this method to promote or demote a user in a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Pass False for all boolean parameters to demote a user. Returns True on success. + * + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#promotechatmember + */ + promoteAuthor(other, signal) { + return this.api.promoteChatMember(orThrow(this.chatId, "promoteAuthor"), orThrow(this.from, "promoteAuthor").id, other, signal); + } + /** + * Context-aware alias for `api.promoteChatMember`. Use this method to promote or demote a user in a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Pass False for all boolean parameters to demote a user. Returns True on success. + * + * @param user_id Unique identifier of the target user + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#promotechatmember + */ + promoteChatMember(user_id, other, signal) { + return this.api.promoteChatMember(orThrow(this.chatId, "promoteChatMember"), user_id, other, signal); + } + /** + * Context-aware alias for `api.setChatAdministratorCustomTitle`. Use this method to set a custom title for an administrator in a supergroup promoted by the bot. Returns True on success. + * + * @param custom_title New custom title for the administrator; 0-16 characters, emoji are not allowed + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setchatadministratorcustomtitle + */ + setChatAdministratorAuthorCustomTitle(custom_title, signal) { + return this.api.setChatAdministratorCustomTitle(orThrow(this.chatId, "setChatAdministratorAuthorCustomTitle"), orThrow(this.from, "setChatAdministratorAuthorCustomTitle").id, custom_title, signal); + } + /** + * Context-aware alias for `api.setChatAdministratorCustomTitle`. Use this method to set a custom title for an administrator in a supergroup promoted by the bot. Returns True on success. + * + * @param user_id Unique identifier of the target user + * @param custom_title New custom title for the administrator; 0-16 characters, emoji are not allowed + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setchatadministratorcustomtitle + */ + setChatAdministratorCustomTitle(user_id, custom_title, signal) { + return this.api.setChatAdministratorCustomTitle(orThrow(this.chatId, "setChatAdministratorCustomTitle"), user_id, custom_title, signal); + } + /** + * Context-aware alias for `api.banChatSenderChat`. Use this method to ban a channel chat in a supergroup or a channel. Until the chat is unbanned, the owner of the banned chat won't be able to send messages on behalf of any of their channels. The bot must be an administrator in the supergroup or channel for this to work and must have the appropriate administrator rights. Returns True on success. + * + * @param sender_chat_id Unique identifier of the target sender chat + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#banchatsenderchat + */ + banChatSenderChat(sender_chat_id, signal) { + return this.api.banChatSenderChat(orThrow(this.chatId, "banChatSenderChat"), sender_chat_id, signal); + } + /** + * Context-aware alias for `api.unbanChatSenderChat`. Use this method to unban a previously banned channel chat in a supergroup or channel. The bot must be an administrator for this to work and must have the appropriate administrator rights. Returns True on success. + * + * @param sender_chat_id Unique identifier of the target sender chat + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#unbanchatsenderchat + */ + unbanChatSenderChat(sender_chat_id, signal) { + return this.api.unbanChatSenderChat(orThrow(this.chatId, "unbanChatSenderChat"), sender_chat_id, signal); + } + /** + * Context-aware alias for `api.setChatPermissions`. Use this method to set default chat permissions for all members. The bot must be an administrator in the group or a supergroup for this to work and must have the can_restrict_members administrator rights. Returns True on success. + * + * @param permissions New default chat permissions + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setchatpermissions + */ + setChatPermissions(permissions, other, signal) { + return this.api.setChatPermissions(orThrow(this.chatId, "setChatPermissions"), permissions, other, signal); + } + /** + * Context-aware alias for `api.exportChatInviteLink`. Use this method to generate a new primary invite link for a chat; any previously generated primary link is revoked. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the new invite link as String on success. + * + * Note: Each administrator in a chat generates their own invite links. Bots can't use invite links generated by other administrators. If you want your bot to work with invite links, it will need to generate its own link using exportChatInviteLink or by calling the getChat method. If your bot needs to generate a new primary invite link replacing its previous one, use exportChatInviteLink again. + * + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#exportchatinvitelink + */ + exportChatInviteLink(signal) { + return this.api.exportChatInviteLink(orThrow(this.chatId, "exportChatInviteLink"), signal); + } + /** + * Context-aware alias for `api.createChatInviteLink`. Use this method to create an additional invite link for a chat. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. The link can be revoked using the method revokeChatInviteLink. Returns the new invite link as ChatInviteLink object. + * + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#createchatinvitelink + */ + createChatInviteLink(other, signal) { + return this.api.createChatInviteLink(orThrow(this.chatId, "createChatInviteLink"), other, signal); + } + /** + * Context-aware alias for `api.editChatInviteLink`. Use this method to edit a non-primary invite link created by the bot. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the edited invite link as a ChatInviteLink object. + * + * @param invite_link The invite link to edit + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#editchatinvitelink + */ + editChatInviteLink(invite_link, other, signal) { + return this.api.editChatInviteLink(orThrow(this.chatId, "editChatInviteLink"), invite_link, other, signal); + } + /** + * Context-aware alias for `api.createChatSubscriptionInviteLink`. Use this method to create a subscription invite link for a channel chat. The bot must have the can_invite_users administrator rights. The link can be edited using the method editChatSubscriptionInviteLink or revoked using the method revokeChatInviteLink. Returns the new invite link as a ChatInviteLink object. + * + * @param subscription_period The number of seconds the subscription will be active for before the next payment. Currently, it must always be 2592000 (30 days). + * @param subscription_price The amount of Telegram Stars a user must pay initially and after each subsequent subscription period to be a member of the chat; 1-2500 + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#createchatsubscriptioninvitelink + */ + createChatSubscriptionInviteLink(subscription_period, subscription_price, other, signal) { + return this.api.createChatSubscriptionInviteLink(orThrow(this.chatId, "createChatSubscriptionInviteLink"), subscription_period, subscription_price, other, signal); + } + /** + * Context-aware alias for `api.editChatSubscriptionInviteLink`. Use this method to edit a subscription invite link created by the bot. The bot must have the can_invite_users administrator rights. Returns the edited invite link as a ChatInviteLink object. + * + * @param invite_link The invite link to edit + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#editchatsubscriptioninvitelink + */ + editChatSubscriptionInviteLink(invite_link, other, signal) { + return this.api.editChatSubscriptionInviteLink(orThrow(this.chatId, "editChatSubscriptionInviteLink"), invite_link, other, signal); + } + /** + * Context-aware alias for `api.revokeChatInviteLink`. Use this method to revoke an invite link created by the bot. If the primary link is revoked, a new link is automatically generated. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the revoked invite link as ChatInviteLink object. + * + * @param invite_link The invite link to revoke + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#revokechatinvitelink + */ + revokeChatInviteLink(invite_link, signal) { + return this.api.revokeChatInviteLink(orThrow(this.chatId, "editChatInviteLink"), invite_link, signal); + } + /** + * Context-aware alias for `api.approveChatJoinRequest`. Use this method to approve a chat join request. The bot must be an administrator in the chat for this to work and must have the can_invite_users administrator right. Returns True on success. + * + * @param user_id Unique identifier of the target user + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#approvechatjoinrequest + */ + approveChatJoinRequest(user_id, signal) { + return this.api.approveChatJoinRequest(orThrow(this.chatId, "approveChatJoinRequest"), user_id, signal); + } + /** + * Context-aware alias for `api.declineChatJoinRequest`. Use this method to decline a chat join request. The bot must be an administrator in the chat for this to work and must have the can_invite_users administrator right. Returns True on success. + * + * @param user_id Unique identifier of the target user + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#declinechatjoinrequest + */ + declineChatJoinRequest(user_id, signal) { + return this.api.declineChatJoinRequest(orThrow(this.chatId, "declineChatJoinRequest"), user_id, signal); + } + /** + * Context-aware alias for `api.approveSuggestedPost`. Use this method to approve a suggested post in a direct messages chat. The bot must have the 'can_post_messages' administrator right in the corresponding channel chat. Returns True on success. + * + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#approvesuggestedpost + */ + approveSuggestedPost(other, signal) { + return this.api.approveSuggestedPost(orThrow(this.chatId, "approveSuggestedPost"), orThrow(this.msgId, "approveSuggestedPost"), other, signal); + } + /** + * Context-aware alias for `api.declineSuggestedPost`. Use this method to decline a suggested post in a direct messages chat. The bot must have the 'can_manage_direct_messages' administrator right in the corresponding channel chat. Returns True on success. + * + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#declinesuggestedpost + */ + declineSuggestedPost(other, signal) { + return this.api.declineSuggestedPost(orThrow(this.chatId, "declineSuggestedPost"), orThrow(this.msgId, "declineSuggestedPost"), other, signal); + } + /** + * Context-aware alias for `api.setChatPhoto`. Use this method to set a new profile photo for the chat. Photos can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success. + * + * @param photo New chat photo, uploaded using multipart/form-data + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setchatphoto + */ + setChatPhoto(photo, signal) { + return this.api.setChatPhoto(orThrow(this.chatId, "setChatPhoto"), photo, signal); + } + /** + * Context-aware alias for `api.deleteChatPhoto`. Use this method to delete a chat photo. Photos can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success. + * + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#deletechatphoto + */ + deleteChatPhoto(signal) { + return this.api.deleteChatPhoto(orThrow(this.chatId, "deleteChatPhoto"), signal); + } + /** + * Context-aware alias for `api.setChatTitle`. Use this method to change the title of a chat. Titles can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success. + * + * @param title New chat title, 1-255 characters + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setchattitle + */ + setChatTitle(title, signal) { + return this.api.setChatTitle(orThrow(this.chatId, "setChatTitle"), title, signal); + } + /** + * Context-aware alias for `api.setChatDescription`. Use this method to change the description of a group, a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success. + * + * @param description New chat description, 0-255 characters + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setchatdescription + */ + setChatDescription(description, signal) { + return this.api.setChatDescription(orThrow(this.chatId, "setChatDescription"), description, signal); + } + /** + * Context-aware alias for `api.pinChatMessage`. Use this method to add a message to the list of pinned messages in a chat. In private chats and channel direct messages chats, all non-service messages can be pinned. Conversely, the bot must be an administrator with the 'can_pin_messages' right or the 'can_edit_messages' right to pin messages in groups and channels respectively. Returns True on success. + * + * @param message_id Identifier of a message to pin + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#pinchatmessage + */ + pinChatMessage(message_id, other, signal) { + return this.api.pinChatMessage(orThrow(this.chatId, "pinChatMessage"), message_id, { business_connection_id: this.businessConnectionId, ...other }, signal); + } + /** + * Context-aware alias for `api.unpinChatMessage`. Use this method to remove a message from the list of pinned messages in a chat. In private chats and channel direct messages chats, all messages can be unpinned. Conversely, the bot must be an administrator with the 'can_pin_messages' right or the 'can_edit_messages' right to unpin messages in groups and channels respectively. Returns True on success. + * + * @param message_id Identifier of a message to unpin. If not specified, the most recent pinned message (by sending date) will be unpinned. + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#unpinchatmessage + */ + unpinChatMessage(message_id, other, signal) { + return this.api.unpinChatMessage(orThrow(this.chatId, "unpinChatMessage"), message_id, { business_connection_id: this.businessConnectionId, ...other }, signal); + } + /** + * Context-aware alias for `api.unpinAllChatMessages`. Use this method to clear the list of pinned messages in a chat. In private chats and channel direct messages chats, no additional rights are required to unpin all pinned messages. Conversely, the bot must be an administrator with the 'can_pin_messages' right or the 'can_edit_messages' right to unpin all pinned messages in groups and channels respectively. Returns True on success. + * + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#unpinallchatmessages + */ + unpinAllChatMessages(signal) { + return this.api.unpinAllChatMessages(orThrow(this.chatId, "unpinAllChatMessages"), signal); + } + /** + * Context-aware alias for `api.leaveChat`. Use this method for your bot to leave a group, supergroup or channel. Returns True on success. + * + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#leavechat + */ + leaveChat(signal) { + return this.api.leaveChat(orThrow(this.chatId, "leaveChat"), signal); + } + /** + * Context-aware alias for `api.getChat`. Use this method to get up to date information about the chat (current name of the user for one-on-one conversations, current username of a user, group or channel, etc.). Returns a Chat object on success. + * + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getchat + */ + getChat(signal) { + return this.api.getChat(orThrow(this.chatId, "getChat"), signal); + } + /** + * Context-aware alias for `api.getChatAdministrators`. Use this method to get a list of administrators in a chat, which aren't bots. Returns an Array of ChatMember objects. + * + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getchatadministrators + */ + getChatAdministrators(signal) { + return this.api.getChatAdministrators(orThrow(this.chatId, "getChatAdministrators"), signal); + } + /** @deprecated Use `getChatMemberCount` instead. */ + getChatMembersCount(...args) { + return this.getChatMemberCount(...args); + } + /** + * Context-aware alias for `api.getChatMemberCount`. Use this method to get the number of members in a chat. Returns Int on success. + * + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getchatmembercount + */ + getChatMemberCount(signal) { + return this.api.getChatMemberCount(orThrow(this.chatId, "getChatMemberCount"), signal); + } + /** + * Context-aware alias for `api.getChatMember`. Use this method to get information about a member of a chat. The method is guaranteed to work only if the bot is an administrator in the chat. Returns a ChatMember object on success. + * + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getchatmember + */ + getAuthor(signal) { + return this.api.getChatMember(orThrow(this.chatId, "getAuthor"), orThrow(this.from, "getAuthor").id, signal); + } + /** + * Context-aware alias for `api.getChatMember`. Use this method to get information about a member of a chat. The method is guaranteed to work only if the bot is an administrator in the chat. Returns a ChatMember object on success. + * + * @param user_id Unique identifier of the target user + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getchatmember + */ + getChatMember(user_id, signal) { + return this.api.getChatMember(orThrow(this.chatId, "getChatMember"), user_id, signal); + } + /** + * Context-aware alias for `api.setChatStickerSet`. Use this method to set a new group sticker set for a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Use the field can_set_sticker_set ly returned in getChat requests to check if the bot can use this method. Returns True on success. + * + * @param sticker_set_name Name of the sticker set to be set as the group sticker set + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setchatstickerset + */ + setChatStickerSet(sticker_set_name, signal) { + return this.api.setChatStickerSet(orThrow(this.chatId, "setChatStickerSet"), sticker_set_name, signal); + } + /** + * Context-aware alias for `api.deleteChatStickerSet`. Use this method to delete a group sticker set from a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Use the field can_set_sticker_set ly returned in getChat requests to check if the bot can use this method. Returns True on success. + * + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#deletechatstickerset + */ + deleteChatStickerSet(signal) { + return this.api.deleteChatStickerSet(orThrow(this.chatId, "deleteChatStickerSet"), signal); + } + /** + * Context-aware alias for `api.createForumTopic`. Use this method to create a topic in a forum supergroup chat or a private chat with a user. In the case of a supergroup chat the bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator right. Returns information about the created topic as a ForumTopic object. + * + * @param name Topic name, 1-128 characters + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#createforumtopic + */ + createForumTopic(name, other, signal) { + return this.api.createForumTopic(orThrow(this.chatId, "createForumTopic"), name, other, signal); + } + /** + * Context-aware alias for `api.editForumTopic`. Use this method to edit name and icon of a topic in a forum supergroup chat or a private chat with a user. In the case of a supergroup chat the bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights, unless it is the creator of the topic. Returns True on success. + * + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#editforumtopic + */ + editForumTopic(other, signal) { + const message = orThrow(this.msg, "editForumTopic"); + const thread = orThrow(message.message_thread_id, "editForumTopic"); + return this.api.editForumTopic(message.chat.id, thread, other, signal); + } + /** + * Context-aware alias for `api.closeForumTopic`. Use this method to close an open topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights, unless it is the creator of the topic. Returns True on success. + * + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#closeforumtopic + */ + closeForumTopic(signal) { + const message = orThrow(this.msg, "closeForumTopic"); + const thread = orThrow(message.message_thread_id, "closeForumTopic"); + return this.api.closeForumTopic(message.chat.id, thread, signal); + } + /** + * Context-aware alias for `api.reopenForumTopic`. Use this method to reopen a closed topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights, unless it is the creator of the topic. Returns True on success. + * + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#reopenforumtopic + */ + reopenForumTopic(signal) { + const message = orThrow(this.msg, "reopenForumTopic"); + const thread = orThrow(message.message_thread_id, "reopenForumTopic"); + return this.api.reopenForumTopic(message.chat.id, thread, signal); + } + /** + * Context-aware alias for `api.deleteForumTopic`. Use this method to delete a forum topic along with all its messages in a forum supergroup chat or a private chat with a user. In the case of a supergroup chat the bot must be an administrator in the chat for this to work and must have the can_delete_messages administrator rights. Returns True on success. + * + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#deleteforumtopic + */ + deleteForumTopic(signal) { + const message = orThrow(this.msg, "deleteForumTopic"); + const thread = orThrow(message.message_thread_id, "deleteForumTopic"); + return this.api.deleteForumTopic(message.chat.id, thread, signal); + } + /** + * Context-aware alias for `api.unpinAllForumTopicMessages`. Use this method to clear the list of pinned messages in a forum topic in a forum supergroup chat or a private chat with a user. In the case of a supergroup chat the bot must be an administrator in the chat for this to work and must have the can_pin_messages administrator right in the supergroup. Returns True on success. + * + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#unpinallforumtopicmessages + */ + unpinAllForumTopicMessages(signal) { + const message = orThrow(this.msg, "unpinAllForumTopicMessages"); + const thread = orThrow(message.message_thread_id, "unpinAllForumTopicMessages"); + return this.api.unpinAllForumTopicMessages(message.chat.id, thread, signal); + } + /** + * Context-aware alias for `api.editGeneralForumTopic`. Use this method to edit the name of the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. Returns True on success. + * + * @param name New topic name, 1-128 characters + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#editgeneralforumtopic + */ + editGeneralForumTopic(name, signal) { + return this.api.editGeneralForumTopic(orThrow(this.chatId, "editGeneralForumTopic"), name, signal); + } + /** + * Context-aware alias for `api.closeGeneralForumTopic`. Use this method to close an open 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. Returns True on success. + * + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#closegeneralforumtopic + */ + closeGeneralForumTopic(signal) { + return this.api.closeGeneralForumTopic(orThrow(this.chatId, "closeGeneralForumTopic"), signal); + } + /** + * Context-aware alias for `api.reopenGeneralForumTopic`. Use this method to reopen a closed 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. The topic will be automatically unhidden if it was hidden. Returns True on success. * + * + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#reopengeneralforumtopic + */ + reopenGeneralForumTopic(signal) { + return this.api.reopenGeneralForumTopic(orThrow(this.chatId, "reopenGeneralForumTopic"), signal); + } + /** + * Context-aware alias for `api.hideGeneralForumTopic`. Use this method to hide the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. The topic will be automatically closed if it was open. Returns True on success. + * + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#hidegeneralforumtopic + */ + hideGeneralForumTopic(signal) { + return this.api.hideGeneralForumTopic(orThrow(this.chatId, "hideGeneralForumTopic"), signal); + } + /** + * Context-aware alias for `api.unhideGeneralForumTopic`. Use this method to unhide the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. Returns True on success. + * + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#unhidegeneralforumtopic + */ + unhideGeneralForumTopic(signal) { + return this.api.unhideGeneralForumTopic(orThrow(this.chatId, "unhideGeneralForumTopic"), signal); + } + /** + * Context-aware alias for `api.unpinAllGeneralForumTopicMessages`. Use this method to clear the list of pinned messages in a General forum topic. The bot must be an administrator in the chat for this to work and must have the can_pin_messages administrator right in the supergroup. Returns True on success. + * + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#unpinallgeneralforumtopicmessages + */ + unpinAllGeneralForumTopicMessages(signal) { + return this.api.unpinAllGeneralForumTopicMessages(orThrow(this.chatId, "unpinAllGeneralForumTopicMessages"), signal); + } + /** + * Context-aware alias for `api.answerCallbackQuery`. Use this method to send answers to callback queries sent from inline keyboards. The answer will be displayed to the user as a notification at the top of the chat screen or as an alert. On success, True is returned. + * + * Alternatively, the user can be redirected to the specified Game URL. For this option to work, you must first create a game for your bot via @BotFather and accept the terms. Otherwise, you may use links like t.me/your_bot?start=XXXX that open your bot with a parameter. + * + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#answercallbackquery + */ + answerCallbackQuery(other, signal) { + return this.api.answerCallbackQuery(orThrow(this.callbackQuery, "answerCallbackQuery").id, typeof other === "string" ? { text: other } : other, signal); + } + /** + * Context-aware alias for `api.setChatMenuButton`. Use this method to change the bot's menu button in a private chat, or the default menu button. Returns True on success. + * + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setchatmenubutton + */ + setChatMenuButton(other, signal) { + return this.api.setChatMenuButton(other, signal); + } + /** + * Context-aware alias for `api.getChatMenuButton`. Use this method to get the current value of the bot's menu button in a private chat, or the default menu button. Returns MenuButton on success. + * + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getchatmenubutton + */ + getChatMenuButton(other, signal) { + return this.api.getChatMenuButton(other, signal); + } + /** + * Context-aware alias for `api.setMyDefaultAdministratorRights`. Use this method to the change the default administrator rights requested by the bot when it's added as an administrator to groups or channels. These rights will be suggested to users, but they are are free to modify the list before adding the bot. Returns True on success. + * + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setmydefaultadministratorrights + */ + setMyDefaultAdministratorRights(other, signal) { + return this.api.setMyDefaultAdministratorRights(other, signal); + } + /** + * Context-aware alias for `api.getMyDefaultAdministratorRights`. Use this method to get the current default administrator rights of the bot. Returns ChatAdministratorRights on success. + * + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + */ + getMyDefaultAdministratorRights(other, signal) { + return this.api.getMyDefaultAdministratorRights(other, signal); + } + /** + * Context-aware alias for `api.editMessageText`. Use this method to edit text and game messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent. + * + * @param text New text of the message, 1-4096 characters after entities parsing + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#editmessagetext + */ + editMessageText(text, other, signal) { + var _a, _b, _c, _d, _e; + const inlineId = this.inlineMessageId; + return inlineId !== undefined + ? this.api.editMessageTextInline(inlineId, text, { business_connection_id: this.businessConnectionId, ...other }, signal) + : this.api.editMessageText(orThrow(this.chatId, "editMessageText"), orThrow((_d = (_b = (_a = this.msg) === null || _a === void 0 ? void 0 : _a.message_id) !== null && _b !== void 0 ? _b : (_c = this.messageReaction) === null || _c === void 0 ? void 0 : _c.message_id) !== null && _d !== void 0 ? _d : (_e = this.messageReactionCount) === null || _e === void 0 ? void 0 : _e.message_id, "editMessageText"), text, { business_connection_id: this.businessConnectionId, ...other }, signal); + } + /** + * Context-aware alias for `api.editMessageCaption`. Use this method to edit captions of messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent. + * + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#editmessagecaption + */ + editMessageCaption(other, signal) { + var _a, _b, _c, _d, _e; + const inlineId = this.inlineMessageId; + return inlineId !== undefined + ? this.api.editMessageCaptionInline(inlineId, { business_connection_id: this.businessConnectionId, ...other }, signal) + : this.api.editMessageCaption(orThrow(this.chatId, "editMessageCaption"), orThrow((_d = (_b = (_a = this.msg) === null || _a === void 0 ? void 0 : _a.message_id) !== null && _b !== void 0 ? _b : (_c = this.messageReaction) === null || _c === void 0 ? void 0 : _c.message_id) !== null && _d !== void 0 ? _d : (_e = this.messageReactionCount) === null || _e === void 0 ? void 0 : _e.message_id, "editMessageCaption"), { business_connection_id: this.businessConnectionId, ...other }, signal); + } + /** + * Context-aware alias for `api.editMessageMedia`. Use this method to edit animation, audio, document, photo, or video messages, or to add media to text messages. If a message is part of a message album, then it can be edited only to an audio for audio albums, only to a document for document albums and to a photo or a video otherwise. When an inline message is edited, a new file can't be uploaded; use a previously uploaded file via its file_id or specify a URL. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent. + * + * @param media An object for a new media content of the message + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#editmessagemedia + */ + editMessageMedia(media, other, signal) { + var _a, _b, _c, _d, _e; + const inlineId = this.inlineMessageId; + return inlineId !== undefined + ? this.api.editMessageMediaInline(inlineId, media, { business_connection_id: this.businessConnectionId, ...other }, signal) + : this.api.editMessageMedia(orThrow(this.chatId, "editMessageMedia"), orThrow((_d = (_b = (_a = this.msg) === null || _a === void 0 ? void 0 : _a.message_id) !== null && _b !== void 0 ? _b : (_c = this.messageReaction) === null || _c === void 0 ? void 0 : _c.message_id) !== null && _d !== void 0 ? _d : (_e = this.messageReactionCount) === null || _e === void 0 ? void 0 : _e.message_id, "editMessageMedia"), media, { business_connection_id: this.businessConnectionId, ...other }, signal); + } + /** + * Context-aware alias for `api.editMessageReplyMarkup`. Use this method to edit only the reply markup of messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent. + * + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#editmessagereplymarkup + */ + editMessageReplyMarkup(other, signal) { + var _a, _b, _c, _d, _e; + const inlineId = this.inlineMessageId; + return inlineId !== undefined + ? this.api.editMessageReplyMarkupInline(inlineId, { business_connection_id: this.businessConnectionId, ...other }, signal) + : this.api.editMessageReplyMarkup(orThrow(this.chatId, "editMessageReplyMarkup"), orThrow((_d = (_b = (_a = this.msg) === null || _a === void 0 ? void 0 : _a.message_id) !== null && _b !== void 0 ? _b : (_c = this.messageReaction) === null || _c === void 0 ? void 0 : _c.message_id) !== null && _d !== void 0 ? _d : (_e = this.messageReactionCount) === null || _e === void 0 ? void 0 : _e.message_id, "editMessageReplyMarkup"), { business_connection_id: this.businessConnectionId, ...other }, signal); + } + /** + * Context-aware alias for `api.stopPoll`. Use this method to stop a poll which was sent by the bot. On success, the stopped Poll is returned. + * + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#stoppoll + */ + stopPoll(other, signal) { + var _a, _b, _c, _d, _e; + return this.api.stopPoll(orThrow(this.chatId, "stopPoll"), orThrow((_d = (_b = (_a = this.msg) === null || _a === void 0 ? void 0 : _a.message_id) !== null && _b !== void 0 ? _b : (_c = this.messageReaction) === null || _c === void 0 ? void 0 : _c.message_id) !== null && _d !== void 0 ? _d : (_e = this.messageReactionCount) === null || _e === void 0 ? void 0 : _e.message_id, "stopPoll"), { business_connection_id: this.businessConnectionId, ...other }, signal); + } + /** + * Context-aware alias for `api.deleteMessage`. Use this method to delete a message, including service messages, with the following limitations: + * - A message can only be deleted if it was sent less than 48 hours ago. + * - A dice message in a private chat can only be deleted if it was sent more than 24 hours ago. + * - Bots can delete outgoing messages in private chats, groups, and supergroups. + * - Bots can delete incoming messages in private chats. + * - Bots granted can_post_messages permissions can delete outgoing messages in channels. + * - If the bot is an administrator of a group, it can delete any message there. + * - If the bot has can_delete_messages administrator right in a supergroup or a channel, it can delete any message there. + * - If the bot has can_manage_direct_messages administrator right in a channel, it can delete any message in the corresponding direct messages chat. + * Returns True on success. + * + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#deletemessage + */ + deleteMessage(signal) { + var _a, _b, _c, _d, _e; + return this.api.deleteMessage(orThrow(this.chatId, "deleteMessage"), orThrow((_d = (_b = (_a = this.msg) === null || _a === void 0 ? void 0 : _a.message_id) !== null && _b !== void 0 ? _b : (_c = this.messageReaction) === null || _c === void 0 ? void 0 : _c.message_id) !== null && _d !== void 0 ? _d : (_e = this.messageReactionCount) === null || _e === void 0 ? void 0 : _e.message_id, "deleteMessage"), signal); + } + /** + * Context-aware alias for `api.deleteMessages`. Use this method to delete multiple messages simultaneously. Returns True on success. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param message_ids A list of 1-100 identifiers of messages to delete. See deleteMessage for limitations on which messages can be deleted + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#deletemessages + */ + deleteMessages(message_ids, signal) { + return this.api.deleteMessages(orThrow(this.chatId, "deleteMessages"), message_ids, signal); + } + /** + * Context-aware alias for `api.deleteBusinessMessages`. Delete messages on behalf of a business account. Requires the can_delete_outgoing_messages business bot right to delete messages sent by the bot itself, or the can_delete_all_messages business bot right to delete any message. Returns True on success. + * + * @param message_ids A list of 1-100 identifiers of messages to delete. All messages must be from the same chat. See deleteMessage for limitations on which messages can be deleted + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#deletebusinessmessages + */ + deleteBusinessMessages(message_ids, signal) { + return this.api.deleteBusinessMessages(orThrow(this.businessConnectionId, "deleteBusinessMessages"), message_ids, signal); + } + /** + * Context-aware alias for `api.setBusinessAccountName`. Changes the first and last name of a managed business account. Requires the can_change_name business bot right. Returns True on success. + * + * @param first_name The new value of the first name for the business account; 1-64 characters + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setbusinessaccountname + */ + setBusinessAccountName(first_name, other, signal) { + return this.api.setBusinessAccountName(orThrow(this.businessConnectionId, "setBusinessAccountName"), first_name, other, signal); + } + /** + * Context-aware alias for `api.setBusinessAccountUsername`. Changes the username of a managed business account. Requires the can_change_username business bot right. Returns True on success. + * + * @param username The new value of the username for the business account; 0-32 characters + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setbusinessaccountusername + */ + setBusinessAccountUsername(username, signal) { + return this.api.setBusinessAccountUsername(orThrow(this.businessConnectionId, "setBusinessAccountUsername"), username, signal); + } + /** + * Context-aware alias for `api.setBusinessAccountBio`. Changes the bio of a managed business account. Requires the can_change_bio business bot right. Returns True on success. + * + * @param bio The new value of the bio for the business account; 0-140 characters + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setbusinessaccountbio + */ + setBusinessAccountBio(bio, signal) { + return this.api.setBusinessAccountBio(orThrow(this.businessConnectionId, "setBusinessAccountBio"), bio, signal); + } + /** + * Context-aware alias for `api.setBusinessAccountProfilePhoto`. CsetBusinessAccountProfilePhotohanges the profile photo of a managed business account. Requires the can_edit_profile_photo business bot right. Returns True on success. + * + * @param photo The new profile photo to set + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setbusinessaccountprofilephoto + */ + setBusinessAccountProfilePhoto(photo, other, signal) { + return this.api.setBusinessAccountProfilePhoto(orThrow(this.businessConnectionId, "setBusinessAccountProfilePhoto"), photo, other, signal); + } + /** + * Context-aware alias for `api.removeBusinessAccountProfilePhoto`. Removes the current profile photo of a managed business account. Requires the can_edit_profile_photo business bot right. Returns True on success. + * + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#removebusinessaccountprofilephoto + */ + removeBusinessAccountProfilePhoto(other, signal) { + return this.api.removeBusinessAccountProfilePhoto(orThrow(this.businessConnectionId, "removeBusinessAccountProfilePhoto"), other, signal); + } + /** + * Context-aware alias for `api.setBusinessAccountGiftSettings`. Changes the privacy settings pertaining to incoming gifts in a managed business account. Requires the can_change_gift_settings business bot right. Returns True on success. + * + * @param show_gift_button Pass True, if a button for sending a gift to the user or by the business account must always be shown in the input field + * @param accepted_gift_types Types of gifts accepted by the business account + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setbusinessaccountgiftsettings + */ + setBusinessAccountGiftSettings(show_gift_button, accepted_gift_types, signal) { + return this.api.setBusinessAccountGiftSettings(orThrow(this.businessConnectionId, "setBusinessAccountGiftSettings"), show_gift_button, accepted_gift_types, signal); + } + /** + * Context-aware alias for `api.getBusinessAccountStarBalance`. Returns the amount of Telegram Stars owned by a managed business account. Requires the can_view_gifts_and_stars business bot right. Returns StarAmount on success. + * + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getbusinessaccountstarbalance + */ + getBusinessAccountStarBalance(signal) { + return this.api.getBusinessAccountStarBalance(orThrow(this.businessConnectionId, "getBusinessAccountStarBalance"), signal); + } + /** + * Context-aware alias for `api.transferBusinessAccountStars`. Transfers Telegram Stars from the business account balance to the bot's balance. Requires the can_transfer_stars business bot right. Returns True on success. + * + * @param star_count Number of Telegram Stars to transfer; 1-10000 + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#transferbusinessaccountstars + */ + transferBusinessAccountStars(star_count, signal) { + return this.api.transferBusinessAccountStars(orThrow(this.businessConnectionId, "transferBusinessAccountStars"), star_count, signal); + } + /** + * Context-aware alias for `api.getBusinessAccountGifts`. Returns the gifts received and owned by a managed business account. Requires the can_view_gifts_and_stars business bot right. Returns OwnedGifts on success. + * + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getbusinessaccountgifts + */ + getBusinessAccountGifts(other, signal) { + return this.api.getBusinessAccountGifts(orThrow(this.businessConnectionId, "getBusinessAccountGifts"), other, signal); + } + /** + * Context-aware alias for `api.convertGiftToStars`. Converts a given regular gift to Telegram Stars. Requires the can_convert_gifts_to_stars business bot right. Returns True on success. + * + * @param owned_gift_id Unique identifier of the regular gift that should be converted to Telegram Stars + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#convertgifttostars + */ + convertGiftToStars(owned_gift_id, signal) { + return this.api.convertGiftToStars(orThrow(this.businessConnectionId, "convertGiftToStars"), owned_gift_id, signal); + } + /** + * Context-aware alias for `api.upgradeGift`. Upgrades a given regular gift to a unique gift. Requires the can_transfer_and_upgrade_gifts business bot right. Additionally requires the can_transfer_stars business bot right if the upgrade is paid. Returns True on success. + * + * @param owned_gift_id Unique identifier of the regular gift that should be upgraded to a unique one + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#upgradegift + */ + upgradeGift(owned_gift_id, other, signal) { + return this.api.upgradeGift(orThrow(this.businessConnectionId, "upgradeGift"), owned_gift_id, other, signal); + } + /** + * Context-aware alias for `api.transferGift`. Transfers an owned unique gift to another user. Requires the can_transfer_and_upgrade_gifts business bot right. Requires can_transfer_stars business bot right if the transfer is paid. Returns True on success. + * + * @param owned_gift_id Unique identifier of the regular gift that should be transferred + * @param new_owner_chat_id Unique identifier of the chat which will own the gift. The chat must be active in the last 24 hours. + * @param star_count The amount of Telegram Stars that will be paid for the transfer from the business account balance. If positive, then the can_transfer_stars business bot right is required. + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#transfergift + */ + transferGift(owned_gift_id, new_owner_chat_id, star_count, signal) { + return this.api.transferGift(orThrow(this.businessConnectionId, "transferGift"), owned_gift_id, new_owner_chat_id, star_count, signal); + } + /** + * Context-aware alias for `api.postStory`. Posts a story on behalf of a managed business account. Requires the can_manage_stories business bot right. Returns Story on success. + * + * @param content Content of the story + * @param active_period Period after which the story is moved to the archive, in seconds; must be one of 6 * 3600, 12 * 3600, 86400, or 2 * 86400 + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#poststory + */ + postStory(content, active_period, other, signal) { + return this.api.postStory(orThrow(this.businessConnectionId, "postStory"), content, active_period, other, signal); + } + /** + * Context-aware alias for `api.repostStory`. Reposts a story on behalf of a business account from another business account. Both business accounts must be managed by the same bot, and the story on the source account must have been posted (or reposted) by the bot. Requires the can_manage_stories business bot right for both business accounts. Returns Story on success. + * + * @param active_period Period after which the story is moved to the archive, in seconds; must be one of 6 * 3600, 12 * 3600, 86400, or 2 * 86400 + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#repoststory + */ + repostStory(active_period, other, signal) { + var _a; + const story = orThrow((_a = this.msg) === null || _a === void 0 ? void 0 : _a.story, "repostStory"); + return this.api.repostStory(orThrow(this.businessConnectionId, "repostStory"), story.chat.id, story.id, active_period, other, signal); + } + /** + * Context-aware alias for `api.editStory`. Edits a story previously posted by the bot on behalf of a managed business account. Requires the can_manage_stories business bot right. Returns Story on success. + * + * @param story_id Unique identifier of the story to edit + * @param content Content of the story + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#editstory + */ + editStory(story_id, content, other, signal) { + return this.api.editStory(orThrow(this.businessConnectionId, "editStory"), story_id, content, other, signal); + } + /** + * Context-aware alias for `api.deleteStory`. Deletes a story previously posted by the bot on behalf of a managed business account. Requires the can_manage_stories business bot right. Returns True on success. + * + * @param story_id Unique identifier of the story to delete + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#deletestory + */ + deleteStory(story_id, signal) { + return this.api.deleteStory(orThrow(this.businessConnectionId, "deleteStory"), story_id, signal); + } + /** + * Context-aware alias for `api.sendSticker`. Use this method to send static .WEBP, animated .TGS, or video .WEBM stickers. On success, the sent Message is returned. + * + * @param sticker Sticker to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a .WEBP sticker from the Internet, or upload a new .WEBP, .TGS, or .WEBM sticker using multipart/form-data. Video and animated stickers can't be sent via an HTTP URL. + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendsticker + */ + replyWithSticker(sticker, other, signal) { + var _a; + const msg = this.msg; + return this.api.sendSticker(orThrow(this.chatId, "sendSticker"), sticker, { + business_connection_id: this.businessConnectionId, + ...((msg === null || msg === void 0 ? void 0 : msg.is_topic_message) + ? { message_thread_id: msg.message_thread_id } + : {}), + direct_messages_topic_id: (_a = msg === null || msg === void 0 ? void 0 : msg.direct_messages_topic) === null || _a === void 0 ? void 0 : _a.topic_id, + ...other, + }, signal); + } + /** + * Use this method to get information about custom emoji stickers by their identifiers. Returns an Array of Sticker objects. + * + * @param custom_emoji_ids A list of custom emoji identifiers + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getcustomemojistickers + */ + getCustomEmojiStickers(signal) { + var _a, _b; + return this.api.getCustomEmojiStickers(((_b = (_a = this.msg) === null || _a === void 0 ? void 0 : _a.entities) !== null && _b !== void 0 ? _b : []) + .filter((e) => e.type === "custom_emoji") + .map((e) => e.custom_emoji_id), signal); + } + /** + * Context-aware alias for `api.sendGift`. Sends a gift to the given user. The gift can't be converted to Telegram Stars by the receiver. Returns True on success. + * + * @param gift_id Identifier of the gift + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendgift + */ + replyWithGift(gift_id, other, signal) { + return this.api.sendGift(orThrow(this.from, "sendGift").id, gift_id, other, signal); + } + /** + * Context-aware alias for `api.giftPremiumSubscription`. Gifts a Telegram Premium subscription to the given user. Returns True on success. + * + * @param month_count Number of months the Telegram Premium subscription will be active for the user; must be one of 3, 6, or 12 + * @param star_count Number of Telegram Stars to pay for the Telegram Premium subscription; must be 1000 for 3 months, 1500 for 6 months, and 2500 for 12 months + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#giftpremiumsubscription + */ + giftPremiumSubscription(month_count, star_count, other, signal) { + return this.api.giftPremiumSubscription(orThrow(this.from, "giftPremiumSubscription").id, month_count, star_count, other, signal); + } + /** + * Context-aware alias for `api.sendGift`. Sends a gift to the given channel chat. The gift can't be converted to Telegram Stars by the receiver. Returns True on success. + * + * @param gift_id Identifier of the gift + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendgift + */ + replyWithGiftToChannel(gift_id, other, signal) { + return this.api.sendGiftToChannel(orThrow(this.chat, "sendGift").id, gift_id, other, signal); + } + /** + * Context-aware alias for `api.answerInlineQuery`. Use this method to send answers to an inline query. On success, True is returned. + * No more than 50 results per query are allowed. + * + * Example: An inline bot that sends YouTube videos can ask the user to connect the bot to their YouTube account to adapt search results accordingly. To do this, it displays a 'Connect your YouTube account' button above the results, or even before showing any. The user presses the button, switches to a private chat with the bot and, in doing so, passes a start parameter that instructs the bot to return an OAuth link. Once done, the bot can offer a switch_inline button so that the user can easily return to the chat where they wanted to use the bot's inline capabilities. + * + * @param results An array of results for the inline query + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#answerinlinequery + */ + answerInlineQuery(results, other, signal) { + return this.api.answerInlineQuery(orThrow(this.inlineQuery, "answerInlineQuery").id, results, other, signal); + } + /** + * Context-aware alias for `api.savePreparedInlineMessage`. Stores a message that can be sent by a user of a Mini App. Returns a PreparedInlineMessage object. + * + * @param result An object describing the message to be sent + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#savepreparedinlinemessage + */ + savePreparedInlineMessage(result, other, signal) { + return this.api.savePreparedInlineMessage(orThrow(this.from, "savePreparedInlineMessage").id, result, other, signal); + } + /** + * Context-aware alias for `api.sendInvoice`. Use this method to send invoices. On success, the sent Message is returned. + * + * @param title Product name, 1-32 characters + * @param description Product description, 1-255 characters + * @param payload Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes. + * @param currency Three-letter ISO 4217 currency code, see more on currencies + * @param prices Price breakdown, a list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.) + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendinvoice + */ + replyWithInvoice(title, description, payload, currency, prices, other, signal) { + var _a; + const msg = this.msg; + return this.api.sendInvoice(orThrow(this.chatId, "sendInvoice"), title, description, payload, currency, prices, { + ...((msg === null || msg === void 0 ? void 0 : msg.is_topic_message) + ? { message_thread_id: msg.message_thread_id } + : {}), + direct_messages_topic_id: (_a = msg === null || msg === void 0 ? void 0 : msg.direct_messages_topic) === null || _a === void 0 ? void 0 : _a.topic_id, + ...other, + }, signal); + } + /** + * Context-aware alias for `api.answerShippingQuery`. If you sent an invoice requesting a shipping address and the parameter is_flexible was specified, the Bot API will send an Update with a shipping_query field to the bot. Use this method to reply to shipping queries. On success, True is returned. + * + * @param shipping_query_id Unique identifier for the query to be answered + * @param ok Pass True if delivery to the specified address is possible and False if there are any problems (for example, if delivery to the specified address is not possible) + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#answershippingquery + */ + answerShippingQuery(ok, other, signal) { + return this.api.answerShippingQuery(orThrow(this.shippingQuery, "answerShippingQuery").id, ok, other, signal); + } + /** + * Context-aware alias for `api.answerPreCheckoutQuery`. Once the user has confirmed their payment and shipping details, the Bot API sends the final confirmation in the form of an Update with the field pre_checkout_query. Use this method to respond to such pre-checkout queries. On success, True is returned. Note: The Bot API must receive an answer within 10 seconds after the pre-checkout query was sent. + * + * @param ok Specify True if everything is alright (goods are available, etc.) and the bot is ready to proceed with the order. Use False if there are any problems. + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#answerprecheckoutquery + */ + answerPreCheckoutQuery(ok, other, signal) { + return this.api.answerPreCheckoutQuery(orThrow(this.preCheckoutQuery, "answerPreCheckoutQuery").id, ok, typeof other === "string" ? { error_message: other } : other, signal); + } + /** + * Context-aware alias for `api.refundStarPayment`. Refunds a successful payment in Telegram Stars. + * + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#refundstarpayment + */ + refundStarPayment(signal) { + var _a; + return this.api.refundStarPayment(orThrow(this.from, "refundStarPayment").id, orThrow((_a = this.msg) === null || _a === void 0 ? void 0 : _a.successful_payment, "refundStarPayment") + .telegram_payment_charge_id, signal); + } + /** + * Context-aware alias for `api.editUserStarSubscription`. Allows the bot to cancel or re-enable extension of a subscription paid in Telegram Stars. Returns True on success. + * + * @param telegram_payment_charge_id Telegram payment identifier for the subscription + * @param is_canceled Pass True to cancel extension of the user subscription; the subscription must be active up to the end of the current subscription period. Pass False to allow the user to re-enable a subscription that was previously canceled by the bot. + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#edituserstarsubscription + */ + editUserStarSubscription(telegram_payment_charge_id, is_canceled, signal) { + return this.api.editUserStarSubscription(orThrow(this.from, "editUserStarSubscription").id, telegram_payment_charge_id, is_canceled, signal); + } + /** + * Context-aware alias for `api.verifyUser`. Verifies a user on behalf of the organization which is represented by the bot. Returns True on success. + * + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#verifyuser + */ + verifyUser(other, signal) { + return this.api.verifyUser(orThrow(this.from, "verifyUser").id, other, signal); + } + /** + * Context-aware alias for `api.verifyChat`. Verifies a chat on behalf of the organization which is represented by the bot. Returns True on success. + * + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#verifychat + */ + verifyChat(other, signal) { + return this.api.verifyChat(orThrow(this.chatId, "verifyChat"), other, signal); + } + /** + * Context-aware alias for `api.removeUserVerification`. Removes verification from a user who is currently verified on behalf of the organization represented by the bot. Returns True on success. + * + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#removeuserverification + */ + removeUserVerification(signal) { + return this.api.removeUserVerification(orThrow(this.from, "removeUserVerification").id, signal); + } + /** + * Context-aware alias for `api.removeChatVerification`. Removes verification from a chat that is currently verified on behalf of the organization represented by the bot. Returns True on success. + * + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#removechatverification + */ + removeChatVerification(signal) { + return this.api.removeChatVerification(orThrow(this.chatId, "removeChatVerification"), signal); + } + /** + * Context-aware alias for `api.readBusinessMessage`. Marks incoming message as read on behalf of a business account. Requires the can_read_messages business bot right. Returns True on success. + * + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#readbusinessmessage + */ + readBusinessMessage(signal) { + return this.api.readBusinessMessage(orThrow(this.businessConnectionId, "readBusinessMessage"), orThrow(this.chatId, "readBusinessMessage"), orThrow(this.msgId, "readBusinessMessage"), signal); + } + /** + * Context-aware alias for `api.setPassportDataErrors`. Informs a user that some of the Telegram Passport elements they provided contains errors. The user will not be able to re-submit their Passport to you until the errors are fixed (the contents of the field for which you returned the error must change). Returns True on success. + * + * Use this if the data submitted by the user doesn't satisfy the standards your service requires for any reason. For example, if a birthday date seems invalid, a submitted document is blurry, a scan shows evidence of tampering, etc. Supply some details in the error message to make sure the user knows how to correct the issues. + * + * @param errors An array describing the errors + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setpassportdataerrors + */ + setPassportDataErrors(errors, signal) { + return this.api.setPassportDataErrors(orThrow(this.from, "setPassportDataErrors").id, errors, signal); + } + /** + * Context-aware alias for `api.sendGame`. Use this method to send a game. On success, the sent Message is returned. + * + * @param game_short_name Short name of the game, serves as the unique identifier for the game. Set up your games via BotFather. + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendgame + */ + replyWithGame(game_short_name, other, signal) { + const msg = this.msg; + return this.api.sendGame(orThrow(this.chatId, "sendGame"), game_short_name, { + business_connection_id: this.businessConnectionId, + ...((msg === null || msg === void 0 ? void 0 : msg.is_topic_message) + ? { message_thread_id: msg.message_thread_id } + : {}), + ...other, + }, signal); + } +} +exports.Context = Context; +// PROBING SHORTCUTS +/** + * `Context.has` is an object that contains a number of useful functions for + * probing context objects. Each of these functions can generate a predicate + * function, to which you can pass context objects in order to check if a + * condition holds for the respective context object. + * + * For example, you can call `Context.has.filterQuery(":text")` to generate + * a predicate function that tests context objects for containing text: + * ```ts + * const hasText = Context.has.filterQuery(":text"); + * + * if (hasText(ctx0)) {} // `ctx0` matches the filter query `:text` + * if (hasText(ctx1)) {} // `ctx1` matches the filter query `:text` + * if (hasText(ctx2)) {} // `ctx2` matches the filter query `:text` + * ``` + * These predicate functions are used internally by the has-methods that are + * installed on every context object. This means that calling + * `ctx.has(":text")` is equivalent to + * `Context.has.filterQuery(":text")(ctx)`. + */ +Context.has = checker; +// === Util functions +function orThrow(value, method) { + if (value === undefined) { + throw new Error(`Missing information for API call to ${method}`); + } + return value; +} +function triggerFn(trigger) { + return toArray(trigger).map((t) => typeof t === "string" + ? (txt) => (txt === t ? t : null) + : (txt) => txt.match(t)); +} +function match(ctx, content, triggers) { + for (const t of triggers) { + const res = t(content); + if (res) { + ctx.match = res; + return true; + } + } + return false; +} +function toArray(e) { + return Array.isArray(e) ? e : [e]; +} diff --git a/sandbox/tgbot/node_modules/grammy/out/convenience/constants.d.ts b/sandbox/tgbot/node_modules/grammy/out/convenience/constants.d.ts new file mode 100644 index 0000000..6826e74 --- /dev/null +++ b/sandbox/tgbot/node_modules/grammy/out/convenience/constants.d.ts @@ -0,0 +1,98 @@ +import { DEFAULT_UPDATE_TYPES } from "../bot.js"; +declare const ALL_UPDATE_TYPES: readonly ["message", "edited_message", "channel_post", "edited_channel_post", "business_connection", "business_message", "edited_business_message", "deleted_business_messages", "inline_query", "chosen_inline_result", "callback_query", "shipping_query", "pre_checkout_query", "purchased_paid_media", "poll", "poll_answer", "my_chat_member", "chat_join_request", "chat_boost", "removed_chat_boost", "chat_member", "message_reaction", "message_reaction_count"]; +declare const ALL_CHAT_PERMISSIONS: { + readonly is_anonymous: true; + readonly can_manage_chat: true; + readonly can_delete_messages: true; + readonly can_manage_video_chats: true; + readonly can_restrict_members: true; + readonly can_promote_members: true; + readonly can_change_info: true; + readonly can_invite_users: true; + readonly can_post_stories: true; + readonly can_edit_stories: true; + readonly can_delete_stories: true; + readonly can_post_messages: true; + readonly can_edit_messages: true; + readonly can_pin_messages: true; + readonly can_manage_topics: true; +}; +/** + * Types of the constants used in the Telegram Bot API. Currently holds all + * available update types as well as all chat permissions. + */ +export interface ApiConstants { + /** + * List of update types a bot receives by default. Useful if you want to + * receive all update types but `chat_member`, `message_reaction`, and + * `message_reaction_count`. + * + * ```ts + * // Built-in polling: + * bot.start({ allowed_updates: DEFAULT_UPDATE_TYPES }); + * // grammY runner: + * run(bot, { runner: { fetch: { allowed_updates: DEFAULT_UPDATE_TYPES } } }); + * // Webhooks: + * await bot.api.setWebhook(url, { allowed_updates: DEFAULT_UPDATE_TYPES }); + * ``` + * + * See the [Bot API reference](https://core.telegram.org/bots/api#update) + * for more information. + */ + DEFAULT_UPDATE_TYPES: typeof DEFAULT_UPDATE_TYPES[number]; + /** + * List of all available update types. Useful if you want to receive all + * updates from the Bot API, rather than just those that are delivered by + * default. + * + * The main use case for this is when you want to receive `chat_member`, + * `message_reaction`, and `message_reaction_count` updates, as they need to + * be enabled first. Use it like so: + * + * ```ts + * // Built-in polling: + * bot.start({ allowed_updates: ALL_UPDATE_TYPES }); + * // grammY runner: + * run(bot, { runner: { fetch: { allowed_updates: ALL_UPDATE_TYPES } } }); + * // Webhooks: + * await bot.api.setWebhook(url, { allowed_updates: ALL_UPDATE_TYPES }); + * ``` + * + * See the [Bot API reference](https://core.telegram.org/bots/api#update) + * for more information. + */ + ALL_UPDATE_TYPES: typeof ALL_UPDATE_TYPES[number]; + /** + * An object containing all available chat permissions. Useful if you want + * to lift restrictions from a user, as this action requires you to pass + * `true` for all permissions. Use it like so: + * + * ```ts + * // On `Bot`: + * await bot.api.restrictChatMember(chat_id, user_id, ALL_CHAT_PERMISSIONS); + * // On `Api`: + * await ctx.api.restrictChatMember(chat_id, user_id, ALL_CHAT_PERMISSIONS); + * // On `Context`: + * await ctx.restrictChatMember(user_id, ALL_CHAT_PERMISSIONS); + * await ctx.restrictAuthor(ALL_CHAT_PERMISSIONS); + * ``` + * + * See the [Bot API reference](https://core.telegram.org/bots/api#update) + * for more information. + */ + ALL_CHAT_PERMISSIONS: keyof typeof ALL_CHAT_PERMISSIONS; +} +interface TypeOf { + DEFAULT_UPDATE_TYPES: typeof DEFAULT_UPDATE_TYPES; + ALL_UPDATE_TYPES: typeof ALL_UPDATE_TYPES; + ALL_CHAT_PERMISSIONS: typeof ALL_CHAT_PERMISSIONS; +} +type ValuesFor = { + [K in keyof T]: K extends keyof TypeOf ? Readonly : never; +}; +/** + * A container for constants used in the Telegram Bot API. Currently holds all + * available update types as well as all chat permissions. + */ +export declare const API_CONSTANTS: ValuesFor; +export {}; diff --git a/sandbox/tgbot/node_modules/grammy/out/convenience/constants.js b/sandbox/tgbot/node_modules/grammy/out/convenience/constants.js new file mode 100644 index 0000000..02528de --- /dev/null +++ b/sandbox/tgbot/node_modules/grammy/out/convenience/constants.js @@ -0,0 +1,37 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.API_CONSTANTS = void 0; +const bot_js_1 = require("../bot.js"); +const ALL_UPDATE_TYPES = [ + ...bot_js_1.DEFAULT_UPDATE_TYPES, + "chat_member", + "message_reaction", + "message_reaction_count", +]; +const ALL_CHAT_PERMISSIONS = { + is_anonymous: true, + can_manage_chat: true, + can_delete_messages: true, + can_manage_video_chats: true, + can_restrict_members: true, + can_promote_members: true, + can_change_info: true, + can_invite_users: true, + can_post_stories: true, + can_edit_stories: true, + can_delete_stories: true, + can_post_messages: true, + can_edit_messages: true, + can_pin_messages: true, + can_manage_topics: true, +}; +/** + * A container for constants used in the Telegram Bot API. Currently holds all + * available update types as well as all chat permissions. + */ +exports.API_CONSTANTS = { + DEFAULT_UPDATE_TYPES: bot_js_1.DEFAULT_UPDATE_TYPES, + ALL_UPDATE_TYPES, + ALL_CHAT_PERMISSIONS, +}; +Object.freeze(exports.API_CONSTANTS); diff --git a/sandbox/tgbot/node_modules/grammy/out/convenience/frameworks.d.ts b/sandbox/tgbot/node_modules/grammy/out/convenience/frameworks.d.ts new file mode 100644 index 0000000..4eb2db8 --- /dev/null +++ b/sandbox/tgbot/node_modules/grammy/out/convenience/frameworks.d.ts @@ -0,0 +1,226 @@ +import { type Update } from "../types.js"; +type MaybePromise = T | Promise; +/** + * Abstraction over a request-response cycle, providing access to the update, as + * well as a mechanism for responding to the request and to end it. + */ +export interface ReqResHandler { + /** + * The update object sent from Telegram, usually resolves the request's JSON + * body + */ + update: MaybePromise; + /** + * X-Telegram-Bot-Api-Secret-Token header of the request, or undefined if + * not present + */ + header?: string; + /** + * Ends the request immediately without body, called after every request + * unless a webhook reply was performed + */ + end?: () => void; + /** + * Sends the specified JSON as a payload in the body, used for webhook + * replies + */ + respond: (json: string) => unknown | Promise; + /** + * Responds that the request is unauthorized due to mismatching + * X-Telegram-Bot-Api-Secret-Token headers + */ + unauthorized: () => unknown | Promise; + /** + * Some frameworks (e.g. Deno's std/http `listenAndServe`) assume that + * handler returns something + */ + handlerReturn?: Promise; +} +/** + * Middleware for a web framework. Creates a request-response handler for a + * request. The handler will be used to integrate with the compatible framework. + */ +export type FrameworkAdapter = (...args: any[]) => ReqResHandler; +export type LambdaAdapter = (event: { + body?: string; + headers: Record; +}, _context: unknown, callback: (arg0: unknown, arg1: Record) => Promise) => ReqResHandler; +export type LambdaAsyncAdapter = (event: { + body?: string; + headers: Record; +}, _context: unknown) => ReqResHandler; +export type AzureAdapter = (context: { + res?: { + [key: string]: any; + }; +}, request: { + body?: unknown; +}) => ReqResHandler; +export type AzureAdapterV4 = (request: { + headers: { + get(name: string): string | null; + }; + json(): Promise; +}) => ReqResHandler<{ + status: number; + body?: string; +} | { + jsonBody: string; +}>; +export type BunAdapter = (request: { + headers: Headers; + json: () => Promise; +}) => ReqResHandler; +export type CloudflareAdapter = (event: { + request: Body & { + method: string; + url: string; + headers: Headers; + }; + respondWith: (response: Promise) => void; +}) => ReqResHandler; +export type CloudflareModuleAdapter = (request: Body & { + method: string; + url: string; + headers: Headers; +}) => ReqResHandler; +export type ElysiaAdapter = (ctx: { + body: unknown; + headers: Record; + set: { + headers: Record; + status?: string | number; + }; +}) => ReqResHandler; +export type ExpressAdapter = (req: { + body: Update; + header: (header: string) => string | undefined; +}, res: { + end: (cb?: () => void) => typeof res; + set: (field: string, value?: string | string[]) => typeof res; + send: (json: string) => typeof res; + status: (code: number) => typeof res; +}) => ReqResHandler; +export type FastifyAdapter = (request: { + body: unknown; + headers: any; +}, reply: { + status: (code: number) => typeof reply; + headers: (headers: Record) => typeof reply; + code: (code: number) => typeof reply; + send: { + (): typeof reply; + (json: string): typeof reply; + }; +}) => ReqResHandler; +export type HonoAdapter = (c: { + req: { + json: () => Promise; + header: (header: string) => string | undefined; + }; + body(data: string): Response; + body(data: null, status: 204): Response; + status: (status: any) => void; + json: (json: string) => Response; +}) => ReqResHandler; +export type HttpAdapter = (req: { + headers: Record; + on: (event: string, listener: (chunk: unknown) => void) => typeof req; + once: (event: string, listener: () => void) => typeof req; +}, res: { + writeHead: { + (status: number): typeof res; + (status: number, headers: Record): typeof res; + }; + end: (json?: string) => void; +}) => ReqResHandler; +export type KoaAdapter = (ctx: { + get: (header: string) => string | undefined; + set: (key: string, value: string) => void; + status: number; + body: string; + request: { + body?: unknown; + }; + response: { + body: unknown; + status: number; + }; +}) => ReqResHandler; +export type NextAdapter = (req: { + body: Update; + headers: Record; +}, res: { + end: (cb?: () => void) => typeof res; + status: (code: number) => typeof res; + json: (json: string) => any; + send: (json: string) => any; +}) => ReqResHandler; +export type NHttpAdapter = (rev: { + body: unknown; + headers: { + get: (header: string) => string | null; + }; + response: { + sendStatus: (status: number) => void; + status: (status: number) => { + send: (json: string) => void; + }; + }; +}) => ReqResHandler; +export type OakAdapter = (ctx: { + request: { + body: { + json: () => Promise; + }; + headers: { + get: (header: string) => string | null; + }; + }; + response: { + status: number; + type: string | undefined; + body: unknown; + }; +}) => ReqResHandler; +export type ServeHttpAdapter = (requestEvent: { + request: Request; + respondWith: (response: Response) => void; +}) => ReqResHandler; +export type StdHttpAdapter = (req: Request) => ReqResHandler; +export type SveltekitAdapter = ({ request }: { + request: Request; +}) => ReqResHandler; +export type WorktopAdapter = (req: { + json: () => Promise; + headers: { + get: (header: string) => string | null; + }; +}, res: { + end: (data: BodyInit | null) => void; + send: (status: number, json: string) => void; +}) => ReqResHandler; +export declare const adapters: { + "aws-lambda": LambdaAdapter; + "aws-lambda-async": LambdaAsyncAdapter; + azure: AzureAdapter; + "azure-v4": AzureAdapterV4; + bun: BunAdapter; + cloudflare: CloudflareAdapter; + "cloudflare-mod": CloudflareModuleAdapter; + elysia: ElysiaAdapter; + express: ExpressAdapter; + fastify: FastifyAdapter; + hono: HonoAdapter; + http: HttpAdapter; + https: HttpAdapter; + koa: KoaAdapter; + "next-js": NextAdapter; + nhttp: NHttpAdapter; + oak: OakAdapter; + serveHttp: ServeHttpAdapter; + "std/http": StdHttpAdapter; + sveltekit: SveltekitAdapter; + worktop: WorktopAdapter; +}; +export {}; diff --git a/sandbox/tgbot/node_modules/grammy/out/convenience/frameworks.js b/sandbox/tgbot/node_modules/grammy/out/convenience/frameworks.js new file mode 100644 index 0000000..25af2cd --- /dev/null +++ b/sandbox/tgbot/node_modules/grammy/out/convenience/frameworks.js @@ -0,0 +1,393 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.adapters = void 0; +const SECRET_HEADER = "X-Telegram-Bot-Api-Secret-Token"; +const SECRET_HEADER_LOWERCASE = SECRET_HEADER.toLowerCase(); +const WRONG_TOKEN_ERROR = "secret token is wrong"; +const ok = () => new Response(null, { status: 200 }); +const okJson = (json) => new Response(json, { + status: 200, + headers: { "Content-Type": "application/json" }, +}); +const unauthorized = () => new Response('"unauthorized"', { + status: 401, + statusText: WRONG_TOKEN_ERROR, +}); +/** AWS lambda serverless functions */ +const awsLambda = (event, _context, callback) => ({ + get update() { + var _a; + return JSON.parse((_a = event.body) !== null && _a !== void 0 ? _a : "{}"); + }, + header: event.headers[SECRET_HEADER], + end: () => callback(null, { statusCode: 200 }), + respond: (json) => callback(null, { + statusCode: 200, + headers: { "Content-Type": "application/json" }, + body: json, + }), + unauthorized: () => callback(null, { statusCode: 401 }), +}); +/** AWS lambda async/await serverless functions */ +const awsLambdaAsync = (event, _context) => { + // deno-lint-ignore no-explicit-any + let resolveResponse; + return { + get update() { + var _a; + return JSON.parse((_a = event.body) !== null && _a !== void 0 ? _a : "{}"); + }, + header: event.headers[SECRET_HEADER], + end: () => resolveResponse({ statusCode: 200 }), + respond: (json) => resolveResponse({ + statusCode: 200, + headers: { "Content-Type": "application/json" }, + body: json, + }), + unauthorized: () => resolveResponse({ statusCode: 401 }), + handlerReturn: new Promise((res) => resolveResponse = res), + }; +}; +/** Azure Functions v3 and v4 */ +const azure = (context, request) => { + var _a, _b; + return ({ + get update() { + return request.body; + }, + header: (_b = (_a = context.res) === null || _a === void 0 ? void 0 : _a.headers) === null || _b === void 0 ? void 0 : _b[SECRET_HEADER], + end: () => (context.res = { + status: 200, + body: "", + }), + respond: (json) => { + var _a, _b, _c, _d; + (_b = (_a = context.res) === null || _a === void 0 ? void 0 : _a.set) === null || _b === void 0 ? void 0 : _b.call(_a, "Content-Type", "application/json"); + (_d = (_c = context.res) === null || _c === void 0 ? void 0 : _c.send) === null || _d === void 0 ? void 0 : _d.call(_c, json); + }, + unauthorized: () => { + var _a, _b; + (_b = (_a = context.res) === null || _a === void 0 ? void 0 : _a.send) === null || _b === void 0 ? void 0 : _b.call(_a, 401, WRONG_TOKEN_ERROR); + }, + }); +}; +const azureV4 = (request) => { + let resolveResponse; + return { + get update() { + return request.json(); + }, + header: request.headers.get(SECRET_HEADER) || undefined, + end: () => resolveResponse({ status: 204 }), + respond: (json) => resolveResponse({ jsonBody: json }), + unauthorized: () => resolveResponse({ status: 401, body: WRONG_TOKEN_ERROR }), + handlerReturn: new Promise((resolve) => resolveResponse = resolve), + }; +}; +/** Bun.serve */ +const bun = (request) => { + let resolveResponse; + return { + get update() { + return request.json(); + }, + header: request.headers.get(SECRET_HEADER) || undefined, + end: () => { + resolveResponse(ok()); + }, + respond: (json) => { + resolveResponse(okJson(json)); + }, + unauthorized: () => { + resolveResponse(unauthorized()); + }, + handlerReturn: new Promise((res) => resolveResponse = res), + }; +}; +/** Native CloudFlare workers (service worker) */ +const cloudflare = (event) => { + let resolveResponse; + event.respondWith(new Promise((resolve) => { + resolveResponse = resolve; + })); + return { + get update() { + return event.request.json(); + }, + header: event.request.headers.get(SECRET_HEADER) || undefined, + end: () => { + resolveResponse(ok()); + }, + respond: (json) => { + resolveResponse(okJson(json)); + }, + unauthorized: () => { + resolveResponse(unauthorized()); + }, + }; +}; +/** Native CloudFlare workers (module worker) */ +const cloudflareModule = (request) => { + let resolveResponse; + return { + get update() { + return request.json(); + }, + header: request.headers.get(SECRET_HEADER) || undefined, + end: () => { + resolveResponse(ok()); + }, + respond: (json) => { + resolveResponse(okJson(json)); + }, + unauthorized: () => { + resolveResponse(unauthorized()); + }, + handlerReturn: new Promise((res) => resolveResponse = res), + }; +}; +/** express web framework */ +const express = (req, res) => ({ + get update() { + return req.body; + }, + header: req.header(SECRET_HEADER), + end: () => res.end(), + respond: (json) => { + res.set("Content-Type", "application/json"); + res.send(json); + }, + unauthorized: () => { + res.status(401).send(WRONG_TOKEN_ERROR); + }, +}); +/** fastify web framework */ +const fastify = (request, reply) => ({ + get update() { + return request.body; + }, + header: request.headers[SECRET_HEADER_LOWERCASE], + end: () => reply.send(""), + respond: (json) => reply.headers({ "Content-Type": "application/json" }).send(json), + unauthorized: () => reply.code(401).send(WRONG_TOKEN_ERROR), +}); +/** hono web framework */ +const hono = (c) => { + let resolveResponse; + return { + get update() { + return c.req.json(); + }, + header: c.req.header(SECRET_HEADER), + end: () => { + resolveResponse(c.body("")); + }, + respond: (json) => { + resolveResponse(c.json(json)); + }, + unauthorized: () => { + c.status(401); + resolveResponse(c.body("")); + }, + handlerReturn: new Promise((res) => resolveResponse = res), + }; +}; +/** Node.js native 'http' and 'https' modules */ +const http = (req, res) => { + const secretHeaderFromRequest = req.headers[SECRET_HEADER_LOWERCASE]; + return { + get update() { + return new Promise((resolve, reject) => { + const chunks = []; + req.on("data", (chunk) => chunks.push(chunk)) + .once("end", () => { + // @ts-ignore `Buffer` is Node-only + // deno-lint-ignore no-node-globals + const raw = Buffer.concat(chunks).toString("utf-8"); + resolve(JSON.parse(raw)); + }) + .once("error", reject); + }); + }, + header: Array.isArray(secretHeaderFromRequest) + ? secretHeaderFromRequest[0] + : secretHeaderFromRequest, + end: () => res.end(), + respond: (json) => res + .writeHead(200, { "Content-Type": "application/json" }) + .end(json), + unauthorized: () => res.writeHead(401).end(WRONG_TOKEN_ERROR), + }; +}; +/** koa web framework */ +const koa = (ctx) => ({ + get update() { + return ctx.request.body; + }, + header: ctx.get(SECRET_HEADER) || undefined, + end: () => { + ctx.body = ""; + }, + respond: (json) => { + ctx.set("Content-Type", "application/json"); + ctx.response.body = json; + }, + unauthorized: () => { + ctx.status = 401; + }, +}); +/** Next.js Serverless Functions */ +const nextJs = (request, response) => ({ + get update() { + return request.body; + }, + header: request.headers[SECRET_HEADER_LOWERCASE], + end: () => response.end(), + respond: (json) => response.status(200).json(json), + unauthorized: () => response.status(401).send(WRONG_TOKEN_ERROR), +}); +/** nhttp web framework */ +const nhttp = (rev) => ({ + get update() { + return rev.body; + }, + header: rev.headers.get(SECRET_HEADER) || undefined, + end: () => rev.response.sendStatus(200), + respond: (json) => rev.response.status(200).send(json), + unauthorized: () => rev.response.status(401).send(WRONG_TOKEN_ERROR), +}); +/** oak web framework */ +const oak = (ctx) => ({ + get update() { + return ctx.request.body.json(); + }, + header: ctx.request.headers.get(SECRET_HEADER) || undefined, + end: () => { + ctx.response.status = 200; + }, + respond: (json) => { + ctx.response.type = "json"; + ctx.response.body = json; + }, + unauthorized: () => { + ctx.response.status = 401; + }, +}); +/** Deno.serve */ +const serveHttp = (requestEvent) => ({ + get update() { + return requestEvent.request.json(); + }, + header: requestEvent.request.headers.get(SECRET_HEADER) || undefined, + end: () => requestEvent.respondWith(ok()), + respond: (json) => requestEvent.respondWith(okJson(json)), + unauthorized: () => requestEvent.respondWith(unauthorized()), +}); +/** std/http web server */ +const stdHttp = (req) => { + let resolveResponse; + return { + get update() { + return req.json(); + }, + header: req.headers.get(SECRET_HEADER) || undefined, + end: () => { + if (resolveResponse) + resolveResponse(ok()); + }, + respond: (json) => { + if (resolveResponse) + resolveResponse(okJson(json)); + }, + unauthorized: () => { + if (resolveResponse) + resolveResponse(unauthorized()); + }, + handlerReturn: new Promise((res) => resolveResponse = res), + }; +}; +/** Sveltekit Serverless Functions */ +const sveltekit = ({ request }) => { + let resolveResponse; + return { + get update() { + return request.json(); + }, + header: request.headers.get(SECRET_HEADER) || undefined, + end: () => { + if (resolveResponse) + resolveResponse(ok()); + }, + respond: (json) => { + if (resolveResponse) + resolveResponse(okJson(json)); + }, + unauthorized: () => { + if (resolveResponse) + resolveResponse(unauthorized()); + }, + handlerReturn: new Promise((res) => resolveResponse = res), + }; +}; +/** worktop Cloudflare workers framework */ +const worktop = (req, res) => { + var _a; + return ({ + get update() { + return req.json(); + }, + header: (_a = req.headers.get(SECRET_HEADER)) !== null && _a !== void 0 ? _a : undefined, + end: () => res.end(null), + respond: (json) => res.send(200, json), + unauthorized: () => res.send(401, WRONG_TOKEN_ERROR), + }); +}; +const elysia = (ctx) => { + // @note upgrade target to use modern code? + // const { promise, resolve } = Promise.withResolvers(); + let resolveResponse; + return { + // @note technically the type shouldn't be limited to Promise, because it's fine to await plain values as well + get update() { + return ctx.body; + }, + header: ctx.headers[SECRET_HEADER_LOWERCASE], + end() { + resolveResponse(""); + }, + respond(json) { + // @note since json is passed as string here, we gotta define proper content-type + ctx.set.headers["content-type"] = "application/json"; + resolveResponse(json); + }, + unauthorized() { + ctx.set.status = 401; + resolveResponse(""); + }, + handlerReturn: new Promise((res) => resolveResponse = res), + }; +}; +// Please open a pull request if you want to add another adapter +exports.adapters = { + "aws-lambda": awsLambda, + "aws-lambda-async": awsLambdaAsync, + azure, + "azure-v4": azureV4, + bun, + cloudflare, + "cloudflare-mod": cloudflareModule, + elysia, + express, + fastify, + hono, + http, + https: http, + koa, + "next-js": nextJs, + nhttp, + oak, + serveHttp, + "std/http": stdHttp, + sveltekit, + worktop, +}; diff --git a/sandbox/tgbot/node_modules/grammy/out/convenience/inline_query.d.ts b/sandbox/tgbot/node_modules/grammy/out/convenience/inline_query.d.ts new file mode 100644 index 0000000..e1605a5 --- /dev/null +++ b/sandbox/tgbot/node_modules/grammy/out/convenience/inline_query.d.ts @@ -0,0 +1,401 @@ +import { type InlineQueryResultArticle, type InlineQueryResultAudio, type InlineQueryResultCachedAudio, type InlineQueryResultCachedDocument, type InlineQueryResultCachedGif, type InlineQueryResultCachedMpeg4Gif, type InlineQueryResultCachedPhoto, type InlineQueryResultCachedSticker, type InlineQueryResultCachedVideo, type InlineQueryResultCachedVoice, type InlineQueryResultContact, type InlineQueryResultDocument, type InlineQueryResultGame, type InlineQueryResultGif, type InlineQueryResultLocation, type InlineQueryResultMpeg4Gif, type InlineQueryResultPhoto, type InlineQueryResultVenue, type InlineQueryResultVideo, type InlineQueryResultVoice, type InputContactMessageContent, type InputInvoiceMessageContent, type InputLocationMessageContent, type InputTextMessageContent, type InputVenueMessageContent, type LabeledPrice } from "../types.js"; +type InlineQueryResultOptions = Omit; +type OptionalKeys = { + [K in keyof T]-?: undefined extends T[K] ? K : never; +}; +type OptionalFields = Pick[keyof T]>; +/** + * Holds a number of helper methods for building `InlineQueryResult*` objects. + * + * For example, letting the user pick one out of three photos can be done like + * this. + * + * ```ts + * const results = [ + * InlineQueryResultBuilder.photo('id0', 'https://grammy.dev/images/Y.png'), + * InlineQueryResultBuilder.photo('id1', 'https://grammy.dev/images/Y.png'), + * InlineQueryResultBuilder.photo('id2', 'https://grammy.dev/images/Y.png'), + * ]; + * await ctx.answerInlineQuery(results) + * ``` + * + * If you want the message content to be different from the content in the + * inline query result, you can perform another method call on the resulting + * objects. + * + * ```ts + * const results = [ + * InlineQueryResultBuilder.photo("id0", "https://grammy.dev/images/Y.png") + * .text("Picked photo 0!"), + * InlineQueryResultBuilder.photo("id1", "https://grammy.dev/images/Y.png") + * .text("Picked photo 1!"), + * InlineQueryResultBuilder.photo("id2", "https://grammy.dev/images/Y.png") + * .text("Picked photo 2!"), + * ]; + * await ctx.answerInlineQuery(results) + * ``` + * + * Be sure to check the + * [documentation](https://core.telegram.org/bots/api#inline-mode) on inline + * mode. + */ +export declare const InlineQueryResultBuilder: { + /** + * Builds an InlineQueryResultArticle object as specified by + * https://core.telegram.org/bots/api#inlinequeryresultarticle. Requires you + * to specify the actual message content by calling another function on the + * object returned from this method. + * + * @param id Unique identifier for this result, 1-64 Bytes + * @param title Title of the result + * @param options Remaining options + */ + article(id: string, title: string, options?: InlineQueryResultOptions): { + text(message_text: string, options?: OptionalFields): InlineQueryResultArticle; + location(latitude: number, longitude: number, options?: OptionalFields): InlineQueryResultArticle; + venue(title: string, latitude: number, longitude: number, address: string, options: OptionalFields): InlineQueryResultArticle; + contact(first_name: string, phone_number: string, options?: OptionalFields): InlineQueryResultArticle; + invoice(title: string, description: string, payload: string, provider_token: string, currency: string, prices: LabeledPrice[], options?: OptionalFields): InlineQueryResultArticle; + }; + /** + * Builds an InlineQueryResultAudio object as specified by + * https://core.telegram.org/bots/api#inlinequeryresultaudio. + * + * @param id Unique identifier for this result, 1-64 bytes + * @param title Title + * @param audio_url A valid URL for the audio file + * @param options Remaining options + */ + audio(id: string, title: string, audio_url: string | URL, options?: InlineQueryResultOptions): InlineQueryResultAudio & { + text(message_text: string, options?: OptionalFields): InlineQueryResultAudio; + location(latitude: number, longitude: number, options?: OptionalFields): InlineQueryResultAudio; + venue(title: string, latitude: number, longitude: number, address: string, options: OptionalFields): InlineQueryResultAudio; + contact(first_name: string, phone_number: string, options?: OptionalFields): InlineQueryResultAudio; + invoice(title: string, description: string, payload: string, provider_token: string, currency: string, prices: LabeledPrice[], options?: OptionalFields): InlineQueryResultAudio; + }; + /** + * Builds an InlineQueryResultCachedAudio object as specified by + * https://core.telegram.org/bots/api#inlinequeryresultcachedaudio. + * + * @param id Unique identifier for this result, 1-64 bytes + * @param audio_file_id A valid file identifier for the audio file + * @param options Remaining options + */ + audioCached(id: string, audio_file_id: string, options?: InlineQueryResultOptions): InlineQueryResultCachedAudio & { + text(message_text: string, options?: OptionalFields): InlineQueryResultCachedAudio; + location(latitude: number, longitude: number, options?: OptionalFields): InlineQueryResultCachedAudio; + venue(title: string, latitude: number, longitude: number, address: string, options: OptionalFields): InlineQueryResultCachedAudio; + contact(first_name: string, phone_number: string, options?: OptionalFields): InlineQueryResultCachedAudio; + invoice(title: string, description: string, payload: string, provider_token: string, currency: string, prices: LabeledPrice[], options?: OptionalFields): InlineQueryResultCachedAudio; + }; + /** + * Builds an InlineQueryResultContact object as specified by + * https://core.telegram.org/bots/api#inlinequeryresultcontact. + * + * @param id Unique identifier for this result, 1-64 Bytes + * @param phone_number Contact's phone number + * @param first_name Contact's first name + * @param options Remaining options + */ + contact(id: string, phone_number: string, first_name: string, options?: InlineQueryResultOptions): InlineQueryResultContact & { + text(message_text: string, options?: OptionalFields): InlineQueryResultContact; + location(latitude: number, longitude: number, options?: OptionalFields): InlineQueryResultContact; + venue(title: string, latitude: number, longitude: number, address: string, options: OptionalFields): InlineQueryResultContact; + contact(first_name: string, phone_number: string, options?: OptionalFields): InlineQueryResultContact; + invoice(title: string, description: string, payload: string, provider_token: string, currency: string, prices: LabeledPrice[], options?: OptionalFields): InlineQueryResultContact; + }; + /** + * Builds an InlineQueryResultDocument object as specified by + * https://core.telegram.org/bots/api#inlinequeryresultdocument with + * mime_type set to "application/pdf". + * + * @param id Unique identifier for this result, 1-64 bytes + * @param title Title for the result + * @param document_url A valid URL for the file + * @param options Remaining options + */ + documentPdf(id: string, title: string, document_url: string | URL, options?: InlineQueryResultOptions): InlineQueryResultDocument & { + text(message_text: string, options?: OptionalFields): InlineQueryResultDocument; + location(latitude: number, longitude: number, options?: OptionalFields): InlineQueryResultDocument; + venue(title: string, latitude: number, longitude: number, address: string, options: OptionalFields): InlineQueryResultDocument; + contact(first_name: string, phone_number: string, options?: OptionalFields): InlineQueryResultDocument; + invoice(title: string, description: string, payload: string, provider_token: string, currency: string, prices: LabeledPrice[], options?: OptionalFields): InlineQueryResultDocument; + }; + /** + * Builds an InlineQueryResultDocument object as specified by + * https://core.telegram.org/bots/api#inlinequeryresultdocument with + * mime_type set to "application/zip". + * + * @param id Unique identifier for this result, 1-64 bytes + * @param title Title for the result + * @param document_url A valid URL for the file + * @param options Remaining options + */ + documentZip(id: string, title: string, document_url: string | URL, options?: InlineQueryResultOptions): InlineQueryResultDocument & { + text(message_text: string, options?: OptionalFields): InlineQueryResultDocument; + location(latitude: number, longitude: number, options?: OptionalFields): InlineQueryResultDocument; + venue(title: string, latitude: number, longitude: number, address: string, options: OptionalFields): InlineQueryResultDocument; + contact(first_name: string, phone_number: string, options?: OptionalFields): InlineQueryResultDocument; + invoice(title: string, description: string, payload: string, provider_token: string, currency: string, prices: LabeledPrice[], options?: OptionalFields): InlineQueryResultDocument; + }; + /** + * Builds an InlineQueryResultCachedDocument object as specified by + * https://core.telegram.org/bots/api#inlinequeryresultcacheddocument. + * + * @param id Unique identifier for this result, 1-64 bytes + * @param title Title for the result + * @param document_file_id A valid file identifier for the file + * @param options Remaining options + */ + documentCached(id: string, title: string, document_file_id: string, options?: InlineQueryResultOptions): InlineQueryResultCachedDocument & { + text(message_text: string, options?: OptionalFields): InlineQueryResultCachedDocument; + location(latitude: number, longitude: number, options?: OptionalFields): InlineQueryResultCachedDocument; + venue(title: string, latitude: number, longitude: number, address: string, options: OptionalFields): InlineQueryResultCachedDocument; + contact(first_name: string, phone_number: string, options?: OptionalFields): InlineQueryResultCachedDocument; + invoice(title: string, description: string, payload: string, provider_token: string, currency: string, prices: LabeledPrice[], options?: OptionalFields): InlineQueryResultCachedDocument; + }; + /** + * Builds an InlineQueryResultGame object as specified by + * https://core.telegram.org/bots/api#inlinequeryresultgame. + * + * @param id Unique identifier for this result, 1-64 bytes + * @param game_short_name Short name of the game + * @param options Remaining options + */ + game(id: string, game_short_name: string, options?: InlineQueryResultOptions): { + reply_markup?: import("@grammyjs/types/markup.js").InlineKeyboardMarkup | undefined; + type: string; + id: string; + game_short_name: string; + }; + /** + * Builds an InlineQueryResultGif object as specified by + * https://core.telegram.org/bots/api#inlinequeryresultgif. + * + * @param id Unique identifier for this result, 1-64 bytes + * @param gif_url A valid URL for the GIF file. File size must not exceed 1MB + * @param thumbnail_url URL of the static (JPEG or GIF) or animated (MPEG4) thumbnail for the result + * @param options Remaining options + */ + gif(id: string, gif_url: string | URL, thumbnail_url: string | URL, options?: InlineQueryResultOptions): InlineQueryResultGif & { + text(message_text: string, options?: OptionalFields): InlineQueryResultGif; + location(latitude: number, longitude: number, options?: OptionalFields): InlineQueryResultGif; + venue(title: string, latitude: number, longitude: number, address: string, options: OptionalFields): InlineQueryResultGif; + contact(first_name: string, phone_number: string, options?: OptionalFields): InlineQueryResultGif; + invoice(title: string, description: string, payload: string, provider_token: string, currency: string, prices: LabeledPrice[], options?: OptionalFields): InlineQueryResultGif; + }; + /** + * Builds an InlineQueryResultCachedGif object as specified by + * https://core.telegram.org/bots/api#inlinequeryresultcachedgif. + * + * @param id Unique identifier for this result, 1-64 bytes + * @param gif_file_id A valid file identifier for the GIF file + * @param options Remaining options + */ + gifCached(id: string, gif_file_id: string, options?: InlineQueryResultOptions): InlineQueryResultCachedGif & { + text(message_text: string, options?: OptionalFields): InlineQueryResultCachedGif; + location(latitude: number, longitude: number, options?: OptionalFields): InlineQueryResultCachedGif; + venue(title: string, latitude: number, longitude: number, address: string, options: OptionalFields): InlineQueryResultCachedGif; + contact(first_name: string, phone_number: string, options?: OptionalFields): InlineQueryResultCachedGif; + invoice(title: string, description: string, payload: string, provider_token: string, currency: string, prices: LabeledPrice[], options?: OptionalFields): InlineQueryResultCachedGif; + }; + /** + * Builds an InlineQueryResultLocation object as specified by + * https://core.telegram.org/bots/api#inlinequeryresultlocation. + * + * @param id Unique identifier for this result, 1-64 Bytes + * @param title Location title + * @param latitude Location latitude in degrees + * @param longitude Location longitude in degrees + * @param options Remaining options + */ + location(id: string, title: string, latitude: number, longitude: number, options?: InlineQueryResultOptions): InlineQueryResultLocation & { + text(message_text: string, options?: OptionalFields): InlineQueryResultLocation; + location(latitude: number, longitude: number, options?: OptionalFields): InlineQueryResultLocation; + venue(title: string, latitude: number, longitude: number, address: string, options: OptionalFields): InlineQueryResultLocation; + contact(first_name: string, phone_number: string, options?: OptionalFields): InlineQueryResultLocation; + invoice(title: string, description: string, payload: string, provider_token: string, currency: string, prices: LabeledPrice[], options?: OptionalFields): InlineQueryResultLocation; + }; + /** + * Builds an InlineQueryResultMpeg4Gif object as specified by + * https://core.telegram.org/bots/api#inlinequeryresultmpeg4gif. + * + * @param id Unique identifier for this result, 1-64 bytes + * @param mpeg4_url A valid URL for the MPEG4 file. File size must not exceed 1MB + * @param thumbnail_url URL of the static (JPEG or GIF) or animated (MPEG4) thumbnail for the result + * @param options Remaining options + */ + mpeg4gif(id: string, mpeg4_url: string | URL, thumbnail_url: string | URL, options?: InlineQueryResultOptions): InlineQueryResultMpeg4Gif & { + text(message_text: string, options?: OptionalFields): InlineQueryResultMpeg4Gif; + location(latitude: number, longitude: number, options?: OptionalFields): InlineQueryResultMpeg4Gif; + venue(title: string, latitude: number, longitude: number, address: string, options: OptionalFields): InlineQueryResultMpeg4Gif; + contact(first_name: string, phone_number: string, options?: OptionalFields): InlineQueryResultMpeg4Gif; + invoice(title: string, description: string, payload: string, provider_token: string, currency: string, prices: LabeledPrice[], options?: OptionalFields): InlineQueryResultMpeg4Gif; + }; + /** + * Builds an InlineQueryResultCachedMpeg4Gif object as specified by + * https://core.telegram.org/bots/api#inlinequeryresultcachedmpeg4gif. + * + * @param id Unique identifier for this result, 1-64 bytes + * @param mpeg4_file_id A valid file identifier for the MPEG4 file + * @param options Remaining options + */ + mpeg4gifCached(id: string, mpeg4_file_id: string, options?: InlineQueryResultOptions): InlineQueryResultCachedMpeg4Gif & { + text(message_text: string, options?: OptionalFields): InlineQueryResultCachedMpeg4Gif; + location(latitude: number, longitude: number, options?: OptionalFields): InlineQueryResultCachedMpeg4Gif; + venue(title: string, latitude: number, longitude: number, address: string, options: OptionalFields): InlineQueryResultCachedMpeg4Gif; + contact(first_name: string, phone_number: string, options?: OptionalFields): InlineQueryResultCachedMpeg4Gif; + invoice(title: string, description: string, payload: string, provider_token: string, currency: string, prices: LabeledPrice[], options?: OptionalFields): InlineQueryResultCachedMpeg4Gif; + }; + /** + * Builds an InlineQueryResultPhoto object as specified by + * https://core.telegram.org/bots/api#inlinequeryresultphoto with the + * thumbnail defaulting to the photo itself. + * + * @param id Unique identifier for this result, 1-64 bytes + * @param photo_url A valid URL of the photo. Photo must be in JPEG format. Photo size must not exceed 5MB + * @param options Remaining options + */ + photo(id: string, photo_url: string | URL, options?: InlineQueryResultOptions): InlineQueryResultPhoto & { + text(message_text: string, options?: OptionalFields): InlineQueryResultPhoto; + location(latitude: number, longitude: number, options?: OptionalFields): InlineQueryResultPhoto; + venue(title: string, latitude: number, longitude: number, address: string, options: OptionalFields): InlineQueryResultPhoto; + contact(first_name: string, phone_number: string, options?: OptionalFields): InlineQueryResultPhoto; + invoice(title: string, description: string, payload: string, provider_token: string, currency: string, prices: LabeledPrice[], options?: OptionalFields): InlineQueryResultPhoto; + }; + /** + * Builds an InlineQueryResultCachedPhoto object as specified by + * https://core.telegram.org/bots/api#inlinequeryresultcachedphoto. + * + * @param id Unique identifier for this result, 1-64 bytes + * @param photo_file_id A valid file identifier of the photo + * @param options Remaining options + */ + photoCached(id: string, photo_file_id: string, options?: InlineQueryResultOptions): InlineQueryResultCachedPhoto & { + text(message_text: string, options?: OptionalFields): InlineQueryResultCachedPhoto; + location(latitude: number, longitude: number, options?: OptionalFields): InlineQueryResultCachedPhoto; + venue(title: string, latitude: number, longitude: number, address: string, options: OptionalFields): InlineQueryResultCachedPhoto; + contact(first_name: string, phone_number: string, options?: OptionalFields): InlineQueryResultCachedPhoto; + invoice(title: string, description: string, payload: string, provider_token: string, currency: string, prices: LabeledPrice[], options?: OptionalFields): InlineQueryResultCachedPhoto; + }; + /** + * Builds an InlineQueryResultCachedSticker object as specified by + * https://core.telegram.org/bots/api#inlinequeryresultcachedsticker. + * + * @param id Unique identifier for this result, 1-64 bytes + * @param sticker_file_id A valid file identifier of the sticker + * @param options Remaining options + */ + stickerCached(id: string, sticker_file_id: string, options?: InlineQueryResultOptions): InlineQueryResultCachedSticker & { + text(message_text: string, options?: OptionalFields): InlineQueryResultCachedSticker; + location(latitude: number, longitude: number, options?: OptionalFields): InlineQueryResultCachedSticker; + venue(title: string, latitude: number, longitude: number, address: string, options: OptionalFields): InlineQueryResultCachedSticker; + contact(first_name: string, phone_number: string, options?: OptionalFields): InlineQueryResultCachedSticker; + invoice(title: string, description: string, payload: string, provider_token: string, currency: string, prices: LabeledPrice[], options?: OptionalFields): InlineQueryResultCachedSticker; + }; + /** + * Builds an InlineQueryResultVenue object as specified by + * https://core.telegram.org/bots/api#inlinequeryresultvenue. + * + * @param id Unique identifier for this result, 1-64 Bytes + * @param title Title of the venue + * @param latitude Latitude of the venue location in degrees + * @param longitude Longitude of the venue location in degrees + * @param address Address of the venue + * @param options Remaining options + */ + venue(id: string, title: string, latitude: number, longitude: number, address: string, options?: InlineQueryResultOptions): InlineQueryResultVenue & { + text(message_text: string, options?: OptionalFields): InlineQueryResultVenue; + location(latitude: number, longitude: number, options?: OptionalFields): InlineQueryResultVenue; + venue(title: string, latitude: number, longitude: number, address: string, options: OptionalFields): InlineQueryResultVenue; + contact(first_name: string, phone_number: string, options?: OptionalFields): InlineQueryResultVenue; + invoice(title: string, description: string, payload: string, provider_token: string, currency: string, prices: LabeledPrice[], options?: OptionalFields): InlineQueryResultVenue; + }; + /** + * Builds an InlineQueryResultVideo object as specified by + * https://core.telegram.org/bots/api#inlinequeryresultvideo with mime_type + * set to "text/html". This will send an embedded video player. Requires you + * to specify the actual message content by calling another function on the + * object returned from this method. + * + * @param id Unique identifier for this result, 1-64 bytes + * @param title Title for the result + * @param video_url A valid URL for the embedded video player + * @param thumbnail_url URL of the thumbnail (JPEG only) for the video + * @param options Remaining options + */ + videoHtml(id: string, title: string, video_url: string | URL, thumbnail_url: string | URL, options?: InlineQueryResultOptions): { + text(message_text: string, options?: OptionalFields): InlineQueryResultVideo; + location(latitude: number, longitude: number, options?: OptionalFields): InlineQueryResultVideo; + venue(title: string, latitude: number, longitude: number, address: string, options: OptionalFields): InlineQueryResultVideo; + contact(first_name: string, phone_number: string, options?: OptionalFields): InlineQueryResultVideo; + invoice(title: string, description: string, payload: string, provider_token: string, currency: string, prices: LabeledPrice[], options?: OptionalFields): InlineQueryResultVideo; + }; + /** + * Builds an InlineQueryResultVideo object as specified by + * https://core.telegram.org/bots/api#inlinequeryresultvideo with mime_type + * set to "video/mp4". + * + * @param id Unique identifier for this result, 1-64 bytes + * @param title Title for the result + * @param video_url A valid URL for the video file + * @param thumbnail_url URL of the thumbnail (JPEG only) for the video + * @param options Remaining options + */ + videoMp4(id: string, title: string, video_url: string | URL, thumbnail_url: string | URL, options?: InlineQueryResultOptions): InlineQueryResultVideo & { + text(message_text: string, options?: OptionalFields): InlineQueryResultVideo; + location(latitude: number, longitude: number, options?: OptionalFields): InlineQueryResultVideo; + venue(title: string, latitude: number, longitude: number, address: string, options: OptionalFields): InlineQueryResultVideo; + contact(first_name: string, phone_number: string, options?: OptionalFields): InlineQueryResultVideo; + invoice(title: string, description: string, payload: string, provider_token: string, currency: string, prices: LabeledPrice[], options?: OptionalFields): InlineQueryResultVideo; + }; + /** + * Builds an InlineQueryResultCachedVideo object as specified by + * https://core.telegram.org/bots/api#inlinequeryresultcachedvideo. + * + * @param id Unique identifier for this result, 1-64 bytes + * @param title Title for the result + * @param video_file_id A valid file identifier for the video file + * @param options Remaining options + */ + videoCached(id: string, title: string, video_file_id: string, options?: InlineQueryResultOptions): InlineQueryResultCachedVideo & { + text(message_text: string, options?: OptionalFields): InlineQueryResultCachedVideo; + location(latitude: number, longitude: number, options?: OptionalFields): InlineQueryResultCachedVideo; + venue(title: string, latitude: number, longitude: number, address: string, options: OptionalFields): InlineQueryResultCachedVideo; + contact(first_name: string, phone_number: string, options?: OptionalFields): InlineQueryResultCachedVideo; + invoice(title: string, description: string, payload: string, provider_token: string, currency: string, prices: LabeledPrice[], options?: OptionalFields): InlineQueryResultCachedVideo; + }; + /** + * Builds an InlineQueryResultVoice object as specified by + * https://core.telegram.org/bots/api#inlinequeryresultvoice. + * + * @param id Unique identifier for this result, 1-64 bytes + * @param title Voice message title + * @param voice_url A valid URL for the voice recording + * @param options Remaining options + */ + voice(id: string, title: string, voice_url: string | URL, options?: InlineQueryResultOptions): InlineQueryResultVoice & { + text(message_text: string, options?: OptionalFields): InlineQueryResultVoice; + location(latitude: number, longitude: number, options?: OptionalFields): InlineQueryResultVoice; + venue(title: string, latitude: number, longitude: number, address: string, options: OptionalFields): InlineQueryResultVoice; + contact(first_name: string, phone_number: string, options?: OptionalFields): InlineQueryResultVoice; + invoice(title: string, description: string, payload: string, provider_token: string, currency: string, prices: LabeledPrice[], options?: OptionalFields): InlineQueryResultVoice; + }; + /** + * Builds an InlineQueryResultCachedVoice object as specified by + * https://core.telegram.org/bots/api#inlinequeryresultcachedvoice. + * + * @param id Unique identifier for this result, 1-64 bytes + * @param title Voice message title + * @param voice_file_id A valid file identifier for the voice message + * @param options Remaining options + */ + voiceCached(id: string, title: string, voice_file_id: string, options?: InlineQueryResultOptions): InlineQueryResultCachedVoice & { + text(message_text: string, options?: OptionalFields): InlineQueryResultCachedVoice; + location(latitude: number, longitude: number, options?: OptionalFields): InlineQueryResultCachedVoice; + venue(title: string, latitude: number, longitude: number, address: string, options: OptionalFields): InlineQueryResultCachedVoice; + contact(first_name: string, phone_number: string, options?: OptionalFields): InlineQueryResultCachedVoice; + invoice(title: string, description: string, payload: string, provider_token: string, currency: string, prices: LabeledPrice[], options?: OptionalFields): InlineQueryResultCachedVoice; + }; +}; +export {}; diff --git a/sandbox/tgbot/node_modules/grammy/out/convenience/inline_query.js b/sandbox/tgbot/node_modules/grammy/out/convenience/inline_query.js new file mode 100644 index 0000000..1132a37 --- /dev/null +++ b/sandbox/tgbot/node_modules/grammy/out/convenience/inline_query.js @@ -0,0 +1,461 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.InlineQueryResultBuilder = void 0; +function inputMessage(queryTemplate) { + return { + ...queryTemplate, + ...inputMessageMethods(queryTemplate), + }; +} +function inputMessageMethods(queryTemplate) { + return { + text(message_text, options = {}) { + const content = { + message_text, + ...options, + }; + return { ...queryTemplate, input_message_content: content }; + }, + location(latitude, longitude, options = {}) { + const content = { + latitude, + longitude, + ...options, + }; + return { ...queryTemplate, input_message_content: content }; + }, + venue(title, latitude, longitude, address, options) { + const content = { + title, + latitude, + longitude, + address, + ...options, + }; + return { ...queryTemplate, input_message_content: content }; + }, + contact(first_name, phone_number, options = {}) { + const content = { + first_name, + phone_number, + ...options, + }; + return { ...queryTemplate, input_message_content: content }; + }, + invoice(title, description, payload, provider_token, currency, prices, options = {}) { + const content = { + title, + description, + payload, + provider_token, + currency, + prices, + ...options, + }; + return { ...queryTemplate, input_message_content: content }; + }, + }; +} +/** + * Holds a number of helper methods for building `InlineQueryResult*` objects. + * + * For example, letting the user pick one out of three photos can be done like + * this. + * + * ```ts + * const results = [ + * InlineQueryResultBuilder.photo('id0', 'https://grammy.dev/images/Y.png'), + * InlineQueryResultBuilder.photo('id1', 'https://grammy.dev/images/Y.png'), + * InlineQueryResultBuilder.photo('id2', 'https://grammy.dev/images/Y.png'), + * ]; + * await ctx.answerInlineQuery(results) + * ``` + * + * If you want the message content to be different from the content in the + * inline query result, you can perform another method call on the resulting + * objects. + * + * ```ts + * const results = [ + * InlineQueryResultBuilder.photo("id0", "https://grammy.dev/images/Y.png") + * .text("Picked photo 0!"), + * InlineQueryResultBuilder.photo("id1", "https://grammy.dev/images/Y.png") + * .text("Picked photo 1!"), + * InlineQueryResultBuilder.photo("id2", "https://grammy.dev/images/Y.png") + * .text("Picked photo 2!"), + * ]; + * await ctx.answerInlineQuery(results) + * ``` + * + * Be sure to check the + * [documentation](https://core.telegram.org/bots/api#inline-mode) on inline + * mode. + */ +exports.InlineQueryResultBuilder = { + /** + * Builds an InlineQueryResultArticle object as specified by + * https://core.telegram.org/bots/api#inlinequeryresultarticle. Requires you + * to specify the actual message content by calling another function on the + * object returned from this method. + * + * @param id Unique identifier for this result, 1-64 Bytes + * @param title Title of the result + * @param options Remaining options + */ + article(id, title, options = {}) { + return inputMessageMethods({ type: "article", id, title, ...options }); + }, + /** + * Builds an InlineQueryResultAudio object as specified by + * https://core.telegram.org/bots/api#inlinequeryresultaudio. + * + * @param id Unique identifier for this result, 1-64 bytes + * @param title Title + * @param audio_url A valid URL for the audio file + * @param options Remaining options + */ + audio(id, title, audio_url, options = {}) { + return inputMessage({ + type: "audio", + id, + title, + audio_url: typeof audio_url === "string" + ? audio_url + : audio_url.href, + ...options, + }); + }, + /** + * Builds an InlineQueryResultCachedAudio object as specified by + * https://core.telegram.org/bots/api#inlinequeryresultcachedaudio. + * + * @param id Unique identifier for this result, 1-64 bytes + * @param audio_file_id A valid file identifier for the audio file + * @param options Remaining options + */ + audioCached(id, audio_file_id, options = {}) { + return inputMessage({ type: "audio", id, audio_file_id, ...options }); + }, + /** + * Builds an InlineQueryResultContact object as specified by + * https://core.telegram.org/bots/api#inlinequeryresultcontact. + * + * @param id Unique identifier for this result, 1-64 Bytes + * @param phone_number Contact's phone number + * @param first_name Contact's first name + * @param options Remaining options + */ + contact(id, phone_number, first_name, options = {}) { + return inputMessage({ type: "contact", id, phone_number, first_name, ...options }); + }, + /** + * Builds an InlineQueryResultDocument object as specified by + * https://core.telegram.org/bots/api#inlinequeryresultdocument with + * mime_type set to "application/pdf". + * + * @param id Unique identifier for this result, 1-64 bytes + * @param title Title for the result + * @param document_url A valid URL for the file + * @param options Remaining options + */ + documentPdf(id, title, document_url, options = {}) { + return inputMessage({ + type: "document", + mime_type: "application/pdf", + id, + title, + document_url: typeof document_url === "string" + ? document_url + : document_url.href, + ...options, + }); + }, + /** + * Builds an InlineQueryResultDocument object as specified by + * https://core.telegram.org/bots/api#inlinequeryresultdocument with + * mime_type set to "application/zip". + * + * @param id Unique identifier for this result, 1-64 bytes + * @param title Title for the result + * @param document_url A valid URL for the file + * @param options Remaining options + */ + documentZip(id, title, document_url, options = {}) { + return inputMessage({ + type: "document", + mime_type: "application/zip", + id, + title, + document_url: typeof document_url === "string" + ? document_url + : document_url.href, + ...options, + }); + }, + /** + * Builds an InlineQueryResultCachedDocument object as specified by + * https://core.telegram.org/bots/api#inlinequeryresultcacheddocument. + * + * @param id Unique identifier for this result, 1-64 bytes + * @param title Title for the result + * @param document_file_id A valid file identifier for the file + * @param options Remaining options + */ + documentCached(id, title, document_file_id, options = {}) { + return inputMessage({ type: "document", id, title, document_file_id, ...options }); + }, + /** + * Builds an InlineQueryResultGame object as specified by + * https://core.telegram.org/bots/api#inlinequeryresultgame. + * + * @param id Unique identifier for this result, 1-64 bytes + * @param game_short_name Short name of the game + * @param options Remaining options + */ + game(id, game_short_name, options = {}) { + return { type: "game", id, game_short_name, ...options }; + }, + /** + * Builds an InlineQueryResultGif object as specified by + * https://core.telegram.org/bots/api#inlinequeryresultgif. + * + * @param id Unique identifier for this result, 1-64 bytes + * @param gif_url A valid URL for the GIF file. File size must not exceed 1MB + * @param thumbnail_url URL of the static (JPEG or GIF) or animated (MPEG4) thumbnail for the result + * @param options Remaining options + */ + gif(id, gif_url, thumbnail_url, options = {}) { + return inputMessage({ + type: "gif", + id, + gif_url: typeof gif_url === "string" ? gif_url : gif_url.href, + thumbnail_url: typeof thumbnail_url === "string" + ? thumbnail_url + : thumbnail_url.href, + ...options, + }); + }, + /** + * Builds an InlineQueryResultCachedGif object as specified by + * https://core.telegram.org/bots/api#inlinequeryresultcachedgif. + * + * @param id Unique identifier for this result, 1-64 bytes + * @param gif_file_id A valid file identifier for the GIF file + * @param options Remaining options + */ + gifCached(id, gif_file_id, options = {}) { + return inputMessage({ type: "gif", id, gif_file_id, ...options }); + }, + /** + * Builds an InlineQueryResultLocation object as specified by + * https://core.telegram.org/bots/api#inlinequeryresultlocation. + * + * @param id Unique identifier for this result, 1-64 Bytes + * @param title Location title + * @param latitude Location latitude in degrees + * @param longitude Location longitude in degrees + * @param options Remaining options + */ + location(id, title, latitude, longitude, options = {}) { + return inputMessage({ type: "location", id, title, latitude, longitude, ...options }); + }, + /** + * Builds an InlineQueryResultMpeg4Gif object as specified by + * https://core.telegram.org/bots/api#inlinequeryresultmpeg4gif. + * + * @param id Unique identifier for this result, 1-64 bytes + * @param mpeg4_url A valid URL for the MPEG4 file. File size must not exceed 1MB + * @param thumbnail_url URL of the static (JPEG or GIF) or animated (MPEG4) thumbnail for the result + * @param options Remaining options + */ + mpeg4gif(id, mpeg4_url, thumbnail_url, options = {}) { + return inputMessage({ + type: "mpeg4_gif", + id, + mpeg4_url: typeof mpeg4_url === "string" + ? mpeg4_url + : mpeg4_url.href, + thumbnail_url: typeof thumbnail_url === "string" + ? thumbnail_url + : thumbnail_url.href, + ...options, + }); + }, + /** + * Builds an InlineQueryResultCachedMpeg4Gif object as specified by + * https://core.telegram.org/bots/api#inlinequeryresultcachedmpeg4gif. + * + * @param id Unique identifier for this result, 1-64 bytes + * @param mpeg4_file_id A valid file identifier for the MPEG4 file + * @param options Remaining options + */ + mpeg4gifCached(id, mpeg4_file_id, options = {}) { + return inputMessage({ type: "mpeg4_gif", id, mpeg4_file_id, ...options }); + }, + /** + * Builds an InlineQueryResultPhoto object as specified by + * https://core.telegram.org/bots/api#inlinequeryresultphoto with the + * thumbnail defaulting to the photo itself. + * + * @param id Unique identifier for this result, 1-64 bytes + * @param photo_url A valid URL of the photo. Photo must be in JPEG format. Photo size must not exceed 5MB + * @param options Remaining options + */ + photo(id, photo_url, options = { + thumbnail_url: typeof photo_url === "string" + ? photo_url + : photo_url.href, + }) { + return inputMessage({ + type: "photo", + id, + photo_url: typeof photo_url === "string" + ? photo_url + : photo_url.href, + ...options, + }); + }, + /** + * Builds an InlineQueryResultCachedPhoto object as specified by + * https://core.telegram.org/bots/api#inlinequeryresultcachedphoto. + * + * @param id Unique identifier for this result, 1-64 bytes + * @param photo_file_id A valid file identifier of the photo + * @param options Remaining options + */ + photoCached(id, photo_file_id, options = {}) { + return inputMessage({ type: "photo", id, photo_file_id, ...options }); + }, + /** + * Builds an InlineQueryResultCachedSticker object as specified by + * https://core.telegram.org/bots/api#inlinequeryresultcachedsticker. + * + * @param id Unique identifier for this result, 1-64 bytes + * @param sticker_file_id A valid file identifier of the sticker + * @param options Remaining options + */ + stickerCached(id, sticker_file_id, options = {}) { + return inputMessage({ type: "sticker", id, sticker_file_id, ...options }); + }, + /** + * Builds an InlineQueryResultVenue object as specified by + * https://core.telegram.org/bots/api#inlinequeryresultvenue. + * + * @param id Unique identifier for this result, 1-64 Bytes + * @param title Title of the venue + * @param latitude Latitude of the venue location in degrees + * @param longitude Longitude of the venue location in degrees + * @param address Address of the venue + * @param options Remaining options + */ + venue(id, title, latitude, longitude, address, options = {}) { + return inputMessage({ + type: "venue", + id, + title, + latitude, + longitude, + address, + ...options, + }); + }, + /** + * Builds an InlineQueryResultVideo object as specified by + * https://core.telegram.org/bots/api#inlinequeryresultvideo with mime_type + * set to "text/html". This will send an embedded video player. Requires you + * to specify the actual message content by calling another function on the + * object returned from this method. + * + * @param id Unique identifier for this result, 1-64 bytes + * @param title Title for the result + * @param video_url A valid URL for the embedded video player + * @param thumbnail_url URL of the thumbnail (JPEG only) for the video + * @param options Remaining options + */ + videoHtml(id, title, video_url, thumbnail_url, options = {}) { + // require input message content by only returning methods + return inputMessageMethods({ + type: "video", + mime_type: "text/html", + id, + title, + video_url: typeof video_url === "string" + ? video_url + : video_url.href, + thumbnail_url: typeof thumbnail_url === "string" + ? thumbnail_url + : thumbnail_url.href, + ...options, + }); + }, + /** + * Builds an InlineQueryResultVideo object as specified by + * https://core.telegram.org/bots/api#inlinequeryresultvideo with mime_type + * set to "video/mp4". + * + * @param id Unique identifier for this result, 1-64 bytes + * @param title Title for the result + * @param video_url A valid URL for the video file + * @param thumbnail_url URL of the thumbnail (JPEG only) for the video + * @param options Remaining options + */ + videoMp4(id, title, video_url, thumbnail_url, options = {}) { + return inputMessage({ + type: "video", + mime_type: "video/mp4", + id, + title, + video_url: typeof video_url === "string" + ? video_url + : video_url.href, + thumbnail_url: typeof thumbnail_url === "string" + ? thumbnail_url + : thumbnail_url.href, + ...options, + }); + }, + /** + * Builds an InlineQueryResultCachedVideo object as specified by + * https://core.telegram.org/bots/api#inlinequeryresultcachedvideo. + * + * @param id Unique identifier for this result, 1-64 bytes + * @param title Title for the result + * @param video_file_id A valid file identifier for the video file + * @param options Remaining options + */ + videoCached(id, title, video_file_id, options = {}) { + return inputMessage({ type: "video", id, title, video_file_id, ...options }); + }, + /** + * Builds an InlineQueryResultVoice object as specified by + * https://core.telegram.org/bots/api#inlinequeryresultvoice. + * + * @param id Unique identifier for this result, 1-64 bytes + * @param title Voice message title + * @param voice_url A valid URL for the voice recording + * @param options Remaining options + */ + voice(id, title, voice_url, options = {}) { + return inputMessage({ + type: "voice", + id, + title, + voice_url: typeof voice_url === "string" + ? voice_url + : voice_url.href, + ...options, + }); + }, + /** + * Builds an InlineQueryResultCachedVoice object as specified by + * https://core.telegram.org/bots/api#inlinequeryresultcachedvoice. + * + * @param id Unique identifier for this result, 1-64 bytes + * @param title Voice message title + * @param voice_file_id A valid file identifier for the voice message + * @param options Remaining options + */ + voiceCached(id, title, voice_file_id, options = {}) { + return inputMessage({ type: "voice", id, title, voice_file_id, ...options }); + }, +}; diff --git a/sandbox/tgbot/node_modules/grammy/out/convenience/input_media.d.ts b/sandbox/tgbot/node_modules/grammy/out/convenience/input_media.d.ts new file mode 100644 index 0000000..40ea59e --- /dev/null +++ b/sandbox/tgbot/node_modules/grammy/out/convenience/input_media.d.ts @@ -0,0 +1,72 @@ +import { type InputFile, type InputMediaAnimation, type InputMediaAudio, type InputMediaDocument, type InputMediaPhoto, type InputMediaVideo } from "../types.js"; +type InputMediaOptions = Omit; +/** + * Holds a number of helper methods for building `InputMedia*` objects. They are + * useful when sending media groups and when editing media messages. + * + * For example, media groups can be sent like this. + * + * ```ts + * const paths = [ + * '/tmp/pic0.jpg', + * '/tmp/pic1.jpg', + * '/tmp/pic2.jpg', + * ] + * const files = paths.map((path) => new InputFile(path)) + * const media = files.map((file) => InputMediaBuilder.photo(file)) + * await bot.api.sendMediaGroup(chatId, media) + * ``` + * + * Media can be edited like this. + * + * ```ts + * const file = new InputFile('/tmp/pic0.jpg') + * const media = InputMediaBuilder.photo(file, { + * caption: 'new caption' + * }) + * await bot.api.editMessageMedia(chatId, messageId, media) + * ``` + */ +export declare const InputMediaBuilder: { + /** + * Creates a new `InputMediaPhoto` object as specified by + * https://core.telegram.org/bots/api#inputmediaphoto. + * + * @param media An `InputFile` instance or a file identifier + * @param options Remaining optional options + */ + photo(media: string | InputFile, options?: InputMediaOptions): InputMediaPhoto; + /** + * Creates a new `InputMediaVideo` object as specified by + * https://core.telegram.org/bots/api#inputmediavideo. + * + * @param media An `InputFile` instance or a file identifier + * @param options Remaining optional options + */ + video(media: string | InputFile, options?: InputMediaOptions): InputMediaVideo; + /** + * Creates a new `InputMediaAnimation` object as specified by + * https://core.telegram.org/bots/api#inputmediaanimation. + * + * @param media An `InputFile` instance or a file identifier + * @param options Remaining optional options + */ + animation(media: string | InputFile, options?: InputMediaOptions): InputMediaAnimation; + /** + * Creates a new `InputMediaAudio` object as specified by + * https://core.telegram.org/bots/api#inputmediaaudio. + * + * @param media An `InputFile` instance or a file identifier + * @param options Remaining optional options + */ + audio(media: string | InputFile, options?: InputMediaOptions): InputMediaAudio; + /** + * Creates a new `InputMediaDocument` object as specified by + * https://core.telegram.org/bots/api#inputmediadocument. + * + * @param media An `InputFile` instance or a file identifier + * @param options Remaining optional options + */ + document(media: string | InputFile, options?: InputMediaOptions): InputMediaDocument; +}; +export {}; diff --git a/sandbox/tgbot/node_modules/grammy/out/convenience/input_media.js b/sandbox/tgbot/node_modules/grammy/out/convenience/input_media.js new file mode 100644 index 0000000..e618267 --- /dev/null +++ b/sandbox/tgbot/node_modules/grammy/out/convenience/input_media.js @@ -0,0 +1,82 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.InputMediaBuilder = void 0; +/** + * Holds a number of helper methods for building `InputMedia*` objects. They are + * useful when sending media groups and when editing media messages. + * + * For example, media groups can be sent like this. + * + * ```ts + * const paths = [ + * '/tmp/pic0.jpg', + * '/tmp/pic1.jpg', + * '/tmp/pic2.jpg', + * ] + * const files = paths.map((path) => new InputFile(path)) + * const media = files.map((file) => InputMediaBuilder.photo(file)) + * await bot.api.sendMediaGroup(chatId, media) + * ``` + * + * Media can be edited like this. + * + * ```ts + * const file = new InputFile('/tmp/pic0.jpg') + * const media = InputMediaBuilder.photo(file, { + * caption: 'new caption' + * }) + * await bot.api.editMessageMedia(chatId, messageId, media) + * ``` + */ +exports.InputMediaBuilder = { + /** + * Creates a new `InputMediaPhoto` object as specified by + * https://core.telegram.org/bots/api#inputmediaphoto. + * + * @param media An `InputFile` instance or a file identifier + * @param options Remaining optional options + */ + photo(media, options = {}) { + return { type: "photo", media, ...options }; + }, + /** + * Creates a new `InputMediaVideo` object as specified by + * https://core.telegram.org/bots/api#inputmediavideo. + * + * @param media An `InputFile` instance or a file identifier + * @param options Remaining optional options + */ + video(media, options = {}) { + return { type: "video", media, ...options }; + }, + /** + * Creates a new `InputMediaAnimation` object as specified by + * https://core.telegram.org/bots/api#inputmediaanimation. + * + * @param media An `InputFile` instance or a file identifier + * @param options Remaining optional options + */ + animation(media, options = {}) { + return { type: "animation", media, ...options }; + }, + /** + * Creates a new `InputMediaAudio` object as specified by + * https://core.telegram.org/bots/api#inputmediaaudio. + * + * @param media An `InputFile` instance or a file identifier + * @param options Remaining optional options + */ + audio(media, options = {}) { + return { type: "audio", media, ...options }; + }, + /** + * Creates a new `InputMediaDocument` object as specified by + * https://core.telegram.org/bots/api#inputmediadocument. + * + * @param media An `InputFile` instance or a file identifier + * @param options Remaining optional options + */ + document(media, options = {}) { + return { type: "document", media, ...options }; + }, +}; diff --git a/sandbox/tgbot/node_modules/grammy/out/convenience/keyboard.d.ts b/sandbox/tgbot/node_modules/grammy/out/convenience/keyboard.d.ts new file mode 100644 index 0000000..2c5af29 --- /dev/null +++ b/sandbox/tgbot/node_modules/grammy/out/convenience/keyboard.d.ts @@ -0,0 +1,879 @@ +import { type CopyTextButton, type InlineKeyboardButton, type KeyboardButton, type KeyboardButtonPollType, type KeyboardButtonRequestChat, type KeyboardButtonRequestUsers, type LoginUrl, type SwitchInlineQueryChosenChat, type WebAppInfo } from "../types.js"; +type KeyboardButtonSource = string | KeyboardButton; +type KeyboardSource = KeyboardButtonSource[][] | Keyboard; +/** + * Use this class to simplify building a custom keyboard (something like this: + * https://core.telegram.org/bots/features#keyboards). + * + * ```ts + * // Build a custom keyboard: + * const keyboard = new Keyboard() + * .text('A').text('B').row() + * .text('C').text('D') + * + * // Now you can send it like so: + * await ctx.reply('Here is your custom keyboard!', { + * reply_markup: keyboard + * }) + * ``` + * + * If you already have some source data which you would like to turn into a + * keyboard button object, you can use the static equivalents which every button + * has. You can use them to create a two-dimensional keyboard button array. The + * resulting array can be turned into a keyboard instance. + * + * ```ts + * const button = Keyboard.text('push my buttons') + * const array = [[button]] + * const keyboard = Keyboard.from(array) + * ``` + * + * If you want to create text buttons only, you can directly use a + * two-dimensional string array and turn it into a keyboard. + * + * ```ts + * const data = [['A', 'B'], ['C', 'D']] + * const keyboard = Keyboard.from(data) + * ``` + * + * Be sure to check out the + * [documentation](https://grammy.dev/plugins/keyboard#custom-keyboards) on + * custom keyboards in grammY. + */ +export declare class Keyboard { + readonly keyboard: KeyboardButton[][]; + /** + * Requests clients to always show the keyboard when the regular keyboard is + * hidden. Defaults to false, in which case the custom keyboard can be + * hidden and opened with a keyboard icon. + */ + is_persistent?: boolean; + /** + * Show the current keyboard only to those users that are mentioned in the + * text of the message object. + */ + selective?: boolean; + /** + * Hide the keyboard after a button is pressed. + */ + one_time_keyboard?: boolean; + /** + * Resize the current keyboard according to its buttons. Usually, this will + * make the keyboard smaller. + */ + resize_keyboard?: boolean; + /** + * Placeholder to be shown in the input field when the keyboard is active. + */ + input_field_placeholder?: string; + /** + * Initialize a new `Keyboard` with an optional two-dimensional array of + * `KeyboardButton` objects. This is the nested array that holds the custom + * keyboard. It will be extended every time you call one of the provided + * methods. + * + * @param keyboard An optional initial two-dimensional button array + */ + constructor(keyboard?: KeyboardButton[][]); + /** + * Allows you to add your own `KeyboardButton` objects if you already have + * them for some reason. You most likely want to call one of the other + * methods. + * + * @param buttons The buttons to add + */ + add(...buttons: KeyboardButton[]): this; + /** + * Adds a 'line break'. Call this method to make sure that the next added + * buttons will be on a new row. + * + * You may pass a number of `KeyboardButton` objects if you already have the + * instances for some reason. You most likely don't want to pass any + * arguments to `row`. + * + * @param buttons A number of buttons to add to the next row + */ + row(...buttons: KeyboardButton[]): this; + /** + * Adds a new text button. This button will simply send the given text as a + * text message back to your bot if a user clicks on it. + * + * @param text The text to display, and optional styling information + * @param options Optional styling information + */ + text(text: string, options?: KeyboardButton.CommonButton["style"] | Omit): this; + /** + * Creates a new text button. This button will simply send the given text as + * a text message back to your bot if a user clicks on it. + * + * @param text The text to display, and optional styling information + * @param options Optional styling information + */ + static text(text: string, options?: KeyboardButton.CommonButton["style"] | Omit): KeyboardButton.CommonButton; + /** + * Adds a new request users button. When the user presses the button, a list + * of suitable users will be opened. Tapping on any number of users will + * send their identifiers to the bot in a “users_shared” service message. + * Available in private chats only. + * + * @param text The text to display, and optional styling information + * @param requestId A signed 32-bit identifier of the request + * @param options Options object for further requirements + */ + requestUsers(text: string | KeyboardButton.CommonButton, requestId: number, options?: Omit): this; + /** + * Creates a new request users button. When the user presses the button, a + * list of suitable users will be opened. Tapping on any number of users + * will send their identifiers to the bot in a “users_shared” service + * message. Available in private chats only. + * + * @param text The text to display, and optional styling information + * @param requestId A signed 32-bit identifier of the request + * @param options Options object for further requirements + */ + static requestUsers(text: string | KeyboardButton.CommonButton, requestId: number, options?: Omit): KeyboardButton.RequestUsersButton; + /** + * Adds a new request chat button. When the user presses the button, a list + * of suitable users will be opened. Tapping on a chat will send its + * identifier to the bot in a “chat_shared” service message. Available in + * private chats only. + * + * @param text The text to display, and optional styling information + * @param requestId A signed 32-bit identifier of the request + * @param options Options object for further requirements + */ + requestChat(text: string | KeyboardButton.CommonButton, requestId: number, options?: Omit): this; + /** + * Creates a new request chat button. When the user presses the button, a + * list of suitable users will be opened. Tapping on a chat will send its + * identifier to the bot in a “chat_shared” service message. Available in + * private chats only. + * + * @param text The text to display, and optional styling information + * @param requestId A signed 32-bit identifier of the request + * @param options Options object for further requirements + */ + static requestChat(text: string | KeyboardButton.CommonButton, requestId: number, options?: Omit): KeyboardButton.RequestChatButton; + /** + * Adds a new contact request button. The user's phone number will be sent + * as a contact when the button is pressed. Available in private chats only. + * + * @param text The text to display, and optional styling information + */ + requestContact(text: string | KeyboardButton.CommonButton): this; + /** + * Creates a new contact request button. The user's phone number will be + * sent as a contact when the button is pressed. Available in private chats + * only. + * + * @param text The text to display, and optional styling information + */ + static requestContact(text: string | KeyboardButton.CommonButton): KeyboardButton.RequestContactButton; + /** + * Adds a new location request button. The user's current location will be + * sent when the button is pressed. Available in private chats only. + * + * @param text The text to display, and optional styling information + */ + requestLocation(text: string | KeyboardButton.CommonButton): this; + /** + * Creates a new location request button. The user's current location will + * be sent when the button is pressed. Available in private chats only. + * + * @param text The text to display, and optional styling information + */ + static requestLocation(text: string | KeyboardButton.CommonButton): KeyboardButton.RequestLocationButton; + /** + * Adds a new poll request button. The user will be asked to create a poll + * and send it to the bot when the button is pressed. Available in private + * chats only. + * + * @param text The text to display, and optional styling information + * @param type The type of permitted polls to create, omit if the user may + * send a poll of any type + */ + requestPoll(text: string | KeyboardButton.CommonButton, type?: KeyboardButtonPollType["type"]): this; + /** + * Creates a new poll request button. The user will be asked to create a + * poll and send it to the bot when the button is pressed. Available in + * private chats only. + * + * @param text The text to display, and optional styling information + * @param type The type of permitted polls to create, omit if the user may + * send a poll of any type + */ + static requestPoll(text: string | KeyboardButton.CommonButton, type?: KeyboardButtonPollType["type"]): KeyboardButton.RequestPollButton; + /** + * Adds a new web app button. The Web App that will be launched when the + * user presses the button. The Web App will be able to send a + * “web_app_data” service message. Available in private chats only. + * + * @param text The text to display, and optional styling information + * @param url An HTTPS URL of a Web App to be opened with additional data + */ + webApp(text: string | KeyboardButton.CommonButton, url: string): this; + /** + * Creates a new web app button. The Web App that will be launched when the + * user presses the button. The Web App will be able to send a + * “web_app_data” service message. Available in private chats only. + * + * @param text The text to display, and optional styling information + * @param url An HTTPS URL of a Web App to be opened with additional data + */ + static webApp(text: string | KeyboardButton.CommonButton, url: string): KeyboardButton.WebAppButton; + /** + * Adds a style to the last added button of the keyboard. + * + * ```ts + * const keyboard = new Keyboard() + * .text('blue button') + * .style('primary') + * ``` + * + * @param style Style of the button + */ + style(style: KeyboardButton.CommonButton["style"]): this; + /** + * Adds a danger style to the last added button of the keyboard. Alias for + * `.style('danger')`. + * + * ```ts + * const keyboard = new Keyboard() + * .text('red button') + * .danger() + * ``` + */ + danger(): this; + /** + * Adds a success style to the last added button of the keyboard. Alias for + * `.style('success')`. + * + * ```ts + * const keyboard = new Keyboard() + * .text('green button') + * .success() + * ``` + */ + success(): this; + /** + * Adds a primary style to the last added button of the keyboard. Alias for + * `.style('primary')`. + * + * ```ts + * const keyboard = new Keyboard() + * .text('blue button') + * .primary() + * ``` + */ + primary(): this; + /** + * Adds a custom emoji icon to the last added button of the keyboard. + * + * ```ts + * const keyboard = new Keyboard() + * .text('button with icon') + * .icon(myCustomEmojiIconIdentifier) + * ``` + * + * @param icon Unique identifier of the custom emoji shown before the text of the button + */ + icon(icon: KeyboardButton.CommonButton["icon_custom_emoji_id"]): this; + /** + * Make the current keyboard persistent. See + * https://grammy.dev/plugins/keyboard#persistent-keyboards for more + * details. + * + * Keyboards are not persistent by default, use this function to enable it + * (without any parameters or pass `true`). Pass `false` to force the + * keyboard to not persist. + * + * @param isEnabled `true` if the keyboard should persist, and `false` otherwise + */ + persistent(isEnabled?: boolean): this; + /** + * Make the current keyboard selective. See + * https://grammy.dev/plugins/keyboard#selectively-send-custom-keyboards + * for more details. + * + * Keyboards are non-selective by default, use this function to enable it + * (without any parameters or pass `true`). Pass `false` to force the + * keyboard to be non-selective. + * + * @param isEnabled `true` if the keyboard should be selective, and `false` otherwise + */ + selected(isEnabled?: boolean): this; + /** + * Make the current keyboard one-time. See + * https://grammy.dev/plugins/keyboard#one-time-custom-keyboards for + * more details. + * + * Keyboards are non-one-time by default, use this function to enable it + * (without any parameters or pass `true`). Pass `false` to force the + * keyboard to be non-one-time. + * + * @param isEnabled `true` if the keyboard should be one-time, and `false` otherwise + */ + oneTime(isEnabled?: boolean): this; + /** + * Make the current keyboard resized. See + * https://grammy.dev/plugins/keyboard#resize-custom-keyboard for more + * details. + * + * Keyboards are non-resized by default, use this function to enable it + * (without any parameters or pass `true`). Pass `false` to force the + * keyboard to be non-resized. + * + * @param isEnabled `true` if the keyboard should be resized, and `false` otherwise + */ + resized(isEnabled?: boolean): this; + /** + * Set the current keyboard's input field placeholder. See + * https://grammy.dev/plugins/keyboard#input-field-placeholder for more + * details. + * + * @param value The placeholder text + */ + placeholder(value: string): this; + /** + * Creates a new keyboard that contains the transposed grid of buttons of + * this keyboard. This means that the resulting keyboard has the rows and + * columns flipped. + * + * Note that buttons can only span multiple columns, but never multiple + * rows. This means that if the given arrays have different lengths, some + * buttons might flow up in the layout. In these cases, transposing a + * keyboard a second time will not undo the first transposition. + * + * Here are some examples. + * + * ``` + * original transposed + * [ a ] ~> [ a ] + * + * [ a ] + * [a b c] ~> [ b ] + * [ c ] + * + * [ a b ] [a c e] + * [ c d ] ~> [ b d ] + * [ e ] + * + * [ a b ] [a c d] + * [ c ] ~> [ b e ] + * [d e f] [ f ] + * ``` + */ + toTransposed(): Keyboard; + /** + * Creates a new keyboard with the same buttons but reflowed into a given + * number of columns as if the buttons were text elements. Optionally, you + * can specify if the flow should make sure to fill up the last row. + * + * This method is idempotent, so calling it a second time will effectively + * clone this keyboard without reordering the buttons. + * + * Here are some examples. + * + * ``` + * original flowed + * [ a ] ~> [ a ] (4 columns) + * + * [ a ] + * [a b c] ~> [ b ] (1 column) + * [ c ] + * + * [ a b ] [a b c] + * [ c d ] ~> [ d e ] (3 columns) + * [ e ] + * + * [ a b ] [abcde] + * [ c ] ~> [ f ] (5 columns) + * [d e f] + * + * [a b c] [ a ] + * [d e f] ~> [b c d] (3 columns, { fillLastRow: true }) + * [g h i] [e f g] + * [ j ] [h i j] + * ``` + * + * @param columns Maximum number of buttons per row + * @param options Optional flowing behavior + */ + toFlowed(columns: number, options?: FlowOptions): Keyboard; + /** + * Creates and returns a deep copy of this keyboard. + * + * Optionally takes a new grid of buttons to replace the current buttons. If + * specified, only the options will be cloned, and the given buttons will be + * used instead. + */ + clone(keyboard?: KeyboardButton[][]): Keyboard; + /** + * Appends the buttons of the given keyboards to this keyboard. If other + * options are specified in these keyboards, they will be ignored. + * + * @param sources A number of keyboards to append + */ + append(...sources: KeyboardSource[]): this; + /** + * Returns the keyboard that was build. Note that it doesn't return + * `resize_keyboard` or other options that may be set. You don't usually + * need to call this method. It is no longer useful. + */ + build(): KeyboardButton[][]; + /** + * Turns a two-dimensional keyboard button array into a keyboard instance. + * You can use the static button builder methods to create keyboard button + * objects. + * + * @param source A two-dimensional button array + */ + static from(source: KeyboardSource): Keyboard; +} +type InlineKeyboardSource = InlineKeyboardButton[][] | InlineKeyboard; +/** + * Use this class to simplify building an inline keyboard (something like this: + * https://core.telegram.org/bots/features#inline-keyboards). + * + * ```ts + * // Build an inline keyboard: + * const keyboard = new InlineKeyboard() + * .text('A').text('B', 'callback-data').row() + * .text('C').text('D').row() + * .url('Telegram', 'telegram.org') + * + * // Send the keyboard: + * await ctx.reply('Here is your inline keyboard!', { + * reply_markup: keyboard + * }) + * ``` + * + * If you already have some source data which you would like to turn into an + * inline button object, you can use the static equivalents which every inline + * button has. You can use them to create a two-dimensional inline button array. + * The resulting array can be turned into a keyboard instance. + * + * ```ts + * const button = InlineKeyboard.text('GO', 'go') + * const array = [[button]] + * const keyboard = InlineKeyboard.from(array) + * ``` + * + * Be sure to to check the + * [documentation](https://grammy.dev/plugins/keyboard#inline-keyboards) on + * inline keyboards in grammY. + */ +export declare class InlineKeyboard { + readonly inline_keyboard: InlineKeyboardButton[][]; + /** + * Initialize a new `InlineKeyboard` with an optional two-dimensional array + * of `InlineKeyboardButton` objects. This is the nested array that holds + * the inline keyboard. It will be extended every time you call one of the + * provided methods. + * + * @param inline_keyboard An optional initial two-dimensional button array + */ + constructor(inline_keyboard?: InlineKeyboardButton[][]); + /** + * Allows you to add your own `InlineKeyboardButton` objects if you already + * have them for some reason. You most likely want to call one of the other + * methods. + * + * @param buttons The buttons to add + */ + add(...buttons: InlineKeyboardButton[]): this; + /** + * Adds a 'line break'. Call this method to make sure that the next added + * buttons will be on a new row. + * + * You may pass a number of `InlineKeyboardButton` objects if you already + * have the instances for some reason. You most likely don't want to pass + * any arguments to `row`. + * + * @param buttons A number of buttons to add to the next row + */ + row(...buttons: InlineKeyboardButton[]): this; + /** + * Adds a new URL button. Telegram clients will open the provided URL when + * the button is pressed. + * + * @param text The text to display, and optional styling information + * @param url HTTP or tg:// url to be opened when the button is pressed. Links tg://user?id= can be used to mention a user by their ID without using a username, if this is allowed by their privacy settings. + */ + url(text: string | InlineKeyboardButton.AbstractInlineKeyboardButton, url: string): this; + /** + * Creates a new URL button. Telegram clients will open the provided URL + * when the button is pressed. + * + * @param text The text to display, and optional styling information + * @param url HTTP or tg:// url to be opened when the button is pressed. Links tg://user?id= can be used to mention a user by their ID without using a username, if this is allowed by their privacy settings. + */ + static url(text: string | InlineKeyboardButton.AbstractInlineKeyboardButton, url: string): InlineKeyboardButton.UrlButton; + /** + * Adds a new callback query button. The button contains a text and a custom + * payload. This payload will be sent back to your bot when the button is + * pressed. If you omit the payload, the display text will be sent back to + * your bot. + * + * Your bot will receive an update every time a user presses any of the text + * buttons. You can listen to these updates like this: + * ```ts + * // Specific buttons: + * bot.callbackQuery('button-data', ctx => { ... }) + * // Any button of any inline keyboard: + * bot.on('callback_query:data', ctx => { ... }) + * ``` + * + * @param text The text to display, and optional styling information + * @param data The callback data to send back to your bot (default = text) + */ + text(text: string | InlineKeyboardButton.AbstractInlineKeyboardButton, data?: string): this; + /** + * Creates a new callback query button. The button contains a text and a + * custom payload. This payload will be sent back to your bot when the + * button is pressed. If you omit the payload, the display text will be sent + * back to your bot. + * + * Your bot will receive an update every time a user presses any of the text + * buttons. You can listen to these updates like this: + * ```ts + * // Specific buttons: + * bot.callbackQuery('button-data', ctx => { ... }) + * // Any button of any inline keyboard: + * bot.on('callback_query:data', ctx => { ... }) + * ``` + * + * @param text The text to display, and optional styling information + * @param data The callback data to send back to your bot (default = text) + */ + static text(text: string | InlineKeyboardButton.AbstractInlineKeyboardButton, data?: string): InlineKeyboardButton.CallbackButton; + /** + * Adds a new web app button, confer https://core.telegram.org/bots/webapps + * + * @param text The text to display, and optional styling information + * @param url An HTTPS URL of a Web App to be opened with additional data + */ + webApp(text: string | InlineKeyboardButton.AbstractInlineKeyboardButton, url: string | WebAppInfo): this; + /** + * Creates a new web app button, confer https://core.telegram.org/bots/webapps + * + * @param text The text to display, and optional styling information + * @param url An HTTPS URL of a Web App to be opened with additional data + */ + static webApp(text: string | InlineKeyboardButton.AbstractInlineKeyboardButton, url: string | WebAppInfo): InlineKeyboardButton.WebAppButton; + /** + * Adds a new login button. This can be used as a replacement for the + * Telegram Login Widget. You must specify an HTTPS URL used to + * automatically authorize the user. + * + * @param text The text to display, and optional styling information + * @param loginUrl The login URL as string or `LoginUrl` object + */ + login(text: string | InlineKeyboardButton.AbstractInlineKeyboardButton, loginUrl: string | LoginUrl): this; + /** + * Creates a new login button. This can be used as a replacement for the + * Telegram Login Widget. You must specify an HTTPS URL used to + * automatically authorize the user. + * + * @param text The text to display, and optional styling information + * @param loginUrl The login URL as string or `LoginUrl` object + */ + static login(text: string | InlineKeyboardButton.AbstractInlineKeyboardButton, loginUrl: string | LoginUrl): InlineKeyboardButton.LoginButton; + /** + * Adds a new inline query button. Telegram clients will let the user pick a + * chat when this button is pressed. This will start an inline query. The + * selected chat will be prefilled with the name of your bot. You may + * provide a text that is specified along with it. + * + * Your bot will in turn receive updates for inline queries. You can listen + * to inline query updates like this: + * ```ts + * bot.on('inline_query', ctx => { ... }) + * ``` + * + * @param text The text to display, and optional styling information + * @param query The (optional) inline query string to prefill + */ + switchInline(text: string | InlineKeyboardButton.AbstractInlineKeyboardButton, query?: string): this; + /** + * Creates a new inline query button. Telegram clients will let the user pick a + * chat when this button is pressed. This will start an inline query. The + * selected chat will be prefilled with the name of your bot. You may + * provide a text that is specified along with it. + * + * Your bot will in turn receive updates for inline queries. You can listen + * to inline query updates like this: + * ```ts + * bot.on('inline_query', ctx => { ... }) + * ``` + * + * @param text The text to display, and optional styling information + * @param query The (optional) inline query string to prefill + */ + static switchInline(text: string | InlineKeyboardButton.AbstractInlineKeyboardButton, query?: string): InlineKeyboardButton.SwitchInlineButton; + /** + * Adds a new inline query button that acts on the current chat. The + * selected chat will be prefilled with the name of your bot. You may + * provide a text that is specified along with it. This will start an inline + * query. + * + * Your bot will in turn receive updates for inline queries. You can listen + * to inline query updates like this: + * ```ts + * bot.on('inline_query', ctx => { ... }) + * ``` + * + * @param text The text to display, and optional styling information + * @param query The (optional) inline query string to prefill + */ + switchInlineCurrent(text: string | InlineKeyboardButton.AbstractInlineKeyboardButton, query?: string): this; + /** + * Creates a new inline query button that acts on the current chat. The + * selected chat will be prefilled with the name of your bot. You may + * provide a text that is specified along with it. This will start an inline + * query. + * + * Your bot will in turn receive updates for inline queries. You can listen + * to inline query updates like this: + * ```ts + * bot.on('inline_query', ctx => { ... }) + * ``` + * + * @param text The text to display, and optional styling information + * @param query The (optional) inline query string to prefill + */ + static switchInlineCurrent(text: string | InlineKeyboardButton.AbstractInlineKeyboardButton, query?: string): InlineKeyboardButton.SwitchInlineCurrentChatButton; + /** + * Adds a new inline query button. Telegram clients will let the user pick a + * chat when this button is pressed. This will start an inline query. The + * selected chat will be prefilled with the name of your bot. You may + * provide a text that is specified along with it. + * + * Your bot will in turn receive updates for inline queries. You can listen + * to inline query updates like this: + * ```ts + * bot.on('inline_query', ctx => { ... }) + * ``` + * + * @param text The text to display, and optional styling information + * @param query The query object describing which chats can be picked + */ + switchInlineChosen(text: string | InlineKeyboardButton.AbstractInlineKeyboardButton, query?: SwitchInlineQueryChosenChat): this; + /** + * Creates a new inline query button. Telegram clients will let the user pick a + * chat when this button is pressed. This will start an inline query. The + * selected chat will be prefilled with the name of your bot. You may + * provide a text that is specified along with it. + * + * Your bot will in turn receive updates for inline queries. You can listen + * to inline query updates like this: + * ```ts + * bot.on('inline_query', ctx => { ... }) + * ``` + * + * @param text The text to display, and optional styling information + * @param query The query object describing which chats can be picked + */ + static switchInlineChosen(text: string | InlineKeyboardButton.AbstractInlineKeyboardButton, query?: SwitchInlineQueryChosenChat): InlineKeyboardButton.SwitchInlineChosenChatButton; + /** + * Adds a new copy text button. When clicked, the specified text will be + * copied to the clipboard. + * + * @param text The text to display, and optional styling information + * @param copyText The text to be copied to the clipboard + */ + copyText(text: string | InlineKeyboardButton.AbstractInlineKeyboardButton, copyText: string | CopyTextButton): this; + /** + * Creates a new copy text button. When clicked, the specified text will be + * copied to the clipboard. + * + * @param text The text to display, and optional styling information + * @param copyText The text to be copied to the clipboard + */ + static copyText(text: string | InlineKeyboardButton.AbstractInlineKeyboardButton, copyText: string | CopyTextButton): InlineKeyboardButton.CopyTextButtonButton; + /** + * Adds a new game query button, confer + * https://core.telegram.org/bots/api#games + * + * This type of button must always be the first button in the first row. + * + * @param text The text to display, and optional styling information + */ + game(text: string | InlineKeyboardButton.AbstractInlineKeyboardButton): this; + /** + * Creates a new game query button, confer + * https://core.telegram.org/bots/api#games + * + * This type of button must always be the first button in the first row. + * + * @param text The text to display, and optional styling information + */ + static game(text: string | InlineKeyboardButton.AbstractInlineKeyboardButton): InlineKeyboardButton.GameButton; + /** + * Adds a new payment button, confer + * https://core.telegram.org/bots/api#payments + * + * This type of button must always be the first button in the first row and + * can only be used in invoice messages. + * + * @param text The text to display, and optional styling information. Substrings “⭐” and “XTR” in the buttons's text will be replaced with a Telegram Star icon. + */ + pay(text: string | InlineKeyboardButton.AbstractInlineKeyboardButton): this; + /** + * Create a new payment button, confer + * https://core.telegram.org/bots/api#payments + * + * This type of button must always be the first button in the first row and + * can only be used in invoice messages. + * + * @param text The text to display, and optional styling information. Substrings “⭐” and “XTR” in the buttons's text will be replaced with a Telegram Star icon. + */ + static pay(text: string | InlineKeyboardButton.AbstractInlineKeyboardButton): InlineKeyboardButton.PayButton; + /** + * Adds a style to the last added button of the inline keyboard. + * + * ```ts + * const keyboard = new InlineKeyboard() + * .text('blue button') + * .style('primary') + * ``` + * + * @param style Style of the button + */ + style(style: InlineKeyboardButton.AbstractInlineKeyboardButton["style"]): this; + /** + * Adds a danger style to the last added button of the inline keyboard. + * Alias for `.style('danger')`. + * + * ```ts + * const keyboard = new InlineKeyboard() + * .text('red button') + * .danger() + * ``` + */ + danger(): this; + /** + * Adds a success style to the last added button of the inline keyboard. + * Alias for `.style('success')`. + * + * ```ts + * const keyboard = new InlineKeyboard() + * .text('green button') + * .success() + * ``` + */ + success(): this; + /** + * Adds a primary style to the last added button of the inline keyboard. + * Alias for `.style('primary')`. + * + * ```ts + * const keyboard = new InlineKeyboard() + * .text('blue button') + * .primary() + * ``` + */ + primary(): this; + /** + * Adds a custom emoji icon to the last added button of the inline keyboard. + * + * ```ts + * const keyboard = new InlineKeyboard() + * .text('button with icon') + * .icon(myCustomEmojiIconIdentifier) + * ``` + * + * @param icon Unique identifier of the custom emoji shown before the text of the button + */ + icon(icon: InlineKeyboardButton.AbstractInlineKeyboardButton["icon_custom_emoji_id"]): this; + /** + * Creates a new inline keyboard that contains the transposed grid of + * buttons of this inline keyboard. This means that the resulting inline + * keyboard has the rows and columns flipped. + * + * Note that inline buttons can only span multiple columns, but never + * multiple rows. This means that if the given arrays have different + * lengths, some buttons might flow up in the layout. In these cases, + * transposing an inline keyboard a second time will not undo the first + * transposition. + * + * Here are some examples. + * + * ``` + * original transposed + * [ a ] ~> [ a ] + * + * [ a ] + * [a b c] ~> [ b ] + * [ c ] + * + * [ a b ] [a c e] + * [ c d ] ~> [ b d ] + * [ e ] + * + * [ a b ] [a c d] + * [ c ] ~> [ b e ] + * [d e f] [ f ] + * ``` + */ + toTransposed(): InlineKeyboard; + /** + * Creates a new inline keyboard with the same buttons but reflowed into a + * given number of columns as if the buttons were text elements. Optionally, + * you can specify if the flow should make sure to fill up the last row. + * + * This method is idempotent, so calling it a second time will effectively + * clone this inline keyboard without reordering the buttons. + * + * Here are some examples. + * + * ``` + * original flowed + * [ a ] ~> [ a ] (4 columns) + * + * [ a ] + * [a b c] ~> [ b ] (1 column) + * [ c ] + * + * [ a b ] [a b c] + * [ c d ] ~> [ d e ] (3 columns) + * [ e ] + * + * [ a b ] [abcde] + * [ c ] ~> [ f ] (5 columns) + * [d e f] + * + * [a b c] [ a ] + * [d e f] ~> [b c d] (3 columns, { fillLastRow: true }) + * [g h i] [e f g] + * [ j ] [h i j] + * ``` + * + * @param columns Maximum number of buttons per row + * @param options Optional flowing behavior + */ + toFlowed(columns: number, options?: FlowOptions): InlineKeyboard; + /** + * Creates and returns a deep copy of this inline keyboard. + */ + clone(): InlineKeyboard; + /** + * Appends the buttons of the given inline keyboards to this keyboard. + * + * @param sources A number of inline keyboards to append + */ + append(...sources: InlineKeyboardSource[]): this; + /** + * Turns a two-dimensional inline button array into an inline keyboard + * instance. You can use the static button builder methods to create inline + * button objects. + * + * @param source A two-dimensional inline button array + */ + static from(source: InlineKeyboardSource): InlineKeyboard; +} +interface FlowOptions { + /** Set to `true` to completely fill up the last row */ + fillLastRow?: boolean; +} +export {}; diff --git a/sandbox/tgbot/node_modules/grammy/out/convenience/keyboard.js b/sandbox/tgbot/node_modules/grammy/out/convenience/keyboard.js new file mode 100644 index 0000000..c52e9b7 --- /dev/null +++ b/sandbox/tgbot/node_modules/grammy/out/convenience/keyboard.js @@ -0,0 +1,1155 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.InlineKeyboard = exports.Keyboard = void 0; +/** + * Use this class to simplify building a custom keyboard (something like this: + * https://core.telegram.org/bots/features#keyboards). + * + * ```ts + * // Build a custom keyboard: + * const keyboard = new Keyboard() + * .text('A').text('B').row() + * .text('C').text('D') + * + * // Now you can send it like so: + * await ctx.reply('Here is your custom keyboard!', { + * reply_markup: keyboard + * }) + * ``` + * + * If you already have some source data which you would like to turn into a + * keyboard button object, you can use the static equivalents which every button + * has. You can use them to create a two-dimensional keyboard button array. The + * resulting array can be turned into a keyboard instance. + * + * ```ts + * const button = Keyboard.text('push my buttons') + * const array = [[button]] + * const keyboard = Keyboard.from(array) + * ``` + * + * If you want to create text buttons only, you can directly use a + * two-dimensional string array and turn it into a keyboard. + * + * ```ts + * const data = [['A', 'B'], ['C', 'D']] + * const keyboard = Keyboard.from(data) + * ``` + * + * Be sure to check out the + * [documentation](https://grammy.dev/plugins/keyboard#custom-keyboards) on + * custom keyboards in grammY. + */ +class Keyboard { + /** + * Initialize a new `Keyboard` with an optional two-dimensional array of + * `KeyboardButton` objects. This is the nested array that holds the custom + * keyboard. It will be extended every time you call one of the provided + * methods. + * + * @param keyboard An optional initial two-dimensional button array + */ + constructor(keyboard = [[]]) { + this.keyboard = keyboard; + } + /** + * Allows you to add your own `KeyboardButton` objects if you already have + * them for some reason. You most likely want to call one of the other + * methods. + * + * @param buttons The buttons to add + */ + add(...buttons) { + var _a; + (_a = this.keyboard[this.keyboard.length - 1]) === null || _a === void 0 ? void 0 : _a.push(...buttons); + return this; + } + /** + * Adds a 'line break'. Call this method to make sure that the next added + * buttons will be on a new row. + * + * You may pass a number of `KeyboardButton` objects if you already have the + * instances for some reason. You most likely don't want to pass any + * arguments to `row`. + * + * @param buttons A number of buttons to add to the next row + */ + row(...buttons) { + this.keyboard.push(buttons); + return this; + } + /** + * Adds a new text button. This button will simply send the given text as a + * text message back to your bot if a user clicks on it. + * + * @param text The text to display, and optional styling information + * @param options Optional styling information + */ + text(text, options) { + return this.add(Keyboard.text(text, options)); + } + /** + * Creates a new text button. This button will simply send the given text as + * a text message back to your bot if a user clicks on it. + * + * @param text The text to display, and optional styling information + * @param options Optional styling information + */ + static text(text, options) { + return typeof options === "string" + ? { text, style: options } + : { text, ...options }; + } + /** + * Adds a new request users button. When the user presses the button, a list + * of suitable users will be opened. Tapping on any number of users will + * send their identifiers to the bot in a “users_shared” service message. + * Available in private chats only. + * + * @param text The text to display, and optional styling information + * @param requestId A signed 32-bit identifier of the request + * @param options Options object for further requirements + */ + requestUsers(text, requestId, options = {}) { + return this.add(Keyboard.requestUsers(text, requestId, options)); + } + /** + * Creates a new request users button. When the user presses the button, a + * list of suitable users will be opened. Tapping on any number of users + * will send their identifiers to the bot in a “users_shared” service + * message. Available in private chats only. + * + * @param text The text to display, and optional styling information + * @param requestId A signed 32-bit identifier of the request + * @param options Options object for further requirements + */ + static requestUsers(text, requestId, options = {}) { + return typeof text === "string" + ? { text, request_users: { request_id: requestId, ...options } } + : { ...text, request_users: { request_id: requestId, ...options } }; + } + /** + * Adds a new request chat button. When the user presses the button, a list + * of suitable users will be opened. Tapping on a chat will send its + * identifier to the bot in a “chat_shared” service message. Available in + * private chats only. + * + * @param text The text to display, and optional styling information + * @param requestId A signed 32-bit identifier of the request + * @param options Options object for further requirements + */ + requestChat(text, requestId, options = { + chat_is_channel: false, + }) { + return this.add(Keyboard.requestChat(text, requestId, options)); + } + /** + * Creates a new request chat button. When the user presses the button, a + * list of suitable users will be opened. Tapping on a chat will send its + * identifier to the bot in a “chat_shared” service message. Available in + * private chats only. + * + * @param text The text to display, and optional styling information + * @param requestId A signed 32-bit identifier of the request + * @param options Options object for further requirements + */ + static requestChat(text, requestId, options = { + chat_is_channel: false, + }) { + const request_chat = { request_id: requestId, ...options }; + return typeof text === "string" + ? { text, request_chat } + : { ...text, request_chat }; + } + /** + * Adds a new contact request button. The user's phone number will be sent + * as a contact when the button is pressed. Available in private chats only. + * + * @param text The text to display, and optional styling information + */ + requestContact(text) { + return this.add(Keyboard.requestContact(text)); + } + /** + * Creates a new contact request button. The user's phone number will be + * sent as a contact when the button is pressed. Available in private chats + * only. + * + * @param text The text to display, and optional styling information + */ + static requestContact(text) { + const request_contact = true; + return typeof text === "string" + ? { text, request_contact } + : { ...text, request_contact }; + } + /** + * Adds a new location request button. The user's current location will be + * sent when the button is pressed. Available in private chats only. + * + * @param text The text to display, and optional styling information + */ + requestLocation(text) { + return this.add(Keyboard.requestLocation(text)); + } + /** + * Creates a new location request button. The user's current location will + * be sent when the button is pressed. Available in private chats only. + * + * @param text The text to display, and optional styling information + */ + static requestLocation(text) { + const request_location = true; + return typeof text === "string" + ? { text, request_location } + : { ...text, request_location }; + } + /** + * Adds a new poll request button. The user will be asked to create a poll + * and send it to the bot when the button is pressed. Available in private + * chats only. + * + * @param text The text to display, and optional styling information + * @param type The type of permitted polls to create, omit if the user may + * send a poll of any type + */ + requestPoll(text, type) { + return this.add(Keyboard.requestPoll(text, type)); + } + /** + * Creates a new poll request button. The user will be asked to create a + * poll and send it to the bot when the button is pressed. Available in + * private chats only. + * + * @param text The text to display, and optional styling information + * @param type The type of permitted polls to create, omit if the user may + * send a poll of any type + */ + static requestPoll(text, type) { + const request_poll = { type }; + return typeof text === "string" + ? { text, request_poll } + : { ...text, request_poll }; + } + /** + * Adds a new web app button. The Web App that will be launched when the + * user presses the button. The Web App will be able to send a + * “web_app_data” service message. Available in private chats only. + * + * @param text The text to display, and optional styling information + * @param url An HTTPS URL of a Web App to be opened with additional data + */ + webApp(text, url) { + return this.add(Keyboard.webApp(text, url)); + } + /** + * Creates a new web app button. The Web App that will be launched when the + * user presses the button. The Web App will be able to send a + * “web_app_data” service message. Available in private chats only. + * + * @param text The text to display, and optional styling information + * @param url An HTTPS URL of a Web App to be opened with additional data + */ + static webApp(text, url) { + const web_app = { url }; + return typeof text === "string" + ? { text, web_app } + : { ...text, web_app }; + } + /** + * Adds a style to the last added button of the keyboard. + * + * ```ts + * const keyboard = new Keyboard() + * .text('blue button') + * .style('primary') + * ``` + * + * @param style Style of the button + */ + style(style) { + const rows = this.keyboard.length; + if (rows === 0) { + throw new Error("Need to add a button before applying a style!"); + } + const lastRow = this.keyboard[rows - 1]; + const cols = lastRow.length; + if (cols === 0) { + throw new Error("Need to add a button before applying a style!"); + } + let lastButton = lastRow[cols - 1]; + if (typeof lastButton === "string") { + lastButton = { text: lastButton }; + lastRow[cols - 1] = lastButton; + } + lastButton.style = style; + return this; + } + /** + * Adds a danger style to the last added button of the keyboard. Alias for + * `.style('danger')`. + * + * ```ts + * const keyboard = new Keyboard() + * .text('red button') + * .danger() + * ``` + */ + danger() { + return this.style("danger"); + } + /** + * Adds a success style to the last added button of the keyboard. Alias for + * `.style('success')`. + * + * ```ts + * const keyboard = new Keyboard() + * .text('green button') + * .success() + * ``` + */ + success() { + return this.style("success"); + } + /** + * Adds a primary style to the last added button of the keyboard. Alias for + * `.style('primary')`. + * + * ```ts + * const keyboard = new Keyboard() + * .text('blue button') + * .primary() + * ``` + */ + primary() { + return this.style("primary"); + } + /** + * Adds a custom emoji icon to the last added button of the keyboard. + * + * ```ts + * const keyboard = new Keyboard() + * .text('button with icon') + * .icon(myCustomEmojiIconIdentifier) + * ``` + * + * @param icon Unique identifier of the custom emoji shown before the text of the button + */ + icon(icon) { + const rows = this.keyboard.length; + if (rows === 0) { + throw new Error("Need to add a button before adding an icon!"); + } + const lastRow = this.keyboard[rows - 1]; + const cols = lastRow.length; + if (cols === 0) { + throw new Error("Need to add a button before adding an icon!"); + } + let lastButton = lastRow[cols - 1]; + if (typeof lastButton === "string") { + lastButton = { text: lastButton }; + lastRow[cols - 1] = lastButton; + } + lastButton.icon_custom_emoji_id = icon; + return this; + } + /** + * Make the current keyboard persistent. See + * https://grammy.dev/plugins/keyboard#persistent-keyboards for more + * details. + * + * Keyboards are not persistent by default, use this function to enable it + * (without any parameters or pass `true`). Pass `false` to force the + * keyboard to not persist. + * + * @param isEnabled `true` if the keyboard should persist, and `false` otherwise + */ + persistent(isEnabled = true) { + this.is_persistent = isEnabled; + return this; + } + /** + * Make the current keyboard selective. See + * https://grammy.dev/plugins/keyboard#selectively-send-custom-keyboards + * for more details. + * + * Keyboards are non-selective by default, use this function to enable it + * (without any parameters or pass `true`). Pass `false` to force the + * keyboard to be non-selective. + * + * @param isEnabled `true` if the keyboard should be selective, and `false` otherwise + */ + selected(isEnabled = true) { + this.selective = isEnabled; + return this; + } + /** + * Make the current keyboard one-time. See + * https://grammy.dev/plugins/keyboard#one-time-custom-keyboards for + * more details. + * + * Keyboards are non-one-time by default, use this function to enable it + * (without any parameters or pass `true`). Pass `false` to force the + * keyboard to be non-one-time. + * + * @param isEnabled `true` if the keyboard should be one-time, and `false` otherwise + */ + oneTime(isEnabled = true) { + this.one_time_keyboard = isEnabled; + return this; + } + /** + * Make the current keyboard resized. See + * https://grammy.dev/plugins/keyboard#resize-custom-keyboard for more + * details. + * + * Keyboards are non-resized by default, use this function to enable it + * (without any parameters or pass `true`). Pass `false` to force the + * keyboard to be non-resized. + * + * @param isEnabled `true` if the keyboard should be resized, and `false` otherwise + */ + resized(isEnabled = true) { + this.resize_keyboard = isEnabled; + return this; + } + /** + * Set the current keyboard's input field placeholder. See + * https://grammy.dev/plugins/keyboard#input-field-placeholder for more + * details. + * + * @param value The placeholder text + */ + placeholder(value) { + this.input_field_placeholder = value; + return this; + } + /** + * Creates a new keyboard that contains the transposed grid of buttons of + * this keyboard. This means that the resulting keyboard has the rows and + * columns flipped. + * + * Note that buttons can only span multiple columns, but never multiple + * rows. This means that if the given arrays have different lengths, some + * buttons might flow up in the layout. In these cases, transposing a + * keyboard a second time will not undo the first transposition. + * + * Here are some examples. + * + * ``` + * original transposed + * [ a ] ~> [ a ] + * + * [ a ] + * [a b c] ~> [ b ] + * [ c ] + * + * [ a b ] [a c e] + * [ c d ] ~> [ b d ] + * [ e ] + * + * [ a b ] [a c d] + * [ c ] ~> [ b e ] + * [d e f] [ f ] + * ``` + */ + toTransposed() { + const original = this.keyboard; + const transposed = transpose(original); + return this.clone(transposed); + } + /** + * Creates a new keyboard with the same buttons but reflowed into a given + * number of columns as if the buttons were text elements. Optionally, you + * can specify if the flow should make sure to fill up the last row. + * + * This method is idempotent, so calling it a second time will effectively + * clone this keyboard without reordering the buttons. + * + * Here are some examples. + * + * ``` + * original flowed + * [ a ] ~> [ a ] (4 columns) + * + * [ a ] + * [a b c] ~> [ b ] (1 column) + * [ c ] + * + * [ a b ] [a b c] + * [ c d ] ~> [ d e ] (3 columns) + * [ e ] + * + * [ a b ] [abcde] + * [ c ] ~> [ f ] (5 columns) + * [d e f] + * + * [a b c] [ a ] + * [d e f] ~> [b c d] (3 columns, { fillLastRow: true }) + * [g h i] [e f g] + * [ j ] [h i j] + * ``` + * + * @param columns Maximum number of buttons per row + * @param options Optional flowing behavior + */ + toFlowed(columns, options = {}) { + const original = this.keyboard; + const flowed = reflow(original, columns, options); + return this.clone(flowed); + } + /** + * Creates and returns a deep copy of this keyboard. + * + * Optionally takes a new grid of buttons to replace the current buttons. If + * specified, only the options will be cloned, and the given buttons will be + * used instead. + */ + clone(keyboard = this.keyboard) { + const clone = new Keyboard(keyboard.map((row) => row.slice())); + clone.is_persistent = this.is_persistent; + clone.selective = this.selective; + clone.one_time_keyboard = this.one_time_keyboard; + clone.resize_keyboard = this.resize_keyboard; + clone.input_field_placeholder = this.input_field_placeholder; + return clone; + } + /** + * Appends the buttons of the given keyboards to this keyboard. If other + * options are specified in these keyboards, they will be ignored. + * + * @param sources A number of keyboards to append + */ + append(...sources) { + for (const source of sources) { + const keyboard = Keyboard.from(source); + this.keyboard.push(...keyboard.keyboard.map((row) => row.slice())); + } + return this; + } + /** + * Returns the keyboard that was build. Note that it doesn't return + * `resize_keyboard` or other options that may be set. You don't usually + * need to call this method. It is no longer useful. + */ + build() { + return this.keyboard; + } + /** + * Turns a two-dimensional keyboard button array into a keyboard instance. + * You can use the static button builder methods to create keyboard button + * objects. + * + * @param source A two-dimensional button array + */ + static from(source) { + if (source instanceof Keyboard) + return source.clone(); + function toButton(btn) { + return typeof btn === "string" ? Keyboard.text(btn) : btn; + } + return new Keyboard(source.map((row) => row.map(toButton))); + } +} +exports.Keyboard = Keyboard; +/** + * Use this class to simplify building an inline keyboard (something like this: + * https://core.telegram.org/bots/features#inline-keyboards). + * + * ```ts + * // Build an inline keyboard: + * const keyboard = new InlineKeyboard() + * .text('A').text('B', 'callback-data').row() + * .text('C').text('D').row() + * .url('Telegram', 'telegram.org') + * + * // Send the keyboard: + * await ctx.reply('Here is your inline keyboard!', { + * reply_markup: keyboard + * }) + * ``` + * + * If you already have some source data which you would like to turn into an + * inline button object, you can use the static equivalents which every inline + * button has. You can use them to create a two-dimensional inline button array. + * The resulting array can be turned into a keyboard instance. + * + * ```ts + * const button = InlineKeyboard.text('GO', 'go') + * const array = [[button]] + * const keyboard = InlineKeyboard.from(array) + * ``` + * + * Be sure to to check the + * [documentation](https://grammy.dev/plugins/keyboard#inline-keyboards) on + * inline keyboards in grammY. + */ +class InlineKeyboard { + /** + * Initialize a new `InlineKeyboard` with an optional two-dimensional array + * of `InlineKeyboardButton` objects. This is the nested array that holds + * the inline keyboard. It will be extended every time you call one of the + * provided methods. + * + * @param inline_keyboard An optional initial two-dimensional button array + */ + constructor(inline_keyboard = [[]]) { + this.inline_keyboard = inline_keyboard; + } + /** + * Allows you to add your own `InlineKeyboardButton` objects if you already + * have them for some reason. You most likely want to call one of the other + * methods. + * + * @param buttons The buttons to add + */ + add(...buttons) { + var _a; + (_a = this.inline_keyboard[this.inline_keyboard.length - 1]) === null || _a === void 0 ? void 0 : _a.push(...buttons); + return this; + } + /** + * Adds a 'line break'. Call this method to make sure that the next added + * buttons will be on a new row. + * + * You may pass a number of `InlineKeyboardButton` objects if you already + * have the instances for some reason. You most likely don't want to pass + * any arguments to `row`. + * + * @param buttons A number of buttons to add to the next row + */ + row(...buttons) { + this.inline_keyboard.push(buttons); + return this; + } + /** + * Adds a new URL button. Telegram clients will open the provided URL when + * the button is pressed. + * + * @param text The text to display, and optional styling information + * @param url HTTP or tg:// url to be opened when the button is pressed. Links tg://user?id= can be used to mention a user by their ID without using a username, if this is allowed by their privacy settings. + */ + url(text, url) { + return this.add(InlineKeyboard.url(text, url)); + } + /** + * Creates a new URL button. Telegram clients will open the provided URL + * when the button is pressed. + * + * @param text The text to display, and optional styling information + * @param url HTTP or tg:// url to be opened when the button is pressed. Links tg://user?id= can be used to mention a user by their ID without using a username, if this is allowed by their privacy settings. + */ + static url(text, url) { + return typeof text === "string" ? { text, url } : { ...text, url }; + } + /** + * Adds a new callback query button. The button contains a text and a custom + * payload. This payload will be sent back to your bot when the button is + * pressed. If you omit the payload, the display text will be sent back to + * your bot. + * + * Your bot will receive an update every time a user presses any of the text + * buttons. You can listen to these updates like this: + * ```ts + * // Specific buttons: + * bot.callbackQuery('button-data', ctx => { ... }) + * // Any button of any inline keyboard: + * bot.on('callback_query:data', ctx => { ... }) + * ``` + * + * @param text The text to display, and optional styling information + * @param data The callback data to send back to your bot (default = text) + */ + text(text, data = typeof text === "string" ? text : text.text) { + return this.add(InlineKeyboard.text(text, data)); + } + /** + * Creates a new callback query button. The button contains a text and a + * custom payload. This payload will be sent back to your bot when the + * button is pressed. If you omit the payload, the display text will be sent + * back to your bot. + * + * Your bot will receive an update every time a user presses any of the text + * buttons. You can listen to these updates like this: + * ```ts + * // Specific buttons: + * bot.callbackQuery('button-data', ctx => { ... }) + * // Any button of any inline keyboard: + * bot.on('callback_query:data', ctx => { ... }) + * ``` + * + * @param text The text to display, and optional styling information + * @param data The callback data to send back to your bot (default = text) + */ + static text(text, data = typeof text === "string" ? text : text.text) { + return typeof text === "string" + ? { text, callback_data: data } + : { ...text, callback_data: data }; + } + /** + * Adds a new web app button, confer https://core.telegram.org/bots/webapps + * + * @param text The text to display, and optional styling information + * @param url An HTTPS URL of a Web App to be opened with additional data + */ + webApp(text, url) { + return this.add(InlineKeyboard.webApp(text, url)); + } + /** + * Creates a new web app button, confer https://core.telegram.org/bots/webapps + * + * @param text The text to display, and optional styling information + * @param url An HTTPS URL of a Web App to be opened with additional data + */ + static webApp(text, url) { + const web_app = typeof url === "string" ? { url } : url; + return typeof text === "string" + ? { text, web_app } + : { ...text, web_app }; + } + /** + * Adds a new login button. This can be used as a replacement for the + * Telegram Login Widget. You must specify an HTTPS URL used to + * automatically authorize the user. + * + * @param text The text to display, and optional styling information + * @param loginUrl The login URL as string or `LoginUrl` object + */ + login(text, loginUrl) { + return this.add(InlineKeyboard.login(text, loginUrl)); + } + /** + * Creates a new login button. This can be used as a replacement for the + * Telegram Login Widget. You must specify an HTTPS URL used to + * automatically authorize the user. + * + * @param text The text to display, and optional styling information + * @param loginUrl The login URL as string or `LoginUrl` object + */ + static login(text, loginUrl) { + const login_url = typeof loginUrl === "string" + ? { url: loginUrl } + : loginUrl; + return typeof text === "string" + ? { text, login_url } + : { ...text, login_url }; + } + /** + * Adds a new inline query button. Telegram clients will let the user pick a + * chat when this button is pressed. This will start an inline query. The + * selected chat will be prefilled with the name of your bot. You may + * provide a text that is specified along with it. + * + * Your bot will in turn receive updates for inline queries. You can listen + * to inline query updates like this: + * ```ts + * bot.on('inline_query', ctx => { ... }) + * ``` + * + * @param text The text to display, and optional styling information + * @param query The (optional) inline query string to prefill + */ + switchInline(text, query = "") { + return this.add(InlineKeyboard.switchInline(text, query)); + } + /** + * Creates a new inline query button. Telegram clients will let the user pick a + * chat when this button is pressed. This will start an inline query. The + * selected chat will be prefilled with the name of your bot. You may + * provide a text that is specified along with it. + * + * Your bot will in turn receive updates for inline queries. You can listen + * to inline query updates like this: + * ```ts + * bot.on('inline_query', ctx => { ... }) + * ``` + * + * @param text The text to display, and optional styling information + * @param query The (optional) inline query string to prefill + */ + static switchInline(text, query = "") { + return typeof text === "string" + ? { text, switch_inline_query: query } + : { ...text, switch_inline_query: query }; + } + /** + * Adds a new inline query button that acts on the current chat. The + * selected chat will be prefilled with the name of your bot. You may + * provide a text that is specified along with it. This will start an inline + * query. + * + * Your bot will in turn receive updates for inline queries. You can listen + * to inline query updates like this: + * ```ts + * bot.on('inline_query', ctx => { ... }) + * ``` + * + * @param text The text to display, and optional styling information + * @param query The (optional) inline query string to prefill + */ + switchInlineCurrent(text, query = "") { + return this.add(InlineKeyboard.switchInlineCurrent(text, query)); + } + /** + * Creates a new inline query button that acts on the current chat. The + * selected chat will be prefilled with the name of your bot. You may + * provide a text that is specified along with it. This will start an inline + * query. + * + * Your bot will in turn receive updates for inline queries. You can listen + * to inline query updates like this: + * ```ts + * bot.on('inline_query', ctx => { ... }) + * ``` + * + * @param text The text to display, and optional styling information + * @param query The (optional) inline query string to prefill + */ + static switchInlineCurrent(text, query = "") { + return typeof text === "string" + ? { text, switch_inline_query_current_chat: query } + : { ...text, switch_inline_query_current_chat: query }; + } + /** + * Adds a new inline query button. Telegram clients will let the user pick a + * chat when this button is pressed. This will start an inline query. The + * selected chat will be prefilled with the name of your bot. You may + * provide a text that is specified along with it. + * + * Your bot will in turn receive updates for inline queries. You can listen + * to inline query updates like this: + * ```ts + * bot.on('inline_query', ctx => { ... }) + * ``` + * + * @param text The text to display, and optional styling information + * @param query The query object describing which chats can be picked + */ + switchInlineChosen(text, query = {}) { + return this.add(InlineKeyboard.switchInlineChosen(text, query)); + } + /** + * Creates a new inline query button. Telegram clients will let the user pick a + * chat when this button is pressed. This will start an inline query. The + * selected chat will be prefilled with the name of your bot. You may + * provide a text that is specified along with it. + * + * Your bot will in turn receive updates for inline queries. You can listen + * to inline query updates like this: + * ```ts + * bot.on('inline_query', ctx => { ... }) + * ``` + * + * @param text The text to display, and optional styling information + * @param query The query object describing which chats can be picked + */ + static switchInlineChosen(text, query = {}) { + return typeof text === "string" + ? { text, switch_inline_query_chosen_chat: query } + : { ...text, switch_inline_query_chosen_chat: query }; + } + /** + * Adds a new copy text button. When clicked, the specified text will be + * copied to the clipboard. + * + * @param text The text to display, and optional styling information + * @param copyText The text to be copied to the clipboard + */ + copyText(text, copyText) { + return this.add(InlineKeyboard.copyText(text, copyText)); + } + /** + * Creates a new copy text button. When clicked, the specified text will be + * copied to the clipboard. + * + * @param text The text to display, and optional styling information + * @param copyText The text to be copied to the clipboard + */ + static copyText(text, copyText) { + const copy_text = typeof copyText === "string" + ? { text: copyText } + : copyText; + return typeof text === "string" + ? { text, copy_text } + : { ...text, copy_text }; + } + /** + * Adds a new game query button, confer + * https://core.telegram.org/bots/api#games + * + * This type of button must always be the first button in the first row. + * + * @param text The text to display, and optional styling information + */ + game(text) { + return this.add(InlineKeyboard.game(text)); + } + /** + * Creates a new game query button, confer + * https://core.telegram.org/bots/api#games + * + * This type of button must always be the first button in the first row. + * + * @param text The text to display, and optional styling information + */ + static game(text) { + const callback_game = {}; + return typeof text === "string" + ? { text, callback_game } + : { ...text, callback_game }; + } + /** + * Adds a new payment button, confer + * https://core.telegram.org/bots/api#payments + * + * This type of button must always be the first button in the first row and + * can only be used in invoice messages. + * + * @param text The text to display, and optional styling information. Substrings “⭐” and “XTR” in the buttons's text will be replaced with a Telegram Star icon. + */ + pay(text) { + return this.add(InlineKeyboard.pay(text)); + } + /** + * Create a new payment button, confer + * https://core.telegram.org/bots/api#payments + * + * This type of button must always be the first button in the first row and + * can only be used in invoice messages. + * + * @param text The text to display, and optional styling information. Substrings “⭐” and “XTR” in the buttons's text will be replaced with a Telegram Star icon. + */ + static pay(text) { + const pay = true; + return typeof text === "string" ? { text, pay } : { ...text, pay }; + } + /** + * Adds a style to the last added button of the inline keyboard. + * + * ```ts + * const keyboard = new InlineKeyboard() + * .text('blue button') + * .style('primary') + * ``` + * + * @param style Style of the button + */ + style(style) { + const rows = this.inline_keyboard.length; + if (rows === 0) { + throw new Error("Need to add a button before applying a style!"); + } + const lastRow = this.inline_keyboard[rows - 1]; + const cols = lastRow.length; + if (cols === 0) { + throw new Error("Need to add a button before applying a style!"); + } + lastRow[cols - 1].style = style; + return this; + } + /** + * Adds a danger style to the last added button of the inline keyboard. + * Alias for `.style('danger')`. + * + * ```ts + * const keyboard = new InlineKeyboard() + * .text('red button') + * .danger() + * ``` + */ + danger() { + return this.style("danger"); + } + /** + * Adds a success style to the last added button of the inline keyboard. + * Alias for `.style('success')`. + * + * ```ts + * const keyboard = new InlineKeyboard() + * .text('green button') + * .success() + * ``` + */ + success() { + return this.style("success"); + } + /** + * Adds a primary style to the last added button of the inline keyboard. + * Alias for `.style('primary')`. + * + * ```ts + * const keyboard = new InlineKeyboard() + * .text('blue button') + * .primary() + * ``` + */ + primary() { + return this.style("primary"); + } + /** + * Adds a custom emoji icon to the last added button of the inline keyboard. + * + * ```ts + * const keyboard = new InlineKeyboard() + * .text('button with icon') + * .icon(myCustomEmojiIconIdentifier) + * ``` + * + * @param icon Unique identifier of the custom emoji shown before the text of the button + */ + icon(icon) { + const rows = this.inline_keyboard.length; + if (rows === 0) { + throw new Error("Need to add a button before adding an icon!"); + } + const lastRow = this.inline_keyboard[rows - 1]; + const cols = lastRow.length; + if (cols === 0) { + throw new Error("Need to add a button before adding an icon!"); + } + lastRow[cols - 1].icon_custom_emoji_id = icon; + return this; + } + /** + * Creates a new inline keyboard that contains the transposed grid of + * buttons of this inline keyboard. This means that the resulting inline + * keyboard has the rows and columns flipped. + * + * Note that inline buttons can only span multiple columns, but never + * multiple rows. This means that if the given arrays have different + * lengths, some buttons might flow up in the layout. In these cases, + * transposing an inline keyboard a second time will not undo the first + * transposition. + * + * Here are some examples. + * + * ``` + * original transposed + * [ a ] ~> [ a ] + * + * [ a ] + * [a b c] ~> [ b ] + * [ c ] + * + * [ a b ] [a c e] + * [ c d ] ~> [ b d ] + * [ e ] + * + * [ a b ] [a c d] + * [ c ] ~> [ b e ] + * [d e f] [ f ] + * ``` + */ + toTransposed() { + const original = this.inline_keyboard; + const transposed = transpose(original); + return new InlineKeyboard(transposed); + } + /** + * Creates a new inline keyboard with the same buttons but reflowed into a + * given number of columns as if the buttons were text elements. Optionally, + * you can specify if the flow should make sure to fill up the last row. + * + * This method is idempotent, so calling it a second time will effectively + * clone this inline keyboard without reordering the buttons. + * + * Here are some examples. + * + * ``` + * original flowed + * [ a ] ~> [ a ] (4 columns) + * + * [ a ] + * [a b c] ~> [ b ] (1 column) + * [ c ] + * + * [ a b ] [a b c] + * [ c d ] ~> [ d e ] (3 columns) + * [ e ] + * + * [ a b ] [abcde] + * [ c ] ~> [ f ] (5 columns) + * [d e f] + * + * [a b c] [ a ] + * [d e f] ~> [b c d] (3 columns, { fillLastRow: true }) + * [g h i] [e f g] + * [ j ] [h i j] + * ``` + * + * @param columns Maximum number of buttons per row + * @param options Optional flowing behavior + */ + toFlowed(columns, options = {}) { + const original = this.inline_keyboard; + const flowed = reflow(original, columns, options); + return new InlineKeyboard(flowed); + } + /** + * Creates and returns a deep copy of this inline keyboard. + */ + clone() { + return new InlineKeyboard(this.inline_keyboard.map((row) => row.slice())); + } + /** + * Appends the buttons of the given inline keyboards to this keyboard. + * + * @param sources A number of inline keyboards to append + */ + append(...sources) { + for (const source of sources) { + const keyboard = InlineKeyboard.from(source); + this.inline_keyboard.push(...keyboard.inline_keyboard.map((row) => row.slice())); + } + return this; + } + /** + * Turns a two-dimensional inline button array into an inline keyboard + * instance. You can use the static button builder methods to create inline + * button objects. + * + * @param source A two-dimensional inline button array + */ + static from(source) { + if (source instanceof InlineKeyboard) + return source.clone(); + return new InlineKeyboard(source.map((row) => row.slice())); + } +} +exports.InlineKeyboard = InlineKeyboard; +function transpose(grid) { + var _a; + const transposed = []; + for (let i = 0; i < grid.length; i++) { + const row = grid[i]; + for (let j = 0; j < row.length; j++) { + const button = row[j]; + ((_a = transposed[j]) !== null && _a !== void 0 ? _a : (transposed[j] = [])).push(button); + } + } + return transposed; +} +function reflow(grid, columns, { fillLastRow = false }) { + var _a; + let first = columns; + if (fillLastRow) { + const buttonCount = grid + .map((row) => row.length) + .reduce((a, b) => a + b, 0); + first = buttonCount % columns; + } + const reflowed = []; + for (const row of grid) { + for (const button of row) { + const at = Math.max(0, reflowed.length - 1); + const max = at === 0 ? first : columns; + let next = ((_a = reflowed[at]) !== null && _a !== void 0 ? _a : (reflowed[at] = [])); + if (next.length === max) { + next = []; + reflowed.push(next); + } + next.push(button); + } + } + return reflowed; +} diff --git a/sandbox/tgbot/node_modules/grammy/out/convenience/session.d.ts b/sandbox/tgbot/node_modules/grammy/out/convenience/session.d.ts new file mode 100644 index 0000000..f777a0f --- /dev/null +++ b/sandbox/tgbot/node_modules/grammy/out/convenience/session.d.ts @@ -0,0 +1,345 @@ +import { type MiddlewareFn } from "../composer.js"; +import { type Context } from "../context.js"; +type MaybePromise = Promise | T; +/** + * A session flavor is a context flavor that holds session data under + * `ctx.session`. + * + * Session middleware will load the session data of a specific chat from your + * storage solution, and make it available to you on the context object. Check + * out the [documentation](https://grammy.dev/ref/core/session) on session + * middleware to know more, and read the section about sessions on the + * [website](https://grammy.dev/plugins/session). + */ +export interface SessionFlavor { + /** + * Session data on the context object. + * + * **WARNING:** You have to make sure that your session data is not + * undefined by _providing an initial value to the session middleware_, or + * by making sure that `ctx.session` is assigned if it is empty! The type + * system does not include `| undefined` because this is really annoying to + * work with. + * + * Accessing `ctx.session` by reading or writing will throw if + * `getSessionKey(ctx) === undefined` for the respective context object + * `ctx`. + */ + get session(): S; + set session(session: S | null | undefined); +} +/** + * A lazy session flavor is a context flavor that holds a promise of some + * session data under `ctx.session`. + * + * Lazy session middleware will provide this promise lazily on the context + * object. Once you access `ctx.session`, the storage will be queried and the + * session data becomes available. If you access `ctx.session` again for the + * same context object, the cached value will be used. Check out the + * [documentation](https://grammy.dev/ref/core/lazysession) on lazy session + * middleware to know more, and read the section about lazy sessions on the + * [website](https://grammy.dev/plugins/session#lazy-sessions). + */ +export interface LazySessionFlavor { + /** + * Session data on the context object, potentially a promise. + * + * **WARNING:** You have to make sure that your session data is not + * undefined by _providing a default value to the session middleware_, or by + * making sure that `ctx.session` is assigned if it is empty! The type + * system does not include `| undefined` because this is really annoying to + * work with. + * + * Accessing `ctx.session` by reading or writing will throw iff + * `getSessionKey(ctx) === undefined` holds for the respective context + * object `ctx`. + */ + get session(): MaybePromise; + set session(session: MaybePromise); +} +/** + * A storage adapter is an abstraction that provides read, write, and delete + * access to a storage solution of any kind. Storage adapters are used to keep + * session middleware independent of your database provider, and they allow you + * to pass your own storage solution. + */ +export interface StorageAdapter { + /** + * Reads a value for the given key from the storage. May return the value or + * undefined, or a promise of either. + */ + read: (key: string) => MaybePromise; + /** + * Writes a value for the given key to the storage. + */ + write: (key: string, value: T) => MaybePromise; + /** + * Deletes a value for the given key from the storage. + */ + delete: (key: string) => MaybePromise; + /** + * Checks whether a key exists in the storage. + */ + has?: (key: string) => MaybePromise; + /** + * Lists all keys. + */ + readAllKeys?: () => Iterable | AsyncIterable; + /** + * Lists all values. + */ + readAllValues?: () => Iterable | AsyncIterable; + /** + * Lists all keys with their values. + */ + readAllEntries?: () => Iterable<[key: string, value: T]> | AsyncIterable<[key: string, value: T]>; +} +/** + * Options for session middleware. + */ +export interface SessionOptions { + type?: "single"; + /** + * **Recommended to use.** + * + * A function that produces an initial value for `ctx.session`. This + * function will be called every time the storage solution returns undefined + * for a given session key. Make sure to create a new value every time, such + * that different context objects do that accidentally share the same + * session data. + */ + initial?: () => S; + /** + * An optional prefix to prepend to the session key after it was generated. + * + * This makes it easier to store session data under a namespace. You can + * technically achieve the same functionality by returning an already + * prefixed key from `getSessionKey`. This option is merely more convenient, + * as it does not require you to think about session key generation. + */ + prefix?: string; + /** + * This option lets you generate your own session keys per context object. + * The session key determines how to map the different session objects to + * your chats and users. Check out the + * [documentation](https://grammy.dev/plugins/session#how-to-use-sessions) + * on the website about how to use session middleware to know how session + * keys are used. + * + * The default implementation will store sessions per chat, as determined by + * `ctx.chatId`. + */ + getSessionKey?: (ctx: Omit) => MaybePromise; + /** + * A storage adapter to your storage solution. Provides read, write, and + * delete access to the session middleware. + * + * Consider using a [known storage + * adapter](https://grammy.dev/plugins/session#known-storage-adapters) + * instead of rolling your own implementation of this. + * + * The default implementation will store session in memory. The data will be + * lost whenever your bot restarts. + */ + storage?: StorageAdapter; +} +/** + * Options for session middleware if multi sessions are used. Specify `"type": + * "multi"` in the options to use multi sessions. + */ +export type MultiSessionOptions = S extends Record ? { + type: "multi"; +} & MultiSessionOptionsRecord : never; +type MultiSessionOptionsRecord, C extends Context> = { + [K in keyof S]: SessionOptions; +}; +/** + * Session middleware provides a persistent data storage for your bot. You can + * use it to let your bot remember any data you want, for example the messages + * it sent or received in the past. This is done by attaching _session data_ to + * every chat. The stored data is then provided on the context object under + * `ctx.session`. + * + * > **What is a session?** Simply put, the session of a chat is a little + * > persistent storage that is attached to it. As an example, your bot can send + * > a message to a chat and store the identifier of that message in the + * > corresponding session. The next time your bot receives an update from that + * > chat, the session will still contain that ID. + * > + * > Session data can be stored in a database, in a file, or simply in memory. + * > grammY only supports memory sessions out of the box, but you can use + * > third-party session middleware to connect to other storage solutions. Note + * > that memory sessions will be lost when you stop your bot and the process + * > exits, so they are usually not useful in production. + * + * Whenever your bot receives an update, the first thing the session middleware + * will do is to load the correct session from your storage solution. This + * object is then provided on `ctx.session` while your other middleware is + * running. As soon as your bot is done handling the update, the middleware + * takes over again and writes back the session object to your storage. This + * allows you to modify the session object arbitrarily in your middleware, and + * to stop worrying about the database. + * + * ```ts + * bot.use(session()) + * + * bot.on('message', ctx => { + * // The session object is persisted across updates! + * const session = ctx.session + * }) + * ``` + * + * It is recommended to make use of the `initial` option in the configuration + * object, which correctly initializes session objects for new chats. + * + * You can delete the session data by setting `ctx.session` to `null` or + * `undefined`. + * + * Check out the [documentation](https://grammy.dev/plugins/session) on the + * website to know more about how sessions work in grammY. + * + * @param options Optional configuration to pass to the session middleware + */ +export declare function session(options?: SessionOptions | MultiSessionOptions): MiddlewareFn>; +/** + * > This is an advanced function of grammY. + * + * Generally speaking, lazy sessions work just like normal sessions—just they + * are loaded on demand. Except for a few `async`s and `await`s here and there, + * their usage looks 100 % identical. + * + * Instead of directly querying the storage every time an update arrives, lazy + * sessions quickly do this _once you access_ `ctx.session`. This can + * significantly reduce the database traffic (especially when your bot is added + * to group chats), because it skips a read and a wrote operation for all + * updates that the bot does not react to. + * + * ```ts + * // The options are identical + * bot.use(lazySession({ storage: ... })) + * + * bot.on('message', async ctx => { + * // The session object is persisted across updates! + * const session = await ctx.session + * // ^ + * // | + * // This plain property access (no function call) will trigger the database query! + * }) + * ``` + * + * Check out the + * [documentation](https://grammy.dev/plugins/session#lazy-sessions) on the + * website to know more about how lazy sessions work in grammY. + * + * @param options Optional configuration to pass to the session middleware + */ +export declare function lazySession(options?: SessionOptions): MiddlewareFn>; +/** + * When enhancing a storage adapter, it needs to be able to store additional + * information. It does this by wrapping the actual data inside an object, and + * adding more properties to this wrapper. + * + * This interface defines the additional properties that need to be stored by a + * storage adapter that supports enhanced sessions. + */ +export interface Enhance { + /** Version */ + v?: number; + /** Data */ + __d: T; + /** Expiry date */ + e?: number; +} +/** Options for enhanced sessions */ +export interface MigrationOptions { + /** The original storage adapter that will be enhanced */ + storage: StorageAdapter>; + /** + * A set of session migrations, defined as an object mapping from version + * numbers to migration functions that transform data to the respective + * version. + */ + migrations?: Migrations; + /** + * Number of milliseconds after the last write operation until the session + * data expires. + */ + millisecondsToLive?: number; +} +/** + * A mapping from version numbers to session migration functions. Each entry in + * this object has a version number as a key, and a function as a value. + * + * For a key `n`, the respective value should be a function that takes the + * previous session data and migrates it to conform with the data that is used + * by version `n`. The previous session data is defined by the next key less + * than `n`, such as `n-1`. Versions don't have to be integers, nor do all + * versions have to be adjacent. For example, you can use `[1, 1.5, 4]` as + * versions. If `n` is the lowest value in the set of keys, the function stored + * for `n` can be used to migrate session data that was stored before migrations + * were used. + */ +export interface Migrations { + [version: number]: (old: any) => any; +} +/** + * You can use this function to transform an existing storage adapter, and add + * more features to it. Currently, you can add session migrations and expiry + * dates. + * + * You can use this function like so: + * ```ts + * const storage = ... // define your storage adapter + * const enhanced = enhanceStorage({ storage, millisecondsToLive: 500 }) + * bot.use(session({ storage: enhanced })) + * ``` + * + * @param options Session enhancing options + * @returns The enhanced storage adapter + */ +export declare function enhanceStorage(options: MigrationOptions): StorageAdapter; +/** + * The memory session storage is a built-in storage adapter that saves your + * session data in RAM using a regular JavaScript `Map` object. If you use this + * storage adapter, all sessions will be lost when your process terminates or + * restarts. Hence, you should only use it for short-lived data that is not + * important to persist. + * + * This class is used as default if you do not provide a storage adapter, e.g. + * to your database. + * + * This storage adapter features expiring sessions. When instantiating this + * class yourself, you can pass a time to live in milliseconds that will be used + * for each session object. If a session for a user expired, the session data + * will be discarded on its first read, and a fresh session object as returned + * by the `initial` option (or undefined) will be put into place. + */ +export declare class MemorySessionStorage implements StorageAdapter { + private readonly timeToLive?; + /** + * Internally used `Map` instance that stores the session data + */ + protected readonly storage: Map; + /** + * Constructs a new memory session storage with the given time to live. Note + * that this storage adapter will not store your data permanently. + * + * @param timeToLive TTL in milliseconds, default is `Infinity` + */ + constructor(timeToLive?: number | undefined); + read(key: string): S | undefined; + /** + * @deprecated Use {@link readAllValues} instead + */ + readAll(): S[]; + readAllKeys(): string[]; + readAllValues(): S[]; + readAllEntries(): [string, S][]; + has(key: string): boolean; + write(key: string, value: S): void; + delete(key: string): void; +} +export {}; diff --git a/sandbox/tgbot/node_modules/grammy/out/convenience/session.js b/sandbox/tgbot/node_modules/grammy/out/convenience/session.js new file mode 100644 index 0000000..49b81e8 --- /dev/null +++ b/sandbox/tgbot/node_modules/grammy/out/convenience/session.js @@ -0,0 +1,455 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.MemorySessionStorage = void 0; +exports.session = session; +exports.lazySession = lazySession; +exports.enhanceStorage = enhanceStorage; +const platform_node_js_1 = require("../platform.node.js"); +const debug = (0, platform_node_js_1.debug)("grammy:session"); +/** + * Session middleware provides a persistent data storage for your bot. You can + * use it to let your bot remember any data you want, for example the messages + * it sent or received in the past. This is done by attaching _session data_ to + * every chat. The stored data is then provided on the context object under + * `ctx.session`. + * + * > **What is a session?** Simply put, the session of a chat is a little + * > persistent storage that is attached to it. As an example, your bot can send + * > a message to a chat and store the identifier of that message in the + * > corresponding session. The next time your bot receives an update from that + * > chat, the session will still contain that ID. + * > + * > Session data can be stored in a database, in a file, or simply in memory. + * > grammY only supports memory sessions out of the box, but you can use + * > third-party session middleware to connect to other storage solutions. Note + * > that memory sessions will be lost when you stop your bot and the process + * > exits, so they are usually not useful in production. + * + * Whenever your bot receives an update, the first thing the session middleware + * will do is to load the correct session from your storage solution. This + * object is then provided on `ctx.session` while your other middleware is + * running. As soon as your bot is done handling the update, the middleware + * takes over again and writes back the session object to your storage. This + * allows you to modify the session object arbitrarily in your middleware, and + * to stop worrying about the database. + * + * ```ts + * bot.use(session()) + * + * bot.on('message', ctx => { + * // The session object is persisted across updates! + * const session = ctx.session + * }) + * ``` + * + * It is recommended to make use of the `initial` option in the configuration + * object, which correctly initializes session objects for new chats. + * + * You can delete the session data by setting `ctx.session` to `null` or + * `undefined`. + * + * Check out the [documentation](https://grammy.dev/plugins/session) on the + * website to know more about how sessions work in grammY. + * + * @param options Optional configuration to pass to the session middleware + */ +function session(options = {}) { + return options.type === "multi" + ? strictMultiSession(options) + : strictSingleSession(options); +} +function strictSingleSession(options) { + const { initial, storage, getSessionKey, custom } = fillDefaults(options); + return async (ctx, next) => { + const propSession = new PropertySession(storage, ctx, "session", initial); + const key = await getSessionKey(ctx); + await propSession.init(key, { custom, lazy: false }); + await next(); // no catch: do not write back if middleware throws + await propSession.finish(); + }; +} +function strictMultiSession(options) { + const props = Object.keys(options).filter((k) => k !== "type"); + const defaults = Object.fromEntries(props.map((prop) => [prop, fillDefaults(options[prop])])); + return async (ctx, next) => { + ctx.session = {}; + const propSessions = await Promise.all(props.map(async (prop) => { + const { initial, storage, getSessionKey, custom } = defaults[prop]; + const s = new PropertySession( + // @ts-expect-error cannot express that the storage works for a concrete prop + storage, ctx.session, prop, initial); + const key = await getSessionKey(ctx); + await s.init(key, { custom, lazy: false }); + return s; + })); + await next(); // no catch: do not write back if middleware throws + if (ctx.session == null) + propSessions.forEach((s) => s.delete()); + await Promise.all(propSessions.map((s) => s.finish())); + }; +} +/** + * > This is an advanced function of grammY. + * + * Generally speaking, lazy sessions work just like normal sessions—just they + * are loaded on demand. Except for a few `async`s and `await`s here and there, + * their usage looks 100 % identical. + * + * Instead of directly querying the storage every time an update arrives, lazy + * sessions quickly do this _once you access_ `ctx.session`. This can + * significantly reduce the database traffic (especially when your bot is added + * to group chats), because it skips a read and a wrote operation for all + * updates that the bot does not react to. + * + * ```ts + * // The options are identical + * bot.use(lazySession({ storage: ... })) + * + * bot.on('message', async ctx => { + * // The session object is persisted across updates! + * const session = await ctx.session + * // ^ + * // | + * // This plain property access (no function call) will trigger the database query! + * }) + * ``` + * + * Check out the + * [documentation](https://grammy.dev/plugins/session#lazy-sessions) on the + * website to know more about how lazy sessions work in grammY. + * + * @param options Optional configuration to pass to the session middleware + */ +function lazySession(options = {}) { + if (options.type !== undefined && options.type !== "single") { + throw new Error("Cannot use lazy multi sessions!"); + } + const { initial, storage, getSessionKey, custom } = fillDefaults(options); + return async (ctx, next) => { + const propSession = new PropertySession( + // @ts-expect-error suppress promise nature of values + storage, ctx, "session", initial); + const key = await getSessionKey(ctx); + await propSession.init(key, { custom, lazy: true }); + await next(); // no catch: do not write back if middleware throws + await propSession.finish(); + }; +} +/** + * Internal class that manages a single property on the session. Can be used + * both in a strict and a lazy way. Works by using `Object.defineProperty` to + * install `O[P]`. + */ +// deno-lint-ignore ban-types +class PropertySession { + constructor(storage, obj, prop, initial) { + this.storage = storage; + this.obj = obj; + this.prop = prop; + this.initial = initial; + this.fetching = false; + this.read = false; + this.wrote = false; + } + /** Performs a read op and stores the result in `this.value` */ + load() { + if (this.key === undefined) { + // No session key provided, cannot load + return; + } + if (this.wrote) { + // Value was set, no need to load + return; + } + // Perform read op if not cached + if (this.promise === undefined) { + this.fetching = true; + this.promise = Promise.resolve(this.storage.read(this.key)) + .then((val) => { + var _a; + this.fetching = false; + // Check for write op in the meantime + if (this.wrote) { + // Discard read op + return this.value; + } + // Store received value in `this.value` + if (val !== undefined) { + this.value = val; + return val; + } + // No value, need to initialize + val = (_a = this.initial) === null || _a === void 0 ? void 0 : _a.call(this); + if (val !== undefined) { + // Wrote initial value + this.wrote = true; + this.value = val; + } + return val; + }); + } + return this.promise; + } + async init(key, opts) { + this.key = key; + if (!opts.lazy) + await this.load(); + Object.defineProperty(this.obj, this.prop, { + enumerable: true, + get: () => { + if (key === undefined) { + const msg = undef("access", opts); + throw new Error(msg); + } + this.read = true; + if (!opts.lazy || this.wrote) + return this.value; + this.load(); + return this.fetching ? this.promise : this.value; + }, + set: (v) => { + if (key === undefined) { + const msg = undef("assign", opts); + throw new Error(msg); + } + this.wrote = true; + this.fetching = false; + this.value = v; + }, + }); + } + delete() { + Object.assign(this.obj, { [this.prop]: undefined }); + } + async finish() { + if (this.key !== undefined) { + if (this.read) + await this.load(); + if (this.read || this.wrote) { + const value = await this.value; + if (value == null) + await this.storage.delete(this.key); + else + await this.storage.write(this.key, value); + } + } + } +} +function fillDefaults(opts = {}) { + let { prefix = "", getSessionKey = defaultGetSessionKey, initial, storage, } = opts; + if (storage == null) { + debug("Storing session data in memory, all data will be lost when the bot restarts."); + storage = new MemorySessionStorage(); + } + const custom = getSessionKey !== defaultGetSessionKey; + return { + initial, + storage, + getSessionKey: async (ctx) => { + const key = await getSessionKey(ctx); + return key === undefined ? undefined : prefix + key; + }, + custom, + }; +} +/** Stores session data per chat by default */ +function defaultGetSessionKey(ctx) { + var _a; + return (_a = ctx.chatId) === null || _a === void 0 ? void 0 : _a.toString(); +} +/** Returns a useful error message for when the session key is undefined */ +function undef(op, opts) { + const { lazy = false, custom } = opts; + const reason = custom + ? "the custom `getSessionKey` function returned undefined for this update" + : "this update does not belong to a chat, so the session key is undefined"; + return `Cannot ${op} ${lazy ? "lazy " : ""}session data because ${reason}!`; +} +function isEnhance(value) { + return value === undefined || + typeof value === "object" && value !== null && "__d" in value; +} +/** + * You can use this function to transform an existing storage adapter, and add + * more features to it. Currently, you can add session migrations and expiry + * dates. + * + * You can use this function like so: + * ```ts + * const storage = ... // define your storage adapter + * const enhanced = enhanceStorage({ storage, millisecondsToLive: 500 }) + * bot.use(session({ storage: enhanced })) + * ``` + * + * @param options Session enhancing options + * @returns The enhanced storage adapter + */ +function enhanceStorage(options) { + let { storage, millisecondsToLive, migrations } = options; + storage = compatStorage(storage); + if (millisecondsToLive !== undefined) { + storage = timeoutStorage(storage, millisecondsToLive); + } + if (migrations !== undefined) { + storage = migrationStorage(storage, migrations); + } + return wrapStorage(storage); +} +function compatStorage(storage) { + return { + read: async (k) => { + const v = await storage.read(k); + return isEnhance(v) ? v : { __d: v }; + }, + write: (k, v) => storage.write(k, v), + delete: (k) => storage.delete(k), + }; +} +function timeoutStorage(storage, millisecondsToLive) { + const ttlStorage = { + read: async (k) => { + const value = await storage.read(k); + if (value === undefined) + return undefined; + if (value.e === undefined) { + await ttlStorage.write(k, value); + return value; + } + if (value.e < Date.now()) { + await ttlStorage.delete(k); + return undefined; + } + return value; + }, + write: async (k, v) => { + v.e = addExpiryDate(v, millisecondsToLive).expires; + await storage.write(k, v); + }, + delete: (k) => storage.delete(k), + }; + return ttlStorage; +} +function migrationStorage(storage, migrations) { + const versions = Object.keys(migrations) + .map((v) => parseInt(v)) + .sort((a, b) => a - b); + const count = versions.length; + if (count === 0) + throw new Error("No migrations given!"); + const earliest = versions[0]; + const last = count - 1; + const latest = versions[last]; + const index = new Map(); + versions.forEach((v, i) => index.set(v, i)); // inverse array lookup + function nextAfter(current) { + // TODO: use `findLastIndex` with Node 18 + let i = last; + while (current <= versions[i]) + i--; + return i; + // return versions.findLastIndex((v) => v < current) + } + return { + read: async (k) => { + var _a; + const val = await storage.read(k); + if (val === undefined) + return val; + let { __d: value, v: current = earliest - 1 } = val; + let i = 1 + ((_a = index.get(current)) !== null && _a !== void 0 ? _a : nextAfter(current)); + for (; i < count; i++) + value = migrations[versions[i]](value); + return { ...val, v: latest, __d: value }; + }, + write: (k, v) => storage.write(k, { v: latest, ...v }), + delete: (k) => storage.delete(k), + }; +} +function wrapStorage(storage) { + return { + read: (k) => Promise.resolve(storage.read(k)).then((v) => v === null || v === void 0 ? void 0 : v.__d), + write: (k, v) => storage.write(k, { __d: v }), + delete: (k) => storage.delete(k), + }; +} +// === Memory storage adapter +/** + * The memory session storage is a built-in storage adapter that saves your + * session data in RAM using a regular JavaScript `Map` object. If you use this + * storage adapter, all sessions will be lost when your process terminates or + * restarts. Hence, you should only use it for short-lived data that is not + * important to persist. + * + * This class is used as default if you do not provide a storage adapter, e.g. + * to your database. + * + * This storage adapter features expiring sessions. When instantiating this + * class yourself, you can pass a time to live in milliseconds that will be used + * for each session object. If a session for a user expired, the session data + * will be discarded on its first read, and a fresh session object as returned + * by the `initial` option (or undefined) will be put into place. + */ +class MemorySessionStorage { + /** + * Constructs a new memory session storage with the given time to live. Note + * that this storage adapter will not store your data permanently. + * + * @param timeToLive TTL in milliseconds, default is `Infinity` + */ + constructor(timeToLive) { + this.timeToLive = timeToLive; + /** + * Internally used `Map` instance that stores the session data + */ + this.storage = new Map(); + } + read(key) { + const value = this.storage.get(key); + if (value === undefined) + return undefined; + if (value.expires !== undefined && value.expires < Date.now()) { + this.delete(key); + return undefined; + } + return value.session; + } + /** + * @deprecated Use {@link readAllValues} instead + */ + readAll() { + return this.readAllValues(); + } + readAllKeys() { + return Array.from(this.storage.keys()); + } + readAllValues() { + return Array + .from(this.storage.keys()) + .map((key) => this.read(key)) + .filter((value) => value !== undefined); + } + readAllEntries() { + return Array.from(this.storage.keys()) + .map((key) => [key, this.read(key)]) + .filter((pair) => pair[1] !== undefined); + } + has(key) { + return this.storage.has(key); + } + write(key, value) { + this.storage.set(key, addExpiryDate(value, this.timeToLive)); + } + delete(key) { + this.storage.delete(key); + } +} +exports.MemorySessionStorage = MemorySessionStorage; +function addExpiryDate(value, ttl) { + if (ttl !== undefined && ttl < Infinity) { + const now = Date.now(); + return { session: value, expires: now + ttl }; + } + else { + return { session: value }; + } +} diff --git a/sandbox/tgbot/node_modules/grammy/out/convenience/webhook.d.ts b/sandbox/tgbot/node_modules/grammy/out/convenience/webhook.d.ts new file mode 100644 index 0000000..39a0d4a --- /dev/null +++ b/sandbox/tgbot/node_modules/grammy/out/convenience/webhook.d.ts @@ -0,0 +1,59 @@ +import { type Bot } from "../bot.js"; +import { type Context } from "../context.js"; +import { type FrameworkAdapter } from "./frameworks.js"; +declare const adapters: { + callback: FrameworkAdapter; + "aws-lambda": import("./frameworks.js").LambdaAdapter; + "aws-lambda-async": import("./frameworks.js").LambdaAsyncAdapter; + azure: import("./frameworks.js").AzureAdapter; + "azure-v4": import("./frameworks.js").AzureAdapterV4; + bun: import("./frameworks.js").BunAdapter; + cloudflare: import("./frameworks.js").CloudflareAdapter; + "cloudflare-mod": import("./frameworks.js").CloudflareModuleAdapter; + elysia: import("./frameworks.js").ElysiaAdapter; + express: import("./frameworks.js").ExpressAdapter; + fastify: import("./frameworks.js").FastifyAdapter; + hono: import("./frameworks.js").HonoAdapter; + http: import("./frameworks.js").HttpAdapter; + https: import("./frameworks.js").HttpAdapter; + koa: import("./frameworks.js").KoaAdapter; + "next-js": import("./frameworks.js").NextAdapter; + nhttp: import("./frameworks.js").NHttpAdapter; + oak: import("./frameworks.js").OakAdapter; + serveHttp: import("./frameworks.js").ServeHttpAdapter; + "std/http": import("./frameworks.js").StdHttpAdapter; + sveltekit: import("./frameworks.js").SveltekitAdapter; + worktop: import("./frameworks.js").WorktopAdapter; +}; +export interface WebhookOptions { + /** An optional strategy to handle timeouts (default: 'throw') */ + onTimeout?: "throw" | "return" | ((...args: any[]) => unknown); + /** An optional number of timeout milliseconds (default: 10_000) */ + timeoutMilliseconds?: number; + /** An optional string to compare to X-Telegram-Bot-Api-Secret-Token */ + secretToken?: string; +} +type Adapters = typeof adapters; +type AdapterNames = keyof Adapters; +type ResolveName = A extends AdapterNames ? Adapters[A] : A; +/** + * Creates a callback function that you can pass to a web framework (such as + * express) if you want to run your bot via webhooks. Use it like this: + * ```ts + * const app = express() // or whatever you're using + * const bot = new Bot('') + * + * app.use(webhookCallback(bot, 'express')) + * ``` + * + * Confer the grammY + * [documentation](https://grammy.dev/guide/deployment-types) to read more + * about how to run your bot with webhooks. + * + * @param bot The bot for which to create a callback + * @param adapter An optional string identifying the framework (default: 'express') + * @param webhookOptions Further options for the webhook setup + */ +export declare function webhookCallback(bot: Bot, adapter: A, webhookOptions?: WebhookOptions): (...args: Parameters>) => ReturnType>["handlerReturn"] extends undefined ? Promise : NonNullable>["handlerReturn"]>; +export declare function webhookCallback(bot: Bot, adapter: A, onTimeout?: WebhookOptions["onTimeout"], timeoutMilliseconds?: WebhookOptions["timeoutMilliseconds"], secretToken?: WebhookOptions["secretToken"]): (...args: Parameters>) => ReturnType>["handlerReturn"] extends undefined ? Promise : NonNullable>["handlerReturn"]>; +export {}; diff --git a/sandbox/tgbot/node_modules/grammy/out/convenience/webhook.js b/sandbox/tgbot/node_modules/grammy/out/convenience/webhook.js new file mode 100644 index 0000000..3f9d5e4 --- /dev/null +++ b/sandbox/tgbot/node_modules/grammy/out/convenience/webhook.js @@ -0,0 +1,120 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.webhookCallback = webhookCallback; +const platform_node_js_1 = require("../platform.node.js"); +const frameworks_js_1 = require("./frameworks.js"); +const debugErr = (0, platform_node_js_1.debug)("grammy:error"); +const callbackAdapter = (update, callback, header, unauthorized = () => callback('"unauthorized"')) => ({ + update: Promise.resolve(update), + respond: callback, + header, + unauthorized, +}); +const adapters = { ...frameworks_js_1.adapters, callback: callbackAdapter }; +/** + * Performs a constant-time comparison of two strings to prevent timing attacks. + * This function always compares all bytes regardless of early differences, + * ensuring the comparison time does not leak information about the secret. + * + * @param header The header value from the request (X-Telegram-Bot-Api-Secret-Token) + * @param token The expected secret token configured for the webhook + * @returns true if strings are equal, false otherwise + */ +function compareSecretToken(header, token) { + // If no token is configured, accept all requests + if (token === undefined) { + return true; + } + // If token is configured but no header provided, reject + if (header === undefined) { + return false; + } + // Convert strings to Uint8Array for byte-by-byte comparison + const encoder = new TextEncoder(); + const headerBytes = encoder.encode(header); + const tokenBytes = encoder.encode(token); + // If lengths differ, reject + if (headerBytes.length !== tokenBytes.length) { + return false; + } + let hasDifference = 0; + // Always iterate exactly tokenBytes.length times to prevent timing attacks + // that could reveal the secret token's length. The loop time is constant + // relative to the secret token length, not the attacker's input length. + for (let i = 0; i < tokenBytes.length; i++) { + // If header is shorter than token, pad with 0 for comparison + const headerByte = i < headerBytes.length ? headerBytes[i] : 0; + const tokenByte = tokenBytes[i]; + // If bytes differ, mark that we found a difference + // Using bitwise OR to maintain constant-time (no short-circuit evaluation) + hasDifference |= headerByte ^ tokenByte; + } + // Return true only if no differences were found + return hasDifference === 0; +} +function webhookCallback(bot, adapter = platform_node_js_1.defaultAdapter, onTimeout, timeoutMilliseconds, secretToken) { + if (bot.isRunning()) { + throw new Error("Bot is already running via long polling, the webhook setup won't receive any updates!"); + } + else { + bot.start = () => { + throw new Error("You already started the bot via webhooks, calling `bot.start()` starts the bot with long polling and this will prevent your webhook setup from receiving any updates!"); + }; + } + const { onTimeout: timeout = "throw", timeoutMilliseconds: ms = 10000, secretToken: token, } = typeof onTimeout === "object" + ? onTimeout + : { onTimeout, timeoutMilliseconds, secretToken }; + let initialized = false; + const server = typeof adapter === "string" + ? adapters[adapter] + : adapter; + return async (...args) => { + var _a; + const handler = server(...args); + if (!initialized) { + // Will dedupe concurrently incoming calls from several updates + await bot.init(); + initialized = true; + } + if (!compareSecretToken(handler.header, token)) { + await handler.unauthorized(); + return handler.handlerReturn; + } + let usedWebhookReply = false; + const webhookReplyEnvelope = { + async send(json) { + usedWebhookReply = true; + await handler.respond(json); + }, + }; + await timeoutIfNecessary(bot.handleUpdate(await handler.update, webhookReplyEnvelope), typeof timeout === "function" ? () => timeout(...args) : timeout, ms); + if (!usedWebhookReply) + (_a = handler.end) === null || _a === void 0 ? void 0 : _a.call(handler); + return handler.handlerReturn; + }; +} +function timeoutIfNecessary(task, onTimeout, timeout) { + if (timeout === Infinity) + return task; + return new Promise((resolve, reject) => { + const handle = setTimeout(() => { + debugErr(`Request timed out after ${timeout} ms`); + if (onTimeout === "throw") { + reject(new Error(`Request timed out after ${timeout} ms`)); + } + else { + if (typeof onTimeout === "function") + onTimeout(); + resolve(); + } + const now = Date.now(); + task.finally(() => { + const diff = Date.now() - now; + debugErr(`Request completed ${diff} ms after timeout!`); + }); + }, timeout); + task.then(resolve) + .catch(reject) + .finally(() => clearTimeout(handle)); + }); +} diff --git a/sandbox/tgbot/node_modules/grammy/out/core/api.d.ts b/sandbox/tgbot/node_modules/grammy/out/core/api.d.ts new file mode 100644 index 0000000..5018d6d --- /dev/null +++ b/sandbox/tgbot/node_modules/grammy/out/core/api.d.ts @@ -0,0 +1,1952 @@ +import { type AcceptedGiftTypes, type BotCommand, type ChatPermissions, type InlineQueryResult, type InputChecklist, type InputFile, type InputMedia, type InputMediaAudio, type InputMediaDocument, type InputMediaPhoto, type InputMediaVideo, type InputPaidMedia, type InputPollOption, type InputProfilePhoto, type InputSticker, type InputStoryContent, type LabeledPrice, type MaskPosition, type PassportElementError, type ReactionType } from "../types.js"; +import { type ApiClientOptions, type Methods, type Payload, type RawApi, type Transformer, type TransformerConsumer, type WebhookReplyEnvelope } from "./client.js"; +/** + * Helper type to derive remaining properties of a given API method call M, + * given that some properties X have already been specified. + */ +export type Other, X extends string = never> = Omit, X>; +/** + * This class provides access to the full Telegram Bot API. All methods of the + * API have an equivalent on this class, with the most important parameters + * pulled up into the function signature, and the other parameters captured by + * an object. + * + * In addition, this class has a property `raw` that provides raw access to the + * complete Telegram API, with the method signatures 1:1 represented as + * documented on the website (https://core.telegram.org/bots/api). + * + * Every method takes an optional `AbortSignal` object that allows you to cancel + * the request if desired. + * + * In advanced use cases, this class allows to install transformers that can + * modify the method and payload on the fly before sending it to the Telegram + * servers. Confer the `config` property for this. + */ +export declare class Api { + readonly token: string; + readonly options?: ApiClientOptions | undefined; + /** + * Provides access to all methods of the Telegram Bot API exactly as + * documented on the website (https://core.telegram.org/bots/api). No + * arguments are pulled up in the function signature for convenience. + * + * If you suppress compiler warnings, this also allows for raw api calls to + * undocumented methods with arbitrary parameters—use only if you know what + * you are doing. + */ + readonly raw: R; + /** + * Configuration object for the API instance, used as a namespace to + * separate those API operations that are related to grammY from methods of + * the Telegram Bot API. Contains advanced options! + */ + readonly config: { + /** + * Allows to install an API request transformer function. A transformer + * function has access to every API call before it is being performed. + * This includes the method as string, the payload as object and the + * upstream transformer function. + * + * _Note that using transformer functions is an advanced feature of + * grammY that most bots will not need to make use of._ + */ + readonly use: TransformerConsumer; + /** + * Provides read access to all currently installed transformers (those + * that have previously been passed to `config.use`). + * + * _Note that using transformer functions is an advanced feature of + * grammY that most bots will not need to make use of._ + */ + readonly installedTransformers: () => Transformer[]; + }; + /** + * Constructs a new instance of `Api`. It is independent from all other + * instances of this class. For example, this lets you install a custom set + * of transformers. + * + * @param token Bot API token obtained from [@BotFather](https://t.me/BotFather) + * @param options Optional API client options for the underlying client instance + * @param webhookReplyEnvelope Optional envelope to handle webhook replies + */ + constructor(token: string, options?: ApiClientOptions | undefined, webhookReplyEnvelope?: WebhookReplyEnvelope); + /** + * Use this method to receive incoming updates using long polling (wiki). Returns an Array of Update objects. + * + * Notes + * 1. This method will not work if an outgoing webhook is set up. + * 2. In order to avoid getting duplicate updates, recalculate offset after each server response. + * + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getupdates + */ + getUpdates(other?: Other, signal?: AbortSignal): Promise; + /** + * Use this method to specify a URL and receive incoming updates via an outgoing webhook. Whenever there is an update for the bot, we will send an HTTPS POST request to the specified URL, containing a JSON-serialized Update. In case of an unsuccessful request, we will give up after a reasonable amount of attempts. Returns True on success. + * + * If you'd like to make sure that the webhook was set by you, you can specify secret data in the parameter secret_token. If specified, the request will contain a header “X-Telegram-Bot-Api-Secret-Token” with the secret token as content. + * + * Notes + * 1. You will not be able to receive updates using getUpdates for as long as an outgoing webhook is set up. + * 2. To use a self-signed certificate, you need to upload your public key certificate using certificate parameter. Please upload as InputFile, sending a String will not work. + * 3. Ports currently supported for Webhooks: 443, 80, 88, 8443. + * + * If you're having any trouble setting up webhooks, please check out this amazing guide to webhooks. + * + * @param url HTTPS url to send updates to. Use an empty string to remove webhook integration + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setwebhook + */ + setWebhook(url: string, other?: Other, signal?: AbortSignal): Promise; + /** + * Use this method to remove webhook integration if you decide to switch back to getUpdates. Returns True on success. + * + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#deletewebhook + */ + deleteWebhook(other?: Other, signal?: AbortSignal): Promise; + /** + * Use this method to get current webhook status. Requires no parameters. On success, returns a WebhookInfo object. If the bot is using getUpdates, will return an object with the url field empty. + * + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getwebhookinfo + */ + getWebhookInfo(signal?: AbortSignal): Promise; + /** + * A simple method for testing your bot's authentication token. Requires no parameters. Returns basic information about the bot in form of a User object. + * + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getme + */ + getMe(signal?: AbortSignal): Promise; + /** + * Use this method to log out from the cloud Bot API server before launching the bot locally. You must log out the bot before running it locally, otherwise there is no guarantee that the bot will receive updates. After a successful call, you can immediately log in on a local server, but will not be able to log in back to the cloud Bot API server for 10 minutes. Returns True on success. Requires no parameters. + * + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#logout + */ + logOut(signal?: AbortSignal): Promise; + /** + * Use this method to close the bot instance before moving it from one local server to another. You need to delete the webhook before calling this method to ensure that the bot isn't launched again after server restart. The method will return error 429 in the first 10 minutes after the bot is launched. Returns True on success. Requires no parameters. + * + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#close + */ + close(signal?: AbortSignal): Promise; + /** + * Use this method to send text messages. On success, the sent Message is returned. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param text Text of the message to be sent, 1-4096 characters after entities parsing + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendmessage + */ + sendMessage(chat_id: number | string, text: string, other?: Other, signal?: AbortSignal): Promise; + /** + * Use this method to stream a partial message to a user while the message is being generated; supported only for bots with forum topic mode enabled. Returns True on success. + * + * @param chat_id Unique identifier for the target private chat + * @param draft_id Unique identifier of the message draft; must be non-zero. Changes of drafts with the same identifier are animated + * @param text Text of the message to be sent, 1-4096 characters after entities parsing + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendmessagedraft + */ + sendMessageDraft(chat_id: number, draft_id: number, text: string, other?: Other, signal?: AbortSignal): Promise; + /** + * Use this method to forward messages of any kind. Service messages and messages with protected content can't be forwarded. On success, the sent Message is returned. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param from_chat_id Unique identifier for the chat where the original message was sent (or channel username in the format @channelusername) + * @param message_id Message identifier in the chat specified in from_chat_id + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#forwardmessage + */ + forwardMessage(chat_id: number | string, from_chat_id: number | string, message_id: number, other?: Other, signal?: AbortSignal): Promise; + /** + * Use this method to forward multiple messages of any kind. If some of the specified messages can't be found or forwarded, they are skipped. Service messages and messages with protected content can't be forwarded. Album grouping is kept for forwarded messages. On success, an array of MessageId of the sent messages is returned. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param from_chat_id Unique identifier for the chat where the original messages were sent (or channel username in the format @channelusername) + * @param message_ids A list of 1-100 identifiers of messages in the chat from_chat_id to forward. The identifiers must be specified in a strictly increasing order. + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#forwardmessages + */ + forwardMessages(chat_id: number | string, from_chat_id: number | string, message_ids: number[], other?: Other, signal?: AbortSignal): Promise; + /** + * Use this method to copy messages of any kind. Service messages, paid media messages, giveaway messages, giveaway winners messages, and invoice messages can't be copied. A quiz poll can be copied only if the value of the field correct_option_id is known to the bot. The method is analogous to the method forwardMessage, but the copied message doesn't have a link to the original message. Returns the MessageId of the sent message on success. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param from_chat_id Unique identifier for the chat where the original message was sent (or channel username in the format @channelusername) + * @param message_id Message identifier in the chat specified in from_chat_id + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#copymessage + */ + copyMessage(chat_id: number | string, from_chat_id: number | string, message_id: number, other?: Other, signal?: AbortSignal): Promise; + /** + * Use this method to copy messages of any kind. If some of the specified messages can't be found or copied, they are skipped. Service messages, paid media messages, giveaway messages, giveaway winners messages, and invoice messages can't be copied. A quiz poll can be copied only if the value of the field correct_option_id is known to the bot. The method is analogous to the method forwardMessages, but the copied messages don't have a link to the original message. Album grouping is kept for copied messages. On success, an array of MessageId of the sent messages is returned. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param from_chat_id Unique identifier for the chat where the original messages were sent (or channel username in the format @channelusername) + * @param message_ids A list of 1-100 identifiers of messages in the chat from_chat_id to copy. The identifiers must be specified in a strictly increasing order. + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#copymessages + */ + copyMessages(chat_id: number | string, from_chat_id: number | string, message_ids: number[], other?: Other, signal?: AbortSignal): Promise; + /** + * Use this method to send photos. On success, the sent Message is returned. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param photo Photo to send. Pass a file_id as String to send a photo that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a photo from the Internet, or upload a new photo using multipart/form-data. The photo must be at most 10 MB in size. The photo's width and height must not exceed 10000 in total. Width and height ratio must be at most 20. + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendphoto + */ + sendPhoto(chat_id: number | string, photo: InputFile | string, other?: Other, signal?: AbortSignal): Promise; + /** + * Use this method to send audio files, if you want Telegram clients to display them in the music player. Your audio must be in the .MP3 or .M4A format. On success, the sent Message is returned. Bots can currently send audio files of up to 50 MB in size, this limit may be changed in the future. + * + * For sending voice messages, use the sendVoice method instead. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param audio Audio file to send. Pass a file_id as String to send an audio file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get an audio file from the Internet, or upload a new one using multipart/form-data. + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendaudio + */ + sendAudio(chat_id: number | string, audio: InputFile | string, other?: Other, signal?: AbortSignal): Promise; + /** + * Use this method to send general files. On success, the sent Message is returned. Bots can currently send files of any type of up to 50 MB in size, this limit may be changed in the future. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param document File to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#senddocument + */ + sendDocument(chat_id: number | string, document: InputFile | string, other?: Other, signal?: AbortSignal): Promise; + /** + * Use this method to send video files, Telegram clients support mp4 videos (other formats may be sent as Document). On success, the sent Message is returned. Bots can currently send video files of up to 50 MB in size, this limit may be changed in the future. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param video Video to send. Pass a file_id as String to send a video that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a video from the Internet, or upload a new video using multipart/form-data. + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendvideo + */ + sendVideo(chat_id: number | string, video: InputFile | string, other?: Other, signal?: AbortSignal): Promise; + /** + * Use this method to send animation files (GIF or H.264/MPEG-4 AVC video without sound). On success, the sent Message is returned. Bots can currently send animation files of up to 50 MB in size, this limit may be changed in the future. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param animation Animation to send. Pass a file_id as String to send an animation that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get an animation from the Internet, or upload a new animation using multipart/form-data. + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendanimation + */ + sendAnimation(chat_id: number | string, animation: InputFile | string, other?: Other, signal?: AbortSignal): Promise; + /** + * Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message. For this to work, your audio must be in an .OGG file encoded with OPUS (other formats may be sent as Audio or Document). On success, the sent Message is returned. Bots can currently send voice messages of up to 50 MB in size, this limit may be changed in the future. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param voice Audio file to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendvoice + */ + sendVoice(chat_id: number | string, voice: InputFile | string, other?: Other, signal?: AbortSignal): Promise; + /** + * Use this method to send video messages. On success, the sent Message is returned. + * As of v.4.0, Telegram clients support rounded square mp4 videos of up to 1 minute long. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param video_note Video note to send. Pass a file_id as String to send a video note that exists on the Telegram servers (recommended) or upload a new video using multipart/form-data.. Sending video notes by a URL is currently unsupported + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendvideonote + */ + sendVideoNote(chat_id: number | string, video_note: InputFile | string, other?: Other, signal?: AbortSignal): Promise; + /** + * Use this method to send a group of photos, videos, documents or audios as an album. Documents and audio files can be only grouped in an album with messages of the same type. On success, an array of Messages that were sent is returned. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param media An array describing messages to be sent, must include 2-10 items + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendmediagroup + */ + sendMediaGroup(chat_id: number | string, media: ReadonlyArray, other?: Other, signal?: AbortSignal): Promise<(import("@grammyjs/types/message.js").Message.PhotoMessage | import("@grammyjs/types/message.js").Message.AudioMessage | import("@grammyjs/types/message.js").Message.DocumentMessage | import("@grammyjs/types/message.js").Message.VideoMessage)[]>; + /** + * Use this method to send point on the map. On success, the sent Message is returned. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param latitude Latitude of the location + * @param longitude Longitude of the location + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendlocation + */ + sendLocation(chat_id: number | string, latitude: number, longitude: number, other?: Other, signal?: AbortSignal): Promise; + /** + * Use this method to edit live location messages. A location can be edited until its live_period expires or editing is explicitly disabled by a call to stopMessageLiveLocation. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param message_id Identifier of the message to edit + * @param latitude Latitude of new location + * @param longitude Longitude of new location + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#editmessagelivelocation + */ + editMessageLiveLocation(chat_id: number | string, message_id: number, latitude: number, longitude: number, other?: Other, signal?: AbortSignal): Promise; + /** + * Use this method to edit live location inline messages. A location can be edited until its live_period expires or editing is explicitly disabled by a call to stopMessageLiveLocation. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. + * + * @param inline_message_id Identifier of the inline message + * @param latitude Latitude of new location + * @param longitude Longitude of new location + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#editmessagelivelocation + */ + editMessageLiveLocationInline(inline_message_id: string, latitude: number, longitude: number, other?: Other, signal?: AbortSignal): Promise; + /** + * Use this method to stop updating a live location message before live_period expires. On success, if the message is not an inline message, the edited Message is returned, otherwise True is returned. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param message_id Identifier of the message with live location to stop + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#stopmessagelivelocation + */ + stopMessageLiveLocation(chat_id: number | string, message_id: number, other?: Other, signal?: AbortSignal): Promise; + /** + * Use this method to stop updating a live location message before live_period expires. On success, if the message is not an inline message, the edited Message is returned, otherwise True is returned. + * + * @param inline_message_id Identifier of the inline message + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#stopmessagelivelocation + */ + stopMessageLiveLocationInline(inline_message_id: string, other?: Other, signal?: AbortSignal): Promise; + /** + * Use this method to send paid media. On success, the sent Message is returned. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param star_count The number of Telegram Stars that must be paid to buy access to the media + * @param media An array describing the media to be sent; up to 10 items + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendpaidmedia + */ + sendPaidMedia(chat_id: number | string, star_count: number, media: InputPaidMedia[], other?: Other, signal?: AbortSignal): Promise; + /** + * Use this method to send information about a venue. On success, the sent Message is returned. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param latitude Latitude of the venue + * @param longitude Longitude of the venue + * @param title Name of the venue + * @param address Address of the venue + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendvenue + */ + sendVenue(chat_id: number | string, latitude: number, longitude: number, title: string, address: string, other?: Other, signal?: AbortSignal): Promise; + /** + * Use this method to send phone contacts. On success, the sent Message is returned. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param phone_number Contact's phone number + * @param first_name Contact's first name + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendcontact + */ + sendContact(chat_id: number | string, phone_number: string, first_name: string, other?: Other, signal?: AbortSignal): Promise; + /** + * Use this method to send a native poll. On success, the sent Message is returned. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param question Poll question, 1-300 characters + * @param options A list of answer options, 2-12 strings 1-100 characters each + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendpoll + */ + sendPoll(chat_id: number | string, question: string, options: (string | InputPollOption)[], other?: Other, signal?: AbortSignal): Promise; + /** + * Use this method to send a checklist on behalf of a connected business account. On success, the sent Message is returned. + * + * @param business_connection_id Unique identifier of the business connection on behalf of which the message will be sent + * @param chat_id Unique identifier for the target chat + * @param checklist An object for the checklist to send + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendchecklist + */ + sendChecklist(business_connection_id: string, chat_id: number, checklist: InputChecklist, other?: Other, signal?: AbortSignal): Promise; + /** + * Use this method to edit a checklist on behalf of a connected business account. On success, the edited Message is returned. + * + * @param business_connection_id Unique identifier of the business connection on behalf of which the message will be sent + * @param chat_id Unique identifier for the target chat + * @param message_id Unique identifier for the target message + * @param checklist An object for the new checklist + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#editmessagechecklist + */ + editMessageChecklist(business_connection_id: string, chat_id: number, message_id: number, checklist: InputChecklist, other?: Other, signal?: AbortSignal): Promise; + /** + * Use this method to send an animated emoji that will display a random value. On success, the sent Message is returned. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param emoji Emoji on which the dice throw animation is based. Currently, must be one of “🎲”, “🎯”, “🏀”, “⚽”, “🎳”, or “🎰”. Dice can have values 1-6 for “🎲”, “🎯” and “🎳”, values 1-5 for “🏀” and “⚽”, and values 1-64 for “🎰”. Defaults to “🎲” + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#senddice + */ + sendDice(chat_id: number | string, emoji: (string & Record) | "🎲" | "🎯" | "🏀" | "⚽" | "🎳" | "🎰", other?: Other, signal?: AbortSignal): Promise; + /** + * Use this method to change the chosen reactions on a message. Service messages of some types can't be reacted to. Automatically forwarded messages from a channel to its discussion group have the same available reactions as messages in the channel. Bots can't use paid reactions. Returns True on success. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param message_id Identifier of the target message + * @param reaction A list of reaction types to set on the message. Currently, as non-premium users, bots can set up to one reaction per message. A custom emoji reaction can be used if it is either already present on the message or explicitly allowed by chat administrators. Paid reactions can't be used by bots. + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setmessagereaction + */ + setMessageReaction(chat_id: number | string, message_id: number, reaction: ReactionType[], other?: Other, signal?: AbortSignal): Promise; + /** + * Use this method when you need to tell the user that something is happening on the bot's side. The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status). Returns True on success. + * + * Example: The ImageBot needs some time to process a request and upload the image. Instead of sending a text message along the lines of “Retrieving image, please wait…”, the bot may use sendChatAction with action = upload_photo. The user will see a “sending photo” status for the bot. + * + * We only recommend using this method when a response from the bot will take a noticeable amount of time to arrive. + * + * @param chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername). Channel chats and channel direct messages chats aren't supported. + * @param action Type of action to broadcast. Choose one, depending on what the user is about to receive: typing for text messages, upload_photo for photos, record_video or upload_video for videos, record_voice or upload_voice for voice notes, upload_document for general files, choose_sticker for stickers, find_location for location data, record_video_note or upload_video_note for video notes. + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendchataction + */ + sendChatAction(chat_id: number | string, action: "typing" | "upload_photo" | "record_video" | "upload_video" | "record_voice" | "upload_voice" | "upload_document" | "choose_sticker" | "find_location" | "record_video_note" | "upload_video_note", other?: Other, signal?: AbortSignal): Promise; + /** + * Use this method to get a list of profile pictures for a user. Returns a UserProfilePhotos object. + * + * @param user_id Unique identifier of the target user + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getuserprofilephotos + */ + getUserProfilePhotos(user_id: number, other?: Other, signal?: AbortSignal): Promise; + /** + * Use this method to get a list of profile audios for a user. Returns a UserProfileAudios object. + * + * @param user_id Unique identifier of the target user + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getuserprofileaudios + */ + getUserProfileAudios(user_id: number, other?: Other, signal?: AbortSignal): Promise; + /** + * Changes the emoji status for a given user that previously allowed the bot to manage their emoji status via the Mini App method requestEmojiStatusAccess. Returns True on success. + * + * @param user_id Unique identifier of the target user + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setuseremojistatus + */ + setUserEmojiStatus(user_id: number, other?: Other, signal?: AbortSignal): Promise; + /** + * Use this method to get the list of boosts added to a chat by a user. Requires administrator rights in the chat. Returns a UserChatBoosts object. + * + * @param chat_id Unique identifier for the chat or username of the channel (in the format @channelusername) + * @param user_id Unique identifier of the target user + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getuserchatboosts + */ + getUserChatBoosts(chat_id: number | string, user_id: number, signal?: AbortSignal): Promise; + /** + * Returns the gifts owned and hosted by a user. Returns OwnedGifts on success. + * + * @param user_id Unique identifier of the user + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getusergifts + */ + getUserGifts(user_id: number, other?: Other, signal?: AbortSignal): Promise; + /** + * Returns the gifts owned by a chat. Returns OwnedGifts on success. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getchatgifts + */ + getChatGifts(chat_id: number, other?: Other, signal?: AbortSignal): Promise; + /** + * Use this method to get information about the connection of the bot with a business account. Returns a BusinessConnection object on success. + * + * @param business_connection_id Unique identifier of the business connection + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getbusinessconnection + */ + getBusinessConnection(business_connection_id: string, signal?: AbortSignal): Promise; + /** + * Use this method to get basic info about a file and prepare it for downloading. For the moment, bots can download files of up to 20MB in size. On success, a File object is returned. The file can then be downloaded via the link `https://api.telegram.org/file/bot/`, where `` is taken from the response. It is guaranteed that the link will be valid for at least 1 hour. When the link expires, a new one can be requested by calling getFile again. + * + * Note: This function may not preserve the original file name and MIME type. You should save the file's MIME type and name (if available) when the File object is received. + * + * @param file_id File identifier to get info about + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getfile + */ + getFile(file_id: string, signal?: AbortSignal): Promise; + /** @deprecated Use `banChatMember` instead. */ + kickChatMember(...args: Parameters): Promise; + /** + * Use this method to ban a user in a group, a supergroup or a channel. In the case of supergroups and channels, the user will not be able to return to the chat on their own using invite links, etc., unless unbanned first. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success. + * + * @param chat_id Unique identifier for the target group or username of the target supergroup or channel (in the format @channelusername) + * @param user_id Unique identifier of the target user + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#banchatmember + */ + banChatMember(chat_id: number | string, user_id: number, other?: Other, signal?: AbortSignal): Promise; + /** + * Use this method to unban a previously banned user in a supergroup or channel. The user will not return to the group or channel automatically, but will be able to join via link, etc. The bot must be an administrator for this to work. By default, this method guarantees that after the call the user is not a member of the chat, but will be able to join it. So if the user is a member of the chat they will also be removed from the chat. If you don't want this, use the parameter only_if_banned. Returns True on success. + * + * @param chat_id Unique identifier for the target group or username of the target supergroup or channel (in the format @username) + * @param user_id Unique identifier of the target user + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#unbanchatmember + */ + unbanChatMember(chat_id: number | string, user_id: number, other?: Other, signal?: AbortSignal): Promise; + /** + * Use this method to restrict a user in a supergroup. The bot must be an administrator in the supergroup for this to work and must have the appropriate administrator rights. Pass True for all permissions to lift restrictions from a user. Returns True on success. + * + * @param chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) + * @param user_id Unique identifier of the target user + * @param permissions An object for new user permissions + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#restrictchatmember + */ + restrictChatMember(chat_id: number | string, user_id: number, permissions: ChatPermissions, other?: Other, signal?: AbortSignal): Promise; + /** + * Use this method to promote or demote a user in a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Pass False for all boolean parameters to demote a user. Returns True on success. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param user_id Unique identifier of the target user + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#promotechatmember + */ + promoteChatMember(chat_id: number | string, user_id: number, other?: Other, signal?: AbortSignal): Promise; + /** + * Use this method to set a custom title for an administrator in a supergroup promoted by the bot. Returns True on success. + * + * @param chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) + * @param user_id Unique identifier of the target user + * @param custom_title New custom title for the administrator; 0-16 characters, emoji are not allowed + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setchatadministratorcustomtitle + */ + setChatAdministratorCustomTitle(chat_id: number | string, user_id: number, custom_title: string, signal?: AbortSignal): Promise; + /** + * Use this method to ban a channel chat in a supergroup or a channel. Until the chat is unbanned, the owner of the banned chat won't be able to send messages on behalf of any of their channels. The bot must be an administrator in the supergroup or channel for this to work and must have the appropriate administrator rights. Returns True on success. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param sender_chat_id Unique identifier of the target sender chat + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#banchatsenderchat + */ + banChatSenderChat(chat_id: number | string, sender_chat_id: number, signal?: AbortSignal): Promise; + /** + * Use this method to unban a previously banned channel chat in a supergroup or channel. The bot must be an administrator for this to work and must have the appropriate administrator rights. Returns True on success. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param sender_chat_id Unique identifier of the target sender chat + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#unbanchatsenderchat + */ + unbanChatSenderChat(chat_id: number | string, sender_chat_id: number, signal?: AbortSignal): Promise; + /** + * Use this method to set default chat permissions for all members. The bot must be an administrator in the group or a supergroup for this to work and must have the can_restrict_members administrator rights. Returns True on success. + * + * @param chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) + * @param permissions New default chat permissions + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setchatpermissions + */ + setChatPermissions(chat_id: number | string, permissions: ChatPermissions, other?: Other, signal?: AbortSignal): Promise; + /** + * Use this method to generate a new primary invite link for a chat; any previously generated primary link is revoked. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the new invite link as String on success. + * + * Note: Each administrator in a chat generates their own invite links. Bots can't use invite links generated by other administrators. If you want your bot to work with invite links, it will need to generate its own link using exportChatInviteLink or by calling the getChat method. If your bot needs to generate a new primary invite link replacing its previous one, use exportChatInviteLink again. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#exportchatinvitelink + */ + exportChatInviteLink(chat_id: number | string, signal?: AbortSignal): Promise; + /** + * Use this method to create an additional invite link for a chat. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. The link can be revoked using the method revokeChatInviteLink. Returns the new invite link as ChatInviteLink object. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#createchatinvitelink + */ + createChatInviteLink(chat_id: number | string, other?: Other, signal?: AbortSignal): Promise; + /** + * Use this method to edit a non-primary invite link created by the bot. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the edited invite link as a ChatInviteLink object. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param invite_link The invite link to edit + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#editchatinvitelink + */ + editChatInviteLink(chat_id: number | string, invite_link: string, other?: Other, signal?: AbortSignal): Promise; + /** + * Use this method to create a subscription invite link for a channel chat. The bot must have the can_invite_users administrator rights. The link can be edited using the method editChatSubscriptionInviteLink or revoked using the method revokeChatInviteLink. Returns the new invite link as a ChatInviteLink object. + * + * @param chat_id Unique identifier for the target channel chat or username of the target channel (in the format @channelusername) + * @param subscription_period The number of seconds the subscription will be active for before the next payment. Currently, it must always be 2592000 (30 days). + * @param subscription_price The amount of Telegram Stars a user must pay initially and after each subsequent subscription period to be a member of the chat; 1-2500 + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#createchatsubscriptioninvitelink + */ + createChatSubscriptionInviteLink(chat_id: number | string, subscription_period: number, subscription_price: number, other?: Other, signal?: AbortSignal): Promise; + /** + * Use this method to edit a subscription invite link created by the bot. The bot must have the can_invite_users administrator rights. Returns the edited invite link as a ChatInviteLink object. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param invite_link The invite link to edit + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#editchatsubscriptioninvitelink + */ + editChatSubscriptionInviteLink(chat_id: number | string, invite_link: string, other?: Other, signal?: AbortSignal): Promise; + /** + * Use this method to revoke an invite link created by the bot. If the primary link is revoked, a new link is automatically generated. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the revoked invite link as ChatInviteLink object. + * + * @param chat_id Unique identifier of the target chat or username of the target channel (in the format @channelusername) + * @param invite_link The invite link to revoke + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#revokechatinvitelink + */ + revokeChatInviteLink(chat_id: number | string, invite_link: string, signal?: AbortSignal): Promise; + /** + * Use this method to approve a chat join request. The bot must be an administrator in the chat for this to work and must have the can_invite_users administrator right. Returns True on success. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param user_id Unique identifier of the target user + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#approvechatjoinrequest + */ + approveChatJoinRequest(chat_id: number | string, user_id: number, signal?: AbortSignal): Promise; + /** + * Use this method to decline a chat join request. The bot must be an administrator in the chat for this to work and must have the can_invite_users administrator right. Returns True on success. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param user_id Unique identifier of the target user + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#declinechatjoinrequest + */ + declineChatJoinRequest(chat_id: number | string, user_id: number, signal?: AbortSignal): Promise; + /** + * Use this method to approve a suggested post in a direct messages chat. The bot must have the 'can_post_messages' administrator right in the corresponding channel chat. Returns True on success. + * + * @param chat_id Unique identifier for the target direct messages chat + * @param message_id Identifier of a suggested post message to approve + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#approvesuggestedpost + */ + approveSuggestedPost(chat_id: number, message_id: number, other?: Other, signal?: AbortSignal): Promise; + /** + * Use this method to decline a suggested post in a direct messages chat. The bot must have the 'can_manage_direct_messages' administrator right in the corresponding channel chat. Returns True on success. + * + * @param chat_id Unique identifier for the target direct messages chat + * @param message_id Identifier of a suggested post message to decline + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#declinesuggestedpost + */ + declineSuggestedPost(chat_id: number, message_id: number, other?: Other, signal?: AbortSignal): Promise; + /** + * Use this method to set a new profile photo for the chat. Photos can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param photo New chat photo, uploaded using multipart/form-data + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setchatphoto + */ + setChatPhoto(chat_id: number | string, photo: InputFile, signal?: AbortSignal): Promise; + /** + * Use this method to delete a chat photo. Photos can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#deletechatphoto + */ + deleteChatPhoto(chat_id: number | string, signal?: AbortSignal): Promise; + /** + * Use this method to change the title of a chat. Titles can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param title New chat title, 1-255 characters + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setchattitle + */ + setChatTitle(chat_id: number | string, title: string, signal?: AbortSignal): Promise; + /** + * Use this method to change the description of a group, a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param description New chat description, 0-255 characters + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setchatdescription + */ + setChatDescription(chat_id: number | string, description?: string, signal?: AbortSignal): Promise; + /** + * Use this method to add a message to the list of pinned messages in a chat. In private chats and channel direct messages chats, all non-service messages can be pinned. Conversely, the bot must be an administrator with the 'can_pin_messages' right or the 'can_edit_messages' right to pin messages in groups and channels respectively. Returns True on success. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param message_id Identifier of a message to pin + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#pinchatmessage + */ + pinChatMessage(chat_id: number | string, message_id: number, other?: Other, signal?: AbortSignal): Promise; + /** + * Use this method to remove a message from the list of pinned messages in a chat. In private chats and channel direct messages chats, all messages can be unpinned. Conversely, the bot must be an administrator with the 'can_pin_messages' right or the 'can_edit_messages' right to unpin messages in groups and channels respectively. Returns True on success. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param message_id Identifier of a message to unpin. If not specified, the most recent pinned message (by sending date) will be unpinned. + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#unpinchatmessage + */ + unpinChatMessage(chat_id: number | string, message_id?: number, other?: Other, signal?: AbortSignal): Promise; + /** + * Use this method to clear the list of pinned messages in a chat. In private chats and channel direct messages chats, no additional rights are required to unpin all pinned messages. Conversely, the bot must be an administrator with the 'can_pin_messages' right or the 'can_edit_messages' right to unpin all pinned messages in groups and channels respectively. Returns True on success. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#unpinallchatmessages + */ + unpinAllChatMessages(chat_id: number | string, signal?: AbortSignal): Promise; + /** + * Use this method for your bot to leave a group, supergroup or channel. Returns True on success. + * + * @param chat_id Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername). Channel direct messages chats aren't supported; leave the corresponding channel instead. + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#leavechat + */ + leaveChat(chat_id: number | string, signal?: AbortSignal): Promise; + /** + * Use this method to get up to date information about the chat (current name of the user for one-on-one conversations, current username of a user, group or channel, etc.). Returns a Chat object on success. + * + * @param chat_id Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername) + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getchat + */ + getChat(chat_id: number | string, signal?: AbortSignal): Promise; + /** + * Use this method to get a list of administrators in a chat, which aren't bots. Returns an Array of ChatMember objects. + * + * @param chat_id Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername) + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getchatadministrators + */ + getChatAdministrators(chat_id: number | string, signal?: AbortSignal): Promise<(import("@grammyjs/types/manage.js").ChatMemberOwner | import("@grammyjs/types/manage.js").ChatMemberAdministrator)[]>; + /** @deprecated Use `getChatMemberCount` instead. */ + getChatMembersCount(...args: Parameters): Promise; + /** + * Use this method to get the number of members in a chat. Returns Int on success. + * + * @param chat_id Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername) + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getchatmembercount + */ + getChatMemberCount(chat_id: number | string, signal?: AbortSignal): Promise; + /** + * Use this method to get information about a member of a chat. The method is guaranteed to work only if the bot is an administrator in the chat. Returns a ChatMember object on success. + * + * @param chat_id Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername) + * @param user_id Unique identifier of the target user + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getchatmember + */ + getChatMember(chat_id: number | string, user_id: number, signal?: AbortSignal): Promise; + /** + * Use this method to set a new group sticker set for a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Use the field can_set_sticker_set ly returned in getChat requests to check if the bot can use this method. Returns True on success. + * + * @param chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) + * @param sticker_set_name Name of the sticker set to be set as the group sticker set + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setchatstickerset + */ + setChatStickerSet(chat_id: number | string, sticker_set_name: string, signal?: AbortSignal): Promise; + /** + * Use this method to delete a group sticker set from a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Use the field can_set_sticker_set ly returned in getChat requests to check if the bot can use this method. Returns True on success. + * + * @param chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#deletechatstickerset + */ + deleteChatStickerSet(chat_id: number | string, signal?: AbortSignal): Promise; + /** + * Use this method to get custom emoji stickers, which can be used as a forum topic icon by any user. Requires no parameters. Returns an Array of Sticker objects. + * + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getforumtopiciconstickers + */ + getForumTopicIconStickers(signal?: AbortSignal): Promise; + /** + * Use this method to create a topic in a forum supergroup chat or a private chat with a user. In the case of a supergroup chat the bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator right. Returns information about the created topic as a ForumTopic object. + * + * @param chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) + * @param name Topic name, 1-128 characters + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#createforumtopic + */ + createForumTopic(chat_id: number | string, name: string, other?: Other, signal?: AbortSignal): Promise; + /** + * Use this method to edit name and icon of a topic in a forum supergroup chat or a private chat with a user. In the case of a supergroup chat the bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights, unless it is the creator of the topic. Returns True on success. + * + * @param chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) + * @param message_thread_id Unique identifier for the target message thread of the forum topic + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#editforumtopic + */ + editForumTopic(chat_id: number | string, message_thread_id: number, other?: Other, signal?: AbortSignal): Promise; + /** + * Use this method to close an open topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights, unless it is the creator of the topic. Returns True on success. + * + * @param chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) + * @param message_thread_id Unique identifier for the target message thread of the forum topic + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#closeforumtopic + */ + closeForumTopic(chat_id: number | string, message_thread_id: number, signal?: AbortSignal): Promise; + /** + * Use this method to reopen a closed topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights, unless it is the creator of the topic. Returns True on success. + * + * @param chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) + * @param message_thread_id Unique identifier for the target message thread of the forum topic + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#reopenforumtopic + */ + reopenForumTopic(chat_id: number | string, message_thread_id: number, signal?: AbortSignal): Promise; + /** + * Use this method to delete a forum topic along with all its messages in a forum supergroup chat or a private chat with a user. In the case of a supergroup chat the bot must be an administrator in the chat for this to work and must have the can_delete_messages administrator rights. Returns True on success. + * + * @param chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) + * @param message_thread_id Unique identifier for the target message thread of the forum topic + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#deleteforumtopic + */ + deleteForumTopic(chat_id: number | string, message_thread_id: number, signal?: AbortSignal): Promise; + /** + * Use this method to clear the list of pinned messages in a forum topic in a forum supergroup chat or a private chat with a user. In the case of a supergroup chat the bot must be an administrator in the chat for this to work and must have the can_pin_messages administrator right in the supergroup. Returns True on success. + * + * @param chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) + * @param message_thread_id Unique identifier for the target message thread of the forum topic + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#unpinallforumtopicmessages + */ + unpinAllForumTopicMessages(chat_id: number | string, message_thread_id: number, signal?: AbortSignal): Promise; + /** + * Use this method to edit the name of the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. Returns True on success. + * + * @param chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) + * @param name New topic name, 1-128 characters + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#editgeneralforumtopic + */ + editGeneralForumTopic(chat_id: number | string, name: string, signal?: AbortSignal): Promise; + /** + * Use this method to close an open 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. Returns True on success. + * + * @param chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#closegeneralforumtopic + */ + closeGeneralForumTopic(chat_id: number | string, signal?: AbortSignal): Promise; + /** + * Use this method to reopen a closed 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. The topic will be automatically unhidden if it was hidden. Returns True on success. * + * + * @param chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#reopengeneralforumtopic + */ + reopenGeneralForumTopic(chat_id: number | string, signal?: AbortSignal): Promise; + /** + * Use this method to hide the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. The topic will be automatically closed if it was open. Returns True on success. + * + * @param chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#hidegeneralforumtopic + */ + hideGeneralForumTopic(chat_id: number | string, signal?: AbortSignal): Promise; + /** + * Use this method to unhide the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. Returns True on success. + * + * @param chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#unhidegeneralforumtopic + */ + unhideGeneralForumTopic(chat_id: number | string, signal?: AbortSignal): Promise; + /** + * Use this method to clear the list of pinned messages in a General forum topic. The bot must be an administrator in the chat for this to work and must have the can_pin_messages administrator right in the supergroup. Returns True on success. + * + * @param chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#unpinallgeneralforumtopicmessages + */ + unpinAllGeneralForumTopicMessages(chat_id: number | string, signal?: AbortSignal): Promise; + /** + * Use this method to send answers to callback queries sent from inline keyboards. The answer will be displayed to the user as a notification at the top of the chat screen or as an alert. On success, True is returned. + * + * Alternatively, the user can be redirected to the specified Game URL. For this option to work, you must first create a game for your bot via @BotFather and accept the terms. Otherwise, you may use links like t.me/your_bot?start=XXXX that open your bot with a parameter. + * + * @param callback_query_id Unique identifier for the query to be answered + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#answercallbackquery + */ + answerCallbackQuery(callback_query_id: string, other?: Other, signal?: AbortSignal): Promise; + /** + * Use this method to change the bot's name. Returns True on success. + * + * @param name New bot name; 0-64 characters. Pass an empty string to remove the dedicated name for the given language. + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setmyname + */ + setMyName(name: string, other?: Other, signal?: AbortSignal): Promise; + /** + * Use this method to get the current bot name for the given user language. Returns BotName on success. + * + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getmyname + */ + getMyName(other?: Other, signal?: AbortSignal): Promise; + /** + * Use this method to change the list of the bot's commands. See https://core.telegram.org/bots/features#commands for more details about bot commands. Returns True on success. + * + * @param commands A list of bot commands to be set as the list of the bot's commands. At most 100 commands can be specified. + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setmycommands + */ + setMyCommands(commands: readonly BotCommand[], other?: Other, signal?: AbortSignal): Promise; + /** + * Use this method to delete the list of the bot's commands for the given scope and user language. After deletion, higher level commands will be shown to affected users. Returns True on success. + * + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#deletemycommands + */ + deleteMyCommands(other?: Other, signal?: AbortSignal): Promise; + /** + * Use this method to get the current list of the bot's commands for the given scope and user language. Returns an Array of BotCommand objects. If commands aren't set, an empty list is returned. + * + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getmycommands + */ + getMyCommands(other?: Other, signal?: AbortSignal): Promise; + /** + * Use this method to change the bot's description, which is shown in the chat with the bot if the chat is empty. Returns True on success. + * + * @param description New bot description; 0-512 characters. Pass an empty string to remove the dedicated description for the given language. + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setmydescription + */ + setMyDescription(description: string, other?: Other, signal?: AbortSignal): Promise; + /** + * Use this method to get the current bot description for the given user language. Returns BotDescription on success. + * + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getmydescription + */ + getMyDescription(other?: Other, signal?: AbortSignal): Promise; + /** + * Use this method to change the bot's short description, which is shown on the bot's profile page and is sent together with the link when users share the bot. Returns True on success. + * + * @param short_description New short description for the bot; 0-120 characters. Pass an empty string to remove the dedicated short description for the given language. + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setmyshortdescription + */ + setMyShortDescription(short_description: string, other?: Other, signal?: AbortSignal): Promise; + /** + * Use this method to get the current bot short description for the given user language. Returns BotShortDescription on success. + * + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getmyshortdescription + */ + getMyShortDescription(other?: Other, signal?: AbortSignal): Promise; + /** + * Changes the profile photo of the bot. Returns True on success. + * + * @param photo The new profile photo to set + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setmyprofilephoto + */ + setMyProfilePhoto(photo: InputProfilePhoto, signal?: AbortSignal): Promise; + /** + * Removes the profile photo of the bot. Requires no parameters. Returns True on success. + * + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#removemyprofilephoto + */ + removeMyProfilePhoto(signal?: AbortSignal): Promise; + /** + * Use this method to change the bot's menu button in a private chat, or the default menu button. Returns True on success. + * + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setchatmenubutton + */ + setChatMenuButton(other?: Other, signal?: AbortSignal): Promise; + /** + * Use this method to get the current value of the bot's menu button in a private chat, or the default menu button. Returns MenuButton on success. + * + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getchatmenubutton + */ + getChatMenuButton(other?: Other, signal?: AbortSignal): Promise; + /** + * Use this method to the change the default administrator rights requested by the bot when it's added as an administrator to groups or channels. These rights will be suggested to users, but they are are free to modify the list before adding the bot. Returns True on success. + * + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setmydefaultadministratorrights + */ + setMyDefaultAdministratorRights(other?: Other, signal?: AbortSignal): Promise; + /** + * Use this method to get the current default administrator rights of the bot. Returns ChatAdministratorRights on success. + * + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getmydefaultadministratorrights + */ + getMyDefaultAdministratorRights(other?: Other, signal?: AbortSignal): Promise; + /** + * A method to get the current Telegram Stars balance of the bot. Requires no parameters. On success, returns a StarAmount object. + * + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getmystarbalance + */ + getMyStarBalance(signal?: AbortSignal): Promise; + /** + * Use this method to edit text and game messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param message_id Identifier of the message to edit + * @param text New text of the message, 1-4096 characters after entities parsing + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#editmessagetext + */ + editMessageText(chat_id: number | string, message_id: number, text: string, other?: Other, signal?: AbortSignal): Promise)>; + /** + * Use this method to edit text and game inline messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent. + * + * @param inline_message_id Identifier of the inline message + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#editmessagetext + */ + editMessageTextInline(inline_message_id: string, text: string, other?: Other, signal?: AbortSignal): Promise)>; + /** + * Use this method to edit captions of messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param message_id Identifier of the message to edit + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#editmessagecaption + */ + editMessageCaption(chat_id: number | string, message_id: number, other?: Other, signal?: AbortSignal): Promise; + /** + * Use this method to edit captions of inline messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent. + * + * @param inline_message_id Identifier of the inline message + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#editmessagecaption + */ + editMessageCaptionInline(inline_message_id: string, other?: Other, signal?: AbortSignal): Promise; + /** + * Use this method to edit animation, audio, document, photo, or video messages, or to add media to text messages. If a message is part of a message album, then it can be edited only to an audio for audio albums, only to a document for document albums and to a photo or a video otherwise. When an inline message is edited, a new file can't be uploaded; use a previously uploaded file via its file_id or specify a URL. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param message_id Identifier of the message to edit + * @param media An object for a new media content of the message + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#editmessagemedia + */ + editMessageMedia(chat_id: number | string, message_id: number, media: InputMedia, other?: Other, signal?: AbortSignal): Promise; + /** + * Use this method to edit animation, audio, document, photo, or video inline messages, or to add media to text inline messages. If a message is part of a message album, then it can be edited only to an audio for audio albums, only to a document for document albums and to a photo or a video otherwise. When an inline message is edited, a new file can't be uploaded; use a previously uploaded file via its file_id or specify a URL. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent. + * + * @param inline_message_id Identifier of the inline message + * @param media An object for a new media content of the message + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#editmessagemedia + */ + editMessageMediaInline(inline_message_id: string, media: InputMedia, other?: Other, signal?: AbortSignal): Promise; + /** + * Use this method to edit only the reply markup of messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param message_id Identifier of the message to edit + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#editmessagereplymarkup + */ + editMessageReplyMarkup(chat_id: number | string, message_id: number, other?: Other, signal?: AbortSignal): Promise; + /** + * Use this method to edit only the reply markup of inline messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent. + * + * @param inline_message_id Identifier of the inline message + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#editmessagereplymarkup + */ + editMessageReplyMarkupInline(inline_message_id: string, other?: Other, signal?: AbortSignal): Promise; + /** + * Use this method to stop a poll which was sent by the bot. On success, the stopped Poll is returned. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param message_id Identifier of the original message with the poll + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#stoppoll + */ + stopPoll(chat_id: number | string, message_id: number, other?: Other, signal?: AbortSignal): Promise; + /** + * Use this method to delete a message, including service messages, with the following limitations: + * - A message can only be deleted if it was sent less than 48 hours ago. + * - A dice message in a private chat can only be deleted if it was sent more than 24 hours ago. + * - Bots can delete outgoing messages in private chats, groups, and supergroups. + * - Bots can delete incoming messages in private chats. + * - Bots granted can_post_messages permissions can delete outgoing messages in channels. + * - If the bot is an administrator of a group, it can delete any message there. + * - If the bot has can_delete_messages administrator right in a supergroup or a channel, it can delete any message there. + * - If the bot has can_manage_direct_messages administrator right in a channel, it can delete any message in the corresponding direct messages chat. + * Returns True on success. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param message_id Identifier of the message to delete + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#deletemessage + */ + deleteMessage(chat_id: number | string, message_id: number, signal?: AbortSignal): Promise; + /** + * Use this method to delete multiple messages simultaneously. Returns True on success. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param message_ids A list of 1-100 identifiers of messages to delete. See deleteMessage for limitations on which messages can be deleted + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#deletemessages + */ + deleteMessages(chat_id: number | string, message_ids: number[], signal?: AbortSignal): Promise; + /** + * Delete messages on behalf of a business account. Requires the can_delete_outgoing_messages business bot right to delete messages sent by the bot itself, or the can_delete_all_messages business bot right to delete any message. Returns True on success. + * + * @param business_connection_id Unique identifier of the business connection on behalf of which to delete the messages + * @param message_ids A list of 1-100 identifiers of messages to delete. All messages must be from the same chat. See deleteMessage for limitations on which messages can be deleted + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#deletebusinessmessages + */ + deleteBusinessMessages(business_connection_id: string, message_ids: number[], signal?: AbortSignal): Promise; + /** + * Changes the first and last name of a managed business account. Requires the can_change_name business bot right. Returns True on success. + * + * @param business_connection_id Unique identifier of the business connection + * @param first_name The new value of the first name for the business account; 1-64 characters + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setbusinessaccountname + */ + setBusinessAccountName(business_connection_id: string, first_name: string, other: Other, signal?: AbortSignal): Promise; + /** + * Changes the username of a managed business account. Requires the can_change_username business bot right. Returns True on success. + * + * @param business_connection_id Unique identifier of the business connection * + * @param username The new value of the username for the business account; 0-32 characters + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setbusinessaccountusername + */ + setBusinessAccountUsername(business_connection_id: string, username: string, signal?: AbortSignal): Promise; + /** + * Changes the bio of a managed business account. Requires the can_change_bio business bot right. Returns True on success. + * + * @param business_connection_id Unique identifier of the business connection + * @param bio The new value of the bio for the business account; 0-140 characters + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setbusinessaccountbio + */ + setBusinessAccountBio(business_connection_id: string, bio: string, signal?: AbortSignal): Promise; + /** + * Changes the profile photo of a managed business account. Requires the can_edit_profile_photo business bot right. Returns True on success. + * + * @param business_connection_id Unique identifier of the business connection + * @param photo The new profile photo to set + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setbusinessaccountprofilephoto + */ + setBusinessAccountProfilePhoto(business_connection_id: string, photo: InputProfilePhoto, other: Other, signal?: AbortSignal): Promise; + /** + * Removes the current profile photo of a managed business account. Requires the can_edit_profile_photo business bot right. Returns True on success. + * + * @param business_connection_id Unique identifier of the business connection + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#removebusinessaccountprofilephoto + */ + removeBusinessAccountProfilePhoto(business_connection_id: string, other: Other, signal?: AbortSignal): Promise; + /** + * Changes the privacy settings pertaining to incoming gifts in a managed business account. Requires the can_change_gift_settings business bot right. Returns True on success. + * + * @param business_connection_id Unique identifier of the business connection + * @param show_gift_button Pass True, if a button for sending a gift to the user or by the business account must always be shown in the input field + * @param accepted_gift_types Types of gifts accepted by the business account + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setbusinessaccountgiftsettings + */ + setBusinessAccountGiftSettings(business_connection_id: string, show_gift_button: boolean, accepted_gift_types: AcceptedGiftTypes, signal?: AbortSignal): Promise; + /** + * Returns the amount of Telegram Stars owned by a managed business account. Requires the can_view_gifts_and_stars business bot right. Returns StarAmount on success. + * + * @param business_connection_id Unique identifier of the business connection + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getbusinessaccountstarbalance + */ + getBusinessAccountStarBalance(business_connection_id: string, signal?: AbortSignal): Promise; + /** + * Transfers Telegram Stars from the business account balance to the bot's balance. Requires the can_transfer_stars business bot right. Returns True on success. + * + * @param business_connection_id Unique identifier of the business connection + * @param star_count Number of Telegram Stars to transfer; 1-10000 + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#transferbusinessaccountstars + */ + transferBusinessAccountStars(business_connection_id: string, star_count: number, signal?: AbortSignal): Promise; + /** + * Returns the gifts received and owned by a managed business account. Requires the can_view_gifts_and_stars business bot right. Returns OwnedGifts on success. + * + * @param business_connection_id Unique identifier of the business connection + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getbusinessaccountgifts + */ + getBusinessAccountGifts(business_connection_id: string, other: Other, signal?: AbortSignal): Promise; + /** + * Converts a given regular gift to Telegram Stars. Requires the can_convert_gifts_to_stars business bot right. Returns True on success. + * + * @param business_connection_id Unique identifier of the business connection + * @param owned_gift_id Unique identifier of the regular gift that should be converted to Telegram Stars + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#convertgifttostars + */ + convertGiftToStars(business_connection_id: string, owned_gift_id: string, signal?: AbortSignal): Promise; + /** + * Upgrades a given regular gift to a unique gift. Requires the can_transfer_and_upgrade_gifts business bot right. Additionally requires the can_transfer_stars business bot right if the upgrade is paid. Returns True on success. + * + * @param business_connection_id Unique identifier of the business connection + * @param owned_gift_id Unique identifier of the regular gift that should be upgraded to a unique one + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#upgradegift + */ + upgradeGift(business_connection_id: string, owned_gift_id: string, other: Other, signal?: AbortSignal): Promise; + /** + * Transfers an owned unique gift to another user. Requires the can_transfer_and_upgrade_gifts business bot right. Requires can_transfer_stars business bot right if the transfer is paid. Returns True on success. + * + * @param business_connection_id Unique identifier of the business connection + * @param owned_gift_id Unique identifier of the regular gift that should be transferred + * @param new_owner_chat_id Unique identifier of the chat which will own the gift. The chat must be active in the last 24 hours. + * @param star_count The amount of Telegram Stars that will be paid for the transfer from the business account balance. If positive, then the can_transfer_stars business bot right is required. + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#transfergift + */ + transferGift(business_connection_id: string, owned_gift_id: string, new_owner_chat_id: number, star_count: number, signal?: AbortSignal): Promise; + /** + * Posts a story on behalf of a managed business account. Requires the can_manage_stories business bot right. Returns Story on success. + * + * @param business_connection_id Unique identifier of the business connection + * @param content Content of the story + * @param active_period Period after which the story is moved to the archive, in seconds; must be one of 6 * 3600, 12 * 3600, 86400, or 2 * 86400 + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#poststory + */ + postStory(business_connection_id: string, content: InputStoryContent, active_period: number, other: Other, signal?: AbortSignal): Promise; + /** + * Reposts a story on behalf of a business account from another business account. Both business accounts must be managed by the same bot, and the story on the source account must have been posted (or reposted) by the bot. Requires the can_manage_stories business bot right for both business accounts. Returns Story on success. + * + * @param business_connection_id Unique identifier of the business connection + * @param from_chat_id Unique identifier of the chat which posted the story that should be reposted + * @param from_story_id Unique identifier of the story that should be reposted + * @param active_period Period after which the story is moved to the archive, in seconds; must be one of 6 * 3600, 12 * 3600, 86400, or 2 * 86400 + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#repoststory + */ + repostStory(business_connection_id: string, from_chat_id: number, from_story_id: number, active_period: number, other: Other, signal?: AbortSignal): Promise; + /** + * Edits a story previously posted by the bot on behalf of a managed business account. Requires the can_manage_stories business bot right. Returns Story on success. + * + * @param business_connection_id Unique identifier of the business connection + * @param story_id Unique identifier of the story to edit + * @param content Content of the story + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#editstory + */ + editStory(business_connection_id: string, story_id: number, content: InputStoryContent, other: Other, signal?: AbortSignal): Promise; + /** + * Deletes a story previously posted by the bot on behalf of a managed business account. Requires the can_manage_stories business bot right. Returns True on success. + * + * @param business_connection_id Unique identifier of the business connection + * @param story_id Unique identifier of the story to delete + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#deletestory + */ + deleteStory(business_connection_id: string, story_id: number, signal?: AbortSignal): Promise; + /** + * Use this method to send static .WEBP, animated .TGS, or video .WEBM stickers. On success, the sent Message is returned. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param sticker Sticker to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a .WEBP sticker from the Internet, or upload a new .WEBP, .TGS, or .WEBM sticker using multipart/form-data. Video and animated stickers can't be sent via an HTTP URL. + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendsticker + */ + sendSticker(chat_id: number | string, sticker: InputFile | string, other?: Other, signal?: AbortSignal): Promise; + /** + * Use this method to get a sticker set. On success, a StickerSet object is returned. + * + * @param name Name of the sticker set + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getstickerset + */ + getStickerSet(name: string, signal?: AbortSignal): Promise; + /** + * Use this method to get information about custom emoji stickers by their identifiers. Returns an Array of Sticker objects. + * + * @param custom_emoji_ids A list of custom emoji identifiers + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getcustomemojistickers + */ + getCustomEmojiStickers(custom_emoji_ids: string[], signal?: AbortSignal): Promise; + /** + * Use this method to upload a file with a sticker for later use in the createNewStickerSet, addStickerToSet, or replaceStickerInSet methods (the file can be used multiple times). Returns the uploaded File on success. + * + * @param user_id User identifier of sticker file owner + * @param sticker_format Format of the sticker, must be one of “static”, “animated”, “video” + * @param sticker A file with the sticker in .WEBP, .PNG, .TGS, or .WEBM format. See https://core.telegram.org/stickers for technical requirements. + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#uploadstickerfile + */ + uploadStickerFile(user_id: number, sticker_format: "static" | "animated" | "video", sticker: InputFile, signal?: AbortSignal): Promise; + /** + * Use this method to create a new sticker set owned by a user. The bot will be able to edit the sticker set thus created. Returns True on success. + * + * @param user_id User identifier of created sticker set owner + * @param name Short name of sticker set, to be used in t.me/addstickers/ URLs (e.g., animals). Can contain only English letters, digits and underscores. Must begin with a letter, can't contain consecutive underscores and must end in `_by_`. `` is case insensitive. 1-64 characters. + * @param title Sticker set title, 1-64 characters + * @param stickers A list of 1-50 initial stickers to be added to the sticker set + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#createnewstickerset + */ + createNewStickerSet(user_id: number, name: string, title: string, stickers: InputSticker[], other?: Other, signal?: AbortSignal): Promise; + /** + * Use this method to add a new sticker to a set created by the bot. The format of the added sticker must match the format of the other stickers in the set. Emoji sticker sets can have up to 200 stickers. Animated and video sticker sets can have up to 50 stickers. Static sticker sets can have up to 120 stickers. Returns True on success. + * + * @param user_id User identifier of sticker set owner + * @param name Sticker set name + * @param sticker An object with information about the added sticker. If exactly the same sticker had already been added to the set, then the set isn't changed. + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#addstickertoset + */ + addStickerToSet(user_id: number, name: string, sticker: InputSticker, signal?: AbortSignal): Promise; + /** + * Use this method to move a sticker in a set created by the bot to a specific position. Returns True on success. + * + * @param sticker File identifier of the sticker + * @param position New sticker position in the set, zero-based + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setstickerpositioninset + */ + setStickerPositionInSet(sticker: string, position: number, signal?: AbortSignal): Promise; + /** + * Use this method to delete a sticker from a set created by the bot. Returns True on success. + * + * @param sticker File identifier of the sticker + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#deletestickerfromset + */ + deleteStickerFromSet(sticker: string, signal?: AbortSignal): Promise; + /** + * Use this method to replace an existing sticker in a sticker set with a new one. The method is equivalent to calling deleteStickerFromSet, then addStickerToSet, then setStickerPositionInSet. Returns True on success. + * + * @param user_id User identifier of the sticker set owner + * @param name Sticker set name + * @param old_sticker File identifier of the replaced sticker + * @param sticker An object with information about the added sticker. If exactly the same sticker had already been added to the set, then the set remains unchanged.:x + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#replacestickerinset + */ + replaceStickerInSet(user_id: number, name: string, old_sticker: string, sticker: InputSticker, signal?: AbortSignal): Promise; + /** + * Use this method to change the list of emoji assigned to a regular or custom emoji sticker. The sticker must belong to a sticker set created by the bot. Returns True on success. + * + * @param sticker File identifier of the sticker + * @param emoji_list A list of 1-20 emoji associated with the sticker + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setstickeremojilist + */ + setStickerEmojiList(sticker: string, emoji_list: string[], signal?: AbortSignal): Promise; + /** + * Use this method to change search keywords assigned to a regular or custom emoji sticker. The sticker must belong to a sticker set created by the bot. Returns True on success. + * + * @param sticker File identifier of the sticker + * @param keywords A list of 0-20 search keywords for the sticker with total length of up to 64 characters + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setstickerkeywords + */ + setStickerKeywords(sticker: string, keywords: string[], signal?: AbortSignal): Promise; + /** + * Use this method to change the mask position of a mask sticker. The sticker must belong to a sticker set that was created by the bot. Returns True on success. + * + * @param sticker File identifier of the sticker + * @param mask_position An object with the position where the mask should be placed on faces. Omit the parameter to remove the mask position. + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setstickermaskposition + */ + setStickerMaskPosition(sticker: string, mask_position?: MaskPosition, signal?: AbortSignal): Promise; + /** + * Use this method to set the title of a created sticker set. Returns True on success. + * + * @param name Sticker set name + * @param title Sticker set title, 1-64 characters + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setstickersettitle + */ + setStickerSetTitle(name: string, title: string, signal?: AbortSignal): Promise; + /** + * Use this method to delete a sticker set that was created by the bot. Returns True on success. + * + * @param name Sticker set name + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#deletestickerset + */ + deleteStickerSet(name: string, signal?: AbortSignal): Promise; + /** + * Use this method to set the thumbnail of a regular or mask sticker set. The format of the thumbnail file must match the format of the stickers in the set. Returns True on success. + * + * @param name Sticker set name + * @param user_id User identifier of the sticker set owner + * @param thumbnail A .WEBP or .PNG image with the thumbnail, must be up to 128 kilobytes in size and have a width and height of exactly 100px, or a .TGS animation with a thumbnail up to 32 kilobytes in size (see https://core.telegram.org/stickers#animated-sticker-requirements for animated sticker technical requirements), or a WEBM video with the thumbnail up to 32 kilobytes in size; see https://core.telegram.org/stickers#video-sticker-requirements for video sticker technical requirements. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. More information on Sending Files ». Animated and video sticker set thumbnails can't be uploaded via HTTP URL. If omitted, then the thumbnail is dropped and the first sticker is used as the thumbnail. + * @param format Format of the thumbnail, must be one of “static” for a .WEBP or .PNG image, “animated” for a .TGS animation, or “video” for a WEBM video + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setstickersetthumbnail + */ + setStickerSetThumbnail(name: string, user_id: number, thumbnail: InputFile | string | undefined, format: "static" | "animated" | "video", signal?: AbortSignal): Promise; + /** + * Use this method to set the thumbnail of a custom emoji sticker set. Returns True on success. + * + * @param name Sticker set name + * @param custom_emoji_id Custom emoji identifier of a sticker from the sticker set; pass an empty string to drop the thumbnail and use the first sticker as the thumbnail. + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setcustomemojistickersetthumbnail + */ + setCustomEmojiStickerSetThumbnail(name: string, custom_emoji_id: string, signal?: AbortSignal): Promise; + /** + * Returns the list of gifts that can be sent by the bot to users and channel chats. Requires no parameters. Returns a Gifts object. + * + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getavailablegifts + */ + getAvailableGifts(signal?: AbortSignal): Promise; + /** + * Sends a gift to the given user. The gift can't be converted to Telegram Stars by the receiver. Returns True on success. + * + * @param user_id Unique identifier of the target user who will receive the gift + * @param gift_id Identifier of the gift + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendgift + */ + sendGift(user_id: number, gift_id: string, other?: Other, signal?: AbortSignal): Promise; + /** + * Gifts a Telegram Premium subscription to the given user. Returns True on success. + * + * @param user_id Unique identifier of the target user who will receive a Telegram Premium subscription + * @param month_count Number of months the Telegram Premium subscription will be active for the user; must be one of 3, 6, or 12 + * @param star_count Number of Telegram Stars to pay for the Telegram Premium subscription; must be 1000 for 3 months, 1500 for 6 months, and 2500 for 12 months + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#giftpremiumsubscription + */ + giftPremiumSubscription(user_id: number, month_count: 3 | 6 | 12, star_count: 1000 | 1500 | 2500, other?: Other, signal?: AbortSignal): Promise; + /** + * Sends a gift to the given channel chat. The gift can't be converted to Telegram Stars by the receiver. Returns True on success. + * + * @param chat_id Unique identifier for the chat or username of the channel (in the format @channelusername) that will receive the gift + * @param gift_id Identifier of the gift + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendgift + */ + sendGiftToChannel(chat_id: number | string, gift_id: string, other?: Other, signal?: AbortSignal): Promise; + /** + * Use this method to send answers to an inline query. On success, True is returned. + * No more than 50 results per query are allowed. + * + * Example: An inline bot that sends YouTube videos can ask the user to connect the bot to their YouTube account to adapt search results accordingly. To do this, it displays a 'Connect your YouTube account' button above the results, or even before showing any. The user presses the button, switches to a private chat with the bot and, in doing so, passes a start parameter that instructs the bot to return an OAuth link. Once done, the bot can offer a switch_inline button so that the user can easily return to the chat where they wanted to use the bot's inline capabilities. + * + * @param inline_query_id Unique identifier for the answered query + * @param results An array of results for the inline query + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#answerinlinequery + */ + answerInlineQuery(inline_query_id: string, results: readonly InlineQueryResult[], other?: Other, signal?: AbortSignal): Promise; + /** + * Use this method to set the result of an interaction with a Web App and send a corresponding message on behalf of the user to the chat from which the query originated. On success, a SentWebAppMessage object is returned. + * + * @param web_app_query_id Unique identifier for the query to be answered + * @param result An object describing the message to be sent + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#answerwebappquery + */ + answerWebAppQuery(web_app_query_id: string, result: InlineQueryResult, signal?: AbortSignal): Promise; + /** + * Stores a message that can be sent by a user of a Mini App. Returns a PreparedInlineMessage object. + * + * @param user_id Unique identifier of the target user that can use the prepared message + * @param result An object describing the message to be sent + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#savepreparedinlinemessage + */ + savePreparedInlineMessage(user_id: number, result: InlineQueryResult, other?: Other, signal?: AbortSignal): Promise; + /** + * Use this method to send invoices. On success, the sent Message is returned. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param title Product name, 1-32 characters + * @param description Product description, 1-255 characters + * @param payload Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes. + * @param currency Three-letter ISO 4217 currency code, see more on currencies + * @param prices Price breakdown, a list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.) + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendinvoice + */ + sendInvoice(chat_id: number | string, title: string, description: string, payload: string, currency: string, prices: readonly LabeledPrice[], other?: Other, signal?: AbortSignal): Promise; + /** + * Use this method to create a link for an invoice. Returns the created invoice link as String on success. + * + * @param title Product name, 1-32 characters + * @param description Product description, 1-255 characters + * @param payload Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes. + * @param provider_token Payment provider token, obtained via BotFather + * @param currency Three-letter ISO 4217 currency code, see more on currencies + * @param prices Price breakdown, a list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.) + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#createinvoicelink + */ + createInvoiceLink(title: string, description: string, payload: string, provider_token: string, currency: string, prices: LabeledPrice[], other?: Other, signal?: AbortSignal): Promise; + /** + * If you sent an invoice requesting a shipping address and the parameter is_flexible was specified, the Bot API will send an Update with a shipping_query field to the bot. Use this method to reply to shipping queries. On success, True is returned. + * + * @param shipping_query_id Unique identifier for the query to be answered + * @param ok Pass True if delivery to the specified address is possible and False if there are any problems (for example, if delivery to the specified address is not possible) + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#answershippingquery + */ + answerShippingQuery(shipping_query_id: string, ok: boolean, other?: Other, signal?: AbortSignal): Promise; + /** + * Once the user has confirmed their payment and shipping details, the Bot API sends the final confirmation in the form of an Update with the field pre_checkout_query. Use this method to respond to such pre-checkout queries. On success, True is returned. Note: The Bot API must receive an answer within 10 seconds after the pre-checkout query was sent. + * + * @param pre_checkout_query_id Unique identifier for the query to be answered + * @param ok Specify True if everything is alright (goods are available, etc.) and the bot is ready to proceed with the order. Use False if there are any problems. + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#answerprecheckoutquery + */ + answerPreCheckoutQuery(pre_checkout_query_id: string, ok: boolean, other?: Other, signal?: AbortSignal): Promise; + /** + * Returns the bot's Telegram Star transactions in chronological order. On success, returns a StarTransactions object. + * + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getstartransactions + */ + getStarTransactions(other?: Other, signal?: AbortSignal): Promise; + /** + * Refunds a successful payment in Telegram Stars. + * + * @param user_id Identifier of the user whose payment will be refunded + * @param telegram_payment_charge_id Telegram payment identifier + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#refundstarpayment + */ + refundStarPayment(user_id: number, telegram_payment_charge_id: string, signal?: AbortSignal): Promise; + /** + * Allows the bot to cancel or re-enable extension of a subscription paid in Telegram Stars. Returns True on success. + * + * @param user_id Identifier of the user whose subscription will be edited + * @param telegram_payment_charge_id Telegram payment identifier for the subscription + * @param is_canceled Pass True to cancel extension of the user subscription; the subscription must be active up to the end of the current subscription period. Pass False to allow the user to re-enable a subscription that was previously canceled by the bot. + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#edituserstarsubscription + */ + editUserStarSubscription(user_id: number, telegram_payment_charge_id: string, is_canceled: boolean, signal?: AbortSignal): Promise; + /** + * Verifies a user on behalf of the organization which is represented by the bot. Returns True on success. + * + * @param user_id Unique identifier of the target user + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#verifyuser + */ + verifyUser(user_id: number, other?: Other, signal?: AbortSignal): Promise; + /** + * Verifies a chat on behalf of the organization which is represented by the bot. Returns True on success. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername). Channel direct messages chats can't be verified. + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#verifychat + */ + verifyChat(chat_id: number | string, other?: Other, signal?: AbortSignal): Promise; + /** + * Removes verification from a user who is currently verified on behalf of the organization represented by the bot. Returns True on success. + * + * @param user_id Unique identifier of the target user + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#removeuserverification + */ + removeUserVerification(user_id: number, signal?: AbortSignal): Promise; + /** + * Removes verification from a chat that is currently verified on behalf of the organization represented by the bot. Returns True on success. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#removechatverification + */ + removeChatVerification(chat_id: number | string, signal?: AbortSignal): Promise; + /** + * Marks incoming message as read on behalf of a business account. Requires the can_read_messages business bot right. Returns True on success. + * + * @param business_connection_id Unique identifier of the business connection on behalf of which to read the message + * @param chat_id Unique identifier of the chat in which the message was received. The chat must have been active in the last 24 hours. + * @param message_id Unique identifier of the message to mark as read + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#readbusinessmessage + */ + readBusinessMessage(business_connection_id: string, chat_id: number, message_id: number, signal?: AbortSignal): Promise; + /** + * Informs a user that some of the Telegram Passport elements they provided contains errors. The user will not be able to re-submit their Passport to you until the errors are fixed (the contents of the field for which you returned the error must change). Returns True on success. + * + * Use this if the data submitted by the user doesn't satisfy the standards your service requires for any reason. For example, if a birthday date seems invalid, a submitted document is blurry, a scan shows evidence of tampering, etc. Supply some details in the error message to make sure the user knows how to correct the issues. + * + * @param user_id User identifier + * @param errors An array describing the errors + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setpassportdataerrors + */ + setPassportDataErrors(user_id: number, errors: readonly PassportElementError[], signal?: AbortSignal): Promise; + /** + * Use this method to send a game. On success, the sent Message is returned. + * + * @param chat_id Unique identifier for the target chat. Games can't be sent to channel direct messages chats and channel chats. + * @param game_short_name Short name of the game, serves as the unique identifier for the game. Set up your games via BotFather. + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendgame + */ + sendGame(chat_id: number, game_short_name: string, other?: Other, signal?: AbortSignal): Promise; + /** + * Use this method to set the score of the specified user in a game message. On success, if the message is not an inline message, the Message is returned, otherwise True is returned. Returns an error, if the new score is not greater than the user's current score in the chat and force is False. + * + * @param chat_id Unique identifier for the target chat + * @param message_id Identifier of the sent message + * @param user_id User identifier + * @param score New score, must be non-negative + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setgamescore + */ + setGameScore(chat_id: number, message_id: number, user_id: number, score: number, other?: Other, signal?: AbortSignal): Promise; + /** + * Use this method to set the score of the specified user in a game message. On success, if the message is not an inline message, the Message is returned, otherwise True is returned. Returns an error, if the new score is not greater than the user's current score in the chat and force is False. + * + * @param inline_message_id Identifier of the inline message + * @param user_id User identifier + * @param score New score, must be non-negative + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setgamescore + */ + setGameScoreInline(inline_message_id: string, user_id: number, score: number, other?: Other, signal?: AbortSignal): Promise; + /** + * Use this method to get data for high score tables. Will return the score of the specified user and several of their neighbors in a game. Returns an Array of GameHighScore objects. + * + * This method will currently return scores for the target user, plus two of their closest neighbors on each side. Will also return the top three users if the user and his neighbors are not among them. Please note that this behavior is subject to change. + * + * @param chat_id Unique identifier for the target chat + * @param message_id Identifier of the sent message + * @param user_id Target user id + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getgamehighscores + */ + getGameHighScores(chat_id: number, message_id: number, user_id: number, signal?: AbortSignal): Promise; + /** + * Use this method to get data for high score tables. Will return the score of the specified user and several of their neighbors in an inline game. On success, returns an Array of GameHighScore objects. + * + * This method will currently return scores for the target user, plus two of their closest neighbors on each side. Will also return the top three users if the user and his neighbors are not among them. Please note that this behavior is subject to change. + * + * @param inline_message_id Identifier of the inline message + * @param user_id Target user id + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getgamehighscores + */ + getGameHighScoresInline(inline_message_id: string, user_id: number, signal?: AbortSignal): Promise; +} +import { AbortSignal } from "./../shim.node.js"; diff --git a/sandbox/tgbot/node_modules/grammy/out/core/api.js b/sandbox/tgbot/node_modules/grammy/out/core/api.js new file mode 100644 index 0000000..63c0a16 --- /dev/null +++ b/sandbox/tgbot/node_modules/grammy/out/core/api.js @@ -0,0 +1,2310 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Api = void 0; +const client_js_1 = require("./client.js"); +/** + * This class provides access to the full Telegram Bot API. All methods of the + * API have an equivalent on this class, with the most important parameters + * pulled up into the function signature, and the other parameters captured by + * an object. + * + * In addition, this class has a property `raw` that provides raw access to the + * complete Telegram API, with the method signatures 1:1 represented as + * documented on the website (https://core.telegram.org/bots/api). + * + * Every method takes an optional `AbortSignal` object that allows you to cancel + * the request if desired. + * + * In advanced use cases, this class allows to install transformers that can + * modify the method and payload on the fly before sending it to the Telegram + * servers. Confer the `config` property for this. + */ +class Api { + /** + * Constructs a new instance of `Api`. It is independent from all other + * instances of this class. For example, this lets you install a custom set + * of transformers. + * + * @param token Bot API token obtained from [@BotFather](https://t.me/BotFather) + * @param options Optional API client options for the underlying client instance + * @param webhookReplyEnvelope Optional envelope to handle webhook replies + */ + constructor(token, options, webhookReplyEnvelope) { + this.token = token; + this.options = options; + const { raw, use, installedTransformers } = (0, client_js_1.createRawApi)(token, options, webhookReplyEnvelope); + this.raw = raw; + this.config = { + use, + installedTransformers: () => installedTransformers.slice(), + }; + } + /** + * Use this method to receive incoming updates using long polling (wiki). Returns an Array of Update objects. + * + * Notes + * 1. This method will not work if an outgoing webhook is set up. + * 2. In order to avoid getting duplicate updates, recalculate offset after each server response. + * + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getupdates + */ + getUpdates(other, signal) { + return this.raw.getUpdates({ ...other }, signal); + } + /** + * Use this method to specify a URL and receive incoming updates via an outgoing webhook. Whenever there is an update for the bot, we will send an HTTPS POST request to the specified URL, containing a JSON-serialized Update. In case of an unsuccessful request, we will give up after a reasonable amount of attempts. Returns True on success. + * + * If you'd like to make sure that the webhook was set by you, you can specify secret data in the parameter secret_token. If specified, the request will contain a header “X-Telegram-Bot-Api-Secret-Token” with the secret token as content. + * + * Notes + * 1. You will not be able to receive updates using getUpdates for as long as an outgoing webhook is set up. + * 2. To use a self-signed certificate, you need to upload your public key certificate using certificate parameter. Please upload as InputFile, sending a String will not work. + * 3. Ports currently supported for Webhooks: 443, 80, 88, 8443. + * + * If you're having any trouble setting up webhooks, please check out this amazing guide to webhooks. + * + * @param url HTTPS url to send updates to. Use an empty string to remove webhook integration + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setwebhook + */ + setWebhook(url, other, signal) { + return this.raw.setWebhook({ url, ...other }, signal); + } + /** + * Use this method to remove webhook integration if you decide to switch back to getUpdates. Returns True on success. + * + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#deletewebhook + */ + deleteWebhook(other, signal) { + return this.raw.deleteWebhook({ ...other }, signal); + } + /** + * Use this method to get current webhook status. Requires no parameters. On success, returns a WebhookInfo object. If the bot is using getUpdates, will return an object with the url field empty. + * + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getwebhookinfo + */ + getWebhookInfo(signal) { + return this.raw.getWebhookInfo(signal); + } + /** + * A simple method for testing your bot's authentication token. Requires no parameters. Returns basic information about the bot in form of a User object. + * + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getme + */ + getMe(signal) { + return this.raw.getMe(signal); + } + /** + * Use this method to log out from the cloud Bot API server before launching the bot locally. You must log out the bot before running it locally, otherwise there is no guarantee that the bot will receive updates. After a successful call, you can immediately log in on a local server, but will not be able to log in back to the cloud Bot API server for 10 minutes. Returns True on success. Requires no parameters. + * + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#logout + */ + logOut(signal) { + return this.raw.logOut(signal); + } + /** + * Use this method to close the bot instance before moving it from one local server to another. You need to delete the webhook before calling this method to ensure that the bot isn't launched again after server restart. The method will return error 429 in the first 10 minutes after the bot is launched. Returns True on success. Requires no parameters. + * + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#close + */ + close(signal) { + return this.raw.close(signal); + } + /** + * Use this method to send text messages. On success, the sent Message is returned. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param text Text of the message to be sent, 1-4096 characters after entities parsing + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendmessage + */ + sendMessage(chat_id, text, other, signal) { + return this.raw.sendMessage({ chat_id, text, ...other }, signal); + } + /** + * Use this method to stream a partial message to a user while the message is being generated; supported only for bots with forum topic mode enabled. Returns True on success. + * + * @param chat_id Unique identifier for the target private chat + * @param draft_id Unique identifier of the message draft; must be non-zero. Changes of drafts with the same identifier are animated + * @param text Text of the message to be sent, 1-4096 characters after entities parsing + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendmessagedraft + */ + sendMessageDraft(chat_id, draft_id, text, other, signal) { + return this.raw.sendMessageDraft({ chat_id, draft_id, text, ...other }, signal); + } + /** + * Use this method to forward messages of any kind. Service messages and messages with protected content can't be forwarded. On success, the sent Message is returned. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param from_chat_id Unique identifier for the chat where the original message was sent (or channel username in the format @channelusername) + * @param message_id Message identifier in the chat specified in from_chat_id + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#forwardmessage + */ + forwardMessage(chat_id, from_chat_id, message_id, other, signal) { + return this.raw.forwardMessage({ chat_id, from_chat_id, message_id, ...other }, signal); + } + /** + * Use this method to forward multiple messages of any kind. If some of the specified messages can't be found or forwarded, they are skipped. Service messages and messages with protected content can't be forwarded. Album grouping is kept for forwarded messages. On success, an array of MessageId of the sent messages is returned. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param from_chat_id Unique identifier for the chat where the original messages were sent (or channel username in the format @channelusername) + * @param message_ids A list of 1-100 identifiers of messages in the chat from_chat_id to forward. The identifiers must be specified in a strictly increasing order. + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#forwardmessages + */ + forwardMessages(chat_id, from_chat_id, message_ids, other, signal) { + return this.raw.forwardMessages({ + chat_id, + from_chat_id, + message_ids, + ...other, + }, signal); + } + /** + * Use this method to copy messages of any kind. Service messages, paid media messages, giveaway messages, giveaway winners messages, and invoice messages can't be copied. A quiz poll can be copied only if the value of the field correct_option_id is known to the bot. The method is analogous to the method forwardMessage, but the copied message doesn't have a link to the original message. Returns the MessageId of the sent message on success. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param from_chat_id Unique identifier for the chat where the original message was sent (or channel username in the format @channelusername) + * @param message_id Message identifier in the chat specified in from_chat_id + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#copymessage + */ + copyMessage(chat_id, from_chat_id, message_id, other, signal) { + return this.raw.copyMessage({ chat_id, from_chat_id, message_id, ...other }, signal); + } + /** + * Use this method to copy messages of any kind. If some of the specified messages can't be found or copied, they are skipped. Service messages, paid media messages, giveaway messages, giveaway winners messages, and invoice messages can't be copied. A quiz poll can be copied only if the value of the field correct_option_id is known to the bot. The method is analogous to the method forwardMessages, but the copied messages don't have a link to the original message. Album grouping is kept for copied messages. On success, an array of MessageId of the sent messages is returned. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param from_chat_id Unique identifier for the chat where the original messages were sent (or channel username in the format @channelusername) + * @param message_ids A list of 1-100 identifiers of messages in the chat from_chat_id to copy. The identifiers must be specified in a strictly increasing order. + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#copymessages + */ + copyMessages(chat_id, from_chat_id, message_ids, other, signal) { + return this.raw.copyMessages({ + chat_id, + from_chat_id, + message_ids, + ...other, + }, signal); + } + /** + * Use this method to send photos. On success, the sent Message is returned. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param photo Photo to send. Pass a file_id as String to send a photo that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a photo from the Internet, or upload a new photo using multipart/form-data. The photo must be at most 10 MB in size. The photo's width and height must not exceed 10000 in total. Width and height ratio must be at most 20. + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendphoto + */ + sendPhoto(chat_id, photo, other, signal) { + return this.raw.sendPhoto({ chat_id, photo, ...other }, signal); + } + /** + * Use this method to send audio files, if you want Telegram clients to display them in the music player. Your audio must be in the .MP3 or .M4A format. On success, the sent Message is returned. Bots can currently send audio files of up to 50 MB in size, this limit may be changed in the future. + * + * For sending voice messages, use the sendVoice method instead. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param audio Audio file to send. Pass a file_id as String to send an audio file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get an audio file from the Internet, or upload a new one using multipart/form-data. + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendaudio + */ + sendAudio(chat_id, audio, other, signal) { + return this.raw.sendAudio({ chat_id, audio, ...other }, signal); + } + /** + * Use this method to send general files. On success, the sent Message is returned. Bots can currently send files of any type of up to 50 MB in size, this limit may be changed in the future. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param document File to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#senddocument + */ + sendDocument(chat_id, document, other, signal) { + return this.raw.sendDocument({ chat_id, document, ...other }, signal); + } + /** + * Use this method to send video files, Telegram clients support mp4 videos (other formats may be sent as Document). On success, the sent Message is returned. Bots can currently send video files of up to 50 MB in size, this limit may be changed in the future. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param video Video to send. Pass a file_id as String to send a video that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a video from the Internet, or upload a new video using multipart/form-data. + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendvideo + */ + sendVideo(chat_id, video, other, signal) { + return this.raw.sendVideo({ chat_id, video, ...other }, signal); + } + /** + * Use this method to send animation files (GIF or H.264/MPEG-4 AVC video without sound). On success, the sent Message is returned. Bots can currently send animation files of up to 50 MB in size, this limit may be changed in the future. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param animation Animation to send. Pass a file_id as String to send an animation that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get an animation from the Internet, or upload a new animation using multipart/form-data. + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendanimation + */ + sendAnimation(chat_id, animation, other, signal) { + return this.raw.sendAnimation({ chat_id, animation, ...other }, signal); + } + /** + * Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message. For this to work, your audio must be in an .OGG file encoded with OPUS (other formats may be sent as Audio or Document). On success, the sent Message is returned. Bots can currently send voice messages of up to 50 MB in size, this limit may be changed in the future. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param voice Audio file to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendvoice + */ + sendVoice(chat_id, voice, other, signal) { + return this.raw.sendVoice({ chat_id, voice, ...other }, signal); + } + /** + * Use this method to send video messages. On success, the sent Message is returned. + * As of v.4.0, Telegram clients support rounded square mp4 videos of up to 1 minute long. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param video_note Video note to send. Pass a file_id as String to send a video note that exists on the Telegram servers (recommended) or upload a new video using multipart/form-data.. Sending video notes by a URL is currently unsupported + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendvideonote + */ + sendVideoNote(chat_id, video_note, other, signal) { + return this.raw.sendVideoNote({ chat_id, video_note, ...other }, signal); + } + /** + * Use this method to send a group of photos, videos, documents or audios as an album. Documents and audio files can be only grouped in an album with messages of the same type. On success, an array of Messages that were sent is returned. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param media An array describing messages to be sent, must include 2-10 items + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendmediagroup + */ + sendMediaGroup(chat_id, media, other, signal) { + return this.raw.sendMediaGroup({ chat_id, media, ...other }, signal); + } + /** + * Use this method to send point on the map. On success, the sent Message is returned. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param latitude Latitude of the location + * @param longitude Longitude of the location + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendlocation + */ + sendLocation(chat_id, latitude, longitude, other, signal) { + return this.raw.sendLocation({ chat_id, latitude, longitude, ...other }, signal); + } + /** + * Use this method to edit live location messages. A location can be edited until its live_period expires or editing is explicitly disabled by a call to stopMessageLiveLocation. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param message_id Identifier of the message to edit + * @param latitude Latitude of new location + * @param longitude Longitude of new location + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#editmessagelivelocation + */ + editMessageLiveLocation(chat_id, message_id, latitude, longitude, other, signal) { + return this.raw.editMessageLiveLocation({ chat_id, message_id, latitude, longitude, ...other }, signal); + } + /** + * Use this method to edit live location inline messages. A location can be edited until its live_period expires or editing is explicitly disabled by a call to stopMessageLiveLocation. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. + * + * @param inline_message_id Identifier of the inline message + * @param latitude Latitude of new location + * @param longitude Longitude of new location + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#editmessagelivelocation + */ + editMessageLiveLocationInline(inline_message_id, latitude, longitude, other, signal) { + return this.raw.editMessageLiveLocation({ inline_message_id, latitude, longitude, ...other }, signal); + } + /** + * Use this method to stop updating a live location message before live_period expires. On success, if the message is not an inline message, the edited Message is returned, otherwise True is returned. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param message_id Identifier of the message with live location to stop + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#stopmessagelivelocation + */ + stopMessageLiveLocation(chat_id, message_id, other, signal) { + return this.raw.stopMessageLiveLocation({ chat_id, message_id, ...other }, signal); + } + /** + * Use this method to stop updating a live location message before live_period expires. On success, if the message is not an inline message, the edited Message is returned, otherwise True is returned. + * + * @param inline_message_id Identifier of the inline message + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#stopmessagelivelocation + */ + stopMessageLiveLocationInline(inline_message_id, other, signal) { + return this.raw.stopMessageLiveLocation({ inline_message_id, ...other }, signal); + } + /** + * Use this method to send paid media. On success, the sent Message is returned. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param star_count The number of Telegram Stars that must be paid to buy access to the media + * @param media An array describing the media to be sent; up to 10 items + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendpaidmedia + */ + sendPaidMedia(chat_id, star_count, media, other, signal) { + return this.raw.sendPaidMedia({ chat_id, star_count, media, ...other }, signal); + } + /** + * Use this method to send information about a venue. On success, the sent Message is returned. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param latitude Latitude of the venue + * @param longitude Longitude of the venue + * @param title Name of the venue + * @param address Address of the venue + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendvenue + */ + sendVenue(chat_id, latitude, longitude, title, address, other, signal) { + return this.raw.sendVenue({ chat_id, latitude, longitude, title, address, ...other }, signal); + } + /** + * Use this method to send phone contacts. On success, the sent Message is returned. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param phone_number Contact's phone number + * @param first_name Contact's first name + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendcontact + */ + sendContact(chat_id, phone_number, first_name, other, signal) { + return this.raw.sendContact({ chat_id, phone_number, first_name, ...other }, signal); + } + /** + * Use this method to send a native poll. On success, the sent Message is returned. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param question Poll question, 1-300 characters + * @param options A list of answer options, 2-12 strings 1-100 characters each + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendpoll + */ + sendPoll(chat_id, question, options, other, signal) { + const opts = options.map((o) => typeof o === "string" ? { text: o } : o); + return this.raw.sendPoll({ chat_id, question, options: opts, ...other }, signal); + } + /** + * Use this method to send a checklist on behalf of a connected business account. On success, the sent Message is returned. + * + * @param business_connection_id Unique identifier of the business connection on behalf of which the message will be sent + * @param chat_id Unique identifier for the target chat + * @param checklist An object for the checklist to send + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendchecklist + */ + sendChecklist(business_connection_id, chat_id, checklist, other, signal) { + return this.raw.sendChecklist({ + business_connection_id, + chat_id, + checklist, + ...other, + }, signal); + } + /** + * Use this method to edit a checklist on behalf of a connected business account. On success, the edited Message is returned. + * + * @param business_connection_id Unique identifier of the business connection on behalf of which the message will be sent + * @param chat_id Unique identifier for the target chat + * @param message_id Unique identifier for the target message + * @param checklist An object for the new checklist + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#editmessagechecklist + */ + editMessageChecklist(business_connection_id, chat_id, message_id, checklist, other, signal) { + return this.raw.editMessageChecklist({ + business_connection_id, + chat_id, + message_id, + checklist, + ...other, + }, signal); + } + /** + * Use this method to send an animated emoji that will display a random value. On success, the sent Message is returned. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param emoji Emoji on which the dice throw animation is based. Currently, must be one of “🎲”, “🎯”, “🏀”, “⚽”, “🎳”, or “🎰”. Dice can have values 1-6 for “🎲”, “🎯” and “🎳”, values 1-5 for “🏀” and “⚽”, and values 1-64 for “🎰”. Defaults to “🎲” + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#senddice + */ + sendDice(chat_id, emoji, other, signal) { + return this.raw.sendDice({ chat_id, emoji, ...other }, signal); + } + /** + * Use this method to change the chosen reactions on a message. Service messages of some types can't be reacted to. Automatically forwarded messages from a channel to its discussion group have the same available reactions as messages in the channel. Bots can't use paid reactions. Returns True on success. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param message_id Identifier of the target message + * @param reaction A list of reaction types to set on the message. Currently, as non-premium users, bots can set up to one reaction per message. A custom emoji reaction can be used if it is either already present on the message or explicitly allowed by chat administrators. Paid reactions can't be used by bots. + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setmessagereaction + */ + setMessageReaction(chat_id, message_id, reaction, other, signal) { + return this.raw.setMessageReaction({ + chat_id, + message_id, + reaction, + ...other, + }, signal); + } + /** + * Use this method when you need to tell the user that something is happening on the bot's side. The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status). Returns True on success. + * + * Example: The ImageBot needs some time to process a request and upload the image. Instead of sending a text message along the lines of “Retrieving image, please wait…”, the bot may use sendChatAction with action = upload_photo. The user will see a “sending photo” status for the bot. + * + * We only recommend using this method when a response from the bot will take a noticeable amount of time to arrive. + * + * @param chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername). Channel chats and channel direct messages chats aren't supported. + * @param action Type of action to broadcast. Choose one, depending on what the user is about to receive: typing for text messages, upload_photo for photos, record_video or upload_video for videos, record_voice or upload_voice for voice notes, upload_document for general files, choose_sticker for stickers, find_location for location data, record_video_note or upload_video_note for video notes. + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendchataction + */ + sendChatAction(chat_id, action, other, signal) { + return this.raw.sendChatAction({ chat_id, action, ...other }, signal); + } + /** + * Use this method to get a list of profile pictures for a user. Returns a UserProfilePhotos object. + * + * @param user_id Unique identifier of the target user + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getuserprofilephotos + */ + getUserProfilePhotos(user_id, other, signal) { + return this.raw.getUserProfilePhotos({ user_id, ...other }, signal); + } + /** + * Use this method to get a list of profile audios for a user. Returns a UserProfileAudios object. + * + * @param user_id Unique identifier of the target user + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getuserprofileaudios + */ + getUserProfileAudios(user_id, other, signal) { + return this.raw.getUserProfileAudios({ user_id, ...other }, signal); + } + /** + * Changes the emoji status for a given user that previously allowed the bot to manage their emoji status via the Mini App method requestEmojiStatusAccess. Returns True on success. + * + * @param user_id Unique identifier of the target user + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setuseremojistatus + */ + setUserEmojiStatus(user_id, other, signal) { + return this.raw.setUserEmojiStatus({ user_id, ...other }, signal); + } + /** + * Use this method to get the list of boosts added to a chat by a user. Requires administrator rights in the chat. Returns a UserChatBoosts object. + * + * @param chat_id Unique identifier for the chat or username of the channel (in the format @channelusername) + * @param user_id Unique identifier of the target user + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getuserchatboosts + */ + getUserChatBoosts(chat_id, user_id, signal) { + return this.raw.getUserChatBoosts({ chat_id, user_id }, signal); + } + /** + * Returns the gifts owned and hosted by a user. Returns OwnedGifts on success. + * + * @param user_id Unique identifier of the user + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getusergifts + */ + getUserGifts(user_id, other, signal) { + return this.raw.getUserGifts({ user_id, ...other }, signal); + } + /** + * Returns the gifts owned by a chat. Returns OwnedGifts on success. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getchatgifts + */ + getChatGifts(chat_id, other, signal) { + return this.raw.getChatGifts({ chat_id, ...other }, signal); + } + /** + * Use this method to get information about the connection of the bot with a business account. Returns a BusinessConnection object on success. + * + * @param business_connection_id Unique identifier of the business connection + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getbusinessconnection + */ + getBusinessConnection(business_connection_id, signal) { + return this.raw.getBusinessConnection({ business_connection_id }, signal); + } + /** + * Use this method to get basic info about a file and prepare it for downloading. For the moment, bots can download files of up to 20MB in size. On success, a File object is returned. The file can then be downloaded via the link `https://api.telegram.org/file/bot/`, where `` is taken from the response. It is guaranteed that the link will be valid for at least 1 hour. When the link expires, a new one can be requested by calling getFile again. + * + * Note: This function may not preserve the original file name and MIME type. You should save the file's MIME type and name (if available) when the File object is received. + * + * @param file_id File identifier to get info about + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getfile + */ + getFile(file_id, signal) { + return this.raw.getFile({ file_id }, signal); + } + /** @deprecated Use `banChatMember` instead. */ + kickChatMember(...args) { + return this.banChatMember(...args); + } + /** + * Use this method to ban a user in a group, a supergroup or a channel. In the case of supergroups and channels, the user will not be able to return to the chat on their own using invite links, etc., unless unbanned first. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success. + * + * @param chat_id Unique identifier for the target group or username of the target supergroup or channel (in the format @channelusername) + * @param user_id Unique identifier of the target user + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#banchatmember + */ + banChatMember(chat_id, user_id, other, signal) { + return this.raw.banChatMember({ chat_id, user_id, ...other }, signal); + } + /** + * Use this method to unban a previously banned user in a supergroup or channel. The user will not return to the group or channel automatically, but will be able to join via link, etc. The bot must be an administrator for this to work. By default, this method guarantees that after the call the user is not a member of the chat, but will be able to join it. So if the user is a member of the chat they will also be removed from the chat. If you don't want this, use the parameter only_if_banned. Returns True on success. + * + * @param chat_id Unique identifier for the target group or username of the target supergroup or channel (in the format @username) + * @param user_id Unique identifier of the target user + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#unbanchatmember + */ + unbanChatMember(chat_id, user_id, other, signal) { + return this.raw.unbanChatMember({ chat_id, user_id, ...other }, signal); + } + /** + * Use this method to restrict a user in a supergroup. The bot must be an administrator in the supergroup for this to work and must have the appropriate administrator rights. Pass True for all permissions to lift restrictions from a user. Returns True on success. + * + * @param chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) + * @param user_id Unique identifier of the target user + * @param permissions An object for new user permissions + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#restrictchatmember + */ + restrictChatMember(chat_id, user_id, permissions, other, signal) { + return this.raw.restrictChatMember({ chat_id, user_id, permissions, ...other }, signal); + } + /** + * Use this method to promote or demote a user in a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Pass False for all boolean parameters to demote a user. Returns True on success. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param user_id Unique identifier of the target user + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#promotechatmember + */ + promoteChatMember(chat_id, user_id, other, signal) { + return this.raw.promoteChatMember({ chat_id, user_id, ...other }, signal); + } + /** + * Use this method to set a custom title for an administrator in a supergroup promoted by the bot. Returns True on success. + * + * @param chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) + * @param user_id Unique identifier of the target user + * @param custom_title New custom title for the administrator; 0-16 characters, emoji are not allowed + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setchatadministratorcustomtitle + */ + setChatAdministratorCustomTitle(chat_id, user_id, custom_title, signal) { + return this.raw.setChatAdministratorCustomTitle({ chat_id, user_id, custom_title }, signal); + } + /** + * Use this method to ban a channel chat in a supergroup or a channel. Until the chat is unbanned, the owner of the banned chat won't be able to send messages on behalf of any of their channels. The bot must be an administrator in the supergroup or channel for this to work and must have the appropriate administrator rights. Returns True on success. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param sender_chat_id Unique identifier of the target sender chat + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#banchatsenderchat + */ + banChatSenderChat(chat_id, sender_chat_id, signal) { + return this.raw.banChatSenderChat({ chat_id, sender_chat_id }, signal); + } + /** + * Use this method to unban a previously banned channel chat in a supergroup or channel. The bot must be an administrator for this to work and must have the appropriate administrator rights. Returns True on success. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param sender_chat_id Unique identifier of the target sender chat + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#unbanchatsenderchat + */ + unbanChatSenderChat(chat_id, sender_chat_id, signal) { + return this.raw.unbanChatSenderChat({ chat_id, sender_chat_id }, signal); + } + /** + * Use this method to set default chat permissions for all members. The bot must be an administrator in the group or a supergroup for this to work and must have the can_restrict_members administrator rights. Returns True on success. + * + * @param chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) + * @param permissions New default chat permissions + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setchatpermissions + */ + setChatPermissions(chat_id, permissions, other, signal) { + return this.raw.setChatPermissions({ chat_id, permissions, ...other }, signal); + } + /** + * Use this method to generate a new primary invite link for a chat; any previously generated primary link is revoked. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the new invite link as String on success. + * + * Note: Each administrator in a chat generates their own invite links. Bots can't use invite links generated by other administrators. If you want your bot to work with invite links, it will need to generate its own link using exportChatInviteLink or by calling the getChat method. If your bot needs to generate a new primary invite link replacing its previous one, use exportChatInviteLink again. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#exportchatinvitelink + */ + exportChatInviteLink(chat_id, signal) { + return this.raw.exportChatInviteLink({ chat_id }, signal); + } + /** + * Use this method to create an additional invite link for a chat. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. The link can be revoked using the method revokeChatInviteLink. Returns the new invite link as ChatInviteLink object. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#createchatinvitelink + */ + createChatInviteLink(chat_id, other, signal) { + return this.raw.createChatInviteLink({ chat_id, ...other }, signal); + } + /** + * Use this method to edit a non-primary invite link created by the bot. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the edited invite link as a ChatInviteLink object. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param invite_link The invite link to edit + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#editchatinvitelink + */ + editChatInviteLink(chat_id, invite_link, other, signal) { + return this.raw.editChatInviteLink({ chat_id, invite_link, ...other }, signal); + } + /** + * Use this method to create a subscription invite link for a channel chat. The bot must have the can_invite_users administrator rights. The link can be edited using the method editChatSubscriptionInviteLink or revoked using the method revokeChatInviteLink. Returns the new invite link as a ChatInviteLink object. + * + * @param chat_id Unique identifier for the target channel chat or username of the target channel (in the format @channelusername) + * @param subscription_period The number of seconds the subscription will be active for before the next payment. Currently, it must always be 2592000 (30 days). + * @param subscription_price The amount of Telegram Stars a user must pay initially and after each subsequent subscription period to be a member of the chat; 1-2500 + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#createchatsubscriptioninvitelink + */ + createChatSubscriptionInviteLink(chat_id, subscription_period, subscription_price, other, signal) { + return this.raw.createChatSubscriptionInviteLink({ chat_id, subscription_period, subscription_price, ...other }, signal); + } + /** + * Use this method to edit a subscription invite link created by the bot. The bot must have the can_invite_users administrator rights. Returns the edited invite link as a ChatInviteLink object. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param invite_link The invite link to edit + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#editchatsubscriptioninvitelink + */ + editChatSubscriptionInviteLink(chat_id, invite_link, other, signal) { + return this.raw.editChatSubscriptionInviteLink({ chat_id, invite_link, ...other }, signal); + } + /** + * Use this method to revoke an invite link created by the bot. If the primary link is revoked, a new link is automatically generated. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the revoked invite link as ChatInviteLink object. + * + * @param chat_id Unique identifier of the target chat or username of the target channel (in the format @channelusername) + * @param invite_link The invite link to revoke + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#revokechatinvitelink + */ + revokeChatInviteLink(chat_id, invite_link, signal) { + return this.raw.revokeChatInviteLink({ chat_id, invite_link }, signal); + } + /** + * Use this method to approve a chat join request. The bot must be an administrator in the chat for this to work and must have the can_invite_users administrator right. Returns True on success. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param user_id Unique identifier of the target user + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#approvechatjoinrequest + */ + approveChatJoinRequest(chat_id, user_id, signal) { + return this.raw.approveChatJoinRequest({ chat_id, user_id }, signal); + } + /** + * Use this method to decline a chat join request. The bot must be an administrator in the chat for this to work and must have the can_invite_users administrator right. Returns True on success. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param user_id Unique identifier of the target user + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#declinechatjoinrequest + */ + declineChatJoinRequest(chat_id, user_id, signal) { + return this.raw.declineChatJoinRequest({ chat_id, user_id }, signal); + } + /** + * Use this method to approve a suggested post in a direct messages chat. The bot must have the 'can_post_messages' administrator right in the corresponding channel chat. Returns True on success. + * + * @param chat_id Unique identifier for the target direct messages chat + * @param message_id Identifier of a suggested post message to approve + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#approvesuggestedpost + */ + approveSuggestedPost(chat_id, message_id, other, signal) { + return this.raw.approveSuggestedPost({ chat_id, message_id, ...other }, signal); + } + /** + * Use this method to decline a suggested post in a direct messages chat. The bot must have the 'can_manage_direct_messages' administrator right in the corresponding channel chat. Returns True on success. + * + * @param chat_id Unique identifier for the target direct messages chat + * @param message_id Identifier of a suggested post message to decline + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#declinesuggestedpost + */ + declineSuggestedPost(chat_id, message_id, other, signal) { + return this.raw.declineSuggestedPost({ chat_id, message_id, ...other }, signal); + } + /** + * Use this method to set a new profile photo for the chat. Photos can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param photo New chat photo, uploaded using multipart/form-data + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setchatphoto + */ + setChatPhoto(chat_id, photo, signal) { + return this.raw.setChatPhoto({ chat_id, photo }, signal); + } + /** + * Use this method to delete a chat photo. Photos can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#deletechatphoto + */ + deleteChatPhoto(chat_id, signal) { + return this.raw.deleteChatPhoto({ chat_id }, signal); + } + /** + * Use this method to change the title of a chat. Titles can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param title New chat title, 1-255 characters + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setchattitle + */ + setChatTitle(chat_id, title, signal) { + return this.raw.setChatTitle({ chat_id, title }, signal); + } + /** + * Use this method to change the description of a group, a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param description New chat description, 0-255 characters + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setchatdescription + */ + setChatDescription(chat_id, description, signal) { + return this.raw.setChatDescription({ chat_id, description }, signal); + } + /** + * Use this method to add a message to the list of pinned messages in a chat. In private chats and channel direct messages chats, all non-service messages can be pinned. Conversely, the bot must be an administrator with the 'can_pin_messages' right or the 'can_edit_messages' right to pin messages in groups and channels respectively. Returns True on success. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param message_id Identifier of a message to pin + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#pinchatmessage + */ + pinChatMessage(chat_id, message_id, other, signal) { + return this.raw.pinChatMessage({ chat_id, message_id, ...other }, signal); + } + /** + * Use this method to remove a message from the list of pinned messages in a chat. In private chats and channel direct messages chats, all messages can be unpinned. Conversely, the bot must be an administrator with the 'can_pin_messages' right or the 'can_edit_messages' right to unpin messages in groups and channels respectively. Returns True on success. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param message_id Identifier of a message to unpin. If not specified, the most recent pinned message (by sending date) will be unpinned. + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#unpinchatmessage + */ + unpinChatMessage(chat_id, message_id, other, signal) { + return this.raw.unpinChatMessage({ chat_id, message_id, ...other }, signal); + } + /** + * Use this method to clear the list of pinned messages in a chat. In private chats and channel direct messages chats, no additional rights are required to unpin all pinned messages. Conversely, the bot must be an administrator with the 'can_pin_messages' right or the 'can_edit_messages' right to unpin all pinned messages in groups and channels respectively. Returns True on success. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#unpinallchatmessages + */ + unpinAllChatMessages(chat_id, signal) { + return this.raw.unpinAllChatMessages({ chat_id }, signal); + } + /** + * Use this method for your bot to leave a group, supergroup or channel. Returns True on success. + * + * @param chat_id Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername). Channel direct messages chats aren't supported; leave the corresponding channel instead. + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#leavechat + */ + leaveChat(chat_id, signal) { + return this.raw.leaveChat({ chat_id }, signal); + } + /** + * Use this method to get up to date information about the chat (current name of the user for one-on-one conversations, current username of a user, group or channel, etc.). Returns a Chat object on success. + * + * @param chat_id Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername) + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getchat + */ + getChat(chat_id, signal) { + return this.raw.getChat({ chat_id }, signal); + } + /** + * Use this method to get a list of administrators in a chat, which aren't bots. Returns an Array of ChatMember objects. + * + * @param chat_id Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername) + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getchatadministrators + */ + getChatAdministrators(chat_id, signal) { + return this.raw.getChatAdministrators({ chat_id }, signal); + } + /** @deprecated Use `getChatMemberCount` instead. */ + getChatMembersCount(...args) { + return this.getChatMemberCount(...args); + } + /** + * Use this method to get the number of members in a chat. Returns Int on success. + * + * @param chat_id Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername) + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getchatmembercount + */ + getChatMemberCount(chat_id, signal) { + return this.raw.getChatMemberCount({ chat_id }, signal); + } + /** + * Use this method to get information about a member of a chat. The method is guaranteed to work only if the bot is an administrator in the chat. Returns a ChatMember object on success. + * + * @param chat_id Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername) + * @param user_id Unique identifier of the target user + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getchatmember + */ + getChatMember(chat_id, user_id, signal) { + return this.raw.getChatMember({ chat_id, user_id }, signal); + } + /** + * Use this method to set a new group sticker set for a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Use the field can_set_sticker_set ly returned in getChat requests to check if the bot can use this method. Returns True on success. + * + * @param chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) + * @param sticker_set_name Name of the sticker set to be set as the group sticker set + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setchatstickerset + */ + setChatStickerSet(chat_id, sticker_set_name, signal) { + return this.raw.setChatStickerSet({ chat_id, sticker_set_name }, signal); + } + /** + * Use this method to delete a group sticker set from a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Use the field can_set_sticker_set ly returned in getChat requests to check if the bot can use this method. Returns True on success. + * + * @param chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#deletechatstickerset + */ + deleteChatStickerSet(chat_id, signal) { + return this.raw.deleteChatStickerSet({ chat_id }, signal); + } + /** + * Use this method to get custom emoji stickers, which can be used as a forum topic icon by any user. Requires no parameters. Returns an Array of Sticker objects. + * + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getforumtopiciconstickers + */ + getForumTopicIconStickers(signal) { + return this.raw.getForumTopicIconStickers(signal); + } + /** + * Use this method to create a topic in a forum supergroup chat or a private chat with a user. In the case of a supergroup chat the bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator right. Returns information about the created topic as a ForumTopic object. + * + * @param chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) + * @param name Topic name, 1-128 characters + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#createforumtopic + */ + createForumTopic(chat_id, name, other, signal) { + return this.raw.createForumTopic({ chat_id, name, ...other }, signal); + } + /** + * Use this method to edit name and icon of a topic in a forum supergroup chat or a private chat with a user. In the case of a supergroup chat the bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights, unless it is the creator of the topic. Returns True on success. + * + * @param chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) + * @param message_thread_id Unique identifier for the target message thread of the forum topic + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#editforumtopic + */ + editForumTopic(chat_id, message_thread_id, other, signal) { + return this.raw.editForumTopic({ chat_id, message_thread_id, ...other }, signal); + } + /** + * Use this method to close an open topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights, unless it is the creator of the topic. Returns True on success. + * + * @param chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) + * @param message_thread_id Unique identifier for the target message thread of the forum topic + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#closeforumtopic + */ + closeForumTopic(chat_id, message_thread_id, signal) { + return this.raw.closeForumTopic({ chat_id, message_thread_id }, signal); + } + /** + * Use this method to reopen a closed topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights, unless it is the creator of the topic. Returns True on success. + * + * @param chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) + * @param message_thread_id Unique identifier for the target message thread of the forum topic + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#reopenforumtopic + */ + reopenForumTopic(chat_id, message_thread_id, signal) { + return this.raw.reopenForumTopic({ chat_id, message_thread_id }, signal); + } + /** + * Use this method to delete a forum topic along with all its messages in a forum supergroup chat or a private chat with a user. In the case of a supergroup chat the bot must be an administrator in the chat for this to work and must have the can_delete_messages administrator rights. Returns True on success. + * + * @param chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) + * @param message_thread_id Unique identifier for the target message thread of the forum topic + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#deleteforumtopic + */ + deleteForumTopic(chat_id, message_thread_id, signal) { + return this.raw.deleteForumTopic({ chat_id, message_thread_id }, signal); + } + /** + * Use this method to clear the list of pinned messages in a forum topic in a forum supergroup chat or a private chat with a user. In the case of a supergroup chat the bot must be an administrator in the chat for this to work and must have the can_pin_messages administrator right in the supergroup. Returns True on success. + * + * @param chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) + * @param message_thread_id Unique identifier for the target message thread of the forum topic + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#unpinallforumtopicmessages + */ + unpinAllForumTopicMessages(chat_id, message_thread_id, signal) { + return this.raw.unpinAllForumTopicMessages({ chat_id, message_thread_id }, signal); + } + /** + * Use this method to edit the name of the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. Returns True on success. + * + * @param chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) + * @param name New topic name, 1-128 characters + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#editgeneralforumtopic + */ + editGeneralForumTopic(chat_id, name, signal) { + return this.raw.editGeneralForumTopic({ chat_id, name }, signal); + } + /** + * Use this method to close an open 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. Returns True on success. + * + * @param chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#closegeneralforumtopic + */ + closeGeneralForumTopic(chat_id, signal) { + return this.raw.closeGeneralForumTopic({ chat_id }, signal); + } + /** + * Use this method to reopen a closed 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. The topic will be automatically unhidden if it was hidden. Returns True on success. * + * + * @param chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#reopengeneralforumtopic + */ + reopenGeneralForumTopic(chat_id, signal) { + return this.raw.reopenGeneralForumTopic({ chat_id }, signal); + } + /** + * Use this method to hide the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. The topic will be automatically closed if it was open. Returns True on success. + * + * @param chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#hidegeneralforumtopic + */ + hideGeneralForumTopic(chat_id, signal) { + return this.raw.hideGeneralForumTopic({ chat_id }, signal); + } + /** + * Use this method to unhide the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. Returns True on success. + * + * @param chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#unhidegeneralforumtopic + */ + unhideGeneralForumTopic(chat_id, signal) { + return this.raw.unhideGeneralForumTopic({ chat_id }, signal); + } + /** + * Use this method to clear the list of pinned messages in a General forum topic. The bot must be an administrator in the chat for this to work and must have the can_pin_messages administrator right in the supergroup. Returns True on success. + * + * @param chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#unpinallgeneralforumtopicmessages + */ + unpinAllGeneralForumTopicMessages(chat_id, signal) { + return this.raw.unpinAllGeneralForumTopicMessages({ chat_id }, signal); + } + /** + * Use this method to send answers to callback queries sent from inline keyboards. The answer will be displayed to the user as a notification at the top of the chat screen or as an alert. On success, True is returned. + * + * Alternatively, the user can be redirected to the specified Game URL. For this option to work, you must first create a game for your bot via @BotFather and accept the terms. Otherwise, you may use links like t.me/your_bot?start=XXXX that open your bot with a parameter. + * + * @param callback_query_id Unique identifier for the query to be answered + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#answercallbackquery + */ + answerCallbackQuery(callback_query_id, other, signal) { + return this.raw.answerCallbackQuery({ callback_query_id, ...other }, signal); + } + /** + * Use this method to change the bot's name. Returns True on success. + * + * @param name New bot name; 0-64 characters. Pass an empty string to remove the dedicated name for the given language. + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setmyname + */ + setMyName(name, other, signal) { + return this.raw.setMyName({ name, ...other }, signal); + } + /** + * Use this method to get the current bot name for the given user language. Returns BotName on success. + * + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getmyname + */ + getMyName(other, signal) { + return this.raw.getMyName(other !== null && other !== void 0 ? other : {}, signal); + } + /** + * Use this method to change the list of the bot's commands. See https://core.telegram.org/bots/features#commands for more details about bot commands. Returns True on success. + * + * @param commands A list of bot commands to be set as the list of the bot's commands. At most 100 commands can be specified. + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setmycommands + */ + setMyCommands(commands, other, signal) { + return this.raw.setMyCommands({ commands, ...other }, signal); + } + /** + * Use this method to delete the list of the bot's commands for the given scope and user language. After deletion, higher level commands will be shown to affected users. Returns True on success. + * + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#deletemycommands + */ + deleteMyCommands(other, signal) { + return this.raw.deleteMyCommands({ ...other }, signal); + } + /** + * Use this method to get the current list of the bot's commands for the given scope and user language. Returns an Array of BotCommand objects. If commands aren't set, an empty list is returned. + * + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getmycommands + */ + getMyCommands(other, signal) { + return this.raw.getMyCommands({ ...other }, signal); + } + /** + * Use this method to change the bot's description, which is shown in the chat with the bot if the chat is empty. Returns True on success. + * + * @param description New bot description; 0-512 characters. Pass an empty string to remove the dedicated description for the given language. + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setmydescription + */ + setMyDescription(description, other, signal) { + return this.raw.setMyDescription({ description, ...other }, signal); + } + /** + * Use this method to get the current bot description for the given user language. Returns BotDescription on success. + * + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getmydescription + */ + getMyDescription(other, signal) { + return this.raw.getMyDescription({ ...other }, signal); + } + /** + * Use this method to change the bot's short description, which is shown on the bot's profile page and is sent together with the link when users share the bot. Returns True on success. + * + * @param short_description New short description for the bot; 0-120 characters. Pass an empty string to remove the dedicated short description for the given language. + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setmyshortdescription + */ + setMyShortDescription(short_description, other, signal) { + return this.raw.setMyShortDescription({ short_description, ...other }, signal); + } + /** + * Use this method to get the current bot short description for the given user language. Returns BotShortDescription on success. + * + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getmyshortdescription + */ + getMyShortDescription(other, signal) { + return this.raw.getMyShortDescription({ ...other }, signal); + } + /** + * Changes the profile photo of the bot. Returns True on success. + * + * @param photo The new profile photo to set + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setmyprofilephoto + */ + setMyProfilePhoto(photo, signal) { + return this.raw.setMyProfilePhoto({ photo }, signal); + } + /** + * Removes the profile photo of the bot. Requires no parameters. Returns True on success. + * + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#removemyprofilephoto + */ + removeMyProfilePhoto(signal) { + return this.raw.removeMyProfilePhoto(signal); + } + /** + * Use this method to change the bot's menu button in a private chat, or the default menu button. Returns True on success. + * + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setchatmenubutton + */ + setChatMenuButton(other, signal) { + return this.raw.setChatMenuButton({ ...other }, signal); + } + /** + * Use this method to get the current value of the bot's menu button in a private chat, or the default menu button. Returns MenuButton on success. + * + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getchatmenubutton + */ + getChatMenuButton(other, signal) { + return this.raw.getChatMenuButton({ ...other }, signal); + } + /** + * Use this method to the change the default administrator rights requested by the bot when it's added as an administrator to groups or channels. These rights will be suggested to users, but they are are free to modify the list before adding the bot. Returns True on success. + * + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setmydefaultadministratorrights + */ + setMyDefaultAdministratorRights(other, signal) { + return this.raw.setMyDefaultAdministratorRights({ ...other }, signal); + } + /** + * Use this method to get the current default administrator rights of the bot. Returns ChatAdministratorRights on success. + * + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getmydefaultadministratorrights + */ + getMyDefaultAdministratorRights(other, signal) { + return this.raw.getMyDefaultAdministratorRights({ ...other }, signal); + } + /** + * A method to get the current Telegram Stars balance of the bot. Requires no parameters. On success, returns a StarAmount object. + * + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getmystarbalance + */ + getMyStarBalance(signal) { + return this.raw.getMyStarBalance(signal); + } + /** + * Use this method to edit text and game messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param message_id Identifier of the message to edit + * @param text New text of the message, 1-4096 characters after entities parsing + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#editmessagetext + */ + editMessageText(chat_id, message_id, text, other, signal) { + return this.raw.editMessageText({ chat_id, message_id, text, ...other }, signal); + } + /** + * Use this method to edit text and game inline messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent. + * + * @param inline_message_id Identifier of the inline message + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#editmessagetext + */ + editMessageTextInline(inline_message_id, text, other, signal) { + return this.raw.editMessageText({ inline_message_id, text, ...other }, signal); + } + /** + * Use this method to edit captions of messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param message_id Identifier of the message to edit + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#editmessagecaption + */ + editMessageCaption(chat_id, message_id, other, signal) { + return this.raw.editMessageCaption({ chat_id, message_id, ...other }, signal); + } + /** + * Use this method to edit captions of inline messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent. + * + * @param inline_message_id Identifier of the inline message + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#editmessagecaption + */ + editMessageCaptionInline(inline_message_id, other, signal) { + return this.raw.editMessageCaption({ inline_message_id, ...other }, signal); + } + /** + * Use this method to edit animation, audio, document, photo, or video messages, or to add media to text messages. If a message is part of a message album, then it can be edited only to an audio for audio albums, only to a document for document albums and to a photo or a video otherwise. When an inline message is edited, a new file can't be uploaded; use a previously uploaded file via its file_id or specify a URL. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param message_id Identifier of the message to edit + * @param media An object for a new media content of the message + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#editmessagemedia + */ + editMessageMedia(chat_id, message_id, media, other, signal) { + return this.raw.editMessageMedia({ chat_id, message_id, media, ...other }, signal); + } + /** + * Use this method to edit animation, audio, document, photo, or video inline messages, or to add media to text inline messages. If a message is part of a message album, then it can be edited only to an audio for audio albums, only to a document for document albums and to a photo or a video otherwise. When an inline message is edited, a new file can't be uploaded; use a previously uploaded file via its file_id or specify a URL. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent. + * + * @param inline_message_id Identifier of the inline message + * @param media An object for a new media content of the message + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#editmessagemedia + */ + editMessageMediaInline(inline_message_id, media, other, signal) { + return this.raw.editMessageMedia({ inline_message_id, media, ...other }, signal); + } + /** + * Use this method to edit only the reply markup of messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param message_id Identifier of the message to edit + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#editmessagereplymarkup + */ + editMessageReplyMarkup(chat_id, message_id, other, signal) { + return this.raw.editMessageReplyMarkup({ chat_id, message_id, ...other }, signal); + } + /** + * Use this method to edit only the reply markup of inline messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent. + * + * @param inline_message_id Identifier of the inline message + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#editmessagereplymarkup + */ + editMessageReplyMarkupInline(inline_message_id, other, signal) { + return this.raw.editMessageReplyMarkup({ inline_message_id, ...other }, signal); + } + /** + * Use this method to stop a poll which was sent by the bot. On success, the stopped Poll is returned. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param message_id Identifier of the original message with the poll + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#stoppoll + */ + stopPoll(chat_id, message_id, other, signal) { + return this.raw.stopPoll({ chat_id, message_id, ...other }, signal); + } + /** + * Use this method to delete a message, including service messages, with the following limitations: + * - A message can only be deleted if it was sent less than 48 hours ago. + * - A dice message in a private chat can only be deleted if it was sent more than 24 hours ago. + * - Bots can delete outgoing messages in private chats, groups, and supergroups. + * - Bots can delete incoming messages in private chats. + * - Bots granted can_post_messages permissions can delete outgoing messages in channels. + * - If the bot is an administrator of a group, it can delete any message there. + * - If the bot has can_delete_messages administrator right in a supergroup or a channel, it can delete any message there. + * - If the bot has can_manage_direct_messages administrator right in a channel, it can delete any message in the corresponding direct messages chat. + * Returns True on success. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param message_id Identifier of the message to delete + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#deletemessage + */ + deleteMessage(chat_id, message_id, signal) { + return this.raw.deleteMessage({ chat_id, message_id }, signal); + } + /** + * Use this method to delete multiple messages simultaneously. Returns True on success. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param message_ids A list of 1-100 identifiers of messages to delete. See deleteMessage for limitations on which messages can be deleted + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#deletemessages + */ + deleteMessages(chat_id, message_ids, signal) { + return this.raw.deleteMessages({ chat_id, message_ids }, signal); + } + /** + * Delete messages on behalf of a business account. Requires the can_delete_outgoing_messages business bot right to delete messages sent by the bot itself, or the can_delete_all_messages business bot right to delete any message. Returns True on success. + * + * @param business_connection_id Unique identifier of the business connection on behalf of which to delete the messages + * @param message_ids A list of 1-100 identifiers of messages to delete. All messages must be from the same chat. See deleteMessage for limitations on which messages can be deleted + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#deletebusinessmessages + */ + deleteBusinessMessages(business_connection_id, message_ids, signal) { + return this.raw.deleteBusinessMessages({ business_connection_id, message_ids }, signal); + } + /** + * Changes the first and last name of a managed business account. Requires the can_change_name business bot right. Returns True on success. + * + * @param business_connection_id Unique identifier of the business connection + * @param first_name The new value of the first name for the business account; 1-64 characters + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setbusinessaccountname + */ + setBusinessAccountName(business_connection_id, first_name, other, signal) { + return this.raw.setBusinessAccountName({ business_connection_id, first_name, ...other }, signal); + } + /** + * Changes the username of a managed business account. Requires the can_change_username business bot right. Returns True on success. + * + * @param business_connection_id Unique identifier of the business connection * + * @param username The new value of the username for the business account; 0-32 characters + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setbusinessaccountusername + */ + setBusinessAccountUsername(business_connection_id, username, signal) { + return this.raw.setBusinessAccountUsername({ business_connection_id, username }, signal); + } + /** + * Changes the bio of a managed business account. Requires the can_change_bio business bot right. Returns True on success. + * + * @param business_connection_id Unique identifier of the business connection + * @param bio The new value of the bio for the business account; 0-140 characters + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setbusinessaccountbio + */ + setBusinessAccountBio(business_connection_id, bio, signal) { + return this.raw.setBusinessAccountBio({ business_connection_id, bio }, signal); + } + /** + * Changes the profile photo of a managed business account. Requires the can_edit_profile_photo business bot right. Returns True on success. + * + * @param business_connection_id Unique identifier of the business connection + * @param photo The new profile photo to set + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setbusinessaccountprofilephoto + */ + setBusinessAccountProfilePhoto(business_connection_id, photo, other, signal) { + return this.raw.setBusinessAccountProfilePhoto({ business_connection_id, photo, ...other }, signal); + } + /** + * Removes the current profile photo of a managed business account. Requires the can_edit_profile_photo business bot right. Returns True on success. + * + * @param business_connection_id Unique identifier of the business connection + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#removebusinessaccountprofilephoto + */ + removeBusinessAccountProfilePhoto(business_connection_id, other, signal) { + return this.raw.removeBusinessAccountProfilePhoto({ business_connection_id, ...other }, signal); + } + /** + * Changes the privacy settings pertaining to incoming gifts in a managed business account. Requires the can_change_gift_settings business bot right. Returns True on success. + * + * @param business_connection_id Unique identifier of the business connection + * @param show_gift_button Pass True, if a button for sending a gift to the user or by the business account must always be shown in the input field + * @param accepted_gift_types Types of gifts accepted by the business account + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setbusinessaccountgiftsettings + */ + setBusinessAccountGiftSettings(business_connection_id, show_gift_button, accepted_gift_types, signal) { + return this.raw.setBusinessAccountGiftSettings({ business_connection_id, show_gift_button, accepted_gift_types }, signal); + } + /** + * Returns the amount of Telegram Stars owned by a managed business account. Requires the can_view_gifts_and_stars business bot right. Returns StarAmount on success. + * + * @param business_connection_id Unique identifier of the business connection + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getbusinessaccountstarbalance + */ + getBusinessAccountStarBalance(business_connection_id, signal) { + return this.raw.getBusinessAccountStarBalance({ business_connection_id }, signal); + } + /** + * Transfers Telegram Stars from the business account balance to the bot's balance. Requires the can_transfer_stars business bot right. Returns True on success. + * + * @param business_connection_id Unique identifier of the business connection + * @param star_count Number of Telegram Stars to transfer; 1-10000 + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#transferbusinessaccountstars + */ + transferBusinessAccountStars(business_connection_id, star_count, signal) { + return this.raw.transferBusinessAccountStars({ business_connection_id, star_count }, signal); + } + /** + * Returns the gifts received and owned by a managed business account. Requires the can_view_gifts_and_stars business bot right. Returns OwnedGifts on success. + * + * @param business_connection_id Unique identifier of the business connection + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getbusinessaccountgifts + */ + getBusinessAccountGifts(business_connection_id, other, signal) { + return this.raw.getBusinessAccountGifts({ business_connection_id, ...other }, signal); + } + /** + * Converts a given regular gift to Telegram Stars. Requires the can_convert_gifts_to_stars business bot right. Returns True on success. + * + * @param business_connection_id Unique identifier of the business connection + * @param owned_gift_id Unique identifier of the regular gift that should be converted to Telegram Stars + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#convertgifttostars + */ + convertGiftToStars(business_connection_id, owned_gift_id, signal) { + return this.raw.convertGiftToStars({ business_connection_id, owned_gift_id }, signal); + } + /** + * Upgrades a given regular gift to a unique gift. Requires the can_transfer_and_upgrade_gifts business bot right. Additionally requires the can_transfer_stars business bot right if the upgrade is paid. Returns True on success. + * + * @param business_connection_id Unique identifier of the business connection + * @param owned_gift_id Unique identifier of the regular gift that should be upgraded to a unique one + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#upgradegift + */ + upgradeGift(business_connection_id, owned_gift_id, other, signal) { + return this.raw.upgradeGift({ business_connection_id, owned_gift_id, ...other }, signal); + } + /** + * Transfers an owned unique gift to another user. Requires the can_transfer_and_upgrade_gifts business bot right. Requires can_transfer_stars business bot right if the transfer is paid. Returns True on success. + * + * @param business_connection_id Unique identifier of the business connection + * @param owned_gift_id Unique identifier of the regular gift that should be transferred + * @param new_owner_chat_id Unique identifier of the chat which will own the gift. The chat must be active in the last 24 hours. + * @param star_count The amount of Telegram Stars that will be paid for the transfer from the business account balance. If positive, then the can_transfer_stars business bot right is required. + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#transfergift + */ + transferGift(business_connection_id, owned_gift_id, new_owner_chat_id, star_count, signal) { + return this.raw.transferGift({ + business_connection_id, + owned_gift_id, + new_owner_chat_id, + star_count, + }, signal); + } + /** + * Posts a story on behalf of a managed business account. Requires the can_manage_stories business bot right. Returns Story on success. + * + * @param business_connection_id Unique identifier of the business connection + * @param content Content of the story + * @param active_period Period after which the story is moved to the archive, in seconds; must be one of 6 * 3600, 12 * 3600, 86400, or 2 * 86400 + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#poststory + */ + postStory(business_connection_id, content, active_period, other, signal) { + return this.raw.postStory({ business_connection_id, content, active_period, ...other }, signal); + } + /** + * Reposts a story on behalf of a business account from another business account. Both business accounts must be managed by the same bot, and the story on the source account must have been posted (or reposted) by the bot. Requires the can_manage_stories business bot right for both business accounts. Returns Story on success. + * + * @param business_connection_id Unique identifier of the business connection + * @param from_chat_id Unique identifier of the chat which posted the story that should be reposted + * @param from_story_id Unique identifier of the story that should be reposted + * @param active_period Period after which the story is moved to the archive, in seconds; must be one of 6 * 3600, 12 * 3600, 86400, or 2 * 86400 + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#repoststory + */ + repostStory(business_connection_id, from_chat_id, from_story_id, active_period, other, signal) { + return this.raw.repostStory({ + business_connection_id, + from_chat_id, + from_story_id, + active_period, + ...other, + }, signal); + } + /** + * Edits a story previously posted by the bot on behalf of a managed business account. Requires the can_manage_stories business bot right. Returns Story on success. + * + * @param business_connection_id Unique identifier of the business connection + * @param story_id Unique identifier of the story to edit + * @param content Content of the story + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#editstory + */ + editStory(business_connection_id, story_id, content, other, signal) { + return this.raw.editStory({ business_connection_id, story_id, content, ...other }, signal); + } + /** + * Deletes a story previously posted by the bot on behalf of a managed business account. Requires the can_manage_stories business bot right. Returns True on success. + * + * @param business_connection_id Unique identifier of the business connection + * @param story_id Unique identifier of the story to delete + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#deletestory + */ + deleteStory(business_connection_id, story_id, signal) { + return this.raw.deleteStory({ business_connection_id, story_id }, signal); + } + /** + * Use this method to send static .WEBP, animated .TGS, or video .WEBM stickers. On success, the sent Message is returned. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param sticker Sticker to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a .WEBP sticker from the Internet, or upload a new .WEBP, .TGS, or .WEBM sticker using multipart/form-data. Video and animated stickers can't be sent via an HTTP URL. + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendsticker + */ + sendSticker(chat_id, sticker, other, signal) { + return this.raw.sendSticker({ chat_id, sticker, ...other }, signal); + } + /** + * Use this method to get a sticker set. On success, a StickerSet object is returned. + * + * @param name Name of the sticker set + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getstickerset + */ + getStickerSet(name, signal) { + return this.raw.getStickerSet({ name }, signal); + } + /** + * Use this method to get information about custom emoji stickers by their identifiers. Returns an Array of Sticker objects. + * + * @param custom_emoji_ids A list of custom emoji identifiers + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getcustomemojistickers + */ + getCustomEmojiStickers(custom_emoji_ids, signal) { + return this.raw.getCustomEmojiStickers({ custom_emoji_ids }, signal); + } + /** + * Use this method to upload a file with a sticker for later use in the createNewStickerSet, addStickerToSet, or replaceStickerInSet methods (the file can be used multiple times). Returns the uploaded File on success. + * + * @param user_id User identifier of sticker file owner + * @param sticker_format Format of the sticker, must be one of “static”, “animated”, “video” + * @param sticker A file with the sticker in .WEBP, .PNG, .TGS, or .WEBM format. See https://core.telegram.org/stickers for technical requirements. + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#uploadstickerfile + */ + uploadStickerFile(user_id, sticker_format, sticker, signal) { + return this.raw.uploadStickerFile({ user_id, sticker_format, sticker }, signal); + } + /** + * Use this method to create a new sticker set owned by a user. The bot will be able to edit the sticker set thus created. Returns True on success. + * + * @param user_id User identifier of created sticker set owner + * @param name Short name of sticker set, to be used in t.me/addstickers/ URLs (e.g., animals). Can contain only English letters, digits and underscores. Must begin with a letter, can't contain consecutive underscores and must end in `_by_`. `` is case insensitive. 1-64 characters. + * @param title Sticker set title, 1-64 characters + * @param stickers A list of 1-50 initial stickers to be added to the sticker set + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#createnewstickerset + */ + createNewStickerSet(user_id, name, title, stickers, other, signal) { + return this.raw.createNewStickerSet({ user_id, name, title, stickers, ...other }, signal); + } + /** + * Use this method to add a new sticker to a set created by the bot. The format of the added sticker must match the format of the other stickers in the set. Emoji sticker sets can have up to 200 stickers. Animated and video sticker sets can have up to 50 stickers. Static sticker sets can have up to 120 stickers. Returns True on success. + * + * @param user_id User identifier of sticker set owner + * @param name Sticker set name + * @param sticker An object with information about the added sticker. If exactly the same sticker had already been added to the set, then the set isn't changed. + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#addstickertoset + */ + addStickerToSet(user_id, name, sticker, signal) { + return this.raw.addStickerToSet({ user_id, name, sticker }, signal); + } + /** + * Use this method to move a sticker in a set created by the bot to a specific position. Returns True on success. + * + * @param sticker File identifier of the sticker + * @param position New sticker position in the set, zero-based + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setstickerpositioninset + */ + setStickerPositionInSet(sticker, position, signal) { + return this.raw.setStickerPositionInSet({ sticker, position }, signal); + } + /** + * Use this method to delete a sticker from a set created by the bot. Returns True on success. + * + * @param sticker File identifier of the sticker + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#deletestickerfromset + */ + deleteStickerFromSet(sticker, signal) { + return this.raw.deleteStickerFromSet({ sticker }, signal); + } + /** + * Use this method to replace an existing sticker in a sticker set with a new one. The method is equivalent to calling deleteStickerFromSet, then addStickerToSet, then setStickerPositionInSet. Returns True on success. + * + * @param user_id User identifier of the sticker set owner + * @param name Sticker set name + * @param old_sticker File identifier of the replaced sticker + * @param sticker An object with information about the added sticker. If exactly the same sticker had already been added to the set, then the set remains unchanged.:x + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#replacestickerinset + */ + replaceStickerInSet(user_id, name, old_sticker, sticker, signal) { + return this.raw.replaceStickerInSet({ user_id, name, old_sticker, sticker }, signal); + } + /** + * Use this method to change the list of emoji assigned to a regular or custom emoji sticker. The sticker must belong to a sticker set created by the bot. Returns True on success. + * + * @param sticker File identifier of the sticker + * @param emoji_list A list of 1-20 emoji associated with the sticker + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setstickeremojilist + */ + setStickerEmojiList(sticker, emoji_list, signal) { + return this.raw.setStickerEmojiList({ sticker, emoji_list }, signal); + } + /** + * Use this method to change search keywords assigned to a regular or custom emoji sticker. The sticker must belong to a sticker set created by the bot. Returns True on success. + * + * @param sticker File identifier of the sticker + * @param keywords A list of 0-20 search keywords for the sticker with total length of up to 64 characters + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setstickerkeywords + */ + setStickerKeywords(sticker, keywords, signal) { + return this.raw.setStickerKeywords({ sticker, keywords }, signal); + } + /** + * Use this method to change the mask position of a mask sticker. The sticker must belong to a sticker set that was created by the bot. Returns True on success. + * + * @param sticker File identifier of the sticker + * @param mask_position An object with the position where the mask should be placed on faces. Omit the parameter to remove the mask position. + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setstickermaskposition + */ + setStickerMaskPosition(sticker, mask_position, signal) { + return this.raw.setStickerMaskPosition({ sticker, mask_position }, signal); + } + /** + * Use this method to set the title of a created sticker set. Returns True on success. + * + * @param name Sticker set name + * @param title Sticker set title, 1-64 characters + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setstickersettitle + */ + setStickerSetTitle(name, title, signal) { + return this.raw.setStickerSetTitle({ name, title }, signal); + } + /** + * Use this method to delete a sticker set that was created by the bot. Returns True on success. + * + * @param name Sticker set name + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#deletestickerset + */ + deleteStickerSet(name, signal) { + return this.raw.deleteStickerSet({ name }, signal); + } + /** + * Use this method to set the thumbnail of a regular or mask sticker set. The format of the thumbnail file must match the format of the stickers in the set. Returns True on success. + * + * @param name Sticker set name + * @param user_id User identifier of the sticker set owner + * @param thumbnail A .WEBP or .PNG image with the thumbnail, must be up to 128 kilobytes in size and have a width and height of exactly 100px, or a .TGS animation with a thumbnail up to 32 kilobytes in size (see https://core.telegram.org/stickers#animated-sticker-requirements for animated sticker technical requirements), or a WEBM video with the thumbnail up to 32 kilobytes in size; see https://core.telegram.org/stickers#video-sticker-requirements for video sticker technical requirements. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. More information on Sending Files ». Animated and video sticker set thumbnails can't be uploaded via HTTP URL. If omitted, then the thumbnail is dropped and the first sticker is used as the thumbnail. + * @param format Format of the thumbnail, must be one of “static” for a .WEBP or .PNG image, “animated” for a .TGS animation, or “video” for a WEBM video + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setstickersetthumbnail + */ + setStickerSetThumbnail(name, user_id, thumbnail, format, signal) { + return this.raw.setStickerSetThumbnail({ name, user_id, thumbnail, format }, signal); + } + /** + * Use this method to set the thumbnail of a custom emoji sticker set. Returns True on success. + * + * @param name Sticker set name + * @param custom_emoji_id Custom emoji identifier of a sticker from the sticker set; pass an empty string to drop the thumbnail and use the first sticker as the thumbnail. + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setcustomemojistickersetthumbnail + */ + setCustomEmojiStickerSetThumbnail(name, custom_emoji_id, signal) { + return this.raw.setCustomEmojiStickerSetThumbnail({ + name, + custom_emoji_id, + }, signal); + } + /** + * Returns the list of gifts that can be sent by the bot to users and channel chats. Requires no parameters. Returns a Gifts object. + * + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getavailablegifts + */ + getAvailableGifts(signal) { + return this.raw.getAvailableGifts(signal); + } + /** + * Sends a gift to the given user. The gift can't be converted to Telegram Stars by the receiver. Returns True on success. + * + * @param user_id Unique identifier of the target user who will receive the gift + * @param gift_id Identifier of the gift + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendgift + */ + sendGift(user_id, gift_id, other, signal) { + return this.raw.sendGift({ user_id, gift_id, ...other }, signal); + } + /** + * Gifts a Telegram Premium subscription to the given user. Returns True on success. + * + * @param user_id Unique identifier of the target user who will receive a Telegram Premium subscription + * @param month_count Number of months the Telegram Premium subscription will be active for the user; must be one of 3, 6, or 12 + * @param star_count Number of Telegram Stars to pay for the Telegram Premium subscription; must be 1000 for 3 months, 1500 for 6 months, and 2500 for 12 months + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#giftpremiumsubscription + */ + giftPremiumSubscription(user_id, month_count, star_count, other, signal) { + return this.raw.giftPremiumSubscription({ user_id, month_count, star_count, ...other }, signal); + } + /** + * Sends a gift to the given channel chat. The gift can't be converted to Telegram Stars by the receiver. Returns True on success. + * + * @param chat_id Unique identifier for the chat or username of the channel (in the format @channelusername) that will receive the gift + * @param gift_id Identifier of the gift + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendgift + */ + sendGiftToChannel(chat_id, gift_id, other, signal) { + return this.raw.sendGift({ chat_id, gift_id, ...other }, signal); + } + /** + * Use this method to send answers to an inline query. On success, True is returned. + * No more than 50 results per query are allowed. + * + * Example: An inline bot that sends YouTube videos can ask the user to connect the bot to their YouTube account to adapt search results accordingly. To do this, it displays a 'Connect your YouTube account' button above the results, or even before showing any. The user presses the button, switches to a private chat with the bot and, in doing so, passes a start parameter that instructs the bot to return an OAuth link. Once done, the bot can offer a switch_inline button so that the user can easily return to the chat where they wanted to use the bot's inline capabilities. + * + * @param inline_query_id Unique identifier for the answered query + * @param results An array of results for the inline query + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#answerinlinequery + */ + answerInlineQuery(inline_query_id, results, other, signal) { + return this.raw.answerInlineQuery({ inline_query_id, results, ...other }, signal); + } + /** + * Use this method to set the result of an interaction with a Web App and send a corresponding message on behalf of the user to the chat from which the query originated. On success, a SentWebAppMessage object is returned. + * + * @param web_app_query_id Unique identifier for the query to be answered + * @param result An object describing the message to be sent + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#answerwebappquery + */ + answerWebAppQuery(web_app_query_id, result, signal) { + return this.raw.answerWebAppQuery({ web_app_query_id, result }, signal); + } + /** + * Stores a message that can be sent by a user of a Mini App. Returns a PreparedInlineMessage object. + * + * @param user_id Unique identifier of the target user that can use the prepared message + * @param result An object describing the message to be sent + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#savepreparedinlinemessage + */ + savePreparedInlineMessage(user_id, result, other, signal) { + return this.raw.savePreparedInlineMessage({ user_id, result, ...other }, signal); + } + /** + * Use this method to send invoices. On success, the sent Message is returned. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param title Product name, 1-32 characters + * @param description Product description, 1-255 characters + * @param payload Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes. + * @param currency Three-letter ISO 4217 currency code, see more on currencies + * @param prices Price breakdown, a list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.) + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendinvoice + */ + sendInvoice(chat_id, title, description, payload, currency, prices, other, signal) { + return this.raw.sendInvoice({ + chat_id, + title, + description, + payload, + currency, + prices, + ...other, + }, signal); + } + /** + * Use this method to create a link for an invoice. Returns the created invoice link as String on success. + * + * @param title Product name, 1-32 characters + * @param description Product description, 1-255 characters + * @param payload Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes. + * @param provider_token Payment provider token, obtained via BotFather + * @param currency Three-letter ISO 4217 currency code, see more on currencies + * @param prices Price breakdown, a list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.) + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#createinvoicelink + */ + createInvoiceLink(title, description, payload, provider_token, currency, prices, other, signal) { + return this.raw.createInvoiceLink({ + title, + description, + payload, + provider_token, + currency, + prices, + ...other, + }, signal); + } + /** + * If you sent an invoice requesting a shipping address and the parameter is_flexible was specified, the Bot API will send an Update with a shipping_query field to the bot. Use this method to reply to shipping queries. On success, True is returned. + * + * @param shipping_query_id Unique identifier for the query to be answered + * @param ok Pass True if delivery to the specified address is possible and False if there are any problems (for example, if delivery to the specified address is not possible) + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#answershippingquery + */ + answerShippingQuery(shipping_query_id, ok, other, signal) { + return this.raw.answerShippingQuery({ shipping_query_id, ok, ...other }, signal); + } + /** + * Once the user has confirmed their payment and shipping details, the Bot API sends the final confirmation in the form of an Update with the field pre_checkout_query. Use this method to respond to such pre-checkout queries. On success, True is returned. Note: The Bot API must receive an answer within 10 seconds after the pre-checkout query was sent. + * + * @param pre_checkout_query_id Unique identifier for the query to be answered + * @param ok Specify True if everything is alright (goods are available, etc.) and the bot is ready to proceed with the order. Use False if there are any problems. + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#answerprecheckoutquery + */ + answerPreCheckoutQuery(pre_checkout_query_id, ok, other, signal) { + return this.raw.answerPreCheckoutQuery({ pre_checkout_query_id, ok, ...other }, signal); + } + /** + * Returns the bot's Telegram Star transactions in chronological order. On success, returns a StarTransactions object. + * + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getstartransactions + */ + getStarTransactions(other, signal) { + return this.raw.getStarTransactions({ ...other }, signal); + } + /** + * Refunds a successful payment in Telegram Stars. + * + * @param user_id Identifier of the user whose payment will be refunded + * @param telegram_payment_charge_id Telegram payment identifier + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#refundstarpayment + */ + refundStarPayment(user_id, telegram_payment_charge_id, signal) { + return this.raw.refundStarPayment({ user_id, telegram_payment_charge_id }, signal); + } + /** + * Allows the bot to cancel or re-enable extension of a subscription paid in Telegram Stars. Returns True on success. + * + * @param user_id Identifier of the user whose subscription will be edited + * @param telegram_payment_charge_id Telegram payment identifier for the subscription + * @param is_canceled Pass True to cancel extension of the user subscription; the subscription must be active up to the end of the current subscription period. Pass False to allow the user to re-enable a subscription that was previously canceled by the bot. + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#edituserstarsubscription + */ + editUserStarSubscription(user_id, telegram_payment_charge_id, is_canceled, signal) { + return this.raw.editUserStarSubscription({ user_id, telegram_payment_charge_id, is_canceled }, signal); + } + /** + * Verifies a user on behalf of the organization which is represented by the bot. Returns True on success. + * + * @param user_id Unique identifier of the target user + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#verifyuser + */ + verifyUser(user_id, other, signal) { + return this.raw.verifyUser({ user_id, ...other }, signal); + } + /** + * Verifies a chat on behalf of the organization which is represented by the bot. Returns True on success. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername). Channel direct messages chats can't be verified. + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#verifychat + */ + verifyChat(chat_id, other, signal) { + return this.raw.verifyChat({ chat_id, ...other }, signal); + } + /** + * Removes verification from a user who is currently verified on behalf of the organization represented by the bot. Returns True on success. + * + * @param user_id Unique identifier of the target user + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#removeuserverification + */ + removeUserVerification(user_id, signal) { + return this.raw.removeUserVerification({ user_id }, signal); + } + /** + * Removes verification from a chat that is currently verified on behalf of the organization represented by the bot. Returns True on success. + * + * @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername) + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#removechatverification + */ + removeChatVerification(chat_id, signal) { + return this.raw.removeChatVerification({ chat_id }, signal); + } + /** + * Marks incoming message as read on behalf of a business account. Requires the can_read_messages business bot right. Returns True on success. + * + * @param business_connection_id Unique identifier of the business connection on behalf of which to read the message + * @param chat_id Unique identifier of the chat in which the message was received. The chat must have been active in the last 24 hours. + * @param message_id Unique identifier of the message to mark as read + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#readbusinessmessage + */ + readBusinessMessage(business_connection_id, chat_id, message_id, signal) { + return this.raw.readBusinessMessage({ business_connection_id, chat_id, message_id }, signal); + } + /** + * Informs a user that some of the Telegram Passport elements they provided contains errors. The user will not be able to re-submit their Passport to you until the errors are fixed (the contents of the field for which you returned the error must change). Returns True on success. + * + * Use this if the data submitted by the user doesn't satisfy the standards your service requires for any reason. For example, if a birthday date seems invalid, a submitted document is blurry, a scan shows evidence of tampering, etc. Supply some details in the error message to make sure the user knows how to correct the issues. + * + * @param user_id User identifier + * @param errors An array describing the errors + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setpassportdataerrors + */ + setPassportDataErrors(user_id, errors, signal) { + return this.raw.setPassportDataErrors({ user_id, errors }, signal); + } + /** + * Use this method to send a game. On success, the sent Message is returned. + * + * @param chat_id Unique identifier for the target chat. Games can't be sent to channel direct messages chats and channel chats. + * @param game_short_name Short name of the game, serves as the unique identifier for the game. Set up your games via BotFather. + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#sendgame + */ + sendGame(chat_id, game_short_name, other, signal) { + return this.raw.sendGame({ chat_id, game_short_name, ...other }, signal); + } + /** + * Use this method to set the score of the specified user in a game message. On success, if the message is not an inline message, the Message is returned, otherwise True is returned. Returns an error, if the new score is not greater than the user's current score in the chat and force is False. + * + * @param chat_id Unique identifier for the target chat + * @param message_id Identifier of the sent message + * @param user_id User identifier + * @param score New score, must be non-negative + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setgamescore + */ + setGameScore(chat_id, message_id, user_id, score, other, signal) { + return this.raw.setGameScore({ chat_id, message_id, user_id, score, ...other }, signal); + } + /** + * Use this method to set the score of the specified user in a game message. On success, if the message is not an inline message, the Message is returned, otherwise True is returned. Returns an error, if the new score is not greater than the user's current score in the chat and force is False. + * + * @param inline_message_id Identifier of the inline message + * @param user_id User identifier + * @param score New score, must be non-negative + * @param other Optional remaining parameters, confer the official reference below + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#setgamescore + */ + setGameScoreInline(inline_message_id, user_id, score, other, signal) { + return this.raw.setGameScore({ inline_message_id, user_id, score, ...other }, signal); + } + /** + * Use this method to get data for high score tables. Will return the score of the specified user and several of their neighbors in a game. Returns an Array of GameHighScore objects. + * + * This method will currently return scores for the target user, plus two of their closest neighbors on each side. Will also return the top three users if the user and his neighbors are not among them. Please note that this behavior is subject to change. + * + * @param chat_id Unique identifier for the target chat + * @param message_id Identifier of the sent message + * @param user_id Target user id + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getgamehighscores + */ + getGameHighScores(chat_id, message_id, user_id, signal) { + return this.raw.getGameHighScores({ chat_id, message_id, user_id }, signal); + } + /** + * Use this method to get data for high score tables. Will return the score of the specified user and several of their neighbors in an inline game. On success, returns an Array of GameHighScore objects. + * + * This method will currently return scores for the target user, plus two of their closest neighbors on each side. Will also return the top three users if the user and his neighbors are not among them. Please note that this behavior is subject to change. + * + * @param inline_message_id Identifier of the inline message + * @param user_id Target user id + * @param signal Optional `AbortSignal` to cancel the request + * + * **Official reference:** https://core.telegram.org/bots/api#getgamehighscores + */ + getGameHighScoresInline(inline_message_id, user_id, signal) { + return this.raw.getGameHighScores({ inline_message_id, user_id }, signal); + } +} +exports.Api = Api; diff --git a/sandbox/tgbot/node_modules/grammy/out/core/client.d.ts b/sandbox/tgbot/node_modules/grammy/out/core/client.d.ts new file mode 100644 index 0000000..00100b7 --- /dev/null +++ b/sandbox/tgbot/node_modules/grammy/out/core/client.d.ts @@ -0,0 +1,180 @@ +import { type ApiMethods as Telegram, type ApiResponse, type Opts } from "../types.js"; +export type Methods = string & keyof R; +/** + * Represents the raw Telegram Bot API with all methods specified 1:1 as + * documented on the website (https://core.telegram.org/bots/api). + * + * Every method takes an optional `AbortSignal` object that allows to cancel the + * API call if desired. + */ +export type RawApi = { + [M in keyof Telegram]: Parameters[0] extends undefined ? (signal?: AbortSignal) => Promise> : (args: Opts, signal?: AbortSignal) => Promise>; +}; +export type Payload, R extends RawApi> = M extends unknown ? R[M] extends (signal?: AbortSignal) => unknown ? {} : R[M] extends (args: any, signal?: AbortSignal) => unknown ? Parameters[0] : never : never; +/** + * Small utility interface that abstracts from webhook reply calls of different + * web frameworks. + */ +export interface WebhookReplyEnvelope { + send?: (payload: string) => void | Promise; +} +/** + * Type of a function that can perform an API call. Used for Transformers. + */ +export type ApiCallFn = >(method: M, payload: Payload, signal?: AbortSignal) => Promise>>; +type ApiCallResult, R extends RawApi> = R[M] extends (...args: unknown[]) => unknown ? Awaited> : never; +/** + * API call transformers are functions that can access and modify the method and + * payload of an API call on the fly. This can be useful if you want to + * implement rate limiting or other things against the Telegram Bot API. + * + * Confer the grammY + * [documentation](https://grammy.dev/advanced/transformers) to read more + * about how to use transformers. + */ +export type Transformer = >(prev: ApiCallFn, method: M, payload: Payload, signal?: AbortSignal) => Promise>>; +export type TransformerConsumer = TransformableApi["use"]; +/** + * A transformable API enhances the `RawApi` type by transformers. + */ +export interface TransformableApi { + /** + * Access to the raw API that the transformers will be installed on. + */ + raw: R; + /** + * Can be used to register any number of transformers on the API. + */ + use: (...transformers: Transformer[]) => this; + /** + * Returns a readonly list or the currently installed transformers. The list + * is sorted by time of installation where index 0 represents the + * transformer that was installed first. + */ + installedTransformers: Transformer[]; +} +/** + * Options to pass to the API client that eventually connects to the Telegram + * Bot API server and makes the HTTP requests. + */ +export interface ApiClientOptions { + /** + * Root URL of the Telegram Bot API server. Default: + * https://api.telegram.org + */ + apiRoot?: string; + /** + * Specifies whether to use the [test + * environment](https://core.telegram.org/bots/webapps#using-bots-in-the-test-environment). + * Can be either `"prod"` (default) or `"test"`. + * + * The testing infrastructure is separate from the regular production + * infrastructure. No chats, accounts, or other data is shared between them. + * If you set this option to `"test"`, you will need to make your Telegram + * client connect to the testing data centers of Telegram, register your + * phone number again, open a new chat with @BotFather, and create a + * separate bot. + */ + environment?: "prod" | "test"; + /** + * URL builder function for API calls. Can be used to modify which API + * server should be called. + * + * @param root The URL that was passed in `apiRoot`, or its default value + * @param token The bot's token that was passed when creating the bot + * @param method The API method to be called, e.g. `getMe` + * @param env The value that was passed in `environment`, or its default value + * @returns The URL that will be fetched during the API call + */ + buildUrl?: (root: string, token: string, method: string, env: "prod" | "test") => string | URL; + /** + * Maximum number of seconds that a request to the Bot API server may take. + * If a request has not completed before this time has elapsed, grammY + * aborts the request and errors. Without such a timeout, networking issues + * may cause your bot to leave open a connection indefinitely, which may + * effectively make your bot freeze. + * + * You probably do not have to care about this option. In rare cases, you + * may want to adjust it if you are transferring large files via slow + * connections to your own Bot API server. + * + * The default number of seconds is `500`, which corresponds to 8 minutes + * and 20 seconds. Note that this is also the value that is hard-coded in + * the official Bot API server, so you cannot perform any successful + * requests that exceed this time frame (even if you would allow it in + * grammY). Setting this option to higher than the default only makes sense + * with a custom Bot API server. + */ + timeoutSeconds?: number; + /** + * If the bot is running on webhooks, as soon as the bot receives an update + * from Telegram, it is possible to make up to one API call in the response + * to the webhook request. As a benefit, this saves your bot from making up + * to one HTTP request per update. However, there are a number of drawbacks + * to using this: + * 1) You will not be able to handle potential errors of the respective API + * call. This includes rate limiting errors, so sent messages can be + * swallowed by the Bot API server and there is no way to detect if a + * message was actually sent or not. + * 2) More importantly, you also won't have access to the response object, + * so e.g. calling `sendMessage` will not give you access to the message + * you sent. + * 3) Furthermore, it is not possible to cancel the request. The + * `AbortSignal` will be disregarded. + * 4) Note also that the types in grammY do not reflect the consequences of + * a performed webhook callback! For instance, they indicate that you + * always receive a response object, so it is your own responsibility to + * make sure you're not screwing up while using this minor performance + * optimization. + * + * With this warning out of the way, here is what you can do with the + * `canUseWebhookReply` option: it can be used to pass a function that + * determines whether to use webhook reply for the given method. It will + * only be invoked if the payload can be sent as JSON. It will not be + * invoked again for a given update after it returned `true`, indicating + * that the API call should be performed as a webhook send. In other words, + * subsequent API calls (during the same update) will always perform their + * own HTTP requests. + * + * @param method The method to call + */ + canUseWebhookReply?: (method: string) => boolean; + /** + * Base configuration for `fetch` calls. Specify any additional parameters + * to use when fetching a method of the Telegram Bot API. Default: `{ + * compress: true }` (Node), `{}` (Deno) + */ + baseFetchConfig?: Omit[1]>, "method" | "headers" | "body">; + /** + * `fetch` function to use for making HTTP requests. Default: `node-fetch` in Node.js, `fetch` in Deno. + */ + fetch?: typeof fetch; + /** + * When the network connection is unreliable and some API requests fail + * because of that, grammY will throw errors that tell you exactly which + * requests failed. However, the error messages do not disclose the fetched + * URL as it contains your bot's token. Logging it may lead to token leaks. + * + * If you are sure that no logs are ever posted in Telegram chats, GitHub + * issues, or otherwise shared, you can set this option to `true` in order + * to obtain more detailed logs that may help you debug your bot. The + * default value is `false`, meaning that the bot token is not logged. + */ + sensitiveLogs?: boolean; +} +/** + * Creates a new transformable API, i.e. an object that lets you perform raw API + * calls to the Telegram Bot API server but pass the calls through a stack of + * transformers before. This will create a new API client instance under the + * hood that will be used to connect to the Telegram servers. You therefore need + * to pass the bot token. In addition, you may pass API client options as well + * as a webhook reply envelope that allows the client to perform up to one HTTP + * request in response to a webhook call if this is desired. + * + * @param token The bot's token + * @param options A number of options to pass to the created API client + * @param webhookReplyEnvelope The webhook reply envelope that will be used + */ +export declare function createRawApi(token: string, options?: ApiClientOptions, webhookReplyEnvelope?: WebhookReplyEnvelope): TransformableApi; +import { AbortSignal, fetch } from "./../shim.node.js"; +export {}; diff --git a/sandbox/tgbot/node_modules/grammy/out/core/client.js b/sandbox/tgbot/node_modules/grammy/out/core/client.js new file mode 100644 index 0000000..c211838 --- /dev/null +++ b/sandbox/tgbot/node_modules/grammy/out/core/client.js @@ -0,0 +1,228 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.createRawApi = createRawApi; +const platform_node_js_1 = require("../platform.node.js"); +const error_js_1 = require("./error.js"); +const payload_js_1 = require("./payload.js"); +const debug = (0, platform_node_js_1.debug)("grammy:core"); +// Transformer base functions +function concatTransformer(prev, trans) { + return (method, payload, signal) => trans(prev, method, payload, signal); +} +class ApiClient { + constructor(token, options = {}, webhookReplyEnvelope = {}) { + var _a, _b, _c, _d, _e, _f; + this.token = token; + this.webhookReplyEnvelope = webhookReplyEnvelope; + this.hasUsedWebhookReply = false; + this.installedTransformers = []; + this.call = async (method, p, signal) => { + const payload = p !== null && p !== void 0 ? p : {}; + debug(`Calling ${method}`); + if (signal !== undefined) + validateSignal(method, payload, signal); + // General config + const opts = this.options; + const formDataRequired = (0, payload_js_1.requiresFormDataUpload)(payload); + // Short-circuit on webhook reply + if (this.webhookReplyEnvelope.send !== undefined && + !this.hasUsedWebhookReply && + !formDataRequired && + opts.canUseWebhookReply(method)) { + this.hasUsedWebhookReply = true; + const config = (0, payload_js_1.createJsonPayload)({ ...payload, method }); + await this.webhookReplyEnvelope.send(config.body); + return { ok: true, result: true }; + } + // Handle timeouts and errors in the underlying form-data stream + const controller = createAbortControllerFromSignal(signal); + const timeout = createTimeout(controller, opts.timeoutSeconds, method); + const streamErr = createStreamError(controller); + // Build request URL and config + const url = opts.buildUrl(opts.apiRoot, this.token, method, opts.environment); + const config = formDataRequired + ? (0, payload_js_1.createFormDataPayload)(payload, (err) => streamErr.catch(err)) + : (0, payload_js_1.createJsonPayload)(payload); + const sig = controller.signal; + const options = { ...opts.baseFetchConfig, signal: sig, ...config }; + // Perform fetch call, and handle networking errors + const successPromise = this.fetch(url instanceof URL ? url.href : url, options).catch((0, error_js_1.toHttpError)(method, opts.sensitiveLogs)); + // Those are the three possible outcomes of the fetch call: + const operations = [successPromise, streamErr.promise, timeout.promise]; + // Wait for result + try { + const res = await Promise.race(operations); + return await res.json(); + } + finally { + if (timeout.handle !== undefined) + clearTimeout(timeout.handle); + } + }; + const apiRoot = (_a = options.apiRoot) !== null && _a !== void 0 ? _a : "https://api.telegram.org"; + const environment = (_b = options.environment) !== null && _b !== void 0 ? _b : "prod"; + // In an ideal world, `fetch` is independent of the context being called, + // but in a Cloudflare worker, any context other than global throws an error. + // That is why we need to call custom fetch or fetch without context. + const { fetch: customFetch } = options; + const fetchFn = customFetch !== null && customFetch !== void 0 ? customFetch : shim_node_js_1.fetch; + this.options = { + apiRoot, + environment, + buildUrl: (_c = options.buildUrl) !== null && _c !== void 0 ? _c : defaultBuildUrl, + timeoutSeconds: (_d = options.timeoutSeconds) !== null && _d !== void 0 ? _d : 500, + baseFetchConfig: { + ...(0, platform_node_js_1.baseFetchConfig)(apiRoot), + ...options.baseFetchConfig, + }, + canUseWebhookReply: (_e = options.canUseWebhookReply) !== null && _e !== void 0 ? _e : (() => false), + sensitiveLogs: (_f = options.sensitiveLogs) !== null && _f !== void 0 ? _f : false, + fetch: ((...args) => fetchFn(...args)), + }; + this.fetch = this.options.fetch; + if (this.options.apiRoot.endsWith("/")) { + throw new Error(`Remove the trailing '/' from the 'apiRoot' option (use '${this.options.apiRoot.substring(0, this.options.apiRoot.length - 1)}' instead of '${this.options.apiRoot}')`); + } + } + use(...transformers) { + this.call = transformers.reduce(concatTransformer, this.call); + this.installedTransformers.push(...transformers); + return this; + } + async callApi(method, payload, signal) { + const data = await this.call(method, payload, signal); + if (data.ok) + return data.result; + else + throw (0, error_js_1.toGrammyError)(data, method, payload); + } +} +/** + * Creates a new transformable API, i.e. an object that lets you perform raw API + * calls to the Telegram Bot API server but pass the calls through a stack of + * transformers before. This will create a new API client instance under the + * hood that will be used to connect to the Telegram servers. You therefore need + * to pass the bot token. In addition, you may pass API client options as well + * as a webhook reply envelope that allows the client to perform up to one HTTP + * request in response to a webhook call if this is desired. + * + * @param token The bot's token + * @param options A number of options to pass to the created API client + * @param webhookReplyEnvelope The webhook reply envelope that will be used + */ +function createRawApi(token, options, webhookReplyEnvelope) { + const client = new ApiClient(token, options, webhookReplyEnvelope); + const proxyHandler = { + get(_, m) { + return m === "toJSON" + ? "__internal" + // Methods with zero parameters are called without any payload, + // so we have to manually inject an empty payload. + : m === "getMe" || + m === "getWebhookInfo" || + m === "getForumTopicIconStickers" || + m === "getAvailableGifts" || + m === "logOut" || + m === "close" || + m === "getMyStarBalance" || + m === "removeMyProfilePhoto" + ? client.callApi.bind(client, m, {}) + : client.callApi.bind(client, m); + }, + ...proxyMethods, + }; + const raw = new Proxy({}, proxyHandler); + const installedTransformers = client.installedTransformers; + const api = { + raw, + installedTransformers, + use: (...t) => { + client.use(...t); + return api; + }, + }; + return api; +} +const defaultBuildUrl = (root, token, method, env) => { + const prefix = env === "test" ? "test/" : ""; + return `${root}/bot${token}/${prefix}${method}`; +}; +const proxyMethods = { + set() { + return false; + }, + defineProperty() { + return false; + }, + deleteProperty() { + return false; + }, + ownKeys() { + return []; + }, +}; +/** Creates a timeout error which aborts a given controller */ +function createTimeout(controller, seconds, method) { + let handle = undefined; + const promise = new Promise((_, reject) => { + handle = setTimeout(() => { + const msg = `Request to '${method}' timed out after ${seconds} seconds`; + reject(new Error(msg)); + controller.abort(); + }, 1000 * seconds); + }); + return { promise, handle }; +} +/** Creates a stream error which abort a given controller */ +function createStreamError(abortController) { + let onError = (err) => { + // Re-throw by default, but will be overwritten immediately + throw err; + }; + const promise = new Promise((_, reject) => { + onError = (err) => { + reject(err); + abortController.abort(); + }; + }); + return { promise, catch: onError }; +} +function createAbortControllerFromSignal(signal) { + const abortController = new shim_node_js_1.AbortController(); + if (signal === undefined) + return abortController; + const sig = signal; + function abort() { + abortController.abort(); + sig.removeEventListener("abort", abort); + } + if (sig.aborted) + abort(); + else + sig.addEventListener("abort", abort); + return { abort, signal: abortController.signal }; +} +function validateSignal(method, payload, signal) { + // We use a very simple heuristic to check for AbortSignal instances + // in order to avoid doing a runtime-specific version of `instanceof`. + if (typeof (signal === null || signal === void 0 ? void 0 : signal.addEventListener) === "function") { + return; + } + let payload0 = JSON.stringify(payload); + if (payload0.length > 20) { + payload0 = payload0.substring(0, 16) + " ..."; + } + let payload1 = JSON.stringify(signal); + if (payload1.length > 20) { + payload1 = payload1.substring(0, 16) + " ..."; + } + throw new Error(`Incorrect abort signal instance found! \ +You passed two payloads to '${method}' but you should merge \ +the second one containing '${payload1}' into the first one \ +containing '${payload0}'! If you are using context shortcuts, \ +you may want to use a method on 'ctx.api' instead. + +If you want to prevent such mistakes in the future, \ +consider using TypeScript. https://www.typescriptlang.org/`); +} +const shim_node_js_1 = require("./../shim.node.js"); diff --git a/sandbox/tgbot/node_modules/grammy/out/core/error.d.ts b/sandbox/tgbot/node_modules/grammy/out/core/error.d.ts new file mode 100644 index 0000000..f6ab9b3 --- /dev/null +++ b/sandbox/tgbot/node_modules/grammy/out/core/error.d.ts @@ -0,0 +1,53 @@ +import { type ApiError, type ResponseParameters } from "../types.js"; +/** + * This class represents errors that are thrown by grammY because the Telegram + * Bot API responded with an error. + * + * Instances of this class hold the information that the Telegram backend + * returned. + * + * If this error is thrown, grammY could successfully communicate with the + * Telegram Bot API servers, however, an error code was returned for the + * respective method call. + */ +export declare class GrammyError extends Error implements ApiError { + /** The called method name which caused this error to be thrown. */ + readonly method: string; + /** The payload that was passed when calling the method. */ + readonly payload: Record; + /** Flag that this request was unsuccessful. Always `false`. */ + readonly ok: false; + /** An integer holding Telegram's error code. Subject to change. */ + readonly error_code: number; + /** A human-readable description of the error. */ + readonly description: string; + /** Further parameters that may help to automatically handle the error. */ + readonly parameters: ResponseParameters; + constructor(message: string, err: ApiError, + /** The called method name which caused this error to be thrown. */ + method: string, + /** The payload that was passed when calling the method. */ + payload: Record); +} +export declare function toGrammyError(err: ApiError, method: string, payload: Record): GrammyError; +/** + * This class represents errors that are thrown by grammY because an HTTP call + * to the Telegram Bot API failed. + * + * Instances of this class hold the error object that was created because the + * fetch call failed. It can be inspected to determine why exactly the network + * request failed. + * + * If an [API transformer + * function](https://grammy.dev/advanced/transformers) throws an error, + * grammY will regard this as if the network request failed. The contained error + * will then be the error that was thrown by the transformer function. + */ +export declare class HttpError extends Error { + /** The thrown error object. */ + readonly error: unknown; + constructor(message: string, + /** The thrown error object. */ + error: unknown); +} +export declare function toHttpError(method: string, sensitiveLogs: boolean): (err: unknown) => never; diff --git a/sandbox/tgbot/node_modules/grammy/out/core/error.js b/sandbox/tgbot/node_modules/grammy/out/core/error.js new file mode 100644 index 0000000..2c526d6 --- /dev/null +++ b/sandbox/tgbot/node_modules/grammy/out/core/error.js @@ -0,0 +1,87 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.HttpError = exports.GrammyError = void 0; +exports.toGrammyError = toGrammyError; +exports.toHttpError = toHttpError; +const platform_node_js_1 = require("../platform.node.js"); +const debug = (0, platform_node_js_1.debug)("grammy:warn"); +/** + * This class represents errors that are thrown by grammY because the Telegram + * Bot API responded with an error. + * + * Instances of this class hold the information that the Telegram backend + * returned. + * + * If this error is thrown, grammY could successfully communicate with the + * Telegram Bot API servers, however, an error code was returned for the + * respective method call. + */ +class GrammyError extends Error { + constructor(message, err, + /** The called method name which caused this error to be thrown. */ + method, + /** The payload that was passed when calling the method. */ + payload) { + var _a; + super(`${message} (${err.error_code}: ${err.description})`); + this.method = method; + this.payload = payload; + /** Flag that this request was unsuccessful. Always `false`. */ + this.ok = false; + this.name = "GrammyError"; + this.error_code = err.error_code; + this.description = err.description; + this.parameters = (_a = err.parameters) !== null && _a !== void 0 ? _a : {}; + } +} +exports.GrammyError = GrammyError; +function toGrammyError(err, method, payload) { + switch (err.error_code) { + case 401: + debug("Error 401 means that your bot token is wrong, talk to https://t.me/BotFather to check it."); + break; + case 409: + debug("Error 409 means that you are running your bot several times on long polling. Consider revoking the bot token if you believe that no other instance is running."); + break; + } + return new GrammyError(`Call to '${method}' failed!`, err, method, payload); +} +/** + * This class represents errors that are thrown by grammY because an HTTP call + * to the Telegram Bot API failed. + * + * Instances of this class hold the error object that was created because the + * fetch call failed. It can be inspected to determine why exactly the network + * request failed. + * + * If an [API transformer + * function](https://grammy.dev/advanced/transformers) throws an error, + * grammY will regard this as if the network request failed. The contained error + * will then be the error that was thrown by the transformer function. + */ +class HttpError extends Error { + constructor(message, + /** The thrown error object. */ + error) { + super(message); + this.error = error; + this.name = "HttpError"; + } +} +exports.HttpError = HttpError; +function isTelegramError(err) { + return (typeof err === "object" && + err !== null && + "status" in err && + "statusText" in err); +} +function toHttpError(method, sensitiveLogs) { + return (err) => { + let msg = `Network request for '${method}' failed!`; + if (isTelegramError(err)) + msg += ` (${err.status}: ${err.statusText})`; + if (sensitiveLogs && err instanceof Error) + msg += ` ${err.message}`; + throw new HttpError(msg, err); + }; +} diff --git a/sandbox/tgbot/node_modules/grammy/out/core/payload.d.ts b/sandbox/tgbot/node_modules/grammy/out/core/payload.d.ts new file mode 100644 index 0000000..1a35dd9 --- /dev/null +++ b/sandbox/tgbot/node_modules/grammy/out/core/payload.d.ts @@ -0,0 +1,39 @@ +/** + * Determines for a given payload if it may be sent as JSON, or if it has to be + * uploaded via multipart/form-data. Returns `true` in the latter case and + * `false` in the former. + * + * @param payload The payload to analyze + */ +export declare function requiresFormDataUpload(payload: unknown): boolean; +/** + * Turns a payload into an options object that can be passed to a `fetch` call + * by setting the necessary headers and method. May only be called for payloads + * `P` that let `requiresFormDataUpload(P)` return `false`. + * + * @param payload The payload to wrap + */ +export declare function createJsonPayload(payload: Record): { + method: string; + headers: { + "content-type": string; + connection: string; + }; + body: string; +}; +/** + * Turns a payload into an options object that can be passed to a `fetch` call + * by setting the necessary headers and method. Note that this method creates a + * multipart/form-data stream under the hood. If possible, a JSON payload should + * be created instead for performance reasons. + * + * @param payload The payload to wrap + */ +export declare function createFormDataPayload(payload: Record, onError: (err: unknown) => void): { + method: string; + headers: { + "content-type": string; + connection: string; + }; + body: import("stream").Readable; +}; diff --git a/sandbox/tgbot/node_modules/grammy/out/core/payload.js b/sandbox/tgbot/node_modules/grammy/out/core/payload.js new file mode 100644 index 0000000..710b67d --- /dev/null +++ b/sandbox/tgbot/node_modules/grammy/out/core/payload.js @@ -0,0 +1,202 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.requiresFormDataUpload = requiresFormDataUpload; +exports.createJsonPayload = createJsonPayload; +exports.createFormDataPayload = createFormDataPayload; +const platform_node_js_1 = require("../platform.node.js"); +const types_js_1 = require("../types.js"); +// === Payload types (JSON vs. form data) +/** + * Determines for a given payload if it may be sent as JSON, or if it has to be + * uploaded via multipart/form-data. Returns `true` in the latter case and + * `false` in the former. + * + * @param payload The payload to analyze + */ +function requiresFormDataUpload(payload) { + return payload instanceof types_js_1.InputFile || (typeof payload === "object" && + payload !== null && + Object.values(payload).some((v) => Array.isArray(v) + ? v.some(requiresFormDataUpload) + : v instanceof types_js_1.InputFile || requiresFormDataUpload(v))); +} +/** + * Calls `JSON.stringify` but removes `null` values from objects before + * serialization + * + * @param value value + * @returns stringified value + */ +function str(value) { + return JSON.stringify(value, (_, v) => v !== null && v !== void 0 ? v : undefined); +} +/** + * Turns a payload into an options object that can be passed to a `fetch` call + * by setting the necessary headers and method. May only be called for payloads + * `P` that let `requiresFormDataUpload(P)` return `false`. + * + * @param payload The payload to wrap + */ +function createJsonPayload(payload) { + return { + method: "POST", + headers: { + "content-type": "application/json", + connection: "keep-alive", + }, + body: str(payload), + }; +} +async function* protectItr(itr, onError) { + try { + yield* itr; + } + catch (err) { + onError(err); + } +} +/** + * Turns a payload into an options object that can be passed to a `fetch` call + * by setting the necessary headers and method. Note that this method creates a + * multipart/form-data stream under the hood. If possible, a JSON payload should + * be created instead for performance reasons. + * + * @param payload The payload to wrap + */ +function createFormDataPayload(payload, onError) { + const boundary = createBoundary(); + const itr = payloadToMultipartItr(payload, boundary); + const safeItr = protectItr(itr, onError); + const stream = (0, platform_node_js_1.itrToStream)(safeItr); + return { + method: "POST", + headers: { + "content-type": `multipart/form-data; boundary=${boundary}`, + connection: "keep-alive", + }, + body: stream, + }; +} +// === Form data creation +function createBoundary() { + // Taken from Deno std lib + return "----------" + randomId(32); +} +function randomId(length = 16) { + return Array.from(Array(length)) + .map(() => Math.random().toString(36)[2] || 0) + .join(""); +} +const enc = new TextEncoder(); +/** + * Takes a payload object and produces a valid multipart/form-data stream. The + * stream is an iterator of `Uint8Array` objects. You also need to specify the + * boundary string that was used in the Content-Type header of the HTTP request. + * + * @param payload a payload object + * @param boundary the boundary string to use between the parts + */ +async function* payloadToMultipartItr(payload, boundary) { + const files = collectFiles(payload); + // Start multipart/form-data protocol + yield enc.encode(`--${boundary}\r\n`); + // Send all payload fields + const separator = enc.encode(`\r\n--${boundary}\r\n`); + let first = true; + for (const [key, value] of Object.entries(payload)) { + if (value == null) + continue; + if (!first) + yield separator; + yield valuePart(key, value instanceof types_js_1.InputFile + ? value.toJSON() + : typeof value === "object" + ? str(value) + : value); + first = false; + } + // Send all files + for (const { id, origin, file } of files) { + if (!first) + yield separator; + yield* filePart(id, origin, file); + first = false; + } + // End multipart/form-data protocol + yield enc.encode(`\r\n--${boundary}--\r\n`); +} +/** + * Installs a `toJSON` implementation on each instance of `InputFile` contained + * in the payload. They return attach:// strings under which the respective + * instances should be sent. The modified payload can now be serialized to JSON. + * + * Returns the list of discovered `InputFile` instances along with the random + * identifiers that were used in the corresponding attach:// strings, as well as + * the origin keys of the original payload object. + * + * @param value a payload object, or a part of it + * @returns the discovered `InputFile` instances with identifiers and origins + */ +function collectFiles(value) { + if (typeof value !== "object" || value === null) + return []; + return Object.entries(value).flatMap(([k, v]) => { + if (Array.isArray(v)) + return v.flatMap((p) => collectFiles(p)); + else if (v instanceof types_js_1.InputFile) { + const id = randomId(); + // Serialize `InputFile` instance with attach:// string + Object.assign(v, { toJSON: () => `attach://${id}` }); + const origin = k === "media" && + "type" in value && typeof value.type === "string" + ? value.type // use `type` for `InputMedia*` + : k; // use property key otherwise + return { id, origin, file: v }; + } + else + return collectFiles(v); + }); +} +/** Turns a regular value into a `Uint8Array` */ +function valuePart(key, value) { + return enc.encode(`content-disposition:form-data;name="${key}"\r\n\r\n${value}`); +} +/** Turns an InputFile into a generator of `Uint8Array`s */ +async function* filePart(id, origin, input) { + const filename = input.filename || `${origin}.${getExt(origin)}`; + if (filename.includes("\r") || filename.includes("\n")) { + throw new Error(`File paths cannot contain carriage-return (\\r) \ +or newline (\\n) characters! Filename for property '${origin}' was: +""" +${filename} +"""`); + } + yield enc.encode(`content-disposition:form-data;name="${id}";filename=${filename}\r\ncontent-type:application/octet-stream\r\n\r\n`); + const data = await input.toRaw(); + if (data instanceof Uint8Array) + yield data; + else + yield* data; +} +/** Returns the default file extension for an API property name */ +function getExt(key) { + switch (key) { + case "certificate": + return "pem"; + case "photo": + case "thumbnail": + return "jpg"; + case "voice": + return "ogg"; + case "audio": + return "mp3"; + case "animation": + case "video": + case "video_note": + return "mp4"; + case "sticker": + return "webp"; + default: + return "dat"; + } +} diff --git a/sandbox/tgbot/node_modules/grammy/out/filter.d.ts b/sandbox/tgbot/node_modules/grammy/out/filter.d.ts new file mode 100644 index 0000000..1472410 --- /dev/null +++ b/sandbox/tgbot/node_modules/grammy/out/filter.d.ts @@ -0,0 +1,1165 @@ +import { type Context } from "./context.js"; +import { type Update } from "./types.js"; +type FilterFunction = (ctx: C) => ctx is D; +/** + * > This is an advanced function of grammY. + * + * Takes a filter query and turns it into a predicate function that can check in + * constant time whether a given context object satisfies the query. The created + * predicate can be passed to `bot.filter` and will narrow down the context + * accordingly. + * + * This function is used internally by `bot.on` but exposed for advanced usage + * like the following. + * ```ts + * // Listens for updates except forwards of messages or channel posts + * bot.drop(matchFilter(':forward_origin'), ctx => { ... }) + * ``` + * + * Check out the + * [documentation](https://grammy.dev/ref/core/composer#on) + * of `bot.on` for examples. In addition, the + * [website](https://grammy.dev/guide/filter-queries) contains more + * information about how filter queries work in grammY. + * + * @param filter A filter query or an array of filter queries + */ +export declare function matchFilter(filter: Q | Q[]): FilterFunction>; +export declare function parse(filter: FilterQuery | FilterQuery[]): string[][]; +export declare function preprocess(filter: string[]): string[][]; +declare const UPDATE_KEYS: { + readonly message: { + readonly direct_messages_topic: {}; + readonly chat_owner_left: { + readonly new_owner: {}; + }; + readonly chat_owner_changd: {}; + readonly new_chat_members: { + readonly me: {}; + readonly is_bot: {}; + readonly is_premium: {}; + readonly added_to_attachment_menu: {}; + }; + readonly left_chat_member: { + readonly me: {}; + readonly is_bot: {}; + readonly is_premium: {}; + readonly added_to_attachment_menu: {}; + }; + readonly group_chat_created: {}; + readonly supergroup_chat_created: {}; + readonly migrate_to_chat_id: {}; + readonly migrate_from_chat_id: {}; + readonly successful_payment: {}; + readonly refunded_payment: {}; + readonly users_shared: {}; + readonly chat_shared: {}; + readonly connected_website: {}; + readonly write_access_allowed: {}; + readonly passport_data: {}; + readonly boost_added: {}; + readonly forum_topic_created: { + readonly is_name_implicit: {}; + }; + readonly forum_topic_edited: { + readonly name: {}; + readonly icon_custom_emoji_id: {}; + }; + readonly forum_topic_closed: {}; + readonly forum_topic_reopened: {}; + readonly general_forum_topic_hidden: {}; + readonly general_forum_topic_unhidden: {}; + readonly checklist: { + readonly others_can_add_tasks: {}; + readonly others_can_mark_tasks_as_done: {}; + }; + readonly checklist_tasks_done: {}; + readonly checklist_tasks_added: {}; + readonly suggested_post_info: {}; + readonly suggested_post_approved: {}; + readonly suggested_post_approval_failed: {}; + readonly suggested_post_declined: {}; + readonly suggested_post_paid: {}; + readonly suggested_post_refunded: {}; + readonly sender_boost_count: {}; + readonly forward_origin: { + readonly user: {}; + readonly hidden_user: {}; + readonly chat: {}; + readonly channel: {}; + }; + readonly is_topic_message: {}; + readonly is_automatic_forward: {}; + readonly business_connection_id: {}; + readonly text: {}; + readonly animation: {}; + readonly audio: {}; + readonly document: {}; + readonly paid_media: {}; + readonly photo: {}; + readonly sticker: { + readonly is_video: {}; + readonly is_animated: {}; + readonly premium_animation: {}; + }; + readonly story: {}; + readonly video: {}; + readonly video_note: {}; + readonly voice: {}; + readonly contact: {}; + readonly dice: {}; + readonly game: {}; + readonly poll: {}; + readonly venue: {}; + readonly location: {}; + readonly entities: { + readonly mention: {}; + readonly hashtag: {}; + readonly cashtag: {}; + readonly bot_command: {}; + readonly url: {}; + readonly email: {}; + readonly phone_number: {}; + readonly bold: {}; + readonly italic: {}; + readonly underline: {}; + readonly strikethrough: {}; + readonly spoiler: {}; + readonly blockquote: {}; + readonly expandable_blockquote: {}; + readonly code: {}; + readonly pre: {}; + readonly text_link: {}; + readonly text_mention: {}; + readonly custom_emoji: {}; + }; + readonly caption_entities: { + readonly mention: {}; + readonly hashtag: {}; + readonly cashtag: {}; + readonly bot_command: {}; + readonly url: {}; + readonly email: {}; + readonly phone_number: {}; + readonly bold: {}; + readonly italic: {}; + readonly underline: {}; + readonly strikethrough: {}; + readonly spoiler: {}; + readonly blockquote: {}; + readonly expandable_blockquote: {}; + readonly code: {}; + readonly pre: {}; + readonly text_link: {}; + readonly text_mention: {}; + readonly custom_emoji: {}; + }; + readonly caption: {}; + readonly link_preview_options: { + readonly url: {}; + readonly prefer_small_media: {}; + readonly prefer_large_media: {}; + readonly show_above_text: {}; + }; + readonly effect_id: {}; + readonly paid_star_count: {}; + readonly has_media_spoiler: {}; + readonly new_chat_title: {}; + readonly new_chat_photo: {}; + readonly delete_chat_photo: {}; + readonly message_auto_delete_timer_changed: {}; + readonly pinned_message: {}; + readonly invoice: {}; + readonly proximity_alert_triggered: {}; + readonly chat_background_set: {}; + readonly giveaway_created: {}; + readonly giveaway: { + readonly only_new_members: {}; + readonly has_public_winners: {}; + }; + readonly giveaway_winners: { + readonly only_new_members: {}; + readonly was_refunded: {}; + }; + readonly giveaway_completed: {}; + readonly gift: { + can_be_upgraded: {}; + is_upgrade_separate: {}; + is_private: {}; + }; + readonly gift_upgrade_sent: { + can_be_upgraded: {}; + is_upgrade_separate: {}; + is_private: {}; + }; + readonly unique_gift: { + readonly transfer_star_count: {}; + }; + readonly paid_message_price_changed: {}; + readonly video_chat_scheduled: {}; + readonly video_chat_started: {}; + readonly video_chat_ended: {}; + readonly video_chat_participants_invited: {}; + readonly web_app_data: {}; + }; + readonly edited_message: { + readonly direct_messages_topic: {}; + readonly chat_owner_left: { + readonly new_owner: {}; + }; + readonly chat_owner_changd: {}; + readonly new_chat_members: { + readonly me: {}; + readonly is_bot: {}; + readonly is_premium: {}; + readonly added_to_attachment_menu: {}; + }; + readonly left_chat_member: { + readonly me: {}; + readonly is_bot: {}; + readonly is_premium: {}; + readonly added_to_attachment_menu: {}; + }; + readonly group_chat_created: {}; + readonly supergroup_chat_created: {}; + readonly migrate_to_chat_id: {}; + readonly migrate_from_chat_id: {}; + readonly successful_payment: {}; + readonly refunded_payment: {}; + readonly users_shared: {}; + readonly chat_shared: {}; + readonly connected_website: {}; + readonly write_access_allowed: {}; + readonly passport_data: {}; + readonly boost_added: {}; + readonly forum_topic_created: { + readonly is_name_implicit: {}; + }; + readonly forum_topic_edited: { + readonly name: {}; + readonly icon_custom_emoji_id: {}; + }; + readonly forum_topic_closed: {}; + readonly forum_topic_reopened: {}; + readonly general_forum_topic_hidden: {}; + readonly general_forum_topic_unhidden: {}; + readonly checklist: { + readonly others_can_add_tasks: {}; + readonly others_can_mark_tasks_as_done: {}; + }; + readonly checklist_tasks_done: {}; + readonly checklist_tasks_added: {}; + readonly suggested_post_info: {}; + readonly suggested_post_approved: {}; + readonly suggested_post_approval_failed: {}; + readonly suggested_post_declined: {}; + readonly suggested_post_paid: {}; + readonly suggested_post_refunded: {}; + readonly sender_boost_count: {}; + readonly forward_origin: { + readonly user: {}; + readonly hidden_user: {}; + readonly chat: {}; + readonly channel: {}; + }; + readonly is_topic_message: {}; + readonly is_automatic_forward: {}; + readonly business_connection_id: {}; + readonly text: {}; + readonly animation: {}; + readonly audio: {}; + readonly document: {}; + readonly paid_media: {}; + readonly photo: {}; + readonly sticker: { + readonly is_video: {}; + readonly is_animated: {}; + readonly premium_animation: {}; + }; + readonly story: {}; + readonly video: {}; + readonly video_note: {}; + readonly voice: {}; + readonly contact: {}; + readonly dice: {}; + readonly game: {}; + readonly poll: {}; + readonly venue: {}; + readonly location: {}; + readonly entities: { + readonly mention: {}; + readonly hashtag: {}; + readonly cashtag: {}; + readonly bot_command: {}; + readonly url: {}; + readonly email: {}; + readonly phone_number: {}; + readonly bold: {}; + readonly italic: {}; + readonly underline: {}; + readonly strikethrough: {}; + readonly spoiler: {}; + readonly blockquote: {}; + readonly expandable_blockquote: {}; + readonly code: {}; + readonly pre: {}; + readonly text_link: {}; + readonly text_mention: {}; + readonly custom_emoji: {}; + }; + readonly caption_entities: { + readonly mention: {}; + readonly hashtag: {}; + readonly cashtag: {}; + readonly bot_command: {}; + readonly url: {}; + readonly email: {}; + readonly phone_number: {}; + readonly bold: {}; + readonly italic: {}; + readonly underline: {}; + readonly strikethrough: {}; + readonly spoiler: {}; + readonly blockquote: {}; + readonly expandable_blockquote: {}; + readonly code: {}; + readonly pre: {}; + readonly text_link: {}; + readonly text_mention: {}; + readonly custom_emoji: {}; + }; + readonly caption: {}; + readonly link_preview_options: { + readonly url: {}; + readonly prefer_small_media: {}; + readonly prefer_large_media: {}; + readonly show_above_text: {}; + }; + readonly effect_id: {}; + readonly paid_star_count: {}; + readonly has_media_spoiler: {}; + readonly new_chat_title: {}; + readonly new_chat_photo: {}; + readonly delete_chat_photo: {}; + readonly message_auto_delete_timer_changed: {}; + readonly pinned_message: {}; + readonly invoice: {}; + readonly proximity_alert_triggered: {}; + readonly chat_background_set: {}; + readonly giveaway_created: {}; + readonly giveaway: { + readonly only_new_members: {}; + readonly has_public_winners: {}; + }; + readonly giveaway_winners: { + readonly only_new_members: {}; + readonly was_refunded: {}; + }; + readonly giveaway_completed: {}; + readonly gift: { + can_be_upgraded: {}; + is_upgrade_separate: {}; + is_private: {}; + }; + readonly gift_upgrade_sent: { + can_be_upgraded: {}; + is_upgrade_separate: {}; + is_private: {}; + }; + readonly unique_gift: { + readonly transfer_star_count: {}; + }; + readonly paid_message_price_changed: {}; + readonly video_chat_scheduled: {}; + readonly video_chat_started: {}; + readonly video_chat_ended: {}; + readonly video_chat_participants_invited: {}; + readonly web_app_data: {}; + }; + readonly channel_post: { + readonly channel_chat_created: {}; + readonly direct_message_price_changed: {}; + readonly is_paid_post: {}; + readonly forward_origin: { + readonly user: {}; + readonly hidden_user: {}; + readonly chat: {}; + readonly channel: {}; + }; + readonly is_topic_message: {}; + readonly is_automatic_forward: {}; + readonly business_connection_id: {}; + readonly text: {}; + readonly animation: {}; + readonly audio: {}; + readonly document: {}; + readonly paid_media: {}; + readonly photo: {}; + readonly sticker: { + readonly is_video: {}; + readonly is_animated: {}; + readonly premium_animation: {}; + }; + readonly story: {}; + readonly video: {}; + readonly video_note: {}; + readonly voice: {}; + readonly contact: {}; + readonly dice: {}; + readonly game: {}; + readonly poll: {}; + readonly venue: {}; + readonly location: {}; + readonly entities: { + readonly mention: {}; + readonly hashtag: {}; + readonly cashtag: {}; + readonly bot_command: {}; + readonly url: {}; + readonly email: {}; + readonly phone_number: {}; + readonly bold: {}; + readonly italic: {}; + readonly underline: {}; + readonly strikethrough: {}; + readonly spoiler: {}; + readonly blockquote: {}; + readonly expandable_blockquote: {}; + readonly code: {}; + readonly pre: {}; + readonly text_link: {}; + readonly text_mention: {}; + readonly custom_emoji: {}; + }; + readonly caption_entities: { + readonly mention: {}; + readonly hashtag: {}; + readonly cashtag: {}; + readonly bot_command: {}; + readonly url: {}; + readonly email: {}; + readonly phone_number: {}; + readonly bold: {}; + readonly italic: {}; + readonly underline: {}; + readonly strikethrough: {}; + readonly spoiler: {}; + readonly blockquote: {}; + readonly expandable_blockquote: {}; + readonly code: {}; + readonly pre: {}; + readonly text_link: {}; + readonly text_mention: {}; + readonly custom_emoji: {}; + }; + readonly caption: {}; + readonly link_preview_options: { + readonly url: {}; + readonly prefer_small_media: {}; + readonly prefer_large_media: {}; + readonly show_above_text: {}; + }; + readonly effect_id: {}; + readonly paid_star_count: {}; + readonly has_media_spoiler: {}; + readonly new_chat_title: {}; + readonly new_chat_photo: {}; + readonly delete_chat_photo: {}; + readonly message_auto_delete_timer_changed: {}; + readonly pinned_message: {}; + readonly invoice: {}; + readonly proximity_alert_triggered: {}; + readonly chat_background_set: {}; + readonly giveaway_created: {}; + readonly giveaway: { + readonly only_new_members: {}; + readonly has_public_winners: {}; + }; + readonly giveaway_winners: { + readonly only_new_members: {}; + readonly was_refunded: {}; + }; + readonly giveaway_completed: {}; + readonly gift: { + can_be_upgraded: {}; + is_upgrade_separate: {}; + is_private: {}; + }; + readonly gift_upgrade_sent: { + can_be_upgraded: {}; + is_upgrade_separate: {}; + is_private: {}; + }; + readonly unique_gift: { + readonly transfer_star_count: {}; + }; + readonly paid_message_price_changed: {}; + readonly video_chat_scheduled: {}; + readonly video_chat_started: {}; + readonly video_chat_ended: {}; + readonly video_chat_participants_invited: {}; + readonly web_app_data: {}; + }; + readonly edited_channel_post: { + readonly channel_chat_created: {}; + readonly direct_message_price_changed: {}; + readonly is_paid_post: {}; + readonly forward_origin: { + readonly user: {}; + readonly hidden_user: {}; + readonly chat: {}; + readonly channel: {}; + }; + readonly is_topic_message: {}; + readonly is_automatic_forward: {}; + readonly business_connection_id: {}; + readonly text: {}; + readonly animation: {}; + readonly audio: {}; + readonly document: {}; + readonly paid_media: {}; + readonly photo: {}; + readonly sticker: { + readonly is_video: {}; + readonly is_animated: {}; + readonly premium_animation: {}; + }; + readonly story: {}; + readonly video: {}; + readonly video_note: {}; + readonly voice: {}; + readonly contact: {}; + readonly dice: {}; + readonly game: {}; + readonly poll: {}; + readonly venue: {}; + readonly location: {}; + readonly entities: { + readonly mention: {}; + readonly hashtag: {}; + readonly cashtag: {}; + readonly bot_command: {}; + readonly url: {}; + readonly email: {}; + readonly phone_number: {}; + readonly bold: {}; + readonly italic: {}; + readonly underline: {}; + readonly strikethrough: {}; + readonly spoiler: {}; + readonly blockquote: {}; + readonly expandable_blockquote: {}; + readonly code: {}; + readonly pre: {}; + readonly text_link: {}; + readonly text_mention: {}; + readonly custom_emoji: {}; + }; + readonly caption_entities: { + readonly mention: {}; + readonly hashtag: {}; + readonly cashtag: {}; + readonly bot_command: {}; + readonly url: {}; + readonly email: {}; + readonly phone_number: {}; + readonly bold: {}; + readonly italic: {}; + readonly underline: {}; + readonly strikethrough: {}; + readonly spoiler: {}; + readonly blockquote: {}; + readonly expandable_blockquote: {}; + readonly code: {}; + readonly pre: {}; + readonly text_link: {}; + readonly text_mention: {}; + readonly custom_emoji: {}; + }; + readonly caption: {}; + readonly link_preview_options: { + readonly url: {}; + readonly prefer_small_media: {}; + readonly prefer_large_media: {}; + readonly show_above_text: {}; + }; + readonly effect_id: {}; + readonly paid_star_count: {}; + readonly has_media_spoiler: {}; + readonly new_chat_title: {}; + readonly new_chat_photo: {}; + readonly delete_chat_photo: {}; + readonly message_auto_delete_timer_changed: {}; + readonly pinned_message: {}; + readonly invoice: {}; + readonly proximity_alert_triggered: {}; + readonly chat_background_set: {}; + readonly giveaway_created: {}; + readonly giveaway: { + readonly only_new_members: {}; + readonly has_public_winners: {}; + }; + readonly giveaway_winners: { + readonly only_new_members: {}; + readonly was_refunded: {}; + }; + readonly giveaway_completed: {}; + readonly gift: { + can_be_upgraded: {}; + is_upgrade_separate: {}; + is_private: {}; + }; + readonly gift_upgrade_sent: { + can_be_upgraded: {}; + is_upgrade_separate: {}; + is_private: {}; + }; + readonly unique_gift: { + readonly transfer_star_count: {}; + }; + readonly paid_message_price_changed: {}; + readonly video_chat_scheduled: {}; + readonly video_chat_started: {}; + readonly video_chat_ended: {}; + readonly video_chat_participants_invited: {}; + readonly web_app_data: {}; + }; + readonly business_connection: { + readonly can_reply: {}; + readonly is_enabled: {}; + }; + readonly business_message: { + readonly direct_messages_topic: {}; + readonly chat_owner_left: { + readonly new_owner: {}; + }; + readonly chat_owner_changd: {}; + readonly new_chat_members: { + readonly me: {}; + readonly is_bot: {}; + readonly is_premium: {}; + readonly added_to_attachment_menu: {}; + }; + readonly left_chat_member: { + readonly me: {}; + readonly is_bot: {}; + readonly is_premium: {}; + readonly added_to_attachment_menu: {}; + }; + readonly group_chat_created: {}; + readonly supergroup_chat_created: {}; + readonly migrate_to_chat_id: {}; + readonly migrate_from_chat_id: {}; + readonly successful_payment: {}; + readonly refunded_payment: {}; + readonly users_shared: {}; + readonly chat_shared: {}; + readonly connected_website: {}; + readonly write_access_allowed: {}; + readonly passport_data: {}; + readonly boost_added: {}; + readonly forum_topic_created: { + readonly is_name_implicit: {}; + }; + readonly forum_topic_edited: { + readonly name: {}; + readonly icon_custom_emoji_id: {}; + }; + readonly forum_topic_closed: {}; + readonly forum_topic_reopened: {}; + readonly general_forum_topic_hidden: {}; + readonly general_forum_topic_unhidden: {}; + readonly checklist: { + readonly others_can_add_tasks: {}; + readonly others_can_mark_tasks_as_done: {}; + }; + readonly checklist_tasks_done: {}; + readonly checklist_tasks_added: {}; + readonly suggested_post_info: {}; + readonly suggested_post_approved: {}; + readonly suggested_post_approval_failed: {}; + readonly suggested_post_declined: {}; + readonly suggested_post_paid: {}; + readonly suggested_post_refunded: {}; + readonly sender_boost_count: {}; + readonly forward_origin: { + readonly user: {}; + readonly hidden_user: {}; + readonly chat: {}; + readonly channel: {}; + }; + readonly is_topic_message: {}; + readonly is_automatic_forward: {}; + readonly business_connection_id: {}; + readonly text: {}; + readonly animation: {}; + readonly audio: {}; + readonly document: {}; + readonly paid_media: {}; + readonly photo: {}; + readonly sticker: { + readonly is_video: {}; + readonly is_animated: {}; + readonly premium_animation: {}; + }; + readonly story: {}; + readonly video: {}; + readonly video_note: {}; + readonly voice: {}; + readonly contact: {}; + readonly dice: {}; + readonly game: {}; + readonly poll: {}; + readonly venue: {}; + readonly location: {}; + readonly entities: { + readonly mention: {}; + readonly hashtag: {}; + readonly cashtag: {}; + readonly bot_command: {}; + readonly url: {}; + readonly email: {}; + readonly phone_number: {}; + readonly bold: {}; + readonly italic: {}; + readonly underline: {}; + readonly strikethrough: {}; + readonly spoiler: {}; + readonly blockquote: {}; + readonly expandable_blockquote: {}; + readonly code: {}; + readonly pre: {}; + readonly text_link: {}; + readonly text_mention: {}; + readonly custom_emoji: {}; + }; + readonly caption_entities: { + readonly mention: {}; + readonly hashtag: {}; + readonly cashtag: {}; + readonly bot_command: {}; + readonly url: {}; + readonly email: {}; + readonly phone_number: {}; + readonly bold: {}; + readonly italic: {}; + readonly underline: {}; + readonly strikethrough: {}; + readonly spoiler: {}; + readonly blockquote: {}; + readonly expandable_blockquote: {}; + readonly code: {}; + readonly pre: {}; + readonly text_link: {}; + readonly text_mention: {}; + readonly custom_emoji: {}; + }; + readonly caption: {}; + readonly link_preview_options: { + readonly url: {}; + readonly prefer_small_media: {}; + readonly prefer_large_media: {}; + readonly show_above_text: {}; + }; + readonly effect_id: {}; + readonly paid_star_count: {}; + readonly has_media_spoiler: {}; + readonly new_chat_title: {}; + readonly new_chat_photo: {}; + readonly delete_chat_photo: {}; + readonly message_auto_delete_timer_changed: {}; + readonly pinned_message: {}; + readonly invoice: {}; + readonly proximity_alert_triggered: {}; + readonly chat_background_set: {}; + readonly giveaway_created: {}; + readonly giveaway: { + readonly only_new_members: {}; + readonly has_public_winners: {}; + }; + readonly giveaway_winners: { + readonly only_new_members: {}; + readonly was_refunded: {}; + }; + readonly giveaway_completed: {}; + readonly gift: { + can_be_upgraded: {}; + is_upgrade_separate: {}; + is_private: {}; + }; + readonly gift_upgrade_sent: { + can_be_upgraded: {}; + is_upgrade_separate: {}; + is_private: {}; + }; + readonly unique_gift: { + readonly transfer_star_count: {}; + }; + readonly paid_message_price_changed: {}; + readonly video_chat_scheduled: {}; + readonly video_chat_started: {}; + readonly video_chat_ended: {}; + readonly video_chat_participants_invited: {}; + readonly web_app_data: {}; + }; + readonly edited_business_message: { + readonly direct_messages_topic: {}; + readonly chat_owner_left: { + readonly new_owner: {}; + }; + readonly chat_owner_changd: {}; + readonly new_chat_members: { + readonly me: {}; + readonly is_bot: {}; + readonly is_premium: {}; + readonly added_to_attachment_menu: {}; + }; + readonly left_chat_member: { + readonly me: {}; + readonly is_bot: {}; + readonly is_premium: {}; + readonly added_to_attachment_menu: {}; + }; + readonly group_chat_created: {}; + readonly supergroup_chat_created: {}; + readonly migrate_to_chat_id: {}; + readonly migrate_from_chat_id: {}; + readonly successful_payment: {}; + readonly refunded_payment: {}; + readonly users_shared: {}; + readonly chat_shared: {}; + readonly connected_website: {}; + readonly write_access_allowed: {}; + readonly passport_data: {}; + readonly boost_added: {}; + readonly forum_topic_created: { + readonly is_name_implicit: {}; + }; + readonly forum_topic_edited: { + readonly name: {}; + readonly icon_custom_emoji_id: {}; + }; + readonly forum_topic_closed: {}; + readonly forum_topic_reopened: {}; + readonly general_forum_topic_hidden: {}; + readonly general_forum_topic_unhidden: {}; + readonly checklist: { + readonly others_can_add_tasks: {}; + readonly others_can_mark_tasks_as_done: {}; + }; + readonly checklist_tasks_done: {}; + readonly checklist_tasks_added: {}; + readonly suggested_post_info: {}; + readonly suggested_post_approved: {}; + readonly suggested_post_approval_failed: {}; + readonly suggested_post_declined: {}; + readonly suggested_post_paid: {}; + readonly suggested_post_refunded: {}; + readonly sender_boost_count: {}; + readonly forward_origin: { + readonly user: {}; + readonly hidden_user: {}; + readonly chat: {}; + readonly channel: {}; + }; + readonly is_topic_message: {}; + readonly is_automatic_forward: {}; + readonly business_connection_id: {}; + readonly text: {}; + readonly animation: {}; + readonly audio: {}; + readonly document: {}; + readonly paid_media: {}; + readonly photo: {}; + readonly sticker: { + readonly is_video: {}; + readonly is_animated: {}; + readonly premium_animation: {}; + }; + readonly story: {}; + readonly video: {}; + readonly video_note: {}; + readonly voice: {}; + readonly contact: {}; + readonly dice: {}; + readonly game: {}; + readonly poll: {}; + readonly venue: {}; + readonly location: {}; + readonly entities: { + readonly mention: {}; + readonly hashtag: {}; + readonly cashtag: {}; + readonly bot_command: {}; + readonly url: {}; + readonly email: {}; + readonly phone_number: {}; + readonly bold: {}; + readonly italic: {}; + readonly underline: {}; + readonly strikethrough: {}; + readonly spoiler: {}; + readonly blockquote: {}; + readonly expandable_blockquote: {}; + readonly code: {}; + readonly pre: {}; + readonly text_link: {}; + readonly text_mention: {}; + readonly custom_emoji: {}; + }; + readonly caption_entities: { + readonly mention: {}; + readonly hashtag: {}; + readonly cashtag: {}; + readonly bot_command: {}; + readonly url: {}; + readonly email: {}; + readonly phone_number: {}; + readonly bold: {}; + readonly italic: {}; + readonly underline: {}; + readonly strikethrough: {}; + readonly spoiler: {}; + readonly blockquote: {}; + readonly expandable_blockquote: {}; + readonly code: {}; + readonly pre: {}; + readonly text_link: {}; + readonly text_mention: {}; + readonly custom_emoji: {}; + }; + readonly caption: {}; + readonly link_preview_options: { + readonly url: {}; + readonly prefer_small_media: {}; + readonly prefer_large_media: {}; + readonly show_above_text: {}; + }; + readonly effect_id: {}; + readonly paid_star_count: {}; + readonly has_media_spoiler: {}; + readonly new_chat_title: {}; + readonly new_chat_photo: {}; + readonly delete_chat_photo: {}; + readonly message_auto_delete_timer_changed: {}; + readonly pinned_message: {}; + readonly invoice: {}; + readonly proximity_alert_triggered: {}; + readonly chat_background_set: {}; + readonly giveaway_created: {}; + readonly giveaway: { + readonly only_new_members: {}; + readonly has_public_winners: {}; + }; + readonly giveaway_winners: { + readonly only_new_members: {}; + readonly was_refunded: {}; + }; + readonly giveaway_completed: {}; + readonly gift: { + can_be_upgraded: {}; + is_upgrade_separate: {}; + is_private: {}; + }; + readonly gift_upgrade_sent: { + can_be_upgraded: {}; + is_upgrade_separate: {}; + is_private: {}; + }; + readonly unique_gift: { + readonly transfer_star_count: {}; + }; + readonly paid_message_price_changed: {}; + readonly video_chat_scheduled: {}; + readonly video_chat_started: {}; + readonly video_chat_ended: {}; + readonly video_chat_participants_invited: {}; + readonly web_app_data: {}; + }; + readonly deleted_business_messages: {}; + readonly inline_query: {}; + readonly chosen_inline_result: {}; + readonly callback_query: { + readonly data: {}; + readonly game_short_name: {}; + }; + readonly shipping_query: {}; + readonly pre_checkout_query: {}; + readonly poll: {}; + readonly poll_answer: {}; + readonly my_chat_member: { + readonly from: { + readonly me: {}; + readonly is_bot: {}; + readonly is_premium: {}; + readonly added_to_attachment_menu: {}; + }; + }; + readonly chat_member: { + readonly from: { + readonly me: {}; + readonly is_bot: {}; + readonly is_premium: {}; + readonly added_to_attachment_menu: {}; + }; + }; + readonly chat_join_request: {}; + readonly message_reaction: { + readonly old_reaction: { + readonly emoji: {}; + readonly custom_emoji: {}; + readonly paid: {}; + }; + readonly new_reaction: { + readonly emoji: {}; + readonly custom_emoji: {}; + readonly paid: {}; + }; + }; + readonly message_reaction_count: { + readonly reactions: { + readonly emoji: {}; + readonly custom_emoji: {}; + readonly paid: {}; + }; + }; + readonly chat_boost: {}; + readonly removed_chat_boost: {}; + readonly purchased_paid_media: {}; +}; +type KeyOf = string & keyof T; +type S = typeof UPDATE_KEYS; +type L1S = KeyOf; +type L2S = L1 extends unknown ? `${L1}:${KeyOf}` : never; +type L3S = L1 extends unknown ? L3S_ : never; +type L3S_ = KeyOf> = L2 extends unknown ? `${L1}:${L2}:${KeyOf}` : never; +type L123 = L1S | L2S | L3S; +type InjectShortcuts = Q extends `${infer L1}:${infer L2}:${infer L3}` ? `${CollapseL1}:${CollapseL2}:${L3}` : Q extends `${infer L1}:${infer L2}` ? `${CollapseL1}:${CollapseL2}` : CollapseL1; +type CollapseL1> = Q | (L extends string ? Q extends typeof L1_SHORTCUTS[L][number] ? L : never : never); +type CollapseL2> = Q | (L extends string ? Q extends typeof L2_SHORTCUTS[L][number] ? L : never : never); +type ComputeFilterQueryList = InjectShortcuts; +/** + * Represents a filter query that can be passed to `bot.on`. There are three + * different kinds of filter queries: Level 1, Level 2, and Level 3. Check out + * the [website](https://grammy.dev/guide/filter-queries) to read about how + * filter queries work in grammY, and how to use them. + * + * Here are three brief examples: + * ```ts + * // Listen for messages of any type (Level 1) + * bot.on('message', ctx => { ... }) + * // Listen for audio messages only (Level 2) + * bot.on('message:audio', ctx => { ... }) + * // Listen for text messages that have a URL entity (Level 3) + * bot.on('message:entities:url', ctx => { ... }) + * ``` + */ +export type FilterQuery = ComputeFilterQueryList; +/** + * Any kind of value that appears in the Telegram Bot API. When intersected with + * an optional field, it effectively removes `| undefined`. + */ +type NotUndefined = {}; +/** + * Given a FilterQuery, returns an object that, when intersected with an Update, + * marks those properties as required that are guaranteed to exist. + */ +type RunQuery = L1Discriminator>; +type L1Parts = Q extends `${infer L1}:${string}` ? L1 : Q; +type L2Parts = Q extends `${L1}:${infer L2}:${string}` ? L2 : Q extends `${L1}:${infer L2}` ? L2 : never; +type L1Discriminator = Combine, L1>; +type L1Fragment = L1 extends unknown ? Record>> : never; +type L2Discriminator = [L2] extends [ + never +] ? L2ShallowFragment : Combine, L2>; +type L2Fragment = L2 extends unknown ? Record, NotUndefined> : never; +type L2ShallowFragment = Record, NotUndefined>; +type Combine = U extends unknown ? U & Partial, undefined>> : never; +/** + * This type infers which properties will be present on the given context object + * provided it matches the given filter query. If the filter query is a union + * type, the produced context object will be a union of possible combinations, + * hence allowing you to narrow down manually which of the properties are + * present. + * + * In some sense, this type computes `matchFilter` on the type level. + */ +export type Filter = PerformQuery>>; +export type FilterCore = PerformQueryCore>>; +type PerformQuery = U extends unknown ? FilteredContext : never; +type PerformQueryCore = U extends unknown ? FilteredContextCore : never; +type FilteredContext = C & FilteredContextCore; +type FilteredContextCore = Record<"update", U> & Shortcuts; +interface Shortcuts { + message: [U["message"]] extends [object] ? U["message"] : undefined; + editedMessage: [U["edited_message"]] extends [object] ? U["edited_message"] : undefined; + channelPost: [U["channel_post"]] extends [object] ? U["channel_post"] : undefined; + editedChannelPost: [U["edited_channel_post"]] extends [object] ? U["edited_channel_post"] : undefined; + businessConnection: [U["business_connection"]] extends [object] ? U["business_connection"] : undefined; + businessMessage: [U["business_message"]] extends [object] ? U["business_message"] : undefined; + editedBusinessMessage: [U["edited_business_message"]] extends [object] ? U["edited_business_message"] : undefined; + deletedBusinessMessages: [U["deleted_business_messages"]] extends [object] ? U["deleted_business_messages"] : undefined; + messageReaction: [U["message_reaction"]] extends [object] ? U["message_reaction"] : undefined; + messageReactionCount: [U["message_reaction_count"]] extends [object] ? U["message_reaction_count"] : undefined; + inlineQuery: [U["inline_query"]] extends [object] ? U["inline_query"] : undefined; + chosenInlineResult: [U["chosen_inline_result"]] extends [object] ? U["chosen_inline_result"] : undefined; + callbackQuery: [U["callback_query"]] extends [object] ? U["callback_query"] : undefined; + shippingQuery: [U["shipping_query"]] extends [object] ? U["shipping_query"] : undefined; + preCheckoutQuery: [U["pre_checkout_query"]] extends [object] ? U["pre_checkout_query"] : undefined; + poll: [U["poll"]] extends [object] ? U["poll"] : undefined; + pollAnswer: [U["poll_answer"]] extends [object] ? U["poll_answer"] : undefined; + myChatMember: [U["my_chat_member"]] extends [object] ? U["my_chat_member"] : undefined; + chatMember: [U["chat_member"]] extends [object] ? U["chat_member"] : undefined; + chatJoinRequest: [U["chat_join_request"]] extends [object] ? U["chat_join_request"] : undefined; + chatBoost: [U["chat_boost"]] extends [object] ? U["chat_boost"] : undefined; + removedChatBoost: [U["removed_chat_boost"]] extends [object] ? U["removed_chat_boost"] : undefined; + purchasedPaidMedia: [U["purchased_paid_media"]] extends [object] ? U["purchased_paid_media"] : undefined; + msg: [U["message"]] extends [object] ? U["message"] : [U["edited_message"]] extends [object] ? U["edited_message"] : [U["channel_post"]] extends [object] ? U["channel_post"] : [U["edited_channel_post"]] extends [object] ? U["edited_channel_post"] : [U["business_message"]] extends [object] ? U["business_message"] : [U["edited_business_message"]] extends [object] ? U["edited_business_message"] : [U["callback_query"]] extends [object] ? U["callback_query"]["message"] : undefined; + chat: [U["callback_query"]] extends [object] ? NonNullable["chat"] | undefined : [Shortcuts["msg"]] extends [object] ? Shortcuts["msg"]["chat"] : [U["deleted_business_messages"]] extends [object] ? U["deleted_business_messages"]["chat"] : [U["message_reaction"]] extends [object] ? U["message_reaction"]["chat"] : [U["message_reaction_count"]] extends [object] ? U["message_reaction_count"]["chat"] : [U["my_chat_member"]] extends [object] ? U["my_chat_member"]["chat"] : [U["chat_member"]] extends [object] ? U["chat_member"]["chat"] : [U["chat_join_request"]] extends [object] ? U["chat_join_request"]["chat"] : [U["chat_boost"]] extends [object] ? U["chat_boost"]["chat"] : [U["removed_chat_boost"]] extends [object] ? U["removed_chat_boost"]["chat"] : undefined; + senderChat: [Shortcuts["msg"]] extends [object] ? Shortcuts["msg"]["sender_chat"] : undefined; + from: [U["business_connection"]] extends [object] ? U["business_connection"]["user"] : [U["message_reaction"]] extends [object] ? U["message_reaction"]["user"] : [U["chat_boost"]] extends [object] ? U["chat_boost"]["boost"]["source"]["user"] : [U["removed_chat_boost"]] extends [object] ? U["removed_chat_boost"]["source"]["user"] : [U["callback_query"]] extends [object] ? U["callback_query"]["from"] : [Shortcuts["msg"]] extends [object] ? Shortcuts["msg"]["from"] : [U["inline_query"]] extends [object] ? U["inline_query"]["from"] : [U["chosen_inline_result"]] extends [object] ? U["chosen_inline_result"]["from"] : [U["shipping_query"]] extends [object] ? U["shipping_query"]["from"] : [U["pre_checkout_query"]] extends [object] ? U["pre_checkout_query"]["from"] : [U["my_chat_member"]] extends [object] ? U["my_chat_member"]["from"] : [U["chat_member"]] extends [object] ? U["chat_member"]["from"] : [U["chat_join_request"]] extends [object] ? U["chat_join_request"]["from"] : undefined; + msgId: [U["callback_query"]] extends [object] ? number | undefined : [Shortcuts["msg"]] extends [object] ? number : [U["message_reaction"]] extends [object] ? number : [U["message_reaction_count"]] extends [object] ? number : undefined; + chatId: [U["callback_query"]] extends [object] ? number | undefined : [Shortcuts["chat"]] extends [object] ? number : [U["business_connection"]] extends [object] ? number : undefined; + businessConnectionId: [U["callback_query"]] extends [object] ? string | undefined : [Shortcuts["msg"]] extends [object] ? string | undefined : [U["business_connection"]] extends [object] ? string : [U["deleted_business_messages"]] extends [object] ? string : undefined; +} +declare const L1_SHORTCUTS: { + readonly "": readonly ["message", "channel_post"]; + readonly msg: readonly ["message", "channel_post"]; + readonly edit: readonly ["edited_message", "edited_channel_post"]; +}; +declare const L2_SHORTCUTS: { + readonly "": readonly ["entities", "caption_entities"]; + readonly media: readonly ["photo", "video"]; + readonly file: readonly ["photo", "animation", "audio", "document", "video", "video_note", "voice", "sticker"]; +}; +type L1Shortcuts = KeyOf; +type L2Shortcuts = KeyOf; +type ExpandShortcuts = Q extends `${infer L1}:${infer L2}:${infer L3}` ? `${ExpandL1}:${ExpandL2}:${L3}` : Q extends `${infer L1}:${infer L2}` ? `${ExpandL1}:${ExpandL2}` : ExpandL1; +type ExpandL1 = S extends L1Shortcuts ? typeof L1_SHORTCUTS[S][number] : S; +type ExpandL2 = S extends L2Shortcuts ? typeof L2_SHORTCUTS[S][number] : S; +type AddTwins = TwinsFromL1 | TwinsFromL2; +type TwinsFromL1 = L1 extends KeyOf ? L1Equivalents[L1] : L2; +type L1Equivalents = { + message: "from"; + edited_message: "from" | "edit_date"; + channel_post: "sender_chat"; + edited_channel_post: "sender_chat" | "edit_date"; + business_message: "from"; + edited_business_message: "from" | "edit_date"; +}; +type TwinsFromL2 = L1 extends KeyOf ? L2 extends KeyOf ? L2Equivalents[L1][L2] : L2 : L2; +type L2Equivalents = { + message: MessageEquivalents; + edited_message: MessageEquivalents; + channel_post: MessageEquivalents; + edited_channel_post: MessageEquivalents; + business_message: MessageEquivalents; + edited_business_message: MessageEquivalents; +}; +type MessageEquivalents = { + animation: "document"; + entities: "text"; + caption_entities: "caption"; + is_topic_message: "message_thread_id"; +}; +export {}; diff --git a/sandbox/tgbot/node_modules/grammy/out/filter.js b/sandbox/tgbot/node_modules/grammy/out/filter.js new file mode 100644 index 0000000..2675b6b --- /dev/null +++ b/sandbox/tgbot/node_modules/grammy/out/filter.js @@ -0,0 +1,408 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.matchFilter = matchFilter; +exports.parse = parse; +exports.preprocess = preprocess; +const filterQueryCache = new Map(); +// === Obtain O(1) filter function from query +/** + * > This is an advanced function of grammY. + * + * Takes a filter query and turns it into a predicate function that can check in + * constant time whether a given context object satisfies the query. The created + * predicate can be passed to `bot.filter` and will narrow down the context + * accordingly. + * + * This function is used internally by `bot.on` but exposed for advanced usage + * like the following. + * ```ts + * // Listens for updates except forwards of messages or channel posts + * bot.drop(matchFilter(':forward_origin'), ctx => { ... }) + * ``` + * + * Check out the + * [documentation](https://grammy.dev/ref/core/composer#on) + * of `bot.on` for examples. In addition, the + * [website](https://grammy.dev/guide/filter-queries) contains more + * information about how filter queries work in grammY. + * + * @param filter A filter query or an array of filter queries + */ +function matchFilter(filter) { + var _a; + const queries = Array.isArray(filter) ? filter : [filter]; + const key = queries.join(","); + const predicate = (_a = filterQueryCache.get(key)) !== null && _a !== void 0 ? _a : (() => { + const parsed = parse(queries); + const pred = compile(parsed); + filterQueryCache.set(key, pred); + return pred; + })(); + return (ctx) => predicate(ctx); +} +function parse(filter) { + return Array.isArray(filter) + ? filter.map((q) => q.split(":")) + : [filter.split(":")]; +} +function compile(parsed) { + const preprocessed = parsed.flatMap((q) => check(q, preprocess(q))); + const ltree = treeify(preprocessed); + const predicate = arborist(ltree); // arborists check trees + return (ctx) => !!predicate(ctx.update, ctx); +} +function preprocess(filter) { + const valid = UPDATE_KEYS; + const expanded = [filter] + // expand L1 + .flatMap((q) => { + const [l1, l2, l3] = q; + // only expand if shortcut is given + if (!(l1 in L1_SHORTCUTS)) + return [q]; + // only expand for at least one non-empty part + if (!l1 && !l2 && !l3) + return [q]; + // perform actual expansion + const targets = L1_SHORTCUTS[l1]; + const expanded = targets.map((s) => [s, l2, l3]); + // assume that bare L1 expansions are always correct + if (l2 === undefined) + return expanded; + // only filter out invalid expansions if we don't do this later + if (l2 in L2_SHORTCUTS && (l2 || l3)) + return expanded; + // filter out invalid expansions, e.g. `channel_post:new_chat_member` for empty L1 + return expanded.filter(([s]) => { var _a; return !!((_a = valid[s]) === null || _a === void 0 ? void 0 : _a[l2]); }); + }) + // expand L2 + .flatMap((q) => { + const [l1, l2, l3] = q; + // only expand if shortcut is given + if (!(l2 in L2_SHORTCUTS)) + return [q]; + // only expand for at least one non-empty part + if (!l2 && !l3) + return [q]; + // perform actual expansion + const targets = L2_SHORTCUTS[l2]; + const expanded = targets.map((s) => [l1, s, l3]); + // assume that bare L2 expansions are always correct + if (l3 === undefined) + return expanded; + // filter out invalid expansions + return expanded.filter(([, s]) => { var _a, _b; return !!((_b = (_a = valid[l1]) === null || _a === void 0 ? void 0 : _a[s]) === null || _b === void 0 ? void 0 : _b[l3]); }); + }); + if (expanded.length === 0) { + throw new Error(`Shortcuts in '${filter.join(":")}' do not expand to any valid filter query`); + } + return expanded; +} +function check(original, preprocessed) { + if (preprocessed.length === 0) + throw new Error("Empty filter query given"); + const errors = preprocessed + .map(checkOne) + .filter((r) => r !== true); + if (errors.length === 0) + return preprocessed; + else if (errors.length === 1) + throw new Error(errors[0]); + else { + throw new Error(`Invalid filter query '${original.join(":")}'. There are ${errors.length} errors after expanding the contained shortcuts: ${errors.join("; ")}`); + } +} +function checkOne(filter) { + const [l1, l2, l3, ...n] = filter; + if (l1 === undefined) + return "Empty filter query given"; + if (!(l1 in UPDATE_KEYS)) { + const permitted = Object.keys(UPDATE_KEYS); + return `Invalid L1 filter '${l1}' given in '${filter.join(":")}'. \ +Permitted values are: ${permitted.map((k) => `'${k}'`).join(", ")}.`; + } + if (l2 === undefined) + return true; + const l1Obj = UPDATE_KEYS[l1]; + if (!(l2 in l1Obj)) { + const permitted = Object.keys(l1Obj); + return `Invalid L2 filter '${l2}' given in '${filter.join(":")}'. \ +Permitted values are: ${permitted.map((k) => `'${k}'`).join(", ")}.`; + } + if (l3 === undefined) + return true; + const l2Obj = l1Obj[l2]; + if (!(l3 in l2Obj)) { + const permitted = Object.keys(l2Obj); + return `Invalid L3 filter '${l3}' given in '${filter.join(":")}'. ${permitted.length === 0 + ? `No further filtering is possible after '${l1}:${l2}'.` + : `Permitted values are: ${permitted.map((k) => `'${k}'`).join(", ")}.`}`; + } + if (n.length === 0) + return true; + return `Cannot filter further than three levels, ':${n.join(":")}' is invalid!`; +} +function treeify(paths) { + var _a, _b; + const tree = {}; + for (const [l1, l2, l3] of paths) { + const subtree = ((_a = tree[l1]) !== null && _a !== void 0 ? _a : (tree[l1] = {})); + if (l2 !== undefined) { + const set = ((_b = subtree[l2]) !== null && _b !== void 0 ? _b : (subtree[l2] = new Set())); + if (l3 !== undefined) + set.add(l3); + } + } + return tree; +} +function or(left, right) { + return (obj, ctx) => left(obj, ctx) || right(obj, ctx); +} +function concat(get, test) { + return (obj, ctx) => { + const nextObj = get(obj, ctx); + return nextObj && test(nextObj, ctx); + }; +} +function leaf(pred) { + return (obj, ctx) => pred(obj, ctx) != null; +} +function arborist(tree) { + const l1Predicates = Object.entries(tree).map(([l1, subtree]) => { + const l1Pred = (obj) => obj[l1]; + const l2Predicates = Object.entries(subtree).map(([l2, set]) => { + const l2Pred = (obj) => obj[l2]; + const l3Predicates = Array.from(set).map((l3) => { + const l3Pred = l3 === "me" // special handling for `me` shortcut + ? (obj, ctx) => { + const me = ctx.me.id; + return testMaybeArray(obj, (u) => u.id === me); + } + : (obj) => testMaybeArray(obj, (e) => e[l3] || e.type === l3); + return l3Pred; + }); + return l3Predicates.length === 0 + ? leaf(l2Pred) + : concat(l2Pred, l3Predicates.reduce(or)); + }); + return l2Predicates.length === 0 + ? leaf(l1Pred) + : concat(l1Pred, l2Predicates.reduce(or)); + }); + if (l1Predicates.length === 0) { + throw new Error("Cannot create filter function for empty query"); + } + return l1Predicates.reduce(or); +} +function testMaybeArray(t, pred) { + const p = (x) => x != null && pred(x); + return Array.isArray(t) ? t.some(p) : p(t); +} +// === Define a structure to validate the queries +// L3 +const ENTITY_KEYS = { + mention: {}, + hashtag: {}, + cashtag: {}, + bot_command: {}, + url: {}, + email: {}, + phone_number: {}, + bold: {}, + italic: {}, + underline: {}, + strikethrough: {}, + spoiler: {}, + blockquote: {}, + expandable_blockquote: {}, + code: {}, + pre: {}, + text_link: {}, + text_mention: {}, + custom_emoji: {}, +}; +const USER_KEYS = { + me: {}, + is_bot: {}, + is_premium: {}, + added_to_attachment_menu: {}, +}; +const FORWARD_ORIGIN_KEYS = { + user: {}, + hidden_user: {}, + chat: {}, + channel: {}, +}; +const STICKER_KEYS = { + is_video: {}, + is_animated: {}, + premium_animation: {}, +}; +const REACTION_KEYS = { + emoji: {}, + custom_emoji: {}, + paid: {}, +}; +const GIFT_INFO_KEYS = { + can_be_upgraded: {}, + is_upgrade_separate: {}, + is_private: {}, +}; +// L2 +const COMMON_MESSAGE_KEYS = { + forward_origin: FORWARD_ORIGIN_KEYS, + is_topic_message: {}, + is_automatic_forward: {}, + business_connection_id: {}, + text: {}, + animation: {}, + audio: {}, + document: {}, + paid_media: {}, + photo: {}, + sticker: STICKER_KEYS, + story: {}, + video: {}, + video_note: {}, + voice: {}, + contact: {}, + dice: {}, + game: {}, + poll: {}, + venue: {}, + location: {}, + entities: ENTITY_KEYS, + caption_entities: ENTITY_KEYS, + caption: {}, + link_preview_options: { + url: {}, + prefer_small_media: {}, + prefer_large_media: {}, + show_above_text: {}, + }, + effect_id: {}, + paid_star_count: {}, + has_media_spoiler: {}, + new_chat_title: {}, + new_chat_photo: {}, + delete_chat_photo: {}, + message_auto_delete_timer_changed: {}, + pinned_message: {}, + invoice: {}, + proximity_alert_triggered: {}, + chat_background_set: {}, + giveaway_created: {}, + giveaway: { only_new_members: {}, has_public_winners: {} }, + giveaway_winners: { only_new_members: {}, was_refunded: {} }, + giveaway_completed: {}, + gift: GIFT_INFO_KEYS, + gift_upgrade_sent: GIFT_INFO_KEYS, + unique_gift: { transfer_star_count: {} }, + paid_message_price_changed: {}, + video_chat_scheduled: {}, + video_chat_started: {}, + video_chat_ended: {}, + video_chat_participants_invited: {}, + web_app_data: {}, +}; +const MESSAGE_KEYS = { + ...COMMON_MESSAGE_KEYS, + direct_messages_topic: {}, + chat_owner_left: { new_owner: {} }, + chat_owner_changd: {}, + new_chat_members: USER_KEYS, + left_chat_member: USER_KEYS, + group_chat_created: {}, + supergroup_chat_created: {}, + migrate_to_chat_id: {}, + migrate_from_chat_id: {}, + successful_payment: {}, + refunded_payment: {}, + users_shared: {}, + chat_shared: {}, + connected_website: {}, + write_access_allowed: {}, + passport_data: {}, + boost_added: {}, + forum_topic_created: { is_name_implicit: {} }, + forum_topic_edited: { name: {}, icon_custom_emoji_id: {} }, + forum_topic_closed: {}, + forum_topic_reopened: {}, + general_forum_topic_hidden: {}, + general_forum_topic_unhidden: {}, + checklist: { others_can_add_tasks: {}, others_can_mark_tasks_as_done: {} }, + checklist_tasks_done: {}, + checklist_tasks_added: {}, + suggested_post_info: {}, + suggested_post_approved: {}, + suggested_post_approval_failed: {}, + suggested_post_declined: {}, + suggested_post_paid: {}, + suggested_post_refunded: {}, + sender_boost_count: {}, +}; +const CHANNEL_POST_KEYS = { + ...COMMON_MESSAGE_KEYS, + channel_chat_created: {}, + direct_message_price_changed: {}, + is_paid_post: {}, +}; +const BUSINESS_CONNECTION_KEYS = { + can_reply: {}, + is_enabled: {}, +}; +const MESSAGE_REACTION_KEYS = { + old_reaction: REACTION_KEYS, + new_reaction: REACTION_KEYS, +}; +const MESSAGE_REACTION_COUNT_UPDATED_KEYS = { + reactions: REACTION_KEYS, +}; +const CALLBACK_QUERY_KEYS = { data: {}, game_short_name: {} }; +const CHAT_MEMBER_UPDATED_KEYS = { from: USER_KEYS }; +// L1 +const UPDATE_KEYS = { + message: MESSAGE_KEYS, + edited_message: MESSAGE_KEYS, + channel_post: CHANNEL_POST_KEYS, + edited_channel_post: CHANNEL_POST_KEYS, + business_connection: BUSINESS_CONNECTION_KEYS, + business_message: MESSAGE_KEYS, + edited_business_message: MESSAGE_KEYS, + deleted_business_messages: {}, + inline_query: {}, + chosen_inline_result: {}, + callback_query: CALLBACK_QUERY_KEYS, + shipping_query: {}, + pre_checkout_query: {}, + poll: {}, + poll_answer: {}, + my_chat_member: CHAT_MEMBER_UPDATED_KEYS, + chat_member: CHAT_MEMBER_UPDATED_KEYS, + chat_join_request: {}, + message_reaction: MESSAGE_REACTION_KEYS, + message_reaction_count: MESSAGE_REACTION_COUNT_UPDATED_KEYS, + chat_boost: {}, + removed_chat_boost: {}, + purchased_paid_media: {}, +}; +// === Define some helpers for handling shortcuts, e.g. in 'edit:photo' +const L1_SHORTCUTS = { + "": ["message", "channel_post"], + msg: ["message", "channel_post"], + edit: ["edited_message", "edited_channel_post"], +}; +const L2_SHORTCUTS = { + "": ["entities", "caption_entities"], + media: ["photo", "video"], + file: [ + "photo", + "animation", + "audio", + "document", + "video", + "video_note", + "voice", + "sticker", + ], +}; diff --git a/sandbox/tgbot/node_modules/grammy/out/mod.d.ts b/sandbox/tgbot/node_modules/grammy/out/mod.d.ts new file mode 100644 index 0000000..1681171 --- /dev/null +++ b/sandbox/tgbot/node_modules/grammy/out/mod.d.ts @@ -0,0 +1,14 @@ +export { Bot, type BotConfig, BotError, type ErrorHandler, type PollingOptions, } from "./bot.js"; +export { InputFile } from "./types.js"; +export { type CallbackQueryContext, type ChatTypeContext, type ChosenInlineResultContext, type CommandContext, Context, type GameQueryContext, type HearsContext, type InlineQueryContext, type ReactionContext, } from "./context.js"; +export * from "./convenience/constants.js"; +export * from "./convenience/inline_query.js"; +export * from "./convenience/input_media.js"; +export * from "./convenience/keyboard.js"; +export * from "./convenience/session.js"; +export * from "./convenience/webhook.js"; +export { type CallbackQueryMiddleware, type ChatTypeMiddleware, type CommandMiddleware, Composer, type GameQueryMiddleware, type HearsMiddleware, type InlineQueryMiddleware, type Middleware, type MiddlewareFn, type MiddlewareObj, type NextFunction, type ReactionMiddleware, } from "./composer.js"; +export { type Filter, type FilterQuery, matchFilter } from "./filter.js"; +export { Api } from "./core/api.js"; +export { type ApiCallFn, type ApiClientOptions, type RawApi, type TransformableApi, type Transformer, type WebhookReplyEnvelope, } from "./core/client.js"; +export { GrammyError, HttpError } from "./core/error.js"; diff --git a/sandbox/tgbot/node_modules/grammy/out/mod.js b/sandbox/tgbot/node_modules/grammy/out/mod.js new file mode 100644 index 0000000..94407ce --- /dev/null +++ b/sandbox/tgbot/node_modules/grammy/out/mod.js @@ -0,0 +1,43 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __exportStar = (this && this.__exportStar) || function(m, exports) { + for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.HttpError = exports.GrammyError = exports.Api = exports.matchFilter = exports.Composer = exports.Context = exports.InputFile = exports.BotError = exports.Bot = void 0; +// Commonly used stuff +var bot_js_1 = require("./bot.js"); +Object.defineProperty(exports, "Bot", { enumerable: true, get: function () { return bot_js_1.Bot; } }); +Object.defineProperty(exports, "BotError", { enumerable: true, get: function () { return bot_js_1.BotError; } }); +var types_js_1 = require("./types.js"); +Object.defineProperty(exports, "InputFile", { enumerable: true, get: function () { return types_js_1.InputFile; } }); +var context_js_1 = require("./context.js"); +Object.defineProperty(exports, "Context", { enumerable: true, get: function () { return context_js_1.Context; } }); +// Convenience stuff, built-in plugins, and helpers +__exportStar(require("./convenience/constants.js"), exports); +__exportStar(require("./convenience/inline_query.js"), exports); +__exportStar(require("./convenience/input_media.js"), exports); +__exportStar(require("./convenience/keyboard.js"), exports); +__exportStar(require("./convenience/session.js"), exports); +__exportStar(require("./convenience/webhook.js"), exports); +// A little more advanced stuff +var composer_js_1 = require("./composer.js"); +Object.defineProperty(exports, "Composer", { enumerable: true, get: function () { return composer_js_1.Composer; } }); +var filter_js_1 = require("./filter.js"); +Object.defineProperty(exports, "matchFilter", { enumerable: true, get: function () { return filter_js_1.matchFilter; } }); +// Internal stuff for expert users +var api_js_1 = require("./core/api.js"); +Object.defineProperty(exports, "Api", { enumerable: true, get: function () { return api_js_1.Api; } }); +var error_js_1 = require("./core/error.js"); +Object.defineProperty(exports, "GrammyError", { enumerable: true, get: function () { return error_js_1.GrammyError; } }); +Object.defineProperty(exports, "HttpError", { enumerable: true, get: function () { return error_js_1.HttpError; } }); diff --git a/sandbox/tgbot/node_modules/grammy/out/platform.node.d.ts b/sandbox/tgbot/node_modules/grammy/out/platform.node.d.ts new file mode 100644 index 0000000..dfd0ca3 --- /dev/null +++ b/sandbox/tgbot/node_modules/grammy/out/platform.node.d.ts @@ -0,0 +1,16 @@ +import { Agent as HttpAgent } from "http"; +import { Agent as HttpsAgent } from "https"; +import { Readable } from "stream"; +export { debug } from "debug"; +export declare const itrToStream: (itr: AsyncIterable) => Readable; +export declare function baseFetchConfig(apiRoot: string): { + compress: boolean; + agent: HttpsAgent; +} | { + agent: HttpAgent; + compress?: undefined; +} | { + compress?: undefined; + agent?: undefined; +}; +export declare const defaultAdapter = "express"; diff --git a/sandbox/tgbot/node_modules/grammy/out/platform.node.js b/sandbox/tgbot/node_modules/grammy/out/platform.node.js new file mode 100644 index 0000000..cba0f38 --- /dev/null +++ b/sandbox/tgbot/node_modules/grammy/out/platform.node.js @@ -0,0 +1,43 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.defaultAdapter = exports.itrToStream = exports.debug = void 0; +exports.baseFetchConfig = baseFetchConfig; +// === Needed imports +const http_1 = require("http"); +const https_1 = require("https"); +const stream_1 = require("stream"); +// === Export debug +var debug_1 = require("debug"); +Object.defineProperty(exports, "debug", { enumerable: true, get: function () { return debug_1.debug; } }); +// === Export system-specific operations +// Turn an AsyncIterable into a stream +const itrToStream = (itr) => stream_1.Readable.from(itr, { objectMode: false }); +exports.itrToStream = itrToStream; +// === Base configuration for `fetch` calls +const httpAgents = new Map(); +const httpsAgents = new Map(); +function getCached(map, key, otherwise) { + let value = map.get(key); + if (value === undefined) { + value = otherwise(); + map.set(key, value); + } + return value; +} +function baseFetchConfig(apiRoot) { + if (apiRoot.startsWith("https:")) { + return { + compress: true, + agent: getCached(httpsAgents, apiRoot, () => new https_1.Agent({ keepAlive: true })), + }; + } + else if (apiRoot.startsWith("http:")) { + return { + agent: getCached(httpAgents, apiRoot, () => new http_1.Agent({ keepAlive: true })), + }; + } + else + return {}; +} +// === Default webhook adapter +exports.defaultAdapter = "express"; diff --git a/sandbox/tgbot/node_modules/grammy/out/shim.node.d.ts b/sandbox/tgbot/node_modules/grammy/out/shim.node.d.ts new file mode 100644 index 0000000..9823864 --- /dev/null +++ b/sandbox/tgbot/node_modules/grammy/out/shim.node.d.ts @@ -0,0 +1,2 @@ +export { AbortController, type AbortSignal } from "abort-controller"; +export { default as fetch } from "node-fetch"; diff --git a/sandbox/tgbot/node_modules/grammy/out/shim.node.js b/sandbox/tgbot/node_modules/grammy/out/shim.node.js new file mode 100644 index 0000000..3b3da19 --- /dev/null +++ b/sandbox/tgbot/node_modules/grammy/out/shim.node.js @@ -0,0 +1,7 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.fetch = exports.AbortController = void 0; +var abort_controller_1 = require("abort-controller"); +Object.defineProperty(exports, "AbortController", { enumerable: true, get: function () { return abort_controller_1.AbortController; } }); +var node_fetch_1 = require("node-fetch"); +Object.defineProperty(exports, "fetch", { enumerable: true, get: function () { return node_fetch_1.default; } }); diff --git a/sandbox/tgbot/node_modules/grammy/out/types.d.ts b/sandbox/tgbot/node_modules/grammy/out/types.d.ts new file mode 100644 index 0000000..a1f9ba7 --- /dev/null +++ b/sandbox/tgbot/node_modules/grammy/out/types.d.ts @@ -0,0 +1 @@ +export * from "./types.node.js"; diff --git a/sandbox/tgbot/node_modules/grammy/out/types.js b/sandbox/tgbot/node_modules/grammy/out/types.js new file mode 100644 index 0000000..8bc9830 --- /dev/null +++ b/sandbox/tgbot/node_modules/grammy/out/types.js @@ -0,0 +1,17 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __exportStar = (this && this.__exportStar) || function(m, exports) { + for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +__exportStar(require("./types.node.js"), exports); diff --git a/sandbox/tgbot/node_modules/grammy/out/types.node.d.ts b/sandbox/tgbot/node_modules/grammy/out/types.node.d.ts new file mode 100644 index 0000000..374413e --- /dev/null +++ b/sandbox/tgbot/node_modules/grammy/out/types.node.d.ts @@ -0,0 +1,95 @@ +import { type ApiMethods as ApiMethodsF, type InputMedia as InputMediaF, type InputMediaAnimation as InputMediaAnimationF, type InputMediaAudio as InputMediaAudioF, type InputMediaDocument as InputMediaDocumentF, type InputMediaPhoto as InputMediaPhotoF, type InputMediaVideo as InputMediaVideoF, type InputPaidMedia as InputPaidMediaF, type InputPaidMediaPhoto as InputPaidMediaPhotoF, type InputPaidMediaVideo as InputPaidMediaVideoF, type InputProfilePhoto as InputProfilePhotoAnimatedF, type InputProfilePhoto as InputProfilePhotoF, type InputProfilePhoto as InputProfilePhotoStaticF, type InputSticker as InputStickerF, type InputStoryContent as InputStoryContentF, type InputStoryContentPhoto as InputStoryContentPhotoF, type InputStoryContentVideo as InputStoryContentVideoF, type Opts as OptsF } from "@grammyjs/types"; +import { type ReadStream } from "fs"; +export * from "@grammyjs/types"; +/** A value, or a potentially async function supplying that value */ +type MaybeSupplier = T | (() => T | Promise); +/** Something that looks like a URL. */ +interface URLLike { + /** + * Identifier of the resource. Must be in a format that can be parsed by the + * URL constructor. + */ + url: string; +} +/** + * An `InputFile` wraps a number of different sources for [sending + * files](https://grammy.dev/guide/files#uploading-your-own-files). + * + * It corresponds to the `InputFile` type in the [Telegram Bot API + * Reference](https://core.telegram.org/bots/api#inputfile). + */ +export declare class InputFile { + private consumed; + private readonly fileData; + /** + * Optional name of the constructed `InputFile` instance. + * + * Check out the + * [documentation](https://grammy.dev/guide/files#uploading-your-own-files) + * on sending files with `InputFile`. + */ + readonly filename?: string; + /** + * Constructs an `InputFile` that can be used in the API to send files. + * + * @param file A path to a local file or a `Buffer` or a `fs.ReadStream` that specifies the file data + * @param filename Optional name of the file + */ + constructor(file: MaybeSupplier | AsyncIterable>, filename?: string); + private guessFilename; + /** + * Internal method. Do not use. + * + * Converts this instance into a binary representation that can be sent to + * the Bot API server in the request body. + */ + toRaw(): Promise | AsyncIterable>; + toJSON(): void; +} +/** Wrapper type to bundle all methods of the Telegram API */ +export type ApiMethods = ApiMethodsF; +/** Utility type providing the argument type for the given method name or `{}` if the method does not take any parameters */ +export type Opts = OptsF[M]; +/** This object describes a sticker to be added to a sticker set. */ +export type InputSticker = InputStickerF; +/** This object represents the content of a media message to be sent. It should be one of +- InputMediaAnimation +- InputMediaDocument +- InputMediaAudio +- InputMediaPhoto +- InputMediaVideo */ +export type InputMedia = InputMediaF; +/** Represents a photo to be sent. */ +export type InputMediaPhoto = InputMediaPhotoF; +/** Represents a video to be sent. */ +export type InputMediaVideo = InputMediaVideoF; +/** Represents an animation file (GIF or H.264/MPEG-4 AVC video without sound) to be sent. */ +export type InputMediaAnimation = InputMediaAnimationF; +/** Represents an audio file to be treated as music to be sent. */ +export type InputMediaAudio = InputMediaAudioF; +/** Represents a general file to be sent. */ +export type InputMediaDocument = InputMediaDocumentF; +/** This object describes the paid media to be sent. Currently, it can be one of +- InputPaidMediaPhoto +- InputPaidMediaVideo */ +export type InputPaidMedia = InputPaidMediaF; +/** The paid media to send is a photo. */ +export type InputPaidMediaPhoto = InputPaidMediaPhotoF; +/** The paid media to send is a video. */ +export type InputPaidMediaVideo = InputPaidMediaVideoF; +/** This object describes a profile photo to set. Currently, it can be one of +- InputProfilePhotoStatic +- InputProfilePhotoAnimated */ +export type InputProfilePhoto = InputProfilePhotoF; +/** A static profile photo in the .JPG format. */ +export type InputProfilePhotoStatic = InputProfilePhotoStaticF; +/** An animated profile photo in the MPEG4 format. */ +export type InputProfilePhotoAnimated = InputProfilePhotoAnimatedF; +/** This object describes the content of a story to post. Currently, it can be one of +- InputStoryContentPhoto +- InputStoryContentVideo */ +export type InputStoryContent = InputStoryContentF; +/** Describes a photo to post as a story. */ +export type InputStoryContentPhoto = InputStoryContentPhotoF; +/** Describes a video to post as a story. */ +export type InputStoryContentVideo = InputStoryContentVideoF; diff --git a/sandbox/tgbot/node_modules/grammy/out/types.node.js b/sandbox/tgbot/node_modules/grammy/out/types.node.js new file mode 100644 index 0000000..12923ad --- /dev/null +++ b/sandbox/tgbot/node_modules/grammy/out/types.node.js @@ -0,0 +1,110 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __exportStar = (this && this.__exportStar) || function(m, exports) { + for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.InputFile = void 0; +const fs_1 = require("fs"); +const node_fetch_1 = require("node-fetch"); +const path_1 = require("path"); +const platform_node_1 = require("./platform.node"); +const debug = (0, platform_node_1.debug)("grammy:warn"); +// === Export all API types +__exportStar(require("@grammyjs/types"), exports); +// === InputFile handling and File augmenting +/** + * An `InputFile` wraps a number of different sources for [sending + * files](https://grammy.dev/guide/files#uploading-your-own-files). + * + * It corresponds to the `InputFile` type in the [Telegram Bot API + * Reference](https://core.telegram.org/bots/api#inputfile). + */ +class InputFile { + /** + * Constructs an `InputFile` that can be used in the API to send files. + * + * @param file A path to a local file or a `Buffer` or a `fs.ReadStream` that specifies the file data + * @param filename Optional name of the file + */ + constructor(file, filename) { + this.consumed = false; + this.fileData = file; + filename !== null && filename !== void 0 ? filename : (filename = this.guessFilename(file)); + this.filename = filename; + if (typeof file === "string" && + (file.startsWith("http:") || file.startsWith("https:"))) { + debug(`InputFile received the local file path '${file}' that looks like a URL. Is this a mistake?`); + } + } + guessFilename(file) { + if (typeof file === "string") + return (0, path_1.basename)(file); + if ("url" in file) + return (0, path_1.basename)(file.url); + if (!(file instanceof URL)) + return undefined; + if (file.pathname !== "/") { + const filename = (0, path_1.basename)(file.pathname); + if (filename) + return filename; + } + return (0, path_1.basename)(file.hostname); + } + /** + * Internal method. Do not use. + * + * Converts this instance into a binary representation that can be sent to + * the Bot API server in the request body. + */ + async toRaw() { + if (this.consumed) { + throw new Error("Cannot reuse InputFile data source!"); + } + const data = this.fileData; + // Handle local files + if (typeof data === "string") + return (0, fs_1.createReadStream)(data); + // Handle URLs and URLLike objects + if (data instanceof URL) { + return data.protocol === "file" // node-fetch does not support file URLs + ? (0, fs_1.createReadStream)(data.pathname) + : fetchFile(data); + } + if ("url" in data) + return fetchFile(data.url); + // Return buffers as-is + if (data instanceof Uint8Array) + return data; + // Unwrap supplier functions + if (typeof data === "function") { + return new InputFile(await data()).toRaw(); + } + // Mark streams and iterators as consumed and return them as-is + this.consumed = true; + return data; + } + toJSON() { + throw new Error("InputFile instances must be sent via grammY"); + } +} +exports.InputFile = InputFile; +async function* fetchFile(url) { + const { body } = await (0, node_fetch_1.default)(url); + for await (const chunk of body) { + if (typeof chunk === "string") { + throw new Error(`Could not transfer file, received string data instead of bytes from '${url}'`); + } + yield chunk; + } +} diff --git a/sandbox/tgbot/node_modules/grammy/out/web.d.ts b/sandbox/tgbot/node_modules/grammy/out/web.d.ts new file mode 100644 index 0000000..4b0ff4e --- /dev/null +++ b/sandbox/tgbot/node_modules/grammy/out/web.d.ts @@ -0,0 +1 @@ +export * from "./mod"; diff --git a/sandbox/tgbot/node_modules/grammy/out/web.mjs b/sandbox/tgbot/node_modules/grammy/out/web.mjs new file mode 100644 index 0000000..a206839 --- /dev/null +++ b/sandbox/tgbot/node_modules/grammy/out/web.mjs @@ -0,0 +1,5838 @@ +const filterQueryCache = new Map(); +function matchFilter(filter) { + const queries = Array.isArray(filter) ? filter : [ + filter + ]; + const key = queries.join(","); + const predicate = filterQueryCache.get(key) ?? (()=>{ + const parsed = parse(queries); + const pred = compile(parsed); + filterQueryCache.set(key, pred); + return pred; + })(); + return (ctx)=>predicate(ctx); +} +function parse(filter) { + return Array.isArray(filter) ? filter.map((q)=>q.split(":")) : [ + filter.split(":") + ]; +} +function compile(parsed) { + const preprocessed = parsed.flatMap((q)=>check(q, preprocess(q))); + const ltree = treeify(preprocessed); + const predicate = arborist(ltree); + return (ctx)=>!!predicate(ctx.update, ctx); +} +function preprocess(filter) { + const valid = UPDATE_KEYS; + const expanded = [ + filter + ].flatMap((q)=>{ + const [l1, l2, l3] = q; + if (!(l1 in L1_SHORTCUTS)) return [ + q + ]; + if (!l1 && !l2 && !l3) return [ + q + ]; + const targets = L1_SHORTCUTS[l1]; + const expanded = targets.map((s)=>[ + s, + l2, + l3 + ]); + if (l2 === undefined) return expanded; + if (l2 in L2_SHORTCUTS && (l2 || l3)) return expanded; + return expanded.filter(([s])=>!!valid[s]?.[l2]); + }).flatMap((q)=>{ + const [l1, l2, l3] = q; + if (!(l2 in L2_SHORTCUTS)) return [ + q + ]; + if (!l2 && !l3) return [ + q + ]; + const targets = L2_SHORTCUTS[l2]; + const expanded = targets.map((s)=>[ + l1, + s, + l3 + ]); + if (l3 === undefined) return expanded; + return expanded.filter(([, s])=>!!valid[l1]?.[s]?.[l3]); + }); + if (expanded.length === 0) { + throw new Error(`Shortcuts in '${filter.join(":")}' do not expand to any valid filter query`); + } + return expanded; +} +function check(original, preprocessed) { + if (preprocessed.length === 0) throw new Error("Empty filter query given"); + const errors = preprocessed.map(checkOne).filter((r)=>r !== true); + if (errors.length === 0) return preprocessed; + else if (errors.length === 1) throw new Error(errors[0]); + else { + throw new Error(`Invalid filter query '${original.join(":")}'. There are ${errors.length} errors after expanding the contained shortcuts: ${errors.join("; ")}`); + } +} +function checkOne(filter) { + const [l1, l2, l3, ...n] = filter; + if (l1 === undefined) return "Empty filter query given"; + if (!(l1 in UPDATE_KEYS)) { + const permitted = Object.keys(UPDATE_KEYS); + return `Invalid L1 filter '${l1}' given in '${filter.join(":")}'. \ +Permitted values are: ${permitted.map((k)=>`'${k}'`).join(", ")}.`; + } + if (l2 === undefined) return true; + const l1Obj = UPDATE_KEYS[l1]; + if (!(l2 in l1Obj)) { + const permitted = Object.keys(l1Obj); + return `Invalid L2 filter '${l2}' given in '${filter.join(":")}'. \ +Permitted values are: ${permitted.map((k)=>`'${k}'`).join(", ")}.`; + } + if (l3 === undefined) return true; + const l2Obj = l1Obj[l2]; + if (!(l3 in l2Obj)) { + const permitted = Object.keys(l2Obj); + return `Invalid L3 filter '${l3}' given in '${filter.join(":")}'. ${permitted.length === 0 ? `No further filtering is possible after '${l1}:${l2}'.` : `Permitted values are: ${permitted.map((k)=>`'${k}'`).join(", ")}.`}`; + } + if (n.length === 0) return true; + return `Cannot filter further than three levels, ':${n.join(":")}' is invalid!`; +} +function treeify(paths) { + const tree = {}; + for (const [l1, l2, l3] of paths){ + const subtree = tree[l1] ??= {}; + if (l2 !== undefined) { + const set = subtree[l2] ??= new Set(); + if (l3 !== undefined) set.add(l3); + } + } + return tree; +} +function or(left, right) { + return (obj, ctx)=>left(obj, ctx) || right(obj, ctx); +} +function concat(get, test) { + return (obj, ctx)=>{ + const nextObj = get(obj, ctx); + return nextObj && test(nextObj, ctx); + }; +} +function leaf(pred) { + return (obj, ctx)=>pred(obj, ctx) != null; +} +function arborist(tree) { + const l1Predicates = Object.entries(tree).map(([l1, subtree])=>{ + const l1Pred = (obj)=>obj[l1]; + const l2Predicates = Object.entries(subtree).map(([l2, set])=>{ + const l2Pred = (obj)=>obj[l2]; + const l3Predicates = Array.from(set).map((l3)=>{ + const l3Pred = l3 === "me" ? (obj, ctx)=>{ + const me = ctx.me.id; + return testMaybeArray(obj, (u)=>u.id === me); + } : (obj)=>testMaybeArray(obj, (e)=>e[l3] || e.type === l3); + return l3Pred; + }); + return l3Predicates.length === 0 ? leaf(l2Pred) : concat(l2Pred, l3Predicates.reduce(or)); + }); + return l2Predicates.length === 0 ? leaf(l1Pred) : concat(l1Pred, l2Predicates.reduce(or)); + }); + if (l1Predicates.length === 0) { + throw new Error("Cannot create filter function for empty query"); + } + return l1Predicates.reduce(or); +} +function testMaybeArray(t, pred) { + const p = (x)=>x != null && pred(x); + return Array.isArray(t) ? t.some(p) : p(t); +} +const ENTITY_KEYS = { + mention: {}, + hashtag: {}, + cashtag: {}, + bot_command: {}, + url: {}, + email: {}, + phone_number: {}, + bold: {}, + italic: {}, + underline: {}, + strikethrough: {}, + spoiler: {}, + blockquote: {}, + expandable_blockquote: {}, + code: {}, + pre: {}, + text_link: {}, + text_mention: {}, + custom_emoji: {} +}; +const USER_KEYS = { + me: {}, + is_bot: {}, + is_premium: {}, + added_to_attachment_menu: {} +}; +const FORWARD_ORIGIN_KEYS = { + user: {}, + hidden_user: {}, + chat: {}, + channel: {} +}; +const STICKER_KEYS = { + is_video: {}, + is_animated: {}, + premium_animation: {} +}; +const REACTION_KEYS = { + emoji: {}, + custom_emoji: {}, + paid: {} +}; +const GIFT_INFO_KEYS = { + can_be_upgraded: {}, + is_upgrade_separate: {}, + is_private: {} +}; +const COMMON_MESSAGE_KEYS = { + forward_origin: FORWARD_ORIGIN_KEYS, + is_topic_message: {}, + is_automatic_forward: {}, + business_connection_id: {}, + text: {}, + animation: {}, + audio: {}, + document: {}, + paid_media: {}, + photo: {}, + sticker: STICKER_KEYS, + story: {}, + video: {}, + video_note: {}, + voice: {}, + contact: {}, + dice: {}, + game: {}, + poll: {}, + venue: {}, + location: {}, + entities: ENTITY_KEYS, + caption_entities: ENTITY_KEYS, + caption: {}, + link_preview_options: { + url: {}, + prefer_small_media: {}, + prefer_large_media: {}, + show_above_text: {} + }, + effect_id: {}, + paid_star_count: {}, + has_media_spoiler: {}, + new_chat_title: {}, + new_chat_photo: {}, + delete_chat_photo: {}, + message_auto_delete_timer_changed: {}, + pinned_message: {}, + invoice: {}, + proximity_alert_triggered: {}, + chat_background_set: {}, + giveaway_created: {}, + giveaway: { + only_new_members: {}, + has_public_winners: {} + }, + giveaway_winners: { + only_new_members: {}, + was_refunded: {} + }, + giveaway_completed: {}, + gift: GIFT_INFO_KEYS, + gift_upgrade_sent: GIFT_INFO_KEYS, + unique_gift: { + transfer_star_count: {} + }, + paid_message_price_changed: {}, + video_chat_scheduled: {}, + video_chat_started: {}, + video_chat_ended: {}, + video_chat_participants_invited: {}, + web_app_data: {} +}; +const MESSAGE_KEYS = { + ...COMMON_MESSAGE_KEYS, + direct_messages_topic: {}, + chat_owner_left: { + new_owner: {} + }, + chat_owner_changd: {}, + new_chat_members: USER_KEYS, + left_chat_member: USER_KEYS, + group_chat_created: {}, + supergroup_chat_created: {}, + migrate_to_chat_id: {}, + migrate_from_chat_id: {}, + successful_payment: {}, + refunded_payment: {}, + users_shared: {}, + chat_shared: {}, + connected_website: {}, + write_access_allowed: {}, + passport_data: {}, + boost_added: {}, + forum_topic_created: { + is_name_implicit: {} + }, + forum_topic_edited: { + name: {}, + icon_custom_emoji_id: {} + }, + forum_topic_closed: {}, + forum_topic_reopened: {}, + general_forum_topic_hidden: {}, + general_forum_topic_unhidden: {}, + checklist: { + others_can_add_tasks: {}, + others_can_mark_tasks_as_done: {} + }, + checklist_tasks_done: {}, + checklist_tasks_added: {}, + suggested_post_info: {}, + suggested_post_approved: {}, + suggested_post_approval_failed: {}, + suggested_post_declined: {}, + suggested_post_paid: {}, + suggested_post_refunded: {}, + sender_boost_count: {} +}; +const CHANNEL_POST_KEYS = { + ...COMMON_MESSAGE_KEYS, + channel_chat_created: {}, + direct_message_price_changed: {}, + is_paid_post: {} +}; +const BUSINESS_CONNECTION_KEYS = { + can_reply: {}, + is_enabled: {} +}; +const MESSAGE_REACTION_KEYS = { + old_reaction: REACTION_KEYS, + new_reaction: REACTION_KEYS +}; +const MESSAGE_REACTION_COUNT_UPDATED_KEYS = { + reactions: REACTION_KEYS +}; +const CALLBACK_QUERY_KEYS = { + data: {}, + game_short_name: {} +}; +const CHAT_MEMBER_UPDATED_KEYS = { + from: USER_KEYS +}; +const UPDATE_KEYS = { + message: MESSAGE_KEYS, + edited_message: MESSAGE_KEYS, + channel_post: CHANNEL_POST_KEYS, + edited_channel_post: CHANNEL_POST_KEYS, + business_connection: BUSINESS_CONNECTION_KEYS, + business_message: MESSAGE_KEYS, + edited_business_message: MESSAGE_KEYS, + deleted_business_messages: {}, + inline_query: {}, + chosen_inline_result: {}, + callback_query: CALLBACK_QUERY_KEYS, + shipping_query: {}, + pre_checkout_query: {}, + poll: {}, + poll_answer: {}, + my_chat_member: CHAT_MEMBER_UPDATED_KEYS, + chat_member: CHAT_MEMBER_UPDATED_KEYS, + chat_join_request: {}, + message_reaction: MESSAGE_REACTION_KEYS, + message_reaction_count: MESSAGE_REACTION_COUNT_UPDATED_KEYS, + chat_boost: {}, + removed_chat_boost: {}, + purchased_paid_media: {} +}; +const L1_SHORTCUTS = { + "": [ + "message", + "channel_post" + ], + msg: [ + "message", + "channel_post" + ], + edit: [ + "edited_message", + "edited_channel_post" + ] +}; +const L2_SHORTCUTS = { + "": [ + "entities", + "caption_entities" + ], + media: [ + "photo", + "video" + ], + file: [ + "photo", + "animation", + "audio", + "document", + "video", + "video_note", + "voice", + "sticker" + ] +}; +const checker = { + filterQuery (filter) { + const pred = matchFilter(filter); + return (ctx)=>pred(ctx); + }, + text (trigger) { + const hasText = checker.filterQuery([ + ":text", + ":caption" + ]); + const trg = triggerFn(trigger); + return (ctx)=>{ + if (!hasText(ctx)) return false; + const msg = ctx.message ?? ctx.channelPost; + const txt = msg.text ?? msg.caption; + return match(ctx, txt, trg); + }; + }, + command (command) { + const hasEntities = checker.filterQuery(":entities:bot_command"); + const atCommands = new Set(); + const noAtCommands = new Set(); + toArray(command).forEach((cmd)=>{ + if (cmd.startsWith("/")) { + throw new Error(`Do not include '/' when registering command handlers (use '${cmd.substring(1)}' not '${cmd}')`); + } + const set = cmd.includes("@") ? atCommands : noAtCommands; + set.add(cmd); + }); + return (ctx)=>{ + if (!hasEntities(ctx)) return false; + const msg = ctx.message ?? ctx.channelPost; + const txt = msg.text ?? msg.caption; + return msg.entities.some((e)=>{ + if (e.type !== "bot_command") return false; + if (e.offset !== 0) return false; + const cmd = txt.substring(1, e.length); + if (noAtCommands.has(cmd) || atCommands.has(cmd)) { + ctx.match = txt.substring(cmd.length + 1).trimStart(); + return true; + } + const index = cmd.indexOf("@"); + if (index === -1) return false; + const atTarget = cmd.substring(index + 1).toLowerCase(); + const username = ctx.me.username.toLowerCase(); + if (atTarget !== username) return false; + const atCommand = cmd.substring(0, index); + if (noAtCommands.has(atCommand)) { + ctx.match = txt.substring(cmd.length + 1).trimStart(); + return true; + } + return false; + }); + }; + }, + reaction (reaction) { + const hasMessageReaction = checker.filterQuery("message_reaction"); + const normalized = typeof reaction === "string" ? [ + { + type: "emoji", + emoji: reaction + } + ] : (Array.isArray(reaction) ? reaction : [ + reaction + ]).map((emoji)=>typeof emoji === "string" ? { + type: "emoji", + emoji + } : emoji); + const emoji = new Set(normalized.filter((r)=>r.type === "emoji").map((r)=>r.emoji)); + const customEmoji = new Set(normalized.filter((r)=>r.type === "custom_emoji").map((r)=>r.custom_emoji_id)); + const paid = normalized.some((r)=>r.type === "paid"); + return (ctx)=>{ + if (!hasMessageReaction(ctx)) return false; + const { old_reaction, new_reaction } = ctx.messageReaction; + for (const reaction of new_reaction){ + let isOld = false; + if (reaction.type === "emoji") { + for (const old of old_reaction){ + if (old.type !== "emoji") continue; + if (old.emoji === reaction.emoji) { + isOld = true; + break; + } + } + } else if (reaction.type === "custom_emoji") { + for (const old of old_reaction){ + if (old.type !== "custom_emoji") continue; + if (old.custom_emoji_id === reaction.custom_emoji_id) { + isOld = true; + break; + } + } + } else if (reaction.type === "paid") { + for (const old of old_reaction){ + if (old.type !== "paid") continue; + isOld = true; + break; + } + } else {} + if (isOld) continue; + if (reaction.type === "emoji") { + if (emoji.has(reaction.emoji)) return true; + } else if (reaction.type === "custom_emoji") { + if (customEmoji.has(reaction.custom_emoji_id)) return true; + } else if (reaction.type === "paid") { + if (paid) return true; + } else { + return true; + } + } + return false; + }; + }, + chatType (chatType) { + const set = new Set(toArray(chatType)); + return (ctx)=>ctx.chat?.type !== undefined && set.has(ctx.chat.type); + }, + callbackQuery (trigger) { + const hasCallbackQuery = checker.filterQuery("callback_query:data"); + const trg = triggerFn(trigger); + return (ctx)=>hasCallbackQuery(ctx) && match(ctx, ctx.callbackQuery.data, trg); + }, + gameQuery (trigger) { + const hasGameQuery = checker.filterQuery("callback_query:game_short_name"); + const trg = triggerFn(trigger); + return (ctx)=>hasGameQuery(ctx) && match(ctx, ctx.callbackQuery.game_short_name, trg); + }, + inlineQuery (trigger) { + const hasInlineQuery = checker.filterQuery("inline_query"); + const trg = triggerFn(trigger); + return (ctx)=>hasInlineQuery(ctx) && match(ctx, ctx.inlineQuery.query, trg); + }, + chosenInlineResult (trigger) { + const hasChosenInlineResult = checker.filterQuery("chosen_inline_result"); + const trg = triggerFn(trigger); + return (ctx)=>hasChosenInlineResult(ctx) && match(ctx, ctx.chosenInlineResult.result_id, trg); + }, + preCheckoutQuery (trigger) { + const hasPreCheckoutQuery = checker.filterQuery("pre_checkout_query"); + const trg = triggerFn(trigger); + return (ctx)=>hasPreCheckoutQuery(ctx) && match(ctx, ctx.preCheckoutQuery.invoice_payload, trg); + }, + shippingQuery (trigger) { + const hasShippingQuery = checker.filterQuery("shipping_query"); + const trg = triggerFn(trigger); + return (ctx)=>hasShippingQuery(ctx) && match(ctx, ctx.shippingQuery.invoice_payload, trg); + } +}; +class Context { + update; + api; + me; + match; + constructor(update, api, me){ + this.update = update; + this.api = api; + this.me = me; + } + get message() { + return this.update.message; + } + get editedMessage() { + return this.update.edited_message; + } + get channelPost() { + return this.update.channel_post; + } + get editedChannelPost() { + return this.update.edited_channel_post; + } + get businessConnection() { + return this.update.business_connection; + } + get businessMessage() { + return this.update.business_message; + } + get editedBusinessMessage() { + return this.update.edited_business_message; + } + get deletedBusinessMessages() { + return this.update.deleted_business_messages; + } + get messageReaction() { + return this.update.message_reaction; + } + get messageReactionCount() { + return this.update.message_reaction_count; + } + get inlineQuery() { + return this.update.inline_query; + } + get chosenInlineResult() { + return this.update.chosen_inline_result; + } + get callbackQuery() { + return this.update.callback_query; + } + get shippingQuery() { + return this.update.shipping_query; + } + get preCheckoutQuery() { + return this.update.pre_checkout_query; + } + get poll() { + return this.update.poll; + } + get pollAnswer() { + return this.update.poll_answer; + } + get myChatMember() { + return this.update.my_chat_member; + } + get chatMember() { + return this.update.chat_member; + } + get chatJoinRequest() { + return this.update.chat_join_request; + } + get chatBoost() { + return this.update.chat_boost; + } + get removedChatBoost() { + return this.update.removed_chat_boost; + } + get purchasedPaidMedia() { + return this.update.purchased_paid_media; + } + get msg() { + return this.message ?? this.editedMessage ?? this.channelPost ?? this.editedChannelPost ?? this.businessMessage ?? this.editedBusinessMessage ?? this.callbackQuery?.message; + } + get chat() { + return (this.msg ?? this.deletedBusinessMessages ?? this.messageReaction ?? this.messageReactionCount ?? this.myChatMember ?? this.chatMember ?? this.chatJoinRequest ?? this.chatBoost ?? this.removedChatBoost)?.chat; + } + get senderChat() { + return this.msg?.sender_chat; + } + get from() { + return (this.businessConnection ?? this.messageReaction ?? (this.chatBoost?.boost ?? this.removedChatBoost)?.source)?.user ?? (this.callbackQuery ?? this.msg ?? this.inlineQuery ?? this.chosenInlineResult ?? this.shippingQuery ?? this.preCheckoutQuery ?? this.myChatMember ?? this.chatMember ?? this.chatJoinRequest ?? this.purchasedPaidMedia)?.from; + } + get msgId() { + return this.msg?.message_id ?? this.messageReaction?.message_id ?? this.messageReactionCount?.message_id; + } + get chatId() { + return this.chat?.id ?? this.businessConnection?.user_chat_id; + } + get inlineMessageId() { + return this.callbackQuery?.inline_message_id ?? this.chosenInlineResult?.inline_message_id; + } + get businessConnectionId() { + return this.msg?.business_connection_id ?? this.businessConnection?.id ?? this.deletedBusinessMessages?.business_connection_id; + } + entities(types) { + const message = this.msg; + if (message === undefined) return []; + const text = message.text ?? message.caption; + if (text === undefined) return []; + let entities = message.entities ?? message.caption_entities; + if (entities === undefined) return []; + if (types !== undefined) { + const filters = new Set(toArray(types)); + entities = entities.filter((entity)=>filters.has(entity.type)); + } + return entities.map((entity)=>({ + ...entity, + text: text.substring(entity.offset, entity.offset + entity.length) + })); + } + reactions() { + const emoji = []; + const emojiAdded = []; + const emojiKept = []; + const emojiRemoved = []; + const customEmoji = []; + const customEmojiAdded = []; + const customEmojiKept = []; + const customEmojiRemoved = []; + let paid = false; + let paidAdded = false; + const r = this.messageReaction; + if (r !== undefined) { + const { old_reaction, new_reaction } = r; + for (const reaction of new_reaction){ + if (reaction.type === "emoji") { + emoji.push(reaction.emoji); + } else if (reaction.type === "custom_emoji") { + customEmoji.push(reaction.custom_emoji_id); + } else if (reaction.type === "paid") { + paid = paidAdded = true; + } + } + for (const reaction of old_reaction){ + if (reaction.type === "emoji") { + emojiRemoved.push(reaction.emoji); + } else if (reaction.type === "custom_emoji") { + customEmojiRemoved.push(reaction.custom_emoji_id); + } else if (reaction.type === "paid") { + paidAdded = false; + } + } + emojiAdded.push(...emoji); + customEmojiAdded.push(...customEmoji); + for(let i = 0; i < emojiRemoved.length; i++){ + const len = emojiAdded.length; + if (len === 0) break; + const rem = emojiRemoved[i]; + for(let j = 0; j < len; j++){ + if (rem === emojiAdded[j]) { + emojiKept.push(rem); + emojiRemoved.splice(i, 1); + emojiAdded.splice(j, 1); + i--; + break; + } + } + } + for(let i = 0; i < customEmojiRemoved.length; i++){ + const len = customEmojiAdded.length; + if (len === 0) break; + const rem = customEmojiRemoved[i]; + for(let j = 0; j < len; j++){ + if (rem === customEmojiAdded[j]) { + customEmojiKept.push(rem); + customEmojiRemoved.splice(i, 1); + customEmojiAdded.splice(j, 1); + i--; + break; + } + } + } + } + return { + emoji, + emojiAdded, + emojiKept, + emojiRemoved, + customEmoji, + customEmojiAdded, + customEmojiKept, + customEmojiRemoved, + paid, + paidAdded + }; + } + static has = checker; + has(filter) { + return Context.has.filterQuery(filter)(this); + } + hasText(trigger) { + return Context.has.text(trigger)(this); + } + hasCommand(command) { + return Context.has.command(command)(this); + } + hasReaction(reaction) { + return Context.has.reaction(reaction)(this); + } + hasChatType(chatType) { + return Context.has.chatType(chatType)(this); + } + hasCallbackQuery(trigger) { + return Context.has.callbackQuery(trigger)(this); + } + hasGameQuery(trigger) { + return Context.has.gameQuery(trigger)(this); + } + hasInlineQuery(trigger) { + return Context.has.inlineQuery(trigger)(this); + } + hasChosenInlineResult(trigger) { + return Context.has.chosenInlineResult(trigger)(this); + } + hasPreCheckoutQuery(trigger) { + return Context.has.preCheckoutQuery(trigger)(this); + } + hasShippingQuery(trigger) { + return Context.has.shippingQuery(trigger)(this); + } + reply(text, other, signal) { + const msg = this.msg; + return this.api.sendMessage(orThrow(this.chatId, "sendMessage"), text, { + business_connection_id: this.businessConnectionId, + ...msg?.is_topic_message ? { + message_thread_id: msg.message_thread_id + } : {}, + direct_messages_topic_id: msg?.direct_messages_topic?.topic_id, + ...other + }, signal); + } + replyWithDraft(text, other, signal) { + const msg = this.msg; + return this.api.sendMessageDraft(orThrow(this.chatId, "sendMessageDraft"), this.update.update_id, text, { + ...msg?.is_topic_message ? { + message_thread_id: msg?.message_thread_id + } : {}, + ...other + }, signal); + } + forwardMessage(chat_id, other, signal) { + const msg = this.msg; + return this.api.forwardMessage(chat_id, orThrow(this.chatId, "forwardMessage"), orThrow(this.msgId, "forwardMessage"), { + direct_messages_topic_id: msg?.direct_messages_topic?.topic_id, + ...other + }, signal); + } + forwardMessages(chat_id, message_ids, other, signal) { + const msg = this.msg; + return this.api.forwardMessages(chat_id, orThrow(this.chatId, "forwardMessages"), message_ids, { + direct_messages_topic_id: msg?.direct_messages_topic?.topic_id, + ...other + }, signal); + } + copyMessage(chat_id, other, signal) { + const msg = this.msg; + return this.api.copyMessage(chat_id, orThrow(this.chatId, "copyMessage"), orThrow(this.msgId, "copyMessage"), { + direct_messages_topic_id: msg?.direct_messages_topic?.topic_id, + ...other + }, signal); + } + copyMessages(chat_id, message_ids, other, signal) { + const msg = this.msg; + return this.api.copyMessages(chat_id, orThrow(this.chatId, "copyMessages"), message_ids, { + direct_messages_topic_id: msg?.direct_messages_topic?.topic_id, + ...other + }, signal); + } + replyWithPhoto(photo, other, signal) { + const msg = this.msg; + return this.api.sendPhoto(orThrow(this.chatId, "sendPhoto"), photo, { + business_connection_id: this.businessConnectionId, + ...msg?.is_topic_message ? { + message_thread_id: msg.message_thread_id + } : {}, + direct_messages_topic_id: msg?.direct_messages_topic?.topic_id, + ...other + }, signal); + } + replyWithAudio(audio, other, signal) { + const msg = this.msg; + return this.api.sendAudio(orThrow(this.chatId, "sendAudio"), audio, { + business_connection_id: this.businessConnectionId, + ...msg?.is_topic_message ? { + message_thread_id: msg.message_thread_id + } : {}, + direct_messages_topic_id: msg?.direct_messages_topic?.topic_id, + ...other + }, signal); + } + replyWithDocument(document1, other, signal) { + const msg = this.msg; + return this.api.sendDocument(orThrow(this.chatId, "sendDocument"), document1, { + business_connection_id: this.businessConnectionId, + ...msg?.is_topic_message ? { + message_thread_id: msg.message_thread_id + } : {}, + direct_messages_topic_id: msg?.direct_messages_topic?.topic_id, + ...other + }, signal); + } + replyWithVideo(video, other, signal) { + const msg = this.msg; + return this.api.sendVideo(orThrow(this.chatId, "sendVideo"), video, { + business_connection_id: this.businessConnectionId, + ...msg?.is_topic_message ? { + message_thread_id: msg.message_thread_id + } : {}, + direct_messages_topic_id: msg?.direct_messages_topic?.topic_id, + ...other + }, signal); + } + replyWithAnimation(animation, other, signal) { + const msg = this.msg; + return this.api.sendAnimation(orThrow(this.chatId, "sendAnimation"), animation, { + business_connection_id: this.businessConnectionId, + ...msg?.is_topic_message ? { + message_thread_id: msg.message_thread_id + } : {}, + direct_messages_topic_id: msg?.direct_messages_topic?.topic_id, + ...other + }, signal); + } + replyWithVoice(voice, other, signal) { + const msg = this.msg; + return this.api.sendVoice(orThrow(this.chatId, "sendVoice"), voice, { + business_connection_id: this.businessConnectionId, + ...msg?.is_topic_message ? { + message_thread_id: msg.message_thread_id + } : {}, + direct_messages_topic_id: msg?.direct_messages_topic?.topic_id, + ...other + }, signal); + } + replyWithVideoNote(video_note, other, signal) { + const msg = this.msg; + return this.api.sendVideoNote(orThrow(this.chatId, "sendVideoNote"), video_note, { + business_connection_id: this.businessConnectionId, + ...msg?.is_topic_message ? { + message_thread_id: msg.message_thread_id + } : {}, + direct_messages_topic_id: msg?.direct_messages_topic?.topic_id, + ...other + }, signal); + } + replyWithMediaGroup(media, other, signal) { + const msg = this.msg; + return this.api.sendMediaGroup(orThrow(this.chatId, "sendMediaGroup"), media, { + business_connection_id: this.businessConnectionId, + ...msg?.is_topic_message ? { + message_thread_id: msg.message_thread_id + } : {}, + direct_messages_topic_id: msg?.direct_messages_topic?.topic_id, + ...other + }, signal); + } + replyWithLocation(latitude, longitude, other, signal) { + const msg = this.msg; + return this.api.sendLocation(orThrow(this.chatId, "sendLocation"), latitude, longitude, { + business_connection_id: this.businessConnectionId, + ...msg?.is_topic_message ? { + message_thread_id: msg.message_thread_id + } : {}, + direct_messages_topic_id: msg?.direct_messages_topic?.topic_id, + ...other + }, signal); + } + editMessageLiveLocation(latitude, longitude, other, signal) { + const inlineId = this.inlineMessageId; + return inlineId !== undefined ? this.api.editMessageLiveLocationInline(inlineId, latitude, longitude, { + business_connection_id: this.businessConnectionId, + ...other + }, signal) : this.api.editMessageLiveLocation(orThrow(this.chatId, "editMessageLiveLocation"), orThrow(this.msgId, "editMessageLiveLocation"), latitude, longitude, { + business_connection_id: this.businessConnectionId, + ...other + }, signal); + } + stopMessageLiveLocation(other, signal) { + const inlineId = this.inlineMessageId; + return inlineId !== undefined ? this.api.stopMessageLiveLocationInline(inlineId, { + business_connection_id: this.businessConnectionId, + ...other + }, signal) : this.api.stopMessageLiveLocation(orThrow(this.chatId, "stopMessageLiveLocation"), orThrow(this.msgId, "stopMessageLiveLocation"), { + business_connection_id: this.businessConnectionId, + ...other + }, signal); + } + sendPaidMedia(star_count, media, other, signal) { + const msg = this.msg; + return this.api.sendPaidMedia(orThrow(this.chatId, "sendPaidMedia"), star_count, media, { + business_connection_id: this.businessConnectionId, + ...msg?.is_topic_message ? { + message_thread_id: msg.message_thread_id + } : {}, + direct_messages_topic_id: this.msg?.direct_messages_topic?.topic_id, + ...other + }, signal); + } + replyWithVenue(latitude, longitude, title, address, other, signal) { + const msg = this.msg; + return this.api.sendVenue(orThrow(this.chatId, "sendVenue"), latitude, longitude, title, address, { + business_connection_id: this.businessConnectionId, + ...msg?.is_topic_message ? { + message_thread_id: msg.message_thread_id + } : {}, + direct_messages_topic_id: msg?.direct_messages_topic?.topic_id, + ...other + }, signal); + } + replyWithContact(phone_number, first_name, other, signal) { + const msg = this.msg; + return this.api.sendContact(orThrow(this.chatId, "sendContact"), phone_number, first_name, { + business_connection_id: this.businessConnectionId, + ...msg?.is_topic_message ? { + message_thread_id: msg.message_thread_id + } : {}, + direct_messages_topic_id: msg?.direct_messages_topic?.topic_id, + ...other + }, signal); + } + replyWithPoll(question, options, other, signal) { + const msg = this.msg; + return this.api.sendPoll(orThrow(this.chatId, "sendPoll"), question, options, { + business_connection_id: this.businessConnectionId, + ...msg?.is_topic_message ? { + message_thread_id: msg.message_thread_id + } : {}, + ...other + }, signal); + } + replyWithChecklist(checklist, other, signal) { + return this.api.sendChecklist(orThrow(this.businessConnectionId, "sendChecklist"), orThrow(this.chatId, "sendChecklist"), checklist, other, signal); + } + editMessageChecklist(checklist, other, signal) { + const msg = orThrow(this.msg, "editMessageChecklist"); + const target = msg.checklist_tasks_done?.checklist_message ?? msg.checklist_tasks_added?.checklist_message ?? msg; + return this.api.editMessageChecklist(orThrow(this.businessConnectionId, "editMessageChecklist"), orThrow(target.chat.id, "editMessageChecklist"), orThrow(target.message_id, "editMessageChecklist"), checklist, other, signal); + } + replyWithDice(emoji, other, signal) { + const msg = this.msg; + return this.api.sendDice(orThrow(this.chatId, "sendDice"), emoji, { + business_connection_id: this.businessConnectionId, + ...msg?.is_topic_message ? { + message_thread_id: msg.message_thread_id + } : {}, + direct_messages_topic_id: msg?.direct_messages_topic?.topic_id, + ...other + }, signal); + } + replyWithChatAction(action, other, signal) { + const msg = this.msg; + return this.api.sendChatAction(orThrow(this.chatId, "sendChatAction"), action, { + business_connection_id: this.businessConnectionId, + message_thread_id: msg?.message_thread_id, + ...other + }, signal); + } + react(reaction, other, signal) { + return this.api.setMessageReaction(orThrow(this.chatId, "setMessageReaction"), orThrow(this.msgId, "setMessageReaction"), typeof reaction === "string" ? [ + { + type: "emoji", + emoji: reaction + } + ] : (Array.isArray(reaction) ? reaction : [ + reaction + ]).map((emoji)=>typeof emoji === "string" ? { + type: "emoji", + emoji + } : emoji), other, signal); + } + getUserProfilePhotos(other, signal) { + return this.api.getUserProfilePhotos(orThrow(this.from, "getUserProfilePhotos").id, other, signal); + } + getUserProfileAudios(other, signal) { + return this.api.getUserProfileAudios(orThrow(this.from, "getUserProfileAudios").id, other, signal); + } + setUserEmojiStatus(other, signal) { + return this.api.setUserEmojiStatus(orThrow(this.from, "setUserEmojiStatus").id, other, signal); + } + getUserChatBoosts(chat_id, signal) { + return this.api.getUserChatBoosts(chat_id ?? orThrow(this.chatId, "getUserChatBoosts"), orThrow(this.from, "getUserChatBoosts").id, signal); + } + getUserGifts(other, signal) { + return this.api.getUserGifts(orThrow(this.from, "getUserGifts").id, other, signal); + } + getChatGifts(other, signal) { + return this.api.getChatGifts(orThrow(this.chatId, "getChatGifts"), other, signal); + } + getBusinessConnection(signal) { + return this.api.getBusinessConnection(orThrow(this.businessConnectionId, "getBusinessConnection"), signal); + } + getFile(signal) { + const m = orThrow(this.msg, "getFile"); + const file = m.photo !== undefined ? m.photo[m.photo.length - 1] : m.animation ?? m.audio ?? m.document ?? m.video ?? m.video_note ?? m.voice ?? m.sticker; + return this.api.getFile(orThrow(file, "getFile").file_id, signal); + } + kickAuthor(...args) { + return this.banAuthor(...args); + } + banAuthor(other, signal) { + return this.api.banChatMember(orThrow(this.chatId, "banAuthor"), orThrow(this.from, "banAuthor").id, other, signal); + } + kickChatMember(...args) { + return this.banChatMember(...args); + } + banChatMember(user_id, other, signal) { + return this.api.banChatMember(orThrow(this.chatId, "banChatMember"), user_id, other, signal); + } + unbanChatMember(user_id, other, signal) { + return this.api.unbanChatMember(orThrow(this.chatId, "unbanChatMember"), user_id, other, signal); + } + restrictAuthor(permissions, other, signal) { + return this.api.restrictChatMember(orThrow(this.chatId, "restrictAuthor"), orThrow(this.from, "restrictAuthor").id, permissions, other, signal); + } + restrictChatMember(user_id, permissions, other, signal) { + return this.api.restrictChatMember(orThrow(this.chatId, "restrictChatMember"), user_id, permissions, other, signal); + } + promoteAuthor(other, signal) { + return this.api.promoteChatMember(orThrow(this.chatId, "promoteAuthor"), orThrow(this.from, "promoteAuthor").id, other, signal); + } + promoteChatMember(user_id, other, signal) { + return this.api.promoteChatMember(orThrow(this.chatId, "promoteChatMember"), user_id, other, signal); + } + setChatAdministratorAuthorCustomTitle(custom_title, signal) { + return this.api.setChatAdministratorCustomTitle(orThrow(this.chatId, "setChatAdministratorAuthorCustomTitle"), orThrow(this.from, "setChatAdministratorAuthorCustomTitle").id, custom_title, signal); + } + setChatAdministratorCustomTitle(user_id, custom_title, signal) { + return this.api.setChatAdministratorCustomTitle(orThrow(this.chatId, "setChatAdministratorCustomTitle"), user_id, custom_title, signal); + } + banChatSenderChat(sender_chat_id, signal) { + return this.api.banChatSenderChat(orThrow(this.chatId, "banChatSenderChat"), sender_chat_id, signal); + } + unbanChatSenderChat(sender_chat_id, signal) { + return this.api.unbanChatSenderChat(orThrow(this.chatId, "unbanChatSenderChat"), sender_chat_id, signal); + } + setChatPermissions(permissions, other, signal) { + return this.api.setChatPermissions(orThrow(this.chatId, "setChatPermissions"), permissions, other, signal); + } + exportChatInviteLink(signal) { + return this.api.exportChatInviteLink(orThrow(this.chatId, "exportChatInviteLink"), signal); + } + createChatInviteLink(other, signal) { + return this.api.createChatInviteLink(orThrow(this.chatId, "createChatInviteLink"), other, signal); + } + editChatInviteLink(invite_link, other, signal) { + return this.api.editChatInviteLink(orThrow(this.chatId, "editChatInviteLink"), invite_link, other, signal); + } + createChatSubscriptionInviteLink(subscription_period, subscription_price, other, signal) { + return this.api.createChatSubscriptionInviteLink(orThrow(this.chatId, "createChatSubscriptionInviteLink"), subscription_period, subscription_price, other, signal); + } + editChatSubscriptionInviteLink(invite_link, other, signal) { + return this.api.editChatSubscriptionInviteLink(orThrow(this.chatId, "editChatSubscriptionInviteLink"), invite_link, other, signal); + } + revokeChatInviteLink(invite_link, signal) { + return this.api.revokeChatInviteLink(orThrow(this.chatId, "editChatInviteLink"), invite_link, signal); + } + approveChatJoinRequest(user_id, signal) { + return this.api.approveChatJoinRequest(orThrow(this.chatId, "approveChatJoinRequest"), user_id, signal); + } + declineChatJoinRequest(user_id, signal) { + return this.api.declineChatJoinRequest(orThrow(this.chatId, "declineChatJoinRequest"), user_id, signal); + } + approveSuggestedPost(other, signal) { + return this.api.approveSuggestedPost(orThrow(this.chatId, "approveSuggestedPost"), orThrow(this.msgId, "approveSuggestedPost"), other, signal); + } + declineSuggestedPost(other, signal) { + return this.api.declineSuggestedPost(orThrow(this.chatId, "declineSuggestedPost"), orThrow(this.msgId, "declineSuggestedPost"), other, signal); + } + setChatPhoto(photo, signal) { + return this.api.setChatPhoto(orThrow(this.chatId, "setChatPhoto"), photo, signal); + } + deleteChatPhoto(signal) { + return this.api.deleteChatPhoto(orThrow(this.chatId, "deleteChatPhoto"), signal); + } + setChatTitle(title, signal) { + return this.api.setChatTitle(orThrow(this.chatId, "setChatTitle"), title, signal); + } + setChatDescription(description, signal) { + return this.api.setChatDescription(orThrow(this.chatId, "setChatDescription"), description, signal); + } + pinChatMessage(message_id, other, signal) { + return this.api.pinChatMessage(orThrow(this.chatId, "pinChatMessage"), message_id, { + business_connection_id: this.businessConnectionId, + ...other + }, signal); + } + unpinChatMessage(message_id, other, signal) { + return this.api.unpinChatMessage(orThrow(this.chatId, "unpinChatMessage"), message_id, { + business_connection_id: this.businessConnectionId, + ...other + }, signal); + } + unpinAllChatMessages(signal) { + return this.api.unpinAllChatMessages(orThrow(this.chatId, "unpinAllChatMessages"), signal); + } + leaveChat(signal) { + return this.api.leaveChat(orThrow(this.chatId, "leaveChat"), signal); + } + getChat(signal) { + return this.api.getChat(orThrow(this.chatId, "getChat"), signal); + } + getChatAdministrators(signal) { + return this.api.getChatAdministrators(orThrow(this.chatId, "getChatAdministrators"), signal); + } + getChatMembersCount(...args) { + return this.getChatMemberCount(...args); + } + getChatMemberCount(signal) { + return this.api.getChatMemberCount(orThrow(this.chatId, "getChatMemberCount"), signal); + } + getAuthor(signal) { + return this.api.getChatMember(orThrow(this.chatId, "getAuthor"), orThrow(this.from, "getAuthor").id, signal); + } + getChatMember(user_id, signal) { + return this.api.getChatMember(orThrow(this.chatId, "getChatMember"), user_id, signal); + } + setChatStickerSet(sticker_set_name, signal) { + return this.api.setChatStickerSet(orThrow(this.chatId, "setChatStickerSet"), sticker_set_name, signal); + } + deleteChatStickerSet(signal) { + return this.api.deleteChatStickerSet(orThrow(this.chatId, "deleteChatStickerSet"), signal); + } + createForumTopic(name, other, signal) { + return this.api.createForumTopic(orThrow(this.chatId, "createForumTopic"), name, other, signal); + } + editForumTopic(other, signal) { + const message = orThrow(this.msg, "editForumTopic"); + const thread = orThrow(message.message_thread_id, "editForumTopic"); + return this.api.editForumTopic(message.chat.id, thread, other, signal); + } + closeForumTopic(signal) { + const message = orThrow(this.msg, "closeForumTopic"); + const thread = orThrow(message.message_thread_id, "closeForumTopic"); + return this.api.closeForumTopic(message.chat.id, thread, signal); + } + reopenForumTopic(signal) { + const message = orThrow(this.msg, "reopenForumTopic"); + const thread = orThrow(message.message_thread_id, "reopenForumTopic"); + return this.api.reopenForumTopic(message.chat.id, thread, signal); + } + deleteForumTopic(signal) { + const message = orThrow(this.msg, "deleteForumTopic"); + const thread = orThrow(message.message_thread_id, "deleteForumTopic"); + return this.api.deleteForumTopic(message.chat.id, thread, signal); + } + unpinAllForumTopicMessages(signal) { + const message = orThrow(this.msg, "unpinAllForumTopicMessages"); + const thread = orThrow(message.message_thread_id, "unpinAllForumTopicMessages"); + return this.api.unpinAllForumTopicMessages(message.chat.id, thread, signal); + } + editGeneralForumTopic(name, signal) { + return this.api.editGeneralForumTopic(orThrow(this.chatId, "editGeneralForumTopic"), name, signal); + } + closeGeneralForumTopic(signal) { + return this.api.closeGeneralForumTopic(orThrow(this.chatId, "closeGeneralForumTopic"), signal); + } + reopenGeneralForumTopic(signal) { + return this.api.reopenGeneralForumTopic(orThrow(this.chatId, "reopenGeneralForumTopic"), signal); + } + hideGeneralForumTopic(signal) { + return this.api.hideGeneralForumTopic(orThrow(this.chatId, "hideGeneralForumTopic"), signal); + } + unhideGeneralForumTopic(signal) { + return this.api.unhideGeneralForumTopic(orThrow(this.chatId, "unhideGeneralForumTopic"), signal); + } + unpinAllGeneralForumTopicMessages(signal) { + return this.api.unpinAllGeneralForumTopicMessages(orThrow(this.chatId, "unpinAllGeneralForumTopicMessages"), signal); + } + answerCallbackQuery(other, signal) { + return this.api.answerCallbackQuery(orThrow(this.callbackQuery, "answerCallbackQuery").id, typeof other === "string" ? { + text: other + } : other, signal); + } + setChatMenuButton(other, signal) { + return this.api.setChatMenuButton(other, signal); + } + getChatMenuButton(other, signal) { + return this.api.getChatMenuButton(other, signal); + } + setMyDefaultAdministratorRights(other, signal) { + return this.api.setMyDefaultAdministratorRights(other, signal); + } + getMyDefaultAdministratorRights(other, signal) { + return this.api.getMyDefaultAdministratorRights(other, signal); + } + editMessageText(text, other, signal) { + const inlineId = this.inlineMessageId; + return inlineId !== undefined ? this.api.editMessageTextInline(inlineId, text, { + business_connection_id: this.businessConnectionId, + ...other + }, signal) : this.api.editMessageText(orThrow(this.chatId, "editMessageText"), orThrow(this.msg?.message_id ?? this.messageReaction?.message_id ?? this.messageReactionCount?.message_id, "editMessageText"), text, { + business_connection_id: this.businessConnectionId, + ...other + }, signal); + } + editMessageCaption(other, signal) { + const inlineId = this.inlineMessageId; + return inlineId !== undefined ? this.api.editMessageCaptionInline(inlineId, { + business_connection_id: this.businessConnectionId, + ...other + }, signal) : this.api.editMessageCaption(orThrow(this.chatId, "editMessageCaption"), orThrow(this.msg?.message_id ?? this.messageReaction?.message_id ?? this.messageReactionCount?.message_id, "editMessageCaption"), { + business_connection_id: this.businessConnectionId, + ...other + }, signal); + } + editMessageMedia(media, other, signal) { + const inlineId = this.inlineMessageId; + return inlineId !== undefined ? this.api.editMessageMediaInline(inlineId, media, { + business_connection_id: this.businessConnectionId, + ...other + }, signal) : this.api.editMessageMedia(orThrow(this.chatId, "editMessageMedia"), orThrow(this.msg?.message_id ?? this.messageReaction?.message_id ?? this.messageReactionCount?.message_id, "editMessageMedia"), media, { + business_connection_id: this.businessConnectionId, + ...other + }, signal); + } + editMessageReplyMarkup(other, signal) { + const inlineId = this.inlineMessageId; + return inlineId !== undefined ? this.api.editMessageReplyMarkupInline(inlineId, { + business_connection_id: this.businessConnectionId, + ...other + }, signal) : this.api.editMessageReplyMarkup(orThrow(this.chatId, "editMessageReplyMarkup"), orThrow(this.msg?.message_id ?? this.messageReaction?.message_id ?? this.messageReactionCount?.message_id, "editMessageReplyMarkup"), { + business_connection_id: this.businessConnectionId, + ...other + }, signal); + } + stopPoll(other, signal) { + return this.api.stopPoll(orThrow(this.chatId, "stopPoll"), orThrow(this.msg?.message_id ?? this.messageReaction?.message_id ?? this.messageReactionCount?.message_id, "stopPoll"), { + business_connection_id: this.businessConnectionId, + ...other + }, signal); + } + deleteMessage(signal) { + return this.api.deleteMessage(orThrow(this.chatId, "deleteMessage"), orThrow(this.msg?.message_id ?? this.messageReaction?.message_id ?? this.messageReactionCount?.message_id, "deleteMessage"), signal); + } + deleteMessages(message_ids, signal) { + return this.api.deleteMessages(orThrow(this.chatId, "deleteMessages"), message_ids, signal); + } + deleteBusinessMessages(message_ids, signal) { + return this.api.deleteBusinessMessages(orThrow(this.businessConnectionId, "deleteBusinessMessages"), message_ids, signal); + } + setBusinessAccountName(first_name, other, signal) { + return this.api.setBusinessAccountName(orThrow(this.businessConnectionId, "setBusinessAccountName"), first_name, other, signal); + } + setBusinessAccountUsername(username, signal) { + return this.api.setBusinessAccountUsername(orThrow(this.businessConnectionId, "setBusinessAccountUsername"), username, signal); + } + setBusinessAccountBio(bio, signal) { + return this.api.setBusinessAccountBio(orThrow(this.businessConnectionId, "setBusinessAccountBio"), bio, signal); + } + setBusinessAccountProfilePhoto(photo, other, signal) { + return this.api.setBusinessAccountProfilePhoto(orThrow(this.businessConnectionId, "setBusinessAccountProfilePhoto"), photo, other, signal); + } + removeBusinessAccountProfilePhoto(other, signal) { + return this.api.removeBusinessAccountProfilePhoto(orThrow(this.businessConnectionId, "removeBusinessAccountProfilePhoto"), other, signal); + } + setBusinessAccountGiftSettings(show_gift_button, accepted_gift_types, signal) { + return this.api.setBusinessAccountGiftSettings(orThrow(this.businessConnectionId, "setBusinessAccountGiftSettings"), show_gift_button, accepted_gift_types, signal); + } + getBusinessAccountStarBalance(signal) { + return this.api.getBusinessAccountStarBalance(orThrow(this.businessConnectionId, "getBusinessAccountStarBalance"), signal); + } + transferBusinessAccountStars(star_count, signal) { + return this.api.transferBusinessAccountStars(orThrow(this.businessConnectionId, "transferBusinessAccountStars"), star_count, signal); + } + getBusinessAccountGifts(other, signal) { + return this.api.getBusinessAccountGifts(orThrow(this.businessConnectionId, "getBusinessAccountGifts"), other, signal); + } + convertGiftToStars(owned_gift_id, signal) { + return this.api.convertGiftToStars(orThrow(this.businessConnectionId, "convertGiftToStars"), owned_gift_id, signal); + } + upgradeGift(owned_gift_id, other, signal) { + return this.api.upgradeGift(orThrow(this.businessConnectionId, "upgradeGift"), owned_gift_id, other, signal); + } + transferGift(owned_gift_id, new_owner_chat_id, star_count, signal) { + return this.api.transferGift(orThrow(this.businessConnectionId, "transferGift"), owned_gift_id, new_owner_chat_id, star_count, signal); + } + postStory(content, active_period, other, signal) { + return this.api.postStory(orThrow(this.businessConnectionId, "postStory"), content, active_period, other, signal); + } + repostStory(active_period, other, signal) { + const story = orThrow(this.msg?.story, "repostStory"); + return this.api.repostStory(orThrow(this.businessConnectionId, "repostStory"), story.chat.id, story.id, active_period, other, signal); + } + editStory(story_id, content, other, signal) { + return this.api.editStory(orThrow(this.businessConnectionId, "editStory"), story_id, content, other, signal); + } + deleteStory(story_id, signal) { + return this.api.deleteStory(orThrow(this.businessConnectionId, "deleteStory"), story_id, signal); + } + replyWithSticker(sticker, other, signal) { + const msg = this.msg; + return this.api.sendSticker(orThrow(this.chatId, "sendSticker"), sticker, { + business_connection_id: this.businessConnectionId, + ...msg?.is_topic_message ? { + message_thread_id: msg.message_thread_id + } : {}, + direct_messages_topic_id: msg?.direct_messages_topic?.topic_id, + ...other + }, signal); + } + getCustomEmojiStickers(signal) { + return this.api.getCustomEmojiStickers((this.msg?.entities ?? []).filter((e)=>e.type === "custom_emoji").map((e)=>e.custom_emoji_id), signal); + } + replyWithGift(gift_id, other, signal) { + return this.api.sendGift(orThrow(this.from, "sendGift").id, gift_id, other, signal); + } + giftPremiumSubscription(month_count, star_count, other, signal) { + return this.api.giftPremiumSubscription(orThrow(this.from, "giftPremiumSubscription").id, month_count, star_count, other, signal); + } + replyWithGiftToChannel(gift_id, other, signal) { + return this.api.sendGiftToChannel(orThrow(this.chat, "sendGift").id, gift_id, other, signal); + } + answerInlineQuery(results, other, signal) { + return this.api.answerInlineQuery(orThrow(this.inlineQuery, "answerInlineQuery").id, results, other, signal); + } + savePreparedInlineMessage(result, other, signal) { + return this.api.savePreparedInlineMessage(orThrow(this.from, "savePreparedInlineMessage").id, result, other, signal); + } + replyWithInvoice(title, description, payload, currency, prices, other, signal) { + const msg = this.msg; + return this.api.sendInvoice(orThrow(this.chatId, "sendInvoice"), title, description, payload, currency, prices, { + ...msg?.is_topic_message ? { + message_thread_id: msg.message_thread_id + } : {}, + direct_messages_topic_id: msg?.direct_messages_topic?.topic_id, + ...other + }, signal); + } + answerShippingQuery(ok, other, signal) { + return this.api.answerShippingQuery(orThrow(this.shippingQuery, "answerShippingQuery").id, ok, other, signal); + } + answerPreCheckoutQuery(ok, other, signal) { + return this.api.answerPreCheckoutQuery(orThrow(this.preCheckoutQuery, "answerPreCheckoutQuery").id, ok, typeof other === "string" ? { + error_message: other + } : other, signal); + } + refundStarPayment(signal) { + return this.api.refundStarPayment(orThrow(this.from, "refundStarPayment").id, orThrow(this.msg?.successful_payment, "refundStarPayment").telegram_payment_charge_id, signal); + } + editUserStarSubscription(telegram_payment_charge_id, is_canceled, signal) { + return this.api.editUserStarSubscription(orThrow(this.from, "editUserStarSubscription").id, telegram_payment_charge_id, is_canceled, signal); + } + verifyUser(other, signal) { + return this.api.verifyUser(orThrow(this.from, "verifyUser").id, other, signal); + } + verifyChat(other, signal) { + return this.api.verifyChat(orThrow(this.chatId, "verifyChat"), other, signal); + } + removeUserVerification(signal) { + return this.api.removeUserVerification(orThrow(this.from, "removeUserVerification").id, signal); + } + removeChatVerification(signal) { + return this.api.removeChatVerification(orThrow(this.chatId, "removeChatVerification"), signal); + } + readBusinessMessage(signal) { + return this.api.readBusinessMessage(orThrow(this.businessConnectionId, "readBusinessMessage"), orThrow(this.chatId, "readBusinessMessage"), orThrow(this.msgId, "readBusinessMessage"), signal); + } + setPassportDataErrors(errors, signal) { + return this.api.setPassportDataErrors(orThrow(this.from, "setPassportDataErrors").id, errors, signal); + } + replyWithGame(game_short_name, other, signal) { + const msg = this.msg; + return this.api.sendGame(orThrow(this.chatId, "sendGame"), game_short_name, { + business_connection_id: this.businessConnectionId, + ...msg?.is_topic_message ? { + message_thread_id: msg.message_thread_id + } : {}, + ...other + }, signal); + } +} +function orThrow(value, method) { + if (value === undefined) { + throw new Error(`Missing information for API call to ${method}`); + } + return value; +} +function triggerFn(trigger) { + return toArray(trigger).map((t)=>typeof t === "string" ? (txt)=>txt === t ? t : null : (txt)=>txt.match(t)); +} +function match(ctx, content, triggers) { + for (const t of triggers){ + const res = t(content); + if (res) { + ctx.match = res; + return true; + } + } + return false; +} +function toArray(e) { + return Array.isArray(e) ? e : [ + e + ]; +} +class BotError extends Error { + error; + ctx; + constructor(error, ctx){ + super(generateBotErrorMessage(error)); + this.error = error; + this.ctx = ctx; + this.name = "BotError"; + if (error instanceof Error) this.stack = error.stack; + } +} +function generateBotErrorMessage(error) { + let msg; + if (error instanceof Error) { + msg = `${error.name} in middleware: ${error.message}`; + } else { + const type = typeof error; + msg = `Non-error value of type ${type} thrown in middleware`; + switch(type){ + case "bigint": + case "boolean": + case "number": + case "symbol": + msg += `: ${error}`; + break; + case "string": + msg += `: ${String(error).substring(0, 50)}`; + break; + default: + msg += "!"; + break; + } + } + return msg; +} +function flatten(mw) { + return typeof mw === "function" ? mw : (ctx, next)=>mw.middleware()(ctx, next); +} +function concat1(first, andThen) { + return async (ctx, next)=>{ + let nextCalled = false; + await first(ctx, async ()=>{ + if (nextCalled) throw new Error("`next` already called before!"); + else nextCalled = true; + await andThen(ctx, next); + }); + }; +} +function pass(_ctx, next) { + return next(); +} +const leaf1 = ()=>Promise.resolve(); +async function run(middleware, ctx) { + await middleware(ctx, leaf1); +} +class Composer { + handler; + constructor(...middleware){ + this.handler = middleware.length === 0 ? pass : middleware.map(flatten).reduce(concat1); + } + middleware() { + return this.handler; + } + use(...middleware) { + const composer = new Composer(...middleware); + this.handler = concat1(this.handler, flatten(composer)); + return composer; + } + on(filter, ...middleware) { + return this.filter(Context.has.filterQuery(filter), ...middleware); + } + hears(trigger, ...middleware) { + return this.filter(Context.has.text(trigger), ...middleware); + } + command(command, ...middleware) { + return this.filter(Context.has.command(command), ...middleware); + } + reaction(reaction, ...middleware) { + return this.filter(Context.has.reaction(reaction), ...middleware); + } + chatType(chatType, ...middleware) { + return this.filter(Context.has.chatType(chatType), ...middleware); + } + callbackQuery(trigger, ...middleware) { + return this.filter(Context.has.callbackQuery(trigger), ...middleware); + } + gameQuery(trigger, ...middleware) { + return this.filter(Context.has.gameQuery(trigger), ...middleware); + } + inlineQuery(trigger, ...middleware) { + return this.filter(Context.has.inlineQuery(trigger), ...middleware); + } + chosenInlineResult(resultId, ...middleware) { + return this.filter(Context.has.chosenInlineResult(resultId), ...middleware); + } + preCheckoutQuery(trigger, ...middleware) { + return this.filter(Context.has.preCheckoutQuery(trigger), ...middleware); + } + shippingQuery(trigger, ...middleware) { + return this.filter(Context.has.shippingQuery(trigger), ...middleware); + } + filter(predicate, ...middleware) { + const composer = new Composer(...middleware); + this.branch(predicate, composer, pass); + return composer; + } + drop(predicate, ...middleware) { + return this.filter(async (ctx)=>!await predicate(ctx), ...middleware); + } + fork(...middleware) { + const composer = new Composer(...middleware); + const fork = flatten(composer); + this.use((ctx, next)=>Promise.all([ + next(), + run(fork, ctx) + ])); + return composer; + } + lazy(middlewareFactory) { + return this.use(async (ctx, next)=>{ + const middleware = await middlewareFactory(ctx); + const arr = Array.isArray(middleware) ? middleware : [ + middleware + ]; + await flatten(new Composer(...arr))(ctx, next); + }); + } + route(router, routeHandlers, fallback = pass) { + return this.lazy(async (ctx)=>{ + const route = await router(ctx); + return (route === undefined || !routeHandlers[route] ? fallback : routeHandlers[route]) ?? []; + }); + } + branch(predicate, trueMiddleware, falseMiddleware) { + return this.lazy(async (ctx)=>await predicate(ctx) ? trueMiddleware : falseMiddleware); + } + errorBoundary(errorHandler, ...middleware) { + const composer = new Composer(...middleware); + const bound = flatten(composer); + this.use(async (ctx, next)=>{ + let nextCalled = false; + const cont = ()=>(nextCalled = true, Promise.resolve()); + try { + await bound(ctx, cont); + } catch (err) { + nextCalled = false; + await errorHandler(new BotError(err, ctx), cont); + } + if (nextCalled) await next(); + }); + return composer; + } +} +var s = 1e3; +var m = s * 60; +var h = m * 60; +var d = h * 24; +var w = d * 7; +var y = d * 365.25; +var ms = function(val, options) { + options = options || {}; + var type = typeof val; + if (type === "string" && val.length > 0) { + return parse1(val); + } else if (type === "number" && isFinite(val)) { + return options.long ? fmtLong(val) : fmtShort(val); + } + throw new Error("val is not a non-empty string or a valid number. val=" + JSON.stringify(val)); +}; +function parse1(str) { + str = String(str); + if (str.length > 100) { + return; + } + var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(str); + if (!match) { + return; + } + var n = parseFloat(match[1]); + var type = (match[2] || "ms").toLowerCase(); + switch(type){ + case "years": + case "year": + case "yrs": + case "yr": + case "y": + return n * y; + case "weeks": + case "week": + case "w": + return n * w; + case "days": + case "day": + case "d": + return n * d; + case "hours": + case "hour": + case "hrs": + case "hr": + case "h": + return n * h; + case "minutes": + case "minute": + case "mins": + case "min": + case "m": + return n * m; + case "seconds": + case "second": + case "secs": + case "sec": + case "s": + return n * s; + case "milliseconds": + case "millisecond": + case "msecs": + case "msec": + case "ms": + return n; + default: + return void 0; + } +} +function fmtShort(ms2) { + var msAbs = Math.abs(ms2); + if (msAbs >= d) { + return Math.round(ms2 / d) + "d"; + } + if (msAbs >= h) { + return Math.round(ms2 / h) + "h"; + } + if (msAbs >= m) { + return Math.round(ms2 / m) + "m"; + } + if (msAbs >= s) { + return Math.round(ms2 / s) + "s"; + } + return ms2 + "ms"; +} +function fmtLong(ms2) { + var msAbs = Math.abs(ms2); + if (msAbs >= d) { + return plural(ms2, msAbs, d, "day"); + } + if (msAbs >= h) { + return plural(ms2, msAbs, h, "hour"); + } + if (msAbs >= m) { + return plural(ms2, msAbs, m, "minute"); + } + if (msAbs >= s) { + return plural(ms2, msAbs, s, "second"); + } + return ms2 + " ms"; +} +function plural(ms2, msAbs, n, name) { + var isPlural = msAbs >= n * 1.5; + return Math.round(ms2 / n) + " " + name + (isPlural ? "s" : ""); +} +function defaultSetTimout() { + throw new Error("setTimeout has not been defined"); +} +function defaultClearTimeout() { + throw new Error("clearTimeout has not been defined"); +} +var cachedSetTimeout = defaultSetTimout; +var cachedClearTimeout = defaultClearTimeout; +var globalContext; +if (typeof window !== "undefined") { + globalContext = window; +} else if (typeof self !== "undefined") { + globalContext = self; +} else { + globalContext = {}; +} +if (typeof globalContext.setTimeout === "function") { + cachedSetTimeout = setTimeout; +} +if (typeof globalContext.clearTimeout === "function") { + cachedClearTimeout = clearTimeout; +} +function runTimeout(fun) { + if (cachedSetTimeout === setTimeout) { + return setTimeout(fun, 0); + } + if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { + cachedSetTimeout = setTimeout; + return setTimeout(fun, 0); + } + try { + return cachedSetTimeout(fun, 0); + } catch (e) { + try { + return cachedSetTimeout.call(null, fun, 0); + } catch (e2) { + return cachedSetTimeout.call(this, fun, 0); + } + } +} +function runClearTimeout(marker) { + if (cachedClearTimeout === clearTimeout) { + return clearTimeout(marker); + } + if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { + cachedClearTimeout = clearTimeout; + return clearTimeout(marker); + } + try { + return cachedClearTimeout(marker); + } catch (e) { + try { + return cachedClearTimeout.call(null, marker); + } catch (e2) { + return cachedClearTimeout.call(this, marker); + } + } +} +var queue = []; +var draining = false; +var currentQueue; +var queueIndex = -1; +function cleanUpNextTick() { + if (!draining || !currentQueue) { + return; + } + draining = false; + if (currentQueue.length) { + queue = currentQueue.concat(queue); + } else { + queueIndex = -1; + } + if (queue.length) { + drainQueue(); + } +} +function drainQueue() { + if (draining) { + return; + } + var timeout = runTimeout(cleanUpNextTick); + draining = true; + var len = queue.length; + while(len){ + currentQueue = queue; + queue = []; + while(++queueIndex < len){ + if (currentQueue) { + currentQueue[queueIndex].run(); + } + } + queueIndex = -1; + len = queue.length; + } + currentQueue = null; + draining = false; + runClearTimeout(timeout); +} +function nextTick(fun) { + var args = new Array(arguments.length - 1); + if (arguments.length > 1) { + for(var i = 1; i < arguments.length; i++){ + args[i - 1] = arguments[i]; + } + } + queue.push(new Item(fun, args)); + if (queue.length === 1 && !draining) { + runTimeout(drainQueue); + } +} +function Item(fun, array) { + this.fun = fun; + this.array = array; +} +Item.prototype.run = function() { + this.fun.apply(null, this.array); +}; +var title = "browser"; +var platform = "browser"; +var browser = true; +var argv = []; +var version = ""; +var versions = {}; +var release = {}; +var config = {}; +function noop() {} +var on = noop; +var addListener = noop; +var once = noop; +var off = noop; +var removeListener = noop; +var removeAllListeners = noop; +var emit = noop; +function binding(name) { + throw new Error("process.binding is not supported"); +} +function cwd() { + return "/"; +} +function chdir(dir) { + throw new Error("process.chdir is not supported"); +} +function umask() { + return 0; +} +var performance = globalContext.performance || {}; +var performanceNow = performance.now || performance.mozNow || performance.msNow || performance.oNow || performance.webkitNow || function() { + return new Date().getTime(); +}; +function hrtime(previousTimestamp) { + var clocktime = performanceNow.call(performance) * 1e-3; + var seconds = Math.floor(clocktime); + var nanoseconds = Math.floor(clocktime % 1 * 1e9); + if (previousTimestamp) { + seconds = seconds - previousTimestamp[0]; + nanoseconds = nanoseconds - previousTimestamp[1]; + if (nanoseconds < 0) { + seconds--; + nanoseconds += 1e9; + } + } + return [ + seconds, + nanoseconds + ]; +} +var startTime = new Date(); +function uptime() { + var currentTime = new Date(); + var dif = currentTime - startTime; + return dif / 1e3; +} +var process = { + nextTick, + title, + browser, + env: { + NODE_ENV: "production" + }, + argv, + version, + versions, + on, + addListener, + once, + off, + removeListener, + removeAllListeners, + emit, + binding, + cwd, + chdir, + umask, + hrtime, + platform, + release, + config, + uptime +}; +function createCommonjsModule(fn, basedir, module) { + return module = { + path: basedir, + exports: {}, + require: function(path, base) { + return commonjsRequire(path, base === void 0 || base === null ? module.path : base); + } + }, fn(module, module.exports), module.exports; +} +function commonjsRequire() { + throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs"); +} +function setup(env) { + createDebug.debug = createDebug; + createDebug.default = createDebug; + createDebug.coerce = coerce; + createDebug.disable = disable; + createDebug.enable = enable; + createDebug.enabled = enabled; + createDebug.humanize = ms; + createDebug.destroy = destroy2; + Object.keys(env).forEach((key)=>{ + createDebug[key] = env[key]; + }); + createDebug.names = []; + createDebug.skips = []; + createDebug.formatters = {}; + function selectColor(namespace) { + let hash = 0; + for(let i = 0; i < namespace.length; i++){ + hash = (hash << 5) - hash + namespace.charCodeAt(i); + hash |= 0; + } + return createDebug.colors[Math.abs(hash) % createDebug.colors.length]; + } + createDebug.selectColor = selectColor; + function createDebug(namespace) { + let prevTime; + let enableOverride = null; + let namespacesCache; + let enabledCache; + function debug(...args) { + if (!debug.enabled) { + return; + } + const self2 = debug; + const curr = Number(new Date()); + const ms2 = curr - (prevTime || curr); + self2.diff = ms2; + self2.prev = prevTime; + self2.curr = curr; + prevTime = curr; + args[0] = createDebug.coerce(args[0]); + if (typeof args[0] !== "string") { + args.unshift("%O"); + } + let index = 0; + args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format)=>{ + if (match === "%%") { + return "%"; + } + index++; + const formatter = createDebug.formatters[format]; + if (typeof formatter === "function") { + const val = args[index]; + match = formatter.call(self2, val); + args.splice(index, 1); + index--; + } + return match; + }); + createDebug.formatArgs.call(self2, args); + const logFn = self2.log || createDebug.log; + logFn.apply(self2, args); + } + debug.namespace = namespace; + debug.useColors = createDebug.useColors(); + debug.color = createDebug.selectColor(namespace); + debug.extend = extend; + debug.destroy = createDebug.destroy; + Object.defineProperty(debug, "enabled", { + enumerable: true, + configurable: false, + get: ()=>{ + if (enableOverride !== null) { + return enableOverride; + } + if (namespacesCache !== createDebug.namespaces) { + namespacesCache = createDebug.namespaces; + enabledCache = createDebug.enabled(namespace); + } + return enabledCache; + }, + set: (v)=>{ + enableOverride = v; + } + }); + if (typeof createDebug.init === "function") { + createDebug.init(debug); + } + return debug; + } + function extend(namespace, delimiter) { + const newDebug = createDebug(this.namespace + (typeof delimiter === "undefined" ? ":" : delimiter) + namespace); + newDebug.log = this.log; + return newDebug; + } + function enable(namespaces) { + createDebug.save(namespaces); + createDebug.namespaces = namespaces; + createDebug.names = []; + createDebug.skips = []; + const split = (typeof namespaces === "string" ? namespaces : "").trim().replace(/\s+/g, ",").split(",").filter(Boolean); + for (const ns of split){ + if (ns[0] === "-") { + createDebug.skips.push(ns.slice(1)); + } else { + createDebug.names.push(ns); + } + } + } + function matchesTemplate(search, template) { + let searchIndex = 0; + let templateIndex = 0; + let starIndex = -1; + let matchIndex = 0; + while(searchIndex < search.length){ + if (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === "*")) { + if (template[templateIndex] === "*") { + starIndex = templateIndex; + matchIndex = searchIndex; + templateIndex++; + } else { + searchIndex++; + templateIndex++; + } + } else if (starIndex !== -1) { + templateIndex = starIndex + 1; + matchIndex++; + searchIndex = matchIndex; + } else { + return false; + } + } + while(templateIndex < template.length && template[templateIndex] === "*"){ + templateIndex++; + } + return templateIndex === template.length; + } + function disable() { + const namespaces = [ + ...createDebug.names, + ...createDebug.skips.map((namespace)=>"-" + namespace) + ].join(","); + createDebug.enable(""); + return namespaces; + } + function enabled(name) { + for (const skip of createDebug.skips){ + if (matchesTemplate(name, skip)) { + return false; + } + } + for (const ns of createDebug.names){ + if (matchesTemplate(name, ns)) { + return true; + } + } + return false; + } + function coerce(val) { + if (val instanceof Error) { + return val.stack || val.message; + } + return val; + } + function destroy2() { + console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."); + } + createDebug.enable(createDebug.load()); + return createDebug; +} +var common = setup; +var browser$1 = createCommonjsModule(function(module, exports) { + exports.formatArgs = formatArgs2; + exports.save = save2; + exports.load = load2; + exports.useColors = useColors2; + exports.storage = localstorage(); + exports.destroy = (()=>{ + let warned = false; + return ()=>{ + if (!warned) { + warned = true; + console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."); + } + }; + })(); + exports.colors = [ + "#0000CC", + "#0000FF", + "#0033CC", + "#0033FF", + "#0066CC", + "#0066FF", + "#0099CC", + "#0099FF", + "#00CC00", + "#00CC33", + "#00CC66", + "#00CC99", + "#00CCCC", + "#00CCFF", + "#3300CC", + "#3300FF", + "#3333CC", + "#3333FF", + "#3366CC", + "#3366FF", + "#3399CC", + "#3399FF", + "#33CC00", + "#33CC33", + "#33CC66", + "#33CC99", + "#33CCCC", + "#33CCFF", + "#6600CC", + "#6600FF", + "#6633CC", + "#6633FF", + "#66CC00", + "#66CC33", + "#9900CC", + "#9900FF", + "#9933CC", + "#9933FF", + "#99CC00", + "#99CC33", + "#CC0000", + "#CC0033", + "#CC0066", + "#CC0099", + "#CC00CC", + "#CC00FF", + "#CC3300", + "#CC3333", + "#CC3366", + "#CC3399", + "#CC33CC", + "#CC33FF", + "#CC6600", + "#CC6633", + "#CC9900", + "#CC9933", + "#CCCC00", + "#CCCC33", + "#FF0000", + "#FF0033", + "#FF0066", + "#FF0099", + "#FF00CC", + "#FF00FF", + "#FF3300", + "#FF3333", + "#FF3366", + "#FF3399", + "#FF33CC", + "#FF33FF", + "#FF6600", + "#FF6633", + "#FF9900", + "#FF9933", + "#FFCC00", + "#FFCC33" + ]; + function useColors2() { + if (typeof window !== "undefined" && window.process && (window.process.type === "renderer" || window.process.__nwjs)) { + return true; + } + if (typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) { + return false; + } + let m; + return typeof document !== "undefined" && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || typeof window !== "undefined" && window.console && (window.console.firebug || window.console.exception && window.console.table) || typeof navigator !== "undefined" && navigator.userAgent && (m = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) && parseInt(m[1], 10) >= 31 || typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/); + } + function formatArgs2(args) { + args[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + args[0] + (this.useColors ? "%c " : " ") + "+" + module.exports.humanize(this.diff); + if (!this.useColors) { + return; + } + const c = "color: " + this.color; + args.splice(1, 0, c, "color: inherit"); + let index = 0; + let lastC = 0; + args[0].replace(/%[a-zA-Z%]/g, (match)=>{ + if (match === "%%") { + return; + } + index++; + if (match === "%c") { + lastC = index; + } + }); + args.splice(lastC, 0, c); + } + exports.log = console.debug || console.log || (()=>{}); + function save2(namespaces) { + try { + if (namespaces) { + exports.storage.setItem("debug", namespaces); + } else { + exports.storage.removeItem("debug"); + } + } catch (error) {} + } + function load2() { + let r; + try { + r = exports.storage.getItem("debug") || exports.storage.getItem("DEBUG"); + } catch (error) {} + if (!r && typeof process !== "undefined" && "env" in process) { + r = process.env.DEBUG; + } + return r; + } + function localstorage() { + try { + return localStorage; + } catch (error) {} + } + module.exports = common(exports); + const { formatters } = module.exports; + formatters.j = function(v) { + try { + return JSON.stringify(v); + } catch (error) { + return "[UnexpectedJSONParseError]: " + error.message; + } + }; +}); +browser$1.colors; +browser$1.destroy; +browser$1.formatArgs; +browser$1.load; +browser$1.log; +browser$1.save; +browser$1.storage; +browser$1.useColors; +const itrToStream = (itr)=>{ + const it = itr[Symbol.asyncIterator](); + return new ReadableStream({ + async pull (controller) { + const chunk = await it.next(); + if (chunk.done) controller.close(); + else controller.enqueue(chunk.value); + } + }); +}; +const baseFetchConfig = (_apiRoot)=>({}); +const defaultAdapter = "cloudflare"; +const debug = browser$1("grammy:warn"); +class GrammyError extends Error { + method; + payload; + ok; + error_code; + description; + parameters; + constructor(message, err, method, payload){ + super(`${message} (${err.error_code}: ${err.description})`); + this.method = method; + this.payload = payload; + this.ok = false; + this.name = "GrammyError"; + this.error_code = err.error_code; + this.description = err.description; + this.parameters = err.parameters ?? {}; + } +} +function toGrammyError(err, method, payload) { + switch(err.error_code){ + case 401: + debug("Error 401 means that your bot token is wrong, talk to https://t.me/BotFather to check it."); + break; + case 409: + debug("Error 409 means that you are running your bot several times on long polling. Consider revoking the bot token if you believe that no other instance is running."); + break; + } + return new GrammyError(`Call to '${method}' failed!`, err, method, payload); +} +class HttpError extends Error { + error; + constructor(message, error){ + super(message); + this.error = error; + this.name = "HttpError"; + } +} +function isTelegramError(err) { + return typeof err === "object" && err !== null && "status" in err && "statusText" in err; +} +function toHttpError(method, sensitiveLogs) { + return (err)=>{ + let msg = `Network request for '${method}' failed!`; + if (isTelegramError(err)) msg += ` (${err.status}: ${err.statusText})`; + if (sensitiveLogs && err instanceof Error) msg += ` ${err.message}`; + throw new HttpError(msg, err); + }; +} +function checkWindows() { + const global = globalThis; + const os = global.Deno?.build?.os; + return typeof os === "string" ? os === "windows" : global.navigator?.platform?.startsWith("Win") ?? global.process?.platform?.startsWith("win") ?? false; +} +const isWindows = checkWindows(); +function assertPath(path) { + if (typeof path !== "string") { + throw new TypeError(`Path must be a string, received "${JSON.stringify(path)}"`); + } +} +function stripSuffix(name, suffix) { + if (suffix.length >= name.length) { + return name; + } + const lenDiff = name.length - suffix.length; + for(let i = suffix.length - 1; i >= 0; --i){ + if (name.charCodeAt(lenDiff + i) !== suffix.charCodeAt(i)) { + return name; + } + } + return name.slice(0, -suffix.length); +} +function lastPathSegment(path, isSep, start = 0) { + let matchedNonSeparator = false; + let end = path.length; + for(let i = path.length - 1; i >= start; --i){ + if (isSep(path.charCodeAt(i))) { + if (matchedNonSeparator) { + start = i + 1; + break; + } + } else if (!matchedNonSeparator) { + matchedNonSeparator = true; + end = i + 1; + } + } + return path.slice(start, end); +} +function assertArgs(path, suffix) { + assertPath(path); + if (path.length === 0) return path; + if (typeof suffix !== "string") { + throw new TypeError(`Suffix must be a string, received "${JSON.stringify(suffix)}"`); + } +} +function assertArg(url) { + url = url instanceof URL ? url : new URL(url); + if (url.protocol !== "file:") { + throw new TypeError(`URL must be a file URL: received "${url.protocol}"`); + } + return url; +} +function fromFileUrl(url) { + url = assertArg(url); + return decodeURIComponent(url.pathname.replace(/%(?![0-9A-Fa-f]{2})/g, "%25")); +} +function stripTrailingSeparators(segment, isSep) { + if (segment.length <= 1) { + return segment; + } + let end = segment.length; + for(let i = segment.length - 1; i > 0; i--){ + if (isSep(segment.charCodeAt(i))) { + end = i; + } else { + break; + } + } + return segment.slice(0, end); +} +function isPosixPathSeparator(code) { + return code === 47; +} +function basename(path, suffix = "") { + if (path instanceof URL) { + path = fromFileUrl(path); + } + assertArgs(path, suffix); + const lastSegment = lastPathSegment(path, isPosixPathSeparator); + const strippedSegment = stripTrailingSeparators(lastSegment, isPosixPathSeparator); + return suffix ? stripSuffix(strippedSegment, suffix) : strippedSegment; +} +function isPathSeparator(code) { + return code === 47 || code === 92; +} +function isWindowsDeviceRoot(code) { + return code >= 97 && code <= 122 || code >= 65 && code <= 90; +} +function fromFileUrl1(url) { + url = assertArg(url); + let path = decodeURIComponent(url.pathname.replace(/\//g, "\\").replace(/%(?![0-9A-Fa-f]{2})/g, "%25")).replace(/^\\*([A-Za-z]:)(\\|$)/, "$1\\"); + if (url.hostname !== "") { + path = `\\\\${url.hostname}${path}`; + } + return path; +} +function basename1(path, suffix = "") { + if (path instanceof URL) { + path = fromFileUrl1(path); + } + assertArgs(path, suffix); + let start = 0; + if (path.length >= 2) { + const drive = path.charCodeAt(0); + if (isWindowsDeviceRoot(drive)) { + if (path.charCodeAt(1) === 58) start = 2; + } + } + const lastSegment = lastPathSegment(path, isPathSeparator, start); + const strippedSegment = stripTrailingSeparators(lastSegment, isPathSeparator); + return suffix ? stripSuffix(strippedSegment, suffix) : strippedSegment; +} +function basename2(path, suffix = "") { + return isWindows ? basename1(path, suffix) : basename(path, suffix); +} +class InputFile { + consumed = false; + fileData; + filename; + constructor(file, filename){ + this.fileData = file; + filename ??= this.guessFilename(file); + this.filename = filename; + } + guessFilename(file) { + if (typeof file === "string") return basename2(file); + if (typeof file !== "object") return undefined; + if ("url" in file) return basename2(file.url); + if (!(file instanceof URL)) return undefined; + return basename2(file.pathname) || basename2(file.hostname); + } + toRaw() { + if (this.consumed) { + throw new Error("Cannot reuse InputFile data source!"); + } + const data = this.fileData; + if (data instanceof Blob) return data.stream(); + if (data instanceof URL) return fetchFile(data); + if ("url" in data) return fetchFile(data.url); + if (!(data instanceof Uint8Array)) this.consumed = true; + return data; + } + toJSON() { + throw new Error("InputFile instances must be sent via grammY"); + } +} +async function* fetchFile(url) { + const { body } = await fetch(url); + if (body === null) { + throw new Error(`Download failed, no response body from '${url}'`); + } + yield* body; +} +function requiresFormDataUpload(payload) { + return payload instanceof InputFile || typeof payload === "object" && payload !== null && Object.values(payload).some((v)=>Array.isArray(v) ? v.some(requiresFormDataUpload) : v instanceof InputFile || requiresFormDataUpload(v)); +} +function str(value) { + return JSON.stringify(value, (_, v)=>v ?? undefined); +} +function createJsonPayload(payload) { + return { + method: "POST", + headers: { + "content-type": "application/json", + connection: "keep-alive" + }, + body: str(payload) + }; +} +async function* protectItr(itr, onError) { + try { + yield* itr; + } catch (err) { + onError(err); + } +} +function createFormDataPayload(payload, onError) { + const boundary = createBoundary(); + const itr = payloadToMultipartItr(payload, boundary); + const safeItr = protectItr(itr, onError); + const stream = itrToStream(safeItr); + return { + method: "POST", + headers: { + "content-type": `multipart/form-data; boundary=${boundary}`, + connection: "keep-alive" + }, + body: stream + }; +} +function createBoundary() { + return "----------" + randomId(32); +} +function randomId(length = 16) { + return Array.from(Array(length)).map(()=>Math.random().toString(36)[2] || 0).join(""); +} +const enc = new TextEncoder(); +async function* payloadToMultipartItr(payload, boundary) { + const files = collectFiles(payload); + yield enc.encode(`--${boundary}\r\n`); + const separator = enc.encode(`\r\n--${boundary}\r\n`); + let first = true; + for (const [key, value] of Object.entries(payload)){ + if (value == null) continue; + if (!first) yield separator; + yield valuePart(key, value instanceof InputFile ? value.toJSON() : typeof value === "object" ? str(value) : value); + first = false; + } + for (const { id, origin, file } of files){ + if (!first) yield separator; + yield* filePart(id, origin, file); + first = false; + } + yield enc.encode(`\r\n--${boundary}--\r\n`); +} +function collectFiles(value) { + if (typeof value !== "object" || value === null) return []; + return Object.entries(value).flatMap(([k, v])=>{ + if (Array.isArray(v)) return v.flatMap((p)=>collectFiles(p)); + else if (v instanceof InputFile) { + const id = randomId(); + Object.assign(v, { + toJSON: ()=>`attach://${id}` + }); + const origin = k === "media" && "type" in value && typeof value.type === "string" ? value.type : k; + return { + id, + origin, + file: v + }; + } else return collectFiles(v); + }); +} +function valuePart(key, value) { + return enc.encode(`content-disposition:form-data;name="${key}"\r\n\r\n${value}`); +} +async function* filePart(id, origin, input) { + const filename = input.filename || `${origin}.${getExt(origin)}`; + if (filename.includes("\r") || filename.includes("\n")) { + throw new Error(`File paths cannot contain carriage-return (\\r) \ +or newline (\\n) characters! Filename for property '${origin}' was: +""" +${filename} +"""`); + } + yield enc.encode(`content-disposition:form-data;name="${id}";filename=${filename}\r\ncontent-type:application/octet-stream\r\n\r\n`); + const data = await input.toRaw(); + if (data instanceof Uint8Array) yield data; + else yield* data; +} +function getExt(key) { + switch(key){ + case "certificate": + return "pem"; + case "photo": + case "thumbnail": + return "jpg"; + case "voice": + return "ogg"; + case "audio": + return "mp3"; + case "animation": + case "video": + case "video_note": + return "mp4"; + case "sticker": + return "webp"; + default: + return "dat"; + } +} +const debug1 = browser$1("grammy:core"); +function concatTransformer(prev, trans) { + return (method, payload, signal)=>trans(prev, method, payload, signal); +} +class ApiClient { + token; + webhookReplyEnvelope; + options; + fetch; + hasUsedWebhookReply; + installedTransformers; + constructor(token, options = {}, webhookReplyEnvelope = {}){ + this.token = token; + this.webhookReplyEnvelope = webhookReplyEnvelope; + this.hasUsedWebhookReply = false; + this.installedTransformers = []; + this.call = async (method, p, signal)=>{ + const payload = p ?? {}; + debug1(`Calling ${method}`); + if (signal !== undefined) validateSignal(method, payload, signal); + const opts = this.options; + const formDataRequired = requiresFormDataUpload(payload); + if (this.webhookReplyEnvelope.send !== undefined && !this.hasUsedWebhookReply && !formDataRequired && opts.canUseWebhookReply(method)) { + this.hasUsedWebhookReply = true; + const config = createJsonPayload({ + ...payload, + method + }); + await this.webhookReplyEnvelope.send(config.body); + return { + ok: true, + result: true + }; + } + const controller = createAbortControllerFromSignal(signal); + const timeout = createTimeout(controller, opts.timeoutSeconds, method); + const streamErr = createStreamError(controller); + const url = opts.buildUrl(opts.apiRoot, this.token, method, opts.environment); + const config = formDataRequired ? createFormDataPayload(payload, (err)=>streamErr.catch(err)) : createJsonPayload(payload); + const sig = controller.signal; + const options = { + ...opts.baseFetchConfig, + signal: sig, + ...config + }; + const successPromise = this.fetch(url instanceof URL ? url.href : url, options).catch(toHttpError(method, opts.sensitiveLogs)); + const operations = [ + successPromise, + streamErr.promise, + timeout.promise + ]; + try { + const res = await Promise.race(operations); + return await res.json(); + } finally{ + if (timeout.handle !== undefined) clearTimeout(timeout.handle); + } + }; + const apiRoot = options.apiRoot ?? "https://api.telegram.org"; + const environment = options.environment ?? "prod"; + const { fetch: customFetch } = options; + const fetchFn = customFetch ?? fetch; + this.options = { + apiRoot, + environment, + buildUrl: options.buildUrl ?? defaultBuildUrl, + timeoutSeconds: options.timeoutSeconds ?? 500, + baseFetchConfig: { + ...baseFetchConfig(apiRoot), + ...options.baseFetchConfig + }, + canUseWebhookReply: options.canUseWebhookReply ?? (()=>false), + sensitiveLogs: options.sensitiveLogs ?? false, + fetch: (...args)=>fetchFn(...args) + }; + this.fetch = this.options.fetch; + if (this.options.apiRoot.endsWith("/")) { + throw new Error(`Remove the trailing '/' from the 'apiRoot' option (use '${this.options.apiRoot.substring(0, this.options.apiRoot.length - 1)}' instead of '${this.options.apiRoot}')`); + } + } + call; + use(...transformers) { + this.call = transformers.reduce(concatTransformer, this.call); + this.installedTransformers.push(...transformers); + return this; + } + async callApi(method, payload, signal) { + const data = await this.call(method, payload, signal); + if (data.ok) return data.result; + else throw toGrammyError(data, method, payload); + } +} +function createRawApi(token, options, webhookReplyEnvelope) { + const client = new ApiClient(token, options, webhookReplyEnvelope); + const proxyHandler = { + get (_, m) { + return m === "toJSON" ? "__internal" : m === "getMe" || m === "getWebhookInfo" || m === "getForumTopicIconStickers" || m === "getAvailableGifts" || m === "logOut" || m === "close" || m === "getMyStarBalance" || m === "removeMyProfilePhoto" ? client.callApi.bind(client, m, {}) : client.callApi.bind(client, m); + }, + ...proxyMethods + }; + const raw = new Proxy({}, proxyHandler); + const installedTransformers = client.installedTransformers; + const api = { + raw, + installedTransformers, + use: (...t)=>{ + client.use(...t); + return api; + } + }; + return api; +} +const defaultBuildUrl = (root, token, method, env)=>{ + const prefix = env === "test" ? "test/" : ""; + return `${root}/bot${token}/${prefix}${method}`; +}; +const proxyMethods = { + set () { + return false; + }, + defineProperty () { + return false; + }, + deleteProperty () { + return false; + }, + ownKeys () { + return []; + } +}; +function createTimeout(controller, seconds, method) { + let handle = undefined; + const promise = new Promise((_, reject)=>{ + handle = setTimeout(()=>{ + const msg = `Request to '${method}' timed out after ${seconds} seconds`; + reject(new Error(msg)); + controller.abort(); + }, 1000 * seconds); + }); + return { + promise, + handle + }; +} +function createStreamError(abortController) { + let onError = (err)=>{ + throw err; + }; + const promise = new Promise((_, reject)=>{ + onError = (err)=>{ + reject(err); + abortController.abort(); + }; + }); + return { + promise, + catch: onError + }; +} +function createAbortControllerFromSignal(signal) { + const abortController = new AbortController(); + if (signal === undefined) return abortController; + const sig = signal; + function abort() { + abortController.abort(); + sig.removeEventListener("abort", abort); + } + if (sig.aborted) abort(); + else sig.addEventListener("abort", abort); + return { + abort, + signal: abortController.signal + }; +} +function validateSignal(method, payload, signal) { + if (typeof signal?.addEventListener === "function") { + return; + } + let payload0 = JSON.stringify(payload); + if (payload0.length > 20) { + payload0 = payload0.substring(0, 16) + " ..."; + } + let payload1 = JSON.stringify(signal); + if (payload1.length > 20) { + payload1 = payload1.substring(0, 16) + " ..."; + } + throw new Error(`Incorrect abort signal instance found! \ +You passed two payloads to '${method}' but you should merge \ +the second one containing '${payload1}' into the first one \ +containing '${payload0}'! If you are using context shortcuts, \ +you may want to use a method on 'ctx.api' instead. + +If you want to prevent such mistakes in the future, \ +consider using TypeScript. https://www.typescriptlang.org/`); +} +class Api { + token; + options; + raw; + config; + constructor(token, options, webhookReplyEnvelope){ + this.token = token; + this.options = options; + const { raw, use, installedTransformers } = createRawApi(token, options, webhookReplyEnvelope); + this.raw = raw; + this.config = { + use, + installedTransformers: ()=>installedTransformers.slice() + }; + } + getUpdates(other, signal) { + return this.raw.getUpdates({ + ...other + }, signal); + } + setWebhook(url, other, signal) { + return this.raw.setWebhook({ + url, + ...other + }, signal); + } + deleteWebhook(other, signal) { + return this.raw.deleteWebhook({ + ...other + }, signal); + } + getWebhookInfo(signal) { + return this.raw.getWebhookInfo(signal); + } + getMe(signal) { + return this.raw.getMe(signal); + } + logOut(signal) { + return this.raw.logOut(signal); + } + close(signal) { + return this.raw.close(signal); + } + sendMessage(chat_id, text, other, signal) { + return this.raw.sendMessage({ + chat_id, + text, + ...other + }, signal); + } + sendMessageDraft(chat_id, draft_id, text, other, signal) { + return this.raw.sendMessageDraft({ + chat_id, + draft_id, + text, + ...other + }, signal); + } + forwardMessage(chat_id, from_chat_id, message_id, other, signal) { + return this.raw.forwardMessage({ + chat_id, + from_chat_id, + message_id, + ...other + }, signal); + } + forwardMessages(chat_id, from_chat_id, message_ids, other, signal) { + return this.raw.forwardMessages({ + chat_id, + from_chat_id, + message_ids, + ...other + }, signal); + } + copyMessage(chat_id, from_chat_id, message_id, other, signal) { + return this.raw.copyMessage({ + chat_id, + from_chat_id, + message_id, + ...other + }, signal); + } + copyMessages(chat_id, from_chat_id, message_ids, other, signal) { + return this.raw.copyMessages({ + chat_id, + from_chat_id, + message_ids, + ...other + }, signal); + } + sendPhoto(chat_id, photo, other, signal) { + return this.raw.sendPhoto({ + chat_id, + photo, + ...other + }, signal); + } + sendAudio(chat_id, audio, other, signal) { + return this.raw.sendAudio({ + chat_id, + audio, + ...other + }, signal); + } + sendDocument(chat_id, document1, other, signal) { + return this.raw.sendDocument({ + chat_id, + document: document1, + ...other + }, signal); + } + sendVideo(chat_id, video, other, signal) { + return this.raw.sendVideo({ + chat_id, + video, + ...other + }, signal); + } + sendAnimation(chat_id, animation, other, signal) { + return this.raw.sendAnimation({ + chat_id, + animation, + ...other + }, signal); + } + sendVoice(chat_id, voice, other, signal) { + return this.raw.sendVoice({ + chat_id, + voice, + ...other + }, signal); + } + sendVideoNote(chat_id, video_note, other, signal) { + return this.raw.sendVideoNote({ + chat_id, + video_note, + ...other + }, signal); + } + sendMediaGroup(chat_id, media, other, signal) { + return this.raw.sendMediaGroup({ + chat_id, + media, + ...other + }, signal); + } + sendLocation(chat_id, latitude, longitude, other, signal) { + return this.raw.sendLocation({ + chat_id, + latitude, + longitude, + ...other + }, signal); + } + editMessageLiveLocation(chat_id, message_id, latitude, longitude, other, signal) { + return this.raw.editMessageLiveLocation({ + chat_id, + message_id, + latitude, + longitude, + ...other + }, signal); + } + editMessageLiveLocationInline(inline_message_id, latitude, longitude, other, signal) { + return this.raw.editMessageLiveLocation({ + inline_message_id, + latitude, + longitude, + ...other + }, signal); + } + stopMessageLiveLocation(chat_id, message_id, other, signal) { + return this.raw.stopMessageLiveLocation({ + chat_id, + message_id, + ...other + }, signal); + } + stopMessageLiveLocationInline(inline_message_id, other, signal) { + return this.raw.stopMessageLiveLocation({ + inline_message_id, + ...other + }, signal); + } + sendPaidMedia(chat_id, star_count, media, other, signal) { + return this.raw.sendPaidMedia({ + chat_id, + star_count, + media, + ...other + }, signal); + } + sendVenue(chat_id, latitude, longitude, title, address, other, signal) { + return this.raw.sendVenue({ + chat_id, + latitude, + longitude, + title, + address, + ...other + }, signal); + } + sendContact(chat_id, phone_number, first_name, other, signal) { + return this.raw.sendContact({ + chat_id, + phone_number, + first_name, + ...other + }, signal); + } + sendPoll(chat_id, question, options, other, signal) { + const opts = options.map((o)=>typeof o === "string" ? { + text: o + } : o); + return this.raw.sendPoll({ + chat_id, + question, + options: opts, + ...other + }, signal); + } + sendChecklist(business_connection_id, chat_id, checklist, other, signal) { + return this.raw.sendChecklist({ + business_connection_id, + chat_id, + checklist, + ...other + }, signal); + } + editMessageChecklist(business_connection_id, chat_id, message_id, checklist, other, signal) { + return this.raw.editMessageChecklist({ + business_connection_id, + chat_id, + message_id, + checklist, + ...other + }, signal); + } + sendDice(chat_id, emoji, other, signal) { + return this.raw.sendDice({ + chat_id, + emoji, + ...other + }, signal); + } + setMessageReaction(chat_id, message_id, reaction, other, signal) { + return this.raw.setMessageReaction({ + chat_id, + message_id, + reaction, + ...other + }, signal); + } + sendChatAction(chat_id, action, other, signal) { + return this.raw.sendChatAction({ + chat_id, + action, + ...other + }, signal); + } + getUserProfilePhotos(user_id, other, signal) { + return this.raw.getUserProfilePhotos({ + user_id, + ...other + }, signal); + } + getUserProfileAudios(user_id, other, signal) { + return this.raw.getUserProfileAudios({ + user_id, + ...other + }, signal); + } + setUserEmojiStatus(user_id, other, signal) { + return this.raw.setUserEmojiStatus({ + user_id, + ...other + }, signal); + } + getUserChatBoosts(chat_id, user_id, signal) { + return this.raw.getUserChatBoosts({ + chat_id, + user_id + }, signal); + } + getUserGifts(user_id, other, signal) { + return this.raw.getUserGifts({ + user_id, + ...other + }, signal); + } + getChatGifts(chat_id, other, signal) { + return this.raw.getChatGifts({ + chat_id, + ...other + }, signal); + } + getBusinessConnection(business_connection_id, signal) { + return this.raw.getBusinessConnection({ + business_connection_id + }, signal); + } + getFile(file_id, signal) { + return this.raw.getFile({ + file_id + }, signal); + } + kickChatMember(...args) { + return this.banChatMember(...args); + } + banChatMember(chat_id, user_id, other, signal) { + return this.raw.banChatMember({ + chat_id, + user_id, + ...other + }, signal); + } + unbanChatMember(chat_id, user_id, other, signal) { + return this.raw.unbanChatMember({ + chat_id, + user_id, + ...other + }, signal); + } + restrictChatMember(chat_id, user_id, permissions, other, signal) { + return this.raw.restrictChatMember({ + chat_id, + user_id, + permissions, + ...other + }, signal); + } + promoteChatMember(chat_id, user_id, other, signal) { + return this.raw.promoteChatMember({ + chat_id, + user_id, + ...other + }, signal); + } + setChatAdministratorCustomTitle(chat_id, user_id, custom_title, signal) { + return this.raw.setChatAdministratorCustomTitle({ + chat_id, + user_id, + custom_title + }, signal); + } + banChatSenderChat(chat_id, sender_chat_id, signal) { + return this.raw.banChatSenderChat({ + chat_id, + sender_chat_id + }, signal); + } + unbanChatSenderChat(chat_id, sender_chat_id, signal) { + return this.raw.unbanChatSenderChat({ + chat_id, + sender_chat_id + }, signal); + } + setChatPermissions(chat_id, permissions, other, signal) { + return this.raw.setChatPermissions({ + chat_id, + permissions, + ...other + }, signal); + } + exportChatInviteLink(chat_id, signal) { + return this.raw.exportChatInviteLink({ + chat_id + }, signal); + } + createChatInviteLink(chat_id, other, signal) { + return this.raw.createChatInviteLink({ + chat_id, + ...other + }, signal); + } + editChatInviteLink(chat_id, invite_link, other, signal) { + return this.raw.editChatInviteLink({ + chat_id, + invite_link, + ...other + }, signal); + } + createChatSubscriptionInviteLink(chat_id, subscription_period, subscription_price, other, signal) { + return this.raw.createChatSubscriptionInviteLink({ + chat_id, + subscription_period, + subscription_price, + ...other + }, signal); + } + editChatSubscriptionInviteLink(chat_id, invite_link, other, signal) { + return this.raw.editChatSubscriptionInviteLink({ + chat_id, + invite_link, + ...other + }, signal); + } + revokeChatInviteLink(chat_id, invite_link, signal) { + return this.raw.revokeChatInviteLink({ + chat_id, + invite_link + }, signal); + } + approveChatJoinRequest(chat_id, user_id, signal) { + return this.raw.approveChatJoinRequest({ + chat_id, + user_id + }, signal); + } + declineChatJoinRequest(chat_id, user_id, signal) { + return this.raw.declineChatJoinRequest({ + chat_id, + user_id + }, signal); + } + approveSuggestedPost(chat_id, message_id, other, signal) { + return this.raw.approveSuggestedPost({ + chat_id, + message_id, + ...other + }, signal); + } + declineSuggestedPost(chat_id, message_id, other, signal) { + return this.raw.declineSuggestedPost({ + chat_id, + message_id, + ...other + }, signal); + } + setChatPhoto(chat_id, photo, signal) { + return this.raw.setChatPhoto({ + chat_id, + photo + }, signal); + } + deleteChatPhoto(chat_id, signal) { + return this.raw.deleteChatPhoto({ + chat_id + }, signal); + } + setChatTitle(chat_id, title, signal) { + return this.raw.setChatTitle({ + chat_id, + title + }, signal); + } + setChatDescription(chat_id, description, signal) { + return this.raw.setChatDescription({ + chat_id, + description + }, signal); + } + pinChatMessage(chat_id, message_id, other, signal) { + return this.raw.pinChatMessage({ + chat_id, + message_id, + ...other + }, signal); + } + unpinChatMessage(chat_id, message_id, other, signal) { + return this.raw.unpinChatMessage({ + chat_id, + message_id, + ...other + }, signal); + } + unpinAllChatMessages(chat_id, signal) { + return this.raw.unpinAllChatMessages({ + chat_id + }, signal); + } + leaveChat(chat_id, signal) { + return this.raw.leaveChat({ + chat_id + }, signal); + } + getChat(chat_id, signal) { + return this.raw.getChat({ + chat_id + }, signal); + } + getChatAdministrators(chat_id, signal) { + return this.raw.getChatAdministrators({ + chat_id + }, signal); + } + getChatMembersCount(...args) { + return this.getChatMemberCount(...args); + } + getChatMemberCount(chat_id, signal) { + return this.raw.getChatMemberCount({ + chat_id + }, signal); + } + getChatMember(chat_id, user_id, signal) { + return this.raw.getChatMember({ + chat_id, + user_id + }, signal); + } + setChatStickerSet(chat_id, sticker_set_name, signal) { + return this.raw.setChatStickerSet({ + chat_id, + sticker_set_name + }, signal); + } + deleteChatStickerSet(chat_id, signal) { + return this.raw.deleteChatStickerSet({ + chat_id + }, signal); + } + getForumTopicIconStickers(signal) { + return this.raw.getForumTopicIconStickers(signal); + } + createForumTopic(chat_id, name, other, signal) { + return this.raw.createForumTopic({ + chat_id, + name, + ...other + }, signal); + } + editForumTopic(chat_id, message_thread_id, other, signal) { + return this.raw.editForumTopic({ + chat_id, + message_thread_id, + ...other + }, signal); + } + closeForumTopic(chat_id, message_thread_id, signal) { + return this.raw.closeForumTopic({ + chat_id, + message_thread_id + }, signal); + } + reopenForumTopic(chat_id, message_thread_id, signal) { + return this.raw.reopenForumTopic({ + chat_id, + message_thread_id + }, signal); + } + deleteForumTopic(chat_id, message_thread_id, signal) { + return this.raw.deleteForumTopic({ + chat_id, + message_thread_id + }, signal); + } + unpinAllForumTopicMessages(chat_id, message_thread_id, signal) { + return this.raw.unpinAllForumTopicMessages({ + chat_id, + message_thread_id + }, signal); + } + editGeneralForumTopic(chat_id, name, signal) { + return this.raw.editGeneralForumTopic({ + chat_id, + name + }, signal); + } + closeGeneralForumTopic(chat_id, signal) { + return this.raw.closeGeneralForumTopic({ + chat_id + }, signal); + } + reopenGeneralForumTopic(chat_id, signal) { + return this.raw.reopenGeneralForumTopic({ + chat_id + }, signal); + } + hideGeneralForumTopic(chat_id, signal) { + return this.raw.hideGeneralForumTopic({ + chat_id + }, signal); + } + unhideGeneralForumTopic(chat_id, signal) { + return this.raw.unhideGeneralForumTopic({ + chat_id + }, signal); + } + unpinAllGeneralForumTopicMessages(chat_id, signal) { + return this.raw.unpinAllGeneralForumTopicMessages({ + chat_id + }, signal); + } + answerCallbackQuery(callback_query_id, other, signal) { + return this.raw.answerCallbackQuery({ + callback_query_id, + ...other + }, signal); + } + setMyName(name, other, signal) { + return this.raw.setMyName({ + name, + ...other + }, signal); + } + getMyName(other, signal) { + return this.raw.getMyName(other ?? {}, signal); + } + setMyCommands(commands, other, signal) { + return this.raw.setMyCommands({ + commands, + ...other + }, signal); + } + deleteMyCommands(other, signal) { + return this.raw.deleteMyCommands({ + ...other + }, signal); + } + getMyCommands(other, signal) { + return this.raw.getMyCommands({ + ...other + }, signal); + } + setMyDescription(description, other, signal) { + return this.raw.setMyDescription({ + description, + ...other + }, signal); + } + getMyDescription(other, signal) { + return this.raw.getMyDescription({ + ...other + }, signal); + } + setMyShortDescription(short_description, other, signal) { + return this.raw.setMyShortDescription({ + short_description, + ...other + }, signal); + } + getMyShortDescription(other, signal) { + return this.raw.getMyShortDescription({ + ...other + }, signal); + } + setMyProfilePhoto(photo, signal) { + return this.raw.setMyProfilePhoto({ + photo + }, signal); + } + removeMyProfilePhoto(signal) { + return this.raw.removeMyProfilePhoto(signal); + } + setChatMenuButton(other, signal) { + return this.raw.setChatMenuButton({ + ...other + }, signal); + } + getChatMenuButton(other, signal) { + return this.raw.getChatMenuButton({ + ...other + }, signal); + } + setMyDefaultAdministratorRights(other, signal) { + return this.raw.setMyDefaultAdministratorRights({ + ...other + }, signal); + } + getMyDefaultAdministratorRights(other, signal) { + return this.raw.getMyDefaultAdministratorRights({ + ...other + }, signal); + } + getMyStarBalance(signal) { + return this.raw.getMyStarBalance(signal); + } + editMessageText(chat_id, message_id, text, other, signal) { + return this.raw.editMessageText({ + chat_id, + message_id, + text, + ...other + }, signal); + } + editMessageTextInline(inline_message_id, text, other, signal) { + return this.raw.editMessageText({ + inline_message_id, + text, + ...other + }, signal); + } + editMessageCaption(chat_id, message_id, other, signal) { + return this.raw.editMessageCaption({ + chat_id, + message_id, + ...other + }, signal); + } + editMessageCaptionInline(inline_message_id, other, signal) { + return this.raw.editMessageCaption({ + inline_message_id, + ...other + }, signal); + } + editMessageMedia(chat_id, message_id, media, other, signal) { + return this.raw.editMessageMedia({ + chat_id, + message_id, + media, + ...other + }, signal); + } + editMessageMediaInline(inline_message_id, media, other, signal) { + return this.raw.editMessageMedia({ + inline_message_id, + media, + ...other + }, signal); + } + editMessageReplyMarkup(chat_id, message_id, other, signal) { + return this.raw.editMessageReplyMarkup({ + chat_id, + message_id, + ...other + }, signal); + } + editMessageReplyMarkupInline(inline_message_id, other, signal) { + return this.raw.editMessageReplyMarkup({ + inline_message_id, + ...other + }, signal); + } + stopPoll(chat_id, message_id, other, signal) { + return this.raw.stopPoll({ + chat_id, + message_id, + ...other + }, signal); + } + deleteMessage(chat_id, message_id, signal) { + return this.raw.deleteMessage({ + chat_id, + message_id + }, signal); + } + deleteMessages(chat_id, message_ids, signal) { + return this.raw.deleteMessages({ + chat_id, + message_ids + }, signal); + } + deleteBusinessMessages(business_connection_id, message_ids, signal) { + return this.raw.deleteBusinessMessages({ + business_connection_id, + message_ids + }, signal); + } + setBusinessAccountName(business_connection_id, first_name, other, signal) { + return this.raw.setBusinessAccountName({ + business_connection_id, + first_name, + ...other + }, signal); + } + setBusinessAccountUsername(business_connection_id, username, signal) { + return this.raw.setBusinessAccountUsername({ + business_connection_id, + username + }, signal); + } + setBusinessAccountBio(business_connection_id, bio, signal) { + return this.raw.setBusinessAccountBio({ + business_connection_id, + bio + }, signal); + } + setBusinessAccountProfilePhoto(business_connection_id, photo, other, signal) { + return this.raw.setBusinessAccountProfilePhoto({ + business_connection_id, + photo, + ...other + }, signal); + } + removeBusinessAccountProfilePhoto(business_connection_id, other, signal) { + return this.raw.removeBusinessAccountProfilePhoto({ + business_connection_id, + ...other + }, signal); + } + setBusinessAccountGiftSettings(business_connection_id, show_gift_button, accepted_gift_types, signal) { + return this.raw.setBusinessAccountGiftSettings({ + business_connection_id, + show_gift_button, + accepted_gift_types + }, signal); + } + getBusinessAccountStarBalance(business_connection_id, signal) { + return this.raw.getBusinessAccountStarBalance({ + business_connection_id + }, signal); + } + transferBusinessAccountStars(business_connection_id, star_count, signal) { + return this.raw.transferBusinessAccountStars({ + business_connection_id, + star_count + }, signal); + } + getBusinessAccountGifts(business_connection_id, other, signal) { + return this.raw.getBusinessAccountGifts({ + business_connection_id, + ...other + }, signal); + } + convertGiftToStars(business_connection_id, owned_gift_id, signal) { + return this.raw.convertGiftToStars({ + business_connection_id, + owned_gift_id + }, signal); + } + upgradeGift(business_connection_id, owned_gift_id, other, signal) { + return this.raw.upgradeGift({ + business_connection_id, + owned_gift_id, + ...other + }, signal); + } + transferGift(business_connection_id, owned_gift_id, new_owner_chat_id, star_count, signal) { + return this.raw.transferGift({ + business_connection_id, + owned_gift_id, + new_owner_chat_id, + star_count + }, signal); + } + postStory(business_connection_id, content, active_period, other, signal) { + return this.raw.postStory({ + business_connection_id, + content, + active_period, + ...other + }, signal); + } + repostStory(business_connection_id, from_chat_id, from_story_id, active_period, other, signal) { + return this.raw.repostStory({ + business_connection_id, + from_chat_id, + from_story_id, + active_period, + ...other + }, signal); + } + editStory(business_connection_id, story_id, content, other, signal) { + return this.raw.editStory({ + business_connection_id, + story_id, + content, + ...other + }, signal); + } + deleteStory(business_connection_id, story_id, signal) { + return this.raw.deleteStory({ + business_connection_id, + story_id + }, signal); + } + sendSticker(chat_id, sticker, other, signal) { + return this.raw.sendSticker({ + chat_id, + sticker, + ...other + }, signal); + } + getStickerSet(name, signal) { + return this.raw.getStickerSet({ + name + }, signal); + } + getCustomEmojiStickers(custom_emoji_ids, signal) { + return this.raw.getCustomEmojiStickers({ + custom_emoji_ids + }, signal); + } + uploadStickerFile(user_id, sticker_format, sticker, signal) { + return this.raw.uploadStickerFile({ + user_id, + sticker_format, + sticker + }, signal); + } + createNewStickerSet(user_id, name, title, stickers, other, signal) { + return this.raw.createNewStickerSet({ + user_id, + name, + title, + stickers, + ...other + }, signal); + } + addStickerToSet(user_id, name, sticker, signal) { + return this.raw.addStickerToSet({ + user_id, + name, + sticker + }, signal); + } + setStickerPositionInSet(sticker, position, signal) { + return this.raw.setStickerPositionInSet({ + sticker, + position + }, signal); + } + deleteStickerFromSet(sticker, signal) { + return this.raw.deleteStickerFromSet({ + sticker + }, signal); + } + replaceStickerInSet(user_id, name, old_sticker, sticker, signal) { + return this.raw.replaceStickerInSet({ + user_id, + name, + old_sticker, + sticker + }, signal); + } + setStickerEmojiList(sticker, emoji_list, signal) { + return this.raw.setStickerEmojiList({ + sticker, + emoji_list + }, signal); + } + setStickerKeywords(sticker, keywords, signal) { + return this.raw.setStickerKeywords({ + sticker, + keywords + }, signal); + } + setStickerMaskPosition(sticker, mask_position, signal) { + return this.raw.setStickerMaskPosition({ + sticker, + mask_position + }, signal); + } + setStickerSetTitle(name, title, signal) { + return this.raw.setStickerSetTitle({ + name, + title + }, signal); + } + deleteStickerSet(name, signal) { + return this.raw.deleteStickerSet({ + name + }, signal); + } + setStickerSetThumbnail(name, user_id, thumbnail, format, signal) { + return this.raw.setStickerSetThumbnail({ + name, + user_id, + thumbnail, + format + }, signal); + } + setCustomEmojiStickerSetThumbnail(name, custom_emoji_id, signal) { + return this.raw.setCustomEmojiStickerSetThumbnail({ + name, + custom_emoji_id + }, signal); + } + getAvailableGifts(signal) { + return this.raw.getAvailableGifts(signal); + } + sendGift(user_id, gift_id, other, signal) { + return this.raw.sendGift({ + user_id, + gift_id, + ...other + }, signal); + } + giftPremiumSubscription(user_id, month_count, star_count, other, signal) { + return this.raw.giftPremiumSubscription({ + user_id, + month_count, + star_count, + ...other + }, signal); + } + sendGiftToChannel(chat_id, gift_id, other, signal) { + return this.raw.sendGift({ + chat_id, + gift_id, + ...other + }, signal); + } + answerInlineQuery(inline_query_id, results, other, signal) { + return this.raw.answerInlineQuery({ + inline_query_id, + results, + ...other + }, signal); + } + answerWebAppQuery(web_app_query_id, result, signal) { + return this.raw.answerWebAppQuery({ + web_app_query_id, + result + }, signal); + } + savePreparedInlineMessage(user_id, result, other, signal) { + return this.raw.savePreparedInlineMessage({ + user_id, + result, + ...other + }, signal); + } + sendInvoice(chat_id, title, description, payload, currency, prices, other, signal) { + return this.raw.sendInvoice({ + chat_id, + title, + description, + payload, + currency, + prices, + ...other + }, signal); + } + createInvoiceLink(title, description, payload, provider_token, currency, prices, other, signal) { + return this.raw.createInvoiceLink({ + title, + description, + payload, + provider_token, + currency, + prices, + ...other + }, signal); + } + answerShippingQuery(shipping_query_id, ok, other, signal) { + return this.raw.answerShippingQuery({ + shipping_query_id, + ok, + ...other + }, signal); + } + answerPreCheckoutQuery(pre_checkout_query_id, ok, other, signal) { + return this.raw.answerPreCheckoutQuery({ + pre_checkout_query_id, + ok, + ...other + }, signal); + } + getStarTransactions(other, signal) { + return this.raw.getStarTransactions({ + ...other + }, signal); + } + refundStarPayment(user_id, telegram_payment_charge_id, signal) { + return this.raw.refundStarPayment({ + user_id, + telegram_payment_charge_id + }, signal); + } + editUserStarSubscription(user_id, telegram_payment_charge_id, is_canceled, signal) { + return this.raw.editUserStarSubscription({ + user_id, + telegram_payment_charge_id, + is_canceled + }, signal); + } + verifyUser(user_id, other, signal) { + return this.raw.verifyUser({ + user_id, + ...other + }, signal); + } + verifyChat(chat_id, other, signal) { + return this.raw.verifyChat({ + chat_id, + ...other + }, signal); + } + removeUserVerification(user_id, signal) { + return this.raw.removeUserVerification({ + user_id + }, signal); + } + removeChatVerification(chat_id, signal) { + return this.raw.removeChatVerification({ + chat_id + }, signal); + } + readBusinessMessage(business_connection_id, chat_id, message_id, signal) { + return this.raw.readBusinessMessage({ + business_connection_id, + chat_id, + message_id + }, signal); + } + setPassportDataErrors(user_id, errors, signal) { + return this.raw.setPassportDataErrors({ + user_id, + errors + }, signal); + } + sendGame(chat_id, game_short_name, other, signal) { + return this.raw.sendGame({ + chat_id, + game_short_name, + ...other + }, signal); + } + setGameScore(chat_id, message_id, user_id, score, other, signal) { + return this.raw.setGameScore({ + chat_id, + message_id, + user_id, + score, + ...other + }, signal); + } + setGameScoreInline(inline_message_id, user_id, score, other, signal) { + return this.raw.setGameScore({ + inline_message_id, + user_id, + score, + ...other + }, signal); + } + getGameHighScores(chat_id, message_id, user_id, signal) { + return this.raw.getGameHighScores({ + chat_id, + message_id, + user_id + }, signal); + } + getGameHighScoresInline(inline_message_id, user_id, signal) { + return this.raw.getGameHighScores({ + inline_message_id, + user_id + }, signal); + } +} +const debug2 = browser$1("grammy:bot"); +const debugWarn = browser$1("grammy:warn"); +const debugErr = browser$1("grammy:error"); +const DEFAULT_UPDATE_TYPES = [ + "message", + "edited_message", + "channel_post", + "edited_channel_post", + "business_connection", + "business_message", + "edited_business_message", + "deleted_business_messages", + "inline_query", + "chosen_inline_result", + "callback_query", + "shipping_query", + "pre_checkout_query", + "purchased_paid_media", + "poll", + "poll_answer", + "my_chat_member", + "chat_join_request", + "chat_boost", + "removed_chat_boost" +]; +class Bot extends Composer { + token; + pollingRunning; + pollingAbortController; + lastTriedUpdateId; + api; + me; + mePromise; + clientConfig; + ContextConstructor; + observedUpdateTypes; + errorHandler; + constructor(token, config){ + super(); + this.token = token; + this.pollingRunning = false; + this.lastTriedUpdateId = 0; + this.observedUpdateTypes = new Set(); + this.errorHandler = async (err)=>{ + console.error("Error in middleware while handling update", err.ctx?.update?.update_id, err.error); + console.error("No error handler was set!"); + console.error("Set your own error handler with `bot.catch = ...`"); + if (this.pollingRunning) { + console.error("Stopping bot"); + await this.stop(); + } + throw err; + }; + if (!token) throw new Error("Empty token!"); + this.me = config?.botInfo; + this.clientConfig = config?.client; + this.ContextConstructor = config?.ContextConstructor ?? Context; + this.api = new Api(token, this.clientConfig); + } + set botInfo(botInfo) { + this.me = botInfo; + } + get botInfo() { + if (this.me === undefined) { + throw new Error("Bot information unavailable! Make sure to call `await bot.init()` before accessing `bot.botInfo`!"); + } + return this.me; + } + on(filter, ...middleware) { + for (const [u] of parse(filter).flatMap(preprocess)){ + this.observedUpdateTypes.add(u); + } + return super.on(filter, ...middleware); + } + reaction(reaction, ...middleware) { + this.observedUpdateTypes.add("message_reaction"); + return super.reaction(reaction, ...middleware); + } + isInited() { + return this.me !== undefined; + } + async init(signal) { + if (!this.isInited()) { + debug2("Initializing bot"); + this.mePromise ??= withRetries(()=>this.api.getMe(signal), signal); + let me; + try { + me = await this.mePromise; + } finally{ + this.mePromise = undefined; + } + if (this.me === undefined) this.me = me; + else debug2("Bot info was set by now, will not overwrite"); + } + debug2(`I am ${this.me.username}!`); + } + async handleUpdates(updates) { + for (const update of updates){ + this.lastTriedUpdateId = update.update_id; + try { + await this.handleUpdate(update); + } catch (err) { + if (err instanceof BotError) { + await this.errorHandler(err); + } else { + console.error("FATAL: grammY unable to handle:", err); + throw err; + } + } + } + } + async handleUpdate(update, webhookReplyEnvelope) { + if (this.me === undefined) { + throw new Error("Bot not initialized! Either call `await bot.init()`, \ +or directly set the `botInfo` option in the `Bot` constructor to specify \ +a known bot info object."); + } + debug2(`Processing update ${update.update_id}`); + const api = new Api(this.token, this.clientConfig, webhookReplyEnvelope); + const t = this.api.config.installedTransformers(); + if (t.length > 0) api.config.use(...t); + const ctx = new this.ContextConstructor(update, api, this.me); + try { + await run(this.middleware(), ctx); + } catch (err) { + debugErr(`Error in middleware for update ${update.update_id}`); + throw new BotError(err, ctx); + } + } + async start(options) { + const setup = []; + if (!this.isInited()) { + setup.push(this.init(this.pollingAbortController?.signal)); + } + if (this.pollingRunning) { + await Promise.all(setup); + debug2("Simple long polling already running!"); + return; + } + this.pollingRunning = true; + this.pollingAbortController = new AbortController(); + try { + setup.push(withRetries(async ()=>{ + await this.api.deleteWebhook({ + drop_pending_updates: options?.drop_pending_updates + }, this.pollingAbortController?.signal); + }, this.pollingAbortController?.signal)); + await Promise.all(setup); + await options?.onStart?.(this.botInfo); + } catch (err) { + this.pollingRunning = false; + this.pollingAbortController = undefined; + throw err; + } + if (!this.pollingRunning) return; + validateAllowedUpdates(this.observedUpdateTypes, options?.allowed_updates); + this.use = noUseFunction; + debug2("Starting simple long polling"); + await this.loop(options); + debug2("Middleware is done running"); + } + async stop() { + if (this.pollingRunning) { + debug2("Stopping bot, saving update offset"); + this.pollingRunning = false; + this.pollingAbortController?.abort(); + const offset = this.lastTriedUpdateId + 1; + await this.api.getUpdates({ + offset, + limit: 1 + }).finally(()=>this.pollingAbortController = undefined); + } else { + debug2("Bot is not running!"); + } + } + isRunning() { + return this.pollingRunning; + } + catch(errorHandler) { + this.errorHandler = errorHandler; + } + async loop(options) { + const limit = options?.limit; + const timeout = options?.timeout ?? 30; + let allowed_updates = options?.allowed_updates ?? []; + try { + while(this.pollingRunning){ + const updates = await this.fetchUpdates({ + limit, + timeout, + allowed_updates + }); + if (updates === undefined) break; + await this.handleUpdates(updates); + allowed_updates = undefined; + } + } finally{ + this.pollingRunning = false; + } + } + async fetchUpdates({ limit, timeout, allowed_updates }) { + const offset = this.lastTriedUpdateId + 1; + let updates = undefined; + do { + try { + updates = await this.api.getUpdates({ + offset, + limit, + timeout, + allowed_updates + }, this.pollingAbortController?.signal); + } catch (error) { + await this.handlePollingError(error); + } + }while (updates === undefined && this.pollingRunning) + return updates; + } + async handlePollingError(error) { + if (!this.pollingRunning) { + debug2("Pending getUpdates request cancelled"); + return; + } + let sleepSeconds = 3; + if (error instanceof GrammyError) { + debugErr(error.message); + if (error.error_code === 401 || error.error_code === 409) { + throw error; + } else if (error.error_code === 429) { + debugErr("Bot API server is closing."); + sleepSeconds = error.parameters.retry_after ?? sleepSeconds; + } + } else debugErr(error); + debugErr(`Call to getUpdates failed, retrying in ${sleepSeconds} seconds ...`); + await sleep(sleepSeconds); + } +} +async function withRetries(task, signal) { + const INITIAL_DELAY = 50; + let lastDelay = 50; + async function handleError(error) { + let delay = false; + let strategy = "rethrow"; + if (error instanceof HttpError) { + delay = true; + strategy = "retry"; + } else if (error instanceof GrammyError) { + if (error.error_code >= 500) { + delay = true; + strategy = "retry"; + } else if (error.error_code === 429) { + const retryAfter = error.parameters.retry_after; + if (typeof retryAfter === "number") { + await sleep(retryAfter, signal); + lastDelay = INITIAL_DELAY; + } else { + delay = true; + } + strategy = "retry"; + } + } + if (delay) { + if (lastDelay !== 50) { + await sleep(lastDelay, signal); + } + const TWENTY_MINUTES = 20 * 60 * 1000; + lastDelay = Math.min(TWENTY_MINUTES, 2 * lastDelay); + } + return strategy; + } + let result = { + ok: false + }; + while(!result.ok){ + try { + result = { + ok: true, + value: await task() + }; + } catch (error) { + debugErr(error); + const strategy = await handleError(error); + switch(strategy){ + case "retry": + continue; + case "rethrow": + throw error; + } + } + } + return result.value; +} +async function sleep(seconds, signal) { + let handle; + let reject; + function abort() { + reject?.(new Error("Aborted delay")); + if (handle !== undefined) clearTimeout(handle); + } + try { + await new Promise((res, rej)=>{ + reject = rej; + if (signal?.aborted) { + abort(); + return; + } + signal?.addEventListener("abort", abort); + handle = setTimeout(res, 1000 * seconds); + }); + } finally{ + signal?.removeEventListener("abort", abort); + } +} +function validateAllowedUpdates(updates, allowed = DEFAULT_UPDATE_TYPES) { + const impossible = Array.from(updates).filter((u)=>!allowed.includes(u)); + if (impossible.length > 0) { + debugWarn(`You registered listeners for the following update types, \ +but you did not specify them in \`allowed_updates\` \ +so they may not be received: ${impossible.map((u)=>`'${u}'`).join(", ")}`); + } +} +function noUseFunction() { + throw new Error(`It looks like you are registering more listeners \ +on your bot from within other listeners! This means that every time your bot \ +handles a message like this one, new listeners will be added. This list grows until \ +your machine crashes, so grammY throws this error to tell you that you should \ +probably do things a bit differently. If you're unsure how to resolve this problem, \ +you can ask in the group chat: https://telegram.me/grammyjs + +On the other hand, if you actually know what you're doing and you do need to install \ +further middleware while your bot is running, consider installing a composer \ +instance on your bot, and in turn augment the composer after the fact. This way, \ +you can circumvent this protection against memory leaks.`); +} +const ALL_UPDATE_TYPES = [ + ...DEFAULT_UPDATE_TYPES, + "chat_member", + "message_reaction", + "message_reaction_count" +]; +const ALL_CHAT_PERMISSIONS = { + is_anonymous: true, + can_manage_chat: true, + can_delete_messages: true, + can_manage_video_chats: true, + can_restrict_members: true, + can_promote_members: true, + can_change_info: true, + can_invite_users: true, + can_post_stories: true, + can_edit_stories: true, + can_delete_stories: true, + can_post_messages: true, + can_edit_messages: true, + can_pin_messages: true, + can_manage_topics: true +}; +const API_CONSTANTS = { + DEFAULT_UPDATE_TYPES, + ALL_UPDATE_TYPES, + ALL_CHAT_PERMISSIONS +}; +Object.freeze(API_CONSTANTS); +export { API_CONSTANTS as API_CONSTANTS }; +function inputMessage(queryTemplate) { + return { + ...queryTemplate, + ...inputMessageMethods(queryTemplate) + }; +} +function inputMessageMethods(queryTemplate) { + return { + text (message_text, options = {}) { + const content = { + message_text, + ...options + }; + return { + ...queryTemplate, + input_message_content: content + }; + }, + location (latitude, longitude, options = {}) { + const content = { + latitude, + longitude, + ...options + }; + return { + ...queryTemplate, + input_message_content: content + }; + }, + venue (title, latitude, longitude, address, options) { + const content = { + title, + latitude, + longitude, + address, + ...options + }; + return { + ...queryTemplate, + input_message_content: content + }; + }, + contact (first_name, phone_number, options = {}) { + const content = { + first_name, + phone_number, + ...options + }; + return { + ...queryTemplate, + input_message_content: content + }; + }, + invoice (title, description, payload, provider_token, currency, prices, options = {}) { + const content = { + title, + description, + payload, + provider_token, + currency, + prices, + ...options + }; + return { + ...queryTemplate, + input_message_content: content + }; + } + }; +} +const InlineQueryResultBuilder = { + article (id, title, options = {}) { + return inputMessageMethods({ + type: "article", + id, + title, + ...options + }); + }, + audio (id, title, audio_url, options = {}) { + return inputMessage({ + type: "audio", + id, + title, + audio_url: typeof audio_url === "string" ? audio_url : audio_url.href, + ...options + }); + }, + audioCached (id, audio_file_id, options = {}) { + return inputMessage({ + type: "audio", + id, + audio_file_id, + ...options + }); + }, + contact (id, phone_number, first_name, options = {}) { + return inputMessage({ + type: "contact", + id, + phone_number, + first_name, + ...options + }); + }, + documentPdf (id, title, document_url, options = {}) { + return inputMessage({ + type: "document", + mime_type: "application/pdf", + id, + title, + document_url: typeof document_url === "string" ? document_url : document_url.href, + ...options + }); + }, + documentZip (id, title, document_url, options = {}) { + return inputMessage({ + type: "document", + mime_type: "application/zip", + id, + title, + document_url: typeof document_url === "string" ? document_url : document_url.href, + ...options + }); + }, + documentCached (id, title, document_file_id, options = {}) { + return inputMessage({ + type: "document", + id, + title, + document_file_id, + ...options + }); + }, + game (id, game_short_name, options = {}) { + return { + type: "game", + id, + game_short_name, + ...options + }; + }, + gif (id, gif_url, thumbnail_url, options = {}) { + return inputMessage({ + type: "gif", + id, + gif_url: typeof gif_url === "string" ? gif_url : gif_url.href, + thumbnail_url: typeof thumbnail_url === "string" ? thumbnail_url : thumbnail_url.href, + ...options + }); + }, + gifCached (id, gif_file_id, options = {}) { + return inputMessage({ + type: "gif", + id, + gif_file_id, + ...options + }); + }, + location (id, title, latitude, longitude, options = {}) { + return inputMessage({ + type: "location", + id, + title, + latitude, + longitude, + ...options + }); + }, + mpeg4gif (id, mpeg4_url, thumbnail_url, options = {}) { + return inputMessage({ + type: "mpeg4_gif", + id, + mpeg4_url: typeof mpeg4_url === "string" ? mpeg4_url : mpeg4_url.href, + thumbnail_url: typeof thumbnail_url === "string" ? thumbnail_url : thumbnail_url.href, + ...options + }); + }, + mpeg4gifCached (id, mpeg4_file_id, options = {}) { + return inputMessage({ + type: "mpeg4_gif", + id, + mpeg4_file_id, + ...options + }); + }, + photo (id, photo_url, options = { + thumbnail_url: typeof photo_url === "string" ? photo_url : photo_url.href + }) { + return inputMessage({ + type: "photo", + id, + photo_url: typeof photo_url === "string" ? photo_url : photo_url.href, + ...options + }); + }, + photoCached (id, photo_file_id, options = {}) { + return inputMessage({ + type: "photo", + id, + photo_file_id, + ...options + }); + }, + stickerCached (id, sticker_file_id, options = {}) { + return inputMessage({ + type: "sticker", + id, + sticker_file_id, + ...options + }); + }, + venue (id, title, latitude, longitude, address, options = {}) { + return inputMessage({ + type: "venue", + id, + title, + latitude, + longitude, + address, + ...options + }); + }, + videoHtml (id, title, video_url, thumbnail_url, options = {}) { + return inputMessageMethods({ + type: "video", + mime_type: "text/html", + id, + title, + video_url: typeof video_url === "string" ? video_url : video_url.href, + thumbnail_url: typeof thumbnail_url === "string" ? thumbnail_url : thumbnail_url.href, + ...options + }); + }, + videoMp4 (id, title, video_url, thumbnail_url, options = {}) { + return inputMessage({ + type: "video", + mime_type: "video/mp4", + id, + title, + video_url: typeof video_url === "string" ? video_url : video_url.href, + thumbnail_url: typeof thumbnail_url === "string" ? thumbnail_url : thumbnail_url.href, + ...options + }); + }, + videoCached (id, title, video_file_id, options = {}) { + return inputMessage({ + type: "video", + id, + title, + video_file_id, + ...options + }); + }, + voice (id, title, voice_url, options = {}) { + return inputMessage({ + type: "voice", + id, + title, + voice_url: typeof voice_url === "string" ? voice_url : voice_url.href, + ...options + }); + }, + voiceCached (id, title, voice_file_id, options = {}) { + return inputMessage({ + type: "voice", + id, + title, + voice_file_id, + ...options + }); + } +}; +export { InlineQueryResultBuilder as InlineQueryResultBuilder }; +const InputMediaBuilder = { + photo (media, options = {}) { + return { + type: "photo", + media, + ...options + }; + }, + video (media, options = {}) { + return { + type: "video", + media, + ...options + }; + }, + animation (media, options = {}) { + return { + type: "animation", + media, + ...options + }; + }, + audio (media, options = {}) { + return { + type: "audio", + media, + ...options + }; + }, + document (media, options = {}) { + return { + type: "document", + media, + ...options + }; + } +}; +export { InputMediaBuilder as InputMediaBuilder }; +class Keyboard { + keyboard; + is_persistent; + selective; + one_time_keyboard; + resize_keyboard; + input_field_placeholder; + constructor(keyboard = [ + [] + ]){ + this.keyboard = keyboard; + } + add(...buttons) { + this.keyboard[this.keyboard.length - 1]?.push(...buttons); + return this; + } + row(...buttons) { + this.keyboard.push(buttons); + return this; + } + text(text, options) { + return this.add(Keyboard.text(text, options)); + } + static text(text, options) { + return typeof options === "string" ? { + text, + style: options + } : { + text, + ...options + }; + } + requestUsers(text, requestId, options = {}) { + return this.add(Keyboard.requestUsers(text, requestId, options)); + } + static requestUsers(text, requestId, options = {}) { + return typeof text === "string" ? { + text, + request_users: { + request_id: requestId, + ...options + } + } : { + ...text, + request_users: { + request_id: requestId, + ...options + } + }; + } + requestChat(text, requestId, options = { + chat_is_channel: false + }) { + return this.add(Keyboard.requestChat(text, requestId, options)); + } + static requestChat(text, requestId, options = { + chat_is_channel: false + }) { + const request_chat = { + request_id: requestId, + ...options + }; + return typeof text === "string" ? { + text, + request_chat + } : { + ...text, + request_chat + }; + } + requestContact(text) { + return this.add(Keyboard.requestContact(text)); + } + static requestContact(text) { + return typeof text === "string" ? { + text, + request_contact: true + } : { + ...text, + request_contact: true + }; + } + requestLocation(text) { + return this.add(Keyboard.requestLocation(text)); + } + static requestLocation(text) { + return typeof text === "string" ? { + text, + request_location: true + } : { + ...text, + request_location: true + }; + } + requestPoll(text, type) { + return this.add(Keyboard.requestPoll(text, type)); + } + static requestPoll(text, type) { + const request_poll = { + type + }; + return typeof text === "string" ? { + text, + request_poll + } : { + ...text, + request_poll + }; + } + webApp(text, url) { + return this.add(Keyboard.webApp(text, url)); + } + static webApp(text, url) { + const web_app = { + url + }; + return typeof text === "string" ? { + text, + web_app + } : { + ...text, + web_app + }; + } + style(style) { + const rows = this.keyboard.length; + if (rows === 0) { + throw new Error("Need to add a button before applying a style!"); + } + const lastRow = this.keyboard[rows - 1]; + const cols = lastRow.length; + if (cols === 0) { + throw new Error("Need to add a button before applying a style!"); + } + let lastButton = lastRow[cols - 1]; + if (typeof lastButton === "string") { + lastButton = { + text: lastButton + }; + lastRow[cols - 1] = lastButton; + } + lastButton.style = style; + return this; + } + danger() { + return this.style("danger"); + } + success() { + return this.style("success"); + } + primary() { + return this.style("primary"); + } + icon(icon) { + const rows = this.keyboard.length; + if (rows === 0) { + throw new Error("Need to add a button before adding an icon!"); + } + const lastRow = this.keyboard[rows - 1]; + const cols = lastRow.length; + if (cols === 0) { + throw new Error("Need to add a button before adding an icon!"); + } + let lastButton = lastRow[cols - 1]; + if (typeof lastButton === "string") { + lastButton = { + text: lastButton + }; + lastRow[cols - 1] = lastButton; + } + lastButton.icon_custom_emoji_id = icon; + return this; + } + persistent(isEnabled = true) { + this.is_persistent = isEnabled; + return this; + } + selected(isEnabled = true) { + this.selective = isEnabled; + return this; + } + oneTime(isEnabled = true) { + this.one_time_keyboard = isEnabled; + return this; + } + resized(isEnabled = true) { + this.resize_keyboard = isEnabled; + return this; + } + placeholder(value) { + this.input_field_placeholder = value; + return this; + } + toTransposed() { + const original = this.keyboard; + const transposed = transpose(original); + return this.clone(transposed); + } + toFlowed(columns, options = {}) { + const original = this.keyboard; + const flowed = reflow(original, columns, options); + return this.clone(flowed); + } + clone(keyboard = this.keyboard) { + const clone = new Keyboard(keyboard.map((row)=>row.slice())); + clone.is_persistent = this.is_persistent; + clone.selective = this.selective; + clone.one_time_keyboard = this.one_time_keyboard; + clone.resize_keyboard = this.resize_keyboard; + clone.input_field_placeholder = this.input_field_placeholder; + return clone; + } + append(...sources) { + for (const source of sources){ + const keyboard = Keyboard.from(source); + this.keyboard.push(...keyboard.keyboard.map((row)=>row.slice())); + } + return this; + } + build() { + return this.keyboard; + } + static from(source) { + if (source instanceof Keyboard) return source.clone(); + function toButton(btn) { + return typeof btn === "string" ? Keyboard.text(btn) : btn; + } + return new Keyboard(source.map((row)=>row.map(toButton))); + } +} +class InlineKeyboard { + inline_keyboard; + constructor(inline_keyboard = [ + [] + ]){ + this.inline_keyboard = inline_keyboard; + } + add(...buttons) { + this.inline_keyboard[this.inline_keyboard.length - 1]?.push(...buttons); + return this; + } + row(...buttons) { + this.inline_keyboard.push(buttons); + return this; + } + url(text, url) { + return this.add(InlineKeyboard.url(text, url)); + } + static url(text, url) { + return typeof text === "string" ? { + text, + url + } : { + ...text, + url + }; + } + text(text, data = typeof text === "string" ? text : text.text) { + return this.add(InlineKeyboard.text(text, data)); + } + static text(text, data = typeof text === "string" ? text : text.text) { + return typeof text === "string" ? { + text, + callback_data: data + } : { + ...text, + callback_data: data + }; + } + webApp(text, url) { + return this.add(InlineKeyboard.webApp(text, url)); + } + static webApp(text, url) { + const web_app = typeof url === "string" ? { + url + } : url; + return typeof text === "string" ? { + text, + web_app + } : { + ...text, + web_app + }; + } + login(text, loginUrl) { + return this.add(InlineKeyboard.login(text, loginUrl)); + } + static login(text, loginUrl) { + const login_url = typeof loginUrl === "string" ? { + url: loginUrl + } : loginUrl; + return typeof text === "string" ? { + text, + login_url + } : { + ...text, + login_url + }; + } + switchInline(text, query = "") { + return this.add(InlineKeyboard.switchInline(text, query)); + } + static switchInline(text, query = "") { + return typeof text === "string" ? { + text, + switch_inline_query: query + } : { + ...text, + switch_inline_query: query + }; + } + switchInlineCurrent(text, query = "") { + return this.add(InlineKeyboard.switchInlineCurrent(text, query)); + } + static switchInlineCurrent(text, query = "") { + return typeof text === "string" ? { + text, + switch_inline_query_current_chat: query + } : { + ...text, + switch_inline_query_current_chat: query + }; + } + switchInlineChosen(text, query = {}) { + return this.add(InlineKeyboard.switchInlineChosen(text, query)); + } + static switchInlineChosen(text, query = {}) { + return typeof text === "string" ? { + text, + switch_inline_query_chosen_chat: query + } : { + ...text, + switch_inline_query_chosen_chat: query + }; + } + copyText(text, copyText) { + return this.add(InlineKeyboard.copyText(text, copyText)); + } + static copyText(text, copyText) { + const copy_text = typeof copyText === "string" ? { + text: copyText + } : copyText; + return typeof text === "string" ? { + text, + copy_text + } : { + ...text, + copy_text + }; + } + game(text) { + return this.add(InlineKeyboard.game(text)); + } + static game(text) { + const callback_game = {}; + return typeof text === "string" ? { + text, + callback_game + } : { + ...text, + callback_game + }; + } + pay(text) { + return this.add(InlineKeyboard.pay(text)); + } + static pay(text) { + return typeof text === "string" ? { + text, + pay: true + } : { + ...text, + pay: true + }; + } + style(style) { + const rows = this.inline_keyboard.length; + if (rows === 0) { + throw new Error("Need to add a button before applying a style!"); + } + const lastRow = this.inline_keyboard[rows - 1]; + const cols = lastRow.length; + if (cols === 0) { + throw new Error("Need to add a button before applying a style!"); + } + lastRow[cols - 1].style = style; + return this; + } + danger() { + return this.style("danger"); + } + success() { + return this.style("success"); + } + primary() { + return this.style("primary"); + } + icon(icon) { + const rows = this.inline_keyboard.length; + if (rows === 0) { + throw new Error("Need to add a button before adding an icon!"); + } + const lastRow = this.inline_keyboard[rows - 1]; + const cols = lastRow.length; + if (cols === 0) { + throw new Error("Need to add a button before adding an icon!"); + } + lastRow[cols - 1].icon_custom_emoji_id = icon; + return this; + } + toTransposed() { + const original = this.inline_keyboard; + const transposed = transpose(original); + return new InlineKeyboard(transposed); + } + toFlowed(columns, options = {}) { + const original = this.inline_keyboard; + const flowed = reflow(original, columns, options); + return new InlineKeyboard(flowed); + } + clone() { + return new InlineKeyboard(this.inline_keyboard.map((row)=>row.slice())); + } + append(...sources) { + for (const source of sources){ + const keyboard = InlineKeyboard.from(source); + this.inline_keyboard.push(...keyboard.inline_keyboard.map((row)=>row.slice())); + } + return this; + } + static from(source) { + if (source instanceof InlineKeyboard) return source.clone(); + return new InlineKeyboard(source.map((row)=>row.slice())); + } +} +function transpose(grid) { + const transposed = []; + for(let i = 0; i < grid.length; i++){ + const row = grid[i]; + for(let j = 0; j < row.length; j++){ + const button = row[j]; + (transposed[j] ??= []).push(button); + } + } + return transposed; +} +function reflow(grid, columns, { fillLastRow = false }) { + let first = columns; + if (fillLastRow) { + const buttonCount = grid.map((row)=>row.length).reduce((a, b)=>a + b, 0); + first = buttonCount % columns; + } + const reflowed = []; + for (const row of grid){ + for (const button of row){ + const at = Math.max(0, reflowed.length - 1); + const max = at === 0 ? first : columns; + let next = reflowed[at] ??= []; + if (next.length === max) { + next = []; + reflowed.push(next); + } + next.push(button); + } + } + return reflowed; +} +export { Keyboard as Keyboard }; +export { InlineKeyboard as InlineKeyboard }; +const debug3 = browser$1("grammy:session"); +function session(options = {}) { + return options.type === "multi" ? strictMultiSession(options) : strictSingleSession(options); +} +function strictSingleSession(options) { + const { initial, storage, getSessionKey, custom } = fillDefaults(options); + return async (ctx, next)=>{ + const propSession = new PropertySession(storage, ctx, "session", initial); + const key = await getSessionKey(ctx); + await propSession.init(key, { + custom, + lazy: false + }); + await next(); + await propSession.finish(); + }; +} +function strictMultiSession(options) { + const props = Object.keys(options).filter((k)=>k !== "type"); + const defaults = Object.fromEntries(props.map((prop)=>[ + prop, + fillDefaults(options[prop]) + ])); + return async (ctx, next)=>{ + ctx.session = {}; + const propSessions = await Promise.all(props.map(async (prop)=>{ + const { initial, storage, getSessionKey, custom } = defaults[prop]; + const s = new PropertySession(storage, ctx.session, prop, initial); + const key = await getSessionKey(ctx); + await s.init(key, { + custom, + lazy: false + }); + return s; + })); + await next(); + if (ctx.session == null) propSessions.forEach((s)=>s.delete()); + await Promise.all(propSessions.map((s)=>s.finish())); + }; +} +function lazySession(options = {}) { + if (options.type !== undefined && options.type !== "single") { + throw new Error("Cannot use lazy multi sessions!"); + } + const { initial, storage, getSessionKey, custom } = fillDefaults(options); + return async (ctx, next)=>{ + const propSession = new PropertySession(storage, ctx, "session", initial); + const key = await getSessionKey(ctx); + await propSession.init(key, { + custom, + lazy: true + }); + await next(); + await propSession.finish(); + }; +} +class PropertySession { + storage; + obj; + prop; + initial; + key; + value; + promise; + fetching; + read; + wrote; + constructor(storage, obj, prop, initial){ + this.storage = storage; + this.obj = obj; + this.prop = prop; + this.initial = initial; + this.fetching = false; + this.read = false; + this.wrote = false; + } + load() { + if (this.key === undefined) { + return; + } + if (this.wrote) { + return; + } + if (this.promise === undefined) { + this.fetching = true; + this.promise = Promise.resolve(this.storage.read(this.key)).then((val)=>{ + this.fetching = false; + if (this.wrote) { + return this.value; + } + if (val !== undefined) { + this.value = val; + return val; + } + val = this.initial?.(); + if (val !== undefined) { + this.wrote = true; + this.value = val; + } + return val; + }); + } + return this.promise; + } + async init(key, opts) { + this.key = key; + if (!opts.lazy) await this.load(); + Object.defineProperty(this.obj, this.prop, { + enumerable: true, + get: ()=>{ + if (key === undefined) { + const msg = undef("access", opts); + throw new Error(msg); + } + this.read = true; + if (!opts.lazy || this.wrote) return this.value; + this.load(); + return this.fetching ? this.promise : this.value; + }, + set: (v)=>{ + if (key === undefined) { + const msg = undef("assign", opts); + throw new Error(msg); + } + this.wrote = true; + this.fetching = false; + this.value = v; + } + }); + } + delete() { + Object.assign(this.obj, { + [this.prop]: undefined + }); + } + async finish() { + if (this.key !== undefined) { + if (this.read) await this.load(); + if (this.read || this.wrote) { + const value = await this.value; + if (value == null) await this.storage.delete(this.key); + else await this.storage.write(this.key, value); + } + } + } +} +function fillDefaults(opts = {}) { + let { prefix = "", getSessionKey = defaultGetSessionKey, initial, storage } = opts; + if (storage == null) { + debug3("Storing session data in memory, all data will be lost when the bot restarts."); + storage = new MemorySessionStorage(); + } + const custom = getSessionKey !== defaultGetSessionKey; + return { + initial, + storage, + getSessionKey: async (ctx)=>{ + const key = await getSessionKey(ctx); + return key === undefined ? undefined : prefix + key; + }, + custom + }; +} +function defaultGetSessionKey(ctx) { + return ctx.chatId?.toString(); +} +function undef(op, opts) { + const { lazy = false, custom } = opts; + const reason = custom ? "the custom `getSessionKey` function returned undefined for this update" : "this update does not belong to a chat, so the session key is undefined"; + return `Cannot ${op} ${lazy ? "lazy " : ""}session data because ${reason}!`; +} +function isEnhance(value) { + return value === undefined || typeof value === "object" && value !== null && "__d" in value; +} +function enhanceStorage(options) { + let { storage, millisecondsToLive, migrations } = options; + storage = compatStorage(storage); + if (millisecondsToLive !== undefined) { + storage = timeoutStorage(storage, millisecondsToLive); + } + if (migrations !== undefined) { + storage = migrationStorage(storage, migrations); + } + return wrapStorage(storage); +} +function compatStorage(storage) { + return { + read: async (k)=>{ + const v = await storage.read(k); + return isEnhance(v) ? v : { + __d: v + }; + }, + write: (k, v)=>storage.write(k, v), + delete: (k)=>storage.delete(k) + }; +} +function timeoutStorage(storage, millisecondsToLive) { + const ttlStorage = { + read: async (k)=>{ + const value = await storage.read(k); + if (value === undefined) return undefined; + if (value.e === undefined) { + await ttlStorage.write(k, value); + return value; + } + if (value.e < Date.now()) { + await ttlStorage.delete(k); + return undefined; + } + return value; + }, + write: async (k, v)=>{ + v.e = addExpiryDate(v, millisecondsToLive).expires; + await storage.write(k, v); + }, + delete: (k)=>storage.delete(k) + }; + return ttlStorage; +} +function migrationStorage(storage, migrations) { + const versions = Object.keys(migrations).map((v)=>parseInt(v)).sort((a, b)=>a - b); + const count = versions.length; + if (count === 0) throw new Error("No migrations given!"); + const earliest = versions[0]; + const last = count - 1; + const latest = versions[last]; + const index = new Map(); + versions.forEach((v, i)=>index.set(v, i)); + function nextAfter(current) { + let i = last; + while(current <= versions[i])i--; + return i; + } + return { + read: async (k)=>{ + const val = await storage.read(k); + if (val === undefined) return val; + let { __d: value, v: current = earliest - 1 } = val; + let i = 1 + (index.get(current) ?? nextAfter(current)); + for(; i < count; i++)value = migrations[versions[i]](value); + return { + ...val, + v: latest, + __d: value + }; + }, + write: (k, v)=>storage.write(k, { + v: latest, + ...v + }), + delete: (k)=>storage.delete(k) + }; +} +function wrapStorage(storage) { + return { + read: (k)=>Promise.resolve(storage.read(k)).then((v)=>v?.__d), + write: (k, v)=>storage.write(k, { + __d: v + }), + delete: (k)=>storage.delete(k) + }; +} +class MemorySessionStorage { + timeToLive; + storage; + constructor(timeToLive){ + this.timeToLive = timeToLive; + this.storage = new Map(); + } + read(key) { + const value = this.storage.get(key); + if (value === undefined) return undefined; + if (value.expires !== undefined && value.expires < Date.now()) { + this.delete(key); + return undefined; + } + return value.session; + } + readAll() { + return this.readAllValues(); + } + readAllKeys() { + return Array.from(this.storage.keys()); + } + readAllValues() { + return Array.from(this.storage.keys()).map((key)=>this.read(key)).filter((value)=>value !== undefined); + } + readAllEntries() { + return Array.from(this.storage.keys()).map((key)=>[ + key, + this.read(key) + ]).filter((pair)=>pair[1] !== undefined); + } + has(key) { + return this.storage.has(key); + } + write(key, value) { + this.storage.set(key, addExpiryDate(value, this.timeToLive)); + } + delete(key) { + this.storage.delete(key); + } +} +function addExpiryDate(value, ttl) { + if (ttl !== undefined && ttl < Infinity) { + const now = Date.now(); + return { + session: value, + expires: now + ttl + }; + } else { + return { + session: value + }; + } +} +export { session as session }; +export { lazySession as lazySession }; +export { enhanceStorage as enhanceStorage }; +export { MemorySessionStorage as MemorySessionStorage }; +const SECRET_HEADER = "X-Telegram-Bot-Api-Secret-Token"; +const SECRET_HEADER_LOWERCASE = SECRET_HEADER.toLowerCase(); +const WRONG_TOKEN_ERROR = "secret token is wrong"; +const ok = ()=>new Response(null, { + status: 200 + }); +const okJson = (json)=>new Response(json, { + status: 200, + headers: { + "Content-Type": "application/json" + } + }); +const unauthorized = ()=>new Response('"unauthorized"', { + status: 401, + statusText: WRONG_TOKEN_ERROR + }); +const awsLambda = (event, _context, callback)=>({ + get update () { + return JSON.parse(event.body ?? "{}"); + }, + header: event.headers[SECRET_HEADER], + end: ()=>callback(null, { + statusCode: 200 + }), + respond: (json)=>callback(null, { + statusCode: 200, + headers: { + "Content-Type": "application/json" + }, + body: json + }), + unauthorized: ()=>callback(null, { + statusCode: 401 + }) + }); +const awsLambdaAsync = (event, _context)=>{ + let resolveResponse; + return { + get update () { + return JSON.parse(event.body ?? "{}"); + }, + header: event.headers[SECRET_HEADER], + end: ()=>resolveResponse({ + statusCode: 200 + }), + respond: (json)=>resolveResponse({ + statusCode: 200, + headers: { + "Content-Type": "application/json" + }, + body: json + }), + unauthorized: ()=>resolveResponse({ + statusCode: 401 + }), + handlerReturn: new Promise((res)=>resolveResponse = res) + }; +}; +const azure = (context, request)=>({ + get update () { + return request.body; + }, + header: context.res?.headers?.[SECRET_HEADER], + end: ()=>context.res = { + status: 200, + body: "" + }, + respond: (json)=>{ + context.res?.set?.("Content-Type", "application/json"); + context.res?.send?.(json); + }, + unauthorized: ()=>{ + context.res?.send?.(401, WRONG_TOKEN_ERROR); + } + }); +const azureV4 = (request)=>{ + let resolveResponse; + return { + get update () { + return request.json(); + }, + header: request.headers.get(SECRET_HEADER) || undefined, + end: ()=>resolveResponse({ + status: 204 + }), + respond: (json)=>resolveResponse({ + jsonBody: json + }), + unauthorized: ()=>resolveResponse({ + status: 401, + body: WRONG_TOKEN_ERROR + }), + handlerReturn: new Promise((resolve)=>resolveResponse = resolve) + }; +}; +const bun = (request)=>{ + let resolveResponse; + return { + get update () { + return request.json(); + }, + header: request.headers.get(SECRET_HEADER) || undefined, + end: ()=>{ + resolveResponse(ok()); + }, + respond: (json)=>{ + resolveResponse(okJson(json)); + }, + unauthorized: ()=>{ + resolveResponse(unauthorized()); + }, + handlerReturn: new Promise((res)=>resolveResponse = res) + }; +}; +const cloudflare = (event)=>{ + let resolveResponse; + event.respondWith(new Promise((resolve)=>{ + resolveResponse = resolve; + })); + return { + get update () { + return event.request.json(); + }, + header: event.request.headers.get(SECRET_HEADER) || undefined, + end: ()=>{ + resolveResponse(ok()); + }, + respond: (json)=>{ + resolveResponse(okJson(json)); + }, + unauthorized: ()=>{ + resolveResponse(unauthorized()); + } + }; +}; +const cloudflareModule = (request)=>{ + let resolveResponse; + return { + get update () { + return request.json(); + }, + header: request.headers.get(SECRET_HEADER) || undefined, + end: ()=>{ + resolveResponse(ok()); + }, + respond: (json)=>{ + resolveResponse(okJson(json)); + }, + unauthorized: ()=>{ + resolveResponse(unauthorized()); + }, + handlerReturn: new Promise((res)=>resolveResponse = res) + }; +}; +const express = (req, res)=>({ + get update () { + return req.body; + }, + header: req.header(SECRET_HEADER), + end: ()=>res.end(), + respond: (json)=>{ + res.set("Content-Type", "application/json"); + res.send(json); + }, + unauthorized: ()=>{ + res.status(401).send(WRONG_TOKEN_ERROR); + } + }); +const fastify = (request, reply)=>({ + get update () { + return request.body; + }, + header: request.headers[SECRET_HEADER_LOWERCASE], + end: ()=>reply.send(""), + respond: (json)=>reply.headers({ + "Content-Type": "application/json" + }).send(json), + unauthorized: ()=>reply.code(401).send(WRONG_TOKEN_ERROR) + }); +const hono = (c)=>{ + let resolveResponse; + return { + get update () { + return c.req.json(); + }, + header: c.req.header(SECRET_HEADER), + end: ()=>{ + resolveResponse(c.body("")); + }, + respond: (json)=>{ + resolveResponse(c.json(json)); + }, + unauthorized: ()=>{ + c.status(401); + resolveResponse(c.body("")); + }, + handlerReturn: new Promise((res)=>resolveResponse = res) + }; +}; +const http = (req, res)=>{ + const secretHeaderFromRequest = req.headers[SECRET_HEADER_LOWERCASE]; + return { + get update () { + return new Promise((resolve, reject)=>{ + const chunks = []; + req.on("data", (chunk)=>chunks.push(chunk)).once("end", ()=>{ + const raw = Buffer.concat(chunks).toString("utf-8"); + resolve(JSON.parse(raw)); + }).once("error", reject); + }); + }, + header: Array.isArray(secretHeaderFromRequest) ? secretHeaderFromRequest[0] : secretHeaderFromRequest, + end: ()=>res.end(), + respond: (json)=>res.writeHead(200, { + "Content-Type": "application/json" + }).end(json), + unauthorized: ()=>res.writeHead(401).end(WRONG_TOKEN_ERROR) + }; +}; +const koa = (ctx)=>({ + get update () { + return ctx.request.body; + }, + header: ctx.get(SECRET_HEADER) || undefined, + end: ()=>{ + ctx.body = ""; + }, + respond: (json)=>{ + ctx.set("Content-Type", "application/json"); + ctx.response.body = json; + }, + unauthorized: ()=>{ + ctx.status = 401; + } + }); +const nextJs = (request, response)=>({ + get update () { + return request.body; + }, + header: request.headers[SECRET_HEADER_LOWERCASE], + end: ()=>response.end(), + respond: (json)=>response.status(200).json(json), + unauthorized: ()=>response.status(401).send(WRONG_TOKEN_ERROR) + }); +const nhttp = (rev)=>({ + get update () { + return rev.body; + }, + header: rev.headers.get(SECRET_HEADER) || undefined, + end: ()=>rev.response.sendStatus(200), + respond: (json)=>rev.response.status(200).send(json), + unauthorized: ()=>rev.response.status(401).send(WRONG_TOKEN_ERROR) + }); +const oak = (ctx)=>({ + get update () { + return ctx.request.body.json(); + }, + header: ctx.request.headers.get(SECRET_HEADER) || undefined, + end: ()=>{ + ctx.response.status = 200; + }, + respond: (json)=>{ + ctx.response.type = "json"; + ctx.response.body = json; + }, + unauthorized: ()=>{ + ctx.response.status = 401; + } + }); +const serveHttp = (requestEvent)=>({ + get update () { + return requestEvent.request.json(); + }, + header: requestEvent.request.headers.get(SECRET_HEADER) || undefined, + end: ()=>requestEvent.respondWith(ok()), + respond: (json)=>requestEvent.respondWith(okJson(json)), + unauthorized: ()=>requestEvent.respondWith(unauthorized()) + }); +const stdHttp = (req)=>{ + let resolveResponse; + return { + get update () { + return req.json(); + }, + header: req.headers.get(SECRET_HEADER) || undefined, + end: ()=>{ + if (resolveResponse) resolveResponse(ok()); + }, + respond: (json)=>{ + if (resolveResponse) resolveResponse(okJson(json)); + }, + unauthorized: ()=>{ + if (resolveResponse) resolveResponse(unauthorized()); + }, + handlerReturn: new Promise((res)=>resolveResponse = res) + }; +}; +const sveltekit = ({ request })=>{ + let resolveResponse; + return { + get update () { + return request.json(); + }, + header: request.headers.get(SECRET_HEADER) || undefined, + end: ()=>{ + if (resolveResponse) resolveResponse(ok()); + }, + respond: (json)=>{ + if (resolveResponse) resolveResponse(okJson(json)); + }, + unauthorized: ()=>{ + if (resolveResponse) resolveResponse(unauthorized()); + }, + handlerReturn: new Promise((res)=>resolveResponse = res) + }; +}; +const worktop = (req, res)=>({ + get update () { + return req.json(); + }, + header: req.headers.get(SECRET_HEADER) ?? undefined, + end: ()=>res.end(null), + respond: (json)=>res.send(200, json), + unauthorized: ()=>res.send(401, WRONG_TOKEN_ERROR) + }); +const elysia = (ctx)=>{ + let resolveResponse; + return { + get update () { + return ctx.body; + }, + header: ctx.headers[SECRET_HEADER_LOWERCASE], + end () { + resolveResponse(""); + }, + respond (json) { + ctx.set.headers["content-type"] = "application/json"; + resolveResponse(json); + }, + unauthorized () { + ctx.set.status = 401; + resolveResponse(""); + }, + handlerReturn: new Promise((res)=>resolveResponse = res) + }; +}; +const adapters = { + "aws-lambda": awsLambda, + "aws-lambda-async": awsLambdaAsync, + azure, + "azure-v4": azureV4, + bun, + cloudflare, + "cloudflare-mod": cloudflareModule, + elysia, + express, + fastify, + hono, + http, + https: http, + koa, + "next-js": nextJs, + nhttp, + oak, + serveHttp, + "std/http": stdHttp, + sveltekit, + worktop +}; +const debugErr1 = browser$1("grammy:error"); +const callbackAdapter = (update, callback, header, unauthorized = ()=>callback('"unauthorized"'))=>({ + update: Promise.resolve(update), + respond: callback, + header, + unauthorized + }); +const adapters1 = { + ...adapters, + callback: callbackAdapter +}; +function compareSecretToken(header, token) { + if (token === undefined) { + return true; + } + if (header === undefined) { + return false; + } + const encoder = new TextEncoder(); + const headerBytes = encoder.encode(header); + const tokenBytes = encoder.encode(token); + if (headerBytes.length !== tokenBytes.length) { + return false; + } + let hasDifference = 0; + for(let i = 0; i < tokenBytes.length; i++){ + const headerByte = i < headerBytes.length ? headerBytes[i] : 0; + const tokenByte = tokenBytes[i]; + hasDifference |= headerByte ^ tokenByte; + } + return hasDifference === 0; +} +function webhookCallback(bot, adapter = defaultAdapter, onTimeout, timeoutMilliseconds, secretToken) { + if (bot.isRunning()) { + throw new Error("Bot is already running via long polling, the webhook setup won't receive any updates!"); + } else { + bot.start = ()=>{ + throw new Error("You already started the bot via webhooks, calling `bot.start()` starts the bot with long polling and this will prevent your webhook setup from receiving any updates!"); + }; + } + const { onTimeout: timeout = "throw", timeoutMilliseconds: ms = 10_000, secretToken: token } = typeof onTimeout === "object" ? onTimeout : { + onTimeout, + timeoutMilliseconds, + secretToken + }; + let initialized = false; + const server = typeof adapter === "string" ? adapters1[adapter] : adapter; + return async (...args)=>{ + const handler = server(...args); + if (!initialized) { + await bot.init(); + initialized = true; + } + if (!compareSecretToken(handler.header, token)) { + await handler.unauthorized(); + return handler.handlerReturn; + } + let usedWebhookReply = false; + const webhookReplyEnvelope = { + async send (json) { + usedWebhookReply = true; + await handler.respond(json); + } + }; + await timeoutIfNecessary(bot.handleUpdate(await handler.update, webhookReplyEnvelope), typeof timeout === "function" ? ()=>timeout(...args) : timeout, ms); + if (!usedWebhookReply) handler.end?.(); + return handler.handlerReturn; + }; +} +function timeoutIfNecessary(task, onTimeout, timeout) { + if (timeout === Infinity) return task; + return new Promise((resolve, reject)=>{ + const handle = setTimeout(()=>{ + debugErr1(`Request timed out after ${timeout} ms`); + if (onTimeout === "throw") { + reject(new Error(`Request timed out after ${timeout} ms`)); + } else { + if (typeof onTimeout === "function") onTimeout(); + resolve(); + } + const now = Date.now(); + task.finally(()=>{ + const diff = Date.now() - now; + debugErr1(`Request completed ${diff} ms after timeout!`); + }); + }, timeout); + task.then(resolve).catch(reject).finally(()=>clearTimeout(handle)); + }); +} +export { webhookCallback as webhookCallback }; +export { Bot as Bot, BotError as BotError }; +export { InputFile as InputFile }; +export { Context as Context }; +export { Composer as Composer }; +export { matchFilter as matchFilter }; +export { Api as Api }; +export { GrammyError as GrammyError, HttpError as HttpError }; diff --git a/sandbox/tgbot/node_modules/grammy/package.json b/sandbox/tgbot/node_modules/grammy/package.json new file mode 100644 index 0000000..889fe06 --- /dev/null +++ b/sandbox/tgbot/node_modules/grammy/package.json @@ -0,0 +1,71 @@ +{ + "name": "grammy", + "description": "The Telegram Bot Framework.", + "version": "1.40.0", + "author": "KnorpelSenf", + "license": "MIT", + "engines": { + "node": "^12.20.0 || >=14.13.1" + }, + "homepage": "https://grammy.dev/", + "repository": { + "type": "git", + "url": "git+https://github.com/grammyjs/grammY.git" + }, + "scripts": { + "prepare": "npm run backport", + "backport": "deno2node tsconfig.json" + }, + "dependencies": { + "@grammyjs/types": "3.24.0", + "abort-controller": "^3.0.0", + "debug": "^4.4.3", + "node-fetch": "^2.7.0" + }, + "devDependencies": { + "@types/debug": "^4.1.12", + "@types/node": "^12.20.55", + "@types/node-fetch": "2.6.2", + "deno2node": "^1.16.0" + }, + "files": [ + "out/" + ], + "main": "./out/mod.js", + "types": "./out/mod.d.ts", + "exports": { + ".": { + "types": "./out/mod.d.ts", + "node": "./out/mod.js", + "browser": "./out/web.mjs", + "default": "./out/web.mjs" + }, + "./types": { + "types": "./out/types.d.ts", + "default": "./out/types.js" + }, + "./web": { + "types": "./out/web.d.ts", + "default": "./out/web.mjs" + } + }, + "typesVersions": { + "*": { + "web": [ + "out/web" + ], + "types": [ + "out/types" + ] + } + }, + "keywords": [ + "telegram", + "bot", + "api", + "client", + "framework", + "library", + "grammy" + ] +} diff --git a/sandbox/tgbot/node_modules/ms/index.js b/sandbox/tgbot/node_modules/ms/index.js new file mode 100644 index 0000000..ea734fb --- /dev/null +++ b/sandbox/tgbot/node_modules/ms/index.js @@ -0,0 +1,162 @@ +/** + * Helpers. + */ + +var s = 1000; +var m = s * 60; +var h = m * 60; +var d = h * 24; +var w = d * 7; +var y = d * 365.25; + +/** + * Parse or format the given `val`. + * + * Options: + * + * - `long` verbose formatting [false] + * + * @param {String|Number} val + * @param {Object} [options] + * @throws {Error} throw an error if val is not a non-empty string or a number + * @return {String|Number} + * @api public + */ + +module.exports = function (val, options) { + options = options || {}; + var type = typeof val; + if (type === 'string' && val.length > 0) { + return parse(val); + } else if (type === 'number' && isFinite(val)) { + return options.long ? fmtLong(val) : fmtShort(val); + } + throw new Error( + 'val is not a non-empty string or a valid number. val=' + + JSON.stringify(val) + ); +}; + +/** + * Parse the given `str` and return milliseconds. + * + * @param {String} str + * @return {Number} + * @api private + */ + +function parse(str) { + str = String(str); + if (str.length > 100) { + return; + } + var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec( + str + ); + if (!match) { + return; + } + var n = parseFloat(match[1]); + var type = (match[2] || 'ms').toLowerCase(); + switch (type) { + case 'years': + case 'year': + case 'yrs': + case 'yr': + case 'y': + return n * y; + case 'weeks': + case 'week': + case 'w': + return n * w; + case 'days': + case 'day': + case 'd': + return n * d; + case 'hours': + case 'hour': + case 'hrs': + case 'hr': + case 'h': + return n * h; + case 'minutes': + case 'minute': + case 'mins': + case 'min': + case 'm': + return n * m; + case 'seconds': + case 'second': + case 'secs': + case 'sec': + case 's': + return n * s; + case 'milliseconds': + case 'millisecond': + case 'msecs': + case 'msec': + case 'ms': + return n; + default: + return undefined; + } +} + +/** + * Short format for `ms`. + * + * @param {Number} ms + * @return {String} + * @api private + */ + +function fmtShort(ms) { + var msAbs = Math.abs(ms); + if (msAbs >= d) { + return Math.round(ms / d) + 'd'; + } + if (msAbs >= h) { + return Math.round(ms / h) + 'h'; + } + if (msAbs >= m) { + return Math.round(ms / m) + 'm'; + } + if (msAbs >= s) { + return Math.round(ms / s) + 's'; + } + return ms + 'ms'; +} + +/** + * Long format for `ms`. + * + * @param {Number} ms + * @return {String} + * @api private + */ + +function fmtLong(ms) { + var msAbs = Math.abs(ms); + if (msAbs >= d) { + return plural(ms, msAbs, d, 'day'); + } + if (msAbs >= h) { + return plural(ms, msAbs, h, 'hour'); + } + if (msAbs >= m) { + return plural(ms, msAbs, m, 'minute'); + } + if (msAbs >= s) { + return plural(ms, msAbs, s, 'second'); + } + return ms + ' ms'; +} + +/** + * Pluralization helper. + */ + +function plural(ms, msAbs, n, name) { + var isPlural = msAbs >= n * 1.5; + return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : ''); +} diff --git a/sandbox/tgbot/node_modules/ms/license.md b/sandbox/tgbot/node_modules/ms/license.md new file mode 100644 index 0000000..fa5d39b --- /dev/null +++ b/sandbox/tgbot/node_modules/ms/license.md @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2020 Vercel, Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/sandbox/tgbot/node_modules/ms/package.json b/sandbox/tgbot/node_modules/ms/package.json new file mode 100644 index 0000000..4997189 --- /dev/null +++ b/sandbox/tgbot/node_modules/ms/package.json @@ -0,0 +1,38 @@ +{ + "name": "ms", + "version": "2.1.3", + "description": "Tiny millisecond conversion utility", + "repository": "vercel/ms", + "main": "./index", + "files": [ + "index.js" + ], + "scripts": { + "precommit": "lint-staged", + "lint": "eslint lib/* bin/*", + "test": "mocha tests.js" + }, + "eslintConfig": { + "extends": "eslint:recommended", + "env": { + "node": true, + "es6": true + } + }, + "lint-staged": { + "*.js": [ + "npm run lint", + "prettier --single-quote --write", + "git add" + ] + }, + "license": "MIT", + "devDependencies": { + "eslint": "4.18.2", + "expect.js": "0.3.1", + "husky": "0.14.3", + "lint-staged": "5.0.0", + "mocha": "4.0.1", + "prettier": "2.0.5" + } +} diff --git a/sandbox/tgbot/node_modules/ms/readme.md b/sandbox/tgbot/node_modules/ms/readme.md new file mode 100644 index 0000000..0fc1abb --- /dev/null +++ b/sandbox/tgbot/node_modules/ms/readme.md @@ -0,0 +1,59 @@ +# ms + +![CI](https://github.com/vercel/ms/workflows/CI/badge.svg) + +Use this package to easily convert various time formats to milliseconds. + +## Examples + +```js +ms('2 days') // 172800000 +ms('1d') // 86400000 +ms('10h') // 36000000 +ms('2.5 hrs') // 9000000 +ms('2h') // 7200000 +ms('1m') // 60000 +ms('5s') // 5000 +ms('1y') // 31557600000 +ms('100') // 100 +ms('-3 days') // -259200000 +ms('-1h') // -3600000 +ms('-200') // -200 +``` + +### Convert from Milliseconds + +```js +ms(60000) // "1m" +ms(2 * 60000) // "2m" +ms(-3 * 60000) // "-3m" +ms(ms('10 hours')) // "10h" +``` + +### Time Format Written-Out + +```js +ms(60000, { long: true }) // "1 minute" +ms(2 * 60000, { long: true }) // "2 minutes" +ms(-3 * 60000, { long: true }) // "-3 minutes" +ms(ms('10 hours'), { long: true }) // "10 hours" +``` + +## Features + +- Works both in [Node.js](https://nodejs.org) and in the browser +- If a number is supplied to `ms`, a string with a unit is returned +- If a string that contains the number is supplied, it returns it as a number (e.g.: it returns `100` for `'100'`) +- If you pass a string with a number and a valid unit, the number of equivalent milliseconds is returned + +## Related Packages + +- [ms.macro](https://github.com/knpwrs/ms.macro) - Run `ms` as a macro at build-time. + +## Caught a Bug? + +1. [Fork](https://help.github.com/articles/fork-a-repo/) this repository to your own GitHub account and then [clone](https://help.github.com/articles/cloning-a-repository/) it to your local device +2. Link the package to the global module directory: `npm link` +3. Within the module you want to test your local development instance of ms, just link it to the dependencies: `npm link ms`. Instead of the default one from npm, Node.js will now use your clone of ms! + +As always, you can run the tests using: `npm test` diff --git a/sandbox/tgbot/node_modules/node-fetch/LICENSE.md b/sandbox/tgbot/node_modules/node-fetch/LICENSE.md new file mode 100644 index 0000000..660ffec --- /dev/null +++ b/sandbox/tgbot/node_modules/node-fetch/LICENSE.md @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) 2016 David Frank + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + diff --git a/sandbox/tgbot/node_modules/node-fetch/README.md b/sandbox/tgbot/node_modules/node-fetch/README.md new file mode 100644 index 0000000..55f09b7 --- /dev/null +++ b/sandbox/tgbot/node_modules/node-fetch/README.md @@ -0,0 +1,634 @@ +node-fetch +========== + +[![npm version][npm-image]][npm-url] +[![build status][travis-image]][travis-url] +[![coverage status][codecov-image]][codecov-url] +[![install size][install-size-image]][install-size-url] +[![Discord][discord-image]][discord-url] + +A light-weight module that brings `window.fetch` to Node.js + +(We are looking for [v2 maintainers and collaborators](https://github.com/bitinn/node-fetch/issues/567)) + +[![Backers][opencollective-image]][opencollective-url] + + + +- [Motivation](#motivation) +- [Features](#features) +- [Difference from client-side fetch](#difference-from-client-side-fetch) +- [Installation](#installation) +- [Loading and configuring the module](#loading-and-configuring-the-module) +- [Common Usage](#common-usage) + - [Plain text or HTML](#plain-text-or-html) + - [JSON](#json) + - [Simple Post](#simple-post) + - [Post with JSON](#post-with-json) + - [Post with form parameters](#post-with-form-parameters) + - [Handling exceptions](#handling-exceptions) + - [Handling client and server errors](#handling-client-and-server-errors) +- [Advanced Usage](#advanced-usage) + - [Streams](#streams) + - [Buffer](#buffer) + - [Accessing Headers and other Meta data](#accessing-headers-and-other-meta-data) + - [Extract Set-Cookie Header](#extract-set-cookie-header) + - [Post data using a file stream](#post-data-using-a-file-stream) + - [Post with form-data (detect multipart)](#post-with-form-data-detect-multipart) + - [Request cancellation with AbortSignal](#request-cancellation-with-abortsignal) +- [API](#api) + - [fetch(url[, options])](#fetchurl-options) + - [Options](#options) + - [Class: Request](#class-request) + - [Class: Response](#class-response) + - [Class: Headers](#class-headers) + - [Interface: Body](#interface-body) + - [Class: FetchError](#class-fetcherror) +- [License](#license) +- [Acknowledgement](#acknowledgement) + + + +## Motivation + +Instead of implementing `XMLHttpRequest` in Node.js to run browser-specific [Fetch polyfill](https://github.com/github/fetch), why not go from native `http` to `fetch` API directly? Hence, `node-fetch`, minimal code for a `window.fetch` compatible API on Node.js runtime. + +See Matt Andrews' [isomorphic-fetch](https://github.com/matthew-andrews/isomorphic-fetch) or Leonardo Quixada's [cross-fetch](https://github.com/lquixada/cross-fetch) for isomorphic usage (exports `node-fetch` for server-side, `whatwg-fetch` for client-side). + +## Features + +- Stay consistent with `window.fetch` API. +- Make conscious trade-off when following [WHATWG fetch spec][whatwg-fetch] and [stream spec](https://streams.spec.whatwg.org/) implementation details, document known differences. +- Use native promise but allow substituting it with [insert your favorite promise library]. +- Use native Node streams for body on both request and response. +- Decode content encoding (gzip/deflate) properly and convert string output (such as `res.text()` and `res.json()`) to UTF-8 automatically. +- Useful extensions such as timeout, redirect limit, response size limit, [explicit errors](ERROR-HANDLING.md) for troubleshooting. + +## Difference from client-side fetch + +- See [Known Differences](LIMITS.md) for details. +- If you happen to use a missing feature that `window.fetch` offers, feel free to open an issue. +- Pull requests are welcomed too! + +## Installation + +Current stable release (`2.x`) + +```sh +$ npm install node-fetch +``` + +## Loading and configuring the module +We suggest you load the module via `require` until the stabilization of ES modules in node: +```js +const fetch = require('node-fetch'); +``` + +If you are using a Promise library other than native, set it through `fetch.Promise`: +```js +const Bluebird = require('bluebird'); + +fetch.Promise = Bluebird; +``` + +## Common Usage + +NOTE: The documentation below is up-to-date with `2.x` releases; see the [`1.x` readme](https://github.com/bitinn/node-fetch/blob/1.x/README.md), [changelog](https://github.com/bitinn/node-fetch/blob/1.x/CHANGELOG.md) and [2.x upgrade guide](UPGRADE-GUIDE.md) for the differences. + +#### Plain text or HTML +```js +fetch('https://github.com/') + .then(res => res.text()) + .then(body => console.log(body)); +``` + +#### JSON + +```js + +fetch('https://api.github.com/users/github') + .then(res => res.json()) + .then(json => console.log(json)); +``` + +#### Simple Post +```js +fetch('https://httpbin.org/post', { method: 'POST', body: 'a=1' }) + .then(res => res.json()) // expecting a json response + .then(json => console.log(json)); +``` + +#### Post with JSON + +```js +const body = { a: 1 }; + +fetch('https://httpbin.org/post', { + method: 'post', + body: JSON.stringify(body), + headers: { 'Content-Type': 'application/json' }, + }) + .then(res => res.json()) + .then(json => console.log(json)); +``` + +#### Post with form parameters +`URLSearchParams` is available in Node.js as of v7.5.0. See [official documentation](https://nodejs.org/api/url.html#url_class_urlsearchparams) for more usage methods. + +NOTE: The `Content-Type` header is only set automatically to `x-www-form-urlencoded` when an instance of `URLSearchParams` is given as such: + +```js +const { URLSearchParams } = require('url'); + +const params = new URLSearchParams(); +params.append('a', 1); + +fetch('https://httpbin.org/post', { method: 'POST', body: params }) + .then(res => res.json()) + .then(json => console.log(json)); +``` + +#### Handling exceptions +NOTE: 3xx-5xx responses are *NOT* exceptions and should be handled in `then()`; see the next section for more information. + +Adding a catch to the fetch promise chain will catch *all* exceptions, such as errors originating from node core libraries, network errors and operational errors, which are instances of FetchError. See the [error handling document](ERROR-HANDLING.md) for more details. + +```js +fetch('https://domain.invalid/') + .catch(err => console.error(err)); +``` + +#### Handling client and server errors +It is common to create a helper function to check that the response contains no client (4xx) or server (5xx) error responses: + +```js +function checkStatus(res) { + if (res.ok) { // res.status >= 200 && res.status < 300 + return res; + } else { + throw MyCustomError(res.statusText); + } +} + +fetch('https://httpbin.org/status/400') + .then(checkStatus) + .then(res => console.log('will not get here...')) +``` + +## Advanced Usage + +#### Streams +The "Node.js way" is to use streams when possible: + +```js +fetch('https://assets-cdn.github.com/images/modules/logos_page/Octocat.png') + .then(res => { + const dest = fs.createWriteStream('./octocat.png'); + res.body.pipe(dest); + }); +``` + +In Node.js 14 you can also use async iterators to read `body`; however, be careful to catch +errors -- the longer a response runs, the more likely it is to encounter an error. + +```js +const fetch = require('node-fetch'); +const response = await fetch('https://httpbin.org/stream/3'); +try { + for await (const chunk of response.body) { + console.dir(JSON.parse(chunk.toString())); + } +} catch (err) { + console.error(err.stack); +} +``` + +In Node.js 12 you can also use async iterators to read `body`; however, async iterators with streams +did not mature until Node.js 14, so you need to do some extra work to ensure you handle errors +directly from the stream and wait on it response to fully close. + +```js +const fetch = require('node-fetch'); +const read = async body => { + let error; + body.on('error', err => { + error = err; + }); + for await (const chunk of body) { + console.dir(JSON.parse(chunk.toString())); + } + return new Promise((resolve, reject) => { + body.on('close', () => { + error ? reject(error) : resolve(); + }); + }); +}; +try { + const response = await fetch('https://httpbin.org/stream/3'); + await read(response.body); +} catch (err) { + console.error(err.stack); +} +``` + +#### Buffer +If you prefer to cache binary data in full, use buffer(). (NOTE: `buffer()` is a `node-fetch`-only API) + +```js +const fileType = require('file-type'); + +fetch('https://assets-cdn.github.com/images/modules/logos_page/Octocat.png') + .then(res => res.buffer()) + .then(buffer => fileType(buffer)) + .then(type => { /* ... */ }); +``` + +#### Accessing Headers and other Meta data +```js +fetch('https://github.com/') + .then(res => { + console.log(res.ok); + console.log(res.status); + console.log(res.statusText); + console.log(res.headers.raw()); + console.log(res.headers.get('content-type')); + }); +``` + +#### Extract Set-Cookie Header + +Unlike browsers, you can access raw `Set-Cookie` headers manually using `Headers.raw()`. This is a `node-fetch` only API. + +```js +fetch(url).then(res => { + // returns an array of values, instead of a string of comma-separated values + console.log(res.headers.raw()['set-cookie']); +}); +``` + +#### Post data using a file stream + +```js +const { createReadStream } = require('fs'); + +const stream = createReadStream('input.txt'); + +fetch('https://httpbin.org/post', { method: 'POST', body: stream }) + .then(res => res.json()) + .then(json => console.log(json)); +``` + +#### Post with form-data (detect multipart) + +```js +const FormData = require('form-data'); + +const form = new FormData(); +form.append('a', 1); + +fetch('https://httpbin.org/post', { method: 'POST', body: form }) + .then(res => res.json()) + .then(json => console.log(json)); + +// OR, using custom headers +// NOTE: getHeaders() is non-standard API + +const form = new FormData(); +form.append('a', 1); + +const options = { + method: 'POST', + body: form, + headers: form.getHeaders() +} + +fetch('https://httpbin.org/post', options) + .then(res => res.json()) + .then(json => console.log(json)); +``` + +#### Request cancellation with AbortSignal + +> NOTE: You may cancel streamed requests only on Node >= v8.0.0 + +You may cancel requests with `AbortController`. A suggested implementation is [`abort-controller`](https://www.npmjs.com/package/abort-controller). + +An example of timing out a request after 150ms could be achieved as the following: + +```js +import AbortController from 'abort-controller'; + +const controller = new AbortController(); +const timeout = setTimeout( + () => { controller.abort(); }, + 150, +); + +fetch(url, { signal: controller.signal }) + .then(res => res.json()) + .then( + data => { + useData(data) + }, + err => { + if (err.name === 'AbortError') { + // request was aborted + } + }, + ) + .finally(() => { + clearTimeout(timeout); + }); +``` + +See [test cases](https://github.com/bitinn/node-fetch/blob/master/test/test.js) for more examples. + + +## API + +### fetch(url[, options]) + +- `url` A string representing the URL for fetching +- `options` [Options](#fetch-options) for the HTTP(S) request +- Returns: Promise<[Response](#class-response)> + +Perform an HTTP(S) fetch. + +`url` should be an absolute url, such as `https://example.com/`. A path-relative URL (`/file/under/root`) or protocol-relative URL (`//can-be-http-or-https.com/`) will result in a rejected `Promise`. + + +### Options + +The default values are shown after each option key. + +```js +{ + // These properties are part of the Fetch Standard + method: 'GET', + headers: {}, // request headers. format is the identical to that accepted by the Headers constructor (see below) + body: null, // request body. can be null, a string, a Buffer, a Blob, or a Node.js Readable stream + redirect: 'follow', // set to `manual` to extract redirect headers, `error` to reject redirect + signal: null, // pass an instance of AbortSignal to optionally abort requests + + // The following properties are node-fetch extensions + follow: 20, // maximum redirect count. 0 to not follow redirect + timeout: 0, // req/res timeout in ms, it resets on redirect. 0 to disable (OS limit applies). Signal is recommended instead. + compress: true, // support gzip/deflate content encoding. false to disable + size: 0, // maximum response body size in bytes. 0 to disable + agent: null // http(s).Agent instance or function that returns an instance (see below) +} +``` + +##### Default Headers + +If no values are set, the following request headers will be sent automatically: + +Header | Value +------------------- | -------------------------------------------------------- +`Accept-Encoding` | `gzip,deflate` _(when `options.compress === true`)_ +`Accept` | `*/*` +`Content-Length` | _(automatically calculated, if possible)_ +`Transfer-Encoding` | `chunked` _(when `req.body` is a stream)_ +`User-Agent` | `node-fetch/1.0 (+https://github.com/bitinn/node-fetch)` + +Note: when `body` is a `Stream`, `Content-Length` is not set automatically. + +##### Custom Agent + +The `agent` option allows you to specify networking related options which are out of the scope of Fetch, including and not limited to the following: + +- Support self-signed certificate +- Use only IPv4 or IPv6 +- Custom DNS Lookup + +See [`http.Agent`](https://nodejs.org/api/http.html#http_new_agent_options) for more information. + +If no agent is specified, the default agent provided by Node.js is used. Note that [this changed in Node.js 19](https://github.com/nodejs/node/blob/4267b92604ad78584244488e7f7508a690cb80d0/lib/_http_agent.js#L564) to have `keepalive` true by default. If you wish to enable `keepalive` in an earlier version of Node.js, you can override the agent as per the following code sample. + +In addition, the `agent` option accepts a function that returns `http`(s)`.Agent` instance given current [URL](https://nodejs.org/api/url.html), this is useful during a redirection chain across HTTP and HTTPS protocol. + +```js +const httpAgent = new http.Agent({ + keepAlive: true +}); +const httpsAgent = new https.Agent({ + keepAlive: true +}); + +const options = { + agent: function (_parsedURL) { + if (_parsedURL.protocol == 'http:') { + return httpAgent; + } else { + return httpsAgent; + } + } +} +``` + + +### Class: Request + +An HTTP(S) request containing information about URL, method, headers, and the body. This class implements the [Body](#iface-body) interface. + +Due to the nature of Node.js, the following properties are not implemented at this moment: + +- `type` +- `destination` +- `referrer` +- `referrerPolicy` +- `mode` +- `credentials` +- `cache` +- `integrity` +- `keepalive` + +The following node-fetch extension properties are provided: + +- `follow` +- `compress` +- `counter` +- `agent` + +See [options](#fetch-options) for exact meaning of these extensions. + +#### new Request(input[, options]) + +*(spec-compliant)* + +- `input` A string representing a URL, or another `Request` (which will be cloned) +- `options` [Options][#fetch-options] for the HTTP(S) request + +Constructs a new `Request` object. The constructor is identical to that in the [browser](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request). + +In most cases, directly `fetch(url, options)` is simpler than creating a `Request` object. + + +### Class: Response + +An HTTP(S) response. This class implements the [Body](#iface-body) interface. + +The following properties are not implemented in node-fetch at this moment: + +- `Response.error()` +- `Response.redirect()` +- `type` +- `trailer` + +#### new Response([body[, options]]) + +*(spec-compliant)* + +- `body` A `String` or [`Readable` stream][node-readable] +- `options` A [`ResponseInit`][response-init] options dictionary + +Constructs a new `Response` object. The constructor is identical to that in the [browser](https://developer.mozilla.org/en-US/docs/Web/API/Response/Response). + +Because Node.js does not implement service workers (for which this class was designed), one rarely has to construct a `Response` directly. + +#### response.ok + +*(spec-compliant)* + +Convenience property representing if the request ended normally. Will evaluate to true if the response status was greater than or equal to 200 but smaller than 300. + +#### response.redirected + +*(spec-compliant)* + +Convenience property representing if the request has been redirected at least once. Will evaluate to true if the internal redirect counter is greater than 0. + + +### Class: Headers + +This class allows manipulating and iterating over a set of HTTP headers. All methods specified in the [Fetch Standard][whatwg-fetch] are implemented. + +#### new Headers([init]) + +*(spec-compliant)* + +- `init` Optional argument to pre-fill the `Headers` object + +Construct a new `Headers` object. `init` can be either `null`, a `Headers` object, an key-value map object or any iterable object. + +```js +// Example adapted from https://fetch.spec.whatwg.org/#example-headers-class + +const meta = { + 'Content-Type': 'text/xml', + 'Breaking-Bad': '<3' +}; +const headers = new Headers(meta); + +// The above is equivalent to +const meta = [ + [ 'Content-Type', 'text/xml' ], + [ 'Breaking-Bad', '<3' ] +]; +const headers = new Headers(meta); + +// You can in fact use any iterable objects, like a Map or even another Headers +const meta = new Map(); +meta.set('Content-Type', 'text/xml'); +meta.set('Breaking-Bad', '<3'); +const headers = new Headers(meta); +const copyOfHeaders = new Headers(headers); +``` + + +### Interface: Body + +`Body` is an abstract interface with methods that are applicable to both `Request` and `Response` classes. + +The following methods are not yet implemented in node-fetch at this moment: + +- `formData()` + +#### body.body + +*(deviation from spec)* + +* Node.js [`Readable` stream][node-readable] + +Data are encapsulated in the `Body` object. Note that while the [Fetch Standard][whatwg-fetch] requires the property to always be a WHATWG `ReadableStream`, in node-fetch it is a Node.js [`Readable` stream][node-readable]. + +#### body.bodyUsed + +*(spec-compliant)* + +* `Boolean` + +A boolean property for if this body has been consumed. Per the specs, a consumed body cannot be used again. + +#### body.arrayBuffer() +#### body.blob() +#### body.json() +#### body.text() + +*(spec-compliant)* + +* Returns: Promise + +Consume the body and return a promise that will resolve to one of these formats. + +#### body.buffer() + +*(node-fetch extension)* + +* Returns: Promise<Buffer> + +Consume the body and return a promise that will resolve to a Buffer. + +#### body.textConverted() + +*(node-fetch extension)* + +* Returns: Promise<String> + +Identical to `body.text()`, except instead of always converting to UTF-8, encoding sniffing will be performed and text converted to UTF-8 if possible. + +(This API requires an optional dependency of the npm package [encoding](https://www.npmjs.com/package/encoding), which you need to install manually. `webpack` users may see [a warning message](https://github.com/bitinn/node-fetch/issues/412#issuecomment-379007792) due to this optional dependency.) + + +### Class: FetchError + +*(node-fetch extension)* + +An operational error in the fetching process. See [ERROR-HANDLING.md][] for more info. + + +### Class: AbortError + +*(node-fetch extension)* + +An Error thrown when the request is aborted in response to an `AbortSignal`'s `abort` event. It has a `name` property of `AbortError`. See [ERROR-HANDLING.MD][] for more info. + +## Acknowledgement + +Thanks to [github/fetch](https://github.com/github/fetch) for providing a solid implementation reference. + +`node-fetch` v1 was maintained by [@bitinn](https://github.com/bitinn); v2 was maintained by [@TimothyGu](https://github.com/timothygu), [@bitinn](https://github.com/bitinn) and [@jimmywarting](https://github.com/jimmywarting); v2 readme is written by [@jkantr](https://github.com/jkantr). + +## License + +MIT + +[npm-image]: https://flat.badgen.net/npm/v/node-fetch +[npm-url]: https://www.npmjs.com/package/node-fetch +[travis-image]: https://flat.badgen.net/travis/bitinn/node-fetch +[travis-url]: https://travis-ci.org/bitinn/node-fetch +[codecov-image]: https://flat.badgen.net/codecov/c/github/bitinn/node-fetch/master +[codecov-url]: https://codecov.io/gh/bitinn/node-fetch +[install-size-image]: https://flat.badgen.net/packagephobia/install/node-fetch +[install-size-url]: https://packagephobia.now.sh/result?p=node-fetch +[discord-image]: https://img.shields.io/discord/619915844268326952?color=%237289DA&label=Discord&style=flat-square +[discord-url]: https://discord.gg/Zxbndcm +[opencollective-image]: https://opencollective.com/node-fetch/backers.svg +[opencollective-url]: https://opencollective.com/node-fetch +[whatwg-fetch]: https://fetch.spec.whatwg.org/ +[response-init]: https://fetch.spec.whatwg.org/#responseinit +[node-readable]: https://nodejs.org/api/stream.html#stream_readable_streams +[mdn-headers]: https://developer.mozilla.org/en-US/docs/Web/API/Headers +[LIMITS.md]: https://github.com/bitinn/node-fetch/blob/master/LIMITS.md +[ERROR-HANDLING.md]: https://github.com/bitinn/node-fetch/blob/master/ERROR-HANDLING.md +[UPGRADE-GUIDE.md]: https://github.com/bitinn/node-fetch/blob/master/UPGRADE-GUIDE.md diff --git a/sandbox/tgbot/node_modules/node-fetch/browser.js b/sandbox/tgbot/node_modules/node-fetch/browser.js new file mode 100644 index 0000000..ee86265 --- /dev/null +++ b/sandbox/tgbot/node_modules/node-fetch/browser.js @@ -0,0 +1,25 @@ +"use strict"; + +// ref: https://github.com/tc39/proposal-global +var getGlobal = function () { + // the only reliable means to get the global object is + // `Function('return this')()` + // However, this causes CSP violations in Chrome apps. + if (typeof self !== 'undefined') { return self; } + if (typeof window !== 'undefined') { return window; } + if (typeof global !== 'undefined') { return global; } + throw new Error('unable to locate global object'); +} + +var globalObject = getGlobal(); + +module.exports = exports = globalObject.fetch; + +// Needed for TypeScript and Webpack. +if (globalObject.fetch) { + exports.default = globalObject.fetch.bind(globalObject); +} + +exports.Headers = globalObject.Headers; +exports.Request = globalObject.Request; +exports.Response = globalObject.Response; diff --git a/sandbox/tgbot/node_modules/node-fetch/lib/index.es.js b/sandbox/tgbot/node_modules/node-fetch/lib/index.es.js new file mode 100644 index 0000000..aae9799 --- /dev/null +++ b/sandbox/tgbot/node_modules/node-fetch/lib/index.es.js @@ -0,0 +1,1777 @@ +process.emitWarning("The .es.js file is deprecated. Use .mjs instead."); + +import Stream from 'stream'; +import http from 'http'; +import Url from 'url'; +import whatwgUrl from 'whatwg-url'; +import https from 'https'; +import zlib from 'zlib'; + +// Based on https://github.com/tmpvar/jsdom/blob/aa85b2abf07766ff7bf5c1f6daafb3726f2f2db5/lib/jsdom/living/blob.js + +// fix for "Readable" isn't a named export issue +const Readable = Stream.Readable; + +const BUFFER = Symbol('buffer'); +const TYPE = Symbol('type'); + +class Blob { + constructor() { + this[TYPE] = ''; + + const blobParts = arguments[0]; + const options = arguments[1]; + + const buffers = []; + let size = 0; + + if (blobParts) { + const a = blobParts; + const length = Number(a.length); + for (let i = 0; i < length; i++) { + const element = a[i]; + let buffer; + if (element instanceof Buffer) { + buffer = element; + } else if (ArrayBuffer.isView(element)) { + buffer = Buffer.from(element.buffer, element.byteOffset, element.byteLength); + } else if (element instanceof ArrayBuffer) { + buffer = Buffer.from(element); + } else if (element instanceof Blob) { + buffer = element[BUFFER]; + } else { + buffer = Buffer.from(typeof element === 'string' ? element : String(element)); + } + size += buffer.length; + buffers.push(buffer); + } + } + + this[BUFFER] = Buffer.concat(buffers); + + let type = options && options.type !== undefined && String(options.type).toLowerCase(); + if (type && !/[^\u0020-\u007E]/.test(type)) { + this[TYPE] = type; + } + } + get size() { + return this[BUFFER].length; + } + get type() { + return this[TYPE]; + } + text() { + return Promise.resolve(this[BUFFER].toString()); + } + arrayBuffer() { + const buf = this[BUFFER]; + const ab = buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength); + return Promise.resolve(ab); + } + stream() { + const readable = new Readable(); + readable._read = function () {}; + readable.push(this[BUFFER]); + readable.push(null); + return readable; + } + toString() { + return '[object Blob]'; + } + slice() { + const size = this.size; + + const start = arguments[0]; + const end = arguments[1]; + let relativeStart, relativeEnd; + if (start === undefined) { + relativeStart = 0; + } else if (start < 0) { + relativeStart = Math.max(size + start, 0); + } else { + relativeStart = Math.min(start, size); + } + if (end === undefined) { + relativeEnd = size; + } else if (end < 0) { + relativeEnd = Math.max(size + end, 0); + } else { + relativeEnd = Math.min(end, size); + } + const span = Math.max(relativeEnd - relativeStart, 0); + + const buffer = this[BUFFER]; + const slicedBuffer = buffer.slice(relativeStart, relativeStart + span); + const blob = new Blob([], { type: arguments[2] }); + blob[BUFFER] = slicedBuffer; + return blob; + } +} + +Object.defineProperties(Blob.prototype, { + size: { enumerable: true }, + type: { enumerable: true }, + slice: { enumerable: true } +}); + +Object.defineProperty(Blob.prototype, Symbol.toStringTag, { + value: 'Blob', + writable: false, + enumerable: false, + configurable: true +}); + +/** + * fetch-error.js + * + * FetchError interface for operational errors + */ + +/** + * Create FetchError instance + * + * @param String message Error message for human + * @param String type Error type for machine + * @param String systemError For Node.js system error + * @return FetchError + */ +function FetchError(message, type, systemError) { + Error.call(this, message); + + this.message = message; + this.type = type; + + // when err.type is `system`, err.code contains system error code + if (systemError) { + this.code = this.errno = systemError.code; + } + + // hide custom error implementation details from end-users + Error.captureStackTrace(this, this.constructor); +} + +FetchError.prototype = Object.create(Error.prototype); +FetchError.prototype.constructor = FetchError; +FetchError.prototype.name = 'FetchError'; + +let convert; +try { + convert = require('encoding').convert; +} catch (e) {} + +const INTERNALS = Symbol('Body internals'); + +// fix an issue where "PassThrough" isn't a named export for node <10 +const PassThrough = Stream.PassThrough; + +/** + * Body mixin + * + * Ref: https://fetch.spec.whatwg.org/#body + * + * @param Stream body Readable stream + * @param Object opts Response options + * @return Void + */ +function Body(body) { + var _this = this; + + var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, + _ref$size = _ref.size; + + let size = _ref$size === undefined ? 0 : _ref$size; + var _ref$timeout = _ref.timeout; + let timeout = _ref$timeout === undefined ? 0 : _ref$timeout; + + if (body == null) { + // body is undefined or null + body = null; + } else if (isURLSearchParams(body)) { + // body is a URLSearchParams + body = Buffer.from(body.toString()); + } else if (isBlob(body)) ; else if (Buffer.isBuffer(body)) ; else if (Object.prototype.toString.call(body) === '[object ArrayBuffer]') { + // body is ArrayBuffer + body = Buffer.from(body); + } else if (ArrayBuffer.isView(body)) { + // body is ArrayBufferView + body = Buffer.from(body.buffer, body.byteOffset, body.byteLength); + } else if (body instanceof Stream) ; else { + // none of the above + // coerce to string then buffer + body = Buffer.from(String(body)); + } + this[INTERNALS] = { + body, + disturbed: false, + error: null + }; + this.size = size; + this.timeout = timeout; + + if (body instanceof Stream) { + body.on('error', function (err) { + const error = err.name === 'AbortError' ? err : new FetchError(`Invalid response body while trying to fetch ${_this.url}: ${err.message}`, 'system', err); + _this[INTERNALS].error = error; + }); + } +} + +Body.prototype = { + get body() { + return this[INTERNALS].body; + }, + + get bodyUsed() { + return this[INTERNALS].disturbed; + }, + + /** + * Decode response as ArrayBuffer + * + * @return Promise + */ + arrayBuffer() { + return consumeBody.call(this).then(function (buf) { + return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength); + }); + }, + + /** + * Return raw response as Blob + * + * @return Promise + */ + blob() { + let ct = this.headers && this.headers.get('content-type') || ''; + return consumeBody.call(this).then(function (buf) { + return Object.assign( + // Prevent copying + new Blob([], { + type: ct.toLowerCase() + }), { + [BUFFER]: buf + }); + }); + }, + + /** + * Decode response as json + * + * @return Promise + */ + json() { + var _this2 = this; + + return consumeBody.call(this).then(function (buffer) { + try { + return JSON.parse(buffer.toString()); + } catch (err) { + return Body.Promise.reject(new FetchError(`invalid json response body at ${_this2.url} reason: ${err.message}`, 'invalid-json')); + } + }); + }, + + /** + * Decode response as text + * + * @return Promise + */ + text() { + return consumeBody.call(this).then(function (buffer) { + return buffer.toString(); + }); + }, + + /** + * Decode response as buffer (non-spec api) + * + * @return Promise + */ + buffer() { + return consumeBody.call(this); + }, + + /** + * Decode response as text, while automatically detecting the encoding and + * trying to decode to UTF-8 (non-spec api) + * + * @return Promise + */ + textConverted() { + var _this3 = this; + + return consumeBody.call(this).then(function (buffer) { + return convertBody(buffer, _this3.headers); + }); + } +}; + +// In browsers, all properties are enumerable. +Object.defineProperties(Body.prototype, { + body: { enumerable: true }, + bodyUsed: { enumerable: true }, + arrayBuffer: { enumerable: true }, + blob: { enumerable: true }, + json: { enumerable: true }, + text: { enumerable: true } +}); + +Body.mixIn = function (proto) { + for (const name of Object.getOwnPropertyNames(Body.prototype)) { + // istanbul ignore else: future proof + if (!(name in proto)) { + const desc = Object.getOwnPropertyDescriptor(Body.prototype, name); + Object.defineProperty(proto, name, desc); + } + } +}; + +/** + * Consume and convert an entire Body to a Buffer. + * + * Ref: https://fetch.spec.whatwg.org/#concept-body-consume-body + * + * @return Promise + */ +function consumeBody() { + var _this4 = this; + + if (this[INTERNALS].disturbed) { + return Body.Promise.reject(new TypeError(`body used already for: ${this.url}`)); + } + + this[INTERNALS].disturbed = true; + + if (this[INTERNALS].error) { + return Body.Promise.reject(this[INTERNALS].error); + } + + let body = this.body; + + // body is null + if (body === null) { + return Body.Promise.resolve(Buffer.alloc(0)); + } + + // body is blob + if (isBlob(body)) { + body = body.stream(); + } + + // body is buffer + if (Buffer.isBuffer(body)) { + return Body.Promise.resolve(body); + } + + // istanbul ignore if: should never happen + if (!(body instanceof Stream)) { + return Body.Promise.resolve(Buffer.alloc(0)); + } + + // body is stream + // get ready to actually consume the body + let accum = []; + let accumBytes = 0; + let abort = false; + + return new Body.Promise(function (resolve, reject) { + let resTimeout; + + // allow timeout on slow response body + if (_this4.timeout) { + resTimeout = setTimeout(function () { + abort = true; + reject(new FetchError(`Response timeout while trying to fetch ${_this4.url} (over ${_this4.timeout}ms)`, 'body-timeout')); + }, _this4.timeout); + } + + // handle stream errors + body.on('error', function (err) { + if (err.name === 'AbortError') { + // if the request was aborted, reject with this Error + abort = true; + reject(err); + } else { + // other errors, such as incorrect content-encoding + reject(new FetchError(`Invalid response body while trying to fetch ${_this4.url}: ${err.message}`, 'system', err)); + } + }); + + body.on('data', function (chunk) { + if (abort || chunk === null) { + return; + } + + if (_this4.size && accumBytes + chunk.length > _this4.size) { + abort = true; + reject(new FetchError(`content size at ${_this4.url} over limit: ${_this4.size}`, 'max-size')); + return; + } + + accumBytes += chunk.length; + accum.push(chunk); + }); + + body.on('end', function () { + if (abort) { + return; + } + + clearTimeout(resTimeout); + + try { + resolve(Buffer.concat(accum, accumBytes)); + } catch (err) { + // handle streams that have accumulated too much data (issue #414) + reject(new FetchError(`Could not create Buffer from response body for ${_this4.url}: ${err.message}`, 'system', err)); + } + }); + }); +} + +/** + * Detect buffer encoding and convert to target encoding + * ref: http://www.w3.org/TR/2011/WD-html5-20110113/parsing.html#determining-the-character-encoding + * + * @param Buffer buffer Incoming buffer + * @param String encoding Target encoding + * @return String + */ +function convertBody(buffer, headers) { + if (typeof convert !== 'function') { + throw new Error('The package `encoding` must be installed to use the textConverted() function'); + } + + const ct = headers.get('content-type'); + let charset = 'utf-8'; + let res, str; + + // header + if (ct) { + res = /charset=([^;]*)/i.exec(ct); + } + + // no charset in content type, peek at response body for at most 1024 bytes + str = buffer.slice(0, 1024).toString(); + + // html5 + if (!res && str) { + res = / 0 && arguments[0] !== undefined ? arguments[0] : undefined; + + this[MAP] = Object.create(null); + + if (init instanceof Headers) { + const rawHeaders = init.raw(); + const headerNames = Object.keys(rawHeaders); + + for (const headerName of headerNames) { + for (const value of rawHeaders[headerName]) { + this.append(headerName, value); + } + } + + return; + } + + // We don't worry about converting prop to ByteString here as append() + // will handle it. + if (init == null) ; else if (typeof init === 'object') { + const method = init[Symbol.iterator]; + if (method != null) { + if (typeof method !== 'function') { + throw new TypeError('Header pairs must be iterable'); + } + + // sequence> + // Note: per spec we have to first exhaust the lists then process them + const pairs = []; + for (const pair of init) { + if (typeof pair !== 'object' || typeof pair[Symbol.iterator] !== 'function') { + throw new TypeError('Each header pair must be iterable'); + } + pairs.push(Array.from(pair)); + } + + for (const pair of pairs) { + if (pair.length !== 2) { + throw new TypeError('Each header pair must be a name/value tuple'); + } + this.append(pair[0], pair[1]); + } + } else { + // record + for (const key of Object.keys(init)) { + const value = init[key]; + this.append(key, value); + } + } + } else { + throw new TypeError('Provided initializer must be an object'); + } + } + + /** + * Return combined header value given name + * + * @param String name Header name + * @return Mixed + */ + get(name) { + name = `${name}`; + validateName(name); + const key = find(this[MAP], name); + if (key === undefined) { + return null; + } + + return this[MAP][key].join(', '); + } + + /** + * Iterate over all headers + * + * @param Function callback Executed for each item with parameters (value, name, thisArg) + * @param Boolean thisArg `this` context for callback function + * @return Void + */ + forEach(callback) { + let thisArg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined; + + let pairs = getHeaders(this); + let i = 0; + while (i < pairs.length) { + var _pairs$i = pairs[i]; + const name = _pairs$i[0], + value = _pairs$i[1]; + + callback.call(thisArg, value, name, this); + pairs = getHeaders(this); + i++; + } + } + + /** + * Overwrite header values given name + * + * @param String name Header name + * @param String value Header value + * @return Void + */ + set(name, value) { + name = `${name}`; + value = `${value}`; + validateName(name); + validateValue(value); + const key = find(this[MAP], name); + this[MAP][key !== undefined ? key : name] = [value]; + } + + /** + * Append a value onto existing header + * + * @param String name Header name + * @param String value Header value + * @return Void + */ + append(name, value) { + name = `${name}`; + value = `${value}`; + validateName(name); + validateValue(value); + const key = find(this[MAP], name); + if (key !== undefined) { + this[MAP][key].push(value); + } else { + this[MAP][name] = [value]; + } + } + + /** + * Check for header name existence + * + * @param String name Header name + * @return Boolean + */ + has(name) { + name = `${name}`; + validateName(name); + return find(this[MAP], name) !== undefined; + } + + /** + * Delete all header values given name + * + * @param String name Header name + * @return Void + */ + delete(name) { + name = `${name}`; + validateName(name); + const key = find(this[MAP], name); + if (key !== undefined) { + delete this[MAP][key]; + } + } + + /** + * Return raw headers (non-spec api) + * + * @return Object + */ + raw() { + return this[MAP]; + } + + /** + * Get an iterator on keys. + * + * @return Iterator + */ + keys() { + return createHeadersIterator(this, 'key'); + } + + /** + * Get an iterator on values. + * + * @return Iterator + */ + values() { + return createHeadersIterator(this, 'value'); + } + + /** + * Get an iterator on entries. + * + * This is the default iterator of the Headers object. + * + * @return Iterator + */ + [Symbol.iterator]() { + return createHeadersIterator(this, 'key+value'); + } +} +Headers.prototype.entries = Headers.prototype[Symbol.iterator]; + +Object.defineProperty(Headers.prototype, Symbol.toStringTag, { + value: 'Headers', + writable: false, + enumerable: false, + configurable: true +}); + +Object.defineProperties(Headers.prototype, { + get: { enumerable: true }, + forEach: { enumerable: true }, + set: { enumerable: true }, + append: { enumerable: true }, + has: { enumerable: true }, + delete: { enumerable: true }, + keys: { enumerable: true }, + values: { enumerable: true }, + entries: { enumerable: true } +}); + +function getHeaders(headers) { + let kind = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'key+value'; + + const keys = Object.keys(headers[MAP]).sort(); + return keys.map(kind === 'key' ? function (k) { + return k.toLowerCase(); + } : kind === 'value' ? function (k) { + return headers[MAP][k].join(', '); + } : function (k) { + return [k.toLowerCase(), headers[MAP][k].join(', ')]; + }); +} + +const INTERNAL = Symbol('internal'); + +function createHeadersIterator(target, kind) { + const iterator = Object.create(HeadersIteratorPrototype); + iterator[INTERNAL] = { + target, + kind, + index: 0 + }; + return iterator; +} + +const HeadersIteratorPrototype = Object.setPrototypeOf({ + next() { + // istanbul ignore if + if (!this || Object.getPrototypeOf(this) !== HeadersIteratorPrototype) { + throw new TypeError('Value of `this` is not a HeadersIterator'); + } + + var _INTERNAL = this[INTERNAL]; + const target = _INTERNAL.target, + kind = _INTERNAL.kind, + index = _INTERNAL.index; + + const values = getHeaders(target, kind); + const len = values.length; + if (index >= len) { + return { + value: undefined, + done: true + }; + } + + this[INTERNAL].index = index + 1; + + return { + value: values[index], + done: false + }; + } +}, Object.getPrototypeOf(Object.getPrototypeOf([][Symbol.iterator]()))); + +Object.defineProperty(HeadersIteratorPrototype, Symbol.toStringTag, { + value: 'HeadersIterator', + writable: false, + enumerable: false, + configurable: true +}); + +/** + * Export the Headers object in a form that Node.js can consume. + * + * @param Headers headers + * @return Object + */ +function exportNodeCompatibleHeaders(headers) { + const obj = Object.assign({ __proto__: null }, headers[MAP]); + + // http.request() only supports string as Host header. This hack makes + // specifying custom Host header possible. + const hostHeaderKey = find(headers[MAP], 'Host'); + if (hostHeaderKey !== undefined) { + obj[hostHeaderKey] = obj[hostHeaderKey][0]; + } + + return obj; +} + +/** + * Create a Headers object from an object of headers, ignoring those that do + * not conform to HTTP grammar productions. + * + * @param Object obj Object of headers + * @return Headers + */ +function createHeadersLenient(obj) { + const headers = new Headers(); + for (const name of Object.keys(obj)) { + if (invalidTokenRegex.test(name)) { + continue; + } + if (Array.isArray(obj[name])) { + for (const val of obj[name]) { + if (invalidHeaderCharRegex.test(val)) { + continue; + } + if (headers[MAP][name] === undefined) { + headers[MAP][name] = [val]; + } else { + headers[MAP][name].push(val); + } + } + } else if (!invalidHeaderCharRegex.test(obj[name])) { + headers[MAP][name] = [obj[name]]; + } + } + return headers; +} + +const INTERNALS$1 = Symbol('Response internals'); + +// fix an issue where "STATUS_CODES" aren't a named export for node <10 +const STATUS_CODES = http.STATUS_CODES; + +/** + * Response class + * + * @param Stream body Readable stream + * @param Object opts Response options + * @return Void + */ +class Response { + constructor() { + let body = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; + let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + + Body.call(this, body, opts); + + const status = opts.status || 200; + const headers = new Headers(opts.headers); + + if (body != null && !headers.has('Content-Type')) { + const contentType = extractContentType(body); + if (contentType) { + headers.append('Content-Type', contentType); + } + } + + this[INTERNALS$1] = { + url: opts.url, + status, + statusText: opts.statusText || STATUS_CODES[status], + headers, + counter: opts.counter + }; + } + + get url() { + return this[INTERNALS$1].url || ''; + } + + get status() { + return this[INTERNALS$1].status; + } + + /** + * Convenience property representing if the request ended normally + */ + get ok() { + return this[INTERNALS$1].status >= 200 && this[INTERNALS$1].status < 300; + } + + get redirected() { + return this[INTERNALS$1].counter > 0; + } + + get statusText() { + return this[INTERNALS$1].statusText; + } + + get headers() { + return this[INTERNALS$1].headers; + } + + /** + * Clone this response + * + * @return Response + */ + clone() { + return new Response(clone(this), { + url: this.url, + status: this.status, + statusText: this.statusText, + headers: this.headers, + ok: this.ok, + redirected: this.redirected + }); + } +} + +Body.mixIn(Response.prototype); + +Object.defineProperties(Response.prototype, { + url: { enumerable: true }, + status: { enumerable: true }, + ok: { enumerable: true }, + redirected: { enumerable: true }, + statusText: { enumerable: true }, + headers: { enumerable: true }, + clone: { enumerable: true } +}); + +Object.defineProperty(Response.prototype, Symbol.toStringTag, { + value: 'Response', + writable: false, + enumerable: false, + configurable: true +}); + +const INTERNALS$2 = Symbol('Request internals'); +const URL = Url.URL || whatwgUrl.URL; + +// fix an issue where "format", "parse" aren't a named export for node <10 +const parse_url = Url.parse; +const format_url = Url.format; + +/** + * Wrapper around `new URL` to handle arbitrary URLs + * + * @param {string} urlStr + * @return {void} + */ +function parseURL(urlStr) { + /* + Check whether the URL is absolute or not + Scheme: https://tools.ietf.org/html/rfc3986#section-3.1 + Absolute URL: https://tools.ietf.org/html/rfc3986#section-4.3 + */ + if (/^[a-zA-Z][a-zA-Z\d+\-.]*:/.exec(urlStr)) { + urlStr = new URL(urlStr).toString(); + } + + // Fallback to old implementation for arbitrary URLs + return parse_url(urlStr); +} + +const streamDestructionSupported = 'destroy' in Stream.Readable.prototype; + +/** + * Check if a value is an instance of Request. + * + * @param Mixed input + * @return Boolean + */ +function isRequest(input) { + return typeof input === 'object' && typeof input[INTERNALS$2] === 'object'; +} + +function isAbortSignal(signal) { + const proto = signal && typeof signal === 'object' && Object.getPrototypeOf(signal); + return !!(proto && proto.constructor.name === 'AbortSignal'); +} + +/** + * Request class + * + * @param Mixed input Url or Request instance + * @param Object init Custom options + * @return Void + */ +class Request { + constructor(input) { + let init = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + + let parsedURL; + + // normalize input + if (!isRequest(input)) { + if (input && input.href) { + // in order to support Node.js' Url objects; though WHATWG's URL objects + // will fall into this branch also (since their `toString()` will return + // `href` property anyway) + parsedURL = parseURL(input.href); + } else { + // coerce input to a string before attempting to parse + parsedURL = parseURL(`${input}`); + } + input = {}; + } else { + parsedURL = parseURL(input.url); + } + + let method = init.method || input.method || 'GET'; + method = method.toUpperCase(); + + if ((init.body != null || isRequest(input) && input.body !== null) && (method === 'GET' || method === 'HEAD')) { + throw new TypeError('Request with GET/HEAD method cannot have body'); + } + + let inputBody = init.body != null ? init.body : isRequest(input) && input.body !== null ? clone(input) : null; + + Body.call(this, inputBody, { + timeout: init.timeout || input.timeout || 0, + size: init.size || input.size || 0 + }); + + const headers = new Headers(init.headers || input.headers || {}); + + if (inputBody != null && !headers.has('Content-Type')) { + const contentType = extractContentType(inputBody); + if (contentType) { + headers.append('Content-Type', contentType); + } + } + + let signal = isRequest(input) ? input.signal : null; + if ('signal' in init) signal = init.signal; + + if (signal != null && !isAbortSignal(signal)) { + throw new TypeError('Expected signal to be an instanceof AbortSignal'); + } + + this[INTERNALS$2] = { + method, + redirect: init.redirect || input.redirect || 'follow', + headers, + parsedURL, + signal + }; + + // node-fetch-only options + this.follow = init.follow !== undefined ? init.follow : input.follow !== undefined ? input.follow : 20; + this.compress = init.compress !== undefined ? init.compress : input.compress !== undefined ? input.compress : true; + this.counter = init.counter || input.counter || 0; + this.agent = init.agent || input.agent; + } + + get method() { + return this[INTERNALS$2].method; + } + + get url() { + return format_url(this[INTERNALS$2].parsedURL); + } + + get headers() { + return this[INTERNALS$2].headers; + } + + get redirect() { + return this[INTERNALS$2].redirect; + } + + get signal() { + return this[INTERNALS$2].signal; + } + + /** + * Clone this request + * + * @return Request + */ + clone() { + return new Request(this); + } +} + +Body.mixIn(Request.prototype); + +Object.defineProperty(Request.prototype, Symbol.toStringTag, { + value: 'Request', + writable: false, + enumerable: false, + configurable: true +}); + +Object.defineProperties(Request.prototype, { + method: { enumerable: true }, + url: { enumerable: true }, + headers: { enumerable: true }, + redirect: { enumerable: true }, + clone: { enumerable: true }, + signal: { enumerable: true } +}); + +/** + * Convert a Request to Node.js http request options. + * + * @param Request A Request instance + * @return Object The options object to be passed to http.request + */ +function getNodeRequestOptions(request) { + const parsedURL = request[INTERNALS$2].parsedURL; + const headers = new Headers(request[INTERNALS$2].headers); + + // fetch step 1.3 + if (!headers.has('Accept')) { + headers.set('Accept', '*/*'); + } + + // Basic fetch + if (!parsedURL.protocol || !parsedURL.hostname) { + throw new TypeError('Only absolute URLs are supported'); + } + + if (!/^https?:$/.test(parsedURL.protocol)) { + throw new TypeError('Only HTTP(S) protocols are supported'); + } + + if (request.signal && request.body instanceof Stream.Readable && !streamDestructionSupported) { + throw new Error('Cancellation of streamed requests with AbortSignal is not supported in node < 8'); + } + + // HTTP-network-or-cache fetch steps 2.4-2.7 + let contentLengthValue = null; + if (request.body == null && /^(POST|PUT)$/i.test(request.method)) { + contentLengthValue = '0'; + } + if (request.body != null) { + const totalBytes = getTotalBytes(request); + if (typeof totalBytes === 'number') { + contentLengthValue = String(totalBytes); + } + } + if (contentLengthValue) { + headers.set('Content-Length', contentLengthValue); + } + + // HTTP-network-or-cache fetch step 2.11 + if (!headers.has('User-Agent')) { + headers.set('User-Agent', 'node-fetch/1.0 (+https://github.com/bitinn/node-fetch)'); + } + + // HTTP-network-or-cache fetch step 2.15 + if (request.compress && !headers.has('Accept-Encoding')) { + headers.set('Accept-Encoding', 'gzip,deflate'); + } + + let agent = request.agent; + if (typeof agent === 'function') { + agent = agent(parsedURL); + } + + // HTTP-network fetch step 4.2 + // chunked encoding is handled by Node.js + + return Object.assign({}, parsedURL, { + method: request.method, + headers: exportNodeCompatibleHeaders(headers), + agent + }); +} + +/** + * abort-error.js + * + * AbortError interface for cancelled requests + */ + +/** + * Create AbortError instance + * + * @param String message Error message for human + * @return AbortError + */ +function AbortError(message) { + Error.call(this, message); + + this.type = 'aborted'; + this.message = message; + + // hide custom error implementation details from end-users + Error.captureStackTrace(this, this.constructor); +} + +AbortError.prototype = Object.create(Error.prototype); +AbortError.prototype.constructor = AbortError; +AbortError.prototype.name = 'AbortError'; + +const URL$1 = Url.URL || whatwgUrl.URL; + +// fix an issue where "PassThrough", "resolve" aren't a named export for node <10 +const PassThrough$1 = Stream.PassThrough; + +const isDomainOrSubdomain = function isDomainOrSubdomain(destination, original) { + const orig = new URL$1(original).hostname; + const dest = new URL$1(destination).hostname; + + return orig === dest || orig[orig.length - dest.length - 1] === '.' && orig.endsWith(dest); +}; + +/** + * isSameProtocol reports whether the two provided URLs use the same protocol. + * + * Both domains must already be in canonical form. + * @param {string|URL} original + * @param {string|URL} destination + */ +const isSameProtocol = function isSameProtocol(destination, original) { + const orig = new URL$1(original).protocol; + const dest = new URL$1(destination).protocol; + + return orig === dest; +}; + +/** + * Fetch function + * + * @param Mixed url Absolute url or Request instance + * @param Object opts Fetch options + * @return Promise + */ +function fetch(url, opts) { + + // allow custom promise + if (!fetch.Promise) { + throw new Error('native promise missing, set fetch.Promise to your favorite alternative'); + } + + Body.Promise = fetch.Promise; + + // wrap http.request into fetch + return new fetch.Promise(function (resolve, reject) { + // build request object + const request = new Request(url, opts); + const options = getNodeRequestOptions(request); + + const send = (options.protocol === 'https:' ? https : http).request; + const signal = request.signal; + + let response = null; + + const abort = function abort() { + let error = new AbortError('The user aborted a request.'); + reject(error); + if (request.body && request.body instanceof Stream.Readable) { + destroyStream(request.body, error); + } + if (!response || !response.body) return; + response.body.emit('error', error); + }; + + if (signal && signal.aborted) { + abort(); + return; + } + + const abortAndFinalize = function abortAndFinalize() { + abort(); + finalize(); + }; + + // send request + const req = send(options); + let reqTimeout; + + if (signal) { + signal.addEventListener('abort', abortAndFinalize); + } + + function finalize() { + req.abort(); + if (signal) signal.removeEventListener('abort', abortAndFinalize); + clearTimeout(reqTimeout); + } + + if (request.timeout) { + req.once('socket', function (socket) { + reqTimeout = setTimeout(function () { + reject(new FetchError(`network timeout at: ${request.url}`, 'request-timeout')); + finalize(); + }, request.timeout); + }); + } + + req.on('error', function (err) { + reject(new FetchError(`request to ${request.url} failed, reason: ${err.message}`, 'system', err)); + + if (response && response.body) { + destroyStream(response.body, err); + } + + finalize(); + }); + + fixResponseChunkedTransferBadEnding(req, function (err) { + if (signal && signal.aborted) { + return; + } + + if (response && response.body) { + destroyStream(response.body, err); + } + }); + + /* c8 ignore next 18 */ + if (parseInt(process.version.substring(1)) < 14) { + // Before Node.js 14, pipeline() does not fully support async iterators and does not always + // properly handle when the socket close/end events are out of order. + req.on('socket', function (s) { + s.addListener('close', function (hadError) { + // if a data listener is still present we didn't end cleanly + const hasDataListener = s.listenerCount('data') > 0; + + // if end happened before close but the socket didn't emit an error, do it now + if (response && hasDataListener && !hadError && !(signal && signal.aborted)) { + const err = new Error('Premature close'); + err.code = 'ERR_STREAM_PREMATURE_CLOSE'; + response.body.emit('error', err); + } + }); + }); + } + + req.on('response', function (res) { + clearTimeout(reqTimeout); + + const headers = createHeadersLenient(res.headers); + + // HTTP fetch step 5 + if (fetch.isRedirect(res.statusCode)) { + // HTTP fetch step 5.2 + const location = headers.get('Location'); + + // HTTP fetch step 5.3 + let locationURL = null; + try { + locationURL = location === null ? null : new URL$1(location, request.url).toString(); + } catch (err) { + // error here can only be invalid URL in Location: header + // do not throw when options.redirect == manual + // let the user extract the errorneous redirect URL + if (request.redirect !== 'manual') { + reject(new FetchError(`uri requested responds with an invalid redirect URL: ${location}`, 'invalid-redirect')); + finalize(); + return; + } + } + + // HTTP fetch step 5.5 + switch (request.redirect) { + case 'error': + reject(new FetchError(`uri requested responds with a redirect, redirect mode is set to error: ${request.url}`, 'no-redirect')); + finalize(); + return; + case 'manual': + // node-fetch-specific step: make manual redirect a bit easier to use by setting the Location header value to the resolved URL. + if (locationURL !== null) { + // handle corrupted header + try { + headers.set('Location', locationURL); + } catch (err) { + // istanbul ignore next: nodejs server prevent invalid response headers, we can't test this through normal request + reject(err); + } + } + break; + case 'follow': + // HTTP-redirect fetch step 2 + if (locationURL === null) { + break; + } + + // HTTP-redirect fetch step 5 + if (request.counter >= request.follow) { + reject(new FetchError(`maximum redirect reached at: ${request.url}`, 'max-redirect')); + finalize(); + return; + } + + // HTTP-redirect fetch step 6 (counter increment) + // Create a new Request object. + const requestOpts = { + headers: new Headers(request.headers), + follow: request.follow, + counter: request.counter + 1, + agent: request.agent, + compress: request.compress, + method: request.method, + body: request.body, + signal: request.signal, + timeout: request.timeout, + size: request.size + }; + + if (!isDomainOrSubdomain(request.url, locationURL) || !isSameProtocol(request.url, locationURL)) { + for (const name of ['authorization', 'www-authenticate', 'cookie', 'cookie2']) { + requestOpts.headers.delete(name); + } + } + + // HTTP-redirect fetch step 9 + if (res.statusCode !== 303 && request.body && getTotalBytes(request) === null) { + reject(new FetchError('Cannot follow redirect with body being a readable stream', 'unsupported-redirect')); + finalize(); + return; + } + + // HTTP-redirect fetch step 11 + if (res.statusCode === 303 || (res.statusCode === 301 || res.statusCode === 302) && request.method === 'POST') { + requestOpts.method = 'GET'; + requestOpts.body = undefined; + requestOpts.headers.delete('content-length'); + } + + // HTTP-redirect fetch step 15 + resolve(fetch(new Request(locationURL, requestOpts))); + finalize(); + return; + } + } + + // prepare response + res.once('end', function () { + if (signal) signal.removeEventListener('abort', abortAndFinalize); + }); + let body = res.pipe(new PassThrough$1()); + + const response_options = { + url: request.url, + status: res.statusCode, + statusText: res.statusMessage, + headers: headers, + size: request.size, + timeout: request.timeout, + counter: request.counter + }; + + // HTTP-network fetch step 12.1.1.3 + const codings = headers.get('Content-Encoding'); + + // HTTP-network fetch step 12.1.1.4: handle content codings + + // in following scenarios we ignore compression support + // 1. compression support is disabled + // 2. HEAD request + // 3. no Content-Encoding header + // 4. no content response (204) + // 5. content not modified response (304) + if (!request.compress || request.method === 'HEAD' || codings === null || res.statusCode === 204 || res.statusCode === 304) { + response = new Response(body, response_options); + resolve(response); + return; + } + + // For Node v6+ + // Be less strict when decoding compressed responses, since sometimes + // servers send slightly invalid responses that are still accepted + // by common browsers. + // Always using Z_SYNC_FLUSH is what cURL does. + const zlibOptions = { + flush: zlib.Z_SYNC_FLUSH, + finishFlush: zlib.Z_SYNC_FLUSH + }; + + // for gzip + if (codings == 'gzip' || codings == 'x-gzip') { + body = body.pipe(zlib.createGunzip(zlibOptions)); + response = new Response(body, response_options); + resolve(response); + return; + } + + // for deflate + if (codings == 'deflate' || codings == 'x-deflate') { + // handle the infamous raw deflate response from old servers + // a hack for old IIS and Apache servers + const raw = res.pipe(new PassThrough$1()); + raw.once('data', function (chunk) { + // see http://stackoverflow.com/questions/37519828 + if ((chunk[0] & 0x0F) === 0x08) { + body = body.pipe(zlib.createInflate()); + } else { + body = body.pipe(zlib.createInflateRaw()); + } + response = new Response(body, response_options); + resolve(response); + }); + raw.on('end', function () { + // some old IIS servers return zero-length OK deflate responses, so 'data' is never emitted. + if (!response) { + response = new Response(body, response_options); + resolve(response); + } + }); + return; + } + + // for br + if (codings == 'br' && typeof zlib.createBrotliDecompress === 'function') { + body = body.pipe(zlib.createBrotliDecompress()); + response = new Response(body, response_options); + resolve(response); + return; + } + + // otherwise, use response as-is + response = new Response(body, response_options); + resolve(response); + }); + + writeToStream(req, request); + }); +} +function fixResponseChunkedTransferBadEnding(request, errorCallback) { + let socket; + + request.on('socket', function (s) { + socket = s; + }); + + request.on('response', function (response) { + const headers = response.headers; + + if (headers['transfer-encoding'] === 'chunked' && !headers['content-length']) { + response.once('close', function (hadError) { + // tests for socket presence, as in some situations the + // the 'socket' event is not triggered for the request + // (happens in deno), avoids `TypeError` + // if a data listener is still present we didn't end cleanly + const hasDataListener = socket && socket.listenerCount('data') > 0; + + if (hasDataListener && !hadError) { + const err = new Error('Premature close'); + err.code = 'ERR_STREAM_PREMATURE_CLOSE'; + errorCallback(err); + } + }); + } + }); +} + +function destroyStream(stream, err) { + if (stream.destroy) { + stream.destroy(err); + } else { + // node < 8 + stream.emit('error', err); + stream.end(); + } +} + +/** + * Redirect code matching + * + * @param Number code Status code + * @return Boolean + */ +fetch.isRedirect = function (code) { + return code === 301 || code === 302 || code === 303 || code === 307 || code === 308; +}; + +// expose Promise +fetch.Promise = global.Promise; + +export default fetch; +export { Headers, Request, Response, FetchError, AbortError }; diff --git a/sandbox/tgbot/node_modules/node-fetch/lib/index.js b/sandbox/tgbot/node_modules/node-fetch/lib/index.js new file mode 100644 index 0000000..567ff5d --- /dev/null +++ b/sandbox/tgbot/node_modules/node-fetch/lib/index.js @@ -0,0 +1,1787 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { value: true }); + +function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } + +var Stream = _interopDefault(require('stream')); +var http = _interopDefault(require('http')); +var Url = _interopDefault(require('url')); +var whatwgUrl = _interopDefault(require('whatwg-url')); +var https = _interopDefault(require('https')); +var zlib = _interopDefault(require('zlib')); + +// Based on https://github.com/tmpvar/jsdom/blob/aa85b2abf07766ff7bf5c1f6daafb3726f2f2db5/lib/jsdom/living/blob.js + +// fix for "Readable" isn't a named export issue +const Readable = Stream.Readable; + +const BUFFER = Symbol('buffer'); +const TYPE = Symbol('type'); + +class Blob { + constructor() { + this[TYPE] = ''; + + const blobParts = arguments[0]; + const options = arguments[1]; + + const buffers = []; + let size = 0; + + if (blobParts) { + const a = blobParts; + const length = Number(a.length); + for (let i = 0; i < length; i++) { + const element = a[i]; + let buffer; + if (element instanceof Buffer) { + buffer = element; + } else if (ArrayBuffer.isView(element)) { + buffer = Buffer.from(element.buffer, element.byteOffset, element.byteLength); + } else if (element instanceof ArrayBuffer) { + buffer = Buffer.from(element); + } else if (element instanceof Blob) { + buffer = element[BUFFER]; + } else { + buffer = Buffer.from(typeof element === 'string' ? element : String(element)); + } + size += buffer.length; + buffers.push(buffer); + } + } + + this[BUFFER] = Buffer.concat(buffers); + + let type = options && options.type !== undefined && String(options.type).toLowerCase(); + if (type && !/[^\u0020-\u007E]/.test(type)) { + this[TYPE] = type; + } + } + get size() { + return this[BUFFER].length; + } + get type() { + return this[TYPE]; + } + text() { + return Promise.resolve(this[BUFFER].toString()); + } + arrayBuffer() { + const buf = this[BUFFER]; + const ab = buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength); + return Promise.resolve(ab); + } + stream() { + const readable = new Readable(); + readable._read = function () {}; + readable.push(this[BUFFER]); + readable.push(null); + return readable; + } + toString() { + return '[object Blob]'; + } + slice() { + const size = this.size; + + const start = arguments[0]; + const end = arguments[1]; + let relativeStart, relativeEnd; + if (start === undefined) { + relativeStart = 0; + } else if (start < 0) { + relativeStart = Math.max(size + start, 0); + } else { + relativeStart = Math.min(start, size); + } + if (end === undefined) { + relativeEnd = size; + } else if (end < 0) { + relativeEnd = Math.max(size + end, 0); + } else { + relativeEnd = Math.min(end, size); + } + const span = Math.max(relativeEnd - relativeStart, 0); + + const buffer = this[BUFFER]; + const slicedBuffer = buffer.slice(relativeStart, relativeStart + span); + const blob = new Blob([], { type: arguments[2] }); + blob[BUFFER] = slicedBuffer; + return blob; + } +} + +Object.defineProperties(Blob.prototype, { + size: { enumerable: true }, + type: { enumerable: true }, + slice: { enumerable: true } +}); + +Object.defineProperty(Blob.prototype, Symbol.toStringTag, { + value: 'Blob', + writable: false, + enumerable: false, + configurable: true +}); + +/** + * fetch-error.js + * + * FetchError interface for operational errors + */ + +/** + * Create FetchError instance + * + * @param String message Error message for human + * @param String type Error type for machine + * @param String systemError For Node.js system error + * @return FetchError + */ +function FetchError(message, type, systemError) { + Error.call(this, message); + + this.message = message; + this.type = type; + + // when err.type is `system`, err.code contains system error code + if (systemError) { + this.code = this.errno = systemError.code; + } + + // hide custom error implementation details from end-users + Error.captureStackTrace(this, this.constructor); +} + +FetchError.prototype = Object.create(Error.prototype); +FetchError.prototype.constructor = FetchError; +FetchError.prototype.name = 'FetchError'; + +let convert; +try { + convert = require('encoding').convert; +} catch (e) {} + +const INTERNALS = Symbol('Body internals'); + +// fix an issue where "PassThrough" isn't a named export for node <10 +const PassThrough = Stream.PassThrough; + +/** + * Body mixin + * + * Ref: https://fetch.spec.whatwg.org/#body + * + * @param Stream body Readable stream + * @param Object opts Response options + * @return Void + */ +function Body(body) { + var _this = this; + + var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, + _ref$size = _ref.size; + + let size = _ref$size === undefined ? 0 : _ref$size; + var _ref$timeout = _ref.timeout; + let timeout = _ref$timeout === undefined ? 0 : _ref$timeout; + + if (body == null) { + // body is undefined or null + body = null; + } else if (isURLSearchParams(body)) { + // body is a URLSearchParams + body = Buffer.from(body.toString()); + } else if (isBlob(body)) ; else if (Buffer.isBuffer(body)) ; else if (Object.prototype.toString.call(body) === '[object ArrayBuffer]') { + // body is ArrayBuffer + body = Buffer.from(body); + } else if (ArrayBuffer.isView(body)) { + // body is ArrayBufferView + body = Buffer.from(body.buffer, body.byteOffset, body.byteLength); + } else if (body instanceof Stream) ; else { + // none of the above + // coerce to string then buffer + body = Buffer.from(String(body)); + } + this[INTERNALS] = { + body, + disturbed: false, + error: null + }; + this.size = size; + this.timeout = timeout; + + if (body instanceof Stream) { + body.on('error', function (err) { + const error = err.name === 'AbortError' ? err : new FetchError(`Invalid response body while trying to fetch ${_this.url}: ${err.message}`, 'system', err); + _this[INTERNALS].error = error; + }); + } +} + +Body.prototype = { + get body() { + return this[INTERNALS].body; + }, + + get bodyUsed() { + return this[INTERNALS].disturbed; + }, + + /** + * Decode response as ArrayBuffer + * + * @return Promise + */ + arrayBuffer() { + return consumeBody.call(this).then(function (buf) { + return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength); + }); + }, + + /** + * Return raw response as Blob + * + * @return Promise + */ + blob() { + let ct = this.headers && this.headers.get('content-type') || ''; + return consumeBody.call(this).then(function (buf) { + return Object.assign( + // Prevent copying + new Blob([], { + type: ct.toLowerCase() + }), { + [BUFFER]: buf + }); + }); + }, + + /** + * Decode response as json + * + * @return Promise + */ + json() { + var _this2 = this; + + return consumeBody.call(this).then(function (buffer) { + try { + return JSON.parse(buffer.toString()); + } catch (err) { + return Body.Promise.reject(new FetchError(`invalid json response body at ${_this2.url} reason: ${err.message}`, 'invalid-json')); + } + }); + }, + + /** + * Decode response as text + * + * @return Promise + */ + text() { + return consumeBody.call(this).then(function (buffer) { + return buffer.toString(); + }); + }, + + /** + * Decode response as buffer (non-spec api) + * + * @return Promise + */ + buffer() { + return consumeBody.call(this); + }, + + /** + * Decode response as text, while automatically detecting the encoding and + * trying to decode to UTF-8 (non-spec api) + * + * @return Promise + */ + textConverted() { + var _this3 = this; + + return consumeBody.call(this).then(function (buffer) { + return convertBody(buffer, _this3.headers); + }); + } +}; + +// In browsers, all properties are enumerable. +Object.defineProperties(Body.prototype, { + body: { enumerable: true }, + bodyUsed: { enumerable: true }, + arrayBuffer: { enumerable: true }, + blob: { enumerable: true }, + json: { enumerable: true }, + text: { enumerable: true } +}); + +Body.mixIn = function (proto) { + for (const name of Object.getOwnPropertyNames(Body.prototype)) { + // istanbul ignore else: future proof + if (!(name in proto)) { + const desc = Object.getOwnPropertyDescriptor(Body.prototype, name); + Object.defineProperty(proto, name, desc); + } + } +}; + +/** + * Consume and convert an entire Body to a Buffer. + * + * Ref: https://fetch.spec.whatwg.org/#concept-body-consume-body + * + * @return Promise + */ +function consumeBody() { + var _this4 = this; + + if (this[INTERNALS].disturbed) { + return Body.Promise.reject(new TypeError(`body used already for: ${this.url}`)); + } + + this[INTERNALS].disturbed = true; + + if (this[INTERNALS].error) { + return Body.Promise.reject(this[INTERNALS].error); + } + + let body = this.body; + + // body is null + if (body === null) { + return Body.Promise.resolve(Buffer.alloc(0)); + } + + // body is blob + if (isBlob(body)) { + body = body.stream(); + } + + // body is buffer + if (Buffer.isBuffer(body)) { + return Body.Promise.resolve(body); + } + + // istanbul ignore if: should never happen + if (!(body instanceof Stream)) { + return Body.Promise.resolve(Buffer.alloc(0)); + } + + // body is stream + // get ready to actually consume the body + let accum = []; + let accumBytes = 0; + let abort = false; + + return new Body.Promise(function (resolve, reject) { + let resTimeout; + + // allow timeout on slow response body + if (_this4.timeout) { + resTimeout = setTimeout(function () { + abort = true; + reject(new FetchError(`Response timeout while trying to fetch ${_this4.url} (over ${_this4.timeout}ms)`, 'body-timeout')); + }, _this4.timeout); + } + + // handle stream errors + body.on('error', function (err) { + if (err.name === 'AbortError') { + // if the request was aborted, reject with this Error + abort = true; + reject(err); + } else { + // other errors, such as incorrect content-encoding + reject(new FetchError(`Invalid response body while trying to fetch ${_this4.url}: ${err.message}`, 'system', err)); + } + }); + + body.on('data', function (chunk) { + if (abort || chunk === null) { + return; + } + + if (_this4.size && accumBytes + chunk.length > _this4.size) { + abort = true; + reject(new FetchError(`content size at ${_this4.url} over limit: ${_this4.size}`, 'max-size')); + return; + } + + accumBytes += chunk.length; + accum.push(chunk); + }); + + body.on('end', function () { + if (abort) { + return; + } + + clearTimeout(resTimeout); + + try { + resolve(Buffer.concat(accum, accumBytes)); + } catch (err) { + // handle streams that have accumulated too much data (issue #414) + reject(new FetchError(`Could not create Buffer from response body for ${_this4.url}: ${err.message}`, 'system', err)); + } + }); + }); +} + +/** + * Detect buffer encoding and convert to target encoding + * ref: http://www.w3.org/TR/2011/WD-html5-20110113/parsing.html#determining-the-character-encoding + * + * @param Buffer buffer Incoming buffer + * @param String encoding Target encoding + * @return String + */ +function convertBody(buffer, headers) { + if (typeof convert !== 'function') { + throw new Error('The package `encoding` must be installed to use the textConverted() function'); + } + + const ct = headers.get('content-type'); + let charset = 'utf-8'; + let res, str; + + // header + if (ct) { + res = /charset=([^;]*)/i.exec(ct); + } + + // no charset in content type, peek at response body for at most 1024 bytes + str = buffer.slice(0, 1024).toString(); + + // html5 + if (!res && str) { + res = / 0 && arguments[0] !== undefined ? arguments[0] : undefined; + + this[MAP] = Object.create(null); + + if (init instanceof Headers) { + const rawHeaders = init.raw(); + const headerNames = Object.keys(rawHeaders); + + for (const headerName of headerNames) { + for (const value of rawHeaders[headerName]) { + this.append(headerName, value); + } + } + + return; + } + + // We don't worry about converting prop to ByteString here as append() + // will handle it. + if (init == null) ; else if (typeof init === 'object') { + const method = init[Symbol.iterator]; + if (method != null) { + if (typeof method !== 'function') { + throw new TypeError('Header pairs must be iterable'); + } + + // sequence> + // Note: per spec we have to first exhaust the lists then process them + const pairs = []; + for (const pair of init) { + if (typeof pair !== 'object' || typeof pair[Symbol.iterator] !== 'function') { + throw new TypeError('Each header pair must be iterable'); + } + pairs.push(Array.from(pair)); + } + + for (const pair of pairs) { + if (pair.length !== 2) { + throw new TypeError('Each header pair must be a name/value tuple'); + } + this.append(pair[0], pair[1]); + } + } else { + // record + for (const key of Object.keys(init)) { + const value = init[key]; + this.append(key, value); + } + } + } else { + throw new TypeError('Provided initializer must be an object'); + } + } + + /** + * Return combined header value given name + * + * @param String name Header name + * @return Mixed + */ + get(name) { + name = `${name}`; + validateName(name); + const key = find(this[MAP], name); + if (key === undefined) { + return null; + } + + return this[MAP][key].join(', '); + } + + /** + * Iterate over all headers + * + * @param Function callback Executed for each item with parameters (value, name, thisArg) + * @param Boolean thisArg `this` context for callback function + * @return Void + */ + forEach(callback) { + let thisArg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined; + + let pairs = getHeaders(this); + let i = 0; + while (i < pairs.length) { + var _pairs$i = pairs[i]; + const name = _pairs$i[0], + value = _pairs$i[1]; + + callback.call(thisArg, value, name, this); + pairs = getHeaders(this); + i++; + } + } + + /** + * Overwrite header values given name + * + * @param String name Header name + * @param String value Header value + * @return Void + */ + set(name, value) { + name = `${name}`; + value = `${value}`; + validateName(name); + validateValue(value); + const key = find(this[MAP], name); + this[MAP][key !== undefined ? key : name] = [value]; + } + + /** + * Append a value onto existing header + * + * @param String name Header name + * @param String value Header value + * @return Void + */ + append(name, value) { + name = `${name}`; + value = `${value}`; + validateName(name); + validateValue(value); + const key = find(this[MAP], name); + if (key !== undefined) { + this[MAP][key].push(value); + } else { + this[MAP][name] = [value]; + } + } + + /** + * Check for header name existence + * + * @param String name Header name + * @return Boolean + */ + has(name) { + name = `${name}`; + validateName(name); + return find(this[MAP], name) !== undefined; + } + + /** + * Delete all header values given name + * + * @param String name Header name + * @return Void + */ + delete(name) { + name = `${name}`; + validateName(name); + const key = find(this[MAP], name); + if (key !== undefined) { + delete this[MAP][key]; + } + } + + /** + * Return raw headers (non-spec api) + * + * @return Object + */ + raw() { + return this[MAP]; + } + + /** + * Get an iterator on keys. + * + * @return Iterator + */ + keys() { + return createHeadersIterator(this, 'key'); + } + + /** + * Get an iterator on values. + * + * @return Iterator + */ + values() { + return createHeadersIterator(this, 'value'); + } + + /** + * Get an iterator on entries. + * + * This is the default iterator of the Headers object. + * + * @return Iterator + */ + [Symbol.iterator]() { + return createHeadersIterator(this, 'key+value'); + } +} +Headers.prototype.entries = Headers.prototype[Symbol.iterator]; + +Object.defineProperty(Headers.prototype, Symbol.toStringTag, { + value: 'Headers', + writable: false, + enumerable: false, + configurable: true +}); + +Object.defineProperties(Headers.prototype, { + get: { enumerable: true }, + forEach: { enumerable: true }, + set: { enumerable: true }, + append: { enumerable: true }, + has: { enumerable: true }, + delete: { enumerable: true }, + keys: { enumerable: true }, + values: { enumerable: true }, + entries: { enumerable: true } +}); + +function getHeaders(headers) { + let kind = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'key+value'; + + const keys = Object.keys(headers[MAP]).sort(); + return keys.map(kind === 'key' ? function (k) { + return k.toLowerCase(); + } : kind === 'value' ? function (k) { + return headers[MAP][k].join(', '); + } : function (k) { + return [k.toLowerCase(), headers[MAP][k].join(', ')]; + }); +} + +const INTERNAL = Symbol('internal'); + +function createHeadersIterator(target, kind) { + const iterator = Object.create(HeadersIteratorPrototype); + iterator[INTERNAL] = { + target, + kind, + index: 0 + }; + return iterator; +} + +const HeadersIteratorPrototype = Object.setPrototypeOf({ + next() { + // istanbul ignore if + if (!this || Object.getPrototypeOf(this) !== HeadersIteratorPrototype) { + throw new TypeError('Value of `this` is not a HeadersIterator'); + } + + var _INTERNAL = this[INTERNAL]; + const target = _INTERNAL.target, + kind = _INTERNAL.kind, + index = _INTERNAL.index; + + const values = getHeaders(target, kind); + const len = values.length; + if (index >= len) { + return { + value: undefined, + done: true + }; + } + + this[INTERNAL].index = index + 1; + + return { + value: values[index], + done: false + }; + } +}, Object.getPrototypeOf(Object.getPrototypeOf([][Symbol.iterator]()))); + +Object.defineProperty(HeadersIteratorPrototype, Symbol.toStringTag, { + value: 'HeadersIterator', + writable: false, + enumerable: false, + configurable: true +}); + +/** + * Export the Headers object in a form that Node.js can consume. + * + * @param Headers headers + * @return Object + */ +function exportNodeCompatibleHeaders(headers) { + const obj = Object.assign({ __proto__: null }, headers[MAP]); + + // http.request() only supports string as Host header. This hack makes + // specifying custom Host header possible. + const hostHeaderKey = find(headers[MAP], 'Host'); + if (hostHeaderKey !== undefined) { + obj[hostHeaderKey] = obj[hostHeaderKey][0]; + } + + return obj; +} + +/** + * Create a Headers object from an object of headers, ignoring those that do + * not conform to HTTP grammar productions. + * + * @param Object obj Object of headers + * @return Headers + */ +function createHeadersLenient(obj) { + const headers = new Headers(); + for (const name of Object.keys(obj)) { + if (invalidTokenRegex.test(name)) { + continue; + } + if (Array.isArray(obj[name])) { + for (const val of obj[name]) { + if (invalidHeaderCharRegex.test(val)) { + continue; + } + if (headers[MAP][name] === undefined) { + headers[MAP][name] = [val]; + } else { + headers[MAP][name].push(val); + } + } + } else if (!invalidHeaderCharRegex.test(obj[name])) { + headers[MAP][name] = [obj[name]]; + } + } + return headers; +} + +const INTERNALS$1 = Symbol('Response internals'); + +// fix an issue where "STATUS_CODES" aren't a named export for node <10 +const STATUS_CODES = http.STATUS_CODES; + +/** + * Response class + * + * @param Stream body Readable stream + * @param Object opts Response options + * @return Void + */ +class Response { + constructor() { + let body = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; + let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + + Body.call(this, body, opts); + + const status = opts.status || 200; + const headers = new Headers(opts.headers); + + if (body != null && !headers.has('Content-Type')) { + const contentType = extractContentType(body); + if (contentType) { + headers.append('Content-Type', contentType); + } + } + + this[INTERNALS$1] = { + url: opts.url, + status, + statusText: opts.statusText || STATUS_CODES[status], + headers, + counter: opts.counter + }; + } + + get url() { + return this[INTERNALS$1].url || ''; + } + + get status() { + return this[INTERNALS$1].status; + } + + /** + * Convenience property representing if the request ended normally + */ + get ok() { + return this[INTERNALS$1].status >= 200 && this[INTERNALS$1].status < 300; + } + + get redirected() { + return this[INTERNALS$1].counter > 0; + } + + get statusText() { + return this[INTERNALS$1].statusText; + } + + get headers() { + return this[INTERNALS$1].headers; + } + + /** + * Clone this response + * + * @return Response + */ + clone() { + return new Response(clone(this), { + url: this.url, + status: this.status, + statusText: this.statusText, + headers: this.headers, + ok: this.ok, + redirected: this.redirected + }); + } +} + +Body.mixIn(Response.prototype); + +Object.defineProperties(Response.prototype, { + url: { enumerable: true }, + status: { enumerable: true }, + ok: { enumerable: true }, + redirected: { enumerable: true }, + statusText: { enumerable: true }, + headers: { enumerable: true }, + clone: { enumerable: true } +}); + +Object.defineProperty(Response.prototype, Symbol.toStringTag, { + value: 'Response', + writable: false, + enumerable: false, + configurable: true +}); + +const INTERNALS$2 = Symbol('Request internals'); +const URL = Url.URL || whatwgUrl.URL; + +// fix an issue where "format", "parse" aren't a named export for node <10 +const parse_url = Url.parse; +const format_url = Url.format; + +/** + * Wrapper around `new URL` to handle arbitrary URLs + * + * @param {string} urlStr + * @return {void} + */ +function parseURL(urlStr) { + /* + Check whether the URL is absolute or not + Scheme: https://tools.ietf.org/html/rfc3986#section-3.1 + Absolute URL: https://tools.ietf.org/html/rfc3986#section-4.3 + */ + if (/^[a-zA-Z][a-zA-Z\d+\-.]*:/.exec(urlStr)) { + urlStr = new URL(urlStr).toString(); + } + + // Fallback to old implementation for arbitrary URLs + return parse_url(urlStr); +} + +const streamDestructionSupported = 'destroy' in Stream.Readable.prototype; + +/** + * Check if a value is an instance of Request. + * + * @param Mixed input + * @return Boolean + */ +function isRequest(input) { + return typeof input === 'object' && typeof input[INTERNALS$2] === 'object'; +} + +function isAbortSignal(signal) { + const proto = signal && typeof signal === 'object' && Object.getPrototypeOf(signal); + return !!(proto && proto.constructor.name === 'AbortSignal'); +} + +/** + * Request class + * + * @param Mixed input Url or Request instance + * @param Object init Custom options + * @return Void + */ +class Request { + constructor(input) { + let init = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + + let parsedURL; + + // normalize input + if (!isRequest(input)) { + if (input && input.href) { + // in order to support Node.js' Url objects; though WHATWG's URL objects + // will fall into this branch also (since their `toString()` will return + // `href` property anyway) + parsedURL = parseURL(input.href); + } else { + // coerce input to a string before attempting to parse + parsedURL = parseURL(`${input}`); + } + input = {}; + } else { + parsedURL = parseURL(input.url); + } + + let method = init.method || input.method || 'GET'; + method = method.toUpperCase(); + + if ((init.body != null || isRequest(input) && input.body !== null) && (method === 'GET' || method === 'HEAD')) { + throw new TypeError('Request with GET/HEAD method cannot have body'); + } + + let inputBody = init.body != null ? init.body : isRequest(input) && input.body !== null ? clone(input) : null; + + Body.call(this, inputBody, { + timeout: init.timeout || input.timeout || 0, + size: init.size || input.size || 0 + }); + + const headers = new Headers(init.headers || input.headers || {}); + + if (inputBody != null && !headers.has('Content-Type')) { + const contentType = extractContentType(inputBody); + if (contentType) { + headers.append('Content-Type', contentType); + } + } + + let signal = isRequest(input) ? input.signal : null; + if ('signal' in init) signal = init.signal; + + if (signal != null && !isAbortSignal(signal)) { + throw new TypeError('Expected signal to be an instanceof AbortSignal'); + } + + this[INTERNALS$2] = { + method, + redirect: init.redirect || input.redirect || 'follow', + headers, + parsedURL, + signal + }; + + // node-fetch-only options + this.follow = init.follow !== undefined ? init.follow : input.follow !== undefined ? input.follow : 20; + this.compress = init.compress !== undefined ? init.compress : input.compress !== undefined ? input.compress : true; + this.counter = init.counter || input.counter || 0; + this.agent = init.agent || input.agent; + } + + get method() { + return this[INTERNALS$2].method; + } + + get url() { + return format_url(this[INTERNALS$2].parsedURL); + } + + get headers() { + return this[INTERNALS$2].headers; + } + + get redirect() { + return this[INTERNALS$2].redirect; + } + + get signal() { + return this[INTERNALS$2].signal; + } + + /** + * Clone this request + * + * @return Request + */ + clone() { + return new Request(this); + } +} + +Body.mixIn(Request.prototype); + +Object.defineProperty(Request.prototype, Symbol.toStringTag, { + value: 'Request', + writable: false, + enumerable: false, + configurable: true +}); + +Object.defineProperties(Request.prototype, { + method: { enumerable: true }, + url: { enumerable: true }, + headers: { enumerable: true }, + redirect: { enumerable: true }, + clone: { enumerable: true }, + signal: { enumerable: true } +}); + +/** + * Convert a Request to Node.js http request options. + * + * @param Request A Request instance + * @return Object The options object to be passed to http.request + */ +function getNodeRequestOptions(request) { + const parsedURL = request[INTERNALS$2].parsedURL; + const headers = new Headers(request[INTERNALS$2].headers); + + // fetch step 1.3 + if (!headers.has('Accept')) { + headers.set('Accept', '*/*'); + } + + // Basic fetch + if (!parsedURL.protocol || !parsedURL.hostname) { + throw new TypeError('Only absolute URLs are supported'); + } + + if (!/^https?:$/.test(parsedURL.protocol)) { + throw new TypeError('Only HTTP(S) protocols are supported'); + } + + if (request.signal && request.body instanceof Stream.Readable && !streamDestructionSupported) { + throw new Error('Cancellation of streamed requests with AbortSignal is not supported in node < 8'); + } + + // HTTP-network-or-cache fetch steps 2.4-2.7 + let contentLengthValue = null; + if (request.body == null && /^(POST|PUT)$/i.test(request.method)) { + contentLengthValue = '0'; + } + if (request.body != null) { + const totalBytes = getTotalBytes(request); + if (typeof totalBytes === 'number') { + contentLengthValue = String(totalBytes); + } + } + if (contentLengthValue) { + headers.set('Content-Length', contentLengthValue); + } + + // HTTP-network-or-cache fetch step 2.11 + if (!headers.has('User-Agent')) { + headers.set('User-Agent', 'node-fetch/1.0 (+https://github.com/bitinn/node-fetch)'); + } + + // HTTP-network-or-cache fetch step 2.15 + if (request.compress && !headers.has('Accept-Encoding')) { + headers.set('Accept-Encoding', 'gzip,deflate'); + } + + let agent = request.agent; + if (typeof agent === 'function') { + agent = agent(parsedURL); + } + + // HTTP-network fetch step 4.2 + // chunked encoding is handled by Node.js + + return Object.assign({}, parsedURL, { + method: request.method, + headers: exportNodeCompatibleHeaders(headers), + agent + }); +} + +/** + * abort-error.js + * + * AbortError interface for cancelled requests + */ + +/** + * Create AbortError instance + * + * @param String message Error message for human + * @return AbortError + */ +function AbortError(message) { + Error.call(this, message); + + this.type = 'aborted'; + this.message = message; + + // hide custom error implementation details from end-users + Error.captureStackTrace(this, this.constructor); +} + +AbortError.prototype = Object.create(Error.prototype); +AbortError.prototype.constructor = AbortError; +AbortError.prototype.name = 'AbortError'; + +const URL$1 = Url.URL || whatwgUrl.URL; + +// fix an issue where "PassThrough", "resolve" aren't a named export for node <10 +const PassThrough$1 = Stream.PassThrough; + +const isDomainOrSubdomain = function isDomainOrSubdomain(destination, original) { + const orig = new URL$1(original).hostname; + const dest = new URL$1(destination).hostname; + + return orig === dest || orig[orig.length - dest.length - 1] === '.' && orig.endsWith(dest); +}; + +/** + * isSameProtocol reports whether the two provided URLs use the same protocol. + * + * Both domains must already be in canonical form. + * @param {string|URL} original + * @param {string|URL} destination + */ +const isSameProtocol = function isSameProtocol(destination, original) { + const orig = new URL$1(original).protocol; + const dest = new URL$1(destination).protocol; + + return orig === dest; +}; + +/** + * Fetch function + * + * @param Mixed url Absolute url or Request instance + * @param Object opts Fetch options + * @return Promise + */ +function fetch(url, opts) { + + // allow custom promise + if (!fetch.Promise) { + throw new Error('native promise missing, set fetch.Promise to your favorite alternative'); + } + + Body.Promise = fetch.Promise; + + // wrap http.request into fetch + return new fetch.Promise(function (resolve, reject) { + // build request object + const request = new Request(url, opts); + const options = getNodeRequestOptions(request); + + const send = (options.protocol === 'https:' ? https : http).request; + const signal = request.signal; + + let response = null; + + const abort = function abort() { + let error = new AbortError('The user aborted a request.'); + reject(error); + if (request.body && request.body instanceof Stream.Readable) { + destroyStream(request.body, error); + } + if (!response || !response.body) return; + response.body.emit('error', error); + }; + + if (signal && signal.aborted) { + abort(); + return; + } + + const abortAndFinalize = function abortAndFinalize() { + abort(); + finalize(); + }; + + // send request + const req = send(options); + let reqTimeout; + + if (signal) { + signal.addEventListener('abort', abortAndFinalize); + } + + function finalize() { + req.abort(); + if (signal) signal.removeEventListener('abort', abortAndFinalize); + clearTimeout(reqTimeout); + } + + if (request.timeout) { + req.once('socket', function (socket) { + reqTimeout = setTimeout(function () { + reject(new FetchError(`network timeout at: ${request.url}`, 'request-timeout')); + finalize(); + }, request.timeout); + }); + } + + req.on('error', function (err) { + reject(new FetchError(`request to ${request.url} failed, reason: ${err.message}`, 'system', err)); + + if (response && response.body) { + destroyStream(response.body, err); + } + + finalize(); + }); + + fixResponseChunkedTransferBadEnding(req, function (err) { + if (signal && signal.aborted) { + return; + } + + if (response && response.body) { + destroyStream(response.body, err); + } + }); + + /* c8 ignore next 18 */ + if (parseInt(process.version.substring(1)) < 14) { + // Before Node.js 14, pipeline() does not fully support async iterators and does not always + // properly handle when the socket close/end events are out of order. + req.on('socket', function (s) { + s.addListener('close', function (hadError) { + // if a data listener is still present we didn't end cleanly + const hasDataListener = s.listenerCount('data') > 0; + + // if end happened before close but the socket didn't emit an error, do it now + if (response && hasDataListener && !hadError && !(signal && signal.aborted)) { + const err = new Error('Premature close'); + err.code = 'ERR_STREAM_PREMATURE_CLOSE'; + response.body.emit('error', err); + } + }); + }); + } + + req.on('response', function (res) { + clearTimeout(reqTimeout); + + const headers = createHeadersLenient(res.headers); + + // HTTP fetch step 5 + if (fetch.isRedirect(res.statusCode)) { + // HTTP fetch step 5.2 + const location = headers.get('Location'); + + // HTTP fetch step 5.3 + let locationURL = null; + try { + locationURL = location === null ? null : new URL$1(location, request.url).toString(); + } catch (err) { + // error here can only be invalid URL in Location: header + // do not throw when options.redirect == manual + // let the user extract the errorneous redirect URL + if (request.redirect !== 'manual') { + reject(new FetchError(`uri requested responds with an invalid redirect URL: ${location}`, 'invalid-redirect')); + finalize(); + return; + } + } + + // HTTP fetch step 5.5 + switch (request.redirect) { + case 'error': + reject(new FetchError(`uri requested responds with a redirect, redirect mode is set to error: ${request.url}`, 'no-redirect')); + finalize(); + return; + case 'manual': + // node-fetch-specific step: make manual redirect a bit easier to use by setting the Location header value to the resolved URL. + if (locationURL !== null) { + // handle corrupted header + try { + headers.set('Location', locationURL); + } catch (err) { + // istanbul ignore next: nodejs server prevent invalid response headers, we can't test this through normal request + reject(err); + } + } + break; + case 'follow': + // HTTP-redirect fetch step 2 + if (locationURL === null) { + break; + } + + // HTTP-redirect fetch step 5 + if (request.counter >= request.follow) { + reject(new FetchError(`maximum redirect reached at: ${request.url}`, 'max-redirect')); + finalize(); + return; + } + + // HTTP-redirect fetch step 6 (counter increment) + // Create a new Request object. + const requestOpts = { + headers: new Headers(request.headers), + follow: request.follow, + counter: request.counter + 1, + agent: request.agent, + compress: request.compress, + method: request.method, + body: request.body, + signal: request.signal, + timeout: request.timeout, + size: request.size + }; + + if (!isDomainOrSubdomain(request.url, locationURL) || !isSameProtocol(request.url, locationURL)) { + for (const name of ['authorization', 'www-authenticate', 'cookie', 'cookie2']) { + requestOpts.headers.delete(name); + } + } + + // HTTP-redirect fetch step 9 + if (res.statusCode !== 303 && request.body && getTotalBytes(request) === null) { + reject(new FetchError('Cannot follow redirect with body being a readable stream', 'unsupported-redirect')); + finalize(); + return; + } + + // HTTP-redirect fetch step 11 + if (res.statusCode === 303 || (res.statusCode === 301 || res.statusCode === 302) && request.method === 'POST') { + requestOpts.method = 'GET'; + requestOpts.body = undefined; + requestOpts.headers.delete('content-length'); + } + + // HTTP-redirect fetch step 15 + resolve(fetch(new Request(locationURL, requestOpts))); + finalize(); + return; + } + } + + // prepare response + res.once('end', function () { + if (signal) signal.removeEventListener('abort', abortAndFinalize); + }); + let body = res.pipe(new PassThrough$1()); + + const response_options = { + url: request.url, + status: res.statusCode, + statusText: res.statusMessage, + headers: headers, + size: request.size, + timeout: request.timeout, + counter: request.counter + }; + + // HTTP-network fetch step 12.1.1.3 + const codings = headers.get('Content-Encoding'); + + // HTTP-network fetch step 12.1.1.4: handle content codings + + // in following scenarios we ignore compression support + // 1. compression support is disabled + // 2. HEAD request + // 3. no Content-Encoding header + // 4. no content response (204) + // 5. content not modified response (304) + if (!request.compress || request.method === 'HEAD' || codings === null || res.statusCode === 204 || res.statusCode === 304) { + response = new Response(body, response_options); + resolve(response); + return; + } + + // For Node v6+ + // Be less strict when decoding compressed responses, since sometimes + // servers send slightly invalid responses that are still accepted + // by common browsers. + // Always using Z_SYNC_FLUSH is what cURL does. + const zlibOptions = { + flush: zlib.Z_SYNC_FLUSH, + finishFlush: zlib.Z_SYNC_FLUSH + }; + + // for gzip + if (codings == 'gzip' || codings == 'x-gzip') { + body = body.pipe(zlib.createGunzip(zlibOptions)); + response = new Response(body, response_options); + resolve(response); + return; + } + + // for deflate + if (codings == 'deflate' || codings == 'x-deflate') { + // handle the infamous raw deflate response from old servers + // a hack for old IIS and Apache servers + const raw = res.pipe(new PassThrough$1()); + raw.once('data', function (chunk) { + // see http://stackoverflow.com/questions/37519828 + if ((chunk[0] & 0x0F) === 0x08) { + body = body.pipe(zlib.createInflate()); + } else { + body = body.pipe(zlib.createInflateRaw()); + } + response = new Response(body, response_options); + resolve(response); + }); + raw.on('end', function () { + // some old IIS servers return zero-length OK deflate responses, so 'data' is never emitted. + if (!response) { + response = new Response(body, response_options); + resolve(response); + } + }); + return; + } + + // for br + if (codings == 'br' && typeof zlib.createBrotliDecompress === 'function') { + body = body.pipe(zlib.createBrotliDecompress()); + response = new Response(body, response_options); + resolve(response); + return; + } + + // otherwise, use response as-is + response = new Response(body, response_options); + resolve(response); + }); + + writeToStream(req, request); + }); +} +function fixResponseChunkedTransferBadEnding(request, errorCallback) { + let socket; + + request.on('socket', function (s) { + socket = s; + }); + + request.on('response', function (response) { + const headers = response.headers; + + if (headers['transfer-encoding'] === 'chunked' && !headers['content-length']) { + response.once('close', function (hadError) { + // tests for socket presence, as in some situations the + // the 'socket' event is not triggered for the request + // (happens in deno), avoids `TypeError` + // if a data listener is still present we didn't end cleanly + const hasDataListener = socket && socket.listenerCount('data') > 0; + + if (hasDataListener && !hadError) { + const err = new Error('Premature close'); + err.code = 'ERR_STREAM_PREMATURE_CLOSE'; + errorCallback(err); + } + }); + } + }); +} + +function destroyStream(stream, err) { + if (stream.destroy) { + stream.destroy(err); + } else { + // node < 8 + stream.emit('error', err); + stream.end(); + } +} + +/** + * Redirect code matching + * + * @param Number code Status code + * @return Boolean + */ +fetch.isRedirect = function (code) { + return code === 301 || code === 302 || code === 303 || code === 307 || code === 308; +}; + +// expose Promise +fetch.Promise = global.Promise; + +module.exports = exports = fetch; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = exports; +exports.Headers = Headers; +exports.Request = Request; +exports.Response = Response; +exports.FetchError = FetchError; +exports.AbortError = AbortError; diff --git a/sandbox/tgbot/node_modules/node-fetch/lib/index.mjs b/sandbox/tgbot/node_modules/node-fetch/lib/index.mjs new file mode 100644 index 0000000..2863dd9 --- /dev/null +++ b/sandbox/tgbot/node_modules/node-fetch/lib/index.mjs @@ -0,0 +1,1775 @@ +import Stream from 'stream'; +import http from 'http'; +import Url from 'url'; +import whatwgUrl from 'whatwg-url'; +import https from 'https'; +import zlib from 'zlib'; + +// Based on https://github.com/tmpvar/jsdom/blob/aa85b2abf07766ff7bf5c1f6daafb3726f2f2db5/lib/jsdom/living/blob.js + +// fix for "Readable" isn't a named export issue +const Readable = Stream.Readable; + +const BUFFER = Symbol('buffer'); +const TYPE = Symbol('type'); + +class Blob { + constructor() { + this[TYPE] = ''; + + const blobParts = arguments[0]; + const options = arguments[1]; + + const buffers = []; + let size = 0; + + if (blobParts) { + const a = blobParts; + const length = Number(a.length); + for (let i = 0; i < length; i++) { + const element = a[i]; + let buffer; + if (element instanceof Buffer) { + buffer = element; + } else if (ArrayBuffer.isView(element)) { + buffer = Buffer.from(element.buffer, element.byteOffset, element.byteLength); + } else if (element instanceof ArrayBuffer) { + buffer = Buffer.from(element); + } else if (element instanceof Blob) { + buffer = element[BUFFER]; + } else { + buffer = Buffer.from(typeof element === 'string' ? element : String(element)); + } + size += buffer.length; + buffers.push(buffer); + } + } + + this[BUFFER] = Buffer.concat(buffers); + + let type = options && options.type !== undefined && String(options.type).toLowerCase(); + if (type && !/[^\u0020-\u007E]/.test(type)) { + this[TYPE] = type; + } + } + get size() { + return this[BUFFER].length; + } + get type() { + return this[TYPE]; + } + text() { + return Promise.resolve(this[BUFFER].toString()); + } + arrayBuffer() { + const buf = this[BUFFER]; + const ab = buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength); + return Promise.resolve(ab); + } + stream() { + const readable = new Readable(); + readable._read = function () {}; + readable.push(this[BUFFER]); + readable.push(null); + return readable; + } + toString() { + return '[object Blob]'; + } + slice() { + const size = this.size; + + const start = arguments[0]; + const end = arguments[1]; + let relativeStart, relativeEnd; + if (start === undefined) { + relativeStart = 0; + } else if (start < 0) { + relativeStart = Math.max(size + start, 0); + } else { + relativeStart = Math.min(start, size); + } + if (end === undefined) { + relativeEnd = size; + } else if (end < 0) { + relativeEnd = Math.max(size + end, 0); + } else { + relativeEnd = Math.min(end, size); + } + const span = Math.max(relativeEnd - relativeStart, 0); + + const buffer = this[BUFFER]; + const slicedBuffer = buffer.slice(relativeStart, relativeStart + span); + const blob = new Blob([], { type: arguments[2] }); + blob[BUFFER] = slicedBuffer; + return blob; + } +} + +Object.defineProperties(Blob.prototype, { + size: { enumerable: true }, + type: { enumerable: true }, + slice: { enumerable: true } +}); + +Object.defineProperty(Blob.prototype, Symbol.toStringTag, { + value: 'Blob', + writable: false, + enumerable: false, + configurable: true +}); + +/** + * fetch-error.js + * + * FetchError interface for operational errors + */ + +/** + * Create FetchError instance + * + * @param String message Error message for human + * @param String type Error type for machine + * @param String systemError For Node.js system error + * @return FetchError + */ +function FetchError(message, type, systemError) { + Error.call(this, message); + + this.message = message; + this.type = type; + + // when err.type is `system`, err.code contains system error code + if (systemError) { + this.code = this.errno = systemError.code; + } + + // hide custom error implementation details from end-users + Error.captureStackTrace(this, this.constructor); +} + +FetchError.prototype = Object.create(Error.prototype); +FetchError.prototype.constructor = FetchError; +FetchError.prototype.name = 'FetchError'; + +let convert; +try { + convert = require('encoding').convert; +} catch (e) {} + +const INTERNALS = Symbol('Body internals'); + +// fix an issue where "PassThrough" isn't a named export for node <10 +const PassThrough = Stream.PassThrough; + +/** + * Body mixin + * + * Ref: https://fetch.spec.whatwg.org/#body + * + * @param Stream body Readable stream + * @param Object opts Response options + * @return Void + */ +function Body(body) { + var _this = this; + + var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, + _ref$size = _ref.size; + + let size = _ref$size === undefined ? 0 : _ref$size; + var _ref$timeout = _ref.timeout; + let timeout = _ref$timeout === undefined ? 0 : _ref$timeout; + + if (body == null) { + // body is undefined or null + body = null; + } else if (isURLSearchParams(body)) { + // body is a URLSearchParams + body = Buffer.from(body.toString()); + } else if (isBlob(body)) ; else if (Buffer.isBuffer(body)) ; else if (Object.prototype.toString.call(body) === '[object ArrayBuffer]') { + // body is ArrayBuffer + body = Buffer.from(body); + } else if (ArrayBuffer.isView(body)) { + // body is ArrayBufferView + body = Buffer.from(body.buffer, body.byteOffset, body.byteLength); + } else if (body instanceof Stream) ; else { + // none of the above + // coerce to string then buffer + body = Buffer.from(String(body)); + } + this[INTERNALS] = { + body, + disturbed: false, + error: null + }; + this.size = size; + this.timeout = timeout; + + if (body instanceof Stream) { + body.on('error', function (err) { + const error = err.name === 'AbortError' ? err : new FetchError(`Invalid response body while trying to fetch ${_this.url}: ${err.message}`, 'system', err); + _this[INTERNALS].error = error; + }); + } +} + +Body.prototype = { + get body() { + return this[INTERNALS].body; + }, + + get bodyUsed() { + return this[INTERNALS].disturbed; + }, + + /** + * Decode response as ArrayBuffer + * + * @return Promise + */ + arrayBuffer() { + return consumeBody.call(this).then(function (buf) { + return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength); + }); + }, + + /** + * Return raw response as Blob + * + * @return Promise + */ + blob() { + let ct = this.headers && this.headers.get('content-type') || ''; + return consumeBody.call(this).then(function (buf) { + return Object.assign( + // Prevent copying + new Blob([], { + type: ct.toLowerCase() + }), { + [BUFFER]: buf + }); + }); + }, + + /** + * Decode response as json + * + * @return Promise + */ + json() { + var _this2 = this; + + return consumeBody.call(this).then(function (buffer) { + try { + return JSON.parse(buffer.toString()); + } catch (err) { + return Body.Promise.reject(new FetchError(`invalid json response body at ${_this2.url} reason: ${err.message}`, 'invalid-json')); + } + }); + }, + + /** + * Decode response as text + * + * @return Promise + */ + text() { + return consumeBody.call(this).then(function (buffer) { + return buffer.toString(); + }); + }, + + /** + * Decode response as buffer (non-spec api) + * + * @return Promise + */ + buffer() { + return consumeBody.call(this); + }, + + /** + * Decode response as text, while automatically detecting the encoding and + * trying to decode to UTF-8 (non-spec api) + * + * @return Promise + */ + textConverted() { + var _this3 = this; + + return consumeBody.call(this).then(function (buffer) { + return convertBody(buffer, _this3.headers); + }); + } +}; + +// In browsers, all properties are enumerable. +Object.defineProperties(Body.prototype, { + body: { enumerable: true }, + bodyUsed: { enumerable: true }, + arrayBuffer: { enumerable: true }, + blob: { enumerable: true }, + json: { enumerable: true }, + text: { enumerable: true } +}); + +Body.mixIn = function (proto) { + for (const name of Object.getOwnPropertyNames(Body.prototype)) { + // istanbul ignore else: future proof + if (!(name in proto)) { + const desc = Object.getOwnPropertyDescriptor(Body.prototype, name); + Object.defineProperty(proto, name, desc); + } + } +}; + +/** + * Consume and convert an entire Body to a Buffer. + * + * Ref: https://fetch.spec.whatwg.org/#concept-body-consume-body + * + * @return Promise + */ +function consumeBody() { + var _this4 = this; + + if (this[INTERNALS].disturbed) { + return Body.Promise.reject(new TypeError(`body used already for: ${this.url}`)); + } + + this[INTERNALS].disturbed = true; + + if (this[INTERNALS].error) { + return Body.Promise.reject(this[INTERNALS].error); + } + + let body = this.body; + + // body is null + if (body === null) { + return Body.Promise.resolve(Buffer.alloc(0)); + } + + // body is blob + if (isBlob(body)) { + body = body.stream(); + } + + // body is buffer + if (Buffer.isBuffer(body)) { + return Body.Promise.resolve(body); + } + + // istanbul ignore if: should never happen + if (!(body instanceof Stream)) { + return Body.Promise.resolve(Buffer.alloc(0)); + } + + // body is stream + // get ready to actually consume the body + let accum = []; + let accumBytes = 0; + let abort = false; + + return new Body.Promise(function (resolve, reject) { + let resTimeout; + + // allow timeout on slow response body + if (_this4.timeout) { + resTimeout = setTimeout(function () { + abort = true; + reject(new FetchError(`Response timeout while trying to fetch ${_this4.url} (over ${_this4.timeout}ms)`, 'body-timeout')); + }, _this4.timeout); + } + + // handle stream errors + body.on('error', function (err) { + if (err.name === 'AbortError') { + // if the request was aborted, reject with this Error + abort = true; + reject(err); + } else { + // other errors, such as incorrect content-encoding + reject(new FetchError(`Invalid response body while trying to fetch ${_this4.url}: ${err.message}`, 'system', err)); + } + }); + + body.on('data', function (chunk) { + if (abort || chunk === null) { + return; + } + + if (_this4.size && accumBytes + chunk.length > _this4.size) { + abort = true; + reject(new FetchError(`content size at ${_this4.url} over limit: ${_this4.size}`, 'max-size')); + return; + } + + accumBytes += chunk.length; + accum.push(chunk); + }); + + body.on('end', function () { + if (abort) { + return; + } + + clearTimeout(resTimeout); + + try { + resolve(Buffer.concat(accum, accumBytes)); + } catch (err) { + // handle streams that have accumulated too much data (issue #414) + reject(new FetchError(`Could not create Buffer from response body for ${_this4.url}: ${err.message}`, 'system', err)); + } + }); + }); +} + +/** + * Detect buffer encoding and convert to target encoding + * ref: http://www.w3.org/TR/2011/WD-html5-20110113/parsing.html#determining-the-character-encoding + * + * @param Buffer buffer Incoming buffer + * @param String encoding Target encoding + * @return String + */ +function convertBody(buffer, headers) { + if (typeof convert !== 'function') { + throw new Error('The package `encoding` must be installed to use the textConverted() function'); + } + + const ct = headers.get('content-type'); + let charset = 'utf-8'; + let res, str; + + // header + if (ct) { + res = /charset=([^;]*)/i.exec(ct); + } + + // no charset in content type, peek at response body for at most 1024 bytes + str = buffer.slice(0, 1024).toString(); + + // html5 + if (!res && str) { + res = / 0 && arguments[0] !== undefined ? arguments[0] : undefined; + + this[MAP] = Object.create(null); + + if (init instanceof Headers) { + const rawHeaders = init.raw(); + const headerNames = Object.keys(rawHeaders); + + for (const headerName of headerNames) { + for (const value of rawHeaders[headerName]) { + this.append(headerName, value); + } + } + + return; + } + + // We don't worry about converting prop to ByteString here as append() + // will handle it. + if (init == null) ; else if (typeof init === 'object') { + const method = init[Symbol.iterator]; + if (method != null) { + if (typeof method !== 'function') { + throw new TypeError('Header pairs must be iterable'); + } + + // sequence> + // Note: per spec we have to first exhaust the lists then process them + const pairs = []; + for (const pair of init) { + if (typeof pair !== 'object' || typeof pair[Symbol.iterator] !== 'function') { + throw new TypeError('Each header pair must be iterable'); + } + pairs.push(Array.from(pair)); + } + + for (const pair of pairs) { + if (pair.length !== 2) { + throw new TypeError('Each header pair must be a name/value tuple'); + } + this.append(pair[0], pair[1]); + } + } else { + // record + for (const key of Object.keys(init)) { + const value = init[key]; + this.append(key, value); + } + } + } else { + throw new TypeError('Provided initializer must be an object'); + } + } + + /** + * Return combined header value given name + * + * @param String name Header name + * @return Mixed + */ + get(name) { + name = `${name}`; + validateName(name); + const key = find(this[MAP], name); + if (key === undefined) { + return null; + } + + return this[MAP][key].join(', '); + } + + /** + * Iterate over all headers + * + * @param Function callback Executed for each item with parameters (value, name, thisArg) + * @param Boolean thisArg `this` context for callback function + * @return Void + */ + forEach(callback) { + let thisArg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined; + + let pairs = getHeaders(this); + let i = 0; + while (i < pairs.length) { + var _pairs$i = pairs[i]; + const name = _pairs$i[0], + value = _pairs$i[1]; + + callback.call(thisArg, value, name, this); + pairs = getHeaders(this); + i++; + } + } + + /** + * Overwrite header values given name + * + * @param String name Header name + * @param String value Header value + * @return Void + */ + set(name, value) { + name = `${name}`; + value = `${value}`; + validateName(name); + validateValue(value); + const key = find(this[MAP], name); + this[MAP][key !== undefined ? key : name] = [value]; + } + + /** + * Append a value onto existing header + * + * @param String name Header name + * @param String value Header value + * @return Void + */ + append(name, value) { + name = `${name}`; + value = `${value}`; + validateName(name); + validateValue(value); + const key = find(this[MAP], name); + if (key !== undefined) { + this[MAP][key].push(value); + } else { + this[MAP][name] = [value]; + } + } + + /** + * Check for header name existence + * + * @param String name Header name + * @return Boolean + */ + has(name) { + name = `${name}`; + validateName(name); + return find(this[MAP], name) !== undefined; + } + + /** + * Delete all header values given name + * + * @param String name Header name + * @return Void + */ + delete(name) { + name = `${name}`; + validateName(name); + const key = find(this[MAP], name); + if (key !== undefined) { + delete this[MAP][key]; + } + } + + /** + * Return raw headers (non-spec api) + * + * @return Object + */ + raw() { + return this[MAP]; + } + + /** + * Get an iterator on keys. + * + * @return Iterator + */ + keys() { + return createHeadersIterator(this, 'key'); + } + + /** + * Get an iterator on values. + * + * @return Iterator + */ + values() { + return createHeadersIterator(this, 'value'); + } + + /** + * Get an iterator on entries. + * + * This is the default iterator of the Headers object. + * + * @return Iterator + */ + [Symbol.iterator]() { + return createHeadersIterator(this, 'key+value'); + } +} +Headers.prototype.entries = Headers.prototype[Symbol.iterator]; + +Object.defineProperty(Headers.prototype, Symbol.toStringTag, { + value: 'Headers', + writable: false, + enumerable: false, + configurable: true +}); + +Object.defineProperties(Headers.prototype, { + get: { enumerable: true }, + forEach: { enumerable: true }, + set: { enumerable: true }, + append: { enumerable: true }, + has: { enumerable: true }, + delete: { enumerable: true }, + keys: { enumerable: true }, + values: { enumerable: true }, + entries: { enumerable: true } +}); + +function getHeaders(headers) { + let kind = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'key+value'; + + const keys = Object.keys(headers[MAP]).sort(); + return keys.map(kind === 'key' ? function (k) { + return k.toLowerCase(); + } : kind === 'value' ? function (k) { + return headers[MAP][k].join(', '); + } : function (k) { + return [k.toLowerCase(), headers[MAP][k].join(', ')]; + }); +} + +const INTERNAL = Symbol('internal'); + +function createHeadersIterator(target, kind) { + const iterator = Object.create(HeadersIteratorPrototype); + iterator[INTERNAL] = { + target, + kind, + index: 0 + }; + return iterator; +} + +const HeadersIteratorPrototype = Object.setPrototypeOf({ + next() { + // istanbul ignore if + if (!this || Object.getPrototypeOf(this) !== HeadersIteratorPrototype) { + throw new TypeError('Value of `this` is not a HeadersIterator'); + } + + var _INTERNAL = this[INTERNAL]; + const target = _INTERNAL.target, + kind = _INTERNAL.kind, + index = _INTERNAL.index; + + const values = getHeaders(target, kind); + const len = values.length; + if (index >= len) { + return { + value: undefined, + done: true + }; + } + + this[INTERNAL].index = index + 1; + + return { + value: values[index], + done: false + }; + } +}, Object.getPrototypeOf(Object.getPrototypeOf([][Symbol.iterator]()))); + +Object.defineProperty(HeadersIteratorPrototype, Symbol.toStringTag, { + value: 'HeadersIterator', + writable: false, + enumerable: false, + configurable: true +}); + +/** + * Export the Headers object in a form that Node.js can consume. + * + * @param Headers headers + * @return Object + */ +function exportNodeCompatibleHeaders(headers) { + const obj = Object.assign({ __proto__: null }, headers[MAP]); + + // http.request() only supports string as Host header. This hack makes + // specifying custom Host header possible. + const hostHeaderKey = find(headers[MAP], 'Host'); + if (hostHeaderKey !== undefined) { + obj[hostHeaderKey] = obj[hostHeaderKey][0]; + } + + return obj; +} + +/** + * Create a Headers object from an object of headers, ignoring those that do + * not conform to HTTP grammar productions. + * + * @param Object obj Object of headers + * @return Headers + */ +function createHeadersLenient(obj) { + const headers = new Headers(); + for (const name of Object.keys(obj)) { + if (invalidTokenRegex.test(name)) { + continue; + } + if (Array.isArray(obj[name])) { + for (const val of obj[name]) { + if (invalidHeaderCharRegex.test(val)) { + continue; + } + if (headers[MAP][name] === undefined) { + headers[MAP][name] = [val]; + } else { + headers[MAP][name].push(val); + } + } + } else if (!invalidHeaderCharRegex.test(obj[name])) { + headers[MAP][name] = [obj[name]]; + } + } + return headers; +} + +const INTERNALS$1 = Symbol('Response internals'); + +// fix an issue where "STATUS_CODES" aren't a named export for node <10 +const STATUS_CODES = http.STATUS_CODES; + +/** + * Response class + * + * @param Stream body Readable stream + * @param Object opts Response options + * @return Void + */ +class Response { + constructor() { + let body = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; + let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + + Body.call(this, body, opts); + + const status = opts.status || 200; + const headers = new Headers(opts.headers); + + if (body != null && !headers.has('Content-Type')) { + const contentType = extractContentType(body); + if (contentType) { + headers.append('Content-Type', contentType); + } + } + + this[INTERNALS$1] = { + url: opts.url, + status, + statusText: opts.statusText || STATUS_CODES[status], + headers, + counter: opts.counter + }; + } + + get url() { + return this[INTERNALS$1].url || ''; + } + + get status() { + return this[INTERNALS$1].status; + } + + /** + * Convenience property representing if the request ended normally + */ + get ok() { + return this[INTERNALS$1].status >= 200 && this[INTERNALS$1].status < 300; + } + + get redirected() { + return this[INTERNALS$1].counter > 0; + } + + get statusText() { + return this[INTERNALS$1].statusText; + } + + get headers() { + return this[INTERNALS$1].headers; + } + + /** + * Clone this response + * + * @return Response + */ + clone() { + return new Response(clone(this), { + url: this.url, + status: this.status, + statusText: this.statusText, + headers: this.headers, + ok: this.ok, + redirected: this.redirected + }); + } +} + +Body.mixIn(Response.prototype); + +Object.defineProperties(Response.prototype, { + url: { enumerable: true }, + status: { enumerable: true }, + ok: { enumerable: true }, + redirected: { enumerable: true }, + statusText: { enumerable: true }, + headers: { enumerable: true }, + clone: { enumerable: true } +}); + +Object.defineProperty(Response.prototype, Symbol.toStringTag, { + value: 'Response', + writable: false, + enumerable: false, + configurable: true +}); + +const INTERNALS$2 = Symbol('Request internals'); +const URL = Url.URL || whatwgUrl.URL; + +// fix an issue where "format", "parse" aren't a named export for node <10 +const parse_url = Url.parse; +const format_url = Url.format; + +/** + * Wrapper around `new URL` to handle arbitrary URLs + * + * @param {string} urlStr + * @return {void} + */ +function parseURL(urlStr) { + /* + Check whether the URL is absolute or not + Scheme: https://tools.ietf.org/html/rfc3986#section-3.1 + Absolute URL: https://tools.ietf.org/html/rfc3986#section-4.3 + */ + if (/^[a-zA-Z][a-zA-Z\d+\-.]*:/.exec(urlStr)) { + urlStr = new URL(urlStr).toString(); + } + + // Fallback to old implementation for arbitrary URLs + return parse_url(urlStr); +} + +const streamDestructionSupported = 'destroy' in Stream.Readable.prototype; + +/** + * Check if a value is an instance of Request. + * + * @param Mixed input + * @return Boolean + */ +function isRequest(input) { + return typeof input === 'object' && typeof input[INTERNALS$2] === 'object'; +} + +function isAbortSignal(signal) { + const proto = signal && typeof signal === 'object' && Object.getPrototypeOf(signal); + return !!(proto && proto.constructor.name === 'AbortSignal'); +} + +/** + * Request class + * + * @param Mixed input Url or Request instance + * @param Object init Custom options + * @return Void + */ +class Request { + constructor(input) { + let init = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + + let parsedURL; + + // normalize input + if (!isRequest(input)) { + if (input && input.href) { + // in order to support Node.js' Url objects; though WHATWG's URL objects + // will fall into this branch also (since their `toString()` will return + // `href` property anyway) + parsedURL = parseURL(input.href); + } else { + // coerce input to a string before attempting to parse + parsedURL = parseURL(`${input}`); + } + input = {}; + } else { + parsedURL = parseURL(input.url); + } + + let method = init.method || input.method || 'GET'; + method = method.toUpperCase(); + + if ((init.body != null || isRequest(input) && input.body !== null) && (method === 'GET' || method === 'HEAD')) { + throw new TypeError('Request with GET/HEAD method cannot have body'); + } + + let inputBody = init.body != null ? init.body : isRequest(input) && input.body !== null ? clone(input) : null; + + Body.call(this, inputBody, { + timeout: init.timeout || input.timeout || 0, + size: init.size || input.size || 0 + }); + + const headers = new Headers(init.headers || input.headers || {}); + + if (inputBody != null && !headers.has('Content-Type')) { + const contentType = extractContentType(inputBody); + if (contentType) { + headers.append('Content-Type', contentType); + } + } + + let signal = isRequest(input) ? input.signal : null; + if ('signal' in init) signal = init.signal; + + if (signal != null && !isAbortSignal(signal)) { + throw new TypeError('Expected signal to be an instanceof AbortSignal'); + } + + this[INTERNALS$2] = { + method, + redirect: init.redirect || input.redirect || 'follow', + headers, + parsedURL, + signal + }; + + // node-fetch-only options + this.follow = init.follow !== undefined ? init.follow : input.follow !== undefined ? input.follow : 20; + this.compress = init.compress !== undefined ? init.compress : input.compress !== undefined ? input.compress : true; + this.counter = init.counter || input.counter || 0; + this.agent = init.agent || input.agent; + } + + get method() { + return this[INTERNALS$2].method; + } + + get url() { + return format_url(this[INTERNALS$2].parsedURL); + } + + get headers() { + return this[INTERNALS$2].headers; + } + + get redirect() { + return this[INTERNALS$2].redirect; + } + + get signal() { + return this[INTERNALS$2].signal; + } + + /** + * Clone this request + * + * @return Request + */ + clone() { + return new Request(this); + } +} + +Body.mixIn(Request.prototype); + +Object.defineProperty(Request.prototype, Symbol.toStringTag, { + value: 'Request', + writable: false, + enumerable: false, + configurable: true +}); + +Object.defineProperties(Request.prototype, { + method: { enumerable: true }, + url: { enumerable: true }, + headers: { enumerable: true }, + redirect: { enumerable: true }, + clone: { enumerable: true }, + signal: { enumerable: true } +}); + +/** + * Convert a Request to Node.js http request options. + * + * @param Request A Request instance + * @return Object The options object to be passed to http.request + */ +function getNodeRequestOptions(request) { + const parsedURL = request[INTERNALS$2].parsedURL; + const headers = new Headers(request[INTERNALS$2].headers); + + // fetch step 1.3 + if (!headers.has('Accept')) { + headers.set('Accept', '*/*'); + } + + // Basic fetch + if (!parsedURL.protocol || !parsedURL.hostname) { + throw new TypeError('Only absolute URLs are supported'); + } + + if (!/^https?:$/.test(parsedURL.protocol)) { + throw new TypeError('Only HTTP(S) protocols are supported'); + } + + if (request.signal && request.body instanceof Stream.Readable && !streamDestructionSupported) { + throw new Error('Cancellation of streamed requests with AbortSignal is not supported in node < 8'); + } + + // HTTP-network-or-cache fetch steps 2.4-2.7 + let contentLengthValue = null; + if (request.body == null && /^(POST|PUT)$/i.test(request.method)) { + contentLengthValue = '0'; + } + if (request.body != null) { + const totalBytes = getTotalBytes(request); + if (typeof totalBytes === 'number') { + contentLengthValue = String(totalBytes); + } + } + if (contentLengthValue) { + headers.set('Content-Length', contentLengthValue); + } + + // HTTP-network-or-cache fetch step 2.11 + if (!headers.has('User-Agent')) { + headers.set('User-Agent', 'node-fetch/1.0 (+https://github.com/bitinn/node-fetch)'); + } + + // HTTP-network-or-cache fetch step 2.15 + if (request.compress && !headers.has('Accept-Encoding')) { + headers.set('Accept-Encoding', 'gzip,deflate'); + } + + let agent = request.agent; + if (typeof agent === 'function') { + agent = agent(parsedURL); + } + + // HTTP-network fetch step 4.2 + // chunked encoding is handled by Node.js + + return Object.assign({}, parsedURL, { + method: request.method, + headers: exportNodeCompatibleHeaders(headers), + agent + }); +} + +/** + * abort-error.js + * + * AbortError interface for cancelled requests + */ + +/** + * Create AbortError instance + * + * @param String message Error message for human + * @return AbortError + */ +function AbortError(message) { + Error.call(this, message); + + this.type = 'aborted'; + this.message = message; + + // hide custom error implementation details from end-users + Error.captureStackTrace(this, this.constructor); +} + +AbortError.prototype = Object.create(Error.prototype); +AbortError.prototype.constructor = AbortError; +AbortError.prototype.name = 'AbortError'; + +const URL$1 = Url.URL || whatwgUrl.URL; + +// fix an issue where "PassThrough", "resolve" aren't a named export for node <10 +const PassThrough$1 = Stream.PassThrough; + +const isDomainOrSubdomain = function isDomainOrSubdomain(destination, original) { + const orig = new URL$1(original).hostname; + const dest = new URL$1(destination).hostname; + + return orig === dest || orig[orig.length - dest.length - 1] === '.' && orig.endsWith(dest); +}; + +/** + * isSameProtocol reports whether the two provided URLs use the same protocol. + * + * Both domains must already be in canonical form. + * @param {string|URL} original + * @param {string|URL} destination + */ +const isSameProtocol = function isSameProtocol(destination, original) { + const orig = new URL$1(original).protocol; + const dest = new URL$1(destination).protocol; + + return orig === dest; +}; + +/** + * Fetch function + * + * @param Mixed url Absolute url or Request instance + * @param Object opts Fetch options + * @return Promise + */ +function fetch(url, opts) { + + // allow custom promise + if (!fetch.Promise) { + throw new Error('native promise missing, set fetch.Promise to your favorite alternative'); + } + + Body.Promise = fetch.Promise; + + // wrap http.request into fetch + return new fetch.Promise(function (resolve, reject) { + // build request object + const request = new Request(url, opts); + const options = getNodeRequestOptions(request); + + const send = (options.protocol === 'https:' ? https : http).request; + const signal = request.signal; + + let response = null; + + const abort = function abort() { + let error = new AbortError('The user aborted a request.'); + reject(error); + if (request.body && request.body instanceof Stream.Readable) { + destroyStream(request.body, error); + } + if (!response || !response.body) return; + response.body.emit('error', error); + }; + + if (signal && signal.aborted) { + abort(); + return; + } + + const abortAndFinalize = function abortAndFinalize() { + abort(); + finalize(); + }; + + // send request + const req = send(options); + let reqTimeout; + + if (signal) { + signal.addEventListener('abort', abortAndFinalize); + } + + function finalize() { + req.abort(); + if (signal) signal.removeEventListener('abort', abortAndFinalize); + clearTimeout(reqTimeout); + } + + if (request.timeout) { + req.once('socket', function (socket) { + reqTimeout = setTimeout(function () { + reject(new FetchError(`network timeout at: ${request.url}`, 'request-timeout')); + finalize(); + }, request.timeout); + }); + } + + req.on('error', function (err) { + reject(new FetchError(`request to ${request.url} failed, reason: ${err.message}`, 'system', err)); + + if (response && response.body) { + destroyStream(response.body, err); + } + + finalize(); + }); + + fixResponseChunkedTransferBadEnding(req, function (err) { + if (signal && signal.aborted) { + return; + } + + if (response && response.body) { + destroyStream(response.body, err); + } + }); + + /* c8 ignore next 18 */ + if (parseInt(process.version.substring(1)) < 14) { + // Before Node.js 14, pipeline() does not fully support async iterators and does not always + // properly handle when the socket close/end events are out of order. + req.on('socket', function (s) { + s.addListener('close', function (hadError) { + // if a data listener is still present we didn't end cleanly + const hasDataListener = s.listenerCount('data') > 0; + + // if end happened before close but the socket didn't emit an error, do it now + if (response && hasDataListener && !hadError && !(signal && signal.aborted)) { + const err = new Error('Premature close'); + err.code = 'ERR_STREAM_PREMATURE_CLOSE'; + response.body.emit('error', err); + } + }); + }); + } + + req.on('response', function (res) { + clearTimeout(reqTimeout); + + const headers = createHeadersLenient(res.headers); + + // HTTP fetch step 5 + if (fetch.isRedirect(res.statusCode)) { + // HTTP fetch step 5.2 + const location = headers.get('Location'); + + // HTTP fetch step 5.3 + let locationURL = null; + try { + locationURL = location === null ? null : new URL$1(location, request.url).toString(); + } catch (err) { + // error here can only be invalid URL in Location: header + // do not throw when options.redirect == manual + // let the user extract the errorneous redirect URL + if (request.redirect !== 'manual') { + reject(new FetchError(`uri requested responds with an invalid redirect URL: ${location}`, 'invalid-redirect')); + finalize(); + return; + } + } + + // HTTP fetch step 5.5 + switch (request.redirect) { + case 'error': + reject(new FetchError(`uri requested responds with a redirect, redirect mode is set to error: ${request.url}`, 'no-redirect')); + finalize(); + return; + case 'manual': + // node-fetch-specific step: make manual redirect a bit easier to use by setting the Location header value to the resolved URL. + if (locationURL !== null) { + // handle corrupted header + try { + headers.set('Location', locationURL); + } catch (err) { + // istanbul ignore next: nodejs server prevent invalid response headers, we can't test this through normal request + reject(err); + } + } + break; + case 'follow': + // HTTP-redirect fetch step 2 + if (locationURL === null) { + break; + } + + // HTTP-redirect fetch step 5 + if (request.counter >= request.follow) { + reject(new FetchError(`maximum redirect reached at: ${request.url}`, 'max-redirect')); + finalize(); + return; + } + + // HTTP-redirect fetch step 6 (counter increment) + // Create a new Request object. + const requestOpts = { + headers: new Headers(request.headers), + follow: request.follow, + counter: request.counter + 1, + agent: request.agent, + compress: request.compress, + method: request.method, + body: request.body, + signal: request.signal, + timeout: request.timeout, + size: request.size + }; + + if (!isDomainOrSubdomain(request.url, locationURL) || !isSameProtocol(request.url, locationURL)) { + for (const name of ['authorization', 'www-authenticate', 'cookie', 'cookie2']) { + requestOpts.headers.delete(name); + } + } + + // HTTP-redirect fetch step 9 + if (res.statusCode !== 303 && request.body && getTotalBytes(request) === null) { + reject(new FetchError('Cannot follow redirect with body being a readable stream', 'unsupported-redirect')); + finalize(); + return; + } + + // HTTP-redirect fetch step 11 + if (res.statusCode === 303 || (res.statusCode === 301 || res.statusCode === 302) && request.method === 'POST') { + requestOpts.method = 'GET'; + requestOpts.body = undefined; + requestOpts.headers.delete('content-length'); + } + + // HTTP-redirect fetch step 15 + resolve(fetch(new Request(locationURL, requestOpts))); + finalize(); + return; + } + } + + // prepare response + res.once('end', function () { + if (signal) signal.removeEventListener('abort', abortAndFinalize); + }); + let body = res.pipe(new PassThrough$1()); + + const response_options = { + url: request.url, + status: res.statusCode, + statusText: res.statusMessage, + headers: headers, + size: request.size, + timeout: request.timeout, + counter: request.counter + }; + + // HTTP-network fetch step 12.1.1.3 + const codings = headers.get('Content-Encoding'); + + // HTTP-network fetch step 12.1.1.4: handle content codings + + // in following scenarios we ignore compression support + // 1. compression support is disabled + // 2. HEAD request + // 3. no Content-Encoding header + // 4. no content response (204) + // 5. content not modified response (304) + if (!request.compress || request.method === 'HEAD' || codings === null || res.statusCode === 204 || res.statusCode === 304) { + response = new Response(body, response_options); + resolve(response); + return; + } + + // For Node v6+ + // Be less strict when decoding compressed responses, since sometimes + // servers send slightly invalid responses that are still accepted + // by common browsers. + // Always using Z_SYNC_FLUSH is what cURL does. + const zlibOptions = { + flush: zlib.Z_SYNC_FLUSH, + finishFlush: zlib.Z_SYNC_FLUSH + }; + + // for gzip + if (codings == 'gzip' || codings == 'x-gzip') { + body = body.pipe(zlib.createGunzip(zlibOptions)); + response = new Response(body, response_options); + resolve(response); + return; + } + + // for deflate + if (codings == 'deflate' || codings == 'x-deflate') { + // handle the infamous raw deflate response from old servers + // a hack for old IIS and Apache servers + const raw = res.pipe(new PassThrough$1()); + raw.once('data', function (chunk) { + // see http://stackoverflow.com/questions/37519828 + if ((chunk[0] & 0x0F) === 0x08) { + body = body.pipe(zlib.createInflate()); + } else { + body = body.pipe(zlib.createInflateRaw()); + } + response = new Response(body, response_options); + resolve(response); + }); + raw.on('end', function () { + // some old IIS servers return zero-length OK deflate responses, so 'data' is never emitted. + if (!response) { + response = new Response(body, response_options); + resolve(response); + } + }); + return; + } + + // for br + if (codings == 'br' && typeof zlib.createBrotliDecompress === 'function') { + body = body.pipe(zlib.createBrotliDecompress()); + response = new Response(body, response_options); + resolve(response); + return; + } + + // otherwise, use response as-is + response = new Response(body, response_options); + resolve(response); + }); + + writeToStream(req, request); + }); +} +function fixResponseChunkedTransferBadEnding(request, errorCallback) { + let socket; + + request.on('socket', function (s) { + socket = s; + }); + + request.on('response', function (response) { + const headers = response.headers; + + if (headers['transfer-encoding'] === 'chunked' && !headers['content-length']) { + response.once('close', function (hadError) { + // tests for socket presence, as in some situations the + // the 'socket' event is not triggered for the request + // (happens in deno), avoids `TypeError` + // if a data listener is still present we didn't end cleanly + const hasDataListener = socket && socket.listenerCount('data') > 0; + + if (hasDataListener && !hadError) { + const err = new Error('Premature close'); + err.code = 'ERR_STREAM_PREMATURE_CLOSE'; + errorCallback(err); + } + }); + } + }); +} + +function destroyStream(stream, err) { + if (stream.destroy) { + stream.destroy(err); + } else { + // node < 8 + stream.emit('error', err); + stream.end(); + } +} + +/** + * Redirect code matching + * + * @param Number code Status code + * @return Boolean + */ +fetch.isRedirect = function (code) { + return code === 301 || code === 302 || code === 303 || code === 307 || code === 308; +}; + +// expose Promise +fetch.Promise = global.Promise; + +export default fetch; +export { Headers, Request, Response, FetchError, AbortError }; diff --git a/sandbox/tgbot/node_modules/node-fetch/package.json b/sandbox/tgbot/node_modules/node-fetch/package.json new file mode 100644 index 0000000..e0be176 --- /dev/null +++ b/sandbox/tgbot/node_modules/node-fetch/package.json @@ -0,0 +1,89 @@ +{ + "name": "node-fetch", + "version": "2.7.0", + "description": "A light-weight module that brings window.fetch to node.js", + "main": "lib/index.js", + "browser": "./browser.js", + "module": "lib/index.mjs", + "files": [ + "lib/index.js", + "lib/index.mjs", + "lib/index.es.js", + "browser.js" + ], + "engines": { + "node": "4.x || >=6.0.0" + }, + "scripts": { + "build": "cross-env BABEL_ENV=rollup rollup -c", + "prepare": "npm run build", + "test": "cross-env BABEL_ENV=test mocha --require babel-register --throw-deprecation test/test.js", + "report": "cross-env BABEL_ENV=coverage nyc --reporter lcov --reporter text mocha -R spec test/test.js", + "coverage": "cross-env BABEL_ENV=coverage nyc --reporter json --reporter text mocha -R spec test/test.js && codecov -f coverage/coverage-final.json" + }, + "repository": { + "type": "git", + "url": "https://github.com/bitinn/node-fetch.git" + }, + "keywords": [ + "fetch", + "http", + "promise" + ], + "author": "David Frank", + "license": "MIT", + "bugs": { + "url": "https://github.com/bitinn/node-fetch/issues" + }, + "homepage": "https://github.com/bitinn/node-fetch", + "dependencies": { + "whatwg-url": "^5.0.0" + }, + "peerDependencies": { + "encoding": "^0.1.0" + }, + "peerDependenciesMeta": { + "encoding": { + "optional": true + } + }, + "devDependencies": { + "@ungap/url-search-params": "^0.1.2", + "abort-controller": "^1.1.0", + "abortcontroller-polyfill": "^1.3.0", + "babel-core": "^6.26.3", + "babel-plugin-istanbul": "^4.1.6", + "babel-plugin-transform-async-generator-functions": "^6.24.1", + "babel-polyfill": "^6.26.0", + "babel-preset-env": "1.4.0", + "babel-register": "^6.16.3", + "chai": "^3.5.0", + "chai-as-promised": "^7.1.1", + "chai-iterator": "^1.1.1", + "chai-string": "~1.3.0", + "codecov": "3.3.0", + "cross-env": "^5.2.0", + "form-data": "^2.3.3", + "is-builtin-module": "^1.0.0", + "mocha": "^5.0.0", + "nyc": "11.9.0", + "parted": "^0.1.1", + "promise": "^8.0.3", + "resumer": "0.0.0", + "rollup": "^0.63.4", + "rollup-plugin-babel": "^3.0.7", + "string-to-arraybuffer": "^1.0.2", + "teeny-request": "3.7.0" + }, + "release": { + "branches": [ + "+([0-9]).x", + "main", + "next", + { + "name": "beta", + "prerelease": true + } + ] + } +} diff --git a/sandbox/tgbot/node_modules/tr46/.npmignore b/sandbox/tgbot/node_modules/tr46/.npmignore new file mode 100644 index 0000000..96e9161 --- /dev/null +++ b/sandbox/tgbot/node_modules/tr46/.npmignore @@ -0,0 +1,4 @@ +scripts/ +test/ + +!lib/mapping_table.json diff --git a/sandbox/tgbot/node_modules/tr46/index.js b/sandbox/tgbot/node_modules/tr46/index.js new file mode 100644 index 0000000..9ce12ca --- /dev/null +++ b/sandbox/tgbot/node_modules/tr46/index.js @@ -0,0 +1,193 @@ +"use strict"; + +var punycode = require("punycode"); +var mappingTable = require("./lib/mappingTable.json"); + +var PROCESSING_OPTIONS = { + TRANSITIONAL: 0, + NONTRANSITIONAL: 1 +}; + +function normalize(str) { // fix bug in v8 + return str.split('\u0000').map(function (s) { return s.normalize('NFC'); }).join('\u0000'); +} + +function findStatus(val) { + var start = 0; + var end = mappingTable.length - 1; + + while (start <= end) { + var mid = Math.floor((start + end) / 2); + + var target = mappingTable[mid]; + if (target[0][0] <= val && target[0][1] >= val) { + return target; + } else if (target[0][0] > val) { + end = mid - 1; + } else { + start = mid + 1; + } + } + + return null; +} + +var regexAstralSymbols = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g; + +function countSymbols(string) { + return string + // replace every surrogate pair with a BMP symbol + .replace(regexAstralSymbols, '_') + // then get the length + .length; +} + +function mapChars(domain_name, useSTD3, processing_option) { + var hasError = false; + var processed = ""; + + var len = countSymbols(domain_name); + for (var i = 0; i < len; ++i) { + var codePoint = domain_name.codePointAt(i); + var status = findStatus(codePoint); + + switch (status[1]) { + case "disallowed": + hasError = true; + processed += String.fromCodePoint(codePoint); + break; + case "ignored": + break; + case "mapped": + processed += String.fromCodePoint.apply(String, status[2]); + break; + case "deviation": + if (processing_option === PROCESSING_OPTIONS.TRANSITIONAL) { + processed += String.fromCodePoint.apply(String, status[2]); + } else { + processed += String.fromCodePoint(codePoint); + } + break; + case "valid": + processed += String.fromCodePoint(codePoint); + break; + case "disallowed_STD3_mapped": + if (useSTD3) { + hasError = true; + processed += String.fromCodePoint(codePoint); + } else { + processed += String.fromCodePoint.apply(String, status[2]); + } + break; + case "disallowed_STD3_valid": + if (useSTD3) { + hasError = true; + } + + processed += String.fromCodePoint(codePoint); + break; + } + } + + return { + string: processed, + error: hasError + }; +} + +var combiningMarksRegex = /[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08E4-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C03\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D01-\u0D03\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u18A9\u1920-\u192B\u1930-\u193B\u19B0-\u19C0\u19C8\u19C9\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF8\u1CF9\u1DC0-\u1DF5\u1DFC-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C4\uA8E0-\uA8F1\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2D]|\uD800[\uDDFD\uDEE0\uDF76-\uDF7A]|\uD802[\uDE01-\uDE03\uDE05\uDE06\uDE0C-\uDE0F\uDE38-\uDE3A\uDE3F\uDEE5\uDEE6]|\uD804[\uDC00-\uDC02\uDC38-\uDC46\uDC7F-\uDC82\uDCB0-\uDCBA\uDD00-\uDD02\uDD27-\uDD34\uDD73\uDD80-\uDD82\uDDB3-\uDDC0\uDE2C-\uDE37\uDEDF-\uDEEA\uDF01-\uDF03\uDF3C\uDF3E-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF57\uDF62\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDCB0-\uDCC3\uDDAF-\uDDB5\uDDB8-\uDDC0\uDE30-\uDE40\uDEAB-\uDEB7]|\uD81A[\uDEF0-\uDEF4\uDF30-\uDF36]|\uD81B[\uDF51-\uDF7E\uDF8F-\uDF92]|\uD82F[\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD83A[\uDCD0-\uDCD6]|\uDB40[\uDD00-\uDDEF]/; + +function validateLabel(label, processing_option) { + if (label.substr(0, 4) === "xn--") { + label = punycode.toUnicode(label); + processing_option = PROCESSING_OPTIONS.NONTRANSITIONAL; + } + + var error = false; + + if (normalize(label) !== label || + (label[3] === "-" && label[4] === "-") || + label[0] === "-" || label[label.length - 1] === "-" || + label.indexOf(".") !== -1 || + label.search(combiningMarksRegex) === 0) { + error = true; + } + + var len = countSymbols(label); + for (var i = 0; i < len; ++i) { + var status = findStatus(label.codePointAt(i)); + if ((processing === PROCESSING_OPTIONS.TRANSITIONAL && status[1] !== "valid") || + (processing === PROCESSING_OPTIONS.NONTRANSITIONAL && + status[1] !== "valid" && status[1] !== "deviation")) { + error = true; + break; + } + } + + return { + label: label, + error: error + }; +} + +function processing(domain_name, useSTD3, processing_option) { + var result = mapChars(domain_name, useSTD3, processing_option); + result.string = normalize(result.string); + + var labels = result.string.split("."); + for (var i = 0; i < labels.length; ++i) { + try { + var validation = validateLabel(labels[i]); + labels[i] = validation.label; + result.error = result.error || validation.error; + } catch(e) { + result.error = true; + } + } + + return { + string: labels.join("."), + error: result.error + }; +} + +module.exports.toASCII = function(domain_name, useSTD3, processing_option, verifyDnsLength) { + var result = processing(domain_name, useSTD3, processing_option); + var labels = result.string.split("."); + labels = labels.map(function(l) { + try { + return punycode.toASCII(l); + } catch(e) { + result.error = true; + return l; + } + }); + + if (verifyDnsLength) { + var total = labels.slice(0, labels.length - 1).join(".").length; + if (total.length > 253 || total.length === 0) { + result.error = true; + } + + for (var i=0; i < labels.length; ++i) { + if (labels.length > 63 || labels.length === 0) { + result.error = true; + break; + } + } + } + + if (result.error) return null; + return labels.join("."); +}; + +module.exports.toUnicode = function(domain_name, useSTD3) { + var result = processing(domain_name, useSTD3, PROCESSING_OPTIONS.NONTRANSITIONAL); + + return { + domain: result.string, + error: result.error + }; +}; + +module.exports.PROCESSING_OPTIONS = PROCESSING_OPTIONS; diff --git a/sandbox/tgbot/node_modules/tr46/lib/.gitkeep b/sandbox/tgbot/node_modules/tr46/lib/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/sandbox/tgbot/node_modules/tr46/lib/mappingTable.json b/sandbox/tgbot/node_modules/tr46/lib/mappingTable.json new file mode 100644 index 0000000..89cf19a --- /dev/null +++ b/sandbox/tgbot/node_modules/tr46/lib/mappingTable.json @@ -0,0 +1 @@ +[[[0,44],"disallowed_STD3_valid"],[[45,46],"valid"],[[47,47],"disallowed_STD3_valid"],[[48,57],"valid"],[[58,64],"disallowed_STD3_valid"],[[65,65],"mapped",[97]],[[66,66],"mapped",[98]],[[67,67],"mapped",[99]],[[68,68],"mapped",[100]],[[69,69],"mapped",[101]],[[70,70],"mapped",[102]],[[71,71],"mapped",[103]],[[72,72],"mapped",[104]],[[73,73],"mapped",[105]],[[74,74],"mapped",[106]],[[75,75],"mapped",[107]],[[76,76],"mapped",[108]],[[77,77],"mapped",[109]],[[78,78],"mapped",[110]],[[79,79],"mapped",[111]],[[80,80],"mapped",[112]],[[81,81],"mapped",[113]],[[82,82],"mapped",[114]],[[83,83],"mapped",[115]],[[84,84],"mapped",[116]],[[85,85],"mapped",[117]],[[86,86],"mapped",[118]],[[87,87],"mapped",[119]],[[88,88],"mapped",[120]],[[89,89],"mapped",[121]],[[90,90],"mapped",[122]],[[91,96],"disallowed_STD3_valid"],[[97,122],"valid"],[[123,127],"disallowed_STD3_valid"],[[128,159],"disallowed"],[[160,160],"disallowed_STD3_mapped",[32]],[[161,167],"valid",[],"NV8"],[[168,168],"disallowed_STD3_mapped",[32,776]],[[169,169],"valid",[],"NV8"],[[170,170],"mapped",[97]],[[171,172],"valid",[],"NV8"],[[173,173],"ignored"],[[174,174],"valid",[],"NV8"],[[175,175],"disallowed_STD3_mapped",[32,772]],[[176,177],"valid",[],"NV8"],[[178,178],"mapped",[50]],[[179,179],"mapped",[51]],[[180,180],"disallowed_STD3_mapped",[32,769]],[[181,181],"mapped",[956]],[[182,182],"valid",[],"NV8"],[[183,183],"valid"],[[184,184],"disallowed_STD3_mapped",[32,807]],[[185,185],"mapped",[49]],[[186,186],"mapped",[111]],[[187,187],"valid",[],"NV8"],[[188,188],"mapped",[49,8260,52]],[[189,189],"mapped",[49,8260,50]],[[190,190],"mapped",[51,8260,52]],[[191,191],"valid",[],"NV8"],[[192,192],"mapped",[224]],[[193,193],"mapped",[225]],[[194,194],"mapped",[226]],[[195,195],"mapped",[227]],[[196,196],"mapped",[228]],[[197,197],"mapped",[229]],[[198,198],"mapped",[230]],[[199,199],"mapped",[231]],[[200,200],"mapped",[232]],[[201,201],"mapped",[233]],[[202,202],"mapped",[234]],[[203,203],"mapped",[235]],[[204,204],"mapped",[236]],[[205,205],"mapped",[237]],[[206,206],"mapped",[238]],[[207,207],"mapped",[239]],[[208,208],"mapped",[240]],[[209,209],"mapped",[241]],[[210,210],"mapped",[242]],[[211,211],"mapped",[243]],[[212,212],"mapped",[244]],[[213,213],"mapped",[245]],[[214,214],"mapped",[246]],[[215,215],"valid",[],"NV8"],[[216,216],"mapped",[248]],[[217,217],"mapped",[249]],[[218,218],"mapped",[250]],[[219,219],"mapped",[251]],[[220,220],"mapped",[252]],[[221,221],"mapped",[253]],[[222,222],"mapped",[254]],[[223,223],"deviation",[115,115]],[[224,246],"valid"],[[247,247],"valid",[],"NV8"],[[248,255],"valid"],[[256,256],"mapped",[257]],[[257,257],"valid"],[[258,258],"mapped",[259]],[[259,259],"valid"],[[260,260],"mapped",[261]],[[261,261],"valid"],[[262,262],"mapped",[263]],[[263,263],"valid"],[[264,264],"mapped",[265]],[[265,265],"valid"],[[266,266],"mapped",[267]],[[267,267],"valid"],[[268,268],"mapped",[269]],[[269,269],"valid"],[[270,270],"mapped",[271]],[[271,271],"valid"],[[272,272],"mapped",[273]],[[273,273],"valid"],[[274,274],"mapped",[275]],[[275,275],"valid"],[[276,276],"mapped",[277]],[[277,277],"valid"],[[278,278],"mapped",[279]],[[279,279],"valid"],[[280,280],"mapped",[281]],[[281,281],"valid"],[[282,282],"mapped",[283]],[[283,283],"valid"],[[284,284],"mapped",[285]],[[285,285],"valid"],[[286,286],"mapped",[287]],[[287,287],"valid"],[[288,288],"mapped",[289]],[[289,289],"valid"],[[290,290],"mapped",[291]],[[291,291],"valid"],[[292,292],"mapped",[293]],[[293,293],"valid"],[[294,294],"mapped",[295]],[[295,295],"valid"],[[296,296],"mapped",[297]],[[297,297],"valid"],[[298,298],"mapped",[299]],[[299,299],"valid"],[[300,300],"mapped",[301]],[[301,301],"valid"],[[302,302],"mapped",[303]],[[303,303],"valid"],[[304,304],"mapped",[105,775]],[[305,305],"valid"],[[306,307],"mapped",[105,106]],[[308,308],"mapped",[309]],[[309,309],"valid"],[[310,310],"mapped",[311]],[[311,312],"valid"],[[313,313],"mapped",[314]],[[314,314],"valid"],[[315,315],"mapped",[316]],[[316,316],"valid"],[[317,317],"mapped",[318]],[[318,318],"valid"],[[319,320],"mapped",[108,183]],[[321,321],"mapped",[322]],[[322,322],"valid"],[[323,323],"mapped",[324]],[[324,324],"valid"],[[325,325],"mapped",[326]],[[326,326],"valid"],[[327,327],"mapped",[328]],[[328,328],"valid"],[[329,329],"mapped",[700,110]],[[330,330],"mapped",[331]],[[331,331],"valid"],[[332,332],"mapped",[333]],[[333,333],"valid"],[[334,334],"mapped",[335]],[[335,335],"valid"],[[336,336],"mapped",[337]],[[337,337],"valid"],[[338,338],"mapped",[339]],[[339,339],"valid"],[[340,340],"mapped",[341]],[[341,341],"valid"],[[342,342],"mapped",[343]],[[343,343],"valid"],[[344,344],"mapped",[345]],[[345,345],"valid"],[[346,346],"mapped",[347]],[[347,347],"valid"],[[348,348],"mapped",[349]],[[349,349],"valid"],[[350,350],"mapped",[351]],[[351,351],"valid"],[[352,352],"mapped",[353]],[[353,353],"valid"],[[354,354],"mapped",[355]],[[355,355],"valid"],[[356,356],"mapped",[357]],[[357,357],"valid"],[[358,358],"mapped",[359]],[[359,359],"valid"],[[360,360],"mapped",[361]],[[361,361],"valid"],[[362,362],"mapped",[363]],[[363,363],"valid"],[[364,364],"mapped",[365]],[[365,365],"valid"],[[366,366],"mapped",[367]],[[367,367],"valid"],[[368,368],"mapped",[369]],[[369,369],"valid"],[[370,370],"mapped",[371]],[[371,371],"valid"],[[372,372],"mapped",[373]],[[373,373],"valid"],[[374,374],"mapped",[375]],[[375,375],"valid"],[[376,376],"mapped",[255]],[[377,377],"mapped",[378]],[[378,378],"valid"],[[379,379],"mapped",[380]],[[380,380],"valid"],[[381,381],"mapped",[382]],[[382,382],"valid"],[[383,383],"mapped",[115]],[[384,384],"valid"],[[385,385],"mapped",[595]],[[386,386],"mapped",[387]],[[387,387],"valid"],[[388,388],"mapped",[389]],[[389,389],"valid"],[[390,390],"mapped",[596]],[[391,391],"mapped",[392]],[[392,392],"valid"],[[393,393],"mapped",[598]],[[394,394],"mapped",[599]],[[395,395],"mapped",[396]],[[396,397],"valid"],[[398,398],"mapped",[477]],[[399,399],"mapped",[601]],[[400,400],"mapped",[603]],[[401,401],"mapped",[402]],[[402,402],"valid"],[[403,403],"mapped",[608]],[[404,404],"mapped",[611]],[[405,405],"valid"],[[406,406],"mapped",[617]],[[407,407],"mapped",[616]],[[408,408],"mapped",[409]],[[409,411],"valid"],[[412,412],"mapped",[623]],[[413,413],"mapped",[626]],[[414,414],"valid"],[[415,415],"mapped",[629]],[[416,416],"mapped",[417]],[[417,417],"valid"],[[418,418],"mapped",[419]],[[419,419],"valid"],[[420,420],"mapped",[421]],[[421,421],"valid"],[[422,422],"mapped",[640]],[[423,423],"mapped",[424]],[[424,424],"valid"],[[425,425],"mapped",[643]],[[426,427],"valid"],[[428,428],"mapped",[429]],[[429,429],"valid"],[[430,430],"mapped",[648]],[[431,431],"mapped",[432]],[[432,432],"valid"],[[433,433],"mapped",[650]],[[434,434],"mapped",[651]],[[435,435],"mapped",[436]],[[436,436],"valid"],[[437,437],"mapped",[438]],[[438,438],"valid"],[[439,439],"mapped",[658]],[[440,440],"mapped",[441]],[[441,443],"valid"],[[444,444],"mapped",[445]],[[445,451],"valid"],[[452,454],"mapped",[100,382]],[[455,457],"mapped",[108,106]],[[458,460],"mapped",[110,106]],[[461,461],"mapped",[462]],[[462,462],"valid"],[[463,463],"mapped",[464]],[[464,464],"valid"],[[465,465],"mapped",[466]],[[466,466],"valid"],[[467,467],"mapped",[468]],[[468,468],"valid"],[[469,469],"mapped",[470]],[[470,470],"valid"],[[471,471],"mapped",[472]],[[472,472],"valid"],[[473,473],"mapped",[474]],[[474,474],"valid"],[[475,475],"mapped",[476]],[[476,477],"valid"],[[478,478],"mapped",[479]],[[479,479],"valid"],[[480,480],"mapped",[481]],[[481,481],"valid"],[[482,482],"mapped",[483]],[[483,483],"valid"],[[484,484],"mapped",[485]],[[485,485],"valid"],[[486,486],"mapped",[487]],[[487,487],"valid"],[[488,488],"mapped",[489]],[[489,489],"valid"],[[490,490],"mapped",[491]],[[491,491],"valid"],[[492,492],"mapped",[493]],[[493,493],"valid"],[[494,494],"mapped",[495]],[[495,496],"valid"],[[497,499],"mapped",[100,122]],[[500,500],"mapped",[501]],[[501,501],"valid"],[[502,502],"mapped",[405]],[[503,503],"mapped",[447]],[[504,504],"mapped",[505]],[[505,505],"valid"],[[506,506],"mapped",[507]],[[507,507],"valid"],[[508,508],"mapped",[509]],[[509,509],"valid"],[[510,510],"mapped",[511]],[[511,511],"valid"],[[512,512],"mapped",[513]],[[513,513],"valid"],[[514,514],"mapped",[515]],[[515,515],"valid"],[[516,516],"mapped",[517]],[[517,517],"valid"],[[518,518],"mapped",[519]],[[519,519],"valid"],[[520,520],"mapped",[521]],[[521,521],"valid"],[[522,522],"mapped",[523]],[[523,523],"valid"],[[524,524],"mapped",[525]],[[525,525],"valid"],[[526,526],"mapped",[527]],[[527,527],"valid"],[[528,528],"mapped",[529]],[[529,529],"valid"],[[530,530],"mapped",[531]],[[531,531],"valid"],[[532,532],"mapped",[533]],[[533,533],"valid"],[[534,534],"mapped",[535]],[[535,535],"valid"],[[536,536],"mapped",[537]],[[537,537],"valid"],[[538,538],"mapped",[539]],[[539,539],"valid"],[[540,540],"mapped",[541]],[[541,541],"valid"],[[542,542],"mapped",[543]],[[543,543],"valid"],[[544,544],"mapped",[414]],[[545,545],"valid"],[[546,546],"mapped",[547]],[[547,547],"valid"],[[548,548],"mapped",[549]],[[549,549],"valid"],[[550,550],"mapped",[551]],[[551,551],"valid"],[[552,552],"mapped",[553]],[[553,553],"valid"],[[554,554],"mapped",[555]],[[555,555],"valid"],[[556,556],"mapped",[557]],[[557,557],"valid"],[[558,558],"mapped",[559]],[[559,559],"valid"],[[560,560],"mapped",[561]],[[561,561],"valid"],[[562,562],"mapped",[563]],[[563,563],"valid"],[[564,566],"valid"],[[567,569],"valid"],[[570,570],"mapped",[11365]],[[571,571],"mapped",[572]],[[572,572],"valid"],[[573,573],"mapped",[410]],[[574,574],"mapped",[11366]],[[575,576],"valid"],[[577,577],"mapped",[578]],[[578,578],"valid"],[[579,579],"mapped",[384]],[[580,580],"mapped",[649]],[[581,581],"mapped",[652]],[[582,582],"mapped",[583]],[[583,583],"valid"],[[584,584],"mapped",[585]],[[585,585],"valid"],[[586,586],"mapped",[587]],[[587,587],"valid"],[[588,588],"mapped",[589]],[[589,589],"valid"],[[590,590],"mapped",[591]],[[591,591],"valid"],[[592,680],"valid"],[[681,685],"valid"],[[686,687],"valid"],[[688,688],"mapped",[104]],[[689,689],"mapped",[614]],[[690,690],"mapped",[106]],[[691,691],"mapped",[114]],[[692,692],"mapped",[633]],[[693,693],"mapped",[635]],[[694,694],"mapped",[641]],[[695,695],"mapped",[119]],[[696,696],"mapped",[121]],[[697,705],"valid"],[[706,709],"valid",[],"NV8"],[[710,721],"valid"],[[722,727],"valid",[],"NV8"],[[728,728],"disallowed_STD3_mapped",[32,774]],[[729,729],"disallowed_STD3_mapped",[32,775]],[[730,730],"disallowed_STD3_mapped",[32,778]],[[731,731],"disallowed_STD3_mapped",[32,808]],[[732,732],"disallowed_STD3_mapped",[32,771]],[[733,733],"disallowed_STD3_mapped",[32,779]],[[734,734],"valid",[],"NV8"],[[735,735],"valid",[],"NV8"],[[736,736],"mapped",[611]],[[737,737],"mapped",[108]],[[738,738],"mapped",[115]],[[739,739],"mapped",[120]],[[740,740],"mapped",[661]],[[741,745],"valid",[],"NV8"],[[746,747],"valid",[],"NV8"],[[748,748],"valid"],[[749,749],"valid",[],"NV8"],[[750,750],"valid"],[[751,767],"valid",[],"NV8"],[[768,831],"valid"],[[832,832],"mapped",[768]],[[833,833],"mapped",[769]],[[834,834],"valid"],[[835,835],"mapped",[787]],[[836,836],"mapped",[776,769]],[[837,837],"mapped",[953]],[[838,846],"valid"],[[847,847],"ignored"],[[848,855],"valid"],[[856,860],"valid"],[[861,863],"valid"],[[864,865],"valid"],[[866,866],"valid"],[[867,879],"valid"],[[880,880],"mapped",[881]],[[881,881],"valid"],[[882,882],"mapped",[883]],[[883,883],"valid"],[[884,884],"mapped",[697]],[[885,885],"valid"],[[886,886],"mapped",[887]],[[887,887],"valid"],[[888,889],"disallowed"],[[890,890],"disallowed_STD3_mapped",[32,953]],[[891,893],"valid"],[[894,894],"disallowed_STD3_mapped",[59]],[[895,895],"mapped",[1011]],[[896,899],"disallowed"],[[900,900],"disallowed_STD3_mapped",[32,769]],[[901,901],"disallowed_STD3_mapped",[32,776,769]],[[902,902],"mapped",[940]],[[903,903],"mapped",[183]],[[904,904],"mapped",[941]],[[905,905],"mapped",[942]],[[906,906],"mapped",[943]],[[907,907],"disallowed"],[[908,908],"mapped",[972]],[[909,909],"disallowed"],[[910,910],"mapped",[973]],[[911,911],"mapped",[974]],[[912,912],"valid"],[[913,913],"mapped",[945]],[[914,914],"mapped",[946]],[[915,915],"mapped",[947]],[[916,916],"mapped",[948]],[[917,917],"mapped",[949]],[[918,918],"mapped",[950]],[[919,919],"mapped",[951]],[[920,920],"mapped",[952]],[[921,921],"mapped",[953]],[[922,922],"mapped",[954]],[[923,923],"mapped",[955]],[[924,924],"mapped",[956]],[[925,925],"mapped",[957]],[[926,926],"mapped",[958]],[[927,927],"mapped",[959]],[[928,928],"mapped",[960]],[[929,929],"mapped",[961]],[[930,930],"disallowed"],[[931,931],"mapped",[963]],[[932,932],"mapped",[964]],[[933,933],"mapped",[965]],[[934,934],"mapped",[966]],[[935,935],"mapped",[967]],[[936,936],"mapped",[968]],[[937,937],"mapped",[969]],[[938,938],"mapped",[970]],[[939,939],"mapped",[971]],[[940,961],"valid"],[[962,962],"deviation",[963]],[[963,974],"valid"],[[975,975],"mapped",[983]],[[976,976],"mapped",[946]],[[977,977],"mapped",[952]],[[978,978],"mapped",[965]],[[979,979],"mapped",[973]],[[980,980],"mapped",[971]],[[981,981],"mapped",[966]],[[982,982],"mapped",[960]],[[983,983],"valid"],[[984,984],"mapped",[985]],[[985,985],"valid"],[[986,986],"mapped",[987]],[[987,987],"valid"],[[988,988],"mapped",[989]],[[989,989],"valid"],[[990,990],"mapped",[991]],[[991,991],"valid"],[[992,992],"mapped",[993]],[[993,993],"valid"],[[994,994],"mapped",[995]],[[995,995],"valid"],[[996,996],"mapped",[997]],[[997,997],"valid"],[[998,998],"mapped",[999]],[[999,999],"valid"],[[1000,1000],"mapped",[1001]],[[1001,1001],"valid"],[[1002,1002],"mapped",[1003]],[[1003,1003],"valid"],[[1004,1004],"mapped",[1005]],[[1005,1005],"valid"],[[1006,1006],"mapped",[1007]],[[1007,1007],"valid"],[[1008,1008],"mapped",[954]],[[1009,1009],"mapped",[961]],[[1010,1010],"mapped",[963]],[[1011,1011],"valid"],[[1012,1012],"mapped",[952]],[[1013,1013],"mapped",[949]],[[1014,1014],"valid",[],"NV8"],[[1015,1015],"mapped",[1016]],[[1016,1016],"valid"],[[1017,1017],"mapped",[963]],[[1018,1018],"mapped",[1019]],[[1019,1019],"valid"],[[1020,1020],"valid"],[[1021,1021],"mapped",[891]],[[1022,1022],"mapped",[892]],[[1023,1023],"mapped",[893]],[[1024,1024],"mapped",[1104]],[[1025,1025],"mapped",[1105]],[[1026,1026],"mapped",[1106]],[[1027,1027],"mapped",[1107]],[[1028,1028],"mapped",[1108]],[[1029,1029],"mapped",[1109]],[[1030,1030],"mapped",[1110]],[[1031,1031],"mapped",[1111]],[[1032,1032],"mapped",[1112]],[[1033,1033],"mapped",[1113]],[[1034,1034],"mapped",[1114]],[[1035,1035],"mapped",[1115]],[[1036,1036],"mapped",[1116]],[[1037,1037],"mapped",[1117]],[[1038,1038],"mapped",[1118]],[[1039,1039],"mapped",[1119]],[[1040,1040],"mapped",[1072]],[[1041,1041],"mapped",[1073]],[[1042,1042],"mapped",[1074]],[[1043,1043],"mapped",[1075]],[[1044,1044],"mapped",[1076]],[[1045,1045],"mapped",[1077]],[[1046,1046],"mapped",[1078]],[[1047,1047],"mapped",[1079]],[[1048,1048],"mapped",[1080]],[[1049,1049],"mapped",[1081]],[[1050,1050],"mapped",[1082]],[[1051,1051],"mapped",[1083]],[[1052,1052],"mapped",[1084]],[[1053,1053],"mapped",[1085]],[[1054,1054],"mapped",[1086]],[[1055,1055],"mapped",[1087]],[[1056,1056],"mapped",[1088]],[[1057,1057],"mapped",[1089]],[[1058,1058],"mapped",[1090]],[[1059,1059],"mapped",[1091]],[[1060,1060],"mapped",[1092]],[[1061,1061],"mapped",[1093]],[[1062,1062],"mapped",[1094]],[[1063,1063],"mapped",[1095]],[[1064,1064],"mapped",[1096]],[[1065,1065],"mapped",[1097]],[[1066,1066],"mapped",[1098]],[[1067,1067],"mapped",[1099]],[[1068,1068],"mapped",[1100]],[[1069,1069],"mapped",[1101]],[[1070,1070],"mapped",[1102]],[[1071,1071],"mapped",[1103]],[[1072,1103],"valid"],[[1104,1104],"valid"],[[1105,1116],"valid"],[[1117,1117],"valid"],[[1118,1119],"valid"],[[1120,1120],"mapped",[1121]],[[1121,1121],"valid"],[[1122,1122],"mapped",[1123]],[[1123,1123],"valid"],[[1124,1124],"mapped",[1125]],[[1125,1125],"valid"],[[1126,1126],"mapped",[1127]],[[1127,1127],"valid"],[[1128,1128],"mapped",[1129]],[[1129,1129],"valid"],[[1130,1130],"mapped",[1131]],[[1131,1131],"valid"],[[1132,1132],"mapped",[1133]],[[1133,1133],"valid"],[[1134,1134],"mapped",[1135]],[[1135,1135],"valid"],[[1136,1136],"mapped",[1137]],[[1137,1137],"valid"],[[1138,1138],"mapped",[1139]],[[1139,1139],"valid"],[[1140,1140],"mapped",[1141]],[[1141,1141],"valid"],[[1142,1142],"mapped",[1143]],[[1143,1143],"valid"],[[1144,1144],"mapped",[1145]],[[1145,1145],"valid"],[[1146,1146],"mapped",[1147]],[[1147,1147],"valid"],[[1148,1148],"mapped",[1149]],[[1149,1149],"valid"],[[1150,1150],"mapped",[1151]],[[1151,1151],"valid"],[[1152,1152],"mapped",[1153]],[[1153,1153],"valid"],[[1154,1154],"valid",[],"NV8"],[[1155,1158],"valid"],[[1159,1159],"valid"],[[1160,1161],"valid",[],"NV8"],[[1162,1162],"mapped",[1163]],[[1163,1163],"valid"],[[1164,1164],"mapped",[1165]],[[1165,1165],"valid"],[[1166,1166],"mapped",[1167]],[[1167,1167],"valid"],[[1168,1168],"mapped",[1169]],[[1169,1169],"valid"],[[1170,1170],"mapped",[1171]],[[1171,1171],"valid"],[[1172,1172],"mapped",[1173]],[[1173,1173],"valid"],[[1174,1174],"mapped",[1175]],[[1175,1175],"valid"],[[1176,1176],"mapped",[1177]],[[1177,1177],"valid"],[[1178,1178],"mapped",[1179]],[[1179,1179],"valid"],[[1180,1180],"mapped",[1181]],[[1181,1181],"valid"],[[1182,1182],"mapped",[1183]],[[1183,1183],"valid"],[[1184,1184],"mapped",[1185]],[[1185,1185],"valid"],[[1186,1186],"mapped",[1187]],[[1187,1187],"valid"],[[1188,1188],"mapped",[1189]],[[1189,1189],"valid"],[[1190,1190],"mapped",[1191]],[[1191,1191],"valid"],[[1192,1192],"mapped",[1193]],[[1193,1193],"valid"],[[1194,1194],"mapped",[1195]],[[1195,1195],"valid"],[[1196,1196],"mapped",[1197]],[[1197,1197],"valid"],[[1198,1198],"mapped",[1199]],[[1199,1199],"valid"],[[1200,1200],"mapped",[1201]],[[1201,1201],"valid"],[[1202,1202],"mapped",[1203]],[[1203,1203],"valid"],[[1204,1204],"mapped",[1205]],[[1205,1205],"valid"],[[1206,1206],"mapped",[1207]],[[1207,1207],"valid"],[[1208,1208],"mapped",[1209]],[[1209,1209],"valid"],[[1210,1210],"mapped",[1211]],[[1211,1211],"valid"],[[1212,1212],"mapped",[1213]],[[1213,1213],"valid"],[[1214,1214],"mapped",[1215]],[[1215,1215],"valid"],[[1216,1216],"disallowed"],[[1217,1217],"mapped",[1218]],[[1218,1218],"valid"],[[1219,1219],"mapped",[1220]],[[1220,1220],"valid"],[[1221,1221],"mapped",[1222]],[[1222,1222],"valid"],[[1223,1223],"mapped",[1224]],[[1224,1224],"valid"],[[1225,1225],"mapped",[1226]],[[1226,1226],"valid"],[[1227,1227],"mapped",[1228]],[[1228,1228],"valid"],[[1229,1229],"mapped",[1230]],[[1230,1230],"valid"],[[1231,1231],"valid"],[[1232,1232],"mapped",[1233]],[[1233,1233],"valid"],[[1234,1234],"mapped",[1235]],[[1235,1235],"valid"],[[1236,1236],"mapped",[1237]],[[1237,1237],"valid"],[[1238,1238],"mapped",[1239]],[[1239,1239],"valid"],[[1240,1240],"mapped",[1241]],[[1241,1241],"valid"],[[1242,1242],"mapped",[1243]],[[1243,1243],"valid"],[[1244,1244],"mapped",[1245]],[[1245,1245],"valid"],[[1246,1246],"mapped",[1247]],[[1247,1247],"valid"],[[1248,1248],"mapped",[1249]],[[1249,1249],"valid"],[[1250,1250],"mapped",[1251]],[[1251,1251],"valid"],[[1252,1252],"mapped",[1253]],[[1253,1253],"valid"],[[1254,1254],"mapped",[1255]],[[1255,1255],"valid"],[[1256,1256],"mapped",[1257]],[[1257,1257],"valid"],[[1258,1258],"mapped",[1259]],[[1259,1259],"valid"],[[1260,1260],"mapped",[1261]],[[1261,1261],"valid"],[[1262,1262],"mapped",[1263]],[[1263,1263],"valid"],[[1264,1264],"mapped",[1265]],[[1265,1265],"valid"],[[1266,1266],"mapped",[1267]],[[1267,1267],"valid"],[[1268,1268],"mapped",[1269]],[[1269,1269],"valid"],[[1270,1270],"mapped",[1271]],[[1271,1271],"valid"],[[1272,1272],"mapped",[1273]],[[1273,1273],"valid"],[[1274,1274],"mapped",[1275]],[[1275,1275],"valid"],[[1276,1276],"mapped",[1277]],[[1277,1277],"valid"],[[1278,1278],"mapped",[1279]],[[1279,1279],"valid"],[[1280,1280],"mapped",[1281]],[[1281,1281],"valid"],[[1282,1282],"mapped",[1283]],[[1283,1283],"valid"],[[1284,1284],"mapped",[1285]],[[1285,1285],"valid"],[[1286,1286],"mapped",[1287]],[[1287,1287],"valid"],[[1288,1288],"mapped",[1289]],[[1289,1289],"valid"],[[1290,1290],"mapped",[1291]],[[1291,1291],"valid"],[[1292,1292],"mapped",[1293]],[[1293,1293],"valid"],[[1294,1294],"mapped",[1295]],[[1295,1295],"valid"],[[1296,1296],"mapped",[1297]],[[1297,1297],"valid"],[[1298,1298],"mapped",[1299]],[[1299,1299],"valid"],[[1300,1300],"mapped",[1301]],[[1301,1301],"valid"],[[1302,1302],"mapped",[1303]],[[1303,1303],"valid"],[[1304,1304],"mapped",[1305]],[[1305,1305],"valid"],[[1306,1306],"mapped",[1307]],[[1307,1307],"valid"],[[1308,1308],"mapped",[1309]],[[1309,1309],"valid"],[[1310,1310],"mapped",[1311]],[[1311,1311],"valid"],[[1312,1312],"mapped",[1313]],[[1313,1313],"valid"],[[1314,1314],"mapped",[1315]],[[1315,1315],"valid"],[[1316,1316],"mapped",[1317]],[[1317,1317],"valid"],[[1318,1318],"mapped",[1319]],[[1319,1319],"valid"],[[1320,1320],"mapped",[1321]],[[1321,1321],"valid"],[[1322,1322],"mapped",[1323]],[[1323,1323],"valid"],[[1324,1324],"mapped",[1325]],[[1325,1325],"valid"],[[1326,1326],"mapped",[1327]],[[1327,1327],"valid"],[[1328,1328],"disallowed"],[[1329,1329],"mapped",[1377]],[[1330,1330],"mapped",[1378]],[[1331,1331],"mapped",[1379]],[[1332,1332],"mapped",[1380]],[[1333,1333],"mapped",[1381]],[[1334,1334],"mapped",[1382]],[[1335,1335],"mapped",[1383]],[[1336,1336],"mapped",[1384]],[[1337,1337],"mapped",[1385]],[[1338,1338],"mapped",[1386]],[[1339,1339],"mapped",[1387]],[[1340,1340],"mapped",[1388]],[[1341,1341],"mapped",[1389]],[[1342,1342],"mapped",[1390]],[[1343,1343],"mapped",[1391]],[[1344,1344],"mapped",[1392]],[[1345,1345],"mapped",[1393]],[[1346,1346],"mapped",[1394]],[[1347,1347],"mapped",[1395]],[[1348,1348],"mapped",[1396]],[[1349,1349],"mapped",[1397]],[[1350,1350],"mapped",[1398]],[[1351,1351],"mapped",[1399]],[[1352,1352],"mapped",[1400]],[[1353,1353],"mapped",[1401]],[[1354,1354],"mapped",[1402]],[[1355,1355],"mapped",[1403]],[[1356,1356],"mapped",[1404]],[[1357,1357],"mapped",[1405]],[[1358,1358],"mapped",[1406]],[[1359,1359],"mapped",[1407]],[[1360,1360],"mapped",[1408]],[[1361,1361],"mapped",[1409]],[[1362,1362],"mapped",[1410]],[[1363,1363],"mapped",[1411]],[[1364,1364],"mapped",[1412]],[[1365,1365],"mapped",[1413]],[[1366,1366],"mapped",[1414]],[[1367,1368],"disallowed"],[[1369,1369],"valid"],[[1370,1375],"valid",[],"NV8"],[[1376,1376],"disallowed"],[[1377,1414],"valid"],[[1415,1415],"mapped",[1381,1410]],[[1416,1416],"disallowed"],[[1417,1417],"valid",[],"NV8"],[[1418,1418],"valid",[],"NV8"],[[1419,1420],"disallowed"],[[1421,1422],"valid",[],"NV8"],[[1423,1423],"valid",[],"NV8"],[[1424,1424],"disallowed"],[[1425,1441],"valid"],[[1442,1442],"valid"],[[1443,1455],"valid"],[[1456,1465],"valid"],[[1466,1466],"valid"],[[1467,1469],"valid"],[[1470,1470],"valid",[],"NV8"],[[1471,1471],"valid"],[[1472,1472],"valid",[],"NV8"],[[1473,1474],"valid"],[[1475,1475],"valid",[],"NV8"],[[1476,1476],"valid"],[[1477,1477],"valid"],[[1478,1478],"valid",[],"NV8"],[[1479,1479],"valid"],[[1480,1487],"disallowed"],[[1488,1514],"valid"],[[1515,1519],"disallowed"],[[1520,1524],"valid"],[[1525,1535],"disallowed"],[[1536,1539],"disallowed"],[[1540,1540],"disallowed"],[[1541,1541],"disallowed"],[[1542,1546],"valid",[],"NV8"],[[1547,1547],"valid",[],"NV8"],[[1548,1548],"valid",[],"NV8"],[[1549,1551],"valid",[],"NV8"],[[1552,1557],"valid"],[[1558,1562],"valid"],[[1563,1563],"valid",[],"NV8"],[[1564,1564],"disallowed"],[[1565,1565],"disallowed"],[[1566,1566],"valid",[],"NV8"],[[1567,1567],"valid",[],"NV8"],[[1568,1568],"valid"],[[1569,1594],"valid"],[[1595,1599],"valid"],[[1600,1600],"valid",[],"NV8"],[[1601,1618],"valid"],[[1619,1621],"valid"],[[1622,1624],"valid"],[[1625,1630],"valid"],[[1631,1631],"valid"],[[1632,1641],"valid"],[[1642,1645],"valid",[],"NV8"],[[1646,1647],"valid"],[[1648,1652],"valid"],[[1653,1653],"mapped",[1575,1652]],[[1654,1654],"mapped",[1608,1652]],[[1655,1655],"mapped",[1735,1652]],[[1656,1656],"mapped",[1610,1652]],[[1657,1719],"valid"],[[1720,1721],"valid"],[[1722,1726],"valid"],[[1727,1727],"valid"],[[1728,1742],"valid"],[[1743,1743],"valid"],[[1744,1747],"valid"],[[1748,1748],"valid",[],"NV8"],[[1749,1756],"valid"],[[1757,1757],"disallowed"],[[1758,1758],"valid",[],"NV8"],[[1759,1768],"valid"],[[1769,1769],"valid",[],"NV8"],[[1770,1773],"valid"],[[1774,1775],"valid"],[[1776,1785],"valid"],[[1786,1790],"valid"],[[1791,1791],"valid"],[[1792,1805],"valid",[],"NV8"],[[1806,1806],"disallowed"],[[1807,1807],"disallowed"],[[1808,1836],"valid"],[[1837,1839],"valid"],[[1840,1866],"valid"],[[1867,1868],"disallowed"],[[1869,1871],"valid"],[[1872,1901],"valid"],[[1902,1919],"valid"],[[1920,1968],"valid"],[[1969,1969],"valid"],[[1970,1983],"disallowed"],[[1984,2037],"valid"],[[2038,2042],"valid",[],"NV8"],[[2043,2047],"disallowed"],[[2048,2093],"valid"],[[2094,2095],"disallowed"],[[2096,2110],"valid",[],"NV8"],[[2111,2111],"disallowed"],[[2112,2139],"valid"],[[2140,2141],"disallowed"],[[2142,2142],"valid",[],"NV8"],[[2143,2207],"disallowed"],[[2208,2208],"valid"],[[2209,2209],"valid"],[[2210,2220],"valid"],[[2221,2226],"valid"],[[2227,2228],"valid"],[[2229,2274],"disallowed"],[[2275,2275],"valid"],[[2276,2302],"valid"],[[2303,2303],"valid"],[[2304,2304],"valid"],[[2305,2307],"valid"],[[2308,2308],"valid"],[[2309,2361],"valid"],[[2362,2363],"valid"],[[2364,2381],"valid"],[[2382,2382],"valid"],[[2383,2383],"valid"],[[2384,2388],"valid"],[[2389,2389],"valid"],[[2390,2391],"valid"],[[2392,2392],"mapped",[2325,2364]],[[2393,2393],"mapped",[2326,2364]],[[2394,2394],"mapped",[2327,2364]],[[2395,2395],"mapped",[2332,2364]],[[2396,2396],"mapped",[2337,2364]],[[2397,2397],"mapped",[2338,2364]],[[2398,2398],"mapped",[2347,2364]],[[2399,2399],"mapped",[2351,2364]],[[2400,2403],"valid"],[[2404,2405],"valid",[],"NV8"],[[2406,2415],"valid"],[[2416,2416],"valid",[],"NV8"],[[2417,2418],"valid"],[[2419,2423],"valid"],[[2424,2424],"valid"],[[2425,2426],"valid"],[[2427,2428],"valid"],[[2429,2429],"valid"],[[2430,2431],"valid"],[[2432,2432],"valid"],[[2433,2435],"valid"],[[2436,2436],"disallowed"],[[2437,2444],"valid"],[[2445,2446],"disallowed"],[[2447,2448],"valid"],[[2449,2450],"disallowed"],[[2451,2472],"valid"],[[2473,2473],"disallowed"],[[2474,2480],"valid"],[[2481,2481],"disallowed"],[[2482,2482],"valid"],[[2483,2485],"disallowed"],[[2486,2489],"valid"],[[2490,2491],"disallowed"],[[2492,2492],"valid"],[[2493,2493],"valid"],[[2494,2500],"valid"],[[2501,2502],"disallowed"],[[2503,2504],"valid"],[[2505,2506],"disallowed"],[[2507,2509],"valid"],[[2510,2510],"valid"],[[2511,2518],"disallowed"],[[2519,2519],"valid"],[[2520,2523],"disallowed"],[[2524,2524],"mapped",[2465,2492]],[[2525,2525],"mapped",[2466,2492]],[[2526,2526],"disallowed"],[[2527,2527],"mapped",[2479,2492]],[[2528,2531],"valid"],[[2532,2533],"disallowed"],[[2534,2545],"valid"],[[2546,2554],"valid",[],"NV8"],[[2555,2555],"valid",[],"NV8"],[[2556,2560],"disallowed"],[[2561,2561],"valid"],[[2562,2562],"valid"],[[2563,2563],"valid"],[[2564,2564],"disallowed"],[[2565,2570],"valid"],[[2571,2574],"disallowed"],[[2575,2576],"valid"],[[2577,2578],"disallowed"],[[2579,2600],"valid"],[[2601,2601],"disallowed"],[[2602,2608],"valid"],[[2609,2609],"disallowed"],[[2610,2610],"valid"],[[2611,2611],"mapped",[2610,2620]],[[2612,2612],"disallowed"],[[2613,2613],"valid"],[[2614,2614],"mapped",[2616,2620]],[[2615,2615],"disallowed"],[[2616,2617],"valid"],[[2618,2619],"disallowed"],[[2620,2620],"valid"],[[2621,2621],"disallowed"],[[2622,2626],"valid"],[[2627,2630],"disallowed"],[[2631,2632],"valid"],[[2633,2634],"disallowed"],[[2635,2637],"valid"],[[2638,2640],"disallowed"],[[2641,2641],"valid"],[[2642,2648],"disallowed"],[[2649,2649],"mapped",[2582,2620]],[[2650,2650],"mapped",[2583,2620]],[[2651,2651],"mapped",[2588,2620]],[[2652,2652],"valid"],[[2653,2653],"disallowed"],[[2654,2654],"mapped",[2603,2620]],[[2655,2661],"disallowed"],[[2662,2676],"valid"],[[2677,2677],"valid"],[[2678,2688],"disallowed"],[[2689,2691],"valid"],[[2692,2692],"disallowed"],[[2693,2699],"valid"],[[2700,2700],"valid"],[[2701,2701],"valid"],[[2702,2702],"disallowed"],[[2703,2705],"valid"],[[2706,2706],"disallowed"],[[2707,2728],"valid"],[[2729,2729],"disallowed"],[[2730,2736],"valid"],[[2737,2737],"disallowed"],[[2738,2739],"valid"],[[2740,2740],"disallowed"],[[2741,2745],"valid"],[[2746,2747],"disallowed"],[[2748,2757],"valid"],[[2758,2758],"disallowed"],[[2759,2761],"valid"],[[2762,2762],"disallowed"],[[2763,2765],"valid"],[[2766,2767],"disallowed"],[[2768,2768],"valid"],[[2769,2783],"disallowed"],[[2784,2784],"valid"],[[2785,2787],"valid"],[[2788,2789],"disallowed"],[[2790,2799],"valid"],[[2800,2800],"valid",[],"NV8"],[[2801,2801],"valid",[],"NV8"],[[2802,2808],"disallowed"],[[2809,2809],"valid"],[[2810,2816],"disallowed"],[[2817,2819],"valid"],[[2820,2820],"disallowed"],[[2821,2828],"valid"],[[2829,2830],"disallowed"],[[2831,2832],"valid"],[[2833,2834],"disallowed"],[[2835,2856],"valid"],[[2857,2857],"disallowed"],[[2858,2864],"valid"],[[2865,2865],"disallowed"],[[2866,2867],"valid"],[[2868,2868],"disallowed"],[[2869,2869],"valid"],[[2870,2873],"valid"],[[2874,2875],"disallowed"],[[2876,2883],"valid"],[[2884,2884],"valid"],[[2885,2886],"disallowed"],[[2887,2888],"valid"],[[2889,2890],"disallowed"],[[2891,2893],"valid"],[[2894,2901],"disallowed"],[[2902,2903],"valid"],[[2904,2907],"disallowed"],[[2908,2908],"mapped",[2849,2876]],[[2909,2909],"mapped",[2850,2876]],[[2910,2910],"disallowed"],[[2911,2913],"valid"],[[2914,2915],"valid"],[[2916,2917],"disallowed"],[[2918,2927],"valid"],[[2928,2928],"valid",[],"NV8"],[[2929,2929],"valid"],[[2930,2935],"valid",[],"NV8"],[[2936,2945],"disallowed"],[[2946,2947],"valid"],[[2948,2948],"disallowed"],[[2949,2954],"valid"],[[2955,2957],"disallowed"],[[2958,2960],"valid"],[[2961,2961],"disallowed"],[[2962,2965],"valid"],[[2966,2968],"disallowed"],[[2969,2970],"valid"],[[2971,2971],"disallowed"],[[2972,2972],"valid"],[[2973,2973],"disallowed"],[[2974,2975],"valid"],[[2976,2978],"disallowed"],[[2979,2980],"valid"],[[2981,2983],"disallowed"],[[2984,2986],"valid"],[[2987,2989],"disallowed"],[[2990,2997],"valid"],[[2998,2998],"valid"],[[2999,3001],"valid"],[[3002,3005],"disallowed"],[[3006,3010],"valid"],[[3011,3013],"disallowed"],[[3014,3016],"valid"],[[3017,3017],"disallowed"],[[3018,3021],"valid"],[[3022,3023],"disallowed"],[[3024,3024],"valid"],[[3025,3030],"disallowed"],[[3031,3031],"valid"],[[3032,3045],"disallowed"],[[3046,3046],"valid"],[[3047,3055],"valid"],[[3056,3058],"valid",[],"NV8"],[[3059,3066],"valid",[],"NV8"],[[3067,3071],"disallowed"],[[3072,3072],"valid"],[[3073,3075],"valid"],[[3076,3076],"disallowed"],[[3077,3084],"valid"],[[3085,3085],"disallowed"],[[3086,3088],"valid"],[[3089,3089],"disallowed"],[[3090,3112],"valid"],[[3113,3113],"disallowed"],[[3114,3123],"valid"],[[3124,3124],"valid"],[[3125,3129],"valid"],[[3130,3132],"disallowed"],[[3133,3133],"valid"],[[3134,3140],"valid"],[[3141,3141],"disallowed"],[[3142,3144],"valid"],[[3145,3145],"disallowed"],[[3146,3149],"valid"],[[3150,3156],"disallowed"],[[3157,3158],"valid"],[[3159,3159],"disallowed"],[[3160,3161],"valid"],[[3162,3162],"valid"],[[3163,3167],"disallowed"],[[3168,3169],"valid"],[[3170,3171],"valid"],[[3172,3173],"disallowed"],[[3174,3183],"valid"],[[3184,3191],"disallowed"],[[3192,3199],"valid",[],"NV8"],[[3200,3200],"disallowed"],[[3201,3201],"valid"],[[3202,3203],"valid"],[[3204,3204],"disallowed"],[[3205,3212],"valid"],[[3213,3213],"disallowed"],[[3214,3216],"valid"],[[3217,3217],"disallowed"],[[3218,3240],"valid"],[[3241,3241],"disallowed"],[[3242,3251],"valid"],[[3252,3252],"disallowed"],[[3253,3257],"valid"],[[3258,3259],"disallowed"],[[3260,3261],"valid"],[[3262,3268],"valid"],[[3269,3269],"disallowed"],[[3270,3272],"valid"],[[3273,3273],"disallowed"],[[3274,3277],"valid"],[[3278,3284],"disallowed"],[[3285,3286],"valid"],[[3287,3293],"disallowed"],[[3294,3294],"valid"],[[3295,3295],"disallowed"],[[3296,3297],"valid"],[[3298,3299],"valid"],[[3300,3301],"disallowed"],[[3302,3311],"valid"],[[3312,3312],"disallowed"],[[3313,3314],"valid"],[[3315,3328],"disallowed"],[[3329,3329],"valid"],[[3330,3331],"valid"],[[3332,3332],"disallowed"],[[3333,3340],"valid"],[[3341,3341],"disallowed"],[[3342,3344],"valid"],[[3345,3345],"disallowed"],[[3346,3368],"valid"],[[3369,3369],"valid"],[[3370,3385],"valid"],[[3386,3386],"valid"],[[3387,3388],"disallowed"],[[3389,3389],"valid"],[[3390,3395],"valid"],[[3396,3396],"valid"],[[3397,3397],"disallowed"],[[3398,3400],"valid"],[[3401,3401],"disallowed"],[[3402,3405],"valid"],[[3406,3406],"valid"],[[3407,3414],"disallowed"],[[3415,3415],"valid"],[[3416,3422],"disallowed"],[[3423,3423],"valid"],[[3424,3425],"valid"],[[3426,3427],"valid"],[[3428,3429],"disallowed"],[[3430,3439],"valid"],[[3440,3445],"valid",[],"NV8"],[[3446,3448],"disallowed"],[[3449,3449],"valid",[],"NV8"],[[3450,3455],"valid"],[[3456,3457],"disallowed"],[[3458,3459],"valid"],[[3460,3460],"disallowed"],[[3461,3478],"valid"],[[3479,3481],"disallowed"],[[3482,3505],"valid"],[[3506,3506],"disallowed"],[[3507,3515],"valid"],[[3516,3516],"disallowed"],[[3517,3517],"valid"],[[3518,3519],"disallowed"],[[3520,3526],"valid"],[[3527,3529],"disallowed"],[[3530,3530],"valid"],[[3531,3534],"disallowed"],[[3535,3540],"valid"],[[3541,3541],"disallowed"],[[3542,3542],"valid"],[[3543,3543],"disallowed"],[[3544,3551],"valid"],[[3552,3557],"disallowed"],[[3558,3567],"valid"],[[3568,3569],"disallowed"],[[3570,3571],"valid"],[[3572,3572],"valid",[],"NV8"],[[3573,3584],"disallowed"],[[3585,3634],"valid"],[[3635,3635],"mapped",[3661,3634]],[[3636,3642],"valid"],[[3643,3646],"disallowed"],[[3647,3647],"valid",[],"NV8"],[[3648,3662],"valid"],[[3663,3663],"valid",[],"NV8"],[[3664,3673],"valid"],[[3674,3675],"valid",[],"NV8"],[[3676,3712],"disallowed"],[[3713,3714],"valid"],[[3715,3715],"disallowed"],[[3716,3716],"valid"],[[3717,3718],"disallowed"],[[3719,3720],"valid"],[[3721,3721],"disallowed"],[[3722,3722],"valid"],[[3723,3724],"disallowed"],[[3725,3725],"valid"],[[3726,3731],"disallowed"],[[3732,3735],"valid"],[[3736,3736],"disallowed"],[[3737,3743],"valid"],[[3744,3744],"disallowed"],[[3745,3747],"valid"],[[3748,3748],"disallowed"],[[3749,3749],"valid"],[[3750,3750],"disallowed"],[[3751,3751],"valid"],[[3752,3753],"disallowed"],[[3754,3755],"valid"],[[3756,3756],"disallowed"],[[3757,3762],"valid"],[[3763,3763],"mapped",[3789,3762]],[[3764,3769],"valid"],[[3770,3770],"disallowed"],[[3771,3773],"valid"],[[3774,3775],"disallowed"],[[3776,3780],"valid"],[[3781,3781],"disallowed"],[[3782,3782],"valid"],[[3783,3783],"disallowed"],[[3784,3789],"valid"],[[3790,3791],"disallowed"],[[3792,3801],"valid"],[[3802,3803],"disallowed"],[[3804,3804],"mapped",[3755,3737]],[[3805,3805],"mapped",[3755,3745]],[[3806,3807],"valid"],[[3808,3839],"disallowed"],[[3840,3840],"valid"],[[3841,3850],"valid",[],"NV8"],[[3851,3851],"valid"],[[3852,3852],"mapped",[3851]],[[3853,3863],"valid",[],"NV8"],[[3864,3865],"valid"],[[3866,3871],"valid",[],"NV8"],[[3872,3881],"valid"],[[3882,3892],"valid",[],"NV8"],[[3893,3893],"valid"],[[3894,3894],"valid",[],"NV8"],[[3895,3895],"valid"],[[3896,3896],"valid",[],"NV8"],[[3897,3897],"valid"],[[3898,3901],"valid",[],"NV8"],[[3902,3906],"valid"],[[3907,3907],"mapped",[3906,4023]],[[3908,3911],"valid"],[[3912,3912],"disallowed"],[[3913,3916],"valid"],[[3917,3917],"mapped",[3916,4023]],[[3918,3921],"valid"],[[3922,3922],"mapped",[3921,4023]],[[3923,3926],"valid"],[[3927,3927],"mapped",[3926,4023]],[[3928,3931],"valid"],[[3932,3932],"mapped",[3931,4023]],[[3933,3944],"valid"],[[3945,3945],"mapped",[3904,4021]],[[3946,3946],"valid"],[[3947,3948],"valid"],[[3949,3952],"disallowed"],[[3953,3954],"valid"],[[3955,3955],"mapped",[3953,3954]],[[3956,3956],"valid"],[[3957,3957],"mapped",[3953,3956]],[[3958,3958],"mapped",[4018,3968]],[[3959,3959],"mapped",[4018,3953,3968]],[[3960,3960],"mapped",[4019,3968]],[[3961,3961],"mapped",[4019,3953,3968]],[[3962,3968],"valid"],[[3969,3969],"mapped",[3953,3968]],[[3970,3972],"valid"],[[3973,3973],"valid",[],"NV8"],[[3974,3979],"valid"],[[3980,3983],"valid"],[[3984,3986],"valid"],[[3987,3987],"mapped",[3986,4023]],[[3988,3989],"valid"],[[3990,3990],"valid"],[[3991,3991],"valid"],[[3992,3992],"disallowed"],[[3993,3996],"valid"],[[3997,3997],"mapped",[3996,4023]],[[3998,4001],"valid"],[[4002,4002],"mapped",[4001,4023]],[[4003,4006],"valid"],[[4007,4007],"mapped",[4006,4023]],[[4008,4011],"valid"],[[4012,4012],"mapped",[4011,4023]],[[4013,4013],"valid"],[[4014,4016],"valid"],[[4017,4023],"valid"],[[4024,4024],"valid"],[[4025,4025],"mapped",[3984,4021]],[[4026,4028],"valid"],[[4029,4029],"disallowed"],[[4030,4037],"valid",[],"NV8"],[[4038,4038],"valid"],[[4039,4044],"valid",[],"NV8"],[[4045,4045],"disallowed"],[[4046,4046],"valid",[],"NV8"],[[4047,4047],"valid",[],"NV8"],[[4048,4049],"valid",[],"NV8"],[[4050,4052],"valid",[],"NV8"],[[4053,4056],"valid",[],"NV8"],[[4057,4058],"valid",[],"NV8"],[[4059,4095],"disallowed"],[[4096,4129],"valid"],[[4130,4130],"valid"],[[4131,4135],"valid"],[[4136,4136],"valid"],[[4137,4138],"valid"],[[4139,4139],"valid"],[[4140,4146],"valid"],[[4147,4149],"valid"],[[4150,4153],"valid"],[[4154,4159],"valid"],[[4160,4169],"valid"],[[4170,4175],"valid",[],"NV8"],[[4176,4185],"valid"],[[4186,4249],"valid"],[[4250,4253],"valid"],[[4254,4255],"valid",[],"NV8"],[[4256,4293],"disallowed"],[[4294,4294],"disallowed"],[[4295,4295],"mapped",[11559]],[[4296,4300],"disallowed"],[[4301,4301],"mapped",[11565]],[[4302,4303],"disallowed"],[[4304,4342],"valid"],[[4343,4344],"valid"],[[4345,4346],"valid"],[[4347,4347],"valid",[],"NV8"],[[4348,4348],"mapped",[4316]],[[4349,4351],"valid"],[[4352,4441],"valid",[],"NV8"],[[4442,4446],"valid",[],"NV8"],[[4447,4448],"disallowed"],[[4449,4514],"valid",[],"NV8"],[[4515,4519],"valid",[],"NV8"],[[4520,4601],"valid",[],"NV8"],[[4602,4607],"valid",[],"NV8"],[[4608,4614],"valid"],[[4615,4615],"valid"],[[4616,4678],"valid"],[[4679,4679],"valid"],[[4680,4680],"valid"],[[4681,4681],"disallowed"],[[4682,4685],"valid"],[[4686,4687],"disallowed"],[[4688,4694],"valid"],[[4695,4695],"disallowed"],[[4696,4696],"valid"],[[4697,4697],"disallowed"],[[4698,4701],"valid"],[[4702,4703],"disallowed"],[[4704,4742],"valid"],[[4743,4743],"valid"],[[4744,4744],"valid"],[[4745,4745],"disallowed"],[[4746,4749],"valid"],[[4750,4751],"disallowed"],[[4752,4782],"valid"],[[4783,4783],"valid"],[[4784,4784],"valid"],[[4785,4785],"disallowed"],[[4786,4789],"valid"],[[4790,4791],"disallowed"],[[4792,4798],"valid"],[[4799,4799],"disallowed"],[[4800,4800],"valid"],[[4801,4801],"disallowed"],[[4802,4805],"valid"],[[4806,4807],"disallowed"],[[4808,4814],"valid"],[[4815,4815],"valid"],[[4816,4822],"valid"],[[4823,4823],"disallowed"],[[4824,4846],"valid"],[[4847,4847],"valid"],[[4848,4878],"valid"],[[4879,4879],"valid"],[[4880,4880],"valid"],[[4881,4881],"disallowed"],[[4882,4885],"valid"],[[4886,4887],"disallowed"],[[4888,4894],"valid"],[[4895,4895],"valid"],[[4896,4934],"valid"],[[4935,4935],"valid"],[[4936,4954],"valid"],[[4955,4956],"disallowed"],[[4957,4958],"valid"],[[4959,4959],"valid"],[[4960,4960],"valid",[],"NV8"],[[4961,4988],"valid",[],"NV8"],[[4989,4991],"disallowed"],[[4992,5007],"valid"],[[5008,5017],"valid",[],"NV8"],[[5018,5023],"disallowed"],[[5024,5108],"valid"],[[5109,5109],"valid"],[[5110,5111],"disallowed"],[[5112,5112],"mapped",[5104]],[[5113,5113],"mapped",[5105]],[[5114,5114],"mapped",[5106]],[[5115,5115],"mapped",[5107]],[[5116,5116],"mapped",[5108]],[[5117,5117],"mapped",[5109]],[[5118,5119],"disallowed"],[[5120,5120],"valid",[],"NV8"],[[5121,5740],"valid"],[[5741,5742],"valid",[],"NV8"],[[5743,5750],"valid"],[[5751,5759],"valid"],[[5760,5760],"disallowed"],[[5761,5786],"valid"],[[5787,5788],"valid",[],"NV8"],[[5789,5791],"disallowed"],[[5792,5866],"valid"],[[5867,5872],"valid",[],"NV8"],[[5873,5880],"valid"],[[5881,5887],"disallowed"],[[5888,5900],"valid"],[[5901,5901],"disallowed"],[[5902,5908],"valid"],[[5909,5919],"disallowed"],[[5920,5940],"valid"],[[5941,5942],"valid",[],"NV8"],[[5943,5951],"disallowed"],[[5952,5971],"valid"],[[5972,5983],"disallowed"],[[5984,5996],"valid"],[[5997,5997],"disallowed"],[[5998,6000],"valid"],[[6001,6001],"disallowed"],[[6002,6003],"valid"],[[6004,6015],"disallowed"],[[6016,6067],"valid"],[[6068,6069],"disallowed"],[[6070,6099],"valid"],[[6100,6102],"valid",[],"NV8"],[[6103,6103],"valid"],[[6104,6107],"valid",[],"NV8"],[[6108,6108],"valid"],[[6109,6109],"valid"],[[6110,6111],"disallowed"],[[6112,6121],"valid"],[[6122,6127],"disallowed"],[[6128,6137],"valid",[],"NV8"],[[6138,6143],"disallowed"],[[6144,6149],"valid",[],"NV8"],[[6150,6150],"disallowed"],[[6151,6154],"valid",[],"NV8"],[[6155,6157],"ignored"],[[6158,6158],"disallowed"],[[6159,6159],"disallowed"],[[6160,6169],"valid"],[[6170,6175],"disallowed"],[[6176,6263],"valid"],[[6264,6271],"disallowed"],[[6272,6313],"valid"],[[6314,6314],"valid"],[[6315,6319],"disallowed"],[[6320,6389],"valid"],[[6390,6399],"disallowed"],[[6400,6428],"valid"],[[6429,6430],"valid"],[[6431,6431],"disallowed"],[[6432,6443],"valid"],[[6444,6447],"disallowed"],[[6448,6459],"valid"],[[6460,6463],"disallowed"],[[6464,6464],"valid",[],"NV8"],[[6465,6467],"disallowed"],[[6468,6469],"valid",[],"NV8"],[[6470,6509],"valid"],[[6510,6511],"disallowed"],[[6512,6516],"valid"],[[6517,6527],"disallowed"],[[6528,6569],"valid"],[[6570,6571],"valid"],[[6572,6575],"disallowed"],[[6576,6601],"valid"],[[6602,6607],"disallowed"],[[6608,6617],"valid"],[[6618,6618],"valid",[],"XV8"],[[6619,6621],"disallowed"],[[6622,6623],"valid",[],"NV8"],[[6624,6655],"valid",[],"NV8"],[[6656,6683],"valid"],[[6684,6685],"disallowed"],[[6686,6687],"valid",[],"NV8"],[[6688,6750],"valid"],[[6751,6751],"disallowed"],[[6752,6780],"valid"],[[6781,6782],"disallowed"],[[6783,6793],"valid"],[[6794,6799],"disallowed"],[[6800,6809],"valid"],[[6810,6815],"disallowed"],[[6816,6822],"valid",[],"NV8"],[[6823,6823],"valid"],[[6824,6829],"valid",[],"NV8"],[[6830,6831],"disallowed"],[[6832,6845],"valid"],[[6846,6846],"valid",[],"NV8"],[[6847,6911],"disallowed"],[[6912,6987],"valid"],[[6988,6991],"disallowed"],[[6992,7001],"valid"],[[7002,7018],"valid",[],"NV8"],[[7019,7027],"valid"],[[7028,7036],"valid",[],"NV8"],[[7037,7039],"disallowed"],[[7040,7082],"valid"],[[7083,7085],"valid"],[[7086,7097],"valid"],[[7098,7103],"valid"],[[7104,7155],"valid"],[[7156,7163],"disallowed"],[[7164,7167],"valid",[],"NV8"],[[7168,7223],"valid"],[[7224,7226],"disallowed"],[[7227,7231],"valid",[],"NV8"],[[7232,7241],"valid"],[[7242,7244],"disallowed"],[[7245,7293],"valid"],[[7294,7295],"valid",[],"NV8"],[[7296,7359],"disallowed"],[[7360,7367],"valid",[],"NV8"],[[7368,7375],"disallowed"],[[7376,7378],"valid"],[[7379,7379],"valid",[],"NV8"],[[7380,7410],"valid"],[[7411,7414],"valid"],[[7415,7415],"disallowed"],[[7416,7417],"valid"],[[7418,7423],"disallowed"],[[7424,7467],"valid"],[[7468,7468],"mapped",[97]],[[7469,7469],"mapped",[230]],[[7470,7470],"mapped",[98]],[[7471,7471],"valid"],[[7472,7472],"mapped",[100]],[[7473,7473],"mapped",[101]],[[7474,7474],"mapped",[477]],[[7475,7475],"mapped",[103]],[[7476,7476],"mapped",[104]],[[7477,7477],"mapped",[105]],[[7478,7478],"mapped",[106]],[[7479,7479],"mapped",[107]],[[7480,7480],"mapped",[108]],[[7481,7481],"mapped",[109]],[[7482,7482],"mapped",[110]],[[7483,7483],"valid"],[[7484,7484],"mapped",[111]],[[7485,7485],"mapped",[547]],[[7486,7486],"mapped",[112]],[[7487,7487],"mapped",[114]],[[7488,7488],"mapped",[116]],[[7489,7489],"mapped",[117]],[[7490,7490],"mapped",[119]],[[7491,7491],"mapped",[97]],[[7492,7492],"mapped",[592]],[[7493,7493],"mapped",[593]],[[7494,7494],"mapped",[7426]],[[7495,7495],"mapped",[98]],[[7496,7496],"mapped",[100]],[[7497,7497],"mapped",[101]],[[7498,7498],"mapped",[601]],[[7499,7499],"mapped",[603]],[[7500,7500],"mapped",[604]],[[7501,7501],"mapped",[103]],[[7502,7502],"valid"],[[7503,7503],"mapped",[107]],[[7504,7504],"mapped",[109]],[[7505,7505],"mapped",[331]],[[7506,7506],"mapped",[111]],[[7507,7507],"mapped",[596]],[[7508,7508],"mapped",[7446]],[[7509,7509],"mapped",[7447]],[[7510,7510],"mapped",[112]],[[7511,7511],"mapped",[116]],[[7512,7512],"mapped",[117]],[[7513,7513],"mapped",[7453]],[[7514,7514],"mapped",[623]],[[7515,7515],"mapped",[118]],[[7516,7516],"mapped",[7461]],[[7517,7517],"mapped",[946]],[[7518,7518],"mapped",[947]],[[7519,7519],"mapped",[948]],[[7520,7520],"mapped",[966]],[[7521,7521],"mapped",[967]],[[7522,7522],"mapped",[105]],[[7523,7523],"mapped",[114]],[[7524,7524],"mapped",[117]],[[7525,7525],"mapped",[118]],[[7526,7526],"mapped",[946]],[[7527,7527],"mapped",[947]],[[7528,7528],"mapped",[961]],[[7529,7529],"mapped",[966]],[[7530,7530],"mapped",[967]],[[7531,7531],"valid"],[[7532,7543],"valid"],[[7544,7544],"mapped",[1085]],[[7545,7578],"valid"],[[7579,7579],"mapped",[594]],[[7580,7580],"mapped",[99]],[[7581,7581],"mapped",[597]],[[7582,7582],"mapped",[240]],[[7583,7583],"mapped",[604]],[[7584,7584],"mapped",[102]],[[7585,7585],"mapped",[607]],[[7586,7586],"mapped",[609]],[[7587,7587],"mapped",[613]],[[7588,7588],"mapped",[616]],[[7589,7589],"mapped",[617]],[[7590,7590],"mapped",[618]],[[7591,7591],"mapped",[7547]],[[7592,7592],"mapped",[669]],[[7593,7593],"mapped",[621]],[[7594,7594],"mapped",[7557]],[[7595,7595],"mapped",[671]],[[7596,7596],"mapped",[625]],[[7597,7597],"mapped",[624]],[[7598,7598],"mapped",[626]],[[7599,7599],"mapped",[627]],[[7600,7600],"mapped",[628]],[[7601,7601],"mapped",[629]],[[7602,7602],"mapped",[632]],[[7603,7603],"mapped",[642]],[[7604,7604],"mapped",[643]],[[7605,7605],"mapped",[427]],[[7606,7606],"mapped",[649]],[[7607,7607],"mapped",[650]],[[7608,7608],"mapped",[7452]],[[7609,7609],"mapped",[651]],[[7610,7610],"mapped",[652]],[[7611,7611],"mapped",[122]],[[7612,7612],"mapped",[656]],[[7613,7613],"mapped",[657]],[[7614,7614],"mapped",[658]],[[7615,7615],"mapped",[952]],[[7616,7619],"valid"],[[7620,7626],"valid"],[[7627,7654],"valid"],[[7655,7669],"valid"],[[7670,7675],"disallowed"],[[7676,7676],"valid"],[[7677,7677],"valid"],[[7678,7679],"valid"],[[7680,7680],"mapped",[7681]],[[7681,7681],"valid"],[[7682,7682],"mapped",[7683]],[[7683,7683],"valid"],[[7684,7684],"mapped",[7685]],[[7685,7685],"valid"],[[7686,7686],"mapped",[7687]],[[7687,7687],"valid"],[[7688,7688],"mapped",[7689]],[[7689,7689],"valid"],[[7690,7690],"mapped",[7691]],[[7691,7691],"valid"],[[7692,7692],"mapped",[7693]],[[7693,7693],"valid"],[[7694,7694],"mapped",[7695]],[[7695,7695],"valid"],[[7696,7696],"mapped",[7697]],[[7697,7697],"valid"],[[7698,7698],"mapped",[7699]],[[7699,7699],"valid"],[[7700,7700],"mapped",[7701]],[[7701,7701],"valid"],[[7702,7702],"mapped",[7703]],[[7703,7703],"valid"],[[7704,7704],"mapped",[7705]],[[7705,7705],"valid"],[[7706,7706],"mapped",[7707]],[[7707,7707],"valid"],[[7708,7708],"mapped",[7709]],[[7709,7709],"valid"],[[7710,7710],"mapped",[7711]],[[7711,7711],"valid"],[[7712,7712],"mapped",[7713]],[[7713,7713],"valid"],[[7714,7714],"mapped",[7715]],[[7715,7715],"valid"],[[7716,7716],"mapped",[7717]],[[7717,7717],"valid"],[[7718,7718],"mapped",[7719]],[[7719,7719],"valid"],[[7720,7720],"mapped",[7721]],[[7721,7721],"valid"],[[7722,7722],"mapped",[7723]],[[7723,7723],"valid"],[[7724,7724],"mapped",[7725]],[[7725,7725],"valid"],[[7726,7726],"mapped",[7727]],[[7727,7727],"valid"],[[7728,7728],"mapped",[7729]],[[7729,7729],"valid"],[[7730,7730],"mapped",[7731]],[[7731,7731],"valid"],[[7732,7732],"mapped",[7733]],[[7733,7733],"valid"],[[7734,7734],"mapped",[7735]],[[7735,7735],"valid"],[[7736,7736],"mapped",[7737]],[[7737,7737],"valid"],[[7738,7738],"mapped",[7739]],[[7739,7739],"valid"],[[7740,7740],"mapped",[7741]],[[7741,7741],"valid"],[[7742,7742],"mapped",[7743]],[[7743,7743],"valid"],[[7744,7744],"mapped",[7745]],[[7745,7745],"valid"],[[7746,7746],"mapped",[7747]],[[7747,7747],"valid"],[[7748,7748],"mapped",[7749]],[[7749,7749],"valid"],[[7750,7750],"mapped",[7751]],[[7751,7751],"valid"],[[7752,7752],"mapped",[7753]],[[7753,7753],"valid"],[[7754,7754],"mapped",[7755]],[[7755,7755],"valid"],[[7756,7756],"mapped",[7757]],[[7757,7757],"valid"],[[7758,7758],"mapped",[7759]],[[7759,7759],"valid"],[[7760,7760],"mapped",[7761]],[[7761,7761],"valid"],[[7762,7762],"mapped",[7763]],[[7763,7763],"valid"],[[7764,7764],"mapped",[7765]],[[7765,7765],"valid"],[[7766,7766],"mapped",[7767]],[[7767,7767],"valid"],[[7768,7768],"mapped",[7769]],[[7769,7769],"valid"],[[7770,7770],"mapped",[7771]],[[7771,7771],"valid"],[[7772,7772],"mapped",[7773]],[[7773,7773],"valid"],[[7774,7774],"mapped",[7775]],[[7775,7775],"valid"],[[7776,7776],"mapped",[7777]],[[7777,7777],"valid"],[[7778,7778],"mapped",[7779]],[[7779,7779],"valid"],[[7780,7780],"mapped",[7781]],[[7781,7781],"valid"],[[7782,7782],"mapped",[7783]],[[7783,7783],"valid"],[[7784,7784],"mapped",[7785]],[[7785,7785],"valid"],[[7786,7786],"mapped",[7787]],[[7787,7787],"valid"],[[7788,7788],"mapped",[7789]],[[7789,7789],"valid"],[[7790,7790],"mapped",[7791]],[[7791,7791],"valid"],[[7792,7792],"mapped",[7793]],[[7793,7793],"valid"],[[7794,7794],"mapped",[7795]],[[7795,7795],"valid"],[[7796,7796],"mapped",[7797]],[[7797,7797],"valid"],[[7798,7798],"mapped",[7799]],[[7799,7799],"valid"],[[7800,7800],"mapped",[7801]],[[7801,7801],"valid"],[[7802,7802],"mapped",[7803]],[[7803,7803],"valid"],[[7804,7804],"mapped",[7805]],[[7805,7805],"valid"],[[7806,7806],"mapped",[7807]],[[7807,7807],"valid"],[[7808,7808],"mapped",[7809]],[[7809,7809],"valid"],[[7810,7810],"mapped",[7811]],[[7811,7811],"valid"],[[7812,7812],"mapped",[7813]],[[7813,7813],"valid"],[[7814,7814],"mapped",[7815]],[[7815,7815],"valid"],[[7816,7816],"mapped",[7817]],[[7817,7817],"valid"],[[7818,7818],"mapped",[7819]],[[7819,7819],"valid"],[[7820,7820],"mapped",[7821]],[[7821,7821],"valid"],[[7822,7822],"mapped",[7823]],[[7823,7823],"valid"],[[7824,7824],"mapped",[7825]],[[7825,7825],"valid"],[[7826,7826],"mapped",[7827]],[[7827,7827],"valid"],[[7828,7828],"mapped",[7829]],[[7829,7833],"valid"],[[7834,7834],"mapped",[97,702]],[[7835,7835],"mapped",[7777]],[[7836,7837],"valid"],[[7838,7838],"mapped",[115,115]],[[7839,7839],"valid"],[[7840,7840],"mapped",[7841]],[[7841,7841],"valid"],[[7842,7842],"mapped",[7843]],[[7843,7843],"valid"],[[7844,7844],"mapped",[7845]],[[7845,7845],"valid"],[[7846,7846],"mapped",[7847]],[[7847,7847],"valid"],[[7848,7848],"mapped",[7849]],[[7849,7849],"valid"],[[7850,7850],"mapped",[7851]],[[7851,7851],"valid"],[[7852,7852],"mapped",[7853]],[[7853,7853],"valid"],[[7854,7854],"mapped",[7855]],[[7855,7855],"valid"],[[7856,7856],"mapped",[7857]],[[7857,7857],"valid"],[[7858,7858],"mapped",[7859]],[[7859,7859],"valid"],[[7860,7860],"mapped",[7861]],[[7861,7861],"valid"],[[7862,7862],"mapped",[7863]],[[7863,7863],"valid"],[[7864,7864],"mapped",[7865]],[[7865,7865],"valid"],[[7866,7866],"mapped",[7867]],[[7867,7867],"valid"],[[7868,7868],"mapped",[7869]],[[7869,7869],"valid"],[[7870,7870],"mapped",[7871]],[[7871,7871],"valid"],[[7872,7872],"mapped",[7873]],[[7873,7873],"valid"],[[7874,7874],"mapped",[7875]],[[7875,7875],"valid"],[[7876,7876],"mapped",[7877]],[[7877,7877],"valid"],[[7878,7878],"mapped",[7879]],[[7879,7879],"valid"],[[7880,7880],"mapped",[7881]],[[7881,7881],"valid"],[[7882,7882],"mapped",[7883]],[[7883,7883],"valid"],[[7884,7884],"mapped",[7885]],[[7885,7885],"valid"],[[7886,7886],"mapped",[7887]],[[7887,7887],"valid"],[[7888,7888],"mapped",[7889]],[[7889,7889],"valid"],[[7890,7890],"mapped",[7891]],[[7891,7891],"valid"],[[7892,7892],"mapped",[7893]],[[7893,7893],"valid"],[[7894,7894],"mapped",[7895]],[[7895,7895],"valid"],[[7896,7896],"mapped",[7897]],[[7897,7897],"valid"],[[7898,7898],"mapped",[7899]],[[7899,7899],"valid"],[[7900,7900],"mapped",[7901]],[[7901,7901],"valid"],[[7902,7902],"mapped",[7903]],[[7903,7903],"valid"],[[7904,7904],"mapped",[7905]],[[7905,7905],"valid"],[[7906,7906],"mapped",[7907]],[[7907,7907],"valid"],[[7908,7908],"mapped",[7909]],[[7909,7909],"valid"],[[7910,7910],"mapped",[7911]],[[7911,7911],"valid"],[[7912,7912],"mapped",[7913]],[[7913,7913],"valid"],[[7914,7914],"mapped",[7915]],[[7915,7915],"valid"],[[7916,7916],"mapped",[7917]],[[7917,7917],"valid"],[[7918,7918],"mapped",[7919]],[[7919,7919],"valid"],[[7920,7920],"mapped",[7921]],[[7921,7921],"valid"],[[7922,7922],"mapped",[7923]],[[7923,7923],"valid"],[[7924,7924],"mapped",[7925]],[[7925,7925],"valid"],[[7926,7926],"mapped",[7927]],[[7927,7927],"valid"],[[7928,7928],"mapped",[7929]],[[7929,7929],"valid"],[[7930,7930],"mapped",[7931]],[[7931,7931],"valid"],[[7932,7932],"mapped",[7933]],[[7933,7933],"valid"],[[7934,7934],"mapped",[7935]],[[7935,7935],"valid"],[[7936,7943],"valid"],[[7944,7944],"mapped",[7936]],[[7945,7945],"mapped",[7937]],[[7946,7946],"mapped",[7938]],[[7947,7947],"mapped",[7939]],[[7948,7948],"mapped",[7940]],[[7949,7949],"mapped",[7941]],[[7950,7950],"mapped",[7942]],[[7951,7951],"mapped",[7943]],[[7952,7957],"valid"],[[7958,7959],"disallowed"],[[7960,7960],"mapped",[7952]],[[7961,7961],"mapped",[7953]],[[7962,7962],"mapped",[7954]],[[7963,7963],"mapped",[7955]],[[7964,7964],"mapped",[7956]],[[7965,7965],"mapped",[7957]],[[7966,7967],"disallowed"],[[7968,7975],"valid"],[[7976,7976],"mapped",[7968]],[[7977,7977],"mapped",[7969]],[[7978,7978],"mapped",[7970]],[[7979,7979],"mapped",[7971]],[[7980,7980],"mapped",[7972]],[[7981,7981],"mapped",[7973]],[[7982,7982],"mapped",[7974]],[[7983,7983],"mapped",[7975]],[[7984,7991],"valid"],[[7992,7992],"mapped",[7984]],[[7993,7993],"mapped",[7985]],[[7994,7994],"mapped",[7986]],[[7995,7995],"mapped",[7987]],[[7996,7996],"mapped",[7988]],[[7997,7997],"mapped",[7989]],[[7998,7998],"mapped",[7990]],[[7999,7999],"mapped",[7991]],[[8000,8005],"valid"],[[8006,8007],"disallowed"],[[8008,8008],"mapped",[8000]],[[8009,8009],"mapped",[8001]],[[8010,8010],"mapped",[8002]],[[8011,8011],"mapped",[8003]],[[8012,8012],"mapped",[8004]],[[8013,8013],"mapped",[8005]],[[8014,8015],"disallowed"],[[8016,8023],"valid"],[[8024,8024],"disallowed"],[[8025,8025],"mapped",[8017]],[[8026,8026],"disallowed"],[[8027,8027],"mapped",[8019]],[[8028,8028],"disallowed"],[[8029,8029],"mapped",[8021]],[[8030,8030],"disallowed"],[[8031,8031],"mapped",[8023]],[[8032,8039],"valid"],[[8040,8040],"mapped",[8032]],[[8041,8041],"mapped",[8033]],[[8042,8042],"mapped",[8034]],[[8043,8043],"mapped",[8035]],[[8044,8044],"mapped",[8036]],[[8045,8045],"mapped",[8037]],[[8046,8046],"mapped",[8038]],[[8047,8047],"mapped",[8039]],[[8048,8048],"valid"],[[8049,8049],"mapped",[940]],[[8050,8050],"valid"],[[8051,8051],"mapped",[941]],[[8052,8052],"valid"],[[8053,8053],"mapped",[942]],[[8054,8054],"valid"],[[8055,8055],"mapped",[943]],[[8056,8056],"valid"],[[8057,8057],"mapped",[972]],[[8058,8058],"valid"],[[8059,8059],"mapped",[973]],[[8060,8060],"valid"],[[8061,8061],"mapped",[974]],[[8062,8063],"disallowed"],[[8064,8064],"mapped",[7936,953]],[[8065,8065],"mapped",[7937,953]],[[8066,8066],"mapped",[7938,953]],[[8067,8067],"mapped",[7939,953]],[[8068,8068],"mapped",[7940,953]],[[8069,8069],"mapped",[7941,953]],[[8070,8070],"mapped",[7942,953]],[[8071,8071],"mapped",[7943,953]],[[8072,8072],"mapped",[7936,953]],[[8073,8073],"mapped",[7937,953]],[[8074,8074],"mapped",[7938,953]],[[8075,8075],"mapped",[7939,953]],[[8076,8076],"mapped",[7940,953]],[[8077,8077],"mapped",[7941,953]],[[8078,8078],"mapped",[7942,953]],[[8079,8079],"mapped",[7943,953]],[[8080,8080],"mapped",[7968,953]],[[8081,8081],"mapped",[7969,953]],[[8082,8082],"mapped",[7970,953]],[[8083,8083],"mapped",[7971,953]],[[8084,8084],"mapped",[7972,953]],[[8085,8085],"mapped",[7973,953]],[[8086,8086],"mapped",[7974,953]],[[8087,8087],"mapped",[7975,953]],[[8088,8088],"mapped",[7968,953]],[[8089,8089],"mapped",[7969,953]],[[8090,8090],"mapped",[7970,953]],[[8091,8091],"mapped",[7971,953]],[[8092,8092],"mapped",[7972,953]],[[8093,8093],"mapped",[7973,953]],[[8094,8094],"mapped",[7974,953]],[[8095,8095],"mapped",[7975,953]],[[8096,8096],"mapped",[8032,953]],[[8097,8097],"mapped",[8033,953]],[[8098,8098],"mapped",[8034,953]],[[8099,8099],"mapped",[8035,953]],[[8100,8100],"mapped",[8036,953]],[[8101,8101],"mapped",[8037,953]],[[8102,8102],"mapped",[8038,953]],[[8103,8103],"mapped",[8039,953]],[[8104,8104],"mapped",[8032,953]],[[8105,8105],"mapped",[8033,953]],[[8106,8106],"mapped",[8034,953]],[[8107,8107],"mapped",[8035,953]],[[8108,8108],"mapped",[8036,953]],[[8109,8109],"mapped",[8037,953]],[[8110,8110],"mapped",[8038,953]],[[8111,8111],"mapped",[8039,953]],[[8112,8113],"valid"],[[8114,8114],"mapped",[8048,953]],[[8115,8115],"mapped",[945,953]],[[8116,8116],"mapped",[940,953]],[[8117,8117],"disallowed"],[[8118,8118],"valid"],[[8119,8119],"mapped",[8118,953]],[[8120,8120],"mapped",[8112]],[[8121,8121],"mapped",[8113]],[[8122,8122],"mapped",[8048]],[[8123,8123],"mapped",[940]],[[8124,8124],"mapped",[945,953]],[[8125,8125],"disallowed_STD3_mapped",[32,787]],[[8126,8126],"mapped",[953]],[[8127,8127],"disallowed_STD3_mapped",[32,787]],[[8128,8128],"disallowed_STD3_mapped",[32,834]],[[8129,8129],"disallowed_STD3_mapped",[32,776,834]],[[8130,8130],"mapped",[8052,953]],[[8131,8131],"mapped",[951,953]],[[8132,8132],"mapped",[942,953]],[[8133,8133],"disallowed"],[[8134,8134],"valid"],[[8135,8135],"mapped",[8134,953]],[[8136,8136],"mapped",[8050]],[[8137,8137],"mapped",[941]],[[8138,8138],"mapped",[8052]],[[8139,8139],"mapped",[942]],[[8140,8140],"mapped",[951,953]],[[8141,8141],"disallowed_STD3_mapped",[32,787,768]],[[8142,8142],"disallowed_STD3_mapped",[32,787,769]],[[8143,8143],"disallowed_STD3_mapped",[32,787,834]],[[8144,8146],"valid"],[[8147,8147],"mapped",[912]],[[8148,8149],"disallowed"],[[8150,8151],"valid"],[[8152,8152],"mapped",[8144]],[[8153,8153],"mapped",[8145]],[[8154,8154],"mapped",[8054]],[[8155,8155],"mapped",[943]],[[8156,8156],"disallowed"],[[8157,8157],"disallowed_STD3_mapped",[32,788,768]],[[8158,8158],"disallowed_STD3_mapped",[32,788,769]],[[8159,8159],"disallowed_STD3_mapped",[32,788,834]],[[8160,8162],"valid"],[[8163,8163],"mapped",[944]],[[8164,8167],"valid"],[[8168,8168],"mapped",[8160]],[[8169,8169],"mapped",[8161]],[[8170,8170],"mapped",[8058]],[[8171,8171],"mapped",[973]],[[8172,8172],"mapped",[8165]],[[8173,8173],"disallowed_STD3_mapped",[32,776,768]],[[8174,8174],"disallowed_STD3_mapped",[32,776,769]],[[8175,8175],"disallowed_STD3_mapped",[96]],[[8176,8177],"disallowed"],[[8178,8178],"mapped",[8060,953]],[[8179,8179],"mapped",[969,953]],[[8180,8180],"mapped",[974,953]],[[8181,8181],"disallowed"],[[8182,8182],"valid"],[[8183,8183],"mapped",[8182,953]],[[8184,8184],"mapped",[8056]],[[8185,8185],"mapped",[972]],[[8186,8186],"mapped",[8060]],[[8187,8187],"mapped",[974]],[[8188,8188],"mapped",[969,953]],[[8189,8189],"disallowed_STD3_mapped",[32,769]],[[8190,8190],"disallowed_STD3_mapped",[32,788]],[[8191,8191],"disallowed"],[[8192,8202],"disallowed_STD3_mapped",[32]],[[8203,8203],"ignored"],[[8204,8205],"deviation",[]],[[8206,8207],"disallowed"],[[8208,8208],"valid",[],"NV8"],[[8209,8209],"mapped",[8208]],[[8210,8214],"valid",[],"NV8"],[[8215,8215],"disallowed_STD3_mapped",[32,819]],[[8216,8227],"valid",[],"NV8"],[[8228,8230],"disallowed"],[[8231,8231],"valid",[],"NV8"],[[8232,8238],"disallowed"],[[8239,8239],"disallowed_STD3_mapped",[32]],[[8240,8242],"valid",[],"NV8"],[[8243,8243],"mapped",[8242,8242]],[[8244,8244],"mapped",[8242,8242,8242]],[[8245,8245],"valid",[],"NV8"],[[8246,8246],"mapped",[8245,8245]],[[8247,8247],"mapped",[8245,8245,8245]],[[8248,8251],"valid",[],"NV8"],[[8252,8252],"disallowed_STD3_mapped",[33,33]],[[8253,8253],"valid",[],"NV8"],[[8254,8254],"disallowed_STD3_mapped",[32,773]],[[8255,8262],"valid",[],"NV8"],[[8263,8263],"disallowed_STD3_mapped",[63,63]],[[8264,8264],"disallowed_STD3_mapped",[63,33]],[[8265,8265],"disallowed_STD3_mapped",[33,63]],[[8266,8269],"valid",[],"NV8"],[[8270,8274],"valid",[],"NV8"],[[8275,8276],"valid",[],"NV8"],[[8277,8278],"valid",[],"NV8"],[[8279,8279],"mapped",[8242,8242,8242,8242]],[[8280,8286],"valid",[],"NV8"],[[8287,8287],"disallowed_STD3_mapped",[32]],[[8288,8288],"ignored"],[[8289,8291],"disallowed"],[[8292,8292],"ignored"],[[8293,8293],"disallowed"],[[8294,8297],"disallowed"],[[8298,8303],"disallowed"],[[8304,8304],"mapped",[48]],[[8305,8305],"mapped",[105]],[[8306,8307],"disallowed"],[[8308,8308],"mapped",[52]],[[8309,8309],"mapped",[53]],[[8310,8310],"mapped",[54]],[[8311,8311],"mapped",[55]],[[8312,8312],"mapped",[56]],[[8313,8313],"mapped",[57]],[[8314,8314],"disallowed_STD3_mapped",[43]],[[8315,8315],"mapped",[8722]],[[8316,8316],"disallowed_STD3_mapped",[61]],[[8317,8317],"disallowed_STD3_mapped",[40]],[[8318,8318],"disallowed_STD3_mapped",[41]],[[8319,8319],"mapped",[110]],[[8320,8320],"mapped",[48]],[[8321,8321],"mapped",[49]],[[8322,8322],"mapped",[50]],[[8323,8323],"mapped",[51]],[[8324,8324],"mapped",[52]],[[8325,8325],"mapped",[53]],[[8326,8326],"mapped",[54]],[[8327,8327],"mapped",[55]],[[8328,8328],"mapped",[56]],[[8329,8329],"mapped",[57]],[[8330,8330],"disallowed_STD3_mapped",[43]],[[8331,8331],"mapped",[8722]],[[8332,8332],"disallowed_STD3_mapped",[61]],[[8333,8333],"disallowed_STD3_mapped",[40]],[[8334,8334],"disallowed_STD3_mapped",[41]],[[8335,8335],"disallowed"],[[8336,8336],"mapped",[97]],[[8337,8337],"mapped",[101]],[[8338,8338],"mapped",[111]],[[8339,8339],"mapped",[120]],[[8340,8340],"mapped",[601]],[[8341,8341],"mapped",[104]],[[8342,8342],"mapped",[107]],[[8343,8343],"mapped",[108]],[[8344,8344],"mapped",[109]],[[8345,8345],"mapped",[110]],[[8346,8346],"mapped",[112]],[[8347,8347],"mapped",[115]],[[8348,8348],"mapped",[116]],[[8349,8351],"disallowed"],[[8352,8359],"valid",[],"NV8"],[[8360,8360],"mapped",[114,115]],[[8361,8362],"valid",[],"NV8"],[[8363,8363],"valid",[],"NV8"],[[8364,8364],"valid",[],"NV8"],[[8365,8367],"valid",[],"NV8"],[[8368,8369],"valid",[],"NV8"],[[8370,8373],"valid",[],"NV8"],[[8374,8376],"valid",[],"NV8"],[[8377,8377],"valid",[],"NV8"],[[8378,8378],"valid",[],"NV8"],[[8379,8381],"valid",[],"NV8"],[[8382,8382],"valid",[],"NV8"],[[8383,8399],"disallowed"],[[8400,8417],"valid",[],"NV8"],[[8418,8419],"valid",[],"NV8"],[[8420,8426],"valid",[],"NV8"],[[8427,8427],"valid",[],"NV8"],[[8428,8431],"valid",[],"NV8"],[[8432,8432],"valid",[],"NV8"],[[8433,8447],"disallowed"],[[8448,8448],"disallowed_STD3_mapped",[97,47,99]],[[8449,8449],"disallowed_STD3_mapped",[97,47,115]],[[8450,8450],"mapped",[99]],[[8451,8451],"mapped",[176,99]],[[8452,8452],"valid",[],"NV8"],[[8453,8453],"disallowed_STD3_mapped",[99,47,111]],[[8454,8454],"disallowed_STD3_mapped",[99,47,117]],[[8455,8455],"mapped",[603]],[[8456,8456],"valid",[],"NV8"],[[8457,8457],"mapped",[176,102]],[[8458,8458],"mapped",[103]],[[8459,8462],"mapped",[104]],[[8463,8463],"mapped",[295]],[[8464,8465],"mapped",[105]],[[8466,8467],"mapped",[108]],[[8468,8468],"valid",[],"NV8"],[[8469,8469],"mapped",[110]],[[8470,8470],"mapped",[110,111]],[[8471,8472],"valid",[],"NV8"],[[8473,8473],"mapped",[112]],[[8474,8474],"mapped",[113]],[[8475,8477],"mapped",[114]],[[8478,8479],"valid",[],"NV8"],[[8480,8480],"mapped",[115,109]],[[8481,8481],"mapped",[116,101,108]],[[8482,8482],"mapped",[116,109]],[[8483,8483],"valid",[],"NV8"],[[8484,8484],"mapped",[122]],[[8485,8485],"valid",[],"NV8"],[[8486,8486],"mapped",[969]],[[8487,8487],"valid",[],"NV8"],[[8488,8488],"mapped",[122]],[[8489,8489],"valid",[],"NV8"],[[8490,8490],"mapped",[107]],[[8491,8491],"mapped",[229]],[[8492,8492],"mapped",[98]],[[8493,8493],"mapped",[99]],[[8494,8494],"valid",[],"NV8"],[[8495,8496],"mapped",[101]],[[8497,8497],"mapped",[102]],[[8498,8498],"disallowed"],[[8499,8499],"mapped",[109]],[[8500,8500],"mapped",[111]],[[8501,8501],"mapped",[1488]],[[8502,8502],"mapped",[1489]],[[8503,8503],"mapped",[1490]],[[8504,8504],"mapped",[1491]],[[8505,8505],"mapped",[105]],[[8506,8506],"valid",[],"NV8"],[[8507,8507],"mapped",[102,97,120]],[[8508,8508],"mapped",[960]],[[8509,8510],"mapped",[947]],[[8511,8511],"mapped",[960]],[[8512,8512],"mapped",[8721]],[[8513,8516],"valid",[],"NV8"],[[8517,8518],"mapped",[100]],[[8519,8519],"mapped",[101]],[[8520,8520],"mapped",[105]],[[8521,8521],"mapped",[106]],[[8522,8523],"valid",[],"NV8"],[[8524,8524],"valid",[],"NV8"],[[8525,8525],"valid",[],"NV8"],[[8526,8526],"valid"],[[8527,8527],"valid",[],"NV8"],[[8528,8528],"mapped",[49,8260,55]],[[8529,8529],"mapped",[49,8260,57]],[[8530,8530],"mapped",[49,8260,49,48]],[[8531,8531],"mapped",[49,8260,51]],[[8532,8532],"mapped",[50,8260,51]],[[8533,8533],"mapped",[49,8260,53]],[[8534,8534],"mapped",[50,8260,53]],[[8535,8535],"mapped",[51,8260,53]],[[8536,8536],"mapped",[52,8260,53]],[[8537,8537],"mapped",[49,8260,54]],[[8538,8538],"mapped",[53,8260,54]],[[8539,8539],"mapped",[49,8260,56]],[[8540,8540],"mapped",[51,8260,56]],[[8541,8541],"mapped",[53,8260,56]],[[8542,8542],"mapped",[55,8260,56]],[[8543,8543],"mapped",[49,8260]],[[8544,8544],"mapped",[105]],[[8545,8545],"mapped",[105,105]],[[8546,8546],"mapped",[105,105,105]],[[8547,8547],"mapped",[105,118]],[[8548,8548],"mapped",[118]],[[8549,8549],"mapped",[118,105]],[[8550,8550],"mapped",[118,105,105]],[[8551,8551],"mapped",[118,105,105,105]],[[8552,8552],"mapped",[105,120]],[[8553,8553],"mapped",[120]],[[8554,8554],"mapped",[120,105]],[[8555,8555],"mapped",[120,105,105]],[[8556,8556],"mapped",[108]],[[8557,8557],"mapped",[99]],[[8558,8558],"mapped",[100]],[[8559,8559],"mapped",[109]],[[8560,8560],"mapped",[105]],[[8561,8561],"mapped",[105,105]],[[8562,8562],"mapped",[105,105,105]],[[8563,8563],"mapped",[105,118]],[[8564,8564],"mapped",[118]],[[8565,8565],"mapped",[118,105]],[[8566,8566],"mapped",[118,105,105]],[[8567,8567],"mapped",[118,105,105,105]],[[8568,8568],"mapped",[105,120]],[[8569,8569],"mapped",[120]],[[8570,8570],"mapped",[120,105]],[[8571,8571],"mapped",[120,105,105]],[[8572,8572],"mapped",[108]],[[8573,8573],"mapped",[99]],[[8574,8574],"mapped",[100]],[[8575,8575],"mapped",[109]],[[8576,8578],"valid",[],"NV8"],[[8579,8579],"disallowed"],[[8580,8580],"valid"],[[8581,8584],"valid",[],"NV8"],[[8585,8585],"mapped",[48,8260,51]],[[8586,8587],"valid",[],"NV8"],[[8588,8591],"disallowed"],[[8592,8682],"valid",[],"NV8"],[[8683,8691],"valid",[],"NV8"],[[8692,8703],"valid",[],"NV8"],[[8704,8747],"valid",[],"NV8"],[[8748,8748],"mapped",[8747,8747]],[[8749,8749],"mapped",[8747,8747,8747]],[[8750,8750],"valid",[],"NV8"],[[8751,8751],"mapped",[8750,8750]],[[8752,8752],"mapped",[8750,8750,8750]],[[8753,8799],"valid",[],"NV8"],[[8800,8800],"disallowed_STD3_valid"],[[8801,8813],"valid",[],"NV8"],[[8814,8815],"disallowed_STD3_valid"],[[8816,8945],"valid",[],"NV8"],[[8946,8959],"valid",[],"NV8"],[[8960,8960],"valid",[],"NV8"],[[8961,8961],"valid",[],"NV8"],[[8962,9000],"valid",[],"NV8"],[[9001,9001],"mapped",[12296]],[[9002,9002],"mapped",[12297]],[[9003,9082],"valid",[],"NV8"],[[9083,9083],"valid",[],"NV8"],[[9084,9084],"valid",[],"NV8"],[[9085,9114],"valid",[],"NV8"],[[9115,9166],"valid",[],"NV8"],[[9167,9168],"valid",[],"NV8"],[[9169,9179],"valid",[],"NV8"],[[9180,9191],"valid",[],"NV8"],[[9192,9192],"valid",[],"NV8"],[[9193,9203],"valid",[],"NV8"],[[9204,9210],"valid",[],"NV8"],[[9211,9215],"disallowed"],[[9216,9252],"valid",[],"NV8"],[[9253,9254],"valid",[],"NV8"],[[9255,9279],"disallowed"],[[9280,9290],"valid",[],"NV8"],[[9291,9311],"disallowed"],[[9312,9312],"mapped",[49]],[[9313,9313],"mapped",[50]],[[9314,9314],"mapped",[51]],[[9315,9315],"mapped",[52]],[[9316,9316],"mapped",[53]],[[9317,9317],"mapped",[54]],[[9318,9318],"mapped",[55]],[[9319,9319],"mapped",[56]],[[9320,9320],"mapped",[57]],[[9321,9321],"mapped",[49,48]],[[9322,9322],"mapped",[49,49]],[[9323,9323],"mapped",[49,50]],[[9324,9324],"mapped",[49,51]],[[9325,9325],"mapped",[49,52]],[[9326,9326],"mapped",[49,53]],[[9327,9327],"mapped",[49,54]],[[9328,9328],"mapped",[49,55]],[[9329,9329],"mapped",[49,56]],[[9330,9330],"mapped",[49,57]],[[9331,9331],"mapped",[50,48]],[[9332,9332],"disallowed_STD3_mapped",[40,49,41]],[[9333,9333],"disallowed_STD3_mapped",[40,50,41]],[[9334,9334],"disallowed_STD3_mapped",[40,51,41]],[[9335,9335],"disallowed_STD3_mapped",[40,52,41]],[[9336,9336],"disallowed_STD3_mapped",[40,53,41]],[[9337,9337],"disallowed_STD3_mapped",[40,54,41]],[[9338,9338],"disallowed_STD3_mapped",[40,55,41]],[[9339,9339],"disallowed_STD3_mapped",[40,56,41]],[[9340,9340],"disallowed_STD3_mapped",[40,57,41]],[[9341,9341],"disallowed_STD3_mapped",[40,49,48,41]],[[9342,9342],"disallowed_STD3_mapped",[40,49,49,41]],[[9343,9343],"disallowed_STD3_mapped",[40,49,50,41]],[[9344,9344],"disallowed_STD3_mapped",[40,49,51,41]],[[9345,9345],"disallowed_STD3_mapped",[40,49,52,41]],[[9346,9346],"disallowed_STD3_mapped",[40,49,53,41]],[[9347,9347],"disallowed_STD3_mapped",[40,49,54,41]],[[9348,9348],"disallowed_STD3_mapped",[40,49,55,41]],[[9349,9349],"disallowed_STD3_mapped",[40,49,56,41]],[[9350,9350],"disallowed_STD3_mapped",[40,49,57,41]],[[9351,9351],"disallowed_STD3_mapped",[40,50,48,41]],[[9352,9371],"disallowed"],[[9372,9372],"disallowed_STD3_mapped",[40,97,41]],[[9373,9373],"disallowed_STD3_mapped",[40,98,41]],[[9374,9374],"disallowed_STD3_mapped",[40,99,41]],[[9375,9375],"disallowed_STD3_mapped",[40,100,41]],[[9376,9376],"disallowed_STD3_mapped",[40,101,41]],[[9377,9377],"disallowed_STD3_mapped",[40,102,41]],[[9378,9378],"disallowed_STD3_mapped",[40,103,41]],[[9379,9379],"disallowed_STD3_mapped",[40,104,41]],[[9380,9380],"disallowed_STD3_mapped",[40,105,41]],[[9381,9381],"disallowed_STD3_mapped",[40,106,41]],[[9382,9382],"disallowed_STD3_mapped",[40,107,41]],[[9383,9383],"disallowed_STD3_mapped",[40,108,41]],[[9384,9384],"disallowed_STD3_mapped",[40,109,41]],[[9385,9385],"disallowed_STD3_mapped",[40,110,41]],[[9386,9386],"disallowed_STD3_mapped",[40,111,41]],[[9387,9387],"disallowed_STD3_mapped",[40,112,41]],[[9388,9388],"disallowed_STD3_mapped",[40,113,41]],[[9389,9389],"disallowed_STD3_mapped",[40,114,41]],[[9390,9390],"disallowed_STD3_mapped",[40,115,41]],[[9391,9391],"disallowed_STD3_mapped",[40,116,41]],[[9392,9392],"disallowed_STD3_mapped",[40,117,41]],[[9393,9393],"disallowed_STD3_mapped",[40,118,41]],[[9394,9394],"disallowed_STD3_mapped",[40,119,41]],[[9395,9395],"disallowed_STD3_mapped",[40,120,41]],[[9396,9396],"disallowed_STD3_mapped",[40,121,41]],[[9397,9397],"disallowed_STD3_mapped",[40,122,41]],[[9398,9398],"mapped",[97]],[[9399,9399],"mapped",[98]],[[9400,9400],"mapped",[99]],[[9401,9401],"mapped",[100]],[[9402,9402],"mapped",[101]],[[9403,9403],"mapped",[102]],[[9404,9404],"mapped",[103]],[[9405,9405],"mapped",[104]],[[9406,9406],"mapped",[105]],[[9407,9407],"mapped",[106]],[[9408,9408],"mapped",[107]],[[9409,9409],"mapped",[108]],[[9410,9410],"mapped",[109]],[[9411,9411],"mapped",[110]],[[9412,9412],"mapped",[111]],[[9413,9413],"mapped",[112]],[[9414,9414],"mapped",[113]],[[9415,9415],"mapped",[114]],[[9416,9416],"mapped",[115]],[[9417,9417],"mapped",[116]],[[9418,9418],"mapped",[117]],[[9419,9419],"mapped",[118]],[[9420,9420],"mapped",[119]],[[9421,9421],"mapped",[120]],[[9422,9422],"mapped",[121]],[[9423,9423],"mapped",[122]],[[9424,9424],"mapped",[97]],[[9425,9425],"mapped",[98]],[[9426,9426],"mapped",[99]],[[9427,9427],"mapped",[100]],[[9428,9428],"mapped",[101]],[[9429,9429],"mapped",[102]],[[9430,9430],"mapped",[103]],[[9431,9431],"mapped",[104]],[[9432,9432],"mapped",[105]],[[9433,9433],"mapped",[106]],[[9434,9434],"mapped",[107]],[[9435,9435],"mapped",[108]],[[9436,9436],"mapped",[109]],[[9437,9437],"mapped",[110]],[[9438,9438],"mapped",[111]],[[9439,9439],"mapped",[112]],[[9440,9440],"mapped",[113]],[[9441,9441],"mapped",[114]],[[9442,9442],"mapped",[115]],[[9443,9443],"mapped",[116]],[[9444,9444],"mapped",[117]],[[9445,9445],"mapped",[118]],[[9446,9446],"mapped",[119]],[[9447,9447],"mapped",[120]],[[9448,9448],"mapped",[121]],[[9449,9449],"mapped",[122]],[[9450,9450],"mapped",[48]],[[9451,9470],"valid",[],"NV8"],[[9471,9471],"valid",[],"NV8"],[[9472,9621],"valid",[],"NV8"],[[9622,9631],"valid",[],"NV8"],[[9632,9711],"valid",[],"NV8"],[[9712,9719],"valid",[],"NV8"],[[9720,9727],"valid",[],"NV8"],[[9728,9747],"valid",[],"NV8"],[[9748,9749],"valid",[],"NV8"],[[9750,9751],"valid",[],"NV8"],[[9752,9752],"valid",[],"NV8"],[[9753,9753],"valid",[],"NV8"],[[9754,9839],"valid",[],"NV8"],[[9840,9841],"valid",[],"NV8"],[[9842,9853],"valid",[],"NV8"],[[9854,9855],"valid",[],"NV8"],[[9856,9865],"valid",[],"NV8"],[[9866,9873],"valid",[],"NV8"],[[9874,9884],"valid",[],"NV8"],[[9885,9885],"valid",[],"NV8"],[[9886,9887],"valid",[],"NV8"],[[9888,9889],"valid",[],"NV8"],[[9890,9905],"valid",[],"NV8"],[[9906,9906],"valid",[],"NV8"],[[9907,9916],"valid",[],"NV8"],[[9917,9919],"valid",[],"NV8"],[[9920,9923],"valid",[],"NV8"],[[9924,9933],"valid",[],"NV8"],[[9934,9934],"valid",[],"NV8"],[[9935,9953],"valid",[],"NV8"],[[9954,9954],"valid",[],"NV8"],[[9955,9955],"valid",[],"NV8"],[[9956,9959],"valid",[],"NV8"],[[9960,9983],"valid",[],"NV8"],[[9984,9984],"valid",[],"NV8"],[[9985,9988],"valid",[],"NV8"],[[9989,9989],"valid",[],"NV8"],[[9990,9993],"valid",[],"NV8"],[[9994,9995],"valid",[],"NV8"],[[9996,10023],"valid",[],"NV8"],[[10024,10024],"valid",[],"NV8"],[[10025,10059],"valid",[],"NV8"],[[10060,10060],"valid",[],"NV8"],[[10061,10061],"valid",[],"NV8"],[[10062,10062],"valid",[],"NV8"],[[10063,10066],"valid",[],"NV8"],[[10067,10069],"valid",[],"NV8"],[[10070,10070],"valid",[],"NV8"],[[10071,10071],"valid",[],"NV8"],[[10072,10078],"valid",[],"NV8"],[[10079,10080],"valid",[],"NV8"],[[10081,10087],"valid",[],"NV8"],[[10088,10101],"valid",[],"NV8"],[[10102,10132],"valid",[],"NV8"],[[10133,10135],"valid",[],"NV8"],[[10136,10159],"valid",[],"NV8"],[[10160,10160],"valid",[],"NV8"],[[10161,10174],"valid",[],"NV8"],[[10175,10175],"valid",[],"NV8"],[[10176,10182],"valid",[],"NV8"],[[10183,10186],"valid",[],"NV8"],[[10187,10187],"valid",[],"NV8"],[[10188,10188],"valid",[],"NV8"],[[10189,10189],"valid",[],"NV8"],[[10190,10191],"valid",[],"NV8"],[[10192,10219],"valid",[],"NV8"],[[10220,10223],"valid",[],"NV8"],[[10224,10239],"valid",[],"NV8"],[[10240,10495],"valid",[],"NV8"],[[10496,10763],"valid",[],"NV8"],[[10764,10764],"mapped",[8747,8747,8747,8747]],[[10765,10867],"valid",[],"NV8"],[[10868,10868],"disallowed_STD3_mapped",[58,58,61]],[[10869,10869],"disallowed_STD3_mapped",[61,61]],[[10870,10870],"disallowed_STD3_mapped",[61,61,61]],[[10871,10971],"valid",[],"NV8"],[[10972,10972],"mapped",[10973,824]],[[10973,11007],"valid",[],"NV8"],[[11008,11021],"valid",[],"NV8"],[[11022,11027],"valid",[],"NV8"],[[11028,11034],"valid",[],"NV8"],[[11035,11039],"valid",[],"NV8"],[[11040,11043],"valid",[],"NV8"],[[11044,11084],"valid",[],"NV8"],[[11085,11087],"valid",[],"NV8"],[[11088,11092],"valid",[],"NV8"],[[11093,11097],"valid",[],"NV8"],[[11098,11123],"valid",[],"NV8"],[[11124,11125],"disallowed"],[[11126,11157],"valid",[],"NV8"],[[11158,11159],"disallowed"],[[11160,11193],"valid",[],"NV8"],[[11194,11196],"disallowed"],[[11197,11208],"valid",[],"NV8"],[[11209,11209],"disallowed"],[[11210,11217],"valid",[],"NV8"],[[11218,11243],"disallowed"],[[11244,11247],"valid",[],"NV8"],[[11248,11263],"disallowed"],[[11264,11264],"mapped",[11312]],[[11265,11265],"mapped",[11313]],[[11266,11266],"mapped",[11314]],[[11267,11267],"mapped",[11315]],[[11268,11268],"mapped",[11316]],[[11269,11269],"mapped",[11317]],[[11270,11270],"mapped",[11318]],[[11271,11271],"mapped",[11319]],[[11272,11272],"mapped",[11320]],[[11273,11273],"mapped",[11321]],[[11274,11274],"mapped",[11322]],[[11275,11275],"mapped",[11323]],[[11276,11276],"mapped",[11324]],[[11277,11277],"mapped",[11325]],[[11278,11278],"mapped",[11326]],[[11279,11279],"mapped",[11327]],[[11280,11280],"mapped",[11328]],[[11281,11281],"mapped",[11329]],[[11282,11282],"mapped",[11330]],[[11283,11283],"mapped",[11331]],[[11284,11284],"mapped",[11332]],[[11285,11285],"mapped",[11333]],[[11286,11286],"mapped",[11334]],[[11287,11287],"mapped",[11335]],[[11288,11288],"mapped",[11336]],[[11289,11289],"mapped",[11337]],[[11290,11290],"mapped",[11338]],[[11291,11291],"mapped",[11339]],[[11292,11292],"mapped",[11340]],[[11293,11293],"mapped",[11341]],[[11294,11294],"mapped",[11342]],[[11295,11295],"mapped",[11343]],[[11296,11296],"mapped",[11344]],[[11297,11297],"mapped",[11345]],[[11298,11298],"mapped",[11346]],[[11299,11299],"mapped",[11347]],[[11300,11300],"mapped",[11348]],[[11301,11301],"mapped",[11349]],[[11302,11302],"mapped",[11350]],[[11303,11303],"mapped",[11351]],[[11304,11304],"mapped",[11352]],[[11305,11305],"mapped",[11353]],[[11306,11306],"mapped",[11354]],[[11307,11307],"mapped",[11355]],[[11308,11308],"mapped",[11356]],[[11309,11309],"mapped",[11357]],[[11310,11310],"mapped",[11358]],[[11311,11311],"disallowed"],[[11312,11358],"valid"],[[11359,11359],"disallowed"],[[11360,11360],"mapped",[11361]],[[11361,11361],"valid"],[[11362,11362],"mapped",[619]],[[11363,11363],"mapped",[7549]],[[11364,11364],"mapped",[637]],[[11365,11366],"valid"],[[11367,11367],"mapped",[11368]],[[11368,11368],"valid"],[[11369,11369],"mapped",[11370]],[[11370,11370],"valid"],[[11371,11371],"mapped",[11372]],[[11372,11372],"valid"],[[11373,11373],"mapped",[593]],[[11374,11374],"mapped",[625]],[[11375,11375],"mapped",[592]],[[11376,11376],"mapped",[594]],[[11377,11377],"valid"],[[11378,11378],"mapped",[11379]],[[11379,11379],"valid"],[[11380,11380],"valid"],[[11381,11381],"mapped",[11382]],[[11382,11383],"valid"],[[11384,11387],"valid"],[[11388,11388],"mapped",[106]],[[11389,11389],"mapped",[118]],[[11390,11390],"mapped",[575]],[[11391,11391],"mapped",[576]],[[11392,11392],"mapped",[11393]],[[11393,11393],"valid"],[[11394,11394],"mapped",[11395]],[[11395,11395],"valid"],[[11396,11396],"mapped",[11397]],[[11397,11397],"valid"],[[11398,11398],"mapped",[11399]],[[11399,11399],"valid"],[[11400,11400],"mapped",[11401]],[[11401,11401],"valid"],[[11402,11402],"mapped",[11403]],[[11403,11403],"valid"],[[11404,11404],"mapped",[11405]],[[11405,11405],"valid"],[[11406,11406],"mapped",[11407]],[[11407,11407],"valid"],[[11408,11408],"mapped",[11409]],[[11409,11409],"valid"],[[11410,11410],"mapped",[11411]],[[11411,11411],"valid"],[[11412,11412],"mapped",[11413]],[[11413,11413],"valid"],[[11414,11414],"mapped",[11415]],[[11415,11415],"valid"],[[11416,11416],"mapped",[11417]],[[11417,11417],"valid"],[[11418,11418],"mapped",[11419]],[[11419,11419],"valid"],[[11420,11420],"mapped",[11421]],[[11421,11421],"valid"],[[11422,11422],"mapped",[11423]],[[11423,11423],"valid"],[[11424,11424],"mapped",[11425]],[[11425,11425],"valid"],[[11426,11426],"mapped",[11427]],[[11427,11427],"valid"],[[11428,11428],"mapped",[11429]],[[11429,11429],"valid"],[[11430,11430],"mapped",[11431]],[[11431,11431],"valid"],[[11432,11432],"mapped",[11433]],[[11433,11433],"valid"],[[11434,11434],"mapped",[11435]],[[11435,11435],"valid"],[[11436,11436],"mapped",[11437]],[[11437,11437],"valid"],[[11438,11438],"mapped",[11439]],[[11439,11439],"valid"],[[11440,11440],"mapped",[11441]],[[11441,11441],"valid"],[[11442,11442],"mapped",[11443]],[[11443,11443],"valid"],[[11444,11444],"mapped",[11445]],[[11445,11445],"valid"],[[11446,11446],"mapped",[11447]],[[11447,11447],"valid"],[[11448,11448],"mapped",[11449]],[[11449,11449],"valid"],[[11450,11450],"mapped",[11451]],[[11451,11451],"valid"],[[11452,11452],"mapped",[11453]],[[11453,11453],"valid"],[[11454,11454],"mapped",[11455]],[[11455,11455],"valid"],[[11456,11456],"mapped",[11457]],[[11457,11457],"valid"],[[11458,11458],"mapped",[11459]],[[11459,11459],"valid"],[[11460,11460],"mapped",[11461]],[[11461,11461],"valid"],[[11462,11462],"mapped",[11463]],[[11463,11463],"valid"],[[11464,11464],"mapped",[11465]],[[11465,11465],"valid"],[[11466,11466],"mapped",[11467]],[[11467,11467],"valid"],[[11468,11468],"mapped",[11469]],[[11469,11469],"valid"],[[11470,11470],"mapped",[11471]],[[11471,11471],"valid"],[[11472,11472],"mapped",[11473]],[[11473,11473],"valid"],[[11474,11474],"mapped",[11475]],[[11475,11475],"valid"],[[11476,11476],"mapped",[11477]],[[11477,11477],"valid"],[[11478,11478],"mapped",[11479]],[[11479,11479],"valid"],[[11480,11480],"mapped",[11481]],[[11481,11481],"valid"],[[11482,11482],"mapped",[11483]],[[11483,11483],"valid"],[[11484,11484],"mapped",[11485]],[[11485,11485],"valid"],[[11486,11486],"mapped",[11487]],[[11487,11487],"valid"],[[11488,11488],"mapped",[11489]],[[11489,11489],"valid"],[[11490,11490],"mapped",[11491]],[[11491,11492],"valid"],[[11493,11498],"valid",[],"NV8"],[[11499,11499],"mapped",[11500]],[[11500,11500],"valid"],[[11501,11501],"mapped",[11502]],[[11502,11505],"valid"],[[11506,11506],"mapped",[11507]],[[11507,11507],"valid"],[[11508,11512],"disallowed"],[[11513,11519],"valid",[],"NV8"],[[11520,11557],"valid"],[[11558,11558],"disallowed"],[[11559,11559],"valid"],[[11560,11564],"disallowed"],[[11565,11565],"valid"],[[11566,11567],"disallowed"],[[11568,11621],"valid"],[[11622,11623],"valid"],[[11624,11630],"disallowed"],[[11631,11631],"mapped",[11617]],[[11632,11632],"valid",[],"NV8"],[[11633,11646],"disallowed"],[[11647,11647],"valid"],[[11648,11670],"valid"],[[11671,11679],"disallowed"],[[11680,11686],"valid"],[[11687,11687],"disallowed"],[[11688,11694],"valid"],[[11695,11695],"disallowed"],[[11696,11702],"valid"],[[11703,11703],"disallowed"],[[11704,11710],"valid"],[[11711,11711],"disallowed"],[[11712,11718],"valid"],[[11719,11719],"disallowed"],[[11720,11726],"valid"],[[11727,11727],"disallowed"],[[11728,11734],"valid"],[[11735,11735],"disallowed"],[[11736,11742],"valid"],[[11743,11743],"disallowed"],[[11744,11775],"valid"],[[11776,11799],"valid",[],"NV8"],[[11800,11803],"valid",[],"NV8"],[[11804,11805],"valid",[],"NV8"],[[11806,11822],"valid",[],"NV8"],[[11823,11823],"valid"],[[11824,11824],"valid",[],"NV8"],[[11825,11825],"valid",[],"NV8"],[[11826,11835],"valid",[],"NV8"],[[11836,11842],"valid",[],"NV8"],[[11843,11903],"disallowed"],[[11904,11929],"valid",[],"NV8"],[[11930,11930],"disallowed"],[[11931,11934],"valid",[],"NV8"],[[11935,11935],"mapped",[27597]],[[11936,12018],"valid",[],"NV8"],[[12019,12019],"mapped",[40863]],[[12020,12031],"disallowed"],[[12032,12032],"mapped",[19968]],[[12033,12033],"mapped",[20008]],[[12034,12034],"mapped",[20022]],[[12035,12035],"mapped",[20031]],[[12036,12036],"mapped",[20057]],[[12037,12037],"mapped",[20101]],[[12038,12038],"mapped",[20108]],[[12039,12039],"mapped",[20128]],[[12040,12040],"mapped",[20154]],[[12041,12041],"mapped",[20799]],[[12042,12042],"mapped",[20837]],[[12043,12043],"mapped",[20843]],[[12044,12044],"mapped",[20866]],[[12045,12045],"mapped",[20886]],[[12046,12046],"mapped",[20907]],[[12047,12047],"mapped",[20960]],[[12048,12048],"mapped",[20981]],[[12049,12049],"mapped",[20992]],[[12050,12050],"mapped",[21147]],[[12051,12051],"mapped",[21241]],[[12052,12052],"mapped",[21269]],[[12053,12053],"mapped",[21274]],[[12054,12054],"mapped",[21304]],[[12055,12055],"mapped",[21313]],[[12056,12056],"mapped",[21340]],[[12057,12057],"mapped",[21353]],[[12058,12058],"mapped",[21378]],[[12059,12059],"mapped",[21430]],[[12060,12060],"mapped",[21448]],[[12061,12061],"mapped",[21475]],[[12062,12062],"mapped",[22231]],[[12063,12063],"mapped",[22303]],[[12064,12064],"mapped",[22763]],[[12065,12065],"mapped",[22786]],[[12066,12066],"mapped",[22794]],[[12067,12067],"mapped",[22805]],[[12068,12068],"mapped",[22823]],[[12069,12069],"mapped",[22899]],[[12070,12070],"mapped",[23376]],[[12071,12071],"mapped",[23424]],[[12072,12072],"mapped",[23544]],[[12073,12073],"mapped",[23567]],[[12074,12074],"mapped",[23586]],[[12075,12075],"mapped",[23608]],[[12076,12076],"mapped",[23662]],[[12077,12077],"mapped",[23665]],[[12078,12078],"mapped",[24027]],[[12079,12079],"mapped",[24037]],[[12080,12080],"mapped",[24049]],[[12081,12081],"mapped",[24062]],[[12082,12082],"mapped",[24178]],[[12083,12083],"mapped",[24186]],[[12084,12084],"mapped",[24191]],[[12085,12085],"mapped",[24308]],[[12086,12086],"mapped",[24318]],[[12087,12087],"mapped",[24331]],[[12088,12088],"mapped",[24339]],[[12089,12089],"mapped",[24400]],[[12090,12090],"mapped",[24417]],[[12091,12091],"mapped",[24435]],[[12092,12092],"mapped",[24515]],[[12093,12093],"mapped",[25096]],[[12094,12094],"mapped",[25142]],[[12095,12095],"mapped",[25163]],[[12096,12096],"mapped",[25903]],[[12097,12097],"mapped",[25908]],[[12098,12098],"mapped",[25991]],[[12099,12099],"mapped",[26007]],[[12100,12100],"mapped",[26020]],[[12101,12101],"mapped",[26041]],[[12102,12102],"mapped",[26080]],[[12103,12103],"mapped",[26085]],[[12104,12104],"mapped",[26352]],[[12105,12105],"mapped",[26376]],[[12106,12106],"mapped",[26408]],[[12107,12107],"mapped",[27424]],[[12108,12108],"mapped",[27490]],[[12109,12109],"mapped",[27513]],[[12110,12110],"mapped",[27571]],[[12111,12111],"mapped",[27595]],[[12112,12112],"mapped",[27604]],[[12113,12113],"mapped",[27611]],[[12114,12114],"mapped",[27663]],[[12115,12115],"mapped",[27668]],[[12116,12116],"mapped",[27700]],[[12117,12117],"mapped",[28779]],[[12118,12118],"mapped",[29226]],[[12119,12119],"mapped",[29238]],[[12120,12120],"mapped",[29243]],[[12121,12121],"mapped",[29247]],[[12122,12122],"mapped",[29255]],[[12123,12123],"mapped",[29273]],[[12124,12124],"mapped",[29275]],[[12125,12125],"mapped",[29356]],[[12126,12126],"mapped",[29572]],[[12127,12127],"mapped",[29577]],[[12128,12128],"mapped",[29916]],[[12129,12129],"mapped",[29926]],[[12130,12130],"mapped",[29976]],[[12131,12131],"mapped",[29983]],[[12132,12132],"mapped",[29992]],[[12133,12133],"mapped",[30000]],[[12134,12134],"mapped",[30091]],[[12135,12135],"mapped",[30098]],[[12136,12136],"mapped",[30326]],[[12137,12137],"mapped",[30333]],[[12138,12138],"mapped",[30382]],[[12139,12139],"mapped",[30399]],[[12140,12140],"mapped",[30446]],[[12141,12141],"mapped",[30683]],[[12142,12142],"mapped",[30690]],[[12143,12143],"mapped",[30707]],[[12144,12144],"mapped",[31034]],[[12145,12145],"mapped",[31160]],[[12146,12146],"mapped",[31166]],[[12147,12147],"mapped",[31348]],[[12148,12148],"mapped",[31435]],[[12149,12149],"mapped",[31481]],[[12150,12150],"mapped",[31859]],[[12151,12151],"mapped",[31992]],[[12152,12152],"mapped",[32566]],[[12153,12153],"mapped",[32593]],[[12154,12154],"mapped",[32650]],[[12155,12155],"mapped",[32701]],[[12156,12156],"mapped",[32769]],[[12157,12157],"mapped",[32780]],[[12158,12158],"mapped",[32786]],[[12159,12159],"mapped",[32819]],[[12160,12160],"mapped",[32895]],[[12161,12161],"mapped",[32905]],[[12162,12162],"mapped",[33251]],[[12163,12163],"mapped",[33258]],[[12164,12164],"mapped",[33267]],[[12165,12165],"mapped",[33276]],[[12166,12166],"mapped",[33292]],[[12167,12167],"mapped",[33307]],[[12168,12168],"mapped",[33311]],[[12169,12169],"mapped",[33390]],[[12170,12170],"mapped",[33394]],[[12171,12171],"mapped",[33400]],[[12172,12172],"mapped",[34381]],[[12173,12173],"mapped",[34411]],[[12174,12174],"mapped",[34880]],[[12175,12175],"mapped",[34892]],[[12176,12176],"mapped",[34915]],[[12177,12177],"mapped",[35198]],[[12178,12178],"mapped",[35211]],[[12179,12179],"mapped",[35282]],[[12180,12180],"mapped",[35328]],[[12181,12181],"mapped",[35895]],[[12182,12182],"mapped",[35910]],[[12183,12183],"mapped",[35925]],[[12184,12184],"mapped",[35960]],[[12185,12185],"mapped",[35997]],[[12186,12186],"mapped",[36196]],[[12187,12187],"mapped",[36208]],[[12188,12188],"mapped",[36275]],[[12189,12189],"mapped",[36523]],[[12190,12190],"mapped",[36554]],[[12191,12191],"mapped",[36763]],[[12192,12192],"mapped",[36784]],[[12193,12193],"mapped",[36789]],[[12194,12194],"mapped",[37009]],[[12195,12195],"mapped",[37193]],[[12196,12196],"mapped",[37318]],[[12197,12197],"mapped",[37324]],[[12198,12198],"mapped",[37329]],[[12199,12199],"mapped",[38263]],[[12200,12200],"mapped",[38272]],[[12201,12201],"mapped",[38428]],[[12202,12202],"mapped",[38582]],[[12203,12203],"mapped",[38585]],[[12204,12204],"mapped",[38632]],[[12205,12205],"mapped",[38737]],[[12206,12206],"mapped",[38750]],[[12207,12207],"mapped",[38754]],[[12208,12208],"mapped",[38761]],[[12209,12209],"mapped",[38859]],[[12210,12210],"mapped",[38893]],[[12211,12211],"mapped",[38899]],[[12212,12212],"mapped",[38913]],[[12213,12213],"mapped",[39080]],[[12214,12214],"mapped",[39131]],[[12215,12215],"mapped",[39135]],[[12216,12216],"mapped",[39318]],[[12217,12217],"mapped",[39321]],[[12218,12218],"mapped",[39340]],[[12219,12219],"mapped",[39592]],[[12220,12220],"mapped",[39640]],[[12221,12221],"mapped",[39647]],[[12222,12222],"mapped",[39717]],[[12223,12223],"mapped",[39727]],[[12224,12224],"mapped",[39730]],[[12225,12225],"mapped",[39740]],[[12226,12226],"mapped",[39770]],[[12227,12227],"mapped",[40165]],[[12228,12228],"mapped",[40565]],[[12229,12229],"mapped",[40575]],[[12230,12230],"mapped",[40613]],[[12231,12231],"mapped",[40635]],[[12232,12232],"mapped",[40643]],[[12233,12233],"mapped",[40653]],[[12234,12234],"mapped",[40657]],[[12235,12235],"mapped",[40697]],[[12236,12236],"mapped",[40701]],[[12237,12237],"mapped",[40718]],[[12238,12238],"mapped",[40723]],[[12239,12239],"mapped",[40736]],[[12240,12240],"mapped",[40763]],[[12241,12241],"mapped",[40778]],[[12242,12242],"mapped",[40786]],[[12243,12243],"mapped",[40845]],[[12244,12244],"mapped",[40860]],[[12245,12245],"mapped",[40864]],[[12246,12271],"disallowed"],[[12272,12283],"disallowed"],[[12284,12287],"disallowed"],[[12288,12288],"disallowed_STD3_mapped",[32]],[[12289,12289],"valid",[],"NV8"],[[12290,12290],"mapped",[46]],[[12291,12292],"valid",[],"NV8"],[[12293,12295],"valid"],[[12296,12329],"valid",[],"NV8"],[[12330,12333],"valid"],[[12334,12341],"valid",[],"NV8"],[[12342,12342],"mapped",[12306]],[[12343,12343],"valid",[],"NV8"],[[12344,12344],"mapped",[21313]],[[12345,12345],"mapped",[21316]],[[12346,12346],"mapped",[21317]],[[12347,12347],"valid",[],"NV8"],[[12348,12348],"valid"],[[12349,12349],"valid",[],"NV8"],[[12350,12350],"valid",[],"NV8"],[[12351,12351],"valid",[],"NV8"],[[12352,12352],"disallowed"],[[12353,12436],"valid"],[[12437,12438],"valid"],[[12439,12440],"disallowed"],[[12441,12442],"valid"],[[12443,12443],"disallowed_STD3_mapped",[32,12441]],[[12444,12444],"disallowed_STD3_mapped",[32,12442]],[[12445,12446],"valid"],[[12447,12447],"mapped",[12424,12426]],[[12448,12448],"valid",[],"NV8"],[[12449,12542],"valid"],[[12543,12543],"mapped",[12467,12488]],[[12544,12548],"disallowed"],[[12549,12588],"valid"],[[12589,12589],"valid"],[[12590,12592],"disallowed"],[[12593,12593],"mapped",[4352]],[[12594,12594],"mapped",[4353]],[[12595,12595],"mapped",[4522]],[[12596,12596],"mapped",[4354]],[[12597,12597],"mapped",[4524]],[[12598,12598],"mapped",[4525]],[[12599,12599],"mapped",[4355]],[[12600,12600],"mapped",[4356]],[[12601,12601],"mapped",[4357]],[[12602,12602],"mapped",[4528]],[[12603,12603],"mapped",[4529]],[[12604,12604],"mapped",[4530]],[[12605,12605],"mapped",[4531]],[[12606,12606],"mapped",[4532]],[[12607,12607],"mapped",[4533]],[[12608,12608],"mapped",[4378]],[[12609,12609],"mapped",[4358]],[[12610,12610],"mapped",[4359]],[[12611,12611],"mapped",[4360]],[[12612,12612],"mapped",[4385]],[[12613,12613],"mapped",[4361]],[[12614,12614],"mapped",[4362]],[[12615,12615],"mapped",[4363]],[[12616,12616],"mapped",[4364]],[[12617,12617],"mapped",[4365]],[[12618,12618],"mapped",[4366]],[[12619,12619],"mapped",[4367]],[[12620,12620],"mapped",[4368]],[[12621,12621],"mapped",[4369]],[[12622,12622],"mapped",[4370]],[[12623,12623],"mapped",[4449]],[[12624,12624],"mapped",[4450]],[[12625,12625],"mapped",[4451]],[[12626,12626],"mapped",[4452]],[[12627,12627],"mapped",[4453]],[[12628,12628],"mapped",[4454]],[[12629,12629],"mapped",[4455]],[[12630,12630],"mapped",[4456]],[[12631,12631],"mapped",[4457]],[[12632,12632],"mapped",[4458]],[[12633,12633],"mapped",[4459]],[[12634,12634],"mapped",[4460]],[[12635,12635],"mapped",[4461]],[[12636,12636],"mapped",[4462]],[[12637,12637],"mapped",[4463]],[[12638,12638],"mapped",[4464]],[[12639,12639],"mapped",[4465]],[[12640,12640],"mapped",[4466]],[[12641,12641],"mapped",[4467]],[[12642,12642],"mapped",[4468]],[[12643,12643],"mapped",[4469]],[[12644,12644],"disallowed"],[[12645,12645],"mapped",[4372]],[[12646,12646],"mapped",[4373]],[[12647,12647],"mapped",[4551]],[[12648,12648],"mapped",[4552]],[[12649,12649],"mapped",[4556]],[[12650,12650],"mapped",[4558]],[[12651,12651],"mapped",[4563]],[[12652,12652],"mapped",[4567]],[[12653,12653],"mapped",[4569]],[[12654,12654],"mapped",[4380]],[[12655,12655],"mapped",[4573]],[[12656,12656],"mapped",[4575]],[[12657,12657],"mapped",[4381]],[[12658,12658],"mapped",[4382]],[[12659,12659],"mapped",[4384]],[[12660,12660],"mapped",[4386]],[[12661,12661],"mapped",[4387]],[[12662,12662],"mapped",[4391]],[[12663,12663],"mapped",[4393]],[[12664,12664],"mapped",[4395]],[[12665,12665],"mapped",[4396]],[[12666,12666],"mapped",[4397]],[[12667,12667],"mapped",[4398]],[[12668,12668],"mapped",[4399]],[[12669,12669],"mapped",[4402]],[[12670,12670],"mapped",[4406]],[[12671,12671],"mapped",[4416]],[[12672,12672],"mapped",[4423]],[[12673,12673],"mapped",[4428]],[[12674,12674],"mapped",[4593]],[[12675,12675],"mapped",[4594]],[[12676,12676],"mapped",[4439]],[[12677,12677],"mapped",[4440]],[[12678,12678],"mapped",[4441]],[[12679,12679],"mapped",[4484]],[[12680,12680],"mapped",[4485]],[[12681,12681],"mapped",[4488]],[[12682,12682],"mapped",[4497]],[[12683,12683],"mapped",[4498]],[[12684,12684],"mapped",[4500]],[[12685,12685],"mapped",[4510]],[[12686,12686],"mapped",[4513]],[[12687,12687],"disallowed"],[[12688,12689],"valid",[],"NV8"],[[12690,12690],"mapped",[19968]],[[12691,12691],"mapped",[20108]],[[12692,12692],"mapped",[19977]],[[12693,12693],"mapped",[22235]],[[12694,12694],"mapped",[19978]],[[12695,12695],"mapped",[20013]],[[12696,12696],"mapped",[19979]],[[12697,12697],"mapped",[30002]],[[12698,12698],"mapped",[20057]],[[12699,12699],"mapped",[19993]],[[12700,12700],"mapped",[19969]],[[12701,12701],"mapped",[22825]],[[12702,12702],"mapped",[22320]],[[12703,12703],"mapped",[20154]],[[12704,12727],"valid"],[[12728,12730],"valid"],[[12731,12735],"disallowed"],[[12736,12751],"valid",[],"NV8"],[[12752,12771],"valid",[],"NV8"],[[12772,12783],"disallowed"],[[12784,12799],"valid"],[[12800,12800],"disallowed_STD3_mapped",[40,4352,41]],[[12801,12801],"disallowed_STD3_mapped",[40,4354,41]],[[12802,12802],"disallowed_STD3_mapped",[40,4355,41]],[[12803,12803],"disallowed_STD3_mapped",[40,4357,41]],[[12804,12804],"disallowed_STD3_mapped",[40,4358,41]],[[12805,12805],"disallowed_STD3_mapped",[40,4359,41]],[[12806,12806],"disallowed_STD3_mapped",[40,4361,41]],[[12807,12807],"disallowed_STD3_mapped",[40,4363,41]],[[12808,12808],"disallowed_STD3_mapped",[40,4364,41]],[[12809,12809],"disallowed_STD3_mapped",[40,4366,41]],[[12810,12810],"disallowed_STD3_mapped",[40,4367,41]],[[12811,12811],"disallowed_STD3_mapped",[40,4368,41]],[[12812,12812],"disallowed_STD3_mapped",[40,4369,41]],[[12813,12813],"disallowed_STD3_mapped",[40,4370,41]],[[12814,12814],"disallowed_STD3_mapped",[40,44032,41]],[[12815,12815],"disallowed_STD3_mapped",[40,45208,41]],[[12816,12816],"disallowed_STD3_mapped",[40,45796,41]],[[12817,12817],"disallowed_STD3_mapped",[40,46972,41]],[[12818,12818],"disallowed_STD3_mapped",[40,47560,41]],[[12819,12819],"disallowed_STD3_mapped",[40,48148,41]],[[12820,12820],"disallowed_STD3_mapped",[40,49324,41]],[[12821,12821],"disallowed_STD3_mapped",[40,50500,41]],[[12822,12822],"disallowed_STD3_mapped",[40,51088,41]],[[12823,12823],"disallowed_STD3_mapped",[40,52264,41]],[[12824,12824],"disallowed_STD3_mapped",[40,52852,41]],[[12825,12825],"disallowed_STD3_mapped",[40,53440,41]],[[12826,12826],"disallowed_STD3_mapped",[40,54028,41]],[[12827,12827],"disallowed_STD3_mapped",[40,54616,41]],[[12828,12828],"disallowed_STD3_mapped",[40,51452,41]],[[12829,12829],"disallowed_STD3_mapped",[40,50724,51204,41]],[[12830,12830],"disallowed_STD3_mapped",[40,50724,54980,41]],[[12831,12831],"disallowed"],[[12832,12832],"disallowed_STD3_mapped",[40,19968,41]],[[12833,12833],"disallowed_STD3_mapped",[40,20108,41]],[[12834,12834],"disallowed_STD3_mapped",[40,19977,41]],[[12835,12835],"disallowed_STD3_mapped",[40,22235,41]],[[12836,12836],"disallowed_STD3_mapped",[40,20116,41]],[[12837,12837],"disallowed_STD3_mapped",[40,20845,41]],[[12838,12838],"disallowed_STD3_mapped",[40,19971,41]],[[12839,12839],"disallowed_STD3_mapped",[40,20843,41]],[[12840,12840],"disallowed_STD3_mapped",[40,20061,41]],[[12841,12841],"disallowed_STD3_mapped",[40,21313,41]],[[12842,12842],"disallowed_STD3_mapped",[40,26376,41]],[[12843,12843],"disallowed_STD3_mapped",[40,28779,41]],[[12844,12844],"disallowed_STD3_mapped",[40,27700,41]],[[12845,12845],"disallowed_STD3_mapped",[40,26408,41]],[[12846,12846],"disallowed_STD3_mapped",[40,37329,41]],[[12847,12847],"disallowed_STD3_mapped",[40,22303,41]],[[12848,12848],"disallowed_STD3_mapped",[40,26085,41]],[[12849,12849],"disallowed_STD3_mapped",[40,26666,41]],[[12850,12850],"disallowed_STD3_mapped",[40,26377,41]],[[12851,12851],"disallowed_STD3_mapped",[40,31038,41]],[[12852,12852],"disallowed_STD3_mapped",[40,21517,41]],[[12853,12853],"disallowed_STD3_mapped",[40,29305,41]],[[12854,12854],"disallowed_STD3_mapped",[40,36001,41]],[[12855,12855],"disallowed_STD3_mapped",[40,31069,41]],[[12856,12856],"disallowed_STD3_mapped",[40,21172,41]],[[12857,12857],"disallowed_STD3_mapped",[40,20195,41]],[[12858,12858],"disallowed_STD3_mapped",[40,21628,41]],[[12859,12859],"disallowed_STD3_mapped",[40,23398,41]],[[12860,12860],"disallowed_STD3_mapped",[40,30435,41]],[[12861,12861],"disallowed_STD3_mapped",[40,20225,41]],[[12862,12862],"disallowed_STD3_mapped",[40,36039,41]],[[12863,12863],"disallowed_STD3_mapped",[40,21332,41]],[[12864,12864],"disallowed_STD3_mapped",[40,31085,41]],[[12865,12865],"disallowed_STD3_mapped",[40,20241,41]],[[12866,12866],"disallowed_STD3_mapped",[40,33258,41]],[[12867,12867],"disallowed_STD3_mapped",[40,33267,41]],[[12868,12868],"mapped",[21839]],[[12869,12869],"mapped",[24188]],[[12870,12870],"mapped",[25991]],[[12871,12871],"mapped",[31631]],[[12872,12879],"valid",[],"NV8"],[[12880,12880],"mapped",[112,116,101]],[[12881,12881],"mapped",[50,49]],[[12882,12882],"mapped",[50,50]],[[12883,12883],"mapped",[50,51]],[[12884,12884],"mapped",[50,52]],[[12885,12885],"mapped",[50,53]],[[12886,12886],"mapped",[50,54]],[[12887,12887],"mapped",[50,55]],[[12888,12888],"mapped",[50,56]],[[12889,12889],"mapped",[50,57]],[[12890,12890],"mapped",[51,48]],[[12891,12891],"mapped",[51,49]],[[12892,12892],"mapped",[51,50]],[[12893,12893],"mapped",[51,51]],[[12894,12894],"mapped",[51,52]],[[12895,12895],"mapped",[51,53]],[[12896,12896],"mapped",[4352]],[[12897,12897],"mapped",[4354]],[[12898,12898],"mapped",[4355]],[[12899,12899],"mapped",[4357]],[[12900,12900],"mapped",[4358]],[[12901,12901],"mapped",[4359]],[[12902,12902],"mapped",[4361]],[[12903,12903],"mapped",[4363]],[[12904,12904],"mapped",[4364]],[[12905,12905],"mapped",[4366]],[[12906,12906],"mapped",[4367]],[[12907,12907],"mapped",[4368]],[[12908,12908],"mapped",[4369]],[[12909,12909],"mapped",[4370]],[[12910,12910],"mapped",[44032]],[[12911,12911],"mapped",[45208]],[[12912,12912],"mapped",[45796]],[[12913,12913],"mapped",[46972]],[[12914,12914],"mapped",[47560]],[[12915,12915],"mapped",[48148]],[[12916,12916],"mapped",[49324]],[[12917,12917],"mapped",[50500]],[[12918,12918],"mapped",[51088]],[[12919,12919],"mapped",[52264]],[[12920,12920],"mapped",[52852]],[[12921,12921],"mapped",[53440]],[[12922,12922],"mapped",[54028]],[[12923,12923],"mapped",[54616]],[[12924,12924],"mapped",[52280,44256]],[[12925,12925],"mapped",[51452,51032]],[[12926,12926],"mapped",[50864]],[[12927,12927],"valid",[],"NV8"],[[12928,12928],"mapped",[19968]],[[12929,12929],"mapped",[20108]],[[12930,12930],"mapped",[19977]],[[12931,12931],"mapped",[22235]],[[12932,12932],"mapped",[20116]],[[12933,12933],"mapped",[20845]],[[12934,12934],"mapped",[19971]],[[12935,12935],"mapped",[20843]],[[12936,12936],"mapped",[20061]],[[12937,12937],"mapped",[21313]],[[12938,12938],"mapped",[26376]],[[12939,12939],"mapped",[28779]],[[12940,12940],"mapped",[27700]],[[12941,12941],"mapped",[26408]],[[12942,12942],"mapped",[37329]],[[12943,12943],"mapped",[22303]],[[12944,12944],"mapped",[26085]],[[12945,12945],"mapped",[26666]],[[12946,12946],"mapped",[26377]],[[12947,12947],"mapped",[31038]],[[12948,12948],"mapped",[21517]],[[12949,12949],"mapped",[29305]],[[12950,12950],"mapped",[36001]],[[12951,12951],"mapped",[31069]],[[12952,12952],"mapped",[21172]],[[12953,12953],"mapped",[31192]],[[12954,12954],"mapped",[30007]],[[12955,12955],"mapped",[22899]],[[12956,12956],"mapped",[36969]],[[12957,12957],"mapped",[20778]],[[12958,12958],"mapped",[21360]],[[12959,12959],"mapped",[27880]],[[12960,12960],"mapped",[38917]],[[12961,12961],"mapped",[20241]],[[12962,12962],"mapped",[20889]],[[12963,12963],"mapped",[27491]],[[12964,12964],"mapped",[19978]],[[12965,12965],"mapped",[20013]],[[12966,12966],"mapped",[19979]],[[12967,12967],"mapped",[24038]],[[12968,12968],"mapped",[21491]],[[12969,12969],"mapped",[21307]],[[12970,12970],"mapped",[23447]],[[12971,12971],"mapped",[23398]],[[12972,12972],"mapped",[30435]],[[12973,12973],"mapped",[20225]],[[12974,12974],"mapped",[36039]],[[12975,12975],"mapped",[21332]],[[12976,12976],"mapped",[22812]],[[12977,12977],"mapped",[51,54]],[[12978,12978],"mapped",[51,55]],[[12979,12979],"mapped",[51,56]],[[12980,12980],"mapped",[51,57]],[[12981,12981],"mapped",[52,48]],[[12982,12982],"mapped",[52,49]],[[12983,12983],"mapped",[52,50]],[[12984,12984],"mapped",[52,51]],[[12985,12985],"mapped",[52,52]],[[12986,12986],"mapped",[52,53]],[[12987,12987],"mapped",[52,54]],[[12988,12988],"mapped",[52,55]],[[12989,12989],"mapped",[52,56]],[[12990,12990],"mapped",[52,57]],[[12991,12991],"mapped",[53,48]],[[12992,12992],"mapped",[49,26376]],[[12993,12993],"mapped",[50,26376]],[[12994,12994],"mapped",[51,26376]],[[12995,12995],"mapped",[52,26376]],[[12996,12996],"mapped",[53,26376]],[[12997,12997],"mapped",[54,26376]],[[12998,12998],"mapped",[55,26376]],[[12999,12999],"mapped",[56,26376]],[[13000,13000],"mapped",[57,26376]],[[13001,13001],"mapped",[49,48,26376]],[[13002,13002],"mapped",[49,49,26376]],[[13003,13003],"mapped",[49,50,26376]],[[13004,13004],"mapped",[104,103]],[[13005,13005],"mapped",[101,114,103]],[[13006,13006],"mapped",[101,118]],[[13007,13007],"mapped",[108,116,100]],[[13008,13008],"mapped",[12450]],[[13009,13009],"mapped",[12452]],[[13010,13010],"mapped",[12454]],[[13011,13011],"mapped",[12456]],[[13012,13012],"mapped",[12458]],[[13013,13013],"mapped",[12459]],[[13014,13014],"mapped",[12461]],[[13015,13015],"mapped",[12463]],[[13016,13016],"mapped",[12465]],[[13017,13017],"mapped",[12467]],[[13018,13018],"mapped",[12469]],[[13019,13019],"mapped",[12471]],[[13020,13020],"mapped",[12473]],[[13021,13021],"mapped",[12475]],[[13022,13022],"mapped",[12477]],[[13023,13023],"mapped",[12479]],[[13024,13024],"mapped",[12481]],[[13025,13025],"mapped",[12484]],[[13026,13026],"mapped",[12486]],[[13027,13027],"mapped",[12488]],[[13028,13028],"mapped",[12490]],[[13029,13029],"mapped",[12491]],[[13030,13030],"mapped",[12492]],[[13031,13031],"mapped",[12493]],[[13032,13032],"mapped",[12494]],[[13033,13033],"mapped",[12495]],[[13034,13034],"mapped",[12498]],[[13035,13035],"mapped",[12501]],[[13036,13036],"mapped",[12504]],[[13037,13037],"mapped",[12507]],[[13038,13038],"mapped",[12510]],[[13039,13039],"mapped",[12511]],[[13040,13040],"mapped",[12512]],[[13041,13041],"mapped",[12513]],[[13042,13042],"mapped",[12514]],[[13043,13043],"mapped",[12516]],[[13044,13044],"mapped",[12518]],[[13045,13045],"mapped",[12520]],[[13046,13046],"mapped",[12521]],[[13047,13047],"mapped",[12522]],[[13048,13048],"mapped",[12523]],[[13049,13049],"mapped",[12524]],[[13050,13050],"mapped",[12525]],[[13051,13051],"mapped",[12527]],[[13052,13052],"mapped",[12528]],[[13053,13053],"mapped",[12529]],[[13054,13054],"mapped",[12530]],[[13055,13055],"disallowed"],[[13056,13056],"mapped",[12450,12497,12540,12488]],[[13057,13057],"mapped",[12450,12523,12501,12449]],[[13058,13058],"mapped",[12450,12531,12506,12450]],[[13059,13059],"mapped",[12450,12540,12523]],[[13060,13060],"mapped",[12452,12491,12531,12464]],[[13061,13061],"mapped",[12452,12531,12481]],[[13062,13062],"mapped",[12454,12457,12531]],[[13063,13063],"mapped",[12456,12473,12463,12540,12489]],[[13064,13064],"mapped",[12456,12540,12459,12540]],[[13065,13065],"mapped",[12458,12531,12473]],[[13066,13066],"mapped",[12458,12540,12512]],[[13067,13067],"mapped",[12459,12452,12522]],[[13068,13068],"mapped",[12459,12521,12483,12488]],[[13069,13069],"mapped",[12459,12525,12522,12540]],[[13070,13070],"mapped",[12460,12525,12531]],[[13071,13071],"mapped",[12460,12531,12510]],[[13072,13072],"mapped",[12462,12460]],[[13073,13073],"mapped",[12462,12491,12540]],[[13074,13074],"mapped",[12461,12517,12522,12540]],[[13075,13075],"mapped",[12462,12523,12480,12540]],[[13076,13076],"mapped",[12461,12525]],[[13077,13077],"mapped",[12461,12525,12464,12521,12512]],[[13078,13078],"mapped",[12461,12525,12513,12540,12488,12523]],[[13079,13079],"mapped",[12461,12525,12527,12483,12488]],[[13080,13080],"mapped",[12464,12521,12512]],[[13081,13081],"mapped",[12464,12521,12512,12488,12531]],[[13082,13082],"mapped",[12463,12523,12476,12452,12525]],[[13083,13083],"mapped",[12463,12525,12540,12493]],[[13084,13084],"mapped",[12465,12540,12473]],[[13085,13085],"mapped",[12467,12523,12490]],[[13086,13086],"mapped",[12467,12540,12509]],[[13087,13087],"mapped",[12469,12452,12463,12523]],[[13088,13088],"mapped",[12469,12531,12481,12540,12512]],[[13089,13089],"mapped",[12471,12522,12531,12464]],[[13090,13090],"mapped",[12475,12531,12481]],[[13091,13091],"mapped",[12475,12531,12488]],[[13092,13092],"mapped",[12480,12540,12473]],[[13093,13093],"mapped",[12487,12471]],[[13094,13094],"mapped",[12489,12523]],[[13095,13095],"mapped",[12488,12531]],[[13096,13096],"mapped",[12490,12494]],[[13097,13097],"mapped",[12494,12483,12488]],[[13098,13098],"mapped",[12495,12452,12484]],[[13099,13099],"mapped",[12497,12540,12475,12531,12488]],[[13100,13100],"mapped",[12497,12540,12484]],[[13101,13101],"mapped",[12496,12540,12524,12523]],[[13102,13102],"mapped",[12500,12450,12473,12488,12523]],[[13103,13103],"mapped",[12500,12463,12523]],[[13104,13104],"mapped",[12500,12467]],[[13105,13105],"mapped",[12499,12523]],[[13106,13106],"mapped",[12501,12449,12521,12483,12489]],[[13107,13107],"mapped",[12501,12451,12540,12488]],[[13108,13108],"mapped",[12502,12483,12471,12455,12523]],[[13109,13109],"mapped",[12501,12521,12531]],[[13110,13110],"mapped",[12504,12463,12479,12540,12523]],[[13111,13111],"mapped",[12506,12477]],[[13112,13112],"mapped",[12506,12491,12498]],[[13113,13113],"mapped",[12504,12523,12484]],[[13114,13114],"mapped",[12506,12531,12473]],[[13115,13115],"mapped",[12506,12540,12472]],[[13116,13116],"mapped",[12505,12540,12479]],[[13117,13117],"mapped",[12509,12452,12531,12488]],[[13118,13118],"mapped",[12508,12523,12488]],[[13119,13119],"mapped",[12507,12531]],[[13120,13120],"mapped",[12509,12531,12489]],[[13121,13121],"mapped",[12507,12540,12523]],[[13122,13122],"mapped",[12507,12540,12531]],[[13123,13123],"mapped",[12510,12452,12463,12525]],[[13124,13124],"mapped",[12510,12452,12523]],[[13125,13125],"mapped",[12510,12483,12495]],[[13126,13126],"mapped",[12510,12523,12463]],[[13127,13127],"mapped",[12510,12531,12471,12519,12531]],[[13128,13128],"mapped",[12511,12463,12525,12531]],[[13129,13129],"mapped",[12511,12522]],[[13130,13130],"mapped",[12511,12522,12496,12540,12523]],[[13131,13131],"mapped",[12513,12460]],[[13132,13132],"mapped",[12513,12460,12488,12531]],[[13133,13133],"mapped",[12513,12540,12488,12523]],[[13134,13134],"mapped",[12516,12540,12489]],[[13135,13135],"mapped",[12516,12540,12523]],[[13136,13136],"mapped",[12518,12450,12531]],[[13137,13137],"mapped",[12522,12483,12488,12523]],[[13138,13138],"mapped",[12522,12521]],[[13139,13139],"mapped",[12523,12500,12540]],[[13140,13140],"mapped",[12523,12540,12502,12523]],[[13141,13141],"mapped",[12524,12512]],[[13142,13142],"mapped",[12524,12531,12488,12466,12531]],[[13143,13143],"mapped",[12527,12483,12488]],[[13144,13144],"mapped",[48,28857]],[[13145,13145],"mapped",[49,28857]],[[13146,13146],"mapped",[50,28857]],[[13147,13147],"mapped",[51,28857]],[[13148,13148],"mapped",[52,28857]],[[13149,13149],"mapped",[53,28857]],[[13150,13150],"mapped",[54,28857]],[[13151,13151],"mapped",[55,28857]],[[13152,13152],"mapped",[56,28857]],[[13153,13153],"mapped",[57,28857]],[[13154,13154],"mapped",[49,48,28857]],[[13155,13155],"mapped",[49,49,28857]],[[13156,13156],"mapped",[49,50,28857]],[[13157,13157],"mapped",[49,51,28857]],[[13158,13158],"mapped",[49,52,28857]],[[13159,13159],"mapped",[49,53,28857]],[[13160,13160],"mapped",[49,54,28857]],[[13161,13161],"mapped",[49,55,28857]],[[13162,13162],"mapped",[49,56,28857]],[[13163,13163],"mapped",[49,57,28857]],[[13164,13164],"mapped",[50,48,28857]],[[13165,13165],"mapped",[50,49,28857]],[[13166,13166],"mapped",[50,50,28857]],[[13167,13167],"mapped",[50,51,28857]],[[13168,13168],"mapped",[50,52,28857]],[[13169,13169],"mapped",[104,112,97]],[[13170,13170],"mapped",[100,97]],[[13171,13171],"mapped",[97,117]],[[13172,13172],"mapped",[98,97,114]],[[13173,13173],"mapped",[111,118]],[[13174,13174],"mapped",[112,99]],[[13175,13175],"mapped",[100,109]],[[13176,13176],"mapped",[100,109,50]],[[13177,13177],"mapped",[100,109,51]],[[13178,13178],"mapped",[105,117]],[[13179,13179],"mapped",[24179,25104]],[[13180,13180],"mapped",[26157,21644]],[[13181,13181],"mapped",[22823,27491]],[[13182,13182],"mapped",[26126,27835]],[[13183,13183],"mapped",[26666,24335,20250,31038]],[[13184,13184],"mapped",[112,97]],[[13185,13185],"mapped",[110,97]],[[13186,13186],"mapped",[956,97]],[[13187,13187],"mapped",[109,97]],[[13188,13188],"mapped",[107,97]],[[13189,13189],"mapped",[107,98]],[[13190,13190],"mapped",[109,98]],[[13191,13191],"mapped",[103,98]],[[13192,13192],"mapped",[99,97,108]],[[13193,13193],"mapped",[107,99,97,108]],[[13194,13194],"mapped",[112,102]],[[13195,13195],"mapped",[110,102]],[[13196,13196],"mapped",[956,102]],[[13197,13197],"mapped",[956,103]],[[13198,13198],"mapped",[109,103]],[[13199,13199],"mapped",[107,103]],[[13200,13200],"mapped",[104,122]],[[13201,13201],"mapped",[107,104,122]],[[13202,13202],"mapped",[109,104,122]],[[13203,13203],"mapped",[103,104,122]],[[13204,13204],"mapped",[116,104,122]],[[13205,13205],"mapped",[956,108]],[[13206,13206],"mapped",[109,108]],[[13207,13207],"mapped",[100,108]],[[13208,13208],"mapped",[107,108]],[[13209,13209],"mapped",[102,109]],[[13210,13210],"mapped",[110,109]],[[13211,13211],"mapped",[956,109]],[[13212,13212],"mapped",[109,109]],[[13213,13213],"mapped",[99,109]],[[13214,13214],"mapped",[107,109]],[[13215,13215],"mapped",[109,109,50]],[[13216,13216],"mapped",[99,109,50]],[[13217,13217],"mapped",[109,50]],[[13218,13218],"mapped",[107,109,50]],[[13219,13219],"mapped",[109,109,51]],[[13220,13220],"mapped",[99,109,51]],[[13221,13221],"mapped",[109,51]],[[13222,13222],"mapped",[107,109,51]],[[13223,13223],"mapped",[109,8725,115]],[[13224,13224],"mapped",[109,8725,115,50]],[[13225,13225],"mapped",[112,97]],[[13226,13226],"mapped",[107,112,97]],[[13227,13227],"mapped",[109,112,97]],[[13228,13228],"mapped",[103,112,97]],[[13229,13229],"mapped",[114,97,100]],[[13230,13230],"mapped",[114,97,100,8725,115]],[[13231,13231],"mapped",[114,97,100,8725,115,50]],[[13232,13232],"mapped",[112,115]],[[13233,13233],"mapped",[110,115]],[[13234,13234],"mapped",[956,115]],[[13235,13235],"mapped",[109,115]],[[13236,13236],"mapped",[112,118]],[[13237,13237],"mapped",[110,118]],[[13238,13238],"mapped",[956,118]],[[13239,13239],"mapped",[109,118]],[[13240,13240],"mapped",[107,118]],[[13241,13241],"mapped",[109,118]],[[13242,13242],"mapped",[112,119]],[[13243,13243],"mapped",[110,119]],[[13244,13244],"mapped",[956,119]],[[13245,13245],"mapped",[109,119]],[[13246,13246],"mapped",[107,119]],[[13247,13247],"mapped",[109,119]],[[13248,13248],"mapped",[107,969]],[[13249,13249],"mapped",[109,969]],[[13250,13250],"disallowed"],[[13251,13251],"mapped",[98,113]],[[13252,13252],"mapped",[99,99]],[[13253,13253],"mapped",[99,100]],[[13254,13254],"mapped",[99,8725,107,103]],[[13255,13255],"disallowed"],[[13256,13256],"mapped",[100,98]],[[13257,13257],"mapped",[103,121]],[[13258,13258],"mapped",[104,97]],[[13259,13259],"mapped",[104,112]],[[13260,13260],"mapped",[105,110]],[[13261,13261],"mapped",[107,107]],[[13262,13262],"mapped",[107,109]],[[13263,13263],"mapped",[107,116]],[[13264,13264],"mapped",[108,109]],[[13265,13265],"mapped",[108,110]],[[13266,13266],"mapped",[108,111,103]],[[13267,13267],"mapped",[108,120]],[[13268,13268],"mapped",[109,98]],[[13269,13269],"mapped",[109,105,108]],[[13270,13270],"mapped",[109,111,108]],[[13271,13271],"mapped",[112,104]],[[13272,13272],"disallowed"],[[13273,13273],"mapped",[112,112,109]],[[13274,13274],"mapped",[112,114]],[[13275,13275],"mapped",[115,114]],[[13276,13276],"mapped",[115,118]],[[13277,13277],"mapped",[119,98]],[[13278,13278],"mapped",[118,8725,109]],[[13279,13279],"mapped",[97,8725,109]],[[13280,13280],"mapped",[49,26085]],[[13281,13281],"mapped",[50,26085]],[[13282,13282],"mapped",[51,26085]],[[13283,13283],"mapped",[52,26085]],[[13284,13284],"mapped",[53,26085]],[[13285,13285],"mapped",[54,26085]],[[13286,13286],"mapped",[55,26085]],[[13287,13287],"mapped",[56,26085]],[[13288,13288],"mapped",[57,26085]],[[13289,13289],"mapped",[49,48,26085]],[[13290,13290],"mapped",[49,49,26085]],[[13291,13291],"mapped",[49,50,26085]],[[13292,13292],"mapped",[49,51,26085]],[[13293,13293],"mapped",[49,52,26085]],[[13294,13294],"mapped",[49,53,26085]],[[13295,13295],"mapped",[49,54,26085]],[[13296,13296],"mapped",[49,55,26085]],[[13297,13297],"mapped",[49,56,26085]],[[13298,13298],"mapped",[49,57,26085]],[[13299,13299],"mapped",[50,48,26085]],[[13300,13300],"mapped",[50,49,26085]],[[13301,13301],"mapped",[50,50,26085]],[[13302,13302],"mapped",[50,51,26085]],[[13303,13303],"mapped",[50,52,26085]],[[13304,13304],"mapped",[50,53,26085]],[[13305,13305],"mapped",[50,54,26085]],[[13306,13306],"mapped",[50,55,26085]],[[13307,13307],"mapped",[50,56,26085]],[[13308,13308],"mapped",[50,57,26085]],[[13309,13309],"mapped",[51,48,26085]],[[13310,13310],"mapped",[51,49,26085]],[[13311,13311],"mapped",[103,97,108]],[[13312,19893],"valid"],[[19894,19903],"disallowed"],[[19904,19967],"valid",[],"NV8"],[[19968,40869],"valid"],[[40870,40891],"valid"],[[40892,40899],"valid"],[[40900,40907],"valid"],[[40908,40908],"valid"],[[40909,40917],"valid"],[[40918,40959],"disallowed"],[[40960,42124],"valid"],[[42125,42127],"disallowed"],[[42128,42145],"valid",[],"NV8"],[[42146,42147],"valid",[],"NV8"],[[42148,42163],"valid",[],"NV8"],[[42164,42164],"valid",[],"NV8"],[[42165,42176],"valid",[],"NV8"],[[42177,42177],"valid",[],"NV8"],[[42178,42180],"valid",[],"NV8"],[[42181,42181],"valid",[],"NV8"],[[42182,42182],"valid",[],"NV8"],[[42183,42191],"disallowed"],[[42192,42237],"valid"],[[42238,42239],"valid",[],"NV8"],[[42240,42508],"valid"],[[42509,42511],"valid",[],"NV8"],[[42512,42539],"valid"],[[42540,42559],"disallowed"],[[42560,42560],"mapped",[42561]],[[42561,42561],"valid"],[[42562,42562],"mapped",[42563]],[[42563,42563],"valid"],[[42564,42564],"mapped",[42565]],[[42565,42565],"valid"],[[42566,42566],"mapped",[42567]],[[42567,42567],"valid"],[[42568,42568],"mapped",[42569]],[[42569,42569],"valid"],[[42570,42570],"mapped",[42571]],[[42571,42571],"valid"],[[42572,42572],"mapped",[42573]],[[42573,42573],"valid"],[[42574,42574],"mapped",[42575]],[[42575,42575],"valid"],[[42576,42576],"mapped",[42577]],[[42577,42577],"valid"],[[42578,42578],"mapped",[42579]],[[42579,42579],"valid"],[[42580,42580],"mapped",[42581]],[[42581,42581],"valid"],[[42582,42582],"mapped",[42583]],[[42583,42583],"valid"],[[42584,42584],"mapped",[42585]],[[42585,42585],"valid"],[[42586,42586],"mapped",[42587]],[[42587,42587],"valid"],[[42588,42588],"mapped",[42589]],[[42589,42589],"valid"],[[42590,42590],"mapped",[42591]],[[42591,42591],"valid"],[[42592,42592],"mapped",[42593]],[[42593,42593],"valid"],[[42594,42594],"mapped",[42595]],[[42595,42595],"valid"],[[42596,42596],"mapped",[42597]],[[42597,42597],"valid"],[[42598,42598],"mapped",[42599]],[[42599,42599],"valid"],[[42600,42600],"mapped",[42601]],[[42601,42601],"valid"],[[42602,42602],"mapped",[42603]],[[42603,42603],"valid"],[[42604,42604],"mapped",[42605]],[[42605,42607],"valid"],[[42608,42611],"valid",[],"NV8"],[[42612,42619],"valid"],[[42620,42621],"valid"],[[42622,42622],"valid",[],"NV8"],[[42623,42623],"valid"],[[42624,42624],"mapped",[42625]],[[42625,42625],"valid"],[[42626,42626],"mapped",[42627]],[[42627,42627],"valid"],[[42628,42628],"mapped",[42629]],[[42629,42629],"valid"],[[42630,42630],"mapped",[42631]],[[42631,42631],"valid"],[[42632,42632],"mapped",[42633]],[[42633,42633],"valid"],[[42634,42634],"mapped",[42635]],[[42635,42635],"valid"],[[42636,42636],"mapped",[42637]],[[42637,42637],"valid"],[[42638,42638],"mapped",[42639]],[[42639,42639],"valid"],[[42640,42640],"mapped",[42641]],[[42641,42641],"valid"],[[42642,42642],"mapped",[42643]],[[42643,42643],"valid"],[[42644,42644],"mapped",[42645]],[[42645,42645],"valid"],[[42646,42646],"mapped",[42647]],[[42647,42647],"valid"],[[42648,42648],"mapped",[42649]],[[42649,42649],"valid"],[[42650,42650],"mapped",[42651]],[[42651,42651],"valid"],[[42652,42652],"mapped",[1098]],[[42653,42653],"mapped",[1100]],[[42654,42654],"valid"],[[42655,42655],"valid"],[[42656,42725],"valid"],[[42726,42735],"valid",[],"NV8"],[[42736,42737],"valid"],[[42738,42743],"valid",[],"NV8"],[[42744,42751],"disallowed"],[[42752,42774],"valid",[],"NV8"],[[42775,42778],"valid"],[[42779,42783],"valid"],[[42784,42785],"valid",[],"NV8"],[[42786,42786],"mapped",[42787]],[[42787,42787],"valid"],[[42788,42788],"mapped",[42789]],[[42789,42789],"valid"],[[42790,42790],"mapped",[42791]],[[42791,42791],"valid"],[[42792,42792],"mapped",[42793]],[[42793,42793],"valid"],[[42794,42794],"mapped",[42795]],[[42795,42795],"valid"],[[42796,42796],"mapped",[42797]],[[42797,42797],"valid"],[[42798,42798],"mapped",[42799]],[[42799,42801],"valid"],[[42802,42802],"mapped",[42803]],[[42803,42803],"valid"],[[42804,42804],"mapped",[42805]],[[42805,42805],"valid"],[[42806,42806],"mapped",[42807]],[[42807,42807],"valid"],[[42808,42808],"mapped",[42809]],[[42809,42809],"valid"],[[42810,42810],"mapped",[42811]],[[42811,42811],"valid"],[[42812,42812],"mapped",[42813]],[[42813,42813],"valid"],[[42814,42814],"mapped",[42815]],[[42815,42815],"valid"],[[42816,42816],"mapped",[42817]],[[42817,42817],"valid"],[[42818,42818],"mapped",[42819]],[[42819,42819],"valid"],[[42820,42820],"mapped",[42821]],[[42821,42821],"valid"],[[42822,42822],"mapped",[42823]],[[42823,42823],"valid"],[[42824,42824],"mapped",[42825]],[[42825,42825],"valid"],[[42826,42826],"mapped",[42827]],[[42827,42827],"valid"],[[42828,42828],"mapped",[42829]],[[42829,42829],"valid"],[[42830,42830],"mapped",[42831]],[[42831,42831],"valid"],[[42832,42832],"mapped",[42833]],[[42833,42833],"valid"],[[42834,42834],"mapped",[42835]],[[42835,42835],"valid"],[[42836,42836],"mapped",[42837]],[[42837,42837],"valid"],[[42838,42838],"mapped",[42839]],[[42839,42839],"valid"],[[42840,42840],"mapped",[42841]],[[42841,42841],"valid"],[[42842,42842],"mapped",[42843]],[[42843,42843],"valid"],[[42844,42844],"mapped",[42845]],[[42845,42845],"valid"],[[42846,42846],"mapped",[42847]],[[42847,42847],"valid"],[[42848,42848],"mapped",[42849]],[[42849,42849],"valid"],[[42850,42850],"mapped",[42851]],[[42851,42851],"valid"],[[42852,42852],"mapped",[42853]],[[42853,42853],"valid"],[[42854,42854],"mapped",[42855]],[[42855,42855],"valid"],[[42856,42856],"mapped",[42857]],[[42857,42857],"valid"],[[42858,42858],"mapped",[42859]],[[42859,42859],"valid"],[[42860,42860],"mapped",[42861]],[[42861,42861],"valid"],[[42862,42862],"mapped",[42863]],[[42863,42863],"valid"],[[42864,42864],"mapped",[42863]],[[42865,42872],"valid"],[[42873,42873],"mapped",[42874]],[[42874,42874],"valid"],[[42875,42875],"mapped",[42876]],[[42876,42876],"valid"],[[42877,42877],"mapped",[7545]],[[42878,42878],"mapped",[42879]],[[42879,42879],"valid"],[[42880,42880],"mapped",[42881]],[[42881,42881],"valid"],[[42882,42882],"mapped",[42883]],[[42883,42883],"valid"],[[42884,42884],"mapped",[42885]],[[42885,42885],"valid"],[[42886,42886],"mapped",[42887]],[[42887,42888],"valid"],[[42889,42890],"valid",[],"NV8"],[[42891,42891],"mapped",[42892]],[[42892,42892],"valid"],[[42893,42893],"mapped",[613]],[[42894,42894],"valid"],[[42895,42895],"valid"],[[42896,42896],"mapped",[42897]],[[42897,42897],"valid"],[[42898,42898],"mapped",[42899]],[[42899,42899],"valid"],[[42900,42901],"valid"],[[42902,42902],"mapped",[42903]],[[42903,42903],"valid"],[[42904,42904],"mapped",[42905]],[[42905,42905],"valid"],[[42906,42906],"mapped",[42907]],[[42907,42907],"valid"],[[42908,42908],"mapped",[42909]],[[42909,42909],"valid"],[[42910,42910],"mapped",[42911]],[[42911,42911],"valid"],[[42912,42912],"mapped",[42913]],[[42913,42913],"valid"],[[42914,42914],"mapped",[42915]],[[42915,42915],"valid"],[[42916,42916],"mapped",[42917]],[[42917,42917],"valid"],[[42918,42918],"mapped",[42919]],[[42919,42919],"valid"],[[42920,42920],"mapped",[42921]],[[42921,42921],"valid"],[[42922,42922],"mapped",[614]],[[42923,42923],"mapped",[604]],[[42924,42924],"mapped",[609]],[[42925,42925],"mapped",[620]],[[42926,42927],"disallowed"],[[42928,42928],"mapped",[670]],[[42929,42929],"mapped",[647]],[[42930,42930],"mapped",[669]],[[42931,42931],"mapped",[43859]],[[42932,42932],"mapped",[42933]],[[42933,42933],"valid"],[[42934,42934],"mapped",[42935]],[[42935,42935],"valid"],[[42936,42998],"disallowed"],[[42999,42999],"valid"],[[43000,43000],"mapped",[295]],[[43001,43001],"mapped",[339]],[[43002,43002],"valid"],[[43003,43007],"valid"],[[43008,43047],"valid"],[[43048,43051],"valid",[],"NV8"],[[43052,43055],"disallowed"],[[43056,43065],"valid",[],"NV8"],[[43066,43071],"disallowed"],[[43072,43123],"valid"],[[43124,43127],"valid",[],"NV8"],[[43128,43135],"disallowed"],[[43136,43204],"valid"],[[43205,43213],"disallowed"],[[43214,43215],"valid",[],"NV8"],[[43216,43225],"valid"],[[43226,43231],"disallowed"],[[43232,43255],"valid"],[[43256,43258],"valid",[],"NV8"],[[43259,43259],"valid"],[[43260,43260],"valid",[],"NV8"],[[43261,43261],"valid"],[[43262,43263],"disallowed"],[[43264,43309],"valid"],[[43310,43311],"valid",[],"NV8"],[[43312,43347],"valid"],[[43348,43358],"disallowed"],[[43359,43359],"valid",[],"NV8"],[[43360,43388],"valid",[],"NV8"],[[43389,43391],"disallowed"],[[43392,43456],"valid"],[[43457,43469],"valid",[],"NV8"],[[43470,43470],"disallowed"],[[43471,43481],"valid"],[[43482,43485],"disallowed"],[[43486,43487],"valid",[],"NV8"],[[43488,43518],"valid"],[[43519,43519],"disallowed"],[[43520,43574],"valid"],[[43575,43583],"disallowed"],[[43584,43597],"valid"],[[43598,43599],"disallowed"],[[43600,43609],"valid"],[[43610,43611],"disallowed"],[[43612,43615],"valid",[],"NV8"],[[43616,43638],"valid"],[[43639,43641],"valid",[],"NV8"],[[43642,43643],"valid"],[[43644,43647],"valid"],[[43648,43714],"valid"],[[43715,43738],"disallowed"],[[43739,43741],"valid"],[[43742,43743],"valid",[],"NV8"],[[43744,43759],"valid"],[[43760,43761],"valid",[],"NV8"],[[43762,43766],"valid"],[[43767,43776],"disallowed"],[[43777,43782],"valid"],[[43783,43784],"disallowed"],[[43785,43790],"valid"],[[43791,43792],"disallowed"],[[43793,43798],"valid"],[[43799,43807],"disallowed"],[[43808,43814],"valid"],[[43815,43815],"disallowed"],[[43816,43822],"valid"],[[43823,43823],"disallowed"],[[43824,43866],"valid"],[[43867,43867],"valid",[],"NV8"],[[43868,43868],"mapped",[42791]],[[43869,43869],"mapped",[43831]],[[43870,43870],"mapped",[619]],[[43871,43871],"mapped",[43858]],[[43872,43875],"valid"],[[43876,43877],"valid"],[[43878,43887],"disallowed"],[[43888,43888],"mapped",[5024]],[[43889,43889],"mapped",[5025]],[[43890,43890],"mapped",[5026]],[[43891,43891],"mapped",[5027]],[[43892,43892],"mapped",[5028]],[[43893,43893],"mapped",[5029]],[[43894,43894],"mapped",[5030]],[[43895,43895],"mapped",[5031]],[[43896,43896],"mapped",[5032]],[[43897,43897],"mapped",[5033]],[[43898,43898],"mapped",[5034]],[[43899,43899],"mapped",[5035]],[[43900,43900],"mapped",[5036]],[[43901,43901],"mapped",[5037]],[[43902,43902],"mapped",[5038]],[[43903,43903],"mapped",[5039]],[[43904,43904],"mapped",[5040]],[[43905,43905],"mapped",[5041]],[[43906,43906],"mapped",[5042]],[[43907,43907],"mapped",[5043]],[[43908,43908],"mapped",[5044]],[[43909,43909],"mapped",[5045]],[[43910,43910],"mapped",[5046]],[[43911,43911],"mapped",[5047]],[[43912,43912],"mapped",[5048]],[[43913,43913],"mapped",[5049]],[[43914,43914],"mapped",[5050]],[[43915,43915],"mapped",[5051]],[[43916,43916],"mapped",[5052]],[[43917,43917],"mapped",[5053]],[[43918,43918],"mapped",[5054]],[[43919,43919],"mapped",[5055]],[[43920,43920],"mapped",[5056]],[[43921,43921],"mapped",[5057]],[[43922,43922],"mapped",[5058]],[[43923,43923],"mapped",[5059]],[[43924,43924],"mapped",[5060]],[[43925,43925],"mapped",[5061]],[[43926,43926],"mapped",[5062]],[[43927,43927],"mapped",[5063]],[[43928,43928],"mapped",[5064]],[[43929,43929],"mapped",[5065]],[[43930,43930],"mapped",[5066]],[[43931,43931],"mapped",[5067]],[[43932,43932],"mapped",[5068]],[[43933,43933],"mapped",[5069]],[[43934,43934],"mapped",[5070]],[[43935,43935],"mapped",[5071]],[[43936,43936],"mapped",[5072]],[[43937,43937],"mapped",[5073]],[[43938,43938],"mapped",[5074]],[[43939,43939],"mapped",[5075]],[[43940,43940],"mapped",[5076]],[[43941,43941],"mapped",[5077]],[[43942,43942],"mapped",[5078]],[[43943,43943],"mapped",[5079]],[[43944,43944],"mapped",[5080]],[[43945,43945],"mapped",[5081]],[[43946,43946],"mapped",[5082]],[[43947,43947],"mapped",[5083]],[[43948,43948],"mapped",[5084]],[[43949,43949],"mapped",[5085]],[[43950,43950],"mapped",[5086]],[[43951,43951],"mapped",[5087]],[[43952,43952],"mapped",[5088]],[[43953,43953],"mapped",[5089]],[[43954,43954],"mapped",[5090]],[[43955,43955],"mapped",[5091]],[[43956,43956],"mapped",[5092]],[[43957,43957],"mapped",[5093]],[[43958,43958],"mapped",[5094]],[[43959,43959],"mapped",[5095]],[[43960,43960],"mapped",[5096]],[[43961,43961],"mapped",[5097]],[[43962,43962],"mapped",[5098]],[[43963,43963],"mapped",[5099]],[[43964,43964],"mapped",[5100]],[[43965,43965],"mapped",[5101]],[[43966,43966],"mapped",[5102]],[[43967,43967],"mapped",[5103]],[[43968,44010],"valid"],[[44011,44011],"valid",[],"NV8"],[[44012,44013],"valid"],[[44014,44015],"disallowed"],[[44016,44025],"valid"],[[44026,44031],"disallowed"],[[44032,55203],"valid"],[[55204,55215],"disallowed"],[[55216,55238],"valid",[],"NV8"],[[55239,55242],"disallowed"],[[55243,55291],"valid",[],"NV8"],[[55292,55295],"disallowed"],[[55296,57343],"disallowed"],[[57344,63743],"disallowed"],[[63744,63744],"mapped",[35912]],[[63745,63745],"mapped",[26356]],[[63746,63746],"mapped",[36554]],[[63747,63747],"mapped",[36040]],[[63748,63748],"mapped",[28369]],[[63749,63749],"mapped",[20018]],[[63750,63750],"mapped",[21477]],[[63751,63752],"mapped",[40860]],[[63753,63753],"mapped",[22865]],[[63754,63754],"mapped",[37329]],[[63755,63755],"mapped",[21895]],[[63756,63756],"mapped",[22856]],[[63757,63757],"mapped",[25078]],[[63758,63758],"mapped",[30313]],[[63759,63759],"mapped",[32645]],[[63760,63760],"mapped",[34367]],[[63761,63761],"mapped",[34746]],[[63762,63762],"mapped",[35064]],[[63763,63763],"mapped",[37007]],[[63764,63764],"mapped",[27138]],[[63765,63765],"mapped",[27931]],[[63766,63766],"mapped",[28889]],[[63767,63767],"mapped",[29662]],[[63768,63768],"mapped",[33853]],[[63769,63769],"mapped",[37226]],[[63770,63770],"mapped",[39409]],[[63771,63771],"mapped",[20098]],[[63772,63772],"mapped",[21365]],[[63773,63773],"mapped",[27396]],[[63774,63774],"mapped",[29211]],[[63775,63775],"mapped",[34349]],[[63776,63776],"mapped",[40478]],[[63777,63777],"mapped",[23888]],[[63778,63778],"mapped",[28651]],[[63779,63779],"mapped",[34253]],[[63780,63780],"mapped",[35172]],[[63781,63781],"mapped",[25289]],[[63782,63782],"mapped",[33240]],[[63783,63783],"mapped",[34847]],[[63784,63784],"mapped",[24266]],[[63785,63785],"mapped",[26391]],[[63786,63786],"mapped",[28010]],[[63787,63787],"mapped",[29436]],[[63788,63788],"mapped",[37070]],[[63789,63789],"mapped",[20358]],[[63790,63790],"mapped",[20919]],[[63791,63791],"mapped",[21214]],[[63792,63792],"mapped",[25796]],[[63793,63793],"mapped",[27347]],[[63794,63794],"mapped",[29200]],[[63795,63795],"mapped",[30439]],[[63796,63796],"mapped",[32769]],[[63797,63797],"mapped",[34310]],[[63798,63798],"mapped",[34396]],[[63799,63799],"mapped",[36335]],[[63800,63800],"mapped",[38706]],[[63801,63801],"mapped",[39791]],[[63802,63802],"mapped",[40442]],[[63803,63803],"mapped",[30860]],[[63804,63804],"mapped",[31103]],[[63805,63805],"mapped",[32160]],[[63806,63806],"mapped",[33737]],[[63807,63807],"mapped",[37636]],[[63808,63808],"mapped",[40575]],[[63809,63809],"mapped",[35542]],[[63810,63810],"mapped",[22751]],[[63811,63811],"mapped",[24324]],[[63812,63812],"mapped",[31840]],[[63813,63813],"mapped",[32894]],[[63814,63814],"mapped",[29282]],[[63815,63815],"mapped",[30922]],[[63816,63816],"mapped",[36034]],[[63817,63817],"mapped",[38647]],[[63818,63818],"mapped",[22744]],[[63819,63819],"mapped",[23650]],[[63820,63820],"mapped",[27155]],[[63821,63821],"mapped",[28122]],[[63822,63822],"mapped",[28431]],[[63823,63823],"mapped",[32047]],[[63824,63824],"mapped",[32311]],[[63825,63825],"mapped",[38475]],[[63826,63826],"mapped",[21202]],[[63827,63827],"mapped",[32907]],[[63828,63828],"mapped",[20956]],[[63829,63829],"mapped",[20940]],[[63830,63830],"mapped",[31260]],[[63831,63831],"mapped",[32190]],[[63832,63832],"mapped",[33777]],[[63833,63833],"mapped",[38517]],[[63834,63834],"mapped",[35712]],[[63835,63835],"mapped",[25295]],[[63836,63836],"mapped",[27138]],[[63837,63837],"mapped",[35582]],[[63838,63838],"mapped",[20025]],[[63839,63839],"mapped",[23527]],[[63840,63840],"mapped",[24594]],[[63841,63841],"mapped",[29575]],[[63842,63842],"mapped",[30064]],[[63843,63843],"mapped",[21271]],[[63844,63844],"mapped",[30971]],[[63845,63845],"mapped",[20415]],[[63846,63846],"mapped",[24489]],[[63847,63847],"mapped",[19981]],[[63848,63848],"mapped",[27852]],[[63849,63849],"mapped",[25976]],[[63850,63850],"mapped",[32034]],[[63851,63851],"mapped",[21443]],[[63852,63852],"mapped",[22622]],[[63853,63853],"mapped",[30465]],[[63854,63854],"mapped",[33865]],[[63855,63855],"mapped",[35498]],[[63856,63856],"mapped",[27578]],[[63857,63857],"mapped",[36784]],[[63858,63858],"mapped",[27784]],[[63859,63859],"mapped",[25342]],[[63860,63860],"mapped",[33509]],[[63861,63861],"mapped",[25504]],[[63862,63862],"mapped",[30053]],[[63863,63863],"mapped",[20142]],[[63864,63864],"mapped",[20841]],[[63865,63865],"mapped",[20937]],[[63866,63866],"mapped",[26753]],[[63867,63867],"mapped",[31975]],[[63868,63868],"mapped",[33391]],[[63869,63869],"mapped",[35538]],[[63870,63870],"mapped",[37327]],[[63871,63871],"mapped",[21237]],[[63872,63872],"mapped",[21570]],[[63873,63873],"mapped",[22899]],[[63874,63874],"mapped",[24300]],[[63875,63875],"mapped",[26053]],[[63876,63876],"mapped",[28670]],[[63877,63877],"mapped",[31018]],[[63878,63878],"mapped",[38317]],[[63879,63879],"mapped",[39530]],[[63880,63880],"mapped",[40599]],[[63881,63881],"mapped",[40654]],[[63882,63882],"mapped",[21147]],[[63883,63883],"mapped",[26310]],[[63884,63884],"mapped",[27511]],[[63885,63885],"mapped",[36706]],[[63886,63886],"mapped",[24180]],[[63887,63887],"mapped",[24976]],[[63888,63888],"mapped",[25088]],[[63889,63889],"mapped",[25754]],[[63890,63890],"mapped",[28451]],[[63891,63891],"mapped",[29001]],[[63892,63892],"mapped",[29833]],[[63893,63893],"mapped",[31178]],[[63894,63894],"mapped",[32244]],[[63895,63895],"mapped",[32879]],[[63896,63896],"mapped",[36646]],[[63897,63897],"mapped",[34030]],[[63898,63898],"mapped",[36899]],[[63899,63899],"mapped",[37706]],[[63900,63900],"mapped",[21015]],[[63901,63901],"mapped",[21155]],[[63902,63902],"mapped",[21693]],[[63903,63903],"mapped",[28872]],[[63904,63904],"mapped",[35010]],[[63905,63905],"mapped",[35498]],[[63906,63906],"mapped",[24265]],[[63907,63907],"mapped",[24565]],[[63908,63908],"mapped",[25467]],[[63909,63909],"mapped",[27566]],[[63910,63910],"mapped",[31806]],[[63911,63911],"mapped",[29557]],[[63912,63912],"mapped",[20196]],[[63913,63913],"mapped",[22265]],[[63914,63914],"mapped",[23527]],[[63915,63915],"mapped",[23994]],[[63916,63916],"mapped",[24604]],[[63917,63917],"mapped",[29618]],[[63918,63918],"mapped",[29801]],[[63919,63919],"mapped",[32666]],[[63920,63920],"mapped",[32838]],[[63921,63921],"mapped",[37428]],[[63922,63922],"mapped",[38646]],[[63923,63923],"mapped",[38728]],[[63924,63924],"mapped",[38936]],[[63925,63925],"mapped",[20363]],[[63926,63926],"mapped",[31150]],[[63927,63927],"mapped",[37300]],[[63928,63928],"mapped",[38584]],[[63929,63929],"mapped",[24801]],[[63930,63930],"mapped",[20102]],[[63931,63931],"mapped",[20698]],[[63932,63932],"mapped",[23534]],[[63933,63933],"mapped",[23615]],[[63934,63934],"mapped",[26009]],[[63935,63935],"mapped",[27138]],[[63936,63936],"mapped",[29134]],[[63937,63937],"mapped",[30274]],[[63938,63938],"mapped",[34044]],[[63939,63939],"mapped",[36988]],[[63940,63940],"mapped",[40845]],[[63941,63941],"mapped",[26248]],[[63942,63942],"mapped",[38446]],[[63943,63943],"mapped",[21129]],[[63944,63944],"mapped",[26491]],[[63945,63945],"mapped",[26611]],[[63946,63946],"mapped",[27969]],[[63947,63947],"mapped",[28316]],[[63948,63948],"mapped",[29705]],[[63949,63949],"mapped",[30041]],[[63950,63950],"mapped",[30827]],[[63951,63951],"mapped",[32016]],[[63952,63952],"mapped",[39006]],[[63953,63953],"mapped",[20845]],[[63954,63954],"mapped",[25134]],[[63955,63955],"mapped",[38520]],[[63956,63956],"mapped",[20523]],[[63957,63957],"mapped",[23833]],[[63958,63958],"mapped",[28138]],[[63959,63959],"mapped",[36650]],[[63960,63960],"mapped",[24459]],[[63961,63961],"mapped",[24900]],[[63962,63962],"mapped",[26647]],[[63963,63963],"mapped",[29575]],[[63964,63964],"mapped",[38534]],[[63965,63965],"mapped",[21033]],[[63966,63966],"mapped",[21519]],[[63967,63967],"mapped",[23653]],[[63968,63968],"mapped",[26131]],[[63969,63969],"mapped",[26446]],[[63970,63970],"mapped",[26792]],[[63971,63971],"mapped",[27877]],[[63972,63972],"mapped",[29702]],[[63973,63973],"mapped",[30178]],[[63974,63974],"mapped",[32633]],[[63975,63975],"mapped",[35023]],[[63976,63976],"mapped",[35041]],[[63977,63977],"mapped",[37324]],[[63978,63978],"mapped",[38626]],[[63979,63979],"mapped",[21311]],[[63980,63980],"mapped",[28346]],[[63981,63981],"mapped",[21533]],[[63982,63982],"mapped",[29136]],[[63983,63983],"mapped",[29848]],[[63984,63984],"mapped",[34298]],[[63985,63985],"mapped",[38563]],[[63986,63986],"mapped",[40023]],[[63987,63987],"mapped",[40607]],[[63988,63988],"mapped",[26519]],[[63989,63989],"mapped",[28107]],[[63990,63990],"mapped",[33256]],[[63991,63991],"mapped",[31435]],[[63992,63992],"mapped",[31520]],[[63993,63993],"mapped",[31890]],[[63994,63994],"mapped",[29376]],[[63995,63995],"mapped",[28825]],[[63996,63996],"mapped",[35672]],[[63997,63997],"mapped",[20160]],[[63998,63998],"mapped",[33590]],[[63999,63999],"mapped",[21050]],[[64000,64000],"mapped",[20999]],[[64001,64001],"mapped",[24230]],[[64002,64002],"mapped",[25299]],[[64003,64003],"mapped",[31958]],[[64004,64004],"mapped",[23429]],[[64005,64005],"mapped",[27934]],[[64006,64006],"mapped",[26292]],[[64007,64007],"mapped",[36667]],[[64008,64008],"mapped",[34892]],[[64009,64009],"mapped",[38477]],[[64010,64010],"mapped",[35211]],[[64011,64011],"mapped",[24275]],[[64012,64012],"mapped",[20800]],[[64013,64013],"mapped",[21952]],[[64014,64015],"valid"],[[64016,64016],"mapped",[22618]],[[64017,64017],"valid"],[[64018,64018],"mapped",[26228]],[[64019,64020],"valid"],[[64021,64021],"mapped",[20958]],[[64022,64022],"mapped",[29482]],[[64023,64023],"mapped",[30410]],[[64024,64024],"mapped",[31036]],[[64025,64025],"mapped",[31070]],[[64026,64026],"mapped",[31077]],[[64027,64027],"mapped",[31119]],[[64028,64028],"mapped",[38742]],[[64029,64029],"mapped",[31934]],[[64030,64030],"mapped",[32701]],[[64031,64031],"valid"],[[64032,64032],"mapped",[34322]],[[64033,64033],"valid"],[[64034,64034],"mapped",[35576]],[[64035,64036],"valid"],[[64037,64037],"mapped",[36920]],[[64038,64038],"mapped",[37117]],[[64039,64041],"valid"],[[64042,64042],"mapped",[39151]],[[64043,64043],"mapped",[39164]],[[64044,64044],"mapped",[39208]],[[64045,64045],"mapped",[40372]],[[64046,64046],"mapped",[37086]],[[64047,64047],"mapped",[38583]],[[64048,64048],"mapped",[20398]],[[64049,64049],"mapped",[20711]],[[64050,64050],"mapped",[20813]],[[64051,64051],"mapped",[21193]],[[64052,64052],"mapped",[21220]],[[64053,64053],"mapped",[21329]],[[64054,64054],"mapped",[21917]],[[64055,64055],"mapped",[22022]],[[64056,64056],"mapped",[22120]],[[64057,64057],"mapped",[22592]],[[64058,64058],"mapped",[22696]],[[64059,64059],"mapped",[23652]],[[64060,64060],"mapped",[23662]],[[64061,64061],"mapped",[24724]],[[64062,64062],"mapped",[24936]],[[64063,64063],"mapped",[24974]],[[64064,64064],"mapped",[25074]],[[64065,64065],"mapped",[25935]],[[64066,64066],"mapped",[26082]],[[64067,64067],"mapped",[26257]],[[64068,64068],"mapped",[26757]],[[64069,64069],"mapped",[28023]],[[64070,64070],"mapped",[28186]],[[64071,64071],"mapped",[28450]],[[64072,64072],"mapped",[29038]],[[64073,64073],"mapped",[29227]],[[64074,64074],"mapped",[29730]],[[64075,64075],"mapped",[30865]],[[64076,64076],"mapped",[31038]],[[64077,64077],"mapped",[31049]],[[64078,64078],"mapped",[31048]],[[64079,64079],"mapped",[31056]],[[64080,64080],"mapped",[31062]],[[64081,64081],"mapped",[31069]],[[64082,64082],"mapped",[31117]],[[64083,64083],"mapped",[31118]],[[64084,64084],"mapped",[31296]],[[64085,64085],"mapped",[31361]],[[64086,64086],"mapped",[31680]],[[64087,64087],"mapped",[32244]],[[64088,64088],"mapped",[32265]],[[64089,64089],"mapped",[32321]],[[64090,64090],"mapped",[32626]],[[64091,64091],"mapped",[32773]],[[64092,64092],"mapped",[33261]],[[64093,64094],"mapped",[33401]],[[64095,64095],"mapped",[33879]],[[64096,64096],"mapped",[35088]],[[64097,64097],"mapped",[35222]],[[64098,64098],"mapped",[35585]],[[64099,64099],"mapped",[35641]],[[64100,64100],"mapped",[36051]],[[64101,64101],"mapped",[36104]],[[64102,64102],"mapped",[36790]],[[64103,64103],"mapped",[36920]],[[64104,64104],"mapped",[38627]],[[64105,64105],"mapped",[38911]],[[64106,64106],"mapped",[38971]],[[64107,64107],"mapped",[24693]],[[64108,64108],"mapped",[148206]],[[64109,64109],"mapped",[33304]],[[64110,64111],"disallowed"],[[64112,64112],"mapped",[20006]],[[64113,64113],"mapped",[20917]],[[64114,64114],"mapped",[20840]],[[64115,64115],"mapped",[20352]],[[64116,64116],"mapped",[20805]],[[64117,64117],"mapped",[20864]],[[64118,64118],"mapped",[21191]],[[64119,64119],"mapped",[21242]],[[64120,64120],"mapped",[21917]],[[64121,64121],"mapped",[21845]],[[64122,64122],"mapped",[21913]],[[64123,64123],"mapped",[21986]],[[64124,64124],"mapped",[22618]],[[64125,64125],"mapped",[22707]],[[64126,64126],"mapped",[22852]],[[64127,64127],"mapped",[22868]],[[64128,64128],"mapped",[23138]],[[64129,64129],"mapped",[23336]],[[64130,64130],"mapped",[24274]],[[64131,64131],"mapped",[24281]],[[64132,64132],"mapped",[24425]],[[64133,64133],"mapped",[24493]],[[64134,64134],"mapped",[24792]],[[64135,64135],"mapped",[24910]],[[64136,64136],"mapped",[24840]],[[64137,64137],"mapped",[24974]],[[64138,64138],"mapped",[24928]],[[64139,64139],"mapped",[25074]],[[64140,64140],"mapped",[25140]],[[64141,64141],"mapped",[25540]],[[64142,64142],"mapped",[25628]],[[64143,64143],"mapped",[25682]],[[64144,64144],"mapped",[25942]],[[64145,64145],"mapped",[26228]],[[64146,64146],"mapped",[26391]],[[64147,64147],"mapped",[26395]],[[64148,64148],"mapped",[26454]],[[64149,64149],"mapped",[27513]],[[64150,64150],"mapped",[27578]],[[64151,64151],"mapped",[27969]],[[64152,64152],"mapped",[28379]],[[64153,64153],"mapped",[28363]],[[64154,64154],"mapped",[28450]],[[64155,64155],"mapped",[28702]],[[64156,64156],"mapped",[29038]],[[64157,64157],"mapped",[30631]],[[64158,64158],"mapped",[29237]],[[64159,64159],"mapped",[29359]],[[64160,64160],"mapped",[29482]],[[64161,64161],"mapped",[29809]],[[64162,64162],"mapped",[29958]],[[64163,64163],"mapped",[30011]],[[64164,64164],"mapped",[30237]],[[64165,64165],"mapped",[30239]],[[64166,64166],"mapped",[30410]],[[64167,64167],"mapped",[30427]],[[64168,64168],"mapped",[30452]],[[64169,64169],"mapped",[30538]],[[64170,64170],"mapped",[30528]],[[64171,64171],"mapped",[30924]],[[64172,64172],"mapped",[31409]],[[64173,64173],"mapped",[31680]],[[64174,64174],"mapped",[31867]],[[64175,64175],"mapped",[32091]],[[64176,64176],"mapped",[32244]],[[64177,64177],"mapped",[32574]],[[64178,64178],"mapped",[32773]],[[64179,64179],"mapped",[33618]],[[64180,64180],"mapped",[33775]],[[64181,64181],"mapped",[34681]],[[64182,64182],"mapped",[35137]],[[64183,64183],"mapped",[35206]],[[64184,64184],"mapped",[35222]],[[64185,64185],"mapped",[35519]],[[64186,64186],"mapped",[35576]],[[64187,64187],"mapped",[35531]],[[64188,64188],"mapped",[35585]],[[64189,64189],"mapped",[35582]],[[64190,64190],"mapped",[35565]],[[64191,64191],"mapped",[35641]],[[64192,64192],"mapped",[35722]],[[64193,64193],"mapped",[36104]],[[64194,64194],"mapped",[36664]],[[64195,64195],"mapped",[36978]],[[64196,64196],"mapped",[37273]],[[64197,64197],"mapped",[37494]],[[64198,64198],"mapped",[38524]],[[64199,64199],"mapped",[38627]],[[64200,64200],"mapped",[38742]],[[64201,64201],"mapped",[38875]],[[64202,64202],"mapped",[38911]],[[64203,64203],"mapped",[38923]],[[64204,64204],"mapped",[38971]],[[64205,64205],"mapped",[39698]],[[64206,64206],"mapped",[40860]],[[64207,64207],"mapped",[141386]],[[64208,64208],"mapped",[141380]],[[64209,64209],"mapped",[144341]],[[64210,64210],"mapped",[15261]],[[64211,64211],"mapped",[16408]],[[64212,64212],"mapped",[16441]],[[64213,64213],"mapped",[152137]],[[64214,64214],"mapped",[154832]],[[64215,64215],"mapped",[163539]],[[64216,64216],"mapped",[40771]],[[64217,64217],"mapped",[40846]],[[64218,64255],"disallowed"],[[64256,64256],"mapped",[102,102]],[[64257,64257],"mapped",[102,105]],[[64258,64258],"mapped",[102,108]],[[64259,64259],"mapped",[102,102,105]],[[64260,64260],"mapped",[102,102,108]],[[64261,64262],"mapped",[115,116]],[[64263,64274],"disallowed"],[[64275,64275],"mapped",[1396,1398]],[[64276,64276],"mapped",[1396,1381]],[[64277,64277],"mapped",[1396,1387]],[[64278,64278],"mapped",[1406,1398]],[[64279,64279],"mapped",[1396,1389]],[[64280,64284],"disallowed"],[[64285,64285],"mapped",[1497,1460]],[[64286,64286],"valid"],[[64287,64287],"mapped",[1522,1463]],[[64288,64288],"mapped",[1506]],[[64289,64289],"mapped",[1488]],[[64290,64290],"mapped",[1491]],[[64291,64291],"mapped",[1492]],[[64292,64292],"mapped",[1499]],[[64293,64293],"mapped",[1500]],[[64294,64294],"mapped",[1501]],[[64295,64295],"mapped",[1512]],[[64296,64296],"mapped",[1514]],[[64297,64297],"disallowed_STD3_mapped",[43]],[[64298,64298],"mapped",[1513,1473]],[[64299,64299],"mapped",[1513,1474]],[[64300,64300],"mapped",[1513,1468,1473]],[[64301,64301],"mapped",[1513,1468,1474]],[[64302,64302],"mapped",[1488,1463]],[[64303,64303],"mapped",[1488,1464]],[[64304,64304],"mapped",[1488,1468]],[[64305,64305],"mapped",[1489,1468]],[[64306,64306],"mapped",[1490,1468]],[[64307,64307],"mapped",[1491,1468]],[[64308,64308],"mapped",[1492,1468]],[[64309,64309],"mapped",[1493,1468]],[[64310,64310],"mapped",[1494,1468]],[[64311,64311],"disallowed"],[[64312,64312],"mapped",[1496,1468]],[[64313,64313],"mapped",[1497,1468]],[[64314,64314],"mapped",[1498,1468]],[[64315,64315],"mapped",[1499,1468]],[[64316,64316],"mapped",[1500,1468]],[[64317,64317],"disallowed"],[[64318,64318],"mapped",[1502,1468]],[[64319,64319],"disallowed"],[[64320,64320],"mapped",[1504,1468]],[[64321,64321],"mapped",[1505,1468]],[[64322,64322],"disallowed"],[[64323,64323],"mapped",[1507,1468]],[[64324,64324],"mapped",[1508,1468]],[[64325,64325],"disallowed"],[[64326,64326],"mapped",[1510,1468]],[[64327,64327],"mapped",[1511,1468]],[[64328,64328],"mapped",[1512,1468]],[[64329,64329],"mapped",[1513,1468]],[[64330,64330],"mapped",[1514,1468]],[[64331,64331],"mapped",[1493,1465]],[[64332,64332],"mapped",[1489,1471]],[[64333,64333],"mapped",[1499,1471]],[[64334,64334],"mapped",[1508,1471]],[[64335,64335],"mapped",[1488,1500]],[[64336,64337],"mapped",[1649]],[[64338,64341],"mapped",[1659]],[[64342,64345],"mapped",[1662]],[[64346,64349],"mapped",[1664]],[[64350,64353],"mapped",[1658]],[[64354,64357],"mapped",[1663]],[[64358,64361],"mapped",[1657]],[[64362,64365],"mapped",[1700]],[[64366,64369],"mapped",[1702]],[[64370,64373],"mapped",[1668]],[[64374,64377],"mapped",[1667]],[[64378,64381],"mapped",[1670]],[[64382,64385],"mapped",[1671]],[[64386,64387],"mapped",[1677]],[[64388,64389],"mapped",[1676]],[[64390,64391],"mapped",[1678]],[[64392,64393],"mapped",[1672]],[[64394,64395],"mapped",[1688]],[[64396,64397],"mapped",[1681]],[[64398,64401],"mapped",[1705]],[[64402,64405],"mapped",[1711]],[[64406,64409],"mapped",[1715]],[[64410,64413],"mapped",[1713]],[[64414,64415],"mapped",[1722]],[[64416,64419],"mapped",[1723]],[[64420,64421],"mapped",[1728]],[[64422,64425],"mapped",[1729]],[[64426,64429],"mapped",[1726]],[[64430,64431],"mapped",[1746]],[[64432,64433],"mapped",[1747]],[[64434,64449],"valid",[],"NV8"],[[64450,64466],"disallowed"],[[64467,64470],"mapped",[1709]],[[64471,64472],"mapped",[1735]],[[64473,64474],"mapped",[1734]],[[64475,64476],"mapped",[1736]],[[64477,64477],"mapped",[1735,1652]],[[64478,64479],"mapped",[1739]],[[64480,64481],"mapped",[1733]],[[64482,64483],"mapped",[1737]],[[64484,64487],"mapped",[1744]],[[64488,64489],"mapped",[1609]],[[64490,64491],"mapped",[1574,1575]],[[64492,64493],"mapped",[1574,1749]],[[64494,64495],"mapped",[1574,1608]],[[64496,64497],"mapped",[1574,1735]],[[64498,64499],"mapped",[1574,1734]],[[64500,64501],"mapped",[1574,1736]],[[64502,64504],"mapped",[1574,1744]],[[64505,64507],"mapped",[1574,1609]],[[64508,64511],"mapped",[1740]],[[64512,64512],"mapped",[1574,1580]],[[64513,64513],"mapped",[1574,1581]],[[64514,64514],"mapped",[1574,1605]],[[64515,64515],"mapped",[1574,1609]],[[64516,64516],"mapped",[1574,1610]],[[64517,64517],"mapped",[1576,1580]],[[64518,64518],"mapped",[1576,1581]],[[64519,64519],"mapped",[1576,1582]],[[64520,64520],"mapped",[1576,1605]],[[64521,64521],"mapped",[1576,1609]],[[64522,64522],"mapped",[1576,1610]],[[64523,64523],"mapped",[1578,1580]],[[64524,64524],"mapped",[1578,1581]],[[64525,64525],"mapped",[1578,1582]],[[64526,64526],"mapped",[1578,1605]],[[64527,64527],"mapped",[1578,1609]],[[64528,64528],"mapped",[1578,1610]],[[64529,64529],"mapped",[1579,1580]],[[64530,64530],"mapped",[1579,1605]],[[64531,64531],"mapped",[1579,1609]],[[64532,64532],"mapped",[1579,1610]],[[64533,64533],"mapped",[1580,1581]],[[64534,64534],"mapped",[1580,1605]],[[64535,64535],"mapped",[1581,1580]],[[64536,64536],"mapped",[1581,1605]],[[64537,64537],"mapped",[1582,1580]],[[64538,64538],"mapped",[1582,1581]],[[64539,64539],"mapped",[1582,1605]],[[64540,64540],"mapped",[1587,1580]],[[64541,64541],"mapped",[1587,1581]],[[64542,64542],"mapped",[1587,1582]],[[64543,64543],"mapped",[1587,1605]],[[64544,64544],"mapped",[1589,1581]],[[64545,64545],"mapped",[1589,1605]],[[64546,64546],"mapped",[1590,1580]],[[64547,64547],"mapped",[1590,1581]],[[64548,64548],"mapped",[1590,1582]],[[64549,64549],"mapped",[1590,1605]],[[64550,64550],"mapped",[1591,1581]],[[64551,64551],"mapped",[1591,1605]],[[64552,64552],"mapped",[1592,1605]],[[64553,64553],"mapped",[1593,1580]],[[64554,64554],"mapped",[1593,1605]],[[64555,64555],"mapped",[1594,1580]],[[64556,64556],"mapped",[1594,1605]],[[64557,64557],"mapped",[1601,1580]],[[64558,64558],"mapped",[1601,1581]],[[64559,64559],"mapped",[1601,1582]],[[64560,64560],"mapped",[1601,1605]],[[64561,64561],"mapped",[1601,1609]],[[64562,64562],"mapped",[1601,1610]],[[64563,64563],"mapped",[1602,1581]],[[64564,64564],"mapped",[1602,1605]],[[64565,64565],"mapped",[1602,1609]],[[64566,64566],"mapped",[1602,1610]],[[64567,64567],"mapped",[1603,1575]],[[64568,64568],"mapped",[1603,1580]],[[64569,64569],"mapped",[1603,1581]],[[64570,64570],"mapped",[1603,1582]],[[64571,64571],"mapped",[1603,1604]],[[64572,64572],"mapped",[1603,1605]],[[64573,64573],"mapped",[1603,1609]],[[64574,64574],"mapped",[1603,1610]],[[64575,64575],"mapped",[1604,1580]],[[64576,64576],"mapped",[1604,1581]],[[64577,64577],"mapped",[1604,1582]],[[64578,64578],"mapped",[1604,1605]],[[64579,64579],"mapped",[1604,1609]],[[64580,64580],"mapped",[1604,1610]],[[64581,64581],"mapped",[1605,1580]],[[64582,64582],"mapped",[1605,1581]],[[64583,64583],"mapped",[1605,1582]],[[64584,64584],"mapped",[1605,1605]],[[64585,64585],"mapped",[1605,1609]],[[64586,64586],"mapped",[1605,1610]],[[64587,64587],"mapped",[1606,1580]],[[64588,64588],"mapped",[1606,1581]],[[64589,64589],"mapped",[1606,1582]],[[64590,64590],"mapped",[1606,1605]],[[64591,64591],"mapped",[1606,1609]],[[64592,64592],"mapped",[1606,1610]],[[64593,64593],"mapped",[1607,1580]],[[64594,64594],"mapped",[1607,1605]],[[64595,64595],"mapped",[1607,1609]],[[64596,64596],"mapped",[1607,1610]],[[64597,64597],"mapped",[1610,1580]],[[64598,64598],"mapped",[1610,1581]],[[64599,64599],"mapped",[1610,1582]],[[64600,64600],"mapped",[1610,1605]],[[64601,64601],"mapped",[1610,1609]],[[64602,64602],"mapped",[1610,1610]],[[64603,64603],"mapped",[1584,1648]],[[64604,64604],"mapped",[1585,1648]],[[64605,64605],"mapped",[1609,1648]],[[64606,64606],"disallowed_STD3_mapped",[32,1612,1617]],[[64607,64607],"disallowed_STD3_mapped",[32,1613,1617]],[[64608,64608],"disallowed_STD3_mapped",[32,1614,1617]],[[64609,64609],"disallowed_STD3_mapped",[32,1615,1617]],[[64610,64610],"disallowed_STD3_mapped",[32,1616,1617]],[[64611,64611],"disallowed_STD3_mapped",[32,1617,1648]],[[64612,64612],"mapped",[1574,1585]],[[64613,64613],"mapped",[1574,1586]],[[64614,64614],"mapped",[1574,1605]],[[64615,64615],"mapped",[1574,1606]],[[64616,64616],"mapped",[1574,1609]],[[64617,64617],"mapped",[1574,1610]],[[64618,64618],"mapped",[1576,1585]],[[64619,64619],"mapped",[1576,1586]],[[64620,64620],"mapped",[1576,1605]],[[64621,64621],"mapped",[1576,1606]],[[64622,64622],"mapped",[1576,1609]],[[64623,64623],"mapped",[1576,1610]],[[64624,64624],"mapped",[1578,1585]],[[64625,64625],"mapped",[1578,1586]],[[64626,64626],"mapped",[1578,1605]],[[64627,64627],"mapped",[1578,1606]],[[64628,64628],"mapped",[1578,1609]],[[64629,64629],"mapped",[1578,1610]],[[64630,64630],"mapped",[1579,1585]],[[64631,64631],"mapped",[1579,1586]],[[64632,64632],"mapped",[1579,1605]],[[64633,64633],"mapped",[1579,1606]],[[64634,64634],"mapped",[1579,1609]],[[64635,64635],"mapped",[1579,1610]],[[64636,64636],"mapped",[1601,1609]],[[64637,64637],"mapped",[1601,1610]],[[64638,64638],"mapped",[1602,1609]],[[64639,64639],"mapped",[1602,1610]],[[64640,64640],"mapped",[1603,1575]],[[64641,64641],"mapped",[1603,1604]],[[64642,64642],"mapped",[1603,1605]],[[64643,64643],"mapped",[1603,1609]],[[64644,64644],"mapped",[1603,1610]],[[64645,64645],"mapped",[1604,1605]],[[64646,64646],"mapped",[1604,1609]],[[64647,64647],"mapped",[1604,1610]],[[64648,64648],"mapped",[1605,1575]],[[64649,64649],"mapped",[1605,1605]],[[64650,64650],"mapped",[1606,1585]],[[64651,64651],"mapped",[1606,1586]],[[64652,64652],"mapped",[1606,1605]],[[64653,64653],"mapped",[1606,1606]],[[64654,64654],"mapped",[1606,1609]],[[64655,64655],"mapped",[1606,1610]],[[64656,64656],"mapped",[1609,1648]],[[64657,64657],"mapped",[1610,1585]],[[64658,64658],"mapped",[1610,1586]],[[64659,64659],"mapped",[1610,1605]],[[64660,64660],"mapped",[1610,1606]],[[64661,64661],"mapped",[1610,1609]],[[64662,64662],"mapped",[1610,1610]],[[64663,64663],"mapped",[1574,1580]],[[64664,64664],"mapped",[1574,1581]],[[64665,64665],"mapped",[1574,1582]],[[64666,64666],"mapped",[1574,1605]],[[64667,64667],"mapped",[1574,1607]],[[64668,64668],"mapped",[1576,1580]],[[64669,64669],"mapped",[1576,1581]],[[64670,64670],"mapped",[1576,1582]],[[64671,64671],"mapped",[1576,1605]],[[64672,64672],"mapped",[1576,1607]],[[64673,64673],"mapped",[1578,1580]],[[64674,64674],"mapped",[1578,1581]],[[64675,64675],"mapped",[1578,1582]],[[64676,64676],"mapped",[1578,1605]],[[64677,64677],"mapped",[1578,1607]],[[64678,64678],"mapped",[1579,1605]],[[64679,64679],"mapped",[1580,1581]],[[64680,64680],"mapped",[1580,1605]],[[64681,64681],"mapped",[1581,1580]],[[64682,64682],"mapped",[1581,1605]],[[64683,64683],"mapped",[1582,1580]],[[64684,64684],"mapped",[1582,1605]],[[64685,64685],"mapped",[1587,1580]],[[64686,64686],"mapped",[1587,1581]],[[64687,64687],"mapped",[1587,1582]],[[64688,64688],"mapped",[1587,1605]],[[64689,64689],"mapped",[1589,1581]],[[64690,64690],"mapped",[1589,1582]],[[64691,64691],"mapped",[1589,1605]],[[64692,64692],"mapped",[1590,1580]],[[64693,64693],"mapped",[1590,1581]],[[64694,64694],"mapped",[1590,1582]],[[64695,64695],"mapped",[1590,1605]],[[64696,64696],"mapped",[1591,1581]],[[64697,64697],"mapped",[1592,1605]],[[64698,64698],"mapped",[1593,1580]],[[64699,64699],"mapped",[1593,1605]],[[64700,64700],"mapped",[1594,1580]],[[64701,64701],"mapped",[1594,1605]],[[64702,64702],"mapped",[1601,1580]],[[64703,64703],"mapped",[1601,1581]],[[64704,64704],"mapped",[1601,1582]],[[64705,64705],"mapped",[1601,1605]],[[64706,64706],"mapped",[1602,1581]],[[64707,64707],"mapped",[1602,1605]],[[64708,64708],"mapped",[1603,1580]],[[64709,64709],"mapped",[1603,1581]],[[64710,64710],"mapped",[1603,1582]],[[64711,64711],"mapped",[1603,1604]],[[64712,64712],"mapped",[1603,1605]],[[64713,64713],"mapped",[1604,1580]],[[64714,64714],"mapped",[1604,1581]],[[64715,64715],"mapped",[1604,1582]],[[64716,64716],"mapped",[1604,1605]],[[64717,64717],"mapped",[1604,1607]],[[64718,64718],"mapped",[1605,1580]],[[64719,64719],"mapped",[1605,1581]],[[64720,64720],"mapped",[1605,1582]],[[64721,64721],"mapped",[1605,1605]],[[64722,64722],"mapped",[1606,1580]],[[64723,64723],"mapped",[1606,1581]],[[64724,64724],"mapped",[1606,1582]],[[64725,64725],"mapped",[1606,1605]],[[64726,64726],"mapped",[1606,1607]],[[64727,64727],"mapped",[1607,1580]],[[64728,64728],"mapped",[1607,1605]],[[64729,64729],"mapped",[1607,1648]],[[64730,64730],"mapped",[1610,1580]],[[64731,64731],"mapped",[1610,1581]],[[64732,64732],"mapped",[1610,1582]],[[64733,64733],"mapped",[1610,1605]],[[64734,64734],"mapped",[1610,1607]],[[64735,64735],"mapped",[1574,1605]],[[64736,64736],"mapped",[1574,1607]],[[64737,64737],"mapped",[1576,1605]],[[64738,64738],"mapped",[1576,1607]],[[64739,64739],"mapped",[1578,1605]],[[64740,64740],"mapped",[1578,1607]],[[64741,64741],"mapped",[1579,1605]],[[64742,64742],"mapped",[1579,1607]],[[64743,64743],"mapped",[1587,1605]],[[64744,64744],"mapped",[1587,1607]],[[64745,64745],"mapped",[1588,1605]],[[64746,64746],"mapped",[1588,1607]],[[64747,64747],"mapped",[1603,1604]],[[64748,64748],"mapped",[1603,1605]],[[64749,64749],"mapped",[1604,1605]],[[64750,64750],"mapped",[1606,1605]],[[64751,64751],"mapped",[1606,1607]],[[64752,64752],"mapped",[1610,1605]],[[64753,64753],"mapped",[1610,1607]],[[64754,64754],"mapped",[1600,1614,1617]],[[64755,64755],"mapped",[1600,1615,1617]],[[64756,64756],"mapped",[1600,1616,1617]],[[64757,64757],"mapped",[1591,1609]],[[64758,64758],"mapped",[1591,1610]],[[64759,64759],"mapped",[1593,1609]],[[64760,64760],"mapped",[1593,1610]],[[64761,64761],"mapped",[1594,1609]],[[64762,64762],"mapped",[1594,1610]],[[64763,64763],"mapped",[1587,1609]],[[64764,64764],"mapped",[1587,1610]],[[64765,64765],"mapped",[1588,1609]],[[64766,64766],"mapped",[1588,1610]],[[64767,64767],"mapped",[1581,1609]],[[64768,64768],"mapped",[1581,1610]],[[64769,64769],"mapped",[1580,1609]],[[64770,64770],"mapped",[1580,1610]],[[64771,64771],"mapped",[1582,1609]],[[64772,64772],"mapped",[1582,1610]],[[64773,64773],"mapped",[1589,1609]],[[64774,64774],"mapped",[1589,1610]],[[64775,64775],"mapped",[1590,1609]],[[64776,64776],"mapped",[1590,1610]],[[64777,64777],"mapped",[1588,1580]],[[64778,64778],"mapped",[1588,1581]],[[64779,64779],"mapped",[1588,1582]],[[64780,64780],"mapped",[1588,1605]],[[64781,64781],"mapped",[1588,1585]],[[64782,64782],"mapped",[1587,1585]],[[64783,64783],"mapped",[1589,1585]],[[64784,64784],"mapped",[1590,1585]],[[64785,64785],"mapped",[1591,1609]],[[64786,64786],"mapped",[1591,1610]],[[64787,64787],"mapped",[1593,1609]],[[64788,64788],"mapped",[1593,1610]],[[64789,64789],"mapped",[1594,1609]],[[64790,64790],"mapped",[1594,1610]],[[64791,64791],"mapped",[1587,1609]],[[64792,64792],"mapped",[1587,1610]],[[64793,64793],"mapped",[1588,1609]],[[64794,64794],"mapped",[1588,1610]],[[64795,64795],"mapped",[1581,1609]],[[64796,64796],"mapped",[1581,1610]],[[64797,64797],"mapped",[1580,1609]],[[64798,64798],"mapped",[1580,1610]],[[64799,64799],"mapped",[1582,1609]],[[64800,64800],"mapped",[1582,1610]],[[64801,64801],"mapped",[1589,1609]],[[64802,64802],"mapped",[1589,1610]],[[64803,64803],"mapped",[1590,1609]],[[64804,64804],"mapped",[1590,1610]],[[64805,64805],"mapped",[1588,1580]],[[64806,64806],"mapped",[1588,1581]],[[64807,64807],"mapped",[1588,1582]],[[64808,64808],"mapped",[1588,1605]],[[64809,64809],"mapped",[1588,1585]],[[64810,64810],"mapped",[1587,1585]],[[64811,64811],"mapped",[1589,1585]],[[64812,64812],"mapped",[1590,1585]],[[64813,64813],"mapped",[1588,1580]],[[64814,64814],"mapped",[1588,1581]],[[64815,64815],"mapped",[1588,1582]],[[64816,64816],"mapped",[1588,1605]],[[64817,64817],"mapped",[1587,1607]],[[64818,64818],"mapped",[1588,1607]],[[64819,64819],"mapped",[1591,1605]],[[64820,64820],"mapped",[1587,1580]],[[64821,64821],"mapped",[1587,1581]],[[64822,64822],"mapped",[1587,1582]],[[64823,64823],"mapped",[1588,1580]],[[64824,64824],"mapped",[1588,1581]],[[64825,64825],"mapped",[1588,1582]],[[64826,64826],"mapped",[1591,1605]],[[64827,64827],"mapped",[1592,1605]],[[64828,64829],"mapped",[1575,1611]],[[64830,64831],"valid",[],"NV8"],[[64832,64847],"disallowed"],[[64848,64848],"mapped",[1578,1580,1605]],[[64849,64850],"mapped",[1578,1581,1580]],[[64851,64851],"mapped",[1578,1581,1605]],[[64852,64852],"mapped",[1578,1582,1605]],[[64853,64853],"mapped",[1578,1605,1580]],[[64854,64854],"mapped",[1578,1605,1581]],[[64855,64855],"mapped",[1578,1605,1582]],[[64856,64857],"mapped",[1580,1605,1581]],[[64858,64858],"mapped",[1581,1605,1610]],[[64859,64859],"mapped",[1581,1605,1609]],[[64860,64860],"mapped",[1587,1581,1580]],[[64861,64861],"mapped",[1587,1580,1581]],[[64862,64862],"mapped",[1587,1580,1609]],[[64863,64864],"mapped",[1587,1605,1581]],[[64865,64865],"mapped",[1587,1605,1580]],[[64866,64867],"mapped",[1587,1605,1605]],[[64868,64869],"mapped",[1589,1581,1581]],[[64870,64870],"mapped",[1589,1605,1605]],[[64871,64872],"mapped",[1588,1581,1605]],[[64873,64873],"mapped",[1588,1580,1610]],[[64874,64875],"mapped",[1588,1605,1582]],[[64876,64877],"mapped",[1588,1605,1605]],[[64878,64878],"mapped",[1590,1581,1609]],[[64879,64880],"mapped",[1590,1582,1605]],[[64881,64882],"mapped",[1591,1605,1581]],[[64883,64883],"mapped",[1591,1605,1605]],[[64884,64884],"mapped",[1591,1605,1610]],[[64885,64885],"mapped",[1593,1580,1605]],[[64886,64887],"mapped",[1593,1605,1605]],[[64888,64888],"mapped",[1593,1605,1609]],[[64889,64889],"mapped",[1594,1605,1605]],[[64890,64890],"mapped",[1594,1605,1610]],[[64891,64891],"mapped",[1594,1605,1609]],[[64892,64893],"mapped",[1601,1582,1605]],[[64894,64894],"mapped",[1602,1605,1581]],[[64895,64895],"mapped",[1602,1605,1605]],[[64896,64896],"mapped",[1604,1581,1605]],[[64897,64897],"mapped",[1604,1581,1610]],[[64898,64898],"mapped",[1604,1581,1609]],[[64899,64900],"mapped",[1604,1580,1580]],[[64901,64902],"mapped",[1604,1582,1605]],[[64903,64904],"mapped",[1604,1605,1581]],[[64905,64905],"mapped",[1605,1581,1580]],[[64906,64906],"mapped",[1605,1581,1605]],[[64907,64907],"mapped",[1605,1581,1610]],[[64908,64908],"mapped",[1605,1580,1581]],[[64909,64909],"mapped",[1605,1580,1605]],[[64910,64910],"mapped",[1605,1582,1580]],[[64911,64911],"mapped",[1605,1582,1605]],[[64912,64913],"disallowed"],[[64914,64914],"mapped",[1605,1580,1582]],[[64915,64915],"mapped",[1607,1605,1580]],[[64916,64916],"mapped",[1607,1605,1605]],[[64917,64917],"mapped",[1606,1581,1605]],[[64918,64918],"mapped",[1606,1581,1609]],[[64919,64920],"mapped",[1606,1580,1605]],[[64921,64921],"mapped",[1606,1580,1609]],[[64922,64922],"mapped",[1606,1605,1610]],[[64923,64923],"mapped",[1606,1605,1609]],[[64924,64925],"mapped",[1610,1605,1605]],[[64926,64926],"mapped",[1576,1582,1610]],[[64927,64927],"mapped",[1578,1580,1610]],[[64928,64928],"mapped",[1578,1580,1609]],[[64929,64929],"mapped",[1578,1582,1610]],[[64930,64930],"mapped",[1578,1582,1609]],[[64931,64931],"mapped",[1578,1605,1610]],[[64932,64932],"mapped",[1578,1605,1609]],[[64933,64933],"mapped",[1580,1605,1610]],[[64934,64934],"mapped",[1580,1581,1609]],[[64935,64935],"mapped",[1580,1605,1609]],[[64936,64936],"mapped",[1587,1582,1609]],[[64937,64937],"mapped",[1589,1581,1610]],[[64938,64938],"mapped",[1588,1581,1610]],[[64939,64939],"mapped",[1590,1581,1610]],[[64940,64940],"mapped",[1604,1580,1610]],[[64941,64941],"mapped",[1604,1605,1610]],[[64942,64942],"mapped",[1610,1581,1610]],[[64943,64943],"mapped",[1610,1580,1610]],[[64944,64944],"mapped",[1610,1605,1610]],[[64945,64945],"mapped",[1605,1605,1610]],[[64946,64946],"mapped",[1602,1605,1610]],[[64947,64947],"mapped",[1606,1581,1610]],[[64948,64948],"mapped",[1602,1605,1581]],[[64949,64949],"mapped",[1604,1581,1605]],[[64950,64950],"mapped",[1593,1605,1610]],[[64951,64951],"mapped",[1603,1605,1610]],[[64952,64952],"mapped",[1606,1580,1581]],[[64953,64953],"mapped",[1605,1582,1610]],[[64954,64954],"mapped",[1604,1580,1605]],[[64955,64955],"mapped",[1603,1605,1605]],[[64956,64956],"mapped",[1604,1580,1605]],[[64957,64957],"mapped",[1606,1580,1581]],[[64958,64958],"mapped",[1580,1581,1610]],[[64959,64959],"mapped",[1581,1580,1610]],[[64960,64960],"mapped",[1605,1580,1610]],[[64961,64961],"mapped",[1601,1605,1610]],[[64962,64962],"mapped",[1576,1581,1610]],[[64963,64963],"mapped",[1603,1605,1605]],[[64964,64964],"mapped",[1593,1580,1605]],[[64965,64965],"mapped",[1589,1605,1605]],[[64966,64966],"mapped",[1587,1582,1610]],[[64967,64967],"mapped",[1606,1580,1610]],[[64968,64975],"disallowed"],[[64976,65007],"disallowed"],[[65008,65008],"mapped",[1589,1604,1746]],[[65009,65009],"mapped",[1602,1604,1746]],[[65010,65010],"mapped",[1575,1604,1604,1607]],[[65011,65011],"mapped",[1575,1603,1576,1585]],[[65012,65012],"mapped",[1605,1581,1605,1583]],[[65013,65013],"mapped",[1589,1604,1593,1605]],[[65014,65014],"mapped",[1585,1587,1608,1604]],[[65015,65015],"mapped",[1593,1604,1610,1607]],[[65016,65016],"mapped",[1608,1587,1604,1605]],[[65017,65017],"mapped",[1589,1604,1609]],[[65018,65018],"disallowed_STD3_mapped",[1589,1604,1609,32,1575,1604,1604,1607,32,1593,1604,1610,1607,32,1608,1587,1604,1605]],[[65019,65019],"disallowed_STD3_mapped",[1580,1604,32,1580,1604,1575,1604,1607]],[[65020,65020],"mapped",[1585,1740,1575,1604]],[[65021,65021],"valid",[],"NV8"],[[65022,65023],"disallowed"],[[65024,65039],"ignored"],[[65040,65040],"disallowed_STD3_mapped",[44]],[[65041,65041],"mapped",[12289]],[[65042,65042],"disallowed"],[[65043,65043],"disallowed_STD3_mapped",[58]],[[65044,65044],"disallowed_STD3_mapped",[59]],[[65045,65045],"disallowed_STD3_mapped",[33]],[[65046,65046],"disallowed_STD3_mapped",[63]],[[65047,65047],"mapped",[12310]],[[65048,65048],"mapped",[12311]],[[65049,65049],"disallowed"],[[65050,65055],"disallowed"],[[65056,65059],"valid"],[[65060,65062],"valid"],[[65063,65069],"valid"],[[65070,65071],"valid"],[[65072,65072],"disallowed"],[[65073,65073],"mapped",[8212]],[[65074,65074],"mapped",[8211]],[[65075,65076],"disallowed_STD3_mapped",[95]],[[65077,65077],"disallowed_STD3_mapped",[40]],[[65078,65078],"disallowed_STD3_mapped",[41]],[[65079,65079],"disallowed_STD3_mapped",[123]],[[65080,65080],"disallowed_STD3_mapped",[125]],[[65081,65081],"mapped",[12308]],[[65082,65082],"mapped",[12309]],[[65083,65083],"mapped",[12304]],[[65084,65084],"mapped",[12305]],[[65085,65085],"mapped",[12298]],[[65086,65086],"mapped",[12299]],[[65087,65087],"mapped",[12296]],[[65088,65088],"mapped",[12297]],[[65089,65089],"mapped",[12300]],[[65090,65090],"mapped",[12301]],[[65091,65091],"mapped",[12302]],[[65092,65092],"mapped",[12303]],[[65093,65094],"valid",[],"NV8"],[[65095,65095],"disallowed_STD3_mapped",[91]],[[65096,65096],"disallowed_STD3_mapped",[93]],[[65097,65100],"disallowed_STD3_mapped",[32,773]],[[65101,65103],"disallowed_STD3_mapped",[95]],[[65104,65104],"disallowed_STD3_mapped",[44]],[[65105,65105],"mapped",[12289]],[[65106,65106],"disallowed"],[[65107,65107],"disallowed"],[[65108,65108],"disallowed_STD3_mapped",[59]],[[65109,65109],"disallowed_STD3_mapped",[58]],[[65110,65110],"disallowed_STD3_mapped",[63]],[[65111,65111],"disallowed_STD3_mapped",[33]],[[65112,65112],"mapped",[8212]],[[65113,65113],"disallowed_STD3_mapped",[40]],[[65114,65114],"disallowed_STD3_mapped",[41]],[[65115,65115],"disallowed_STD3_mapped",[123]],[[65116,65116],"disallowed_STD3_mapped",[125]],[[65117,65117],"mapped",[12308]],[[65118,65118],"mapped",[12309]],[[65119,65119],"disallowed_STD3_mapped",[35]],[[65120,65120],"disallowed_STD3_mapped",[38]],[[65121,65121],"disallowed_STD3_mapped",[42]],[[65122,65122],"disallowed_STD3_mapped",[43]],[[65123,65123],"mapped",[45]],[[65124,65124],"disallowed_STD3_mapped",[60]],[[65125,65125],"disallowed_STD3_mapped",[62]],[[65126,65126],"disallowed_STD3_mapped",[61]],[[65127,65127],"disallowed"],[[65128,65128],"disallowed_STD3_mapped",[92]],[[65129,65129],"disallowed_STD3_mapped",[36]],[[65130,65130],"disallowed_STD3_mapped",[37]],[[65131,65131],"disallowed_STD3_mapped",[64]],[[65132,65135],"disallowed"],[[65136,65136],"disallowed_STD3_mapped",[32,1611]],[[65137,65137],"mapped",[1600,1611]],[[65138,65138],"disallowed_STD3_mapped",[32,1612]],[[65139,65139],"valid"],[[65140,65140],"disallowed_STD3_mapped",[32,1613]],[[65141,65141],"disallowed"],[[65142,65142],"disallowed_STD3_mapped",[32,1614]],[[65143,65143],"mapped",[1600,1614]],[[65144,65144],"disallowed_STD3_mapped",[32,1615]],[[65145,65145],"mapped",[1600,1615]],[[65146,65146],"disallowed_STD3_mapped",[32,1616]],[[65147,65147],"mapped",[1600,1616]],[[65148,65148],"disallowed_STD3_mapped",[32,1617]],[[65149,65149],"mapped",[1600,1617]],[[65150,65150],"disallowed_STD3_mapped",[32,1618]],[[65151,65151],"mapped",[1600,1618]],[[65152,65152],"mapped",[1569]],[[65153,65154],"mapped",[1570]],[[65155,65156],"mapped",[1571]],[[65157,65158],"mapped",[1572]],[[65159,65160],"mapped",[1573]],[[65161,65164],"mapped",[1574]],[[65165,65166],"mapped",[1575]],[[65167,65170],"mapped",[1576]],[[65171,65172],"mapped",[1577]],[[65173,65176],"mapped",[1578]],[[65177,65180],"mapped",[1579]],[[65181,65184],"mapped",[1580]],[[65185,65188],"mapped",[1581]],[[65189,65192],"mapped",[1582]],[[65193,65194],"mapped",[1583]],[[65195,65196],"mapped",[1584]],[[65197,65198],"mapped",[1585]],[[65199,65200],"mapped",[1586]],[[65201,65204],"mapped",[1587]],[[65205,65208],"mapped",[1588]],[[65209,65212],"mapped",[1589]],[[65213,65216],"mapped",[1590]],[[65217,65220],"mapped",[1591]],[[65221,65224],"mapped",[1592]],[[65225,65228],"mapped",[1593]],[[65229,65232],"mapped",[1594]],[[65233,65236],"mapped",[1601]],[[65237,65240],"mapped",[1602]],[[65241,65244],"mapped",[1603]],[[65245,65248],"mapped",[1604]],[[65249,65252],"mapped",[1605]],[[65253,65256],"mapped",[1606]],[[65257,65260],"mapped",[1607]],[[65261,65262],"mapped",[1608]],[[65263,65264],"mapped",[1609]],[[65265,65268],"mapped",[1610]],[[65269,65270],"mapped",[1604,1570]],[[65271,65272],"mapped",[1604,1571]],[[65273,65274],"mapped",[1604,1573]],[[65275,65276],"mapped",[1604,1575]],[[65277,65278],"disallowed"],[[65279,65279],"ignored"],[[65280,65280],"disallowed"],[[65281,65281],"disallowed_STD3_mapped",[33]],[[65282,65282],"disallowed_STD3_mapped",[34]],[[65283,65283],"disallowed_STD3_mapped",[35]],[[65284,65284],"disallowed_STD3_mapped",[36]],[[65285,65285],"disallowed_STD3_mapped",[37]],[[65286,65286],"disallowed_STD3_mapped",[38]],[[65287,65287],"disallowed_STD3_mapped",[39]],[[65288,65288],"disallowed_STD3_mapped",[40]],[[65289,65289],"disallowed_STD3_mapped",[41]],[[65290,65290],"disallowed_STD3_mapped",[42]],[[65291,65291],"disallowed_STD3_mapped",[43]],[[65292,65292],"disallowed_STD3_mapped",[44]],[[65293,65293],"mapped",[45]],[[65294,65294],"mapped",[46]],[[65295,65295],"disallowed_STD3_mapped",[47]],[[65296,65296],"mapped",[48]],[[65297,65297],"mapped",[49]],[[65298,65298],"mapped",[50]],[[65299,65299],"mapped",[51]],[[65300,65300],"mapped",[52]],[[65301,65301],"mapped",[53]],[[65302,65302],"mapped",[54]],[[65303,65303],"mapped",[55]],[[65304,65304],"mapped",[56]],[[65305,65305],"mapped",[57]],[[65306,65306],"disallowed_STD3_mapped",[58]],[[65307,65307],"disallowed_STD3_mapped",[59]],[[65308,65308],"disallowed_STD3_mapped",[60]],[[65309,65309],"disallowed_STD3_mapped",[61]],[[65310,65310],"disallowed_STD3_mapped",[62]],[[65311,65311],"disallowed_STD3_mapped",[63]],[[65312,65312],"disallowed_STD3_mapped",[64]],[[65313,65313],"mapped",[97]],[[65314,65314],"mapped",[98]],[[65315,65315],"mapped",[99]],[[65316,65316],"mapped",[100]],[[65317,65317],"mapped",[101]],[[65318,65318],"mapped",[102]],[[65319,65319],"mapped",[103]],[[65320,65320],"mapped",[104]],[[65321,65321],"mapped",[105]],[[65322,65322],"mapped",[106]],[[65323,65323],"mapped",[107]],[[65324,65324],"mapped",[108]],[[65325,65325],"mapped",[109]],[[65326,65326],"mapped",[110]],[[65327,65327],"mapped",[111]],[[65328,65328],"mapped",[112]],[[65329,65329],"mapped",[113]],[[65330,65330],"mapped",[114]],[[65331,65331],"mapped",[115]],[[65332,65332],"mapped",[116]],[[65333,65333],"mapped",[117]],[[65334,65334],"mapped",[118]],[[65335,65335],"mapped",[119]],[[65336,65336],"mapped",[120]],[[65337,65337],"mapped",[121]],[[65338,65338],"mapped",[122]],[[65339,65339],"disallowed_STD3_mapped",[91]],[[65340,65340],"disallowed_STD3_mapped",[92]],[[65341,65341],"disallowed_STD3_mapped",[93]],[[65342,65342],"disallowed_STD3_mapped",[94]],[[65343,65343],"disallowed_STD3_mapped",[95]],[[65344,65344],"disallowed_STD3_mapped",[96]],[[65345,65345],"mapped",[97]],[[65346,65346],"mapped",[98]],[[65347,65347],"mapped",[99]],[[65348,65348],"mapped",[100]],[[65349,65349],"mapped",[101]],[[65350,65350],"mapped",[102]],[[65351,65351],"mapped",[103]],[[65352,65352],"mapped",[104]],[[65353,65353],"mapped",[105]],[[65354,65354],"mapped",[106]],[[65355,65355],"mapped",[107]],[[65356,65356],"mapped",[108]],[[65357,65357],"mapped",[109]],[[65358,65358],"mapped",[110]],[[65359,65359],"mapped",[111]],[[65360,65360],"mapped",[112]],[[65361,65361],"mapped",[113]],[[65362,65362],"mapped",[114]],[[65363,65363],"mapped",[115]],[[65364,65364],"mapped",[116]],[[65365,65365],"mapped",[117]],[[65366,65366],"mapped",[118]],[[65367,65367],"mapped",[119]],[[65368,65368],"mapped",[120]],[[65369,65369],"mapped",[121]],[[65370,65370],"mapped",[122]],[[65371,65371],"disallowed_STD3_mapped",[123]],[[65372,65372],"disallowed_STD3_mapped",[124]],[[65373,65373],"disallowed_STD3_mapped",[125]],[[65374,65374],"disallowed_STD3_mapped",[126]],[[65375,65375],"mapped",[10629]],[[65376,65376],"mapped",[10630]],[[65377,65377],"mapped",[46]],[[65378,65378],"mapped",[12300]],[[65379,65379],"mapped",[12301]],[[65380,65380],"mapped",[12289]],[[65381,65381],"mapped",[12539]],[[65382,65382],"mapped",[12530]],[[65383,65383],"mapped",[12449]],[[65384,65384],"mapped",[12451]],[[65385,65385],"mapped",[12453]],[[65386,65386],"mapped",[12455]],[[65387,65387],"mapped",[12457]],[[65388,65388],"mapped",[12515]],[[65389,65389],"mapped",[12517]],[[65390,65390],"mapped",[12519]],[[65391,65391],"mapped",[12483]],[[65392,65392],"mapped",[12540]],[[65393,65393],"mapped",[12450]],[[65394,65394],"mapped",[12452]],[[65395,65395],"mapped",[12454]],[[65396,65396],"mapped",[12456]],[[65397,65397],"mapped",[12458]],[[65398,65398],"mapped",[12459]],[[65399,65399],"mapped",[12461]],[[65400,65400],"mapped",[12463]],[[65401,65401],"mapped",[12465]],[[65402,65402],"mapped",[12467]],[[65403,65403],"mapped",[12469]],[[65404,65404],"mapped",[12471]],[[65405,65405],"mapped",[12473]],[[65406,65406],"mapped",[12475]],[[65407,65407],"mapped",[12477]],[[65408,65408],"mapped",[12479]],[[65409,65409],"mapped",[12481]],[[65410,65410],"mapped",[12484]],[[65411,65411],"mapped",[12486]],[[65412,65412],"mapped",[12488]],[[65413,65413],"mapped",[12490]],[[65414,65414],"mapped",[12491]],[[65415,65415],"mapped",[12492]],[[65416,65416],"mapped",[12493]],[[65417,65417],"mapped",[12494]],[[65418,65418],"mapped",[12495]],[[65419,65419],"mapped",[12498]],[[65420,65420],"mapped",[12501]],[[65421,65421],"mapped",[12504]],[[65422,65422],"mapped",[12507]],[[65423,65423],"mapped",[12510]],[[65424,65424],"mapped",[12511]],[[65425,65425],"mapped",[12512]],[[65426,65426],"mapped",[12513]],[[65427,65427],"mapped",[12514]],[[65428,65428],"mapped",[12516]],[[65429,65429],"mapped",[12518]],[[65430,65430],"mapped",[12520]],[[65431,65431],"mapped",[12521]],[[65432,65432],"mapped",[12522]],[[65433,65433],"mapped",[12523]],[[65434,65434],"mapped",[12524]],[[65435,65435],"mapped",[12525]],[[65436,65436],"mapped",[12527]],[[65437,65437],"mapped",[12531]],[[65438,65438],"mapped",[12441]],[[65439,65439],"mapped",[12442]],[[65440,65440],"disallowed"],[[65441,65441],"mapped",[4352]],[[65442,65442],"mapped",[4353]],[[65443,65443],"mapped",[4522]],[[65444,65444],"mapped",[4354]],[[65445,65445],"mapped",[4524]],[[65446,65446],"mapped",[4525]],[[65447,65447],"mapped",[4355]],[[65448,65448],"mapped",[4356]],[[65449,65449],"mapped",[4357]],[[65450,65450],"mapped",[4528]],[[65451,65451],"mapped",[4529]],[[65452,65452],"mapped",[4530]],[[65453,65453],"mapped",[4531]],[[65454,65454],"mapped",[4532]],[[65455,65455],"mapped",[4533]],[[65456,65456],"mapped",[4378]],[[65457,65457],"mapped",[4358]],[[65458,65458],"mapped",[4359]],[[65459,65459],"mapped",[4360]],[[65460,65460],"mapped",[4385]],[[65461,65461],"mapped",[4361]],[[65462,65462],"mapped",[4362]],[[65463,65463],"mapped",[4363]],[[65464,65464],"mapped",[4364]],[[65465,65465],"mapped",[4365]],[[65466,65466],"mapped",[4366]],[[65467,65467],"mapped",[4367]],[[65468,65468],"mapped",[4368]],[[65469,65469],"mapped",[4369]],[[65470,65470],"mapped",[4370]],[[65471,65473],"disallowed"],[[65474,65474],"mapped",[4449]],[[65475,65475],"mapped",[4450]],[[65476,65476],"mapped",[4451]],[[65477,65477],"mapped",[4452]],[[65478,65478],"mapped",[4453]],[[65479,65479],"mapped",[4454]],[[65480,65481],"disallowed"],[[65482,65482],"mapped",[4455]],[[65483,65483],"mapped",[4456]],[[65484,65484],"mapped",[4457]],[[65485,65485],"mapped",[4458]],[[65486,65486],"mapped",[4459]],[[65487,65487],"mapped",[4460]],[[65488,65489],"disallowed"],[[65490,65490],"mapped",[4461]],[[65491,65491],"mapped",[4462]],[[65492,65492],"mapped",[4463]],[[65493,65493],"mapped",[4464]],[[65494,65494],"mapped",[4465]],[[65495,65495],"mapped",[4466]],[[65496,65497],"disallowed"],[[65498,65498],"mapped",[4467]],[[65499,65499],"mapped",[4468]],[[65500,65500],"mapped",[4469]],[[65501,65503],"disallowed"],[[65504,65504],"mapped",[162]],[[65505,65505],"mapped",[163]],[[65506,65506],"mapped",[172]],[[65507,65507],"disallowed_STD3_mapped",[32,772]],[[65508,65508],"mapped",[166]],[[65509,65509],"mapped",[165]],[[65510,65510],"mapped",[8361]],[[65511,65511],"disallowed"],[[65512,65512],"mapped",[9474]],[[65513,65513],"mapped",[8592]],[[65514,65514],"mapped",[8593]],[[65515,65515],"mapped",[8594]],[[65516,65516],"mapped",[8595]],[[65517,65517],"mapped",[9632]],[[65518,65518],"mapped",[9675]],[[65519,65528],"disallowed"],[[65529,65531],"disallowed"],[[65532,65532],"disallowed"],[[65533,65533],"disallowed"],[[65534,65535],"disallowed"],[[65536,65547],"valid"],[[65548,65548],"disallowed"],[[65549,65574],"valid"],[[65575,65575],"disallowed"],[[65576,65594],"valid"],[[65595,65595],"disallowed"],[[65596,65597],"valid"],[[65598,65598],"disallowed"],[[65599,65613],"valid"],[[65614,65615],"disallowed"],[[65616,65629],"valid"],[[65630,65663],"disallowed"],[[65664,65786],"valid"],[[65787,65791],"disallowed"],[[65792,65794],"valid",[],"NV8"],[[65795,65798],"disallowed"],[[65799,65843],"valid",[],"NV8"],[[65844,65846],"disallowed"],[[65847,65855],"valid",[],"NV8"],[[65856,65930],"valid",[],"NV8"],[[65931,65932],"valid",[],"NV8"],[[65933,65935],"disallowed"],[[65936,65947],"valid",[],"NV8"],[[65948,65951],"disallowed"],[[65952,65952],"valid",[],"NV8"],[[65953,65999],"disallowed"],[[66000,66044],"valid",[],"NV8"],[[66045,66045],"valid"],[[66046,66175],"disallowed"],[[66176,66204],"valid"],[[66205,66207],"disallowed"],[[66208,66256],"valid"],[[66257,66271],"disallowed"],[[66272,66272],"valid"],[[66273,66299],"valid",[],"NV8"],[[66300,66303],"disallowed"],[[66304,66334],"valid"],[[66335,66335],"valid"],[[66336,66339],"valid",[],"NV8"],[[66340,66351],"disallowed"],[[66352,66368],"valid"],[[66369,66369],"valid",[],"NV8"],[[66370,66377],"valid"],[[66378,66378],"valid",[],"NV8"],[[66379,66383],"disallowed"],[[66384,66426],"valid"],[[66427,66431],"disallowed"],[[66432,66461],"valid"],[[66462,66462],"disallowed"],[[66463,66463],"valid",[],"NV8"],[[66464,66499],"valid"],[[66500,66503],"disallowed"],[[66504,66511],"valid"],[[66512,66517],"valid",[],"NV8"],[[66518,66559],"disallowed"],[[66560,66560],"mapped",[66600]],[[66561,66561],"mapped",[66601]],[[66562,66562],"mapped",[66602]],[[66563,66563],"mapped",[66603]],[[66564,66564],"mapped",[66604]],[[66565,66565],"mapped",[66605]],[[66566,66566],"mapped",[66606]],[[66567,66567],"mapped",[66607]],[[66568,66568],"mapped",[66608]],[[66569,66569],"mapped",[66609]],[[66570,66570],"mapped",[66610]],[[66571,66571],"mapped",[66611]],[[66572,66572],"mapped",[66612]],[[66573,66573],"mapped",[66613]],[[66574,66574],"mapped",[66614]],[[66575,66575],"mapped",[66615]],[[66576,66576],"mapped",[66616]],[[66577,66577],"mapped",[66617]],[[66578,66578],"mapped",[66618]],[[66579,66579],"mapped",[66619]],[[66580,66580],"mapped",[66620]],[[66581,66581],"mapped",[66621]],[[66582,66582],"mapped",[66622]],[[66583,66583],"mapped",[66623]],[[66584,66584],"mapped",[66624]],[[66585,66585],"mapped",[66625]],[[66586,66586],"mapped",[66626]],[[66587,66587],"mapped",[66627]],[[66588,66588],"mapped",[66628]],[[66589,66589],"mapped",[66629]],[[66590,66590],"mapped",[66630]],[[66591,66591],"mapped",[66631]],[[66592,66592],"mapped",[66632]],[[66593,66593],"mapped",[66633]],[[66594,66594],"mapped",[66634]],[[66595,66595],"mapped",[66635]],[[66596,66596],"mapped",[66636]],[[66597,66597],"mapped",[66637]],[[66598,66598],"mapped",[66638]],[[66599,66599],"mapped",[66639]],[[66600,66637],"valid"],[[66638,66717],"valid"],[[66718,66719],"disallowed"],[[66720,66729],"valid"],[[66730,66815],"disallowed"],[[66816,66855],"valid"],[[66856,66863],"disallowed"],[[66864,66915],"valid"],[[66916,66926],"disallowed"],[[66927,66927],"valid",[],"NV8"],[[66928,67071],"disallowed"],[[67072,67382],"valid"],[[67383,67391],"disallowed"],[[67392,67413],"valid"],[[67414,67423],"disallowed"],[[67424,67431],"valid"],[[67432,67583],"disallowed"],[[67584,67589],"valid"],[[67590,67591],"disallowed"],[[67592,67592],"valid"],[[67593,67593],"disallowed"],[[67594,67637],"valid"],[[67638,67638],"disallowed"],[[67639,67640],"valid"],[[67641,67643],"disallowed"],[[67644,67644],"valid"],[[67645,67646],"disallowed"],[[67647,67647],"valid"],[[67648,67669],"valid"],[[67670,67670],"disallowed"],[[67671,67679],"valid",[],"NV8"],[[67680,67702],"valid"],[[67703,67711],"valid",[],"NV8"],[[67712,67742],"valid"],[[67743,67750],"disallowed"],[[67751,67759],"valid",[],"NV8"],[[67760,67807],"disallowed"],[[67808,67826],"valid"],[[67827,67827],"disallowed"],[[67828,67829],"valid"],[[67830,67834],"disallowed"],[[67835,67839],"valid",[],"NV8"],[[67840,67861],"valid"],[[67862,67865],"valid",[],"NV8"],[[67866,67867],"valid",[],"NV8"],[[67868,67870],"disallowed"],[[67871,67871],"valid",[],"NV8"],[[67872,67897],"valid"],[[67898,67902],"disallowed"],[[67903,67903],"valid",[],"NV8"],[[67904,67967],"disallowed"],[[67968,68023],"valid"],[[68024,68027],"disallowed"],[[68028,68029],"valid",[],"NV8"],[[68030,68031],"valid"],[[68032,68047],"valid",[],"NV8"],[[68048,68049],"disallowed"],[[68050,68095],"valid",[],"NV8"],[[68096,68099],"valid"],[[68100,68100],"disallowed"],[[68101,68102],"valid"],[[68103,68107],"disallowed"],[[68108,68115],"valid"],[[68116,68116],"disallowed"],[[68117,68119],"valid"],[[68120,68120],"disallowed"],[[68121,68147],"valid"],[[68148,68151],"disallowed"],[[68152,68154],"valid"],[[68155,68158],"disallowed"],[[68159,68159],"valid"],[[68160,68167],"valid",[],"NV8"],[[68168,68175],"disallowed"],[[68176,68184],"valid",[],"NV8"],[[68185,68191],"disallowed"],[[68192,68220],"valid"],[[68221,68223],"valid",[],"NV8"],[[68224,68252],"valid"],[[68253,68255],"valid",[],"NV8"],[[68256,68287],"disallowed"],[[68288,68295],"valid"],[[68296,68296],"valid",[],"NV8"],[[68297,68326],"valid"],[[68327,68330],"disallowed"],[[68331,68342],"valid",[],"NV8"],[[68343,68351],"disallowed"],[[68352,68405],"valid"],[[68406,68408],"disallowed"],[[68409,68415],"valid",[],"NV8"],[[68416,68437],"valid"],[[68438,68439],"disallowed"],[[68440,68447],"valid",[],"NV8"],[[68448,68466],"valid"],[[68467,68471],"disallowed"],[[68472,68479],"valid",[],"NV8"],[[68480,68497],"valid"],[[68498,68504],"disallowed"],[[68505,68508],"valid",[],"NV8"],[[68509,68520],"disallowed"],[[68521,68527],"valid",[],"NV8"],[[68528,68607],"disallowed"],[[68608,68680],"valid"],[[68681,68735],"disallowed"],[[68736,68736],"mapped",[68800]],[[68737,68737],"mapped",[68801]],[[68738,68738],"mapped",[68802]],[[68739,68739],"mapped",[68803]],[[68740,68740],"mapped",[68804]],[[68741,68741],"mapped",[68805]],[[68742,68742],"mapped",[68806]],[[68743,68743],"mapped",[68807]],[[68744,68744],"mapped",[68808]],[[68745,68745],"mapped",[68809]],[[68746,68746],"mapped",[68810]],[[68747,68747],"mapped",[68811]],[[68748,68748],"mapped",[68812]],[[68749,68749],"mapped",[68813]],[[68750,68750],"mapped",[68814]],[[68751,68751],"mapped",[68815]],[[68752,68752],"mapped",[68816]],[[68753,68753],"mapped",[68817]],[[68754,68754],"mapped",[68818]],[[68755,68755],"mapped",[68819]],[[68756,68756],"mapped",[68820]],[[68757,68757],"mapped",[68821]],[[68758,68758],"mapped",[68822]],[[68759,68759],"mapped",[68823]],[[68760,68760],"mapped",[68824]],[[68761,68761],"mapped",[68825]],[[68762,68762],"mapped",[68826]],[[68763,68763],"mapped",[68827]],[[68764,68764],"mapped",[68828]],[[68765,68765],"mapped",[68829]],[[68766,68766],"mapped",[68830]],[[68767,68767],"mapped",[68831]],[[68768,68768],"mapped",[68832]],[[68769,68769],"mapped",[68833]],[[68770,68770],"mapped",[68834]],[[68771,68771],"mapped",[68835]],[[68772,68772],"mapped",[68836]],[[68773,68773],"mapped",[68837]],[[68774,68774],"mapped",[68838]],[[68775,68775],"mapped",[68839]],[[68776,68776],"mapped",[68840]],[[68777,68777],"mapped",[68841]],[[68778,68778],"mapped",[68842]],[[68779,68779],"mapped",[68843]],[[68780,68780],"mapped",[68844]],[[68781,68781],"mapped",[68845]],[[68782,68782],"mapped",[68846]],[[68783,68783],"mapped",[68847]],[[68784,68784],"mapped",[68848]],[[68785,68785],"mapped",[68849]],[[68786,68786],"mapped",[68850]],[[68787,68799],"disallowed"],[[68800,68850],"valid"],[[68851,68857],"disallowed"],[[68858,68863],"valid",[],"NV8"],[[68864,69215],"disallowed"],[[69216,69246],"valid",[],"NV8"],[[69247,69631],"disallowed"],[[69632,69702],"valid"],[[69703,69709],"valid",[],"NV8"],[[69710,69713],"disallowed"],[[69714,69733],"valid",[],"NV8"],[[69734,69743],"valid"],[[69744,69758],"disallowed"],[[69759,69759],"valid"],[[69760,69818],"valid"],[[69819,69820],"valid",[],"NV8"],[[69821,69821],"disallowed"],[[69822,69825],"valid",[],"NV8"],[[69826,69839],"disallowed"],[[69840,69864],"valid"],[[69865,69871],"disallowed"],[[69872,69881],"valid"],[[69882,69887],"disallowed"],[[69888,69940],"valid"],[[69941,69941],"disallowed"],[[69942,69951],"valid"],[[69952,69955],"valid",[],"NV8"],[[69956,69967],"disallowed"],[[69968,70003],"valid"],[[70004,70005],"valid",[],"NV8"],[[70006,70006],"valid"],[[70007,70015],"disallowed"],[[70016,70084],"valid"],[[70085,70088],"valid",[],"NV8"],[[70089,70089],"valid",[],"NV8"],[[70090,70092],"valid"],[[70093,70093],"valid",[],"NV8"],[[70094,70095],"disallowed"],[[70096,70105],"valid"],[[70106,70106],"valid"],[[70107,70107],"valid",[],"NV8"],[[70108,70108],"valid"],[[70109,70111],"valid",[],"NV8"],[[70112,70112],"disallowed"],[[70113,70132],"valid",[],"NV8"],[[70133,70143],"disallowed"],[[70144,70161],"valid"],[[70162,70162],"disallowed"],[[70163,70199],"valid"],[[70200,70205],"valid",[],"NV8"],[[70206,70271],"disallowed"],[[70272,70278],"valid"],[[70279,70279],"disallowed"],[[70280,70280],"valid"],[[70281,70281],"disallowed"],[[70282,70285],"valid"],[[70286,70286],"disallowed"],[[70287,70301],"valid"],[[70302,70302],"disallowed"],[[70303,70312],"valid"],[[70313,70313],"valid",[],"NV8"],[[70314,70319],"disallowed"],[[70320,70378],"valid"],[[70379,70383],"disallowed"],[[70384,70393],"valid"],[[70394,70399],"disallowed"],[[70400,70400],"valid"],[[70401,70403],"valid"],[[70404,70404],"disallowed"],[[70405,70412],"valid"],[[70413,70414],"disallowed"],[[70415,70416],"valid"],[[70417,70418],"disallowed"],[[70419,70440],"valid"],[[70441,70441],"disallowed"],[[70442,70448],"valid"],[[70449,70449],"disallowed"],[[70450,70451],"valid"],[[70452,70452],"disallowed"],[[70453,70457],"valid"],[[70458,70459],"disallowed"],[[70460,70468],"valid"],[[70469,70470],"disallowed"],[[70471,70472],"valid"],[[70473,70474],"disallowed"],[[70475,70477],"valid"],[[70478,70479],"disallowed"],[[70480,70480],"valid"],[[70481,70486],"disallowed"],[[70487,70487],"valid"],[[70488,70492],"disallowed"],[[70493,70499],"valid"],[[70500,70501],"disallowed"],[[70502,70508],"valid"],[[70509,70511],"disallowed"],[[70512,70516],"valid"],[[70517,70783],"disallowed"],[[70784,70853],"valid"],[[70854,70854],"valid",[],"NV8"],[[70855,70855],"valid"],[[70856,70863],"disallowed"],[[70864,70873],"valid"],[[70874,71039],"disallowed"],[[71040,71093],"valid"],[[71094,71095],"disallowed"],[[71096,71104],"valid"],[[71105,71113],"valid",[],"NV8"],[[71114,71127],"valid",[],"NV8"],[[71128,71133],"valid"],[[71134,71167],"disallowed"],[[71168,71232],"valid"],[[71233,71235],"valid",[],"NV8"],[[71236,71236],"valid"],[[71237,71247],"disallowed"],[[71248,71257],"valid"],[[71258,71295],"disallowed"],[[71296,71351],"valid"],[[71352,71359],"disallowed"],[[71360,71369],"valid"],[[71370,71423],"disallowed"],[[71424,71449],"valid"],[[71450,71452],"disallowed"],[[71453,71467],"valid"],[[71468,71471],"disallowed"],[[71472,71481],"valid"],[[71482,71487],"valid",[],"NV8"],[[71488,71839],"disallowed"],[[71840,71840],"mapped",[71872]],[[71841,71841],"mapped",[71873]],[[71842,71842],"mapped",[71874]],[[71843,71843],"mapped",[71875]],[[71844,71844],"mapped",[71876]],[[71845,71845],"mapped",[71877]],[[71846,71846],"mapped",[71878]],[[71847,71847],"mapped",[71879]],[[71848,71848],"mapped",[71880]],[[71849,71849],"mapped",[71881]],[[71850,71850],"mapped",[71882]],[[71851,71851],"mapped",[71883]],[[71852,71852],"mapped",[71884]],[[71853,71853],"mapped",[71885]],[[71854,71854],"mapped",[71886]],[[71855,71855],"mapped",[71887]],[[71856,71856],"mapped",[71888]],[[71857,71857],"mapped",[71889]],[[71858,71858],"mapped",[71890]],[[71859,71859],"mapped",[71891]],[[71860,71860],"mapped",[71892]],[[71861,71861],"mapped",[71893]],[[71862,71862],"mapped",[71894]],[[71863,71863],"mapped",[71895]],[[71864,71864],"mapped",[71896]],[[71865,71865],"mapped",[71897]],[[71866,71866],"mapped",[71898]],[[71867,71867],"mapped",[71899]],[[71868,71868],"mapped",[71900]],[[71869,71869],"mapped",[71901]],[[71870,71870],"mapped",[71902]],[[71871,71871],"mapped",[71903]],[[71872,71913],"valid"],[[71914,71922],"valid",[],"NV8"],[[71923,71934],"disallowed"],[[71935,71935],"valid"],[[71936,72383],"disallowed"],[[72384,72440],"valid"],[[72441,73727],"disallowed"],[[73728,74606],"valid"],[[74607,74648],"valid"],[[74649,74649],"valid"],[[74650,74751],"disallowed"],[[74752,74850],"valid",[],"NV8"],[[74851,74862],"valid",[],"NV8"],[[74863,74863],"disallowed"],[[74864,74867],"valid",[],"NV8"],[[74868,74868],"valid",[],"NV8"],[[74869,74879],"disallowed"],[[74880,75075],"valid"],[[75076,77823],"disallowed"],[[77824,78894],"valid"],[[78895,82943],"disallowed"],[[82944,83526],"valid"],[[83527,92159],"disallowed"],[[92160,92728],"valid"],[[92729,92735],"disallowed"],[[92736,92766],"valid"],[[92767,92767],"disallowed"],[[92768,92777],"valid"],[[92778,92781],"disallowed"],[[92782,92783],"valid",[],"NV8"],[[92784,92879],"disallowed"],[[92880,92909],"valid"],[[92910,92911],"disallowed"],[[92912,92916],"valid"],[[92917,92917],"valid",[],"NV8"],[[92918,92927],"disallowed"],[[92928,92982],"valid"],[[92983,92991],"valid",[],"NV8"],[[92992,92995],"valid"],[[92996,92997],"valid",[],"NV8"],[[92998,93007],"disallowed"],[[93008,93017],"valid"],[[93018,93018],"disallowed"],[[93019,93025],"valid",[],"NV8"],[[93026,93026],"disallowed"],[[93027,93047],"valid"],[[93048,93052],"disallowed"],[[93053,93071],"valid"],[[93072,93951],"disallowed"],[[93952,94020],"valid"],[[94021,94031],"disallowed"],[[94032,94078],"valid"],[[94079,94094],"disallowed"],[[94095,94111],"valid"],[[94112,110591],"disallowed"],[[110592,110593],"valid"],[[110594,113663],"disallowed"],[[113664,113770],"valid"],[[113771,113775],"disallowed"],[[113776,113788],"valid"],[[113789,113791],"disallowed"],[[113792,113800],"valid"],[[113801,113807],"disallowed"],[[113808,113817],"valid"],[[113818,113819],"disallowed"],[[113820,113820],"valid",[],"NV8"],[[113821,113822],"valid"],[[113823,113823],"valid",[],"NV8"],[[113824,113827],"ignored"],[[113828,118783],"disallowed"],[[118784,119029],"valid",[],"NV8"],[[119030,119039],"disallowed"],[[119040,119078],"valid",[],"NV8"],[[119079,119080],"disallowed"],[[119081,119081],"valid",[],"NV8"],[[119082,119133],"valid",[],"NV8"],[[119134,119134],"mapped",[119127,119141]],[[119135,119135],"mapped",[119128,119141]],[[119136,119136],"mapped",[119128,119141,119150]],[[119137,119137],"mapped",[119128,119141,119151]],[[119138,119138],"mapped",[119128,119141,119152]],[[119139,119139],"mapped",[119128,119141,119153]],[[119140,119140],"mapped",[119128,119141,119154]],[[119141,119154],"valid",[],"NV8"],[[119155,119162],"disallowed"],[[119163,119226],"valid",[],"NV8"],[[119227,119227],"mapped",[119225,119141]],[[119228,119228],"mapped",[119226,119141]],[[119229,119229],"mapped",[119225,119141,119150]],[[119230,119230],"mapped",[119226,119141,119150]],[[119231,119231],"mapped",[119225,119141,119151]],[[119232,119232],"mapped",[119226,119141,119151]],[[119233,119261],"valid",[],"NV8"],[[119262,119272],"valid",[],"NV8"],[[119273,119295],"disallowed"],[[119296,119365],"valid",[],"NV8"],[[119366,119551],"disallowed"],[[119552,119638],"valid",[],"NV8"],[[119639,119647],"disallowed"],[[119648,119665],"valid",[],"NV8"],[[119666,119807],"disallowed"],[[119808,119808],"mapped",[97]],[[119809,119809],"mapped",[98]],[[119810,119810],"mapped",[99]],[[119811,119811],"mapped",[100]],[[119812,119812],"mapped",[101]],[[119813,119813],"mapped",[102]],[[119814,119814],"mapped",[103]],[[119815,119815],"mapped",[104]],[[119816,119816],"mapped",[105]],[[119817,119817],"mapped",[106]],[[119818,119818],"mapped",[107]],[[119819,119819],"mapped",[108]],[[119820,119820],"mapped",[109]],[[119821,119821],"mapped",[110]],[[119822,119822],"mapped",[111]],[[119823,119823],"mapped",[112]],[[119824,119824],"mapped",[113]],[[119825,119825],"mapped",[114]],[[119826,119826],"mapped",[115]],[[119827,119827],"mapped",[116]],[[119828,119828],"mapped",[117]],[[119829,119829],"mapped",[118]],[[119830,119830],"mapped",[119]],[[119831,119831],"mapped",[120]],[[119832,119832],"mapped",[121]],[[119833,119833],"mapped",[122]],[[119834,119834],"mapped",[97]],[[119835,119835],"mapped",[98]],[[119836,119836],"mapped",[99]],[[119837,119837],"mapped",[100]],[[119838,119838],"mapped",[101]],[[119839,119839],"mapped",[102]],[[119840,119840],"mapped",[103]],[[119841,119841],"mapped",[104]],[[119842,119842],"mapped",[105]],[[119843,119843],"mapped",[106]],[[119844,119844],"mapped",[107]],[[119845,119845],"mapped",[108]],[[119846,119846],"mapped",[109]],[[119847,119847],"mapped",[110]],[[119848,119848],"mapped",[111]],[[119849,119849],"mapped",[112]],[[119850,119850],"mapped",[113]],[[119851,119851],"mapped",[114]],[[119852,119852],"mapped",[115]],[[119853,119853],"mapped",[116]],[[119854,119854],"mapped",[117]],[[119855,119855],"mapped",[118]],[[119856,119856],"mapped",[119]],[[119857,119857],"mapped",[120]],[[119858,119858],"mapped",[121]],[[119859,119859],"mapped",[122]],[[119860,119860],"mapped",[97]],[[119861,119861],"mapped",[98]],[[119862,119862],"mapped",[99]],[[119863,119863],"mapped",[100]],[[119864,119864],"mapped",[101]],[[119865,119865],"mapped",[102]],[[119866,119866],"mapped",[103]],[[119867,119867],"mapped",[104]],[[119868,119868],"mapped",[105]],[[119869,119869],"mapped",[106]],[[119870,119870],"mapped",[107]],[[119871,119871],"mapped",[108]],[[119872,119872],"mapped",[109]],[[119873,119873],"mapped",[110]],[[119874,119874],"mapped",[111]],[[119875,119875],"mapped",[112]],[[119876,119876],"mapped",[113]],[[119877,119877],"mapped",[114]],[[119878,119878],"mapped",[115]],[[119879,119879],"mapped",[116]],[[119880,119880],"mapped",[117]],[[119881,119881],"mapped",[118]],[[119882,119882],"mapped",[119]],[[119883,119883],"mapped",[120]],[[119884,119884],"mapped",[121]],[[119885,119885],"mapped",[122]],[[119886,119886],"mapped",[97]],[[119887,119887],"mapped",[98]],[[119888,119888],"mapped",[99]],[[119889,119889],"mapped",[100]],[[119890,119890],"mapped",[101]],[[119891,119891],"mapped",[102]],[[119892,119892],"mapped",[103]],[[119893,119893],"disallowed"],[[119894,119894],"mapped",[105]],[[119895,119895],"mapped",[106]],[[119896,119896],"mapped",[107]],[[119897,119897],"mapped",[108]],[[119898,119898],"mapped",[109]],[[119899,119899],"mapped",[110]],[[119900,119900],"mapped",[111]],[[119901,119901],"mapped",[112]],[[119902,119902],"mapped",[113]],[[119903,119903],"mapped",[114]],[[119904,119904],"mapped",[115]],[[119905,119905],"mapped",[116]],[[119906,119906],"mapped",[117]],[[119907,119907],"mapped",[118]],[[119908,119908],"mapped",[119]],[[119909,119909],"mapped",[120]],[[119910,119910],"mapped",[121]],[[119911,119911],"mapped",[122]],[[119912,119912],"mapped",[97]],[[119913,119913],"mapped",[98]],[[119914,119914],"mapped",[99]],[[119915,119915],"mapped",[100]],[[119916,119916],"mapped",[101]],[[119917,119917],"mapped",[102]],[[119918,119918],"mapped",[103]],[[119919,119919],"mapped",[104]],[[119920,119920],"mapped",[105]],[[119921,119921],"mapped",[106]],[[119922,119922],"mapped",[107]],[[119923,119923],"mapped",[108]],[[119924,119924],"mapped",[109]],[[119925,119925],"mapped",[110]],[[119926,119926],"mapped",[111]],[[119927,119927],"mapped",[112]],[[119928,119928],"mapped",[113]],[[119929,119929],"mapped",[114]],[[119930,119930],"mapped",[115]],[[119931,119931],"mapped",[116]],[[119932,119932],"mapped",[117]],[[119933,119933],"mapped",[118]],[[119934,119934],"mapped",[119]],[[119935,119935],"mapped",[120]],[[119936,119936],"mapped",[121]],[[119937,119937],"mapped",[122]],[[119938,119938],"mapped",[97]],[[119939,119939],"mapped",[98]],[[119940,119940],"mapped",[99]],[[119941,119941],"mapped",[100]],[[119942,119942],"mapped",[101]],[[119943,119943],"mapped",[102]],[[119944,119944],"mapped",[103]],[[119945,119945],"mapped",[104]],[[119946,119946],"mapped",[105]],[[119947,119947],"mapped",[106]],[[119948,119948],"mapped",[107]],[[119949,119949],"mapped",[108]],[[119950,119950],"mapped",[109]],[[119951,119951],"mapped",[110]],[[119952,119952],"mapped",[111]],[[119953,119953],"mapped",[112]],[[119954,119954],"mapped",[113]],[[119955,119955],"mapped",[114]],[[119956,119956],"mapped",[115]],[[119957,119957],"mapped",[116]],[[119958,119958],"mapped",[117]],[[119959,119959],"mapped",[118]],[[119960,119960],"mapped",[119]],[[119961,119961],"mapped",[120]],[[119962,119962],"mapped",[121]],[[119963,119963],"mapped",[122]],[[119964,119964],"mapped",[97]],[[119965,119965],"disallowed"],[[119966,119966],"mapped",[99]],[[119967,119967],"mapped",[100]],[[119968,119969],"disallowed"],[[119970,119970],"mapped",[103]],[[119971,119972],"disallowed"],[[119973,119973],"mapped",[106]],[[119974,119974],"mapped",[107]],[[119975,119976],"disallowed"],[[119977,119977],"mapped",[110]],[[119978,119978],"mapped",[111]],[[119979,119979],"mapped",[112]],[[119980,119980],"mapped",[113]],[[119981,119981],"disallowed"],[[119982,119982],"mapped",[115]],[[119983,119983],"mapped",[116]],[[119984,119984],"mapped",[117]],[[119985,119985],"mapped",[118]],[[119986,119986],"mapped",[119]],[[119987,119987],"mapped",[120]],[[119988,119988],"mapped",[121]],[[119989,119989],"mapped",[122]],[[119990,119990],"mapped",[97]],[[119991,119991],"mapped",[98]],[[119992,119992],"mapped",[99]],[[119993,119993],"mapped",[100]],[[119994,119994],"disallowed"],[[119995,119995],"mapped",[102]],[[119996,119996],"disallowed"],[[119997,119997],"mapped",[104]],[[119998,119998],"mapped",[105]],[[119999,119999],"mapped",[106]],[[120000,120000],"mapped",[107]],[[120001,120001],"mapped",[108]],[[120002,120002],"mapped",[109]],[[120003,120003],"mapped",[110]],[[120004,120004],"disallowed"],[[120005,120005],"mapped",[112]],[[120006,120006],"mapped",[113]],[[120007,120007],"mapped",[114]],[[120008,120008],"mapped",[115]],[[120009,120009],"mapped",[116]],[[120010,120010],"mapped",[117]],[[120011,120011],"mapped",[118]],[[120012,120012],"mapped",[119]],[[120013,120013],"mapped",[120]],[[120014,120014],"mapped",[121]],[[120015,120015],"mapped",[122]],[[120016,120016],"mapped",[97]],[[120017,120017],"mapped",[98]],[[120018,120018],"mapped",[99]],[[120019,120019],"mapped",[100]],[[120020,120020],"mapped",[101]],[[120021,120021],"mapped",[102]],[[120022,120022],"mapped",[103]],[[120023,120023],"mapped",[104]],[[120024,120024],"mapped",[105]],[[120025,120025],"mapped",[106]],[[120026,120026],"mapped",[107]],[[120027,120027],"mapped",[108]],[[120028,120028],"mapped",[109]],[[120029,120029],"mapped",[110]],[[120030,120030],"mapped",[111]],[[120031,120031],"mapped",[112]],[[120032,120032],"mapped",[113]],[[120033,120033],"mapped",[114]],[[120034,120034],"mapped",[115]],[[120035,120035],"mapped",[116]],[[120036,120036],"mapped",[117]],[[120037,120037],"mapped",[118]],[[120038,120038],"mapped",[119]],[[120039,120039],"mapped",[120]],[[120040,120040],"mapped",[121]],[[120041,120041],"mapped",[122]],[[120042,120042],"mapped",[97]],[[120043,120043],"mapped",[98]],[[120044,120044],"mapped",[99]],[[120045,120045],"mapped",[100]],[[120046,120046],"mapped",[101]],[[120047,120047],"mapped",[102]],[[120048,120048],"mapped",[103]],[[120049,120049],"mapped",[104]],[[120050,120050],"mapped",[105]],[[120051,120051],"mapped",[106]],[[120052,120052],"mapped",[107]],[[120053,120053],"mapped",[108]],[[120054,120054],"mapped",[109]],[[120055,120055],"mapped",[110]],[[120056,120056],"mapped",[111]],[[120057,120057],"mapped",[112]],[[120058,120058],"mapped",[113]],[[120059,120059],"mapped",[114]],[[120060,120060],"mapped",[115]],[[120061,120061],"mapped",[116]],[[120062,120062],"mapped",[117]],[[120063,120063],"mapped",[118]],[[120064,120064],"mapped",[119]],[[120065,120065],"mapped",[120]],[[120066,120066],"mapped",[121]],[[120067,120067],"mapped",[122]],[[120068,120068],"mapped",[97]],[[120069,120069],"mapped",[98]],[[120070,120070],"disallowed"],[[120071,120071],"mapped",[100]],[[120072,120072],"mapped",[101]],[[120073,120073],"mapped",[102]],[[120074,120074],"mapped",[103]],[[120075,120076],"disallowed"],[[120077,120077],"mapped",[106]],[[120078,120078],"mapped",[107]],[[120079,120079],"mapped",[108]],[[120080,120080],"mapped",[109]],[[120081,120081],"mapped",[110]],[[120082,120082],"mapped",[111]],[[120083,120083],"mapped",[112]],[[120084,120084],"mapped",[113]],[[120085,120085],"disallowed"],[[120086,120086],"mapped",[115]],[[120087,120087],"mapped",[116]],[[120088,120088],"mapped",[117]],[[120089,120089],"mapped",[118]],[[120090,120090],"mapped",[119]],[[120091,120091],"mapped",[120]],[[120092,120092],"mapped",[121]],[[120093,120093],"disallowed"],[[120094,120094],"mapped",[97]],[[120095,120095],"mapped",[98]],[[120096,120096],"mapped",[99]],[[120097,120097],"mapped",[100]],[[120098,120098],"mapped",[101]],[[120099,120099],"mapped",[102]],[[120100,120100],"mapped",[103]],[[120101,120101],"mapped",[104]],[[120102,120102],"mapped",[105]],[[120103,120103],"mapped",[106]],[[120104,120104],"mapped",[107]],[[120105,120105],"mapped",[108]],[[120106,120106],"mapped",[109]],[[120107,120107],"mapped",[110]],[[120108,120108],"mapped",[111]],[[120109,120109],"mapped",[112]],[[120110,120110],"mapped",[113]],[[120111,120111],"mapped",[114]],[[120112,120112],"mapped",[115]],[[120113,120113],"mapped",[116]],[[120114,120114],"mapped",[117]],[[120115,120115],"mapped",[118]],[[120116,120116],"mapped",[119]],[[120117,120117],"mapped",[120]],[[120118,120118],"mapped",[121]],[[120119,120119],"mapped",[122]],[[120120,120120],"mapped",[97]],[[120121,120121],"mapped",[98]],[[120122,120122],"disallowed"],[[120123,120123],"mapped",[100]],[[120124,120124],"mapped",[101]],[[120125,120125],"mapped",[102]],[[120126,120126],"mapped",[103]],[[120127,120127],"disallowed"],[[120128,120128],"mapped",[105]],[[120129,120129],"mapped",[106]],[[120130,120130],"mapped",[107]],[[120131,120131],"mapped",[108]],[[120132,120132],"mapped",[109]],[[120133,120133],"disallowed"],[[120134,120134],"mapped",[111]],[[120135,120137],"disallowed"],[[120138,120138],"mapped",[115]],[[120139,120139],"mapped",[116]],[[120140,120140],"mapped",[117]],[[120141,120141],"mapped",[118]],[[120142,120142],"mapped",[119]],[[120143,120143],"mapped",[120]],[[120144,120144],"mapped",[121]],[[120145,120145],"disallowed"],[[120146,120146],"mapped",[97]],[[120147,120147],"mapped",[98]],[[120148,120148],"mapped",[99]],[[120149,120149],"mapped",[100]],[[120150,120150],"mapped",[101]],[[120151,120151],"mapped",[102]],[[120152,120152],"mapped",[103]],[[120153,120153],"mapped",[104]],[[120154,120154],"mapped",[105]],[[120155,120155],"mapped",[106]],[[120156,120156],"mapped",[107]],[[120157,120157],"mapped",[108]],[[120158,120158],"mapped",[109]],[[120159,120159],"mapped",[110]],[[120160,120160],"mapped",[111]],[[120161,120161],"mapped",[112]],[[120162,120162],"mapped",[113]],[[120163,120163],"mapped",[114]],[[120164,120164],"mapped",[115]],[[120165,120165],"mapped",[116]],[[120166,120166],"mapped",[117]],[[120167,120167],"mapped",[118]],[[120168,120168],"mapped",[119]],[[120169,120169],"mapped",[120]],[[120170,120170],"mapped",[121]],[[120171,120171],"mapped",[122]],[[120172,120172],"mapped",[97]],[[120173,120173],"mapped",[98]],[[120174,120174],"mapped",[99]],[[120175,120175],"mapped",[100]],[[120176,120176],"mapped",[101]],[[120177,120177],"mapped",[102]],[[120178,120178],"mapped",[103]],[[120179,120179],"mapped",[104]],[[120180,120180],"mapped",[105]],[[120181,120181],"mapped",[106]],[[120182,120182],"mapped",[107]],[[120183,120183],"mapped",[108]],[[120184,120184],"mapped",[109]],[[120185,120185],"mapped",[110]],[[120186,120186],"mapped",[111]],[[120187,120187],"mapped",[112]],[[120188,120188],"mapped",[113]],[[120189,120189],"mapped",[114]],[[120190,120190],"mapped",[115]],[[120191,120191],"mapped",[116]],[[120192,120192],"mapped",[117]],[[120193,120193],"mapped",[118]],[[120194,120194],"mapped",[119]],[[120195,120195],"mapped",[120]],[[120196,120196],"mapped",[121]],[[120197,120197],"mapped",[122]],[[120198,120198],"mapped",[97]],[[120199,120199],"mapped",[98]],[[120200,120200],"mapped",[99]],[[120201,120201],"mapped",[100]],[[120202,120202],"mapped",[101]],[[120203,120203],"mapped",[102]],[[120204,120204],"mapped",[103]],[[120205,120205],"mapped",[104]],[[120206,120206],"mapped",[105]],[[120207,120207],"mapped",[106]],[[120208,120208],"mapped",[107]],[[120209,120209],"mapped",[108]],[[120210,120210],"mapped",[109]],[[120211,120211],"mapped",[110]],[[120212,120212],"mapped",[111]],[[120213,120213],"mapped",[112]],[[120214,120214],"mapped",[113]],[[120215,120215],"mapped",[114]],[[120216,120216],"mapped",[115]],[[120217,120217],"mapped",[116]],[[120218,120218],"mapped",[117]],[[120219,120219],"mapped",[118]],[[120220,120220],"mapped",[119]],[[120221,120221],"mapped",[120]],[[120222,120222],"mapped",[121]],[[120223,120223],"mapped",[122]],[[120224,120224],"mapped",[97]],[[120225,120225],"mapped",[98]],[[120226,120226],"mapped",[99]],[[120227,120227],"mapped",[100]],[[120228,120228],"mapped",[101]],[[120229,120229],"mapped",[102]],[[120230,120230],"mapped",[103]],[[120231,120231],"mapped",[104]],[[120232,120232],"mapped",[105]],[[120233,120233],"mapped",[106]],[[120234,120234],"mapped",[107]],[[120235,120235],"mapped",[108]],[[120236,120236],"mapped",[109]],[[120237,120237],"mapped",[110]],[[120238,120238],"mapped",[111]],[[120239,120239],"mapped",[112]],[[120240,120240],"mapped",[113]],[[120241,120241],"mapped",[114]],[[120242,120242],"mapped",[115]],[[120243,120243],"mapped",[116]],[[120244,120244],"mapped",[117]],[[120245,120245],"mapped",[118]],[[120246,120246],"mapped",[119]],[[120247,120247],"mapped",[120]],[[120248,120248],"mapped",[121]],[[120249,120249],"mapped",[122]],[[120250,120250],"mapped",[97]],[[120251,120251],"mapped",[98]],[[120252,120252],"mapped",[99]],[[120253,120253],"mapped",[100]],[[120254,120254],"mapped",[101]],[[120255,120255],"mapped",[102]],[[120256,120256],"mapped",[103]],[[120257,120257],"mapped",[104]],[[120258,120258],"mapped",[105]],[[120259,120259],"mapped",[106]],[[120260,120260],"mapped",[107]],[[120261,120261],"mapped",[108]],[[120262,120262],"mapped",[109]],[[120263,120263],"mapped",[110]],[[120264,120264],"mapped",[111]],[[120265,120265],"mapped",[112]],[[120266,120266],"mapped",[113]],[[120267,120267],"mapped",[114]],[[120268,120268],"mapped",[115]],[[120269,120269],"mapped",[116]],[[120270,120270],"mapped",[117]],[[120271,120271],"mapped",[118]],[[120272,120272],"mapped",[119]],[[120273,120273],"mapped",[120]],[[120274,120274],"mapped",[121]],[[120275,120275],"mapped",[122]],[[120276,120276],"mapped",[97]],[[120277,120277],"mapped",[98]],[[120278,120278],"mapped",[99]],[[120279,120279],"mapped",[100]],[[120280,120280],"mapped",[101]],[[120281,120281],"mapped",[102]],[[120282,120282],"mapped",[103]],[[120283,120283],"mapped",[104]],[[120284,120284],"mapped",[105]],[[120285,120285],"mapped",[106]],[[120286,120286],"mapped",[107]],[[120287,120287],"mapped",[108]],[[120288,120288],"mapped",[109]],[[120289,120289],"mapped",[110]],[[120290,120290],"mapped",[111]],[[120291,120291],"mapped",[112]],[[120292,120292],"mapped",[113]],[[120293,120293],"mapped",[114]],[[120294,120294],"mapped",[115]],[[120295,120295],"mapped",[116]],[[120296,120296],"mapped",[117]],[[120297,120297],"mapped",[118]],[[120298,120298],"mapped",[119]],[[120299,120299],"mapped",[120]],[[120300,120300],"mapped",[121]],[[120301,120301],"mapped",[122]],[[120302,120302],"mapped",[97]],[[120303,120303],"mapped",[98]],[[120304,120304],"mapped",[99]],[[120305,120305],"mapped",[100]],[[120306,120306],"mapped",[101]],[[120307,120307],"mapped",[102]],[[120308,120308],"mapped",[103]],[[120309,120309],"mapped",[104]],[[120310,120310],"mapped",[105]],[[120311,120311],"mapped",[106]],[[120312,120312],"mapped",[107]],[[120313,120313],"mapped",[108]],[[120314,120314],"mapped",[109]],[[120315,120315],"mapped",[110]],[[120316,120316],"mapped",[111]],[[120317,120317],"mapped",[112]],[[120318,120318],"mapped",[113]],[[120319,120319],"mapped",[114]],[[120320,120320],"mapped",[115]],[[120321,120321],"mapped",[116]],[[120322,120322],"mapped",[117]],[[120323,120323],"mapped",[118]],[[120324,120324],"mapped",[119]],[[120325,120325],"mapped",[120]],[[120326,120326],"mapped",[121]],[[120327,120327],"mapped",[122]],[[120328,120328],"mapped",[97]],[[120329,120329],"mapped",[98]],[[120330,120330],"mapped",[99]],[[120331,120331],"mapped",[100]],[[120332,120332],"mapped",[101]],[[120333,120333],"mapped",[102]],[[120334,120334],"mapped",[103]],[[120335,120335],"mapped",[104]],[[120336,120336],"mapped",[105]],[[120337,120337],"mapped",[106]],[[120338,120338],"mapped",[107]],[[120339,120339],"mapped",[108]],[[120340,120340],"mapped",[109]],[[120341,120341],"mapped",[110]],[[120342,120342],"mapped",[111]],[[120343,120343],"mapped",[112]],[[120344,120344],"mapped",[113]],[[120345,120345],"mapped",[114]],[[120346,120346],"mapped",[115]],[[120347,120347],"mapped",[116]],[[120348,120348],"mapped",[117]],[[120349,120349],"mapped",[118]],[[120350,120350],"mapped",[119]],[[120351,120351],"mapped",[120]],[[120352,120352],"mapped",[121]],[[120353,120353],"mapped",[122]],[[120354,120354],"mapped",[97]],[[120355,120355],"mapped",[98]],[[120356,120356],"mapped",[99]],[[120357,120357],"mapped",[100]],[[120358,120358],"mapped",[101]],[[120359,120359],"mapped",[102]],[[120360,120360],"mapped",[103]],[[120361,120361],"mapped",[104]],[[120362,120362],"mapped",[105]],[[120363,120363],"mapped",[106]],[[120364,120364],"mapped",[107]],[[120365,120365],"mapped",[108]],[[120366,120366],"mapped",[109]],[[120367,120367],"mapped",[110]],[[120368,120368],"mapped",[111]],[[120369,120369],"mapped",[112]],[[120370,120370],"mapped",[113]],[[120371,120371],"mapped",[114]],[[120372,120372],"mapped",[115]],[[120373,120373],"mapped",[116]],[[120374,120374],"mapped",[117]],[[120375,120375],"mapped",[118]],[[120376,120376],"mapped",[119]],[[120377,120377],"mapped",[120]],[[120378,120378],"mapped",[121]],[[120379,120379],"mapped",[122]],[[120380,120380],"mapped",[97]],[[120381,120381],"mapped",[98]],[[120382,120382],"mapped",[99]],[[120383,120383],"mapped",[100]],[[120384,120384],"mapped",[101]],[[120385,120385],"mapped",[102]],[[120386,120386],"mapped",[103]],[[120387,120387],"mapped",[104]],[[120388,120388],"mapped",[105]],[[120389,120389],"mapped",[106]],[[120390,120390],"mapped",[107]],[[120391,120391],"mapped",[108]],[[120392,120392],"mapped",[109]],[[120393,120393],"mapped",[110]],[[120394,120394],"mapped",[111]],[[120395,120395],"mapped",[112]],[[120396,120396],"mapped",[113]],[[120397,120397],"mapped",[114]],[[120398,120398],"mapped",[115]],[[120399,120399],"mapped",[116]],[[120400,120400],"mapped",[117]],[[120401,120401],"mapped",[118]],[[120402,120402],"mapped",[119]],[[120403,120403],"mapped",[120]],[[120404,120404],"mapped",[121]],[[120405,120405],"mapped",[122]],[[120406,120406],"mapped",[97]],[[120407,120407],"mapped",[98]],[[120408,120408],"mapped",[99]],[[120409,120409],"mapped",[100]],[[120410,120410],"mapped",[101]],[[120411,120411],"mapped",[102]],[[120412,120412],"mapped",[103]],[[120413,120413],"mapped",[104]],[[120414,120414],"mapped",[105]],[[120415,120415],"mapped",[106]],[[120416,120416],"mapped",[107]],[[120417,120417],"mapped",[108]],[[120418,120418],"mapped",[109]],[[120419,120419],"mapped",[110]],[[120420,120420],"mapped",[111]],[[120421,120421],"mapped",[112]],[[120422,120422],"mapped",[113]],[[120423,120423],"mapped",[114]],[[120424,120424],"mapped",[115]],[[120425,120425],"mapped",[116]],[[120426,120426],"mapped",[117]],[[120427,120427],"mapped",[118]],[[120428,120428],"mapped",[119]],[[120429,120429],"mapped",[120]],[[120430,120430],"mapped",[121]],[[120431,120431],"mapped",[122]],[[120432,120432],"mapped",[97]],[[120433,120433],"mapped",[98]],[[120434,120434],"mapped",[99]],[[120435,120435],"mapped",[100]],[[120436,120436],"mapped",[101]],[[120437,120437],"mapped",[102]],[[120438,120438],"mapped",[103]],[[120439,120439],"mapped",[104]],[[120440,120440],"mapped",[105]],[[120441,120441],"mapped",[106]],[[120442,120442],"mapped",[107]],[[120443,120443],"mapped",[108]],[[120444,120444],"mapped",[109]],[[120445,120445],"mapped",[110]],[[120446,120446],"mapped",[111]],[[120447,120447],"mapped",[112]],[[120448,120448],"mapped",[113]],[[120449,120449],"mapped",[114]],[[120450,120450],"mapped",[115]],[[120451,120451],"mapped",[116]],[[120452,120452],"mapped",[117]],[[120453,120453],"mapped",[118]],[[120454,120454],"mapped",[119]],[[120455,120455],"mapped",[120]],[[120456,120456],"mapped",[121]],[[120457,120457],"mapped",[122]],[[120458,120458],"mapped",[97]],[[120459,120459],"mapped",[98]],[[120460,120460],"mapped",[99]],[[120461,120461],"mapped",[100]],[[120462,120462],"mapped",[101]],[[120463,120463],"mapped",[102]],[[120464,120464],"mapped",[103]],[[120465,120465],"mapped",[104]],[[120466,120466],"mapped",[105]],[[120467,120467],"mapped",[106]],[[120468,120468],"mapped",[107]],[[120469,120469],"mapped",[108]],[[120470,120470],"mapped",[109]],[[120471,120471],"mapped",[110]],[[120472,120472],"mapped",[111]],[[120473,120473],"mapped",[112]],[[120474,120474],"mapped",[113]],[[120475,120475],"mapped",[114]],[[120476,120476],"mapped",[115]],[[120477,120477],"mapped",[116]],[[120478,120478],"mapped",[117]],[[120479,120479],"mapped",[118]],[[120480,120480],"mapped",[119]],[[120481,120481],"mapped",[120]],[[120482,120482],"mapped",[121]],[[120483,120483],"mapped",[122]],[[120484,120484],"mapped",[305]],[[120485,120485],"mapped",[567]],[[120486,120487],"disallowed"],[[120488,120488],"mapped",[945]],[[120489,120489],"mapped",[946]],[[120490,120490],"mapped",[947]],[[120491,120491],"mapped",[948]],[[120492,120492],"mapped",[949]],[[120493,120493],"mapped",[950]],[[120494,120494],"mapped",[951]],[[120495,120495],"mapped",[952]],[[120496,120496],"mapped",[953]],[[120497,120497],"mapped",[954]],[[120498,120498],"mapped",[955]],[[120499,120499],"mapped",[956]],[[120500,120500],"mapped",[957]],[[120501,120501],"mapped",[958]],[[120502,120502],"mapped",[959]],[[120503,120503],"mapped",[960]],[[120504,120504],"mapped",[961]],[[120505,120505],"mapped",[952]],[[120506,120506],"mapped",[963]],[[120507,120507],"mapped",[964]],[[120508,120508],"mapped",[965]],[[120509,120509],"mapped",[966]],[[120510,120510],"mapped",[967]],[[120511,120511],"mapped",[968]],[[120512,120512],"mapped",[969]],[[120513,120513],"mapped",[8711]],[[120514,120514],"mapped",[945]],[[120515,120515],"mapped",[946]],[[120516,120516],"mapped",[947]],[[120517,120517],"mapped",[948]],[[120518,120518],"mapped",[949]],[[120519,120519],"mapped",[950]],[[120520,120520],"mapped",[951]],[[120521,120521],"mapped",[952]],[[120522,120522],"mapped",[953]],[[120523,120523],"mapped",[954]],[[120524,120524],"mapped",[955]],[[120525,120525],"mapped",[956]],[[120526,120526],"mapped",[957]],[[120527,120527],"mapped",[958]],[[120528,120528],"mapped",[959]],[[120529,120529],"mapped",[960]],[[120530,120530],"mapped",[961]],[[120531,120532],"mapped",[963]],[[120533,120533],"mapped",[964]],[[120534,120534],"mapped",[965]],[[120535,120535],"mapped",[966]],[[120536,120536],"mapped",[967]],[[120537,120537],"mapped",[968]],[[120538,120538],"mapped",[969]],[[120539,120539],"mapped",[8706]],[[120540,120540],"mapped",[949]],[[120541,120541],"mapped",[952]],[[120542,120542],"mapped",[954]],[[120543,120543],"mapped",[966]],[[120544,120544],"mapped",[961]],[[120545,120545],"mapped",[960]],[[120546,120546],"mapped",[945]],[[120547,120547],"mapped",[946]],[[120548,120548],"mapped",[947]],[[120549,120549],"mapped",[948]],[[120550,120550],"mapped",[949]],[[120551,120551],"mapped",[950]],[[120552,120552],"mapped",[951]],[[120553,120553],"mapped",[952]],[[120554,120554],"mapped",[953]],[[120555,120555],"mapped",[954]],[[120556,120556],"mapped",[955]],[[120557,120557],"mapped",[956]],[[120558,120558],"mapped",[957]],[[120559,120559],"mapped",[958]],[[120560,120560],"mapped",[959]],[[120561,120561],"mapped",[960]],[[120562,120562],"mapped",[961]],[[120563,120563],"mapped",[952]],[[120564,120564],"mapped",[963]],[[120565,120565],"mapped",[964]],[[120566,120566],"mapped",[965]],[[120567,120567],"mapped",[966]],[[120568,120568],"mapped",[967]],[[120569,120569],"mapped",[968]],[[120570,120570],"mapped",[969]],[[120571,120571],"mapped",[8711]],[[120572,120572],"mapped",[945]],[[120573,120573],"mapped",[946]],[[120574,120574],"mapped",[947]],[[120575,120575],"mapped",[948]],[[120576,120576],"mapped",[949]],[[120577,120577],"mapped",[950]],[[120578,120578],"mapped",[951]],[[120579,120579],"mapped",[952]],[[120580,120580],"mapped",[953]],[[120581,120581],"mapped",[954]],[[120582,120582],"mapped",[955]],[[120583,120583],"mapped",[956]],[[120584,120584],"mapped",[957]],[[120585,120585],"mapped",[958]],[[120586,120586],"mapped",[959]],[[120587,120587],"mapped",[960]],[[120588,120588],"mapped",[961]],[[120589,120590],"mapped",[963]],[[120591,120591],"mapped",[964]],[[120592,120592],"mapped",[965]],[[120593,120593],"mapped",[966]],[[120594,120594],"mapped",[967]],[[120595,120595],"mapped",[968]],[[120596,120596],"mapped",[969]],[[120597,120597],"mapped",[8706]],[[120598,120598],"mapped",[949]],[[120599,120599],"mapped",[952]],[[120600,120600],"mapped",[954]],[[120601,120601],"mapped",[966]],[[120602,120602],"mapped",[961]],[[120603,120603],"mapped",[960]],[[120604,120604],"mapped",[945]],[[120605,120605],"mapped",[946]],[[120606,120606],"mapped",[947]],[[120607,120607],"mapped",[948]],[[120608,120608],"mapped",[949]],[[120609,120609],"mapped",[950]],[[120610,120610],"mapped",[951]],[[120611,120611],"mapped",[952]],[[120612,120612],"mapped",[953]],[[120613,120613],"mapped",[954]],[[120614,120614],"mapped",[955]],[[120615,120615],"mapped",[956]],[[120616,120616],"mapped",[957]],[[120617,120617],"mapped",[958]],[[120618,120618],"mapped",[959]],[[120619,120619],"mapped",[960]],[[120620,120620],"mapped",[961]],[[120621,120621],"mapped",[952]],[[120622,120622],"mapped",[963]],[[120623,120623],"mapped",[964]],[[120624,120624],"mapped",[965]],[[120625,120625],"mapped",[966]],[[120626,120626],"mapped",[967]],[[120627,120627],"mapped",[968]],[[120628,120628],"mapped",[969]],[[120629,120629],"mapped",[8711]],[[120630,120630],"mapped",[945]],[[120631,120631],"mapped",[946]],[[120632,120632],"mapped",[947]],[[120633,120633],"mapped",[948]],[[120634,120634],"mapped",[949]],[[120635,120635],"mapped",[950]],[[120636,120636],"mapped",[951]],[[120637,120637],"mapped",[952]],[[120638,120638],"mapped",[953]],[[120639,120639],"mapped",[954]],[[120640,120640],"mapped",[955]],[[120641,120641],"mapped",[956]],[[120642,120642],"mapped",[957]],[[120643,120643],"mapped",[958]],[[120644,120644],"mapped",[959]],[[120645,120645],"mapped",[960]],[[120646,120646],"mapped",[961]],[[120647,120648],"mapped",[963]],[[120649,120649],"mapped",[964]],[[120650,120650],"mapped",[965]],[[120651,120651],"mapped",[966]],[[120652,120652],"mapped",[967]],[[120653,120653],"mapped",[968]],[[120654,120654],"mapped",[969]],[[120655,120655],"mapped",[8706]],[[120656,120656],"mapped",[949]],[[120657,120657],"mapped",[952]],[[120658,120658],"mapped",[954]],[[120659,120659],"mapped",[966]],[[120660,120660],"mapped",[961]],[[120661,120661],"mapped",[960]],[[120662,120662],"mapped",[945]],[[120663,120663],"mapped",[946]],[[120664,120664],"mapped",[947]],[[120665,120665],"mapped",[948]],[[120666,120666],"mapped",[949]],[[120667,120667],"mapped",[950]],[[120668,120668],"mapped",[951]],[[120669,120669],"mapped",[952]],[[120670,120670],"mapped",[953]],[[120671,120671],"mapped",[954]],[[120672,120672],"mapped",[955]],[[120673,120673],"mapped",[956]],[[120674,120674],"mapped",[957]],[[120675,120675],"mapped",[958]],[[120676,120676],"mapped",[959]],[[120677,120677],"mapped",[960]],[[120678,120678],"mapped",[961]],[[120679,120679],"mapped",[952]],[[120680,120680],"mapped",[963]],[[120681,120681],"mapped",[964]],[[120682,120682],"mapped",[965]],[[120683,120683],"mapped",[966]],[[120684,120684],"mapped",[967]],[[120685,120685],"mapped",[968]],[[120686,120686],"mapped",[969]],[[120687,120687],"mapped",[8711]],[[120688,120688],"mapped",[945]],[[120689,120689],"mapped",[946]],[[120690,120690],"mapped",[947]],[[120691,120691],"mapped",[948]],[[120692,120692],"mapped",[949]],[[120693,120693],"mapped",[950]],[[120694,120694],"mapped",[951]],[[120695,120695],"mapped",[952]],[[120696,120696],"mapped",[953]],[[120697,120697],"mapped",[954]],[[120698,120698],"mapped",[955]],[[120699,120699],"mapped",[956]],[[120700,120700],"mapped",[957]],[[120701,120701],"mapped",[958]],[[120702,120702],"mapped",[959]],[[120703,120703],"mapped",[960]],[[120704,120704],"mapped",[961]],[[120705,120706],"mapped",[963]],[[120707,120707],"mapped",[964]],[[120708,120708],"mapped",[965]],[[120709,120709],"mapped",[966]],[[120710,120710],"mapped",[967]],[[120711,120711],"mapped",[968]],[[120712,120712],"mapped",[969]],[[120713,120713],"mapped",[8706]],[[120714,120714],"mapped",[949]],[[120715,120715],"mapped",[952]],[[120716,120716],"mapped",[954]],[[120717,120717],"mapped",[966]],[[120718,120718],"mapped",[961]],[[120719,120719],"mapped",[960]],[[120720,120720],"mapped",[945]],[[120721,120721],"mapped",[946]],[[120722,120722],"mapped",[947]],[[120723,120723],"mapped",[948]],[[120724,120724],"mapped",[949]],[[120725,120725],"mapped",[950]],[[120726,120726],"mapped",[951]],[[120727,120727],"mapped",[952]],[[120728,120728],"mapped",[953]],[[120729,120729],"mapped",[954]],[[120730,120730],"mapped",[955]],[[120731,120731],"mapped",[956]],[[120732,120732],"mapped",[957]],[[120733,120733],"mapped",[958]],[[120734,120734],"mapped",[959]],[[120735,120735],"mapped",[960]],[[120736,120736],"mapped",[961]],[[120737,120737],"mapped",[952]],[[120738,120738],"mapped",[963]],[[120739,120739],"mapped",[964]],[[120740,120740],"mapped",[965]],[[120741,120741],"mapped",[966]],[[120742,120742],"mapped",[967]],[[120743,120743],"mapped",[968]],[[120744,120744],"mapped",[969]],[[120745,120745],"mapped",[8711]],[[120746,120746],"mapped",[945]],[[120747,120747],"mapped",[946]],[[120748,120748],"mapped",[947]],[[120749,120749],"mapped",[948]],[[120750,120750],"mapped",[949]],[[120751,120751],"mapped",[950]],[[120752,120752],"mapped",[951]],[[120753,120753],"mapped",[952]],[[120754,120754],"mapped",[953]],[[120755,120755],"mapped",[954]],[[120756,120756],"mapped",[955]],[[120757,120757],"mapped",[956]],[[120758,120758],"mapped",[957]],[[120759,120759],"mapped",[958]],[[120760,120760],"mapped",[959]],[[120761,120761],"mapped",[960]],[[120762,120762],"mapped",[961]],[[120763,120764],"mapped",[963]],[[120765,120765],"mapped",[964]],[[120766,120766],"mapped",[965]],[[120767,120767],"mapped",[966]],[[120768,120768],"mapped",[967]],[[120769,120769],"mapped",[968]],[[120770,120770],"mapped",[969]],[[120771,120771],"mapped",[8706]],[[120772,120772],"mapped",[949]],[[120773,120773],"mapped",[952]],[[120774,120774],"mapped",[954]],[[120775,120775],"mapped",[966]],[[120776,120776],"mapped",[961]],[[120777,120777],"mapped",[960]],[[120778,120779],"mapped",[989]],[[120780,120781],"disallowed"],[[120782,120782],"mapped",[48]],[[120783,120783],"mapped",[49]],[[120784,120784],"mapped",[50]],[[120785,120785],"mapped",[51]],[[120786,120786],"mapped",[52]],[[120787,120787],"mapped",[53]],[[120788,120788],"mapped",[54]],[[120789,120789],"mapped",[55]],[[120790,120790],"mapped",[56]],[[120791,120791],"mapped",[57]],[[120792,120792],"mapped",[48]],[[120793,120793],"mapped",[49]],[[120794,120794],"mapped",[50]],[[120795,120795],"mapped",[51]],[[120796,120796],"mapped",[52]],[[120797,120797],"mapped",[53]],[[120798,120798],"mapped",[54]],[[120799,120799],"mapped",[55]],[[120800,120800],"mapped",[56]],[[120801,120801],"mapped",[57]],[[120802,120802],"mapped",[48]],[[120803,120803],"mapped",[49]],[[120804,120804],"mapped",[50]],[[120805,120805],"mapped",[51]],[[120806,120806],"mapped",[52]],[[120807,120807],"mapped",[53]],[[120808,120808],"mapped",[54]],[[120809,120809],"mapped",[55]],[[120810,120810],"mapped",[56]],[[120811,120811],"mapped",[57]],[[120812,120812],"mapped",[48]],[[120813,120813],"mapped",[49]],[[120814,120814],"mapped",[50]],[[120815,120815],"mapped",[51]],[[120816,120816],"mapped",[52]],[[120817,120817],"mapped",[53]],[[120818,120818],"mapped",[54]],[[120819,120819],"mapped",[55]],[[120820,120820],"mapped",[56]],[[120821,120821],"mapped",[57]],[[120822,120822],"mapped",[48]],[[120823,120823],"mapped",[49]],[[120824,120824],"mapped",[50]],[[120825,120825],"mapped",[51]],[[120826,120826],"mapped",[52]],[[120827,120827],"mapped",[53]],[[120828,120828],"mapped",[54]],[[120829,120829],"mapped",[55]],[[120830,120830],"mapped",[56]],[[120831,120831],"mapped",[57]],[[120832,121343],"valid",[],"NV8"],[[121344,121398],"valid"],[[121399,121402],"valid",[],"NV8"],[[121403,121452],"valid"],[[121453,121460],"valid",[],"NV8"],[[121461,121461],"valid"],[[121462,121475],"valid",[],"NV8"],[[121476,121476],"valid"],[[121477,121483],"valid",[],"NV8"],[[121484,121498],"disallowed"],[[121499,121503],"valid"],[[121504,121504],"disallowed"],[[121505,121519],"valid"],[[121520,124927],"disallowed"],[[124928,125124],"valid"],[[125125,125126],"disallowed"],[[125127,125135],"valid",[],"NV8"],[[125136,125142],"valid"],[[125143,126463],"disallowed"],[[126464,126464],"mapped",[1575]],[[126465,126465],"mapped",[1576]],[[126466,126466],"mapped",[1580]],[[126467,126467],"mapped",[1583]],[[126468,126468],"disallowed"],[[126469,126469],"mapped",[1608]],[[126470,126470],"mapped",[1586]],[[126471,126471],"mapped",[1581]],[[126472,126472],"mapped",[1591]],[[126473,126473],"mapped",[1610]],[[126474,126474],"mapped",[1603]],[[126475,126475],"mapped",[1604]],[[126476,126476],"mapped",[1605]],[[126477,126477],"mapped",[1606]],[[126478,126478],"mapped",[1587]],[[126479,126479],"mapped",[1593]],[[126480,126480],"mapped",[1601]],[[126481,126481],"mapped",[1589]],[[126482,126482],"mapped",[1602]],[[126483,126483],"mapped",[1585]],[[126484,126484],"mapped",[1588]],[[126485,126485],"mapped",[1578]],[[126486,126486],"mapped",[1579]],[[126487,126487],"mapped",[1582]],[[126488,126488],"mapped",[1584]],[[126489,126489],"mapped",[1590]],[[126490,126490],"mapped",[1592]],[[126491,126491],"mapped",[1594]],[[126492,126492],"mapped",[1646]],[[126493,126493],"mapped",[1722]],[[126494,126494],"mapped",[1697]],[[126495,126495],"mapped",[1647]],[[126496,126496],"disallowed"],[[126497,126497],"mapped",[1576]],[[126498,126498],"mapped",[1580]],[[126499,126499],"disallowed"],[[126500,126500],"mapped",[1607]],[[126501,126502],"disallowed"],[[126503,126503],"mapped",[1581]],[[126504,126504],"disallowed"],[[126505,126505],"mapped",[1610]],[[126506,126506],"mapped",[1603]],[[126507,126507],"mapped",[1604]],[[126508,126508],"mapped",[1605]],[[126509,126509],"mapped",[1606]],[[126510,126510],"mapped",[1587]],[[126511,126511],"mapped",[1593]],[[126512,126512],"mapped",[1601]],[[126513,126513],"mapped",[1589]],[[126514,126514],"mapped",[1602]],[[126515,126515],"disallowed"],[[126516,126516],"mapped",[1588]],[[126517,126517],"mapped",[1578]],[[126518,126518],"mapped",[1579]],[[126519,126519],"mapped",[1582]],[[126520,126520],"disallowed"],[[126521,126521],"mapped",[1590]],[[126522,126522],"disallowed"],[[126523,126523],"mapped",[1594]],[[126524,126529],"disallowed"],[[126530,126530],"mapped",[1580]],[[126531,126534],"disallowed"],[[126535,126535],"mapped",[1581]],[[126536,126536],"disallowed"],[[126537,126537],"mapped",[1610]],[[126538,126538],"disallowed"],[[126539,126539],"mapped",[1604]],[[126540,126540],"disallowed"],[[126541,126541],"mapped",[1606]],[[126542,126542],"mapped",[1587]],[[126543,126543],"mapped",[1593]],[[126544,126544],"disallowed"],[[126545,126545],"mapped",[1589]],[[126546,126546],"mapped",[1602]],[[126547,126547],"disallowed"],[[126548,126548],"mapped",[1588]],[[126549,126550],"disallowed"],[[126551,126551],"mapped",[1582]],[[126552,126552],"disallowed"],[[126553,126553],"mapped",[1590]],[[126554,126554],"disallowed"],[[126555,126555],"mapped",[1594]],[[126556,126556],"disallowed"],[[126557,126557],"mapped",[1722]],[[126558,126558],"disallowed"],[[126559,126559],"mapped",[1647]],[[126560,126560],"disallowed"],[[126561,126561],"mapped",[1576]],[[126562,126562],"mapped",[1580]],[[126563,126563],"disallowed"],[[126564,126564],"mapped",[1607]],[[126565,126566],"disallowed"],[[126567,126567],"mapped",[1581]],[[126568,126568],"mapped",[1591]],[[126569,126569],"mapped",[1610]],[[126570,126570],"mapped",[1603]],[[126571,126571],"disallowed"],[[126572,126572],"mapped",[1605]],[[126573,126573],"mapped",[1606]],[[126574,126574],"mapped",[1587]],[[126575,126575],"mapped",[1593]],[[126576,126576],"mapped",[1601]],[[126577,126577],"mapped",[1589]],[[126578,126578],"mapped",[1602]],[[126579,126579],"disallowed"],[[126580,126580],"mapped",[1588]],[[126581,126581],"mapped",[1578]],[[126582,126582],"mapped",[1579]],[[126583,126583],"mapped",[1582]],[[126584,126584],"disallowed"],[[126585,126585],"mapped",[1590]],[[126586,126586],"mapped",[1592]],[[126587,126587],"mapped",[1594]],[[126588,126588],"mapped",[1646]],[[126589,126589],"disallowed"],[[126590,126590],"mapped",[1697]],[[126591,126591],"disallowed"],[[126592,126592],"mapped",[1575]],[[126593,126593],"mapped",[1576]],[[126594,126594],"mapped",[1580]],[[126595,126595],"mapped",[1583]],[[126596,126596],"mapped",[1607]],[[126597,126597],"mapped",[1608]],[[126598,126598],"mapped",[1586]],[[126599,126599],"mapped",[1581]],[[126600,126600],"mapped",[1591]],[[126601,126601],"mapped",[1610]],[[126602,126602],"disallowed"],[[126603,126603],"mapped",[1604]],[[126604,126604],"mapped",[1605]],[[126605,126605],"mapped",[1606]],[[126606,126606],"mapped",[1587]],[[126607,126607],"mapped",[1593]],[[126608,126608],"mapped",[1601]],[[126609,126609],"mapped",[1589]],[[126610,126610],"mapped",[1602]],[[126611,126611],"mapped",[1585]],[[126612,126612],"mapped",[1588]],[[126613,126613],"mapped",[1578]],[[126614,126614],"mapped",[1579]],[[126615,126615],"mapped",[1582]],[[126616,126616],"mapped",[1584]],[[126617,126617],"mapped",[1590]],[[126618,126618],"mapped",[1592]],[[126619,126619],"mapped",[1594]],[[126620,126624],"disallowed"],[[126625,126625],"mapped",[1576]],[[126626,126626],"mapped",[1580]],[[126627,126627],"mapped",[1583]],[[126628,126628],"disallowed"],[[126629,126629],"mapped",[1608]],[[126630,126630],"mapped",[1586]],[[126631,126631],"mapped",[1581]],[[126632,126632],"mapped",[1591]],[[126633,126633],"mapped",[1610]],[[126634,126634],"disallowed"],[[126635,126635],"mapped",[1604]],[[126636,126636],"mapped",[1605]],[[126637,126637],"mapped",[1606]],[[126638,126638],"mapped",[1587]],[[126639,126639],"mapped",[1593]],[[126640,126640],"mapped",[1601]],[[126641,126641],"mapped",[1589]],[[126642,126642],"mapped",[1602]],[[126643,126643],"mapped",[1585]],[[126644,126644],"mapped",[1588]],[[126645,126645],"mapped",[1578]],[[126646,126646],"mapped",[1579]],[[126647,126647],"mapped",[1582]],[[126648,126648],"mapped",[1584]],[[126649,126649],"mapped",[1590]],[[126650,126650],"mapped",[1592]],[[126651,126651],"mapped",[1594]],[[126652,126703],"disallowed"],[[126704,126705],"valid",[],"NV8"],[[126706,126975],"disallowed"],[[126976,127019],"valid",[],"NV8"],[[127020,127023],"disallowed"],[[127024,127123],"valid",[],"NV8"],[[127124,127135],"disallowed"],[[127136,127150],"valid",[],"NV8"],[[127151,127152],"disallowed"],[[127153,127166],"valid",[],"NV8"],[[127167,127167],"valid",[],"NV8"],[[127168,127168],"disallowed"],[[127169,127183],"valid",[],"NV8"],[[127184,127184],"disallowed"],[[127185,127199],"valid",[],"NV8"],[[127200,127221],"valid",[],"NV8"],[[127222,127231],"disallowed"],[[127232,127232],"disallowed"],[[127233,127233],"disallowed_STD3_mapped",[48,44]],[[127234,127234],"disallowed_STD3_mapped",[49,44]],[[127235,127235],"disallowed_STD3_mapped",[50,44]],[[127236,127236],"disallowed_STD3_mapped",[51,44]],[[127237,127237],"disallowed_STD3_mapped",[52,44]],[[127238,127238],"disallowed_STD3_mapped",[53,44]],[[127239,127239],"disallowed_STD3_mapped",[54,44]],[[127240,127240],"disallowed_STD3_mapped",[55,44]],[[127241,127241],"disallowed_STD3_mapped",[56,44]],[[127242,127242],"disallowed_STD3_mapped",[57,44]],[[127243,127244],"valid",[],"NV8"],[[127245,127247],"disallowed"],[[127248,127248],"disallowed_STD3_mapped",[40,97,41]],[[127249,127249],"disallowed_STD3_mapped",[40,98,41]],[[127250,127250],"disallowed_STD3_mapped",[40,99,41]],[[127251,127251],"disallowed_STD3_mapped",[40,100,41]],[[127252,127252],"disallowed_STD3_mapped",[40,101,41]],[[127253,127253],"disallowed_STD3_mapped",[40,102,41]],[[127254,127254],"disallowed_STD3_mapped",[40,103,41]],[[127255,127255],"disallowed_STD3_mapped",[40,104,41]],[[127256,127256],"disallowed_STD3_mapped",[40,105,41]],[[127257,127257],"disallowed_STD3_mapped",[40,106,41]],[[127258,127258],"disallowed_STD3_mapped",[40,107,41]],[[127259,127259],"disallowed_STD3_mapped",[40,108,41]],[[127260,127260],"disallowed_STD3_mapped",[40,109,41]],[[127261,127261],"disallowed_STD3_mapped",[40,110,41]],[[127262,127262],"disallowed_STD3_mapped",[40,111,41]],[[127263,127263],"disallowed_STD3_mapped",[40,112,41]],[[127264,127264],"disallowed_STD3_mapped",[40,113,41]],[[127265,127265],"disallowed_STD3_mapped",[40,114,41]],[[127266,127266],"disallowed_STD3_mapped",[40,115,41]],[[127267,127267],"disallowed_STD3_mapped",[40,116,41]],[[127268,127268],"disallowed_STD3_mapped",[40,117,41]],[[127269,127269],"disallowed_STD3_mapped",[40,118,41]],[[127270,127270],"disallowed_STD3_mapped",[40,119,41]],[[127271,127271],"disallowed_STD3_mapped",[40,120,41]],[[127272,127272],"disallowed_STD3_mapped",[40,121,41]],[[127273,127273],"disallowed_STD3_mapped",[40,122,41]],[[127274,127274],"mapped",[12308,115,12309]],[[127275,127275],"mapped",[99]],[[127276,127276],"mapped",[114]],[[127277,127277],"mapped",[99,100]],[[127278,127278],"mapped",[119,122]],[[127279,127279],"disallowed"],[[127280,127280],"mapped",[97]],[[127281,127281],"mapped",[98]],[[127282,127282],"mapped",[99]],[[127283,127283],"mapped",[100]],[[127284,127284],"mapped",[101]],[[127285,127285],"mapped",[102]],[[127286,127286],"mapped",[103]],[[127287,127287],"mapped",[104]],[[127288,127288],"mapped",[105]],[[127289,127289],"mapped",[106]],[[127290,127290],"mapped",[107]],[[127291,127291],"mapped",[108]],[[127292,127292],"mapped",[109]],[[127293,127293],"mapped",[110]],[[127294,127294],"mapped",[111]],[[127295,127295],"mapped",[112]],[[127296,127296],"mapped",[113]],[[127297,127297],"mapped",[114]],[[127298,127298],"mapped",[115]],[[127299,127299],"mapped",[116]],[[127300,127300],"mapped",[117]],[[127301,127301],"mapped",[118]],[[127302,127302],"mapped",[119]],[[127303,127303],"mapped",[120]],[[127304,127304],"mapped",[121]],[[127305,127305],"mapped",[122]],[[127306,127306],"mapped",[104,118]],[[127307,127307],"mapped",[109,118]],[[127308,127308],"mapped",[115,100]],[[127309,127309],"mapped",[115,115]],[[127310,127310],"mapped",[112,112,118]],[[127311,127311],"mapped",[119,99]],[[127312,127318],"valid",[],"NV8"],[[127319,127319],"valid",[],"NV8"],[[127320,127326],"valid",[],"NV8"],[[127327,127327],"valid",[],"NV8"],[[127328,127337],"valid",[],"NV8"],[[127338,127338],"mapped",[109,99]],[[127339,127339],"mapped",[109,100]],[[127340,127343],"disallowed"],[[127344,127352],"valid",[],"NV8"],[[127353,127353],"valid",[],"NV8"],[[127354,127354],"valid",[],"NV8"],[[127355,127356],"valid",[],"NV8"],[[127357,127358],"valid",[],"NV8"],[[127359,127359],"valid",[],"NV8"],[[127360,127369],"valid",[],"NV8"],[[127370,127373],"valid",[],"NV8"],[[127374,127375],"valid",[],"NV8"],[[127376,127376],"mapped",[100,106]],[[127377,127386],"valid",[],"NV8"],[[127387,127461],"disallowed"],[[127462,127487],"valid",[],"NV8"],[[127488,127488],"mapped",[12411,12363]],[[127489,127489],"mapped",[12467,12467]],[[127490,127490],"mapped",[12469]],[[127491,127503],"disallowed"],[[127504,127504],"mapped",[25163]],[[127505,127505],"mapped",[23383]],[[127506,127506],"mapped",[21452]],[[127507,127507],"mapped",[12487]],[[127508,127508],"mapped",[20108]],[[127509,127509],"mapped",[22810]],[[127510,127510],"mapped",[35299]],[[127511,127511],"mapped",[22825]],[[127512,127512],"mapped",[20132]],[[127513,127513],"mapped",[26144]],[[127514,127514],"mapped",[28961]],[[127515,127515],"mapped",[26009]],[[127516,127516],"mapped",[21069]],[[127517,127517],"mapped",[24460]],[[127518,127518],"mapped",[20877]],[[127519,127519],"mapped",[26032]],[[127520,127520],"mapped",[21021]],[[127521,127521],"mapped",[32066]],[[127522,127522],"mapped",[29983]],[[127523,127523],"mapped",[36009]],[[127524,127524],"mapped",[22768]],[[127525,127525],"mapped",[21561]],[[127526,127526],"mapped",[28436]],[[127527,127527],"mapped",[25237]],[[127528,127528],"mapped",[25429]],[[127529,127529],"mapped",[19968]],[[127530,127530],"mapped",[19977]],[[127531,127531],"mapped",[36938]],[[127532,127532],"mapped",[24038]],[[127533,127533],"mapped",[20013]],[[127534,127534],"mapped",[21491]],[[127535,127535],"mapped",[25351]],[[127536,127536],"mapped",[36208]],[[127537,127537],"mapped",[25171]],[[127538,127538],"mapped",[31105]],[[127539,127539],"mapped",[31354]],[[127540,127540],"mapped",[21512]],[[127541,127541],"mapped",[28288]],[[127542,127542],"mapped",[26377]],[[127543,127543],"mapped",[26376]],[[127544,127544],"mapped",[30003]],[[127545,127545],"mapped",[21106]],[[127546,127546],"mapped",[21942]],[[127547,127551],"disallowed"],[[127552,127552],"mapped",[12308,26412,12309]],[[127553,127553],"mapped",[12308,19977,12309]],[[127554,127554],"mapped",[12308,20108,12309]],[[127555,127555],"mapped",[12308,23433,12309]],[[127556,127556],"mapped",[12308,28857,12309]],[[127557,127557],"mapped",[12308,25171,12309]],[[127558,127558],"mapped",[12308,30423,12309]],[[127559,127559],"mapped",[12308,21213,12309]],[[127560,127560],"mapped",[12308,25943,12309]],[[127561,127567],"disallowed"],[[127568,127568],"mapped",[24471]],[[127569,127569],"mapped",[21487]],[[127570,127743],"disallowed"],[[127744,127776],"valid",[],"NV8"],[[127777,127788],"valid",[],"NV8"],[[127789,127791],"valid",[],"NV8"],[[127792,127797],"valid",[],"NV8"],[[127798,127798],"valid",[],"NV8"],[[127799,127868],"valid",[],"NV8"],[[127869,127869],"valid",[],"NV8"],[[127870,127871],"valid",[],"NV8"],[[127872,127891],"valid",[],"NV8"],[[127892,127903],"valid",[],"NV8"],[[127904,127940],"valid",[],"NV8"],[[127941,127941],"valid",[],"NV8"],[[127942,127946],"valid",[],"NV8"],[[127947,127950],"valid",[],"NV8"],[[127951,127955],"valid",[],"NV8"],[[127956,127967],"valid",[],"NV8"],[[127968,127984],"valid",[],"NV8"],[[127985,127991],"valid",[],"NV8"],[[127992,127999],"valid",[],"NV8"],[[128000,128062],"valid",[],"NV8"],[[128063,128063],"valid",[],"NV8"],[[128064,128064],"valid",[],"NV8"],[[128065,128065],"valid",[],"NV8"],[[128066,128247],"valid",[],"NV8"],[[128248,128248],"valid",[],"NV8"],[[128249,128252],"valid",[],"NV8"],[[128253,128254],"valid",[],"NV8"],[[128255,128255],"valid",[],"NV8"],[[128256,128317],"valid",[],"NV8"],[[128318,128319],"valid",[],"NV8"],[[128320,128323],"valid",[],"NV8"],[[128324,128330],"valid",[],"NV8"],[[128331,128335],"valid",[],"NV8"],[[128336,128359],"valid",[],"NV8"],[[128360,128377],"valid",[],"NV8"],[[128378,128378],"disallowed"],[[128379,128419],"valid",[],"NV8"],[[128420,128420],"disallowed"],[[128421,128506],"valid",[],"NV8"],[[128507,128511],"valid",[],"NV8"],[[128512,128512],"valid",[],"NV8"],[[128513,128528],"valid",[],"NV8"],[[128529,128529],"valid",[],"NV8"],[[128530,128532],"valid",[],"NV8"],[[128533,128533],"valid",[],"NV8"],[[128534,128534],"valid",[],"NV8"],[[128535,128535],"valid",[],"NV8"],[[128536,128536],"valid",[],"NV8"],[[128537,128537],"valid",[],"NV8"],[[128538,128538],"valid",[],"NV8"],[[128539,128539],"valid",[],"NV8"],[[128540,128542],"valid",[],"NV8"],[[128543,128543],"valid",[],"NV8"],[[128544,128549],"valid",[],"NV8"],[[128550,128551],"valid",[],"NV8"],[[128552,128555],"valid",[],"NV8"],[[128556,128556],"valid",[],"NV8"],[[128557,128557],"valid",[],"NV8"],[[128558,128559],"valid",[],"NV8"],[[128560,128563],"valid",[],"NV8"],[[128564,128564],"valid",[],"NV8"],[[128565,128576],"valid",[],"NV8"],[[128577,128578],"valid",[],"NV8"],[[128579,128580],"valid",[],"NV8"],[[128581,128591],"valid",[],"NV8"],[[128592,128639],"valid",[],"NV8"],[[128640,128709],"valid",[],"NV8"],[[128710,128719],"valid",[],"NV8"],[[128720,128720],"valid",[],"NV8"],[[128721,128735],"disallowed"],[[128736,128748],"valid",[],"NV8"],[[128749,128751],"disallowed"],[[128752,128755],"valid",[],"NV8"],[[128756,128767],"disallowed"],[[128768,128883],"valid",[],"NV8"],[[128884,128895],"disallowed"],[[128896,128980],"valid",[],"NV8"],[[128981,129023],"disallowed"],[[129024,129035],"valid",[],"NV8"],[[129036,129039],"disallowed"],[[129040,129095],"valid",[],"NV8"],[[129096,129103],"disallowed"],[[129104,129113],"valid",[],"NV8"],[[129114,129119],"disallowed"],[[129120,129159],"valid",[],"NV8"],[[129160,129167],"disallowed"],[[129168,129197],"valid",[],"NV8"],[[129198,129295],"disallowed"],[[129296,129304],"valid",[],"NV8"],[[129305,129407],"disallowed"],[[129408,129412],"valid",[],"NV8"],[[129413,129471],"disallowed"],[[129472,129472],"valid",[],"NV8"],[[129473,131069],"disallowed"],[[131070,131071],"disallowed"],[[131072,173782],"valid"],[[173783,173823],"disallowed"],[[173824,177972],"valid"],[[177973,177983],"disallowed"],[[177984,178205],"valid"],[[178206,178207],"disallowed"],[[178208,183969],"valid"],[[183970,194559],"disallowed"],[[194560,194560],"mapped",[20029]],[[194561,194561],"mapped",[20024]],[[194562,194562],"mapped",[20033]],[[194563,194563],"mapped",[131362]],[[194564,194564],"mapped",[20320]],[[194565,194565],"mapped",[20398]],[[194566,194566],"mapped",[20411]],[[194567,194567],"mapped",[20482]],[[194568,194568],"mapped",[20602]],[[194569,194569],"mapped",[20633]],[[194570,194570],"mapped",[20711]],[[194571,194571],"mapped",[20687]],[[194572,194572],"mapped",[13470]],[[194573,194573],"mapped",[132666]],[[194574,194574],"mapped",[20813]],[[194575,194575],"mapped",[20820]],[[194576,194576],"mapped",[20836]],[[194577,194577],"mapped",[20855]],[[194578,194578],"mapped",[132380]],[[194579,194579],"mapped",[13497]],[[194580,194580],"mapped",[20839]],[[194581,194581],"mapped",[20877]],[[194582,194582],"mapped",[132427]],[[194583,194583],"mapped",[20887]],[[194584,194584],"mapped",[20900]],[[194585,194585],"mapped",[20172]],[[194586,194586],"mapped",[20908]],[[194587,194587],"mapped",[20917]],[[194588,194588],"mapped",[168415]],[[194589,194589],"mapped",[20981]],[[194590,194590],"mapped",[20995]],[[194591,194591],"mapped",[13535]],[[194592,194592],"mapped",[21051]],[[194593,194593],"mapped",[21062]],[[194594,194594],"mapped",[21106]],[[194595,194595],"mapped",[21111]],[[194596,194596],"mapped",[13589]],[[194597,194597],"mapped",[21191]],[[194598,194598],"mapped",[21193]],[[194599,194599],"mapped",[21220]],[[194600,194600],"mapped",[21242]],[[194601,194601],"mapped",[21253]],[[194602,194602],"mapped",[21254]],[[194603,194603],"mapped",[21271]],[[194604,194604],"mapped",[21321]],[[194605,194605],"mapped",[21329]],[[194606,194606],"mapped",[21338]],[[194607,194607],"mapped",[21363]],[[194608,194608],"mapped",[21373]],[[194609,194611],"mapped",[21375]],[[194612,194612],"mapped",[133676]],[[194613,194613],"mapped",[28784]],[[194614,194614],"mapped",[21450]],[[194615,194615],"mapped",[21471]],[[194616,194616],"mapped",[133987]],[[194617,194617],"mapped",[21483]],[[194618,194618],"mapped",[21489]],[[194619,194619],"mapped",[21510]],[[194620,194620],"mapped",[21662]],[[194621,194621],"mapped",[21560]],[[194622,194622],"mapped",[21576]],[[194623,194623],"mapped",[21608]],[[194624,194624],"mapped",[21666]],[[194625,194625],"mapped",[21750]],[[194626,194626],"mapped",[21776]],[[194627,194627],"mapped",[21843]],[[194628,194628],"mapped",[21859]],[[194629,194630],"mapped",[21892]],[[194631,194631],"mapped",[21913]],[[194632,194632],"mapped",[21931]],[[194633,194633],"mapped",[21939]],[[194634,194634],"mapped",[21954]],[[194635,194635],"mapped",[22294]],[[194636,194636],"mapped",[22022]],[[194637,194637],"mapped",[22295]],[[194638,194638],"mapped",[22097]],[[194639,194639],"mapped",[22132]],[[194640,194640],"mapped",[20999]],[[194641,194641],"mapped",[22766]],[[194642,194642],"mapped",[22478]],[[194643,194643],"mapped",[22516]],[[194644,194644],"mapped",[22541]],[[194645,194645],"mapped",[22411]],[[194646,194646],"mapped",[22578]],[[194647,194647],"mapped",[22577]],[[194648,194648],"mapped",[22700]],[[194649,194649],"mapped",[136420]],[[194650,194650],"mapped",[22770]],[[194651,194651],"mapped",[22775]],[[194652,194652],"mapped",[22790]],[[194653,194653],"mapped",[22810]],[[194654,194654],"mapped",[22818]],[[194655,194655],"mapped",[22882]],[[194656,194656],"mapped",[136872]],[[194657,194657],"mapped",[136938]],[[194658,194658],"mapped",[23020]],[[194659,194659],"mapped",[23067]],[[194660,194660],"mapped",[23079]],[[194661,194661],"mapped",[23000]],[[194662,194662],"mapped",[23142]],[[194663,194663],"mapped",[14062]],[[194664,194664],"disallowed"],[[194665,194665],"mapped",[23304]],[[194666,194667],"mapped",[23358]],[[194668,194668],"mapped",[137672]],[[194669,194669],"mapped",[23491]],[[194670,194670],"mapped",[23512]],[[194671,194671],"mapped",[23527]],[[194672,194672],"mapped",[23539]],[[194673,194673],"mapped",[138008]],[[194674,194674],"mapped",[23551]],[[194675,194675],"mapped",[23558]],[[194676,194676],"disallowed"],[[194677,194677],"mapped",[23586]],[[194678,194678],"mapped",[14209]],[[194679,194679],"mapped",[23648]],[[194680,194680],"mapped",[23662]],[[194681,194681],"mapped",[23744]],[[194682,194682],"mapped",[23693]],[[194683,194683],"mapped",[138724]],[[194684,194684],"mapped",[23875]],[[194685,194685],"mapped",[138726]],[[194686,194686],"mapped",[23918]],[[194687,194687],"mapped",[23915]],[[194688,194688],"mapped",[23932]],[[194689,194689],"mapped",[24033]],[[194690,194690],"mapped",[24034]],[[194691,194691],"mapped",[14383]],[[194692,194692],"mapped",[24061]],[[194693,194693],"mapped",[24104]],[[194694,194694],"mapped",[24125]],[[194695,194695],"mapped",[24169]],[[194696,194696],"mapped",[14434]],[[194697,194697],"mapped",[139651]],[[194698,194698],"mapped",[14460]],[[194699,194699],"mapped",[24240]],[[194700,194700],"mapped",[24243]],[[194701,194701],"mapped",[24246]],[[194702,194702],"mapped",[24266]],[[194703,194703],"mapped",[172946]],[[194704,194704],"mapped",[24318]],[[194705,194706],"mapped",[140081]],[[194707,194707],"mapped",[33281]],[[194708,194709],"mapped",[24354]],[[194710,194710],"mapped",[14535]],[[194711,194711],"mapped",[144056]],[[194712,194712],"mapped",[156122]],[[194713,194713],"mapped",[24418]],[[194714,194714],"mapped",[24427]],[[194715,194715],"mapped",[14563]],[[194716,194716],"mapped",[24474]],[[194717,194717],"mapped",[24525]],[[194718,194718],"mapped",[24535]],[[194719,194719],"mapped",[24569]],[[194720,194720],"mapped",[24705]],[[194721,194721],"mapped",[14650]],[[194722,194722],"mapped",[14620]],[[194723,194723],"mapped",[24724]],[[194724,194724],"mapped",[141012]],[[194725,194725],"mapped",[24775]],[[194726,194726],"mapped",[24904]],[[194727,194727],"mapped",[24908]],[[194728,194728],"mapped",[24910]],[[194729,194729],"mapped",[24908]],[[194730,194730],"mapped",[24954]],[[194731,194731],"mapped",[24974]],[[194732,194732],"mapped",[25010]],[[194733,194733],"mapped",[24996]],[[194734,194734],"mapped",[25007]],[[194735,194735],"mapped",[25054]],[[194736,194736],"mapped",[25074]],[[194737,194737],"mapped",[25078]],[[194738,194738],"mapped",[25104]],[[194739,194739],"mapped",[25115]],[[194740,194740],"mapped",[25181]],[[194741,194741],"mapped",[25265]],[[194742,194742],"mapped",[25300]],[[194743,194743],"mapped",[25424]],[[194744,194744],"mapped",[142092]],[[194745,194745],"mapped",[25405]],[[194746,194746],"mapped",[25340]],[[194747,194747],"mapped",[25448]],[[194748,194748],"mapped",[25475]],[[194749,194749],"mapped",[25572]],[[194750,194750],"mapped",[142321]],[[194751,194751],"mapped",[25634]],[[194752,194752],"mapped",[25541]],[[194753,194753],"mapped",[25513]],[[194754,194754],"mapped",[14894]],[[194755,194755],"mapped",[25705]],[[194756,194756],"mapped",[25726]],[[194757,194757],"mapped",[25757]],[[194758,194758],"mapped",[25719]],[[194759,194759],"mapped",[14956]],[[194760,194760],"mapped",[25935]],[[194761,194761],"mapped",[25964]],[[194762,194762],"mapped",[143370]],[[194763,194763],"mapped",[26083]],[[194764,194764],"mapped",[26360]],[[194765,194765],"mapped",[26185]],[[194766,194766],"mapped",[15129]],[[194767,194767],"mapped",[26257]],[[194768,194768],"mapped",[15112]],[[194769,194769],"mapped",[15076]],[[194770,194770],"mapped",[20882]],[[194771,194771],"mapped",[20885]],[[194772,194772],"mapped",[26368]],[[194773,194773],"mapped",[26268]],[[194774,194774],"mapped",[32941]],[[194775,194775],"mapped",[17369]],[[194776,194776],"mapped",[26391]],[[194777,194777],"mapped",[26395]],[[194778,194778],"mapped",[26401]],[[194779,194779],"mapped",[26462]],[[194780,194780],"mapped",[26451]],[[194781,194781],"mapped",[144323]],[[194782,194782],"mapped",[15177]],[[194783,194783],"mapped",[26618]],[[194784,194784],"mapped",[26501]],[[194785,194785],"mapped",[26706]],[[194786,194786],"mapped",[26757]],[[194787,194787],"mapped",[144493]],[[194788,194788],"mapped",[26766]],[[194789,194789],"mapped",[26655]],[[194790,194790],"mapped",[26900]],[[194791,194791],"mapped",[15261]],[[194792,194792],"mapped",[26946]],[[194793,194793],"mapped",[27043]],[[194794,194794],"mapped",[27114]],[[194795,194795],"mapped",[27304]],[[194796,194796],"mapped",[145059]],[[194797,194797],"mapped",[27355]],[[194798,194798],"mapped",[15384]],[[194799,194799],"mapped",[27425]],[[194800,194800],"mapped",[145575]],[[194801,194801],"mapped",[27476]],[[194802,194802],"mapped",[15438]],[[194803,194803],"mapped",[27506]],[[194804,194804],"mapped",[27551]],[[194805,194805],"mapped",[27578]],[[194806,194806],"mapped",[27579]],[[194807,194807],"mapped",[146061]],[[194808,194808],"mapped",[138507]],[[194809,194809],"mapped",[146170]],[[194810,194810],"mapped",[27726]],[[194811,194811],"mapped",[146620]],[[194812,194812],"mapped",[27839]],[[194813,194813],"mapped",[27853]],[[194814,194814],"mapped",[27751]],[[194815,194815],"mapped",[27926]],[[194816,194816],"mapped",[27966]],[[194817,194817],"mapped",[28023]],[[194818,194818],"mapped",[27969]],[[194819,194819],"mapped",[28009]],[[194820,194820],"mapped",[28024]],[[194821,194821],"mapped",[28037]],[[194822,194822],"mapped",[146718]],[[194823,194823],"mapped",[27956]],[[194824,194824],"mapped",[28207]],[[194825,194825],"mapped",[28270]],[[194826,194826],"mapped",[15667]],[[194827,194827],"mapped",[28363]],[[194828,194828],"mapped",[28359]],[[194829,194829],"mapped",[147153]],[[194830,194830],"mapped",[28153]],[[194831,194831],"mapped",[28526]],[[194832,194832],"mapped",[147294]],[[194833,194833],"mapped",[147342]],[[194834,194834],"mapped",[28614]],[[194835,194835],"mapped",[28729]],[[194836,194836],"mapped",[28702]],[[194837,194837],"mapped",[28699]],[[194838,194838],"mapped",[15766]],[[194839,194839],"mapped",[28746]],[[194840,194840],"mapped",[28797]],[[194841,194841],"mapped",[28791]],[[194842,194842],"mapped",[28845]],[[194843,194843],"mapped",[132389]],[[194844,194844],"mapped",[28997]],[[194845,194845],"mapped",[148067]],[[194846,194846],"mapped",[29084]],[[194847,194847],"disallowed"],[[194848,194848],"mapped",[29224]],[[194849,194849],"mapped",[29237]],[[194850,194850],"mapped",[29264]],[[194851,194851],"mapped",[149000]],[[194852,194852],"mapped",[29312]],[[194853,194853],"mapped",[29333]],[[194854,194854],"mapped",[149301]],[[194855,194855],"mapped",[149524]],[[194856,194856],"mapped",[29562]],[[194857,194857],"mapped",[29579]],[[194858,194858],"mapped",[16044]],[[194859,194859],"mapped",[29605]],[[194860,194861],"mapped",[16056]],[[194862,194862],"mapped",[29767]],[[194863,194863],"mapped",[29788]],[[194864,194864],"mapped",[29809]],[[194865,194865],"mapped",[29829]],[[194866,194866],"mapped",[29898]],[[194867,194867],"mapped",[16155]],[[194868,194868],"mapped",[29988]],[[194869,194869],"mapped",[150582]],[[194870,194870],"mapped",[30014]],[[194871,194871],"mapped",[150674]],[[194872,194872],"mapped",[30064]],[[194873,194873],"mapped",[139679]],[[194874,194874],"mapped",[30224]],[[194875,194875],"mapped",[151457]],[[194876,194876],"mapped",[151480]],[[194877,194877],"mapped",[151620]],[[194878,194878],"mapped",[16380]],[[194879,194879],"mapped",[16392]],[[194880,194880],"mapped",[30452]],[[194881,194881],"mapped",[151795]],[[194882,194882],"mapped",[151794]],[[194883,194883],"mapped",[151833]],[[194884,194884],"mapped",[151859]],[[194885,194885],"mapped",[30494]],[[194886,194887],"mapped",[30495]],[[194888,194888],"mapped",[30538]],[[194889,194889],"mapped",[16441]],[[194890,194890],"mapped",[30603]],[[194891,194891],"mapped",[16454]],[[194892,194892],"mapped",[16534]],[[194893,194893],"mapped",[152605]],[[194894,194894],"mapped",[30798]],[[194895,194895],"mapped",[30860]],[[194896,194896],"mapped",[30924]],[[194897,194897],"mapped",[16611]],[[194898,194898],"mapped",[153126]],[[194899,194899],"mapped",[31062]],[[194900,194900],"mapped",[153242]],[[194901,194901],"mapped",[153285]],[[194902,194902],"mapped",[31119]],[[194903,194903],"mapped",[31211]],[[194904,194904],"mapped",[16687]],[[194905,194905],"mapped",[31296]],[[194906,194906],"mapped",[31306]],[[194907,194907],"mapped",[31311]],[[194908,194908],"mapped",[153980]],[[194909,194910],"mapped",[154279]],[[194911,194911],"disallowed"],[[194912,194912],"mapped",[16898]],[[194913,194913],"mapped",[154539]],[[194914,194914],"mapped",[31686]],[[194915,194915],"mapped",[31689]],[[194916,194916],"mapped",[16935]],[[194917,194917],"mapped",[154752]],[[194918,194918],"mapped",[31954]],[[194919,194919],"mapped",[17056]],[[194920,194920],"mapped",[31976]],[[194921,194921],"mapped",[31971]],[[194922,194922],"mapped",[32000]],[[194923,194923],"mapped",[155526]],[[194924,194924],"mapped",[32099]],[[194925,194925],"mapped",[17153]],[[194926,194926],"mapped",[32199]],[[194927,194927],"mapped",[32258]],[[194928,194928],"mapped",[32325]],[[194929,194929],"mapped",[17204]],[[194930,194930],"mapped",[156200]],[[194931,194931],"mapped",[156231]],[[194932,194932],"mapped",[17241]],[[194933,194933],"mapped",[156377]],[[194934,194934],"mapped",[32634]],[[194935,194935],"mapped",[156478]],[[194936,194936],"mapped",[32661]],[[194937,194937],"mapped",[32762]],[[194938,194938],"mapped",[32773]],[[194939,194939],"mapped",[156890]],[[194940,194940],"mapped",[156963]],[[194941,194941],"mapped",[32864]],[[194942,194942],"mapped",[157096]],[[194943,194943],"mapped",[32880]],[[194944,194944],"mapped",[144223]],[[194945,194945],"mapped",[17365]],[[194946,194946],"mapped",[32946]],[[194947,194947],"mapped",[33027]],[[194948,194948],"mapped",[17419]],[[194949,194949],"mapped",[33086]],[[194950,194950],"mapped",[23221]],[[194951,194951],"mapped",[157607]],[[194952,194952],"mapped",[157621]],[[194953,194953],"mapped",[144275]],[[194954,194954],"mapped",[144284]],[[194955,194955],"mapped",[33281]],[[194956,194956],"mapped",[33284]],[[194957,194957],"mapped",[36766]],[[194958,194958],"mapped",[17515]],[[194959,194959],"mapped",[33425]],[[194960,194960],"mapped",[33419]],[[194961,194961],"mapped",[33437]],[[194962,194962],"mapped",[21171]],[[194963,194963],"mapped",[33457]],[[194964,194964],"mapped",[33459]],[[194965,194965],"mapped",[33469]],[[194966,194966],"mapped",[33510]],[[194967,194967],"mapped",[158524]],[[194968,194968],"mapped",[33509]],[[194969,194969],"mapped",[33565]],[[194970,194970],"mapped",[33635]],[[194971,194971],"mapped",[33709]],[[194972,194972],"mapped",[33571]],[[194973,194973],"mapped",[33725]],[[194974,194974],"mapped",[33767]],[[194975,194975],"mapped",[33879]],[[194976,194976],"mapped",[33619]],[[194977,194977],"mapped",[33738]],[[194978,194978],"mapped",[33740]],[[194979,194979],"mapped",[33756]],[[194980,194980],"mapped",[158774]],[[194981,194981],"mapped",[159083]],[[194982,194982],"mapped",[158933]],[[194983,194983],"mapped",[17707]],[[194984,194984],"mapped",[34033]],[[194985,194985],"mapped",[34035]],[[194986,194986],"mapped",[34070]],[[194987,194987],"mapped",[160714]],[[194988,194988],"mapped",[34148]],[[194989,194989],"mapped",[159532]],[[194990,194990],"mapped",[17757]],[[194991,194991],"mapped",[17761]],[[194992,194992],"mapped",[159665]],[[194993,194993],"mapped",[159954]],[[194994,194994],"mapped",[17771]],[[194995,194995],"mapped",[34384]],[[194996,194996],"mapped",[34396]],[[194997,194997],"mapped",[34407]],[[194998,194998],"mapped",[34409]],[[194999,194999],"mapped",[34473]],[[195000,195000],"mapped",[34440]],[[195001,195001],"mapped",[34574]],[[195002,195002],"mapped",[34530]],[[195003,195003],"mapped",[34681]],[[195004,195004],"mapped",[34600]],[[195005,195005],"mapped",[34667]],[[195006,195006],"mapped",[34694]],[[195007,195007],"disallowed"],[[195008,195008],"mapped",[34785]],[[195009,195009],"mapped",[34817]],[[195010,195010],"mapped",[17913]],[[195011,195011],"mapped",[34912]],[[195012,195012],"mapped",[34915]],[[195013,195013],"mapped",[161383]],[[195014,195014],"mapped",[35031]],[[195015,195015],"mapped",[35038]],[[195016,195016],"mapped",[17973]],[[195017,195017],"mapped",[35066]],[[195018,195018],"mapped",[13499]],[[195019,195019],"mapped",[161966]],[[195020,195020],"mapped",[162150]],[[195021,195021],"mapped",[18110]],[[195022,195022],"mapped",[18119]],[[195023,195023],"mapped",[35488]],[[195024,195024],"mapped",[35565]],[[195025,195025],"mapped",[35722]],[[195026,195026],"mapped",[35925]],[[195027,195027],"mapped",[162984]],[[195028,195028],"mapped",[36011]],[[195029,195029],"mapped",[36033]],[[195030,195030],"mapped",[36123]],[[195031,195031],"mapped",[36215]],[[195032,195032],"mapped",[163631]],[[195033,195033],"mapped",[133124]],[[195034,195034],"mapped",[36299]],[[195035,195035],"mapped",[36284]],[[195036,195036],"mapped",[36336]],[[195037,195037],"mapped",[133342]],[[195038,195038],"mapped",[36564]],[[195039,195039],"mapped",[36664]],[[195040,195040],"mapped",[165330]],[[195041,195041],"mapped",[165357]],[[195042,195042],"mapped",[37012]],[[195043,195043],"mapped",[37105]],[[195044,195044],"mapped",[37137]],[[195045,195045],"mapped",[165678]],[[195046,195046],"mapped",[37147]],[[195047,195047],"mapped",[37432]],[[195048,195048],"mapped",[37591]],[[195049,195049],"mapped",[37592]],[[195050,195050],"mapped",[37500]],[[195051,195051],"mapped",[37881]],[[195052,195052],"mapped",[37909]],[[195053,195053],"mapped",[166906]],[[195054,195054],"mapped",[38283]],[[195055,195055],"mapped",[18837]],[[195056,195056],"mapped",[38327]],[[195057,195057],"mapped",[167287]],[[195058,195058],"mapped",[18918]],[[195059,195059],"mapped",[38595]],[[195060,195060],"mapped",[23986]],[[195061,195061],"mapped",[38691]],[[195062,195062],"mapped",[168261]],[[195063,195063],"mapped",[168474]],[[195064,195064],"mapped",[19054]],[[195065,195065],"mapped",[19062]],[[195066,195066],"mapped",[38880]],[[195067,195067],"mapped",[168970]],[[195068,195068],"mapped",[19122]],[[195069,195069],"mapped",[169110]],[[195070,195071],"mapped",[38923]],[[195072,195072],"mapped",[38953]],[[195073,195073],"mapped",[169398]],[[195074,195074],"mapped",[39138]],[[195075,195075],"mapped",[19251]],[[195076,195076],"mapped",[39209]],[[195077,195077],"mapped",[39335]],[[195078,195078],"mapped",[39362]],[[195079,195079],"mapped",[39422]],[[195080,195080],"mapped",[19406]],[[195081,195081],"mapped",[170800]],[[195082,195082],"mapped",[39698]],[[195083,195083],"mapped",[40000]],[[195084,195084],"mapped",[40189]],[[195085,195085],"mapped",[19662]],[[195086,195086],"mapped",[19693]],[[195087,195087],"mapped",[40295]],[[195088,195088],"mapped",[172238]],[[195089,195089],"mapped",[19704]],[[195090,195090],"mapped",[172293]],[[195091,195091],"mapped",[172558]],[[195092,195092],"mapped",[172689]],[[195093,195093],"mapped",[40635]],[[195094,195094],"mapped",[19798]],[[195095,195095],"mapped",[40697]],[[195096,195096],"mapped",[40702]],[[195097,195097],"mapped",[40709]],[[195098,195098],"mapped",[40719]],[[195099,195099],"mapped",[40726]],[[195100,195100],"mapped",[40763]],[[195101,195101],"mapped",[173568]],[[195102,196605],"disallowed"],[[196606,196607],"disallowed"],[[196608,262141],"disallowed"],[[262142,262143],"disallowed"],[[262144,327677],"disallowed"],[[327678,327679],"disallowed"],[[327680,393213],"disallowed"],[[393214,393215],"disallowed"],[[393216,458749],"disallowed"],[[458750,458751],"disallowed"],[[458752,524285],"disallowed"],[[524286,524287],"disallowed"],[[524288,589821],"disallowed"],[[589822,589823],"disallowed"],[[589824,655357],"disallowed"],[[655358,655359],"disallowed"],[[655360,720893],"disallowed"],[[720894,720895],"disallowed"],[[720896,786429],"disallowed"],[[786430,786431],"disallowed"],[[786432,851965],"disallowed"],[[851966,851967],"disallowed"],[[851968,917501],"disallowed"],[[917502,917503],"disallowed"],[[917504,917504],"disallowed"],[[917505,917505],"disallowed"],[[917506,917535],"disallowed"],[[917536,917631],"disallowed"],[[917632,917759],"disallowed"],[[917760,917999],"ignored"],[[918000,983037],"disallowed"],[[983038,983039],"disallowed"],[[983040,1048573],"disallowed"],[[1048574,1048575],"disallowed"],[[1048576,1114109],"disallowed"],[[1114110,1114111],"disallowed"]] \ No newline at end of file diff --git a/sandbox/tgbot/node_modules/tr46/package.json b/sandbox/tgbot/node_modules/tr46/package.json new file mode 100644 index 0000000..b6826da --- /dev/null +++ b/sandbox/tgbot/node_modules/tr46/package.json @@ -0,0 +1,31 @@ +{ + "name": "tr46", + "version": "0.0.3", + "description": "An implementation of the Unicode TR46 spec", + "main": "index.js", + "scripts": { + "test": "mocha", + "pretest": "node scripts/getLatestUnicodeTests.js", + "prepublish": "node scripts/generateMappingTable.js" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/Sebmaster/tr46.js.git" + }, + "keywords": [ + "unicode", + "tr46", + "url", + "whatwg" + ], + "author": "Sebastian Mayr ", + "license": "MIT", + "bugs": { + "url": "https://github.com/Sebmaster/tr46.js/issues" + }, + "homepage": "https://github.com/Sebmaster/tr46.js#readme", + "devDependencies": { + "mocha": "^2.2.5", + "request": "^2.57.0" + } +} diff --git a/sandbox/tgbot/node_modules/webidl-conversions/LICENSE.md b/sandbox/tgbot/node_modules/webidl-conversions/LICENSE.md new file mode 100644 index 0000000..d4a994f --- /dev/null +++ b/sandbox/tgbot/node_modules/webidl-conversions/LICENSE.md @@ -0,0 +1,12 @@ +# The BSD 2-Clause License + +Copyright (c) 2014, Domenic Denicola +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/sandbox/tgbot/node_modules/webidl-conversions/README.md b/sandbox/tgbot/node_modules/webidl-conversions/README.md new file mode 100644 index 0000000..3657890 --- /dev/null +++ b/sandbox/tgbot/node_modules/webidl-conversions/README.md @@ -0,0 +1,53 @@ +# WebIDL Type Conversions on JavaScript Values + +This package implements, in JavaScript, the algorithms to convert a given JavaScript value according to a given [WebIDL](http://heycam.github.io/webidl/) [type](http://heycam.github.io/webidl/#idl-types). + +The goal is that you should be able to write code like + +```js +const conversions = require("webidl-conversions"); + +function doStuff(x, y) { + x = conversions["boolean"](x); + y = conversions["unsigned long"](y); + // actual algorithm code here +} +``` + +and your function `doStuff` will behave the same as a WebIDL operation declared as + +```webidl +void doStuff(boolean x, unsigned long y); +``` + +## API + +This package's main module's default export is an object with a variety of methods, each corresponding to a different WebIDL type. Each method, when invoked on a JavaScript value, will give back the new JavaScript value that results after passing through the WebIDL conversion rules. (See below for more details on what that means.) Alternately, the method could throw an error, if the WebIDL algorithm is specified to do so: for example `conversions["float"](NaN)` [will throw a `TypeError`](http://heycam.github.io/webidl/#es-float). + +## Status + +All of the numeric types are implemented (float being implemented as double) and some others are as well - check the source for all of them. This list will grow over time in service of the [HTML as Custom Elements](https://github.com/dglazkov/html-as-custom-elements) project, but in the meantime, pull requests welcome! + +I'm not sure yet what the strategy will be for modifiers, e.g. [`[Clamp]`](http://heycam.github.io/webidl/#Clamp). Maybe something like `conversions["unsigned long"](x, { clamp: true })`? We'll see. + +We might also want to extend the API to give better error messages, e.g. "Argument 1 of HTMLMediaElement.fastSeek is not a finite floating-point value" instead of "Argument is not a finite floating-point value." This would require passing in more information to the conversion functions than we currently do. + +## Background + +What's actually going on here, conceptually, is pretty weird. Let's try to explain. + +WebIDL, as part of its madness-inducing design, has its own type system. When people write algorithms in web platform specs, they usually operate on WebIDL values, i.e. instances of WebIDL types. For example, if they were specifying the algorithm for our `doStuff` operation above, they would treat `x` as a WebIDL value of [WebIDL type `boolean`](http://heycam.github.io/webidl/#idl-boolean). Crucially, they would _not_ treat `x` as a JavaScript variable whose value is either the JavaScript `true` or `false`. They're instead working in a different type system altogether, with its own rules. + +Separately from its type system, WebIDL defines a ["binding"](http://heycam.github.io/webidl/#ecmascript-binding) of the type system into JavaScript. This contains rules like: when you pass a JavaScript value to the JavaScript method that manifests a given WebIDL operation, how does that get converted into a WebIDL value? For example, a JavaScript `true` passed in the position of a WebIDL `boolean` argument becomes a WebIDL `true`. But, a JavaScript `true` passed in the position of a [WebIDL `unsigned long`](http://heycam.github.io/webidl/#idl-unsigned-long) becomes a WebIDL `1`. And so on. + +Finally, we have the actual implementation code. This is usually C++, although these days [some smart people are using Rust](https://github.com/servo/servo). The implementation, of course, has its own type system. So when they implement the WebIDL algorithms, they don't actually use WebIDL values, since those aren't "real" outside of specs. Instead, implementations apply the WebIDL binding rules in such a way as to convert incoming JavaScript values into C++ values. For example, if code in the browser called `doStuff(true, true)`, then the implementation code would eventually receive a C++ `bool` containing `true` and a C++ `uint32_t` containing `1`. + +The upside of all this is that implementations can abstract all the conversion logic away, letting WebIDL handle it, and focus on implementing the relevant methods in C++ with values of the correct type already provided. That is payoff of WebIDL, in a nutshell. + +And getting to that payoff is the goal of _this_ project—but for JavaScript implementations, instead of C++ ones. That is, this library is designed to make it easier for JavaScript developers to write functions that behave like a given WebIDL operation. So conceptually, the conversion pipeline, which in its general form is JavaScript values ↦ WebIDL values ↦ implementation-language values, in this case becomes JavaScript values ↦ WebIDL values ↦ JavaScript values. And that intermediate step is where all the logic is performed: a JavaScript `true` becomes a WebIDL `1` in an unsigned long context, which then becomes a JavaScript `1`. + +## Don't Use This + +Seriously, why would you ever use this? You really shouldn't. WebIDL is … not great, and you shouldn't be emulating its semantics. If you're looking for a generic argument-processing library, you should find one with better rules than those from WebIDL. In general, your JavaScript should not be trying to become more like WebIDL; if anything, we should fix WebIDL to make it more like JavaScript. + +The _only_ people who should use this are those trying to create faithful implementations (or polyfills) of web platform interfaces defined in WebIDL. diff --git a/sandbox/tgbot/node_modules/webidl-conversions/lib/index.js b/sandbox/tgbot/node_modules/webidl-conversions/lib/index.js new file mode 100644 index 0000000..c5153a3 --- /dev/null +++ b/sandbox/tgbot/node_modules/webidl-conversions/lib/index.js @@ -0,0 +1,189 @@ +"use strict"; + +var conversions = {}; +module.exports = conversions; + +function sign(x) { + return x < 0 ? -1 : 1; +} + +function evenRound(x) { + // Round x to the nearest integer, choosing the even integer if it lies halfway between two. + if ((x % 1) === 0.5 && (x & 1) === 0) { // [even number].5; round down (i.e. floor) + return Math.floor(x); + } else { + return Math.round(x); + } +} + +function createNumberConversion(bitLength, typeOpts) { + if (!typeOpts.unsigned) { + --bitLength; + } + const lowerBound = typeOpts.unsigned ? 0 : -Math.pow(2, bitLength); + const upperBound = Math.pow(2, bitLength) - 1; + + const moduloVal = typeOpts.moduloBitLength ? Math.pow(2, typeOpts.moduloBitLength) : Math.pow(2, bitLength); + const moduloBound = typeOpts.moduloBitLength ? Math.pow(2, typeOpts.moduloBitLength - 1) : Math.pow(2, bitLength - 1); + + return function(V, opts) { + if (!opts) opts = {}; + + let x = +V; + + if (opts.enforceRange) { + if (!Number.isFinite(x)) { + throw new TypeError("Argument is not a finite number"); + } + + x = sign(x) * Math.floor(Math.abs(x)); + if (x < lowerBound || x > upperBound) { + throw new TypeError("Argument is not in byte range"); + } + + return x; + } + + if (!isNaN(x) && opts.clamp) { + x = evenRound(x); + + if (x < lowerBound) x = lowerBound; + if (x > upperBound) x = upperBound; + return x; + } + + if (!Number.isFinite(x) || x === 0) { + return 0; + } + + x = sign(x) * Math.floor(Math.abs(x)); + x = x % moduloVal; + + if (!typeOpts.unsigned && x >= moduloBound) { + return x - moduloVal; + } else if (typeOpts.unsigned) { + if (x < 0) { + x += moduloVal; + } else if (x === -0) { // don't return negative zero + return 0; + } + } + + return x; + } +} + +conversions["void"] = function () { + return undefined; +}; + +conversions["boolean"] = function (val) { + return !!val; +}; + +conversions["byte"] = createNumberConversion(8, { unsigned: false }); +conversions["octet"] = createNumberConversion(8, { unsigned: true }); + +conversions["short"] = createNumberConversion(16, { unsigned: false }); +conversions["unsigned short"] = createNumberConversion(16, { unsigned: true }); + +conversions["long"] = createNumberConversion(32, { unsigned: false }); +conversions["unsigned long"] = createNumberConversion(32, { unsigned: true }); + +conversions["long long"] = createNumberConversion(32, { unsigned: false, moduloBitLength: 64 }); +conversions["unsigned long long"] = createNumberConversion(32, { unsigned: true, moduloBitLength: 64 }); + +conversions["double"] = function (V) { + const x = +V; + + if (!Number.isFinite(x)) { + throw new TypeError("Argument is not a finite floating-point value"); + } + + return x; +}; + +conversions["unrestricted double"] = function (V) { + const x = +V; + + if (isNaN(x)) { + throw new TypeError("Argument is NaN"); + } + + return x; +}; + +// not quite valid, but good enough for JS +conversions["float"] = conversions["double"]; +conversions["unrestricted float"] = conversions["unrestricted double"]; + +conversions["DOMString"] = function (V, opts) { + if (!opts) opts = {}; + + if (opts.treatNullAsEmptyString && V === null) { + return ""; + } + + return String(V); +}; + +conversions["ByteString"] = function (V, opts) { + const x = String(V); + let c = undefined; + for (let i = 0; (c = x.codePointAt(i)) !== undefined; ++i) { + if (c > 255) { + throw new TypeError("Argument is not a valid bytestring"); + } + } + + return x; +}; + +conversions["USVString"] = function (V) { + const S = String(V); + const n = S.length; + const U = []; + for (let i = 0; i < n; ++i) { + const c = S.charCodeAt(i); + if (c < 0xD800 || c > 0xDFFF) { + U.push(String.fromCodePoint(c)); + } else if (0xDC00 <= c && c <= 0xDFFF) { + U.push(String.fromCodePoint(0xFFFD)); + } else { + if (i === n - 1) { + U.push(String.fromCodePoint(0xFFFD)); + } else { + const d = S.charCodeAt(i + 1); + if (0xDC00 <= d && d <= 0xDFFF) { + const a = c & 0x3FF; + const b = d & 0x3FF; + U.push(String.fromCodePoint((2 << 15) + (2 << 9) * a + b)); + ++i; + } else { + U.push(String.fromCodePoint(0xFFFD)); + } + } + } + } + + return U.join(''); +}; + +conversions["Date"] = function (V, opts) { + if (!(V instanceof Date)) { + throw new TypeError("Argument is not a Date object"); + } + if (isNaN(V)) { + return undefined; + } + + return V; +}; + +conversions["RegExp"] = function (V, opts) { + if (!(V instanceof RegExp)) { + V = new RegExp(V); + } + + return V; +}; diff --git a/sandbox/tgbot/node_modules/webidl-conversions/package.json b/sandbox/tgbot/node_modules/webidl-conversions/package.json new file mode 100644 index 0000000..c31bc07 --- /dev/null +++ b/sandbox/tgbot/node_modules/webidl-conversions/package.json @@ -0,0 +1,23 @@ +{ + "name": "webidl-conversions", + "version": "3.0.1", + "description": "Implements the WebIDL algorithms for converting to and from JavaScript values", + "main": "lib/index.js", + "scripts": { + "test": "mocha test/*.js" + }, + "repository": "jsdom/webidl-conversions", + "keywords": [ + "webidl", + "web", + "types" + ], + "files": [ + "lib/" + ], + "author": "Domenic Denicola (https://domenic.me/)", + "license": "BSD-2-Clause", + "devDependencies": { + "mocha": "^1.21.4" + } +} diff --git a/sandbox/tgbot/node_modules/whatwg-url/LICENSE.txt b/sandbox/tgbot/node_modules/whatwg-url/LICENSE.txt new file mode 100644 index 0000000..54dfac3 --- /dev/null +++ b/sandbox/tgbot/node_modules/whatwg-url/LICENSE.txt @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2015–2016 Sebastian Mayr + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/sandbox/tgbot/node_modules/whatwg-url/README.md b/sandbox/tgbot/node_modules/whatwg-url/README.md new file mode 100644 index 0000000..4347a7f --- /dev/null +++ b/sandbox/tgbot/node_modules/whatwg-url/README.md @@ -0,0 +1,67 @@ +# whatwg-url + +whatwg-url is a full implementation of the WHATWG [URL Standard](https://url.spec.whatwg.org/). It can be used standalone, but it also exposes a lot of the internal algorithms that are useful for integrating a URL parser into a project like [jsdom](https://github.com/tmpvar/jsdom). + +## Current Status + +whatwg-url is currently up to date with the URL spec up to commit [a62223](https://github.com/whatwg/url/commit/a622235308342c9adc7fc2fd1659ff059f7d5e2a). + +## API + +### The `URL` Constructor + +The main API is the [`URL`](https://url.spec.whatwg.org/#url) export, which follows the spec's behavior in all ways (including e.g. `USVString` conversion). Most consumers of this library will want to use this. + +### Low-level URL Standard API + +The following methods are exported for use by places like jsdom that need to implement things like [`HTMLHyperlinkElementUtils`](https://html.spec.whatwg.org/#htmlhyperlinkelementutils). They operate on or return an "internal URL" or ["URL record"](https://url.spec.whatwg.org/#concept-url) type. + +- [URL parser](https://url.spec.whatwg.org/#concept-url-parser): `parseURL(input, { baseURL, encodingOverride })` +- [Basic URL parser](https://url.spec.whatwg.org/#concept-basic-url-parser): `basicURLParse(input, { baseURL, encodingOverride, url, stateOverride })` +- [URL serializer](https://url.spec.whatwg.org/#concept-url-serializer): `serializeURL(urlRecord, excludeFragment)` +- [Host serializer](https://url.spec.whatwg.org/#concept-host-serializer): `serializeHost(hostFromURLRecord)` +- [Serialize an integer](https://url.spec.whatwg.org/#serialize-an-integer): `serializeInteger(number)` +- [Origin](https://url.spec.whatwg.org/#concept-url-origin) [serializer](https://html.spec.whatwg.org/multipage/browsers.html#serialization-of-an-origin): `serializeURLOrigin(urlRecord)` +- [Set the username](https://url.spec.whatwg.org/#set-the-username): `setTheUsername(urlRecord, usernameString)` +- [Set the password](https://url.spec.whatwg.org/#set-the-password): `setThePassword(urlRecord, passwordString)` +- [Cannot have a username/password/port](https://url.spec.whatwg.org/#cannot-have-a-username-password-port): `cannotHaveAUsernamePasswordPort(urlRecord)` + +The `stateOverride` parameter is one of the following strings: + +- [`"scheme start"`](https://url.spec.whatwg.org/#scheme-start-state) +- [`"scheme"`](https://url.spec.whatwg.org/#scheme-state) +- [`"no scheme"`](https://url.spec.whatwg.org/#no-scheme-state) +- [`"special relative or authority"`](https://url.spec.whatwg.org/#special-relative-or-authority-state) +- [`"path or authority"`](https://url.spec.whatwg.org/#path-or-authority-state) +- [`"relative"`](https://url.spec.whatwg.org/#relative-state) +- [`"relative slash"`](https://url.spec.whatwg.org/#relative-slash-state) +- [`"special authority slashes"`](https://url.spec.whatwg.org/#special-authority-slashes-state) +- [`"special authority ignore slashes"`](https://url.spec.whatwg.org/#special-authority-ignore-slashes-state) +- [`"authority"`](https://url.spec.whatwg.org/#authority-state) +- [`"host"`](https://url.spec.whatwg.org/#host-state) +- [`"hostname"`](https://url.spec.whatwg.org/#hostname-state) +- [`"port"`](https://url.spec.whatwg.org/#port-state) +- [`"file"`](https://url.spec.whatwg.org/#file-state) +- [`"file slash"`](https://url.spec.whatwg.org/#file-slash-state) +- [`"file host"`](https://url.spec.whatwg.org/#file-host-state) +- [`"path start"`](https://url.spec.whatwg.org/#path-start-state) +- [`"path"`](https://url.spec.whatwg.org/#path-state) +- [`"cannot-be-a-base-URL path"`](https://url.spec.whatwg.org/#cannot-be-a-base-url-path-state) +- [`"query"`](https://url.spec.whatwg.org/#query-state) +- [`"fragment"`](https://url.spec.whatwg.org/#fragment-state) + +The URL record type has the following API: + +- [`scheme`](https://url.spec.whatwg.org/#concept-url-scheme) +- [`username`](https://url.spec.whatwg.org/#concept-url-username) +- [`password`](https://url.spec.whatwg.org/#concept-url-password) +- [`host`](https://url.spec.whatwg.org/#concept-url-host) +- [`port`](https://url.spec.whatwg.org/#concept-url-port) +- [`path`](https://url.spec.whatwg.org/#concept-url-path) (as an array) +- [`query`](https://url.spec.whatwg.org/#concept-url-query) +- [`fragment`](https://url.spec.whatwg.org/#concept-url-fragment) +- [`cannotBeABaseURL`](https://url.spec.whatwg.org/#url-cannot-be-a-base-url-flag) (as a boolean) + +These properties should be treated with care, as in general changing them will cause the URL record to be in an inconsistent state until the appropriate invocation of `basicURLParse` is used to fix it up. You can see examples of this in the URL Standard, where there are many step sequences like "4. Set context object’s url’s fragment to the empty string. 5. Basic URL parse _input_ with context object’s url as _url_ and fragment state as _state override_." In between those two steps, a URL record is in an unusable state. + +The return value of "failure" in the spec is represented by the string `"failure"`. That is, functions like `parseURL` and `basicURLParse` can return _either_ a URL record _or_ the string `"failure"`. diff --git a/sandbox/tgbot/node_modules/whatwg-url/lib/URL-impl.js b/sandbox/tgbot/node_modules/whatwg-url/lib/URL-impl.js new file mode 100644 index 0000000..dc7452c --- /dev/null +++ b/sandbox/tgbot/node_modules/whatwg-url/lib/URL-impl.js @@ -0,0 +1,200 @@ +"use strict"; +const usm = require("./url-state-machine"); + +exports.implementation = class URLImpl { + constructor(constructorArgs) { + const url = constructorArgs[0]; + const base = constructorArgs[1]; + + let parsedBase = null; + if (base !== undefined) { + parsedBase = usm.basicURLParse(base); + if (parsedBase === "failure") { + throw new TypeError("Invalid base URL"); + } + } + + const parsedURL = usm.basicURLParse(url, { baseURL: parsedBase }); + if (parsedURL === "failure") { + throw new TypeError("Invalid URL"); + } + + this._url = parsedURL; + + // TODO: query stuff + } + + get href() { + return usm.serializeURL(this._url); + } + + set href(v) { + const parsedURL = usm.basicURLParse(v); + if (parsedURL === "failure") { + throw new TypeError("Invalid URL"); + } + + this._url = parsedURL; + } + + get origin() { + return usm.serializeURLOrigin(this._url); + } + + get protocol() { + return this._url.scheme + ":"; + } + + set protocol(v) { + usm.basicURLParse(v + ":", { url: this._url, stateOverride: "scheme start" }); + } + + get username() { + return this._url.username; + } + + set username(v) { + if (usm.cannotHaveAUsernamePasswordPort(this._url)) { + return; + } + + usm.setTheUsername(this._url, v); + } + + get password() { + return this._url.password; + } + + set password(v) { + if (usm.cannotHaveAUsernamePasswordPort(this._url)) { + return; + } + + usm.setThePassword(this._url, v); + } + + get host() { + const url = this._url; + + if (url.host === null) { + return ""; + } + + if (url.port === null) { + return usm.serializeHost(url.host); + } + + return usm.serializeHost(url.host) + ":" + usm.serializeInteger(url.port); + } + + set host(v) { + if (this._url.cannotBeABaseURL) { + return; + } + + usm.basicURLParse(v, { url: this._url, stateOverride: "host" }); + } + + get hostname() { + if (this._url.host === null) { + return ""; + } + + return usm.serializeHost(this._url.host); + } + + set hostname(v) { + if (this._url.cannotBeABaseURL) { + return; + } + + usm.basicURLParse(v, { url: this._url, stateOverride: "hostname" }); + } + + get port() { + if (this._url.port === null) { + return ""; + } + + return usm.serializeInteger(this._url.port); + } + + set port(v) { + if (usm.cannotHaveAUsernamePasswordPort(this._url)) { + return; + } + + if (v === "") { + this._url.port = null; + } else { + usm.basicURLParse(v, { url: this._url, stateOverride: "port" }); + } + } + + get pathname() { + if (this._url.cannotBeABaseURL) { + return this._url.path[0]; + } + + if (this._url.path.length === 0) { + return ""; + } + + return "/" + this._url.path.join("/"); + } + + set pathname(v) { + if (this._url.cannotBeABaseURL) { + return; + } + + this._url.path = []; + usm.basicURLParse(v, { url: this._url, stateOverride: "path start" }); + } + + get search() { + if (this._url.query === null || this._url.query === "") { + return ""; + } + + return "?" + this._url.query; + } + + set search(v) { + // TODO: query stuff + + const url = this._url; + + if (v === "") { + url.query = null; + return; + } + + const input = v[0] === "?" ? v.substring(1) : v; + url.query = ""; + usm.basicURLParse(input, { url, stateOverride: "query" }); + } + + get hash() { + if (this._url.fragment === null || this._url.fragment === "") { + return ""; + } + + return "#" + this._url.fragment; + } + + set hash(v) { + if (v === "") { + this._url.fragment = null; + return; + } + + const input = v[0] === "#" ? v.substring(1) : v; + this._url.fragment = ""; + usm.basicURLParse(input, { url: this._url, stateOverride: "fragment" }); + } + + toJSON() { + return this.href; + } +}; diff --git a/sandbox/tgbot/node_modules/whatwg-url/lib/URL.js b/sandbox/tgbot/node_modules/whatwg-url/lib/URL.js new file mode 100644 index 0000000..78c7207 --- /dev/null +++ b/sandbox/tgbot/node_modules/whatwg-url/lib/URL.js @@ -0,0 +1,196 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); +const Impl = require(".//URL-impl.js"); + +const impl = utils.implSymbol; + +function URL(url) { + if (!this || this[impl] || !(this instanceof URL)) { + throw new TypeError("Failed to construct 'URL': Please use the 'new' operator, this DOM object constructor cannot be called as a function."); + } + if (arguments.length < 1) { + throw new TypeError("Failed to construct 'URL': 1 argument required, but only " + arguments.length + " present."); + } + const args = []; + for (let i = 0; i < arguments.length && i < 2; ++i) { + args[i] = arguments[i]; + } + args[0] = conversions["USVString"](args[0]); + if (args[1] !== undefined) { + args[1] = conversions["USVString"](args[1]); + } + + module.exports.setup(this, args); +} + +URL.prototype.toJSON = function toJSON() { + if (!this || !module.exports.is(this)) { + throw new TypeError("Illegal invocation"); + } + const args = []; + for (let i = 0; i < arguments.length && i < 0; ++i) { + args[i] = arguments[i]; + } + return this[impl].toJSON.apply(this[impl], args); +}; +Object.defineProperty(URL.prototype, "href", { + get() { + return this[impl].href; + }, + set(V) { + V = conversions["USVString"](V); + this[impl].href = V; + }, + enumerable: true, + configurable: true +}); + +URL.prototype.toString = function () { + if (!this || !module.exports.is(this)) { + throw new TypeError("Illegal invocation"); + } + return this.href; +}; + +Object.defineProperty(URL.prototype, "origin", { + get() { + return this[impl].origin; + }, + enumerable: true, + configurable: true +}); + +Object.defineProperty(URL.prototype, "protocol", { + get() { + return this[impl].protocol; + }, + set(V) { + V = conversions["USVString"](V); + this[impl].protocol = V; + }, + enumerable: true, + configurable: true +}); + +Object.defineProperty(URL.prototype, "username", { + get() { + return this[impl].username; + }, + set(V) { + V = conversions["USVString"](V); + this[impl].username = V; + }, + enumerable: true, + configurable: true +}); + +Object.defineProperty(URL.prototype, "password", { + get() { + return this[impl].password; + }, + set(V) { + V = conversions["USVString"](V); + this[impl].password = V; + }, + enumerable: true, + configurable: true +}); + +Object.defineProperty(URL.prototype, "host", { + get() { + return this[impl].host; + }, + set(V) { + V = conversions["USVString"](V); + this[impl].host = V; + }, + enumerable: true, + configurable: true +}); + +Object.defineProperty(URL.prototype, "hostname", { + get() { + return this[impl].hostname; + }, + set(V) { + V = conversions["USVString"](V); + this[impl].hostname = V; + }, + enumerable: true, + configurable: true +}); + +Object.defineProperty(URL.prototype, "port", { + get() { + return this[impl].port; + }, + set(V) { + V = conversions["USVString"](V); + this[impl].port = V; + }, + enumerable: true, + configurable: true +}); + +Object.defineProperty(URL.prototype, "pathname", { + get() { + return this[impl].pathname; + }, + set(V) { + V = conversions["USVString"](V); + this[impl].pathname = V; + }, + enumerable: true, + configurable: true +}); + +Object.defineProperty(URL.prototype, "search", { + get() { + return this[impl].search; + }, + set(V) { + V = conversions["USVString"](V); + this[impl].search = V; + }, + enumerable: true, + configurable: true +}); + +Object.defineProperty(URL.prototype, "hash", { + get() { + return this[impl].hash; + }, + set(V) { + V = conversions["USVString"](V); + this[impl].hash = V; + }, + enumerable: true, + configurable: true +}); + + +module.exports = { + is(obj) { + return !!obj && obj[impl] instanceof Impl.implementation; + }, + create(constructorArgs, privateData) { + let obj = Object.create(URL.prototype); + this.setup(obj, constructorArgs, privateData); + return obj; + }, + setup(obj, constructorArgs, privateData) { + if (!privateData) privateData = {}; + privateData.wrapper = obj; + + obj[impl] = new Impl.implementation(constructorArgs, privateData); + obj[impl][utils.wrapperSymbol] = obj; + }, + interface: URL, + expose: { + Window: { URL: URL }, + Worker: { URL: URL } + } +}; + diff --git a/sandbox/tgbot/node_modules/whatwg-url/lib/public-api.js b/sandbox/tgbot/node_modules/whatwg-url/lib/public-api.js new file mode 100644 index 0000000..932dcad --- /dev/null +++ b/sandbox/tgbot/node_modules/whatwg-url/lib/public-api.js @@ -0,0 +1,11 @@ +"use strict"; + +exports.URL = require("./URL").interface; +exports.serializeURL = require("./url-state-machine").serializeURL; +exports.serializeURLOrigin = require("./url-state-machine").serializeURLOrigin; +exports.basicURLParse = require("./url-state-machine").basicURLParse; +exports.setTheUsername = require("./url-state-machine").setTheUsername; +exports.setThePassword = require("./url-state-machine").setThePassword; +exports.serializeHost = require("./url-state-machine").serializeHost; +exports.serializeInteger = require("./url-state-machine").serializeInteger; +exports.parseURL = require("./url-state-machine").parseURL; diff --git a/sandbox/tgbot/node_modules/whatwg-url/lib/url-state-machine.js b/sandbox/tgbot/node_modules/whatwg-url/lib/url-state-machine.js new file mode 100644 index 0000000..c25dbc2 --- /dev/null +++ b/sandbox/tgbot/node_modules/whatwg-url/lib/url-state-machine.js @@ -0,0 +1,1297 @@ +"use strict"; +const punycode = require("punycode"); +const tr46 = require("tr46"); + +const specialSchemes = { + ftp: 21, + file: null, + gopher: 70, + http: 80, + https: 443, + ws: 80, + wss: 443 +}; + +const failure = Symbol("failure"); + +function countSymbols(str) { + return punycode.ucs2.decode(str).length; +} + +function at(input, idx) { + const c = input[idx]; + return isNaN(c) ? undefined : String.fromCodePoint(c); +} + +function isASCIIDigit(c) { + return c >= 0x30 && c <= 0x39; +} + +function isASCIIAlpha(c) { + return (c >= 0x41 && c <= 0x5A) || (c >= 0x61 && c <= 0x7A); +} + +function isASCIIAlphanumeric(c) { + return isASCIIAlpha(c) || isASCIIDigit(c); +} + +function isASCIIHex(c) { + return isASCIIDigit(c) || (c >= 0x41 && c <= 0x46) || (c >= 0x61 && c <= 0x66); +} + +function isSingleDot(buffer) { + return buffer === "." || buffer.toLowerCase() === "%2e"; +} + +function isDoubleDot(buffer) { + buffer = buffer.toLowerCase(); + return buffer === ".." || buffer === "%2e." || buffer === ".%2e" || buffer === "%2e%2e"; +} + +function isWindowsDriveLetterCodePoints(cp1, cp2) { + return isASCIIAlpha(cp1) && (cp2 === 58 || cp2 === 124); +} + +function isWindowsDriveLetterString(string) { + return string.length === 2 && isASCIIAlpha(string.codePointAt(0)) && (string[1] === ":" || string[1] === "|"); +} + +function isNormalizedWindowsDriveLetterString(string) { + return string.length === 2 && isASCIIAlpha(string.codePointAt(0)) && string[1] === ":"; +} + +function containsForbiddenHostCodePoint(string) { + return string.search(/\u0000|\u0009|\u000A|\u000D|\u0020|#|%|\/|:|\?|@|\[|\\|\]/) !== -1; +} + +function containsForbiddenHostCodePointExcludingPercent(string) { + return string.search(/\u0000|\u0009|\u000A|\u000D|\u0020|#|\/|:|\?|@|\[|\\|\]/) !== -1; +} + +function isSpecialScheme(scheme) { + return specialSchemes[scheme] !== undefined; +} + +function isSpecial(url) { + return isSpecialScheme(url.scheme); +} + +function defaultPort(scheme) { + return specialSchemes[scheme]; +} + +function percentEncode(c) { + let hex = c.toString(16).toUpperCase(); + if (hex.length === 1) { + hex = "0" + hex; + } + + return "%" + hex; +} + +function utf8PercentEncode(c) { + const buf = new Buffer(c); + + let str = ""; + + for (let i = 0; i < buf.length; ++i) { + str += percentEncode(buf[i]); + } + + return str; +} + +function utf8PercentDecode(str) { + const input = new Buffer(str); + const output = []; + for (let i = 0; i < input.length; ++i) { + if (input[i] !== 37) { + output.push(input[i]); + } else if (input[i] === 37 && isASCIIHex(input[i + 1]) && isASCIIHex(input[i + 2])) { + output.push(parseInt(input.slice(i + 1, i + 3).toString(), 16)); + i += 2; + } else { + output.push(input[i]); + } + } + return new Buffer(output).toString(); +} + +function isC0ControlPercentEncode(c) { + return c <= 0x1F || c > 0x7E; +} + +const extraPathPercentEncodeSet = new Set([32, 34, 35, 60, 62, 63, 96, 123, 125]); +function isPathPercentEncode(c) { + return isC0ControlPercentEncode(c) || extraPathPercentEncodeSet.has(c); +} + +const extraUserinfoPercentEncodeSet = + new Set([47, 58, 59, 61, 64, 91, 92, 93, 94, 124]); +function isUserinfoPercentEncode(c) { + return isPathPercentEncode(c) || extraUserinfoPercentEncodeSet.has(c); +} + +function percentEncodeChar(c, encodeSetPredicate) { + const cStr = String.fromCodePoint(c); + + if (encodeSetPredicate(c)) { + return utf8PercentEncode(cStr); + } + + return cStr; +} + +function parseIPv4Number(input) { + let R = 10; + + if (input.length >= 2 && input.charAt(0) === "0" && input.charAt(1).toLowerCase() === "x") { + input = input.substring(2); + R = 16; + } else if (input.length >= 2 && input.charAt(0) === "0") { + input = input.substring(1); + R = 8; + } + + if (input === "") { + return 0; + } + + const regex = R === 10 ? /[^0-9]/ : (R === 16 ? /[^0-9A-Fa-f]/ : /[^0-7]/); + if (regex.test(input)) { + return failure; + } + + return parseInt(input, R); +} + +function parseIPv4(input) { + const parts = input.split("."); + if (parts[parts.length - 1] === "") { + if (parts.length > 1) { + parts.pop(); + } + } + + if (parts.length > 4) { + return input; + } + + const numbers = []; + for (const part of parts) { + if (part === "") { + return input; + } + const n = parseIPv4Number(part); + if (n === failure) { + return input; + } + + numbers.push(n); + } + + for (let i = 0; i < numbers.length - 1; ++i) { + if (numbers[i] > 255) { + return failure; + } + } + if (numbers[numbers.length - 1] >= Math.pow(256, 5 - numbers.length)) { + return failure; + } + + let ipv4 = numbers.pop(); + let counter = 0; + + for (const n of numbers) { + ipv4 += n * Math.pow(256, 3 - counter); + ++counter; + } + + return ipv4; +} + +function serializeIPv4(address) { + let output = ""; + let n = address; + + for (let i = 1; i <= 4; ++i) { + output = String(n % 256) + output; + if (i !== 4) { + output = "." + output; + } + n = Math.floor(n / 256); + } + + return output; +} + +function parseIPv6(input) { + const address = [0, 0, 0, 0, 0, 0, 0, 0]; + let pieceIndex = 0; + let compress = null; + let pointer = 0; + + input = punycode.ucs2.decode(input); + + if (input[pointer] === 58) { + if (input[pointer + 1] !== 58) { + return failure; + } + + pointer += 2; + ++pieceIndex; + compress = pieceIndex; + } + + while (pointer < input.length) { + if (pieceIndex === 8) { + return failure; + } + + if (input[pointer] === 58) { + if (compress !== null) { + return failure; + } + ++pointer; + ++pieceIndex; + compress = pieceIndex; + continue; + } + + let value = 0; + let length = 0; + + while (length < 4 && isASCIIHex(input[pointer])) { + value = value * 0x10 + parseInt(at(input, pointer), 16); + ++pointer; + ++length; + } + + if (input[pointer] === 46) { + if (length === 0) { + return failure; + } + + pointer -= length; + + if (pieceIndex > 6) { + return failure; + } + + let numbersSeen = 0; + + while (input[pointer] !== undefined) { + let ipv4Piece = null; + + if (numbersSeen > 0) { + if (input[pointer] === 46 && numbersSeen < 4) { + ++pointer; + } else { + return failure; + } + } + + if (!isASCIIDigit(input[pointer])) { + return failure; + } + + while (isASCIIDigit(input[pointer])) { + const number = parseInt(at(input, pointer)); + if (ipv4Piece === null) { + ipv4Piece = number; + } else if (ipv4Piece === 0) { + return failure; + } else { + ipv4Piece = ipv4Piece * 10 + number; + } + if (ipv4Piece > 255) { + return failure; + } + ++pointer; + } + + address[pieceIndex] = address[pieceIndex] * 0x100 + ipv4Piece; + + ++numbersSeen; + + if (numbersSeen === 2 || numbersSeen === 4) { + ++pieceIndex; + } + } + + if (numbersSeen !== 4) { + return failure; + } + + break; + } else if (input[pointer] === 58) { + ++pointer; + if (input[pointer] === undefined) { + return failure; + } + } else if (input[pointer] !== undefined) { + return failure; + } + + address[pieceIndex] = value; + ++pieceIndex; + } + + if (compress !== null) { + let swaps = pieceIndex - compress; + pieceIndex = 7; + while (pieceIndex !== 0 && swaps > 0) { + const temp = address[compress + swaps - 1]; + address[compress + swaps - 1] = address[pieceIndex]; + address[pieceIndex] = temp; + --pieceIndex; + --swaps; + } + } else if (compress === null && pieceIndex !== 8) { + return failure; + } + + return address; +} + +function serializeIPv6(address) { + let output = ""; + const seqResult = findLongestZeroSequence(address); + const compress = seqResult.idx; + let ignore0 = false; + + for (let pieceIndex = 0; pieceIndex <= 7; ++pieceIndex) { + if (ignore0 && address[pieceIndex] === 0) { + continue; + } else if (ignore0) { + ignore0 = false; + } + + if (compress === pieceIndex) { + const separator = pieceIndex === 0 ? "::" : ":"; + output += separator; + ignore0 = true; + continue; + } + + output += address[pieceIndex].toString(16); + + if (pieceIndex !== 7) { + output += ":"; + } + } + + return output; +} + +function parseHost(input, isSpecialArg) { + if (input[0] === "[") { + if (input[input.length - 1] !== "]") { + return failure; + } + + return parseIPv6(input.substring(1, input.length - 1)); + } + + if (!isSpecialArg) { + return parseOpaqueHost(input); + } + + const domain = utf8PercentDecode(input); + const asciiDomain = tr46.toASCII(domain, false, tr46.PROCESSING_OPTIONS.NONTRANSITIONAL, false); + if (asciiDomain === null) { + return failure; + } + + if (containsForbiddenHostCodePoint(asciiDomain)) { + return failure; + } + + const ipv4Host = parseIPv4(asciiDomain); + if (typeof ipv4Host === "number" || ipv4Host === failure) { + return ipv4Host; + } + + return asciiDomain; +} + +function parseOpaqueHost(input) { + if (containsForbiddenHostCodePointExcludingPercent(input)) { + return failure; + } + + let output = ""; + const decoded = punycode.ucs2.decode(input); + for (let i = 0; i < decoded.length; ++i) { + output += percentEncodeChar(decoded[i], isC0ControlPercentEncode); + } + return output; +} + +function findLongestZeroSequence(arr) { + let maxIdx = null; + let maxLen = 1; // only find elements > 1 + let currStart = null; + let currLen = 0; + + for (let i = 0; i < arr.length; ++i) { + if (arr[i] !== 0) { + if (currLen > maxLen) { + maxIdx = currStart; + maxLen = currLen; + } + + currStart = null; + currLen = 0; + } else { + if (currStart === null) { + currStart = i; + } + ++currLen; + } + } + + // if trailing zeros + if (currLen > maxLen) { + maxIdx = currStart; + maxLen = currLen; + } + + return { + idx: maxIdx, + len: maxLen + }; +} + +function serializeHost(host) { + if (typeof host === "number") { + return serializeIPv4(host); + } + + // IPv6 serializer + if (host instanceof Array) { + return "[" + serializeIPv6(host) + "]"; + } + + return host; +} + +function trimControlChars(url) { + return url.replace(/^[\u0000-\u001F\u0020]+|[\u0000-\u001F\u0020]+$/g, ""); +} + +function trimTabAndNewline(url) { + return url.replace(/\u0009|\u000A|\u000D/g, ""); +} + +function shortenPath(url) { + const path = url.path; + if (path.length === 0) { + return; + } + if (url.scheme === "file" && path.length === 1 && isNormalizedWindowsDriveLetter(path[0])) { + return; + } + + path.pop(); +} + +function includesCredentials(url) { + return url.username !== "" || url.password !== ""; +} + +function cannotHaveAUsernamePasswordPort(url) { + return url.host === null || url.host === "" || url.cannotBeABaseURL || url.scheme === "file"; +} + +function isNormalizedWindowsDriveLetter(string) { + return /^[A-Za-z]:$/.test(string); +} + +function URLStateMachine(input, base, encodingOverride, url, stateOverride) { + this.pointer = 0; + this.input = input; + this.base = base || null; + this.encodingOverride = encodingOverride || "utf-8"; + this.stateOverride = stateOverride; + this.url = url; + this.failure = false; + this.parseError = false; + + if (!this.url) { + this.url = { + scheme: "", + username: "", + password: "", + host: null, + port: null, + path: [], + query: null, + fragment: null, + + cannotBeABaseURL: false + }; + + const res = trimControlChars(this.input); + if (res !== this.input) { + this.parseError = true; + } + this.input = res; + } + + const res = trimTabAndNewline(this.input); + if (res !== this.input) { + this.parseError = true; + } + this.input = res; + + this.state = stateOverride || "scheme start"; + + this.buffer = ""; + this.atFlag = false; + this.arrFlag = false; + this.passwordTokenSeenFlag = false; + + this.input = punycode.ucs2.decode(this.input); + + for (; this.pointer <= this.input.length; ++this.pointer) { + const c = this.input[this.pointer]; + const cStr = isNaN(c) ? undefined : String.fromCodePoint(c); + + // exec state machine + const ret = this["parse " + this.state](c, cStr); + if (!ret) { + break; // terminate algorithm + } else if (ret === failure) { + this.failure = true; + break; + } + } +} + +URLStateMachine.prototype["parse scheme start"] = function parseSchemeStart(c, cStr) { + if (isASCIIAlpha(c)) { + this.buffer += cStr.toLowerCase(); + this.state = "scheme"; + } else if (!this.stateOverride) { + this.state = "no scheme"; + --this.pointer; + } else { + this.parseError = true; + return failure; + } + + return true; +}; + +URLStateMachine.prototype["parse scheme"] = function parseScheme(c, cStr) { + if (isASCIIAlphanumeric(c) || c === 43 || c === 45 || c === 46) { + this.buffer += cStr.toLowerCase(); + } else if (c === 58) { + if (this.stateOverride) { + if (isSpecial(this.url) && !isSpecialScheme(this.buffer)) { + return false; + } + + if (!isSpecial(this.url) && isSpecialScheme(this.buffer)) { + return false; + } + + if ((includesCredentials(this.url) || this.url.port !== null) && this.buffer === "file") { + return false; + } + + if (this.url.scheme === "file" && (this.url.host === "" || this.url.host === null)) { + return false; + } + } + this.url.scheme = this.buffer; + this.buffer = ""; + if (this.stateOverride) { + return false; + } + if (this.url.scheme === "file") { + if (this.input[this.pointer + 1] !== 47 || this.input[this.pointer + 2] !== 47) { + this.parseError = true; + } + this.state = "file"; + } else if (isSpecial(this.url) && this.base !== null && this.base.scheme === this.url.scheme) { + this.state = "special relative or authority"; + } else if (isSpecial(this.url)) { + this.state = "special authority slashes"; + } else if (this.input[this.pointer + 1] === 47) { + this.state = "path or authority"; + ++this.pointer; + } else { + this.url.cannotBeABaseURL = true; + this.url.path.push(""); + this.state = "cannot-be-a-base-URL path"; + } + } else if (!this.stateOverride) { + this.buffer = ""; + this.state = "no scheme"; + this.pointer = -1; + } else { + this.parseError = true; + return failure; + } + + return true; +}; + +URLStateMachine.prototype["parse no scheme"] = function parseNoScheme(c) { + if (this.base === null || (this.base.cannotBeABaseURL && c !== 35)) { + return failure; + } else if (this.base.cannotBeABaseURL && c === 35) { + this.url.scheme = this.base.scheme; + this.url.path = this.base.path.slice(); + this.url.query = this.base.query; + this.url.fragment = ""; + this.url.cannotBeABaseURL = true; + this.state = "fragment"; + } else if (this.base.scheme === "file") { + this.state = "file"; + --this.pointer; + } else { + this.state = "relative"; + --this.pointer; + } + + return true; +}; + +URLStateMachine.prototype["parse special relative or authority"] = function parseSpecialRelativeOrAuthority(c) { + if (c === 47 && this.input[this.pointer + 1] === 47) { + this.state = "special authority ignore slashes"; + ++this.pointer; + } else { + this.parseError = true; + this.state = "relative"; + --this.pointer; + } + + return true; +}; + +URLStateMachine.prototype["parse path or authority"] = function parsePathOrAuthority(c) { + if (c === 47) { + this.state = "authority"; + } else { + this.state = "path"; + --this.pointer; + } + + return true; +}; + +URLStateMachine.prototype["parse relative"] = function parseRelative(c) { + this.url.scheme = this.base.scheme; + if (isNaN(c)) { + this.url.username = this.base.username; + this.url.password = this.base.password; + this.url.host = this.base.host; + this.url.port = this.base.port; + this.url.path = this.base.path.slice(); + this.url.query = this.base.query; + } else if (c === 47) { + this.state = "relative slash"; + } else if (c === 63) { + this.url.username = this.base.username; + this.url.password = this.base.password; + this.url.host = this.base.host; + this.url.port = this.base.port; + this.url.path = this.base.path.slice(); + this.url.query = ""; + this.state = "query"; + } else if (c === 35) { + this.url.username = this.base.username; + this.url.password = this.base.password; + this.url.host = this.base.host; + this.url.port = this.base.port; + this.url.path = this.base.path.slice(); + this.url.query = this.base.query; + this.url.fragment = ""; + this.state = "fragment"; + } else if (isSpecial(this.url) && c === 92) { + this.parseError = true; + this.state = "relative slash"; + } else { + this.url.username = this.base.username; + this.url.password = this.base.password; + this.url.host = this.base.host; + this.url.port = this.base.port; + this.url.path = this.base.path.slice(0, this.base.path.length - 1); + + this.state = "path"; + --this.pointer; + } + + return true; +}; + +URLStateMachine.prototype["parse relative slash"] = function parseRelativeSlash(c) { + if (isSpecial(this.url) && (c === 47 || c === 92)) { + if (c === 92) { + this.parseError = true; + } + this.state = "special authority ignore slashes"; + } else if (c === 47) { + this.state = "authority"; + } else { + this.url.username = this.base.username; + this.url.password = this.base.password; + this.url.host = this.base.host; + this.url.port = this.base.port; + this.state = "path"; + --this.pointer; + } + + return true; +}; + +URLStateMachine.prototype["parse special authority slashes"] = function parseSpecialAuthoritySlashes(c) { + if (c === 47 && this.input[this.pointer + 1] === 47) { + this.state = "special authority ignore slashes"; + ++this.pointer; + } else { + this.parseError = true; + this.state = "special authority ignore slashes"; + --this.pointer; + } + + return true; +}; + +URLStateMachine.prototype["parse special authority ignore slashes"] = function parseSpecialAuthorityIgnoreSlashes(c) { + if (c !== 47 && c !== 92) { + this.state = "authority"; + --this.pointer; + } else { + this.parseError = true; + } + + return true; +}; + +URLStateMachine.prototype["parse authority"] = function parseAuthority(c, cStr) { + if (c === 64) { + this.parseError = true; + if (this.atFlag) { + this.buffer = "%40" + this.buffer; + } + this.atFlag = true; + + // careful, this is based on buffer and has its own pointer (this.pointer != pointer) and inner chars + const len = countSymbols(this.buffer); + for (let pointer = 0; pointer < len; ++pointer) { + const codePoint = this.buffer.codePointAt(pointer); + + if (codePoint === 58 && !this.passwordTokenSeenFlag) { + this.passwordTokenSeenFlag = true; + continue; + } + const encodedCodePoints = percentEncodeChar(codePoint, isUserinfoPercentEncode); + if (this.passwordTokenSeenFlag) { + this.url.password += encodedCodePoints; + } else { + this.url.username += encodedCodePoints; + } + } + this.buffer = ""; + } else if (isNaN(c) || c === 47 || c === 63 || c === 35 || + (isSpecial(this.url) && c === 92)) { + if (this.atFlag && this.buffer === "") { + this.parseError = true; + return failure; + } + this.pointer -= countSymbols(this.buffer) + 1; + this.buffer = ""; + this.state = "host"; + } else { + this.buffer += cStr; + } + + return true; +}; + +URLStateMachine.prototype["parse hostname"] = +URLStateMachine.prototype["parse host"] = function parseHostName(c, cStr) { + if (this.stateOverride && this.url.scheme === "file") { + --this.pointer; + this.state = "file host"; + } else if (c === 58 && !this.arrFlag) { + if (this.buffer === "") { + this.parseError = true; + return failure; + } + + const host = parseHost(this.buffer, isSpecial(this.url)); + if (host === failure) { + return failure; + } + + this.url.host = host; + this.buffer = ""; + this.state = "port"; + if (this.stateOverride === "hostname") { + return false; + } + } else if (isNaN(c) || c === 47 || c === 63 || c === 35 || + (isSpecial(this.url) && c === 92)) { + --this.pointer; + if (isSpecial(this.url) && this.buffer === "") { + this.parseError = true; + return failure; + } else if (this.stateOverride && this.buffer === "" && + (includesCredentials(this.url) || this.url.port !== null)) { + this.parseError = true; + return false; + } + + const host = parseHost(this.buffer, isSpecial(this.url)); + if (host === failure) { + return failure; + } + + this.url.host = host; + this.buffer = ""; + this.state = "path start"; + if (this.stateOverride) { + return false; + } + } else { + if (c === 91) { + this.arrFlag = true; + } else if (c === 93) { + this.arrFlag = false; + } + this.buffer += cStr; + } + + return true; +}; + +URLStateMachine.prototype["parse port"] = function parsePort(c, cStr) { + if (isASCIIDigit(c)) { + this.buffer += cStr; + } else if (isNaN(c) || c === 47 || c === 63 || c === 35 || + (isSpecial(this.url) && c === 92) || + this.stateOverride) { + if (this.buffer !== "") { + const port = parseInt(this.buffer); + if (port > Math.pow(2, 16) - 1) { + this.parseError = true; + return failure; + } + this.url.port = port === defaultPort(this.url.scheme) ? null : port; + this.buffer = ""; + } + if (this.stateOverride) { + return false; + } + this.state = "path start"; + --this.pointer; + } else { + this.parseError = true; + return failure; + } + + return true; +}; + +const fileOtherwiseCodePoints = new Set([47, 92, 63, 35]); + +URLStateMachine.prototype["parse file"] = function parseFile(c) { + this.url.scheme = "file"; + + if (c === 47 || c === 92) { + if (c === 92) { + this.parseError = true; + } + this.state = "file slash"; + } else if (this.base !== null && this.base.scheme === "file") { + if (isNaN(c)) { + this.url.host = this.base.host; + this.url.path = this.base.path.slice(); + this.url.query = this.base.query; + } else if (c === 63) { + this.url.host = this.base.host; + this.url.path = this.base.path.slice(); + this.url.query = ""; + this.state = "query"; + } else if (c === 35) { + this.url.host = this.base.host; + this.url.path = this.base.path.slice(); + this.url.query = this.base.query; + this.url.fragment = ""; + this.state = "fragment"; + } else { + if (this.input.length - this.pointer - 1 === 0 || // remaining consists of 0 code points + !isWindowsDriveLetterCodePoints(c, this.input[this.pointer + 1]) || + (this.input.length - this.pointer - 1 >= 2 && // remaining has at least 2 code points + !fileOtherwiseCodePoints.has(this.input[this.pointer + 2]))) { + this.url.host = this.base.host; + this.url.path = this.base.path.slice(); + shortenPath(this.url); + } else { + this.parseError = true; + } + + this.state = "path"; + --this.pointer; + } + } else { + this.state = "path"; + --this.pointer; + } + + return true; +}; + +URLStateMachine.prototype["parse file slash"] = function parseFileSlash(c) { + if (c === 47 || c === 92) { + if (c === 92) { + this.parseError = true; + } + this.state = "file host"; + } else { + if (this.base !== null && this.base.scheme === "file") { + if (isNormalizedWindowsDriveLetterString(this.base.path[0])) { + this.url.path.push(this.base.path[0]); + } else { + this.url.host = this.base.host; + } + } + this.state = "path"; + --this.pointer; + } + + return true; +}; + +URLStateMachine.prototype["parse file host"] = function parseFileHost(c, cStr) { + if (isNaN(c) || c === 47 || c === 92 || c === 63 || c === 35) { + --this.pointer; + if (!this.stateOverride && isWindowsDriveLetterString(this.buffer)) { + this.parseError = true; + this.state = "path"; + } else if (this.buffer === "") { + this.url.host = ""; + if (this.stateOverride) { + return false; + } + this.state = "path start"; + } else { + let host = parseHost(this.buffer, isSpecial(this.url)); + if (host === failure) { + return failure; + } + if (host === "localhost") { + host = ""; + } + this.url.host = host; + + if (this.stateOverride) { + return false; + } + + this.buffer = ""; + this.state = "path start"; + } + } else { + this.buffer += cStr; + } + + return true; +}; + +URLStateMachine.prototype["parse path start"] = function parsePathStart(c) { + if (isSpecial(this.url)) { + if (c === 92) { + this.parseError = true; + } + this.state = "path"; + + if (c !== 47 && c !== 92) { + --this.pointer; + } + } else if (!this.stateOverride && c === 63) { + this.url.query = ""; + this.state = "query"; + } else if (!this.stateOverride && c === 35) { + this.url.fragment = ""; + this.state = "fragment"; + } else if (c !== undefined) { + this.state = "path"; + if (c !== 47) { + --this.pointer; + } + } + + return true; +}; + +URLStateMachine.prototype["parse path"] = function parsePath(c) { + if (isNaN(c) || c === 47 || (isSpecial(this.url) && c === 92) || + (!this.stateOverride && (c === 63 || c === 35))) { + if (isSpecial(this.url) && c === 92) { + this.parseError = true; + } + + if (isDoubleDot(this.buffer)) { + shortenPath(this.url); + if (c !== 47 && !(isSpecial(this.url) && c === 92)) { + this.url.path.push(""); + } + } else if (isSingleDot(this.buffer) && c !== 47 && + !(isSpecial(this.url) && c === 92)) { + this.url.path.push(""); + } else if (!isSingleDot(this.buffer)) { + if (this.url.scheme === "file" && this.url.path.length === 0 && isWindowsDriveLetterString(this.buffer)) { + if (this.url.host !== "" && this.url.host !== null) { + this.parseError = true; + this.url.host = ""; + } + this.buffer = this.buffer[0] + ":"; + } + this.url.path.push(this.buffer); + } + this.buffer = ""; + if (this.url.scheme === "file" && (c === undefined || c === 63 || c === 35)) { + while (this.url.path.length > 1 && this.url.path[0] === "") { + this.parseError = true; + this.url.path.shift(); + } + } + if (c === 63) { + this.url.query = ""; + this.state = "query"; + } + if (c === 35) { + this.url.fragment = ""; + this.state = "fragment"; + } + } else { + // TODO: If c is not a URL code point and not "%", parse error. + + if (c === 37 && + (!isASCIIHex(this.input[this.pointer + 1]) || + !isASCIIHex(this.input[this.pointer + 2]))) { + this.parseError = true; + } + + this.buffer += percentEncodeChar(c, isPathPercentEncode); + } + + return true; +}; + +URLStateMachine.prototype["parse cannot-be-a-base-URL path"] = function parseCannotBeABaseURLPath(c) { + if (c === 63) { + this.url.query = ""; + this.state = "query"; + } else if (c === 35) { + this.url.fragment = ""; + this.state = "fragment"; + } else { + // TODO: Add: not a URL code point + if (!isNaN(c) && c !== 37) { + this.parseError = true; + } + + if (c === 37 && + (!isASCIIHex(this.input[this.pointer + 1]) || + !isASCIIHex(this.input[this.pointer + 2]))) { + this.parseError = true; + } + + if (!isNaN(c)) { + this.url.path[0] = this.url.path[0] + percentEncodeChar(c, isC0ControlPercentEncode); + } + } + + return true; +}; + +URLStateMachine.prototype["parse query"] = function parseQuery(c, cStr) { + if (isNaN(c) || (!this.stateOverride && c === 35)) { + if (!isSpecial(this.url) || this.url.scheme === "ws" || this.url.scheme === "wss") { + this.encodingOverride = "utf-8"; + } + + const buffer = new Buffer(this.buffer); // TODO: Use encoding override instead + for (let i = 0; i < buffer.length; ++i) { + if (buffer[i] < 0x21 || buffer[i] > 0x7E || buffer[i] === 0x22 || buffer[i] === 0x23 || + buffer[i] === 0x3C || buffer[i] === 0x3E) { + this.url.query += percentEncode(buffer[i]); + } else { + this.url.query += String.fromCodePoint(buffer[i]); + } + } + + this.buffer = ""; + if (c === 35) { + this.url.fragment = ""; + this.state = "fragment"; + } + } else { + // TODO: If c is not a URL code point and not "%", parse error. + if (c === 37 && + (!isASCIIHex(this.input[this.pointer + 1]) || + !isASCIIHex(this.input[this.pointer + 2]))) { + this.parseError = true; + } + + this.buffer += cStr; + } + + return true; +}; + +URLStateMachine.prototype["parse fragment"] = function parseFragment(c) { + if (isNaN(c)) { // do nothing + } else if (c === 0x0) { + this.parseError = true; + } else { + // TODO: If c is not a URL code point and not "%", parse error. + if (c === 37 && + (!isASCIIHex(this.input[this.pointer + 1]) || + !isASCIIHex(this.input[this.pointer + 2]))) { + this.parseError = true; + } + + this.url.fragment += percentEncodeChar(c, isC0ControlPercentEncode); + } + + return true; +}; + +function serializeURL(url, excludeFragment) { + let output = url.scheme + ":"; + if (url.host !== null) { + output += "//"; + + if (url.username !== "" || url.password !== "") { + output += url.username; + if (url.password !== "") { + output += ":" + url.password; + } + output += "@"; + } + + output += serializeHost(url.host); + + if (url.port !== null) { + output += ":" + url.port; + } + } else if (url.host === null && url.scheme === "file") { + output += "//"; + } + + if (url.cannotBeABaseURL) { + output += url.path[0]; + } else { + for (const string of url.path) { + output += "/" + string; + } + } + + if (url.query !== null) { + output += "?" + url.query; + } + + if (!excludeFragment && url.fragment !== null) { + output += "#" + url.fragment; + } + + return output; +} + +function serializeOrigin(tuple) { + let result = tuple.scheme + "://"; + result += serializeHost(tuple.host); + + if (tuple.port !== null) { + result += ":" + tuple.port; + } + + return result; +} + +module.exports.serializeURL = serializeURL; + +module.exports.serializeURLOrigin = function (url) { + // https://url.spec.whatwg.org/#concept-url-origin + switch (url.scheme) { + case "blob": + try { + return module.exports.serializeURLOrigin(module.exports.parseURL(url.path[0])); + } catch (e) { + // serializing an opaque origin returns "null" + return "null"; + } + case "ftp": + case "gopher": + case "http": + case "https": + case "ws": + case "wss": + return serializeOrigin({ + scheme: url.scheme, + host: url.host, + port: url.port + }); + case "file": + // spec says "exercise to the reader", chrome says "file://" + return "file://"; + default: + // serializing an opaque origin returns "null" + return "null"; + } +}; + +module.exports.basicURLParse = function (input, options) { + if (options === undefined) { + options = {}; + } + + const usm = new URLStateMachine(input, options.baseURL, options.encodingOverride, options.url, options.stateOverride); + if (usm.failure) { + return "failure"; + } + + return usm.url; +}; + +module.exports.setTheUsername = function (url, username) { + url.username = ""; + const decoded = punycode.ucs2.decode(username); + for (let i = 0; i < decoded.length; ++i) { + url.username += percentEncodeChar(decoded[i], isUserinfoPercentEncode); + } +}; + +module.exports.setThePassword = function (url, password) { + url.password = ""; + const decoded = punycode.ucs2.decode(password); + for (let i = 0; i < decoded.length; ++i) { + url.password += percentEncodeChar(decoded[i], isUserinfoPercentEncode); + } +}; + +module.exports.serializeHost = serializeHost; + +module.exports.cannotHaveAUsernamePasswordPort = cannotHaveAUsernamePasswordPort; + +module.exports.serializeInteger = function (integer) { + return String(integer); +}; + +module.exports.parseURL = function (input, options) { + if (options === undefined) { + options = {}; + } + + // We don't handle blobs, so this just delegates: + return module.exports.basicURLParse(input, { baseURL: options.baseURL, encodingOverride: options.encodingOverride }); +}; diff --git a/sandbox/tgbot/node_modules/whatwg-url/lib/utils.js b/sandbox/tgbot/node_modules/whatwg-url/lib/utils.js new file mode 100644 index 0000000..a562009 --- /dev/null +++ b/sandbox/tgbot/node_modules/whatwg-url/lib/utils.js @@ -0,0 +1,20 @@ +"use strict"; + +module.exports.mixin = function mixin(target, source) { + const keys = Object.getOwnPropertyNames(source); + for (let i = 0; i < keys.length; ++i) { + Object.defineProperty(target, keys[i], Object.getOwnPropertyDescriptor(source, keys[i])); + } +}; + +module.exports.wrapperSymbol = Symbol("wrapper"); +module.exports.implSymbol = Symbol("impl"); + +module.exports.wrapperForImpl = function (impl) { + return impl[module.exports.wrapperSymbol]; +}; + +module.exports.implForWrapper = function (wrapper) { + return wrapper[module.exports.implSymbol]; +}; + diff --git a/sandbox/tgbot/node_modules/whatwg-url/package.json b/sandbox/tgbot/node_modules/whatwg-url/package.json new file mode 100644 index 0000000..fce35ae --- /dev/null +++ b/sandbox/tgbot/node_modules/whatwg-url/package.json @@ -0,0 +1,32 @@ +{ + "name": "whatwg-url", + "version": "5.0.0", + "description": "An implementation of the WHATWG URL Standard's URL API and parsing machinery", + "main": "lib/public-api.js", + "files": [ + "lib/" + ], + "author": "Sebastian Mayr ", + "license": "MIT", + "repository": "jsdom/whatwg-url", + "dependencies": { + "tr46": "~0.0.3", + "webidl-conversions": "^3.0.0" + }, + "devDependencies": { + "eslint": "^2.6.0", + "istanbul": "~0.4.3", + "mocha": "^2.2.4", + "recast": "~0.10.29", + "request": "^2.55.0", + "webidl2js": "^3.0.2" + }, + "scripts": { + "build": "node scripts/transform.js && node scripts/convert-idl.js", + "coverage": "istanbul cover node_modules/mocha/bin/_mocha", + "lint": "eslint .", + "prepublish": "npm run build", + "pretest": "node scripts/get-latest-platform-tests.js && npm run build", + "test": "mocha" + } +} diff --git a/sandbox/tgbot/package-lock.json b/sandbox/tgbot/package-lock.json new file mode 100644 index 0000000..c98cc72 --- /dev/null +++ b/sandbox/tgbot/package-lock.json @@ -0,0 +1,123 @@ +{ + "name": "tgbot", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "tgbot", + "version": "1.0.0", + "license": "ISC", + "dependencies": { + "grammy": "^1.40.0" + } + }, + "node_modules/@grammyjs/types": { + "version": "3.24.0", + "resolved": "https://registry.npmjs.org/@grammyjs/types/-/types-3.24.0.tgz", + "integrity": "sha512-qQIEs4lN5WqUdr4aT8MeU6UFpMbGYAvcvYSW1A4OO1PABGJQHz/KLON6qvpf+5RxaNDQBxiY2k2otIhg/AG7RQ==", + "license": "MIT" + }, + "node_modules/abort-controller": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz", + "integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==", + "license": "MIT", + "dependencies": { + "event-target-shim": "^5.0.0" + }, + "engines": { + "node": ">=6.5" + } + }, + "node_modules/debug": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", + "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/event-target-shim": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", + "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/grammy": { + "version": "1.40.0", + "resolved": "https://registry.npmjs.org/grammy/-/grammy-1.40.0.tgz", + "integrity": "sha512-ssuE7fc1AwqlUxHr931OCVW3fU+oFDjHZGgvIedPKXfTdjXvzP19xifvVGCnPtYVUig1Kz+gwxe4A9M5WdkT4Q==", + "license": "MIT", + "dependencies": { + "@grammyjs/types": "3.24.0", + "abort-controller": "^3.0.0", + "debug": "^4.4.3", + "node-fetch": "^2.7.0" + }, + "engines": { + "node": "^12.20.0 || >=14.13.1" + } + }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "license": "MIT" + }, + "node_modules/node-fetch": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", + "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", + "license": "MIT", + "dependencies": { + "whatwg-url": "^5.0.0" + }, + "engines": { + "node": "4.x || >=6.0.0" + }, + "peerDependencies": { + "encoding": "^0.1.0" + }, + "peerDependenciesMeta": { + "encoding": { + "optional": true + } + } + }, + "node_modules/tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", + "license": "MIT" + }, + "node_modules/webidl-conversions": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==", + "license": "BSD-2-Clause" + }, + "node_modules/whatwg-url": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", + "license": "MIT", + "dependencies": { + "tr46": "~0.0.3", + "webidl-conversions": "^3.0.0" + } + } + } +} diff --git a/sandbox/tgbot/package.json b/sandbox/tgbot/package.json new file mode 100644 index 0000000..9c64fc3 --- /dev/null +++ b/sandbox/tgbot/package.json @@ -0,0 +1,15 @@ +{ + "name": "tgbot", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [], + "author": "", + "license": "ISC", + "dependencies": { + "grammy": "^1.40.0" + } +}