Compare commits
14 Commits
a30936f120
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e04f9059ae | ||
|
|
002f9863b0 | ||
|
|
77c7cd09aa | ||
|
|
b66a74df06 | ||
|
|
b8db06cd21 | ||
|
|
7e889d8530 | ||
|
|
73ba559593 | ||
|
|
10cb24b7e5 | ||
|
|
20c318b3c1 | ||
|
|
8873e441c2 | ||
|
|
d72fd95dfd | ||
|
|
87eb4fb765 | ||
|
|
e2e15009e2 | ||
|
|
5017827af2 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1 +1,2 @@
|
|||||||
adolf/.env
|
adolf/.env
|
||||||
|
seafile/.env
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ This repository manages Docker Compose configurations for the **Agap** self-host
|
|||||||
| `immich-app/` | Immich (photo management) | 2283 | Main compose via root `docker-compose.yml` |
|
| `immich-app/` | Immich (photo management) | 2283 | Main compose via root `docker-compose.yml` |
|
||||||
| `gitea/` | Gitea (git hosting) + Postgres | 3000, 222 | Standalone compose |
|
| `gitea/` | Gitea (git hosting) + Postgres | 3000, 222 | Standalone compose |
|
||||||
| `openai/` | Open WebUI + Ollama (AI chat) | 3125 | Requires NVIDIA GPU |
|
| `openai/` | Open WebUI + Ollama (AI chat) | 3125 | Requires NVIDIA GPU |
|
||||||
|
| `vaultwarden/` | Vaultwarden (password manager) | 8041 | Backup script in `vaultwarden/backup.sh` |
|
||||||
|
|
||||||
## Common Commands
|
## Common Commands
|
||||||
|
|
||||||
@@ -90,6 +91,8 @@ When changes are made to infrastructure (services, config, setup), update the re
|
|||||||
| Home-Assistant | KVM-based Home Assistant setup |
|
| Home-Assistant | KVM-based Home Assistant setup |
|
||||||
| 3X-UI | VPN proxy panel |
|
| 3X-UI | VPN proxy panel |
|
||||||
| Gitea | Git hosting Docker service |
|
| Gitea | Git hosting Docker service |
|
||||||
|
| Vaultwarden | Password manager, CLI setup, backup |
|
||||||
|
| Seafile | File sync, document editing, OnlyOffice, WebDAV |
|
||||||
|
|
||||||
### Read Wiki Pages (API)
|
### Read Wiki Pages (API)
|
||||||
|
|
||||||
|
|||||||
122
Caddyfile
Normal file
122
Caddyfile
Normal file
@@ -0,0 +1,122 @@
|
|||||||
|
haos.alogins.net {
|
||||||
|
reverse_proxy http://192.168.1.141:8123 {
|
||||||
|
|
||||||
|
header_up X-Forwarded-For {remote_host}
|
||||||
|
header_up X-Forwarded-Proto {scheme}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
vi.alogins.net {
|
||||||
|
reverse_proxy localhost:2283
|
||||||
|
}
|
||||||
|
|
||||||
|
doc.alogins.net {
|
||||||
|
reverse_proxy localhost:11001
|
||||||
|
}
|
||||||
|
|
||||||
|
zb.alogins.net {
|
||||||
|
reverse_proxy localhost:81
|
||||||
|
}
|
||||||
|
|
||||||
|
wiki.alogins.net {
|
||||||
|
reverse_proxy localhost:8083 {
|
||||||
|
header_up Host {http.request.host}
|
||||||
|
header_up X-Forwarded-Proto {scheme}
|
||||||
|
header_up X-Real-IP {remote_host}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
nn.alogins.net {
|
||||||
|
reverse_proxy localhost:5678
|
||||||
|
}
|
||||||
|
|
||||||
|
git.alogins.net {
|
||||||
|
reverse_proxy localhost:3000
|
||||||
|
}
|
||||||
|
|
||||||
|
ds.alogins.net {
|
||||||
|
reverse_proxy localhost:3974
|
||||||
|
}
|
||||||
|
|
||||||
|
ai.alogins.net {
|
||||||
|
reverse_proxy localhost:3125
|
||||||
|
}
|
||||||
|
|
||||||
|
openpi.alogins.net {
|
||||||
|
root * /home/alvis/tmp/files/pi05_droid
|
||||||
|
file_server browse
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
vui3.alogins.net {
|
||||||
|
@xhttp {
|
||||||
|
path /VLSpdG9k/xht*
|
||||||
|
}
|
||||||
|
handle @xhttp {
|
||||||
|
reverse_proxy http://localhost:8445 {
|
||||||
|
flush_interval -1
|
||||||
|
header_up X-Real-IP {remote_host}
|
||||||
|
transport http {
|
||||||
|
read_timeout 0
|
||||||
|
write_timeout 0
|
||||||
|
dial_timeout 10s
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
reverse_proxy /gnYCNq4EbYukS5qtOe/* localhost:58959
|
||||||
|
respond 401
|
||||||
|
}
|
||||||
|
|
||||||
|
vui4.alogins.net {
|
||||||
|
reverse_proxy localhost:58959
|
||||||
|
}
|
||||||
|
|
||||||
|
ntfy.alogins.net {
|
||||||
|
reverse_proxy localhost:8840
|
||||||
|
}
|
||||||
|
|
||||||
|
docs.alogins.net {
|
||||||
|
reverse_proxy localhost:8078
|
||||||
|
}
|
||||||
|
|
||||||
|
office.alogins.net {
|
||||||
|
reverse_proxy localhost:6233
|
||||||
|
}
|
||||||
|
|
||||||
|
vw.alogins.net {
|
||||||
|
reverse_proxy localhost:8041
|
||||||
|
}
|
||||||
|
|
||||||
|
mtx.alogins.net {
|
||||||
|
handle /.well-known/matrix/client {
|
||||||
|
header Content-Type application/json
|
||||||
|
header Access-Control-Allow-Origin *
|
||||||
|
respond `{"m.homeserver":{"base_url":"https://mtx.alogins.net"},"org.matrix.msc4143.rtc_foci":[{"type":"livekit","livekit_service_url":"https://lkjwt.alogins.net"}]}`
|
||||||
|
}
|
||||||
|
handle /.well-known/matrix/server {
|
||||||
|
header Content-Type application/json
|
||||||
|
header Access-Control-Allow-Origin *
|
||||||
|
respond `{"m.server":"mtx.alogins.net:443"}`
|
||||||
|
}
|
||||||
|
handle /_matrix/client/unstable/org.matrix.msc4143/rtc/transports {
|
||||||
|
header Content-Type application/json
|
||||||
|
header Access-Control-Allow-Origin *
|
||||||
|
respond `{"foci":[{"type":"livekit","livekit_service_url":"https://lkjwt.alogins.net"}]}`
|
||||||
|
}
|
||||||
|
reverse_proxy localhost:8008
|
||||||
|
}
|
||||||
|
|
||||||
|
lkjwt.alogins.net {
|
||||||
|
reverse_proxy localhost:8009
|
||||||
|
}
|
||||||
|
|
||||||
|
lk.alogins.net {
|
||||||
|
reverse_proxy localhost:7880
|
||||||
|
}
|
||||||
|
|
||||||
|
localhost:8042 {
|
||||||
|
reverse_proxy localhost:8041
|
||||||
|
tls internal
|
||||||
|
}
|
||||||
@@ -1,118 +0,0 @@
|
|||||||
# Adolf
|
|
||||||
|
|
||||||
Autonomous personal assistant with a multi-channel gateway. Three-tier model routing with GPU VRAM management.
|
|
||||||
|
|
||||||
## Architecture
|
|
||||||
|
|
||||||
```
|
|
||||||
┌─────────────────────────────────────────────────────┐
|
|
||||||
│ 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-<chat_id>` | Grammy long-poll → POST /message | channels.py → POST grammy:3001/send |
|
|
||||||
| CLI | `cli-<user>` | POST /message directly | GET /reply/{id} SSE stream |
|
|
||||||
| Voice | `voice-<device>` | (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 | 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 |
|
|
||||||
|
|
||||||
**`/think` prefix**: forces complex tier, stripped before sending to agent.
|
|
||||||
|
|
||||||
## VRAM Management
|
|
||||||
|
|
||||||
GTX 1070 — 8 GB. Ollama must be restarted if CUDA init fails (model loads on CPU).
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
## Session ID Convention
|
|
||||||
|
|
||||||
- Telegram: `tg-<chat_id>` (e.g. `tg-346967270`)
|
|
||||||
- CLI: `cli-<username>` (e.g. `cli-alvis`)
|
|
||||||
|
|
||||||
Conversation history is keyed by session_id (5-turn buffer).
|
|
||||||
|
|
||||||
## Files
|
|
||||||
|
|
||||||
```
|
|
||||||
adolf/
|
|
||||||
├── docker-compose.yml Services: deepagents, openmemory, grammy
|
|
||||||
├── Dockerfile deepagents container (Python 3.12)
|
|
||||||
├── 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
|
|
||||||
├── 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
|
|
||||||
│ └── Dockerfile
|
|
||||||
└── grammy/
|
|
||||||
├── 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 |
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
FROM python:3.12-slim
|
|
||||||
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
RUN pip install --no-cache-dir deepagents langchain-ollama langgraph \
|
|
||||||
fastapi uvicorn langchain-mcp-adapters langchain-community httpx
|
|
||||||
|
|
||||||
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"]
|
|
||||||
386
adolf/agent.py
386
adolf/agent.py
@@ -1,386 +0,0 @@
|
|||||||
import asyncio
|
|
||||||
import os
|
|
||||||
import time
|
|
||||||
from contextlib import asynccontextmanager
|
|
||||||
|
|
||||||
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
|
|
||||||
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")
|
|
||||||
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")
|
|
||||||
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. "
|
|
||||||
"Use web_search for questions about current events or facts you don't know. "
|
|
||||||
"Reply concisely."
|
|
||||||
)
|
|
||||||
|
|
||||||
COMPLEX_SYSTEM_PROMPT = (
|
|
||||||
"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
|
|
||||||
complex_agent = None
|
|
||||||
router: Router = None
|
|
||||||
vram_manager: VRAMManager = None
|
|
||||||
mcp_client = None
|
|
||||||
|
|
||||||
# GPU mutex: one LLM inference at a time
|
|
||||||
_reply_semaphore = asyncio.Semaphore(1)
|
|
||||||
|
|
||||||
|
|
||||||
@asynccontextmanager
|
|
||||||
async def lifespan(app: FastAPI):
|
|
||||||
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,
|
|
||||||
)
|
|
||||||
medium_model = ChatOllama(
|
|
||||||
model=MEDIUM_MODEL, base_url=OLLAMA_BASE_URL, think=False, num_ctx=8192
|
|
||||||
)
|
|
||||||
complex_model = ChatOllama(
|
|
||||||
model=COMPLEX_MODEL, base_url=OLLAMA_BASE_URL, think=True, num_ctx=16384
|
|
||||||
)
|
|
||||||
|
|
||||||
vram_manager = VRAMManager(base_url=OLLAMA_BASE_URL)
|
|
||||||
router = Router(model=router_model)
|
|
||||||
|
|
||||||
mcp_connections = {
|
|
||||||
"openmemory": {"transport": "sse", "url": f"{OPENMEMORY_URL}/sse"},
|
|
||||||
}
|
|
||||||
mcp_client = MultiServerMCPClient(mcp_connections)
|
|
||||||
for attempt in range(12):
|
|
||||||
try:
|
|
||||||
mcp_tools = await mcp_client.get_tools()
|
|
||||||
break
|
|
||||||
except Exception as e:
|
|
||||||
if attempt == 11:
|
|
||||||
raise
|
|
||||||
print(f"[agent] MCP not ready (attempt {attempt + 1}/12): {e}. Retrying in 5s...")
|
|
||||||
await asyncio.sleep(5)
|
|
||||||
|
|
||||||
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=_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."
|
|
||||||
),
|
|
||||||
))
|
|
||||||
|
|
||||||
medium_agent = build_medium_agent(
|
|
||||||
model=medium_model,
|
|
||||||
agent_tools=agent_tools,
|
|
||||||
system_prompt=MEDIUM_SYSTEM_PROMPT,
|
|
||||||
)
|
|
||||||
complex_agent = build_complex_agent(
|
|
||||||
model=complex_model,
|
|
||||||
agent_tools=agent_tools,
|
|
||||||
system_prompt=COMPLEX_SYSTEM_PROMPT.format(user_id="{user_id}"),
|
|
||||||
)
|
|
||||||
|
|
||||||
print(
|
|
||||||
f"[agent] three-tier: router={ROUTER_MODEL} | medium={MEDIUM_MODEL} | complex={COMPLEX_MODEL}",
|
|
||||||
flush=True,
|
|
||||||
)
|
|
||||||
print(f"[agent] agent tools: {[t.name for t in agent_tools]}", flush=True)
|
|
||||||
|
|
||||||
yield
|
|
||||||
|
|
||||||
medium_agent = None
|
|
||||||
complex_agent = None
|
|
||||||
router = None
|
|
||||||
vram_manager = None
|
|
||||||
mcp_client = 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
|
|
||||||
|
|
||||||
|
|
||||||
# ── helpers ────────────────────────────────────────────────────────────────────
|
|
||||||
|
|
||||||
def _extract_final_text(result) -> str | None:
|
|
||||||
msgs = result.get("messages", [])
|
|
||||||
for m in reversed(msgs):
|
|
||||||
if type(m).__name__ == "AIMessage" and getattr(m, "content", ""):
|
|
||||||
return m.content
|
|
||||||
if isinstance(result, dict) and result.get("output"):
|
|
||||||
return result["output"]
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
def _log_messages(result):
|
|
||||||
msgs = result.get("messages", [])
|
|
||||||
for m in msgs:
|
|
||||||
role = type(m).__name__
|
|
||||||
content = getattr(m, "content", "")
|
|
||||||
tool_calls = getattr(m, "tool_calls", [])
|
|
||||||
if content:
|
|
||||||
print(f"[agent] {role}: {str(content)[:150]}", flush=True)
|
|
||||||
for tc in tool_calls:
|
|
||||||
print(f"[agent] {role} → {tc['name']}({tc['args']})", 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)
|
|
||||||
|
|
||||||
force_complex = False
|
|
||||||
clean_message = message
|
|
||||||
if message.startswith("/think "):
|
|
||||||
force_complex = True
|
|
||||||
clean_message = message[len("/think "):]
|
|
||||||
print("[agent] /think prefix → force_complex=True", flush=True)
|
|
||||||
|
|
||||||
async with _reply_semaphore:
|
|
||||||
t0 = time.monotonic()
|
|
||||||
history = _conversation_buffers.get(session_id, [])
|
|
||||||
print(f"[agent] running: {clean_message[:80]!r}", flush=True)
|
|
||||||
|
|
||||||
tier, light_reply = await router.route(clean_message, history, force_complex)
|
|
||||||
print(f"[agent] tier={tier} message={clean_message[:60]!r}", flush=True)
|
|
||||||
|
|
||||||
final_text = None
|
|
||||||
try:
|
|
||||||
if tier == "light":
|
|
||||||
final_text = light_reply
|
|
||||||
llm_elapsed = time.monotonic() - t0
|
|
||||||
print(f"[agent] light path: answered by router", flush=True)
|
|
||||||
|
|
||||||
elif tier == "medium":
|
|
||||||
system_prompt = MEDIUM_SYSTEM_PROMPT
|
|
||||||
result = await medium_agent.ainvoke({
|
|
||||||
"messages": [
|
|
||||||
{"role": "system", "content": system_prompt},
|
|
||||||
*history,
|
|
||||||
{"role": "user", "content": clean_message},
|
|
||||||
]
|
|
||||||
})
|
|
||||||
llm_elapsed = time.monotonic() - t0
|
|
||||||
_log_messages(result)
|
|
||||||
final_text = _extract_final_text(result)
|
|
||||||
|
|
||||||
else: # complex
|
|
||||||
ok = await vram_manager.enter_complex_mode()
|
|
||||||
if not ok:
|
|
||||||
print("[agent] complex→medium fallback (eviction timeout)", flush=True)
|
|
||||||
tier = "medium"
|
|
||||||
result = await medium_agent.ainvoke({
|
|
||||||
"messages": [
|
|
||||||
{"role": "system", "content": MEDIUM_SYSTEM_PROMPT},
|
|
||||||
*history,
|
|
||||||
{"role": "user", "content": clean_message},
|
|
||||||
]
|
|
||||||
})
|
|
||||||
else:
|
|
||||||
system_prompt = COMPLEX_SYSTEM_PROMPT.format(user_id=session_id)
|
|
||||||
result = await complex_agent.ainvoke({
|
|
||||||
"messages": [
|
|
||||||
{"role": "system", "content": system_prompt},
|
|
||||||
*history,
|
|
||||||
{"role": "user", "content": clean_message},
|
|
||||||
]
|
|
||||||
})
|
|
||||||
asyncio.create_task(vram_manager.exit_complex_mode())
|
|
||||||
|
|
||||||
llm_elapsed = time.monotonic() - t0
|
|
||||||
_log_messages(result)
|
|
||||||
final_text = _extract_final_text(result)
|
|
||||||
|
|
||||||
except Exception as e:
|
|
||||||
import traceback
|
|
||||||
llm_elapsed = time.monotonic() - t0
|
|
||||||
print(f"[agent] error after {llm_elapsed:.1f}s for chat {session_id}: {e}", flush=True)
|
|
||||||
traceback.print_exc()
|
|
||||||
|
|
||||||
# Deliver reply through the originating channel
|
|
||||||
if final_text:
|
|
||||||
t1 = time.monotonic()
|
|
||||||
await channels.deliver(session_id, channel, final_text)
|
|
||||||
send_elapsed = time.monotonic() - t1
|
|
||||||
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,
|
|
||||||
)
|
|
||||||
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(session_id, [])
|
|
||||||
buf.append({"role": "user", "content": clean_message})
|
|
||||||
buf.append({"role": "assistant", "content": final_text})
|
|
||||||
_conversation_buffers[session_id] = buf[-(MAX_HISTORY_TURNS * 2):]
|
|
||||||
|
|
||||||
|
|
||||||
# ── 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-<chat_id> session for backward compatibility."""
|
|
||||||
if medium_agent is None:
|
|
||||||
return JSONResponse(status_code=503, content={"error": "Agent not ready"})
|
|
||||||
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}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
from deepagents import create_deep_agent
|
|
||||||
|
|
||||||
|
|
||||||
def build_medium_agent(model, agent_tools: list, system_prompt: str):
|
|
||||||
"""Medium agent: create_deep_agent with TodoList planning, no subagents."""
|
|
||||||
return create_deep_agent(
|
|
||||||
model=model,
|
|
||||||
tools=agent_tools,
|
|
||||||
system_prompt=system_prompt,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def build_complex_agent(model, agent_tools: list, system_prompt: str):
|
|
||||||
"""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,
|
|
||||||
)
|
|
||||||
@@ -1,75 +0,0 @@
|
|||||||
"""
|
|
||||||
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)
|
|
||||||
80
adolf/cli.py
80
adolf/cli.py
@@ -1,80 +0,0 @@
|
|||||||
#!/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()
|
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
services:
|
|
||||||
deepagents:
|
|
||||||
build: .
|
|
||||||
container_name: deepagents
|
|
||||||
ports:
|
|
||||||
- "8000:8000"
|
|
||||||
environment:
|
|
||||||
- PYTHONUNBUFFERED=1
|
|
||||||
- OLLAMA_BASE_URL=http://host.docker.internal:11436
|
|
||||||
- DEEPAGENTS_MODEL=qwen3:4b
|
|
||||||
- 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:
|
|
||||||
build: ./openmemory
|
|
||||||
container_name: openmemory
|
|
||||||
ports:
|
|
||||||
- "8765:8765"
|
|
||||||
environment:
|
|
||||||
# Extraction LLM (qwen2.5:1.5b) runs on GPU after reply — fast 2-5s extraction
|
|
||||||
- OLLAMA_GPU_URL=http://host.docker.internal:11436
|
|
||||||
# Embedding (nomic-embed-text) runs on CPU — fast enough for search (50-150ms)
|
|
||||||
- OLLAMA_CPU_URL=http://host.docker.internal:11435
|
|
||||||
extra_hosts:
|
|
||||||
- "host.docker.internal:host-gateway"
|
|
||||||
restart: unless-stopped
|
|
||||||
|
|
||||||
grammy:
|
|
||||||
build: ./grammy
|
|
||||||
container_name: grammy
|
|
||||||
ports:
|
|
||||||
- "3001:3001"
|
|
||||||
environment:
|
|
||||||
- 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
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
FROM node:22-alpine
|
|
||||||
WORKDIR /app
|
|
||||||
COPY package.json .
|
|
||||||
RUN npm install
|
|
||||||
COPY bot.mjs .
|
|
||||||
CMD ["node", "bot.mjs"]
|
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
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`),
|
|
||||||
});
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
{
|
|
||||||
"type": "module",
|
|
||||||
"dependencies": {
|
|
||||||
"grammy": "^1.36.0",
|
|
||||||
"express": "^4.21.0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
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}")
|
|
||||||
@@ -1,247 +0,0 @@
|
|||||||
# 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
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
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"]
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
mem0ai
|
|
||||||
ollama
|
|
||||||
fastapi
|
|
||||||
uvicorn
|
|
||||||
mcp[cli]
|
|
||||||
qdrant-client
|
|
||||||
@@ -1,155 +0,0 @@
|
|||||||
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": "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, # CPU: 50-150ms per query, no GPU needed
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"vector_store": {
|
|
||||||
"provider": "qdrant",
|
|
||||||
"config": {
|
|
||||||
"collection_name": "adolf_memories",
|
|
||||||
"embedding_model_dims": 768,
|
|
||||||
"host": QDRANT_HOST,
|
|
||||||
"port": QDRANT_PORT,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"custom_fact_extraction_prompt": EXTRACTION_PROMPT,
|
|
||||||
"custom_update_memory_prompt": UPDATE_PROMPT,
|
|
||||||
}
|
|
||||||
|
|
||||||
memory = Memory.from_config(config)
|
|
||||||
|
|
||||||
mcp = FastMCP("openmemory", host="0.0.0.0", port=8765)
|
|
||||||
|
|
||||||
|
|
||||||
@mcp.tool()
|
|
||||||
def add_memory(text: str, user_id: str = "default") -> str:
|
|
||||||
"""Store a memory for a user."""
|
|
||||||
result = memory.add(text, user_id=user_id)
|
|
||||||
# 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, 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", 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__":
|
|
||||||
mcp.run(transport="sse")
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
# Potential Directions
|
|
||||||
|
|
||||||
## CPU Extraction Model Candidates (mem0 / openmemory)
|
|
||||||
|
|
||||||
Replacing `gemma3:1b` — documented JSON/structured output failures make it unreliable for mem0's extraction pipeline.
|
|
||||||
|
|
||||||
| Rank | Model | Size | CPU speed | JSON reliability | Notes |
|
|
||||||
|------|-------|------|-----------|-----------------|-------|
|
|
||||||
| 1 | `qwen2.5:1.5b` | ~934 MB | 25–40 tok/s | Excellent | Best fit: fast + structured output, 18T token training |
|
|
||||||
| 2 | `qwen2.5:3b` | ~1.9 GB | 15–25 tok/s | Excellent | Quality upgrade, same family |
|
|
||||||
| 3 | `llama3.2:3b` | ~2 GB | 15–25 tok/s | Good | Highest IFEval score (77.4) in class |
|
|
||||||
| 4 | `smollm2:1.7b` | ~1.1 GB | 25–35 tok/s | Moderate | Use temp=0; NuExtract-1.5-smol is fine-tuned variant |
|
|
||||||
| 5 | `phi4-mini` | ~2.5 GB | 10–17 tok/s | Good | Function calling support, borderline CPU speed |
|
|
||||||
@@ -1,287 +0,0 @@
|
|||||||
# 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
|
|
||||||
`<think>...</think>` 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 `<think>...</think>` 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
|
|
||||||
140
adolf/router.py
140
adolf/router.py
@@ -1,140 +0,0 @@
|
|||||||
import re
|
|
||||||
from typing import Optional
|
|
||||||
from langchain_core.messages import SystemMessage, HumanMessage
|
|
||||||
|
|
||||||
# ── Regex pre-classifier ──────────────────────────────────────────────────────
|
|
||||||
# Catches obvious light-tier patterns before calling the LLM.
|
|
||||||
# Keyed by regex → compiled pattern.
|
|
||||||
_LIGHT_PATTERNS = re.compile(
|
|
||||||
r"^("
|
|
||||||
# Greetings / farewells
|
|
||||||
r"hi|hello|hey|yo|sup|howdy|good morning|good evening|good night|good afternoon"
|
|
||||||
r"|bye|goodbye|see you|cya|later|ttyl"
|
|
||||||
# Acknowledgements / small talk
|
|
||||||
r"|thanks?|thank you|thx|ty|ok|okay|k|cool|great|awesome|perfect|sounds good|got it|nice|sure"
|
|
||||||
r"|how are you|how are you\?|how are you doing(\s+today)?[?!.]*"
|
|
||||||
r"|what.?s up"
|
|
||||||
# Calendar facts: "what day comes after X?" / "what comes after X?"
|
|
||||||
r"|what\s+day\s+(comes\s+after|follows|is\s+after)\s+\w+[?!.]*"
|
|
||||||
r"|what\s+comes\s+after\s+\w+[?!.]*"
|
|
||||||
# Acronym expansions: "what does X stand for?"
|
|
||||||
r"|what\s+does\s+\w+\s+stand\s+for[?!.]*"
|
|
||||||
r")[\s!.?]*$",
|
|
||||||
re.IGNORECASE,
|
|
||||||
)
|
|
||||||
|
|
||||||
# ── LLM classification prompt ─────────────────────────────────────────────────
|
|
||||||
CLASSIFY_PROMPT = """Classify the message. Output ONLY one word: light, medium, or complex.
|
|
||||||
|
|
||||||
LIGHT = answerable from general knowledge, no internet needed:
|
|
||||||
what is 2+2 / what is the capital of France / name the three primary colors
|
|
||||||
tell me a short joke / is the sky blue / is water wet
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
Message: {message}
|
|
||||||
Output (one word only — light, medium, or complex):"""
|
|
||||||
|
|
||||||
LIGHT_REPLY_PROMPT = """You are a helpful Telegram assistant. Answer briefly and naturally (1-3 sentences). Be friendly."""
|
|
||||||
|
|
||||||
|
|
||||||
def _format_history(history: list[dict]) -> str:
|
|
||||||
if not history:
|
|
||||||
return "(none)"
|
|
||||||
lines = []
|
|
||||||
for msg in history:
|
|
||||||
role = msg.get("role", "?")
|
|
||||||
content = str(msg.get("content", ""))[:200]
|
|
||||||
lines.append(f"{role}: {content}")
|
|
||||||
return "\n".join(lines)
|
|
||||||
|
|
||||||
|
|
||||||
def _parse_tier(text: str) -> str:
|
|
||||||
"""Extract tier from raw model output. Default to medium."""
|
|
||||||
t = text.strip().lower()
|
|
||||||
snippet = t[:60]
|
|
||||||
if "complex" in snippet:
|
|
||||||
return "complex"
|
|
||||||
if "medium" in snippet:
|
|
||||||
return "medium"
|
|
||||||
if "light" in snippet:
|
|
||||||
return "light"
|
|
||||||
# Model invented a descriptive category (e.g. "simplefact", "trivial", "basic") →
|
|
||||||
# treat as light since it recognised the question doesn't need tools
|
|
||||||
if any(w in snippet for w in ("simple", "fact", "trivial", "basic", "easy", "general")):
|
|
||||||
return "light"
|
|
||||||
return "medium" # safe default
|
|
||||||
|
|
||||||
|
|
||||||
class Router:
|
|
||||||
def __init__(self, model):
|
|
||||||
self.model = model
|
|
||||||
|
|
||||||
async def route(
|
|
||||||
self,
|
|
||||||
message: str,
|
|
||||||
history: list[dict],
|
|
||||||
force_complex: bool = False,
|
|
||||||
) -> tuple[str, Optional[str]]:
|
|
||||||
"""
|
|
||||||
Returns (tier, reply_or_None).
|
|
||||||
For light tier: also generates the reply with a second call.
|
|
||||||
For medium/complex: reply is None.
|
|
||||||
"""
|
|
||||||
if force_complex:
|
|
||||||
return "complex", None
|
|
||||||
|
|
||||||
# Step 0: regex pre-classification for obvious light patterns
|
|
||||||
if _LIGHT_PATTERNS.match(message.strip()):
|
|
||||||
print(f"[router] regex→light", flush=True)
|
|
||||||
return await self._generate_light_reply(message, history)
|
|
||||||
|
|
||||||
# Step 1: LLM classification with raw text output
|
|
||||||
try:
|
|
||||||
classify_response = await self.model.ainvoke([
|
|
||||||
HumanMessage(content=CLASSIFY_PROMPT.format(message=message)),
|
|
||||||
])
|
|
||||||
raw = classify_response.content or ""
|
|
||||||
raw = re.sub(r"<think>.*?</think>", "", raw, flags=re.DOTALL).strip()
|
|
||||||
tier = _parse_tier(raw)
|
|
||||||
|
|
||||||
if tier == "complex" and not message.startswith("/think"):
|
|
||||||
tier = "medium"
|
|
||||||
|
|
||||||
print(f"[router] raw={raw[:30]!r} → tier={tier}", flush=True)
|
|
||||||
except Exception as e:
|
|
||||||
print(f"[router] classify error, defaulting to medium: {e}", flush=True)
|
|
||||||
return "medium", None
|
|
||||||
|
|
||||||
if tier != "light":
|
|
||||||
return tier, None
|
|
||||||
|
|
||||||
return await self._generate_light_reply(message, history)
|
|
||||||
|
|
||||||
async def _generate_light_reply(
|
|
||||||
self, message: str, history: list[dict]
|
|
||||||
) -> tuple[str, Optional[str]]:
|
|
||||||
"""Generate a short reply using the router model for light-tier messages."""
|
|
||||||
history_text = _format_history(history)
|
|
||||||
context = f"\nConversation history:\n{history_text}" if history else ""
|
|
||||||
try:
|
|
||||||
reply_response = await self.model.ainvoke([
|
|
||||||
SystemMessage(content=LIGHT_REPLY_PROMPT + context),
|
|
||||||
HumanMessage(content=message),
|
|
||||||
])
|
|
||||||
reply_text = reply_response.content or ""
|
|
||||||
reply_text = re.sub(r"<think>.*?</think>", "", reply_text, flags=re.DOTALL).strip()
|
|
||||||
if not reply_text:
|
|
||||||
print("[router] light reply empty, falling back to medium", flush=True)
|
|
||||||
return "medium", None
|
|
||||||
print(f"[router] light reply: {len(reply_text)} chars", flush=True)
|
|
||||||
return "light", reply_text
|
|
||||||
except Exception as e:
|
|
||||||
print(f"[router] light reply error, falling back to medium: {e}", flush=True)
|
|
||||||
return "medium", None
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,71 +0,0 @@
|
|||||||
import asyncio
|
|
||||||
import os
|
|
||||||
import httpx
|
|
||||||
|
|
||||||
OLLAMA_BASE_URL = os.getenv("OLLAMA_BASE_URL", "http://localhost:11434")
|
|
||||||
|
|
||||||
|
|
||||||
class VRAMManager:
|
|
||||||
MEDIUM_MODELS = ["qwen3:4b", "qwen2.5:1.5b"]
|
|
||||||
COMPLEX_MODEL = "qwen3:8b"
|
|
||||||
|
|
||||||
def __init__(self, base_url: str = OLLAMA_BASE_URL):
|
|
||||||
self.base_url = base_url
|
|
||||||
|
|
||||||
async def enter_complex_mode(self) -> bool:
|
|
||||||
"""Flush medium models before loading 8b. Returns False if eviction timed out."""
|
|
||||||
print("[vram] enter_complex_mode: flushing medium models", flush=True)
|
|
||||||
await asyncio.gather(*[self._flush(m) for m in self.MEDIUM_MODELS])
|
|
||||||
ok = await self._poll_evicted(self.MEDIUM_MODELS, timeout=15)
|
|
||||||
if ok:
|
|
||||||
print("[vram] enter_complex_mode: eviction confirmed, loading qwen3:8b", flush=True)
|
|
||||||
else:
|
|
||||||
print("[vram] enter_complex_mode: eviction timeout — falling back to medium", flush=True)
|
|
||||||
return ok
|
|
||||||
|
|
||||||
async def exit_complex_mode(self):
|
|
||||||
"""Flush 8b and pre-warm medium models. Run as background task after complex reply."""
|
|
||||||
print("[vram] exit_complex_mode: flushing qwen3:8b", flush=True)
|
|
||||||
await self._flush(self.COMPLEX_MODEL)
|
|
||||||
print("[vram] exit_complex_mode: pre-warming medium models", flush=True)
|
|
||||||
await asyncio.gather(*[self._prewarm(m) for m in self.MEDIUM_MODELS])
|
|
||||||
print("[vram] exit_complex_mode: done", flush=True)
|
|
||||||
|
|
||||||
async def _flush(self, model: str):
|
|
||||||
"""Send keep_alive=0 to force immediate unload from VRAM."""
|
|
||||||
try:
|
|
||||||
async with httpx.AsyncClient(timeout=10.0) as client:
|
|
||||||
await client.post(
|
|
||||||
f"{self.base_url}/api/generate",
|
|
||||||
json={"model": model, "prompt": "", "keep_alive": 0},
|
|
||||||
)
|
|
||||||
except Exception as e:
|
|
||||||
print(f"[vram] flush {model} error: {e}", flush=True)
|
|
||||||
|
|
||||||
async def _poll_evicted(self, models: list[str], timeout: float) -> bool:
|
|
||||||
"""Poll /api/ps until none of the given models appear (or timeout)."""
|
|
||||||
deadline = asyncio.get_event_loop().time() + timeout
|
|
||||||
while asyncio.get_event_loop().time() < deadline:
|
|
||||||
try:
|
|
||||||
async with httpx.AsyncClient(timeout=5.0) as client:
|
|
||||||
resp = await client.get(f"{self.base_url}/api/ps")
|
|
||||||
data = resp.json()
|
|
||||||
loaded = {m.get("name", "") for m in data.get("models", [])}
|
|
||||||
if not any(m in loaded for m in models):
|
|
||||||
return True
|
|
||||||
except Exception as e:
|
|
||||||
print(f"[vram] poll_evicted error: {e}", flush=True)
|
|
||||||
await asyncio.sleep(0.5)
|
|
||||||
return False
|
|
||||||
|
|
||||||
async def _prewarm(self, model: str):
|
|
||||||
"""Load model into VRAM with keep_alive=300 (5 min)."""
|
|
||||||
try:
|
|
||||||
async with httpx.AsyncClient(timeout=60.0) as client:
|
|
||||||
await client.post(
|
|
||||||
f"{self.base_url}/api/generate",
|
|
||||||
json={"model": model, "prompt": "", "keep_alive": 300},
|
|
||||||
)
|
|
||||||
print(f"[vram] pre-warmed {model}", flush=True)
|
|
||||||
except Exception as e:
|
|
||||||
print(f"[vram] prewarm {model} error: {e}", flush=True)
|
|
||||||
@@ -1,278 +0,0 @@
|
|||||||
#!/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()
|
|
||||||
30
immich-app/backup.sh
Executable file
30
immich-app/backup.sh
Executable file
@@ -0,0 +1,30 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
BACKUP_DIR=/mnt/backups/media
|
||||||
|
DB_BACKUP_DIR="$BACKUP_DIR/backups"
|
||||||
|
LOG="$BACKUP_DIR/backup.log"
|
||||||
|
RETAIN_DAYS=14
|
||||||
|
|
||||||
|
mkdir -p "$DB_BACKUP_DIR"
|
||||||
|
|
||||||
|
echo "[$(date)] Starting Immich backup" >> "$LOG"
|
||||||
|
|
||||||
|
# 1. Database dump (must come before file sync)
|
||||||
|
DUMP_FILE="$DB_BACKUP_DIR/immich-db-$(date +%Y%m%dT%H%M%S).sql.gz"
|
||||||
|
docker exec immich_postgres pg_dump --clean --if-exists \
|
||||||
|
--dbname=immich --username=postgres | gzip > "$DUMP_FILE"
|
||||||
|
echo "[$(date)] DB dump: $DUMP_FILE" >> "$LOG"
|
||||||
|
|
||||||
|
# 2. Rsync critical asset folders (skip thumbs and encoded-video — regeneratable)
|
||||||
|
for DIR in library upload profile; do
|
||||||
|
rsync -a --delete /mnt/media/upload/$DIR/ "$BACKUP_DIR/$DIR/" >> "$LOG" 2>&1
|
||||||
|
echo "[$(date)] Synced $DIR" >> "$LOG"
|
||||||
|
done
|
||||||
|
|
||||||
|
# 3. Remove old DB dumps
|
||||||
|
find "$DB_BACKUP_DIR" -name "immich-db-*.sql.gz" -mtime +$RETAIN_DAYS -delete
|
||||||
|
echo "[$(date)] Cleaned dumps older than ${RETAIN_DAYS}d" >> "$LOG"
|
||||||
|
|
||||||
|
touch "$BACKUP_DIR/.last_sync"
|
||||||
|
echo "[$(date)] Immich backup complete" >> "$LOG"
|
||||||
7
matrix/.env
Normal file
7
matrix/.env
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
SYNAPSE_DATA=./data/synapse
|
||||||
|
POSTGRES_DATA=./data/postgres
|
||||||
|
POSTGRES_USER=synapse
|
||||||
|
POSTGRES_PASSWORD=OimW4JUSXhZBCtLHE1kFnZ7cWVbESsxynapnJ+PSw/4=
|
||||||
|
POSTGRES_DB=synapse
|
||||||
|
LIVEKIT_KEY=devkey
|
||||||
|
LIVEKIT_SECRET=ef3ef4b903ca8469b09b2dd7ab6af529c4d2f3c95668f53832fc351cf67777a9
|
||||||
1
matrix/.gitignore
vendored
Normal file
1
matrix/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
data/
|
||||||
105
matrix/README.md
Normal file
105
matrix/README.md
Normal file
@@ -0,0 +1,105 @@
|
|||||||
|
# Matrix Home Server
|
||||||
|
|
||||||
|
Self-hosted Matrix homeserver running on `mtx.alogins.net`.
|
||||||
|
|
||||||
|
## Stack
|
||||||
|
|
||||||
|
| Service | Purpose |
|
||||||
|
|---------|---------|
|
||||||
|
| Synapse | Matrix homeserver |
|
||||||
|
| PostgreSQL | Synapse database |
|
||||||
|
| LiveKit | MatrixRTC media server (calls) |
|
||||||
|
| lk-jwt-service | LiveKit JWT auth for Matrix users |
|
||||||
|
| coturn | TURN/STUN server (ICE fallback) |
|
||||||
|
|
||||||
|
## Clients
|
||||||
|
|
||||||
|
- **Element X** (Android/iOS) — recommended, full call support
|
||||||
|
- **FluffyChat** — messaging only, calls not supported
|
||||||
|
|
||||||
|
Connect clients to: `https://mtx.alogins.net`
|
||||||
|
|
||||||
|
## Users
|
||||||
|
|
||||||
|
| Username | Admin |
|
||||||
|
|----------|-------|
|
||||||
|
| admin | yes |
|
||||||
|
| elizaveta | no |
|
||||||
|
| aleksandra | no |
|
||||||
|
|
||||||
|
## Managing Users
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Add user
|
||||||
|
docker exec synapse register_new_matrix_user \
|
||||||
|
-c /data/homeserver.yaml \
|
||||||
|
-u <username> -p <password> --no-admin \
|
||||||
|
http://localhost:8008
|
||||||
|
|
||||||
|
# Add admin
|
||||||
|
docker exec synapse register_new_matrix_user \
|
||||||
|
-c /data/homeserver.yaml \
|
||||||
|
-u <username> -p <password> -a \
|
||||||
|
http://localhost:8008
|
||||||
|
```
|
||||||
|
|
||||||
|
## Start / Stop
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd /home/alvis/agap_git/matrix
|
||||||
|
|
||||||
|
docker compose up -d # start all
|
||||||
|
docker compose down # stop all
|
||||||
|
docker compose restart # restart all
|
||||||
|
docker compose ps # status
|
||||||
|
docker compose logs -f # logs
|
||||||
|
```
|
||||||
|
|
||||||
|
## Caddy
|
||||||
|
|
||||||
|
Entries in `/home/alvis/agap_git/Caddyfile`:
|
||||||
|
|
||||||
|
| Domain | Purpose |
|
||||||
|
|--------|---------|
|
||||||
|
| `mtx.alogins.net` | Synapse + well-known |
|
||||||
|
| `lk.alogins.net` | LiveKit SFU |
|
||||||
|
| `lkjwt.alogins.net` | LiveKit JWT service |
|
||||||
|
|
||||||
|
Deploy Caddyfile changes:
|
||||||
|
```bash
|
||||||
|
sudo cp /home/alvis/agap_git/Caddyfile /etc/caddy/Caddyfile && sudo systemctl reload caddy
|
||||||
|
```
|
||||||
|
|
||||||
|
## Firewall Ports Required
|
||||||
|
|
||||||
|
| Port | Protocol | Service |
|
||||||
|
|------|----------|---------|
|
||||||
|
| 443 | TCP | Caddy (HTTPS) |
|
||||||
|
| 3478 | UDP+TCP | coturn TURN |
|
||||||
|
| 5349 | UDP+TCP | coturn TURNS |
|
||||||
|
| 7881 | TCP | LiveKit |
|
||||||
|
| 49152-65535 | UDP | coturn relay |
|
||||||
|
| 50100-50200 | UDP | LiveKit media |
|
||||||
|
|
||||||
|
## Data Locations
|
||||||
|
|
||||||
|
| Data | Path |
|
||||||
|
|------|------|
|
||||||
|
| Synapse config & media | `./data/synapse/` |
|
||||||
|
| PostgreSQL data | `./data/postgres/` |
|
||||||
|
| LiveKit config | `./livekit/livekit.yaml` |
|
||||||
|
| coturn config | `./coturn/turnserver.conf` |
|
||||||
|
|
||||||
|
## First-Time Setup (reference)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Generate Synapse config
|
||||||
|
docker run --rm \
|
||||||
|
-v ./data/synapse:/data \
|
||||||
|
-e SYNAPSE_SERVER_NAME=mtx.alogins.net \
|
||||||
|
-e SYNAPSE_REPORT_STATS=no \
|
||||||
|
matrixdotorg/synapse:latest generate
|
||||||
|
|
||||||
|
# Edit database section in data/synapse/homeserver.yaml, then:
|
||||||
|
docker compose up -d
|
||||||
|
```
|
||||||
18
matrix/coturn/turnserver.conf
Normal file
18
matrix/coturn/turnserver.conf
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
listening-port=3478
|
||||||
|
tls-listening-port=5349
|
||||||
|
|
||||||
|
external-ip=83.99.190.32/192.168.1.3
|
||||||
|
|
||||||
|
realm=mtx.alogins.net
|
||||||
|
server-name=mtx.alogins.net
|
||||||
|
|
||||||
|
use-auth-secret
|
||||||
|
static-auth-secret=144152cc09030796a4fd0109437dfc2089db2d5181b848d38d20c646c1d7a14b
|
||||||
|
|
||||||
|
no-multicast-peers
|
||||||
|
denied-peer-ip=10.0.0.0-10.255.255.255
|
||||||
|
denied-peer-ip=172.16.0.0-172.31.255.255
|
||||||
|
denied-peer-ip=192.168.0.0-192.168.255.255
|
||||||
|
|
||||||
|
log-file=stdout
|
||||||
|
no-software-attribute
|
||||||
73
matrix/docker-compose.yml
Normal file
73
matrix/docker-compose.yml
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
services:
|
||||||
|
synapse:
|
||||||
|
image: matrixdotorg/synapse:latest
|
||||||
|
container_name: synapse
|
||||||
|
restart: unless-stopped
|
||||||
|
volumes:
|
||||||
|
- ${SYNAPSE_DATA}:/data
|
||||||
|
- /etc/localtime:/etc/localtime:ro
|
||||||
|
environment:
|
||||||
|
- SYNAPSE_CONFIG_PATH=/data/homeserver.yaml
|
||||||
|
ports:
|
||||||
|
- "127.0.0.1:8008:8008"
|
||||||
|
depends_on:
|
||||||
|
- db
|
||||||
|
networks:
|
||||||
|
- matrix
|
||||||
|
- frontend
|
||||||
|
|
||||||
|
db:
|
||||||
|
image: postgres:16-alpine
|
||||||
|
container_name: synapse-db
|
||||||
|
restart: unless-stopped
|
||||||
|
environment:
|
||||||
|
- POSTGRES_USER=${POSTGRES_USER}
|
||||||
|
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
|
||||||
|
- POSTGRES_DB=${POSTGRES_DB}
|
||||||
|
- POSTGRES_INITDB_ARGS=--encoding=UTF-8 --lc-collate=C --lc-ctype=C
|
||||||
|
volumes:
|
||||||
|
- ${POSTGRES_DATA}:/var/lib/postgresql/data
|
||||||
|
- /etc/localtime:/etc/localtime:ro
|
||||||
|
networks:
|
||||||
|
- matrix
|
||||||
|
|
||||||
|
lk-jwt-service:
|
||||||
|
image: ghcr.io/element-hq/lk-jwt-service:latest
|
||||||
|
container_name: lk-jwt-service
|
||||||
|
restart: unless-stopped
|
||||||
|
ports:
|
||||||
|
- "127.0.0.1:8009:8080"
|
||||||
|
environment:
|
||||||
|
- LIVEKIT_JWT_BIND=:8080
|
||||||
|
- LIVEKIT_URL=wss://lk.alogins.net
|
||||||
|
- LIVEKIT_KEY=${LIVEKIT_KEY}
|
||||||
|
- LIVEKIT_SECRET=${LIVEKIT_SECRET}
|
||||||
|
- LIVEKIT_FULL_ACCESS_HOMESERVERS=mtx.alogins.net
|
||||||
|
extra_hosts:
|
||||||
|
- "mtx.alogins.net:host-gateway"
|
||||||
|
- "lk.alogins.net:host-gateway"
|
||||||
|
|
||||||
|
livekit:
|
||||||
|
image: livekit/livekit-server:latest
|
||||||
|
container_name: livekit
|
||||||
|
restart: unless-stopped
|
||||||
|
network_mode: host
|
||||||
|
volumes:
|
||||||
|
- ./livekit/livekit.yaml:/etc/livekit.yaml:ro
|
||||||
|
command: --config /etc/livekit.yaml
|
||||||
|
|
||||||
|
coturn:
|
||||||
|
image: coturn/coturn:latest
|
||||||
|
container_name: coturn
|
||||||
|
restart: unless-stopped
|
||||||
|
network_mode: host
|
||||||
|
volumes:
|
||||||
|
- ./coturn/turnserver.conf:/etc/coturn/turnserver.conf:ro
|
||||||
|
- /etc/localtime:/etc/localtime:ro
|
||||||
|
|
||||||
|
networks:
|
||||||
|
matrix:
|
||||||
|
driver: bridge
|
||||||
|
internal: true
|
||||||
|
frontend:
|
||||||
|
driver: bridge
|
||||||
15
matrix/livekit/livekit.yaml
Normal file
15
matrix/livekit/livekit.yaml
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
port: 7880
|
||||||
|
rtc:
|
||||||
|
tcp_port: 7881
|
||||||
|
port_range_start: 50100
|
||||||
|
port_range_end: 50200
|
||||||
|
use_external_ip: true
|
||||||
|
|
||||||
|
keys:
|
||||||
|
devkey: ef3ef4b903ca8469b09b2dd7ab6af529c4d2f3c95668f53832fc351cf67777a9
|
||||||
|
|
||||||
|
room:
|
||||||
|
auto_create: false
|
||||||
|
|
||||||
|
logging:
|
||||||
|
level: info
|
||||||
@@ -27,6 +27,9 @@ services:
|
|||||||
# Uncomment the line below if you are using Pi-hole as your NTP server
|
# Uncomment the line below if you are using Pi-hole as your NTP server
|
||||||
#- "123:123/udp"
|
#- "123:123/udp"
|
||||||
|
|
||||||
|
dns:
|
||||||
|
- 8.8.8.8
|
||||||
|
- 1.1.1.1
|
||||||
networks:
|
networks:
|
||||||
macvlan-br0:
|
macvlan-br0:
|
||||||
ipv4_address: 192.168.1.2
|
ipv4_address: 192.168.1.2
|
||||||
|
|||||||
@@ -1,24 +0,0 @@
|
|||||||
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.`),
|
|
||||||
});
|
|
||||||
115
sandbox/tgbot/node_modules/.package-lock.json
generated
vendored
115
sandbox/tgbot/node_modules/.package-lock.json
generated
vendored
@@ -1,115 +0,0 @@
|
|||||||
{
|
|
||||||
"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"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
21
sandbox/tgbot/node_modules/@grammyjs/types/LICENSE
generated
vendored
21
sandbox/tgbot/node_modules/@grammyjs/types/LICENSE
generated
vendored
@@ -1,21 +0,0 @@
|
|||||||
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.
|
|
||||||
107
sandbox/tgbot/node_modules/@grammyjs/types/README.md
generated
vendored
107
sandbox/tgbot/node_modules/@grammyjs/types/README.md
generated
vendored
@@ -1,107 +0,0 @@
|
|||||||
# 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<M>` (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: <https://grammy.dev/guide/api.html#type-definitions-for-the-api>.
|
|
||||||
|
|
||||||
## 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 <https://deno.land/x/grammy_types>.
|
|
||||||
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.
|
|
||||||
22
sandbox/tgbot/node_modules/@grammyjs/types/api.d.ts
generated
vendored
22
sandbox/tgbot/node_modules/@grammyjs/types/api.d.ts
generated
vendored
@@ -1,22 +0,0 @@
|
|||||||
export interface ApiError {
|
|
||||||
ok: false;
|
|
||||||
error_code: number;
|
|
||||||
description: string;
|
|
||||||
parameters?: ResponseParameters;
|
|
||||||
}
|
|
||||||
export interface ApiSuccess<T> {
|
|
||||||
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<T> = ApiError | ApiSuccess<T>;
|
|
||||||
/** 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;
|
|
||||||
}
|
|
||||||
72
sandbox/tgbot/node_modules/@grammyjs/types/checklist.d.ts
generated
vendored
72
sandbox/tgbot/node_modules/@grammyjs/types/checklist.d.ts
generated
vendored
@@ -1,72 +0,0 @@
|
|||||||
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[];
|
|
||||||
}
|
|
||||||
684
sandbox/tgbot/node_modules/@grammyjs/types/inline.d.ts
generated
vendored
684
sandbox/tgbot/node_modules/@grammyjs/types/inline.d.ts
generated
vendored
@@ -1,684 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
193
sandbox/tgbot/node_modules/@grammyjs/types/langs.d.ts
generated
vendored
193
sandbox/tgbot/node_modules/@grammyjs/types/langs.d.ts
generated
vendored
@@ -1,193 +0,0 @@
|
|||||||
/** 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";
|
|
||||||
};
|
|
||||||
1058
sandbox/tgbot/node_modules/@grammyjs/types/manage.d.ts
generated
vendored
1058
sandbox/tgbot/node_modules/@grammyjs/types/manage.d.ts
generated
vendored
File diff suppressed because it is too large
Load Diff
250
sandbox/tgbot/node_modules/@grammyjs/types/markup.d.ts
generated
vendored
250
sandbox/tgbot/node_modules/@grammyjs/types/markup.d.ts
generated
vendored
@@ -1,250 +0,0 @@
|
|||||||
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=<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;
|
|
||||||
}
|
|
||||||
1362
sandbox/tgbot/node_modules/@grammyjs/types/message.d.ts
generated
vendored
1362
sandbox/tgbot/node_modules/@grammyjs/types/message.d.ts
generated
vendored
File diff suppressed because it is too large
Load Diff
2429
sandbox/tgbot/node_modules/@grammyjs/types/methods.d.ts
generated
vendored
2429
sandbox/tgbot/node_modules/@grammyjs/types/methods.d.ts
generated
vendored
File diff suppressed because it is too large
Load Diff
13
sandbox/tgbot/node_modules/@grammyjs/types/mod.d.ts
generated
vendored
13
sandbox/tgbot/node_modules/@grammyjs/types/mod.d.ts
generated
vendored
@@ -1,13 +0,0 @@
|
|||||||
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";
|
|
||||||
2
sandbox/tgbot/node_modules/@grammyjs/types/mod.js
generated
vendored
2
sandbox/tgbot/node_modules/@grammyjs/types/mod.js
generated
vendored
@@ -1,2 +0,0 @@
|
|||||||
/* The comment below makes Vite recognize an empty main file as a valid CJS module. */
|
|
||||||
// module.exports
|
|
||||||
34
sandbox/tgbot/node_modules/@grammyjs/types/package.json
generated
vendored
34
sandbox/tgbot/node_modules/@grammyjs/types/package.json
generated
vendored
@@ -1,34 +0,0 @@
|
|||||||
{
|
|
||||||
"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"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
163
sandbox/tgbot/node_modules/@grammyjs/types/passport.d.ts
generated
vendored
163
sandbox/tgbot/node_modules/@grammyjs/types/passport.d.ts
generated
vendored
@@ -1,163 +0,0 @@
|
|||||||
/** 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;
|
|
||||||
}
|
|
||||||
563
sandbox/tgbot/node_modules/@grammyjs/types/payment.d.ts
generated
vendored
563
sandbox/tgbot/node_modules/@grammyjs/types/payment.d.ts
generated
vendored
@@ -1,563 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
120
sandbox/tgbot/node_modules/@grammyjs/types/settings.d.ts
generated
vendored
120
sandbox/tgbot/node_modules/@grammyjs/types/settings.d.ts
generated
vendored
@@ -1,120 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
89
sandbox/tgbot/node_modules/@grammyjs/types/story.d.ts
generated
vendored
89
sandbox/tgbot/node_modules/@grammyjs/types/story.d.ts
generated
vendored
@@ -1,89 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
78
sandbox/tgbot/node_modules/@grammyjs/types/update.d.ts
generated
vendored
78
sandbox/tgbot/node_modules/@grammyjs/types/update.d.ts
generated
vendored
@@ -1,78 +0,0 @@
|
|||||||
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<Chat, Chat.ChannelChat>;
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
21
sandbox/tgbot/node_modules/abort-controller/LICENSE
generated
vendored
21
sandbox/tgbot/node_modules/abort-controller/LICENSE
generated
vendored
@@ -1,21 +0,0 @@
|
|||||||
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.
|
|
||||||
98
sandbox/tgbot/node_modules/abort-controller/README.md
generated
vendored
98
sandbox/tgbot/node_modules/abort-controller/README.md
generated
vendored
@@ -1,98 +0,0 @@
|
|||||||
# abort-controller
|
|
||||||
|
|
||||||
[](https://www.npmjs.com/package/abort-controller)
|
|
||||||
[](http://www.npmtrends.com/abort-controller)
|
|
||||||
[](https://travis-ci.org/mysticatea/abort-controller)
|
|
||||||
[](https://codecov.io/gh/mysticatea/abort-controller)
|
|
||||||
[](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.
|
|
||||||
13
sandbox/tgbot/node_modules/abort-controller/browser.js
generated
vendored
13
sandbox/tgbot/node_modules/abort-controller/browser.js
generated
vendored
@@ -1,13 +0,0 @@
|
|||||||
/*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
|
|
||||||
11
sandbox/tgbot/node_modules/abort-controller/browser.mjs
generated
vendored
11
sandbox/tgbot/node_modules/abort-controller/browser.mjs
generated
vendored
@@ -1,11 +0,0 @@
|
|||||||
/*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 }
|
|
||||||
43
sandbox/tgbot/node_modules/abort-controller/dist/abort-controller.d.ts
generated
vendored
43
sandbox/tgbot/node_modules/abort-controller/dist/abort-controller.d.ts
generated
vendored
@@ -1,43 +0,0 @@
|
|||||||
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<Events, EventAttributes> {
|
|
||||||
/**
|
|
||||||
* 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 }
|
|
||||||
127
sandbox/tgbot/node_modules/abort-controller/dist/abort-controller.js
generated
vendored
127
sandbox/tgbot/node_modules/abort-controller/dist/abort-controller.js
generated
vendored
@@ -1,127 +0,0 @@
|
|||||||
/**
|
|
||||||
* @author Toru Nagashima <https://github.com/mysticatea>
|
|
||||||
* 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
|
|
||||||
1
sandbox/tgbot/node_modules/abort-controller/dist/abort-controller.js.map
generated
vendored
1
sandbox/tgbot/node_modules/abort-controller/dist/abort-controller.js.map
generated
vendored
File diff suppressed because one or more lines are too long
118
sandbox/tgbot/node_modules/abort-controller/dist/abort-controller.mjs
generated
vendored
118
sandbox/tgbot/node_modules/abort-controller/dist/abort-controller.mjs
generated
vendored
@@ -1,118 +0,0 @@
|
|||||||
/**
|
|
||||||
* @author Toru Nagashima <https://github.com/mysticatea>
|
|
||||||
* 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
|
|
||||||
1
sandbox/tgbot/node_modules/abort-controller/dist/abort-controller.mjs.map
generated
vendored
1
sandbox/tgbot/node_modules/abort-controller/dist/abort-controller.mjs.map
generated
vendored
File diff suppressed because one or more lines are too long
5
sandbox/tgbot/node_modules/abort-controller/dist/abort-controller.umd.js
generated
vendored
5
sandbox/tgbot/node_modules/abort-controller/dist/abort-controller.umd.js
generated
vendored
File diff suppressed because one or more lines are too long
1
sandbox/tgbot/node_modules/abort-controller/dist/abort-controller.umd.js.map
generated
vendored
1
sandbox/tgbot/node_modules/abort-controller/dist/abort-controller.umd.js.map
generated
vendored
File diff suppressed because one or more lines are too long
97
sandbox/tgbot/node_modules/abort-controller/package.json
generated
vendored
97
sandbox/tgbot/node_modules/abort-controller/package.json
generated
vendored
@@ -1,97 +0,0 @@
|
|||||||
{
|
|
||||||
"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"
|
|
||||||
}
|
|
||||||
21
sandbox/tgbot/node_modules/abort-controller/polyfill.js
generated
vendored
21
sandbox/tgbot/node_modules/abort-controller/polyfill.js
generated
vendored
@@ -1,21 +0,0 @@
|
|||||||
/*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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
19
sandbox/tgbot/node_modules/abort-controller/polyfill.mjs
generated
vendored
19
sandbox/tgbot/node_modules/abort-controller/polyfill.mjs
generated
vendored
@@ -1,19 +0,0 @@
|
|||||||
/*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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
20
sandbox/tgbot/node_modules/debug/LICENSE
generated
vendored
20
sandbox/tgbot/node_modules/debug/LICENSE
generated
vendored
@@ -1,20 +0,0 @@
|
|||||||
(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.
|
|
||||||
|
|
||||||
481
sandbox/tgbot/node_modules/debug/README.md
generated
vendored
481
sandbox/tgbot/node_modules/debug/README.md
generated
vendored
@@ -1,481 +0,0 @@
|
|||||||
# debug
|
|
||||||
[](#backers)
|
|
||||||
[](#sponsors)
|
|
||||||
|
|
||||||
<img width="647" src="https://user-images.githubusercontent.com/71256/29091486-fa38524c-7c37-11e7-895f-e7ec8e1039b6.png">
|
|
||||||
|
|
||||||
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:
|
|
||||||
|
|
||||||
<img width="647" alt="screen shot 2017-08-08 at 12 53 04 pm" src="https://user-images.githubusercontent.com/71256/29091703-a6302cdc-7c38-11e7-8304-7c0b3bc600cd.png">
|
|
||||||
<img width="647" alt="screen shot 2017-08-08 at 12 53 38 pm" src="https://user-images.githubusercontent.com/71256/29091700-a62a6888-7c38-11e7-800b-db911291ca2b.png">
|
|
||||||
<img width="647" alt="screen shot 2017-08-08 at 12 53 25 pm" src="https://user-images.githubusercontent.com/71256/29091701-a62ea114-7c38-11e7-826a-2692bedca740.png">
|
|
||||||
|
|
||||||
#### 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.
|
|
||||||
|
|
||||||
<img width="521" src="https://user-images.githubusercontent.com/71256/29092181-47f6a9e6-7c3a-11e7-9a14-1928d8a711cd.png">
|
|
||||||
|
|
||||||
#### 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).
|
|
||||||
|
|
||||||
<img width="524" src="https://user-images.githubusercontent.com/71256/29092033-b65f9f2e-7c39-11e7-8e32-f6f0d8e865c1.png">
|
|
||||||
|
|
||||||
|
|
||||||
## 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.
|
|
||||||
|
|
||||||
<img width="647" src="https://user-images.githubusercontent.com/71256/29091486-fa38524c-7c37-11e7-895f-e7ec8e1039b6.png">
|
|
||||||
|
|
||||||
When stdout is not a TTY, `Date#toISOString()` is used, making it more useful for logging the debug information as shown below:
|
|
||||||
|
|
||||||
<img width="647" src="https://user-images.githubusercontent.com/71256/29091956-6bd78372-7c39-11e7-8c55-c948396d6edd.png">
|
|
||||||
|
|
||||||
|
|
||||||
## 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_.
|
|
||||||
|
|
||||||
<img width="647" src="https://user-images.githubusercontent.com/7143133/152083257-29034707-c42c-4959-8add-3cee850e6fcf.png">
|
|
||||||
|
|
||||||
## 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)]
|
|
||||||
|
|
||||||
<a href="https://opencollective.com/debug/backer/0/website" target="_blank"><img src="https://opencollective.com/debug/backer/0/avatar.svg"></a>
|
|
||||||
<a href="https://opencollective.com/debug/backer/1/website" target="_blank"><img src="https://opencollective.com/debug/backer/1/avatar.svg"></a>
|
|
||||||
<a href="https://opencollective.com/debug/backer/2/website" target="_blank"><img src="https://opencollective.com/debug/backer/2/avatar.svg"></a>
|
|
||||||
<a href="https://opencollective.com/debug/backer/3/website" target="_blank"><img src="https://opencollective.com/debug/backer/3/avatar.svg"></a>
|
|
||||||
<a href="https://opencollective.com/debug/backer/4/website" target="_blank"><img src="https://opencollective.com/debug/backer/4/avatar.svg"></a>
|
|
||||||
<a href="https://opencollective.com/debug/backer/5/website" target="_blank"><img src="https://opencollective.com/debug/backer/5/avatar.svg"></a>
|
|
||||||
<a href="https://opencollective.com/debug/backer/6/website" target="_blank"><img src="https://opencollective.com/debug/backer/6/avatar.svg"></a>
|
|
||||||
<a href="https://opencollective.com/debug/backer/7/website" target="_blank"><img src="https://opencollective.com/debug/backer/7/avatar.svg"></a>
|
|
||||||
<a href="https://opencollective.com/debug/backer/8/website" target="_blank"><img src="https://opencollective.com/debug/backer/8/avatar.svg"></a>
|
|
||||||
<a href="https://opencollective.com/debug/backer/9/website" target="_blank"><img src="https://opencollective.com/debug/backer/9/avatar.svg"></a>
|
|
||||||
<a href="https://opencollective.com/debug/backer/10/website" target="_blank"><img src="https://opencollective.com/debug/backer/10/avatar.svg"></a>
|
|
||||||
<a href="https://opencollective.com/debug/backer/11/website" target="_blank"><img src="https://opencollective.com/debug/backer/11/avatar.svg"></a>
|
|
||||||
<a href="https://opencollective.com/debug/backer/12/website" target="_blank"><img src="https://opencollective.com/debug/backer/12/avatar.svg"></a>
|
|
||||||
<a href="https://opencollective.com/debug/backer/13/website" target="_blank"><img src="https://opencollective.com/debug/backer/13/avatar.svg"></a>
|
|
||||||
<a href="https://opencollective.com/debug/backer/14/website" target="_blank"><img src="https://opencollective.com/debug/backer/14/avatar.svg"></a>
|
|
||||||
<a href="https://opencollective.com/debug/backer/15/website" target="_blank"><img src="https://opencollective.com/debug/backer/15/avatar.svg"></a>
|
|
||||||
<a href="https://opencollective.com/debug/backer/16/website" target="_blank"><img src="https://opencollective.com/debug/backer/16/avatar.svg"></a>
|
|
||||||
<a href="https://opencollective.com/debug/backer/17/website" target="_blank"><img src="https://opencollective.com/debug/backer/17/avatar.svg"></a>
|
|
||||||
<a href="https://opencollective.com/debug/backer/18/website" target="_blank"><img src="https://opencollective.com/debug/backer/18/avatar.svg"></a>
|
|
||||||
<a href="https://opencollective.com/debug/backer/19/website" target="_blank"><img src="https://opencollective.com/debug/backer/19/avatar.svg"></a>
|
|
||||||
<a href="https://opencollective.com/debug/backer/20/website" target="_blank"><img src="https://opencollective.com/debug/backer/20/avatar.svg"></a>
|
|
||||||
<a href="https://opencollective.com/debug/backer/21/website" target="_blank"><img src="https://opencollective.com/debug/backer/21/avatar.svg"></a>
|
|
||||||
<a href="https://opencollective.com/debug/backer/22/website" target="_blank"><img src="https://opencollective.com/debug/backer/22/avatar.svg"></a>
|
|
||||||
<a href="https://opencollective.com/debug/backer/23/website" target="_blank"><img src="https://opencollective.com/debug/backer/23/avatar.svg"></a>
|
|
||||||
<a href="https://opencollective.com/debug/backer/24/website" target="_blank"><img src="https://opencollective.com/debug/backer/24/avatar.svg"></a>
|
|
||||||
<a href="https://opencollective.com/debug/backer/25/website" target="_blank"><img src="https://opencollective.com/debug/backer/25/avatar.svg"></a>
|
|
||||||
<a href="https://opencollective.com/debug/backer/26/website" target="_blank"><img src="https://opencollective.com/debug/backer/26/avatar.svg"></a>
|
|
||||||
<a href="https://opencollective.com/debug/backer/27/website" target="_blank"><img src="https://opencollective.com/debug/backer/27/avatar.svg"></a>
|
|
||||||
<a href="https://opencollective.com/debug/backer/28/website" target="_blank"><img src="https://opencollective.com/debug/backer/28/avatar.svg"></a>
|
|
||||||
<a href="https://opencollective.com/debug/backer/29/website" target="_blank"><img src="https://opencollective.com/debug/backer/29/avatar.svg"></a>
|
|
||||||
|
|
||||||
|
|
||||||
## 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)]
|
|
||||||
|
|
||||||
<a href="https://opencollective.com/debug/sponsor/0/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/0/avatar.svg"></a>
|
|
||||||
<a href="https://opencollective.com/debug/sponsor/1/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/1/avatar.svg"></a>
|
|
||||||
<a href="https://opencollective.com/debug/sponsor/2/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/2/avatar.svg"></a>
|
|
||||||
<a href="https://opencollective.com/debug/sponsor/3/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/3/avatar.svg"></a>
|
|
||||||
<a href="https://opencollective.com/debug/sponsor/4/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/4/avatar.svg"></a>
|
|
||||||
<a href="https://opencollective.com/debug/sponsor/5/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/5/avatar.svg"></a>
|
|
||||||
<a href="https://opencollective.com/debug/sponsor/6/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/6/avatar.svg"></a>
|
|
||||||
<a href="https://opencollective.com/debug/sponsor/7/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/7/avatar.svg"></a>
|
|
||||||
<a href="https://opencollective.com/debug/sponsor/8/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/8/avatar.svg"></a>
|
|
||||||
<a href="https://opencollective.com/debug/sponsor/9/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/9/avatar.svg"></a>
|
|
||||||
<a href="https://opencollective.com/debug/sponsor/10/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/10/avatar.svg"></a>
|
|
||||||
<a href="https://opencollective.com/debug/sponsor/11/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/11/avatar.svg"></a>
|
|
||||||
<a href="https://opencollective.com/debug/sponsor/12/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/12/avatar.svg"></a>
|
|
||||||
<a href="https://opencollective.com/debug/sponsor/13/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/13/avatar.svg"></a>
|
|
||||||
<a href="https://opencollective.com/debug/sponsor/14/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/14/avatar.svg"></a>
|
|
||||||
<a href="https://opencollective.com/debug/sponsor/15/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/15/avatar.svg"></a>
|
|
||||||
<a href="https://opencollective.com/debug/sponsor/16/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/16/avatar.svg"></a>
|
|
||||||
<a href="https://opencollective.com/debug/sponsor/17/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/17/avatar.svg"></a>
|
|
||||||
<a href="https://opencollective.com/debug/sponsor/18/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/18/avatar.svg"></a>
|
|
||||||
<a href="https://opencollective.com/debug/sponsor/19/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/19/avatar.svg"></a>
|
|
||||||
<a href="https://opencollective.com/debug/sponsor/20/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/20/avatar.svg"></a>
|
|
||||||
<a href="https://opencollective.com/debug/sponsor/21/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/21/avatar.svg"></a>
|
|
||||||
<a href="https://opencollective.com/debug/sponsor/22/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/22/avatar.svg"></a>
|
|
||||||
<a href="https://opencollective.com/debug/sponsor/23/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/23/avatar.svg"></a>
|
|
||||||
<a href="https://opencollective.com/debug/sponsor/24/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/24/avatar.svg"></a>
|
|
||||||
<a href="https://opencollective.com/debug/sponsor/25/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/25/avatar.svg"></a>
|
|
||||||
<a href="https://opencollective.com/debug/sponsor/26/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/26/avatar.svg"></a>
|
|
||||||
<a href="https://opencollective.com/debug/sponsor/27/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/27/avatar.svg"></a>
|
|
||||||
<a href="https://opencollective.com/debug/sponsor/28/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/28/avatar.svg"></a>
|
|
||||||
<a href="https://opencollective.com/debug/sponsor/29/website" target="_blank"><img src="https://opencollective.com/debug/sponsor/29/avatar.svg"></a>
|
|
||||||
|
|
||||||
## 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.
|
|
||||||
64
sandbox/tgbot/node_modules/debug/package.json
generated
vendored
64
sandbox/tgbot/node_modules/debug/package.json
generated
vendored
@@ -1,64 +0,0 @@
|
|||||||
{
|
|
||||||
"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 <tj@vision-media.ca>",
|
|
||||||
"Nathan Rajlich <nathan@tootallnate.net> (http://n8.io)",
|
|
||||||
"Andrew Rhyne <rhyneandrew@gmail.com>"
|
|
||||||
],
|
|
||||||
"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"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
272
sandbox/tgbot/node_modules/debug/src/browser.js
generated
vendored
272
sandbox/tgbot/node_modules/debug/src/browser.js
generated
vendored
@@ -1,272 +0,0 @@
|
|||||||
/* 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;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
292
sandbox/tgbot/node_modules/debug/src/common.js
generated
vendored
292
sandbox/tgbot/node_modules/debug/src/common.js
generated
vendored
@@ -1,292 +0,0 @@
|
|||||||
|
|
||||||
/**
|
|
||||||
* 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;
|
|
||||||
10
sandbox/tgbot/node_modules/debug/src/index.js
generated
vendored
10
sandbox/tgbot/node_modules/debug/src/index.js
generated
vendored
@@ -1,10 +0,0 @@
|
|||||||
/**
|
|
||||||
* 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');
|
|
||||||
}
|
|
||||||
263
sandbox/tgbot/node_modules/debug/src/node.js
generated
vendored
263
sandbox/tgbot/node_modules/debug/src/node.js
generated
vendored
@@ -1,263 +0,0 @@
|
|||||||
/**
|
|
||||||
* 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);
|
|
||||||
};
|
|
||||||
22
sandbox/tgbot/node_modules/event-target-shim/LICENSE
generated
vendored
22
sandbox/tgbot/node_modules/event-target-shim/LICENSE
generated
vendored
@@ -1,22 +0,0 @@
|
|||||||
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.
|
|
||||||
|
|
||||||
293
sandbox/tgbot/node_modules/event-target-shim/README.md
generated
vendored
293
sandbox/tgbot/node_modules/event-target-shim/README.md
generated
vendored
@@ -1,293 +0,0 @@
|
|||||||
# event-target-shim
|
|
||||||
|
|
||||||
[](https://www.npmjs.com/package/event-target-shim)
|
|
||||||
[](http://www.npmtrends.com/event-target-shim)
|
|
||||||
[](https://travis-ci.org/mysticatea/event-target-shim)
|
|
||||||
[](https://codecov.io/gh/mysticatea/event-target-shim)
|
|
||||||
[](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<FooEvents, FooEventAttributes> {
|
|
||||||
// ...
|
|
||||||
}
|
|
||||||
// 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<FooEvents, {}, "strict"> {
|
|
||||||
// ...
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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<string>()`.
|
|
||||||
2. Make the `type` property of event definitions stricter.
|
|
||||||
|
|
||||||
```ts
|
|
||||||
type FooEvents = {
|
|
||||||
hello: CustomEvent & { type: "hello" }
|
|
||||||
hey: Event & { type: "hey" }
|
|
||||||
}
|
|
||||||
class Foo extends EventTarget<FooEvents, {}, "strict"> {
|
|
||||||
// ...
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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.
|
|
||||||
871
sandbox/tgbot/node_modules/event-target-shim/dist/event-target-shim.js
generated
vendored
871
sandbox/tgbot/node_modules/event-target-shim/dist/event-target-shim.js
generated
vendored
@@ -1,871 +0,0 @@
|
|||||||
/**
|
|
||||||
* @author Toru Nagashima <https://github.com/mysticatea>
|
|
||||||
* @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<Event, PrivateData>}
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
const privateData = new WeakMap();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Cache for wrapper classes.
|
|
||||||
* @type {WeakMap<Object, Function>}
|
|
||||||
* @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<object, Map<string, ListenerNode>>}
|
|
||||||
* @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<string, ListenerNode>} 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
|
|
||||||
1
sandbox/tgbot/node_modules/event-target-shim/dist/event-target-shim.js.map
generated
vendored
1
sandbox/tgbot/node_modules/event-target-shim/dist/event-target-shim.js.map
generated
vendored
File diff suppressed because one or more lines are too long
862
sandbox/tgbot/node_modules/event-target-shim/dist/event-target-shim.mjs
generated
vendored
862
sandbox/tgbot/node_modules/event-target-shim/dist/event-target-shim.mjs
generated
vendored
@@ -1,862 +0,0 @@
|
|||||||
/**
|
|
||||||
* @author Toru Nagashima <https://github.com/mysticatea>
|
|
||||||
* @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<Event, PrivateData>}
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
const privateData = new WeakMap();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Cache for wrapper classes.
|
|
||||||
* @type {WeakMap<Object, Function>}
|
|
||||||
* @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<object, Map<string, ListenerNode>>}
|
|
||||||
* @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<string, ListenerNode>} 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
|
|
||||||
1
sandbox/tgbot/node_modules/event-target-shim/dist/event-target-shim.mjs.map
generated
vendored
1
sandbox/tgbot/node_modules/event-target-shim/dist/event-target-shim.mjs.map
generated
vendored
File diff suppressed because one or more lines are too long
6
sandbox/tgbot/node_modules/event-target-shim/dist/event-target-shim.umd.js
generated
vendored
6
sandbox/tgbot/node_modules/event-target-shim/dist/event-target-shim.umd.js
generated
vendored
File diff suppressed because one or more lines are too long
1
sandbox/tgbot/node_modules/event-target-shim/dist/event-target-shim.umd.js.map
generated
vendored
1
sandbox/tgbot/node_modules/event-target-shim/dist/event-target-shim.umd.js.map
generated
vendored
File diff suppressed because one or more lines are too long
399
sandbox/tgbot/node_modules/event-target-shim/index.d.ts
generated
vendored
399
sandbox/tgbot/node_modules/event-target-shim/index.d.ts
generated
vendored
@@ -1,399 +0,0 @@
|
|||||||
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<TEvents, TEventAttributes, TMode>
|
|
||||||
new(): EventTarget<TEvents, TEventAttributes, TMode>
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* `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<TEventAttributes> & {
|
|
||||||
/**
|
|
||||||
* 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<TEventType extends EventTarget.EventType<TEvents, TMode>>(
|
|
||||||
type: TEventType,
|
|
||||||
listener:
|
|
||||||
| EventTarget.Listener<EventTarget.PickEvent<TEvents, TEventType>>
|
|
||||||
| 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<TEventType extends EventTarget.EventType<TEvents, TMode>>(
|
|
||||||
type: TEventType,
|
|
||||||
listener:
|
|
||||||
| EventTarget.Listener<EventTarget.PickEvent<TEvents, TEventType>>
|
|
||||||
| null,
|
|
||||||
options?: boolean | EventTarget.RemoveOptions
|
|
||||||
): void
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Dispatch a given event.
|
|
||||||
* @param event The event to dispatch.
|
|
||||||
* @returns `false` if canceled.
|
|
||||||
*/
|
|
||||||
dispatchEvent<TEventType extends EventTarget.EventType<TEvents, TMode>>(
|
|
||||||
event: EventTarget.EventData<TEvents, TEventType, TMode>
|
|
||||||
): 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<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"
|
|
||||||
>(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<TEvent> {
|
|
||||||
(event: TEvent): void
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The type of object listeners.
|
|
||||||
*/
|
|
||||||
export interface ObjectListener<TEvent> {
|
|
||||||
handleEvent(event: TEvent): void
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The type of listeners.
|
|
||||||
*/
|
|
||||||
export type Listener<TEvent> =
|
|
||||||
| FunctionListener<TEvent>
|
|
||||||
| ObjectListener<TEvent>
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Event definition.
|
|
||||||
*/
|
|
||||||
export type EventDefinition = {
|
|
||||||
readonly [key: string]: Event
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Mapped type for event attributes.
|
|
||||||
*/
|
|
||||||
export type EventAttributes<TEventAttributes extends EventDefinition> = {
|
|
||||||
[P in keyof TEventAttributes]:
|
|
||||||
| FunctionListener<TEventAttributes[P]>
|
|
||||||
| 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<keyof TEvents[TEventType], OmittableEventKeys>
|
|
||||||
>
|
|
||||||
// Properties which are generated automatically are optional.
|
|
||||||
& Partial<Pick<Event, OmittableEventKeys>>
|
|
||||||
)
|
|
||||||
: (
|
|
||||||
TMode extends "standard"
|
|
||||||
? Event
|
|
||||||
: Event | NonStandardEvent
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The string literal types of the properties which are generated
|
|
||||||
* automatically in `dispatchEvent()` method.
|
|
||||||
*/
|
|
||||||
export type OmittableEventKeys = Exclude<keyof Event, "type">
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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<T extends string> = { 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
|
|
||||||
82
sandbox/tgbot/node_modules/event-target-shim/package.json
generated
vendored
82
sandbox/tgbot/node_modules/event-target-shim/package.json
generated
vendored
@@ -1,82 +0,0 @@
|
|||||||
{
|
|
||||||
"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"
|
|
||||||
}
|
|
||||||
21
sandbox/tgbot/node_modules/grammy/LICENSE
generated
vendored
21
sandbox/tgbot/node_modules/grammy/LICENSE
generated
vendored
@@ -1,21 +0,0 @@
|
|||||||
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.
|
|
||||||
347
sandbox/tgbot/node_modules/grammy/README.md
generated
vendored
347
sandbox/tgbot/node_modules/grammy/README.md
generated
vendored
@@ -1,347 +0,0 @@
|
|||||||
<div align="center"><a href="https://grammy.dev"><img src="https://raw.githubusercontent.com/grammyjs/website/main/logos/grammY.png" alt="grammY"></a></h1></div>
|
|
||||||
|
|
||||||
<div align="right">
|
|
||||||
|
|
||||||
# The Telegram Bot Framework
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div align="center">
|
|
||||||
|
|
||||||
<!-- deno-fmt-ignore-start -->
|
|
||||||
|
|
||||||
[](https://core.telegram.org/bots/api)
|
|
||||||
[](https://deno.land/x/grammy)
|
|
||||||
[](https://www.npmjs.org/package/grammy)
|
|
||||||
[](#contributors-)
|
|
||||||
|
|
||||||
<!-- deno-fmt-ignore-end -->
|
|
||||||
|
|
||||||
## _[docs.](https://grammy.dev) [reference.](https://grammy.dev/ref) [chat.](https://telegram.me/grammyjs) [news.](https://telegram.me/grammyjs_news)_
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
**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 <https://bundle.deno.dev/>.
|
|
||||||
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 <https://bundle.deno.dev/https://raw.githubusercontent.com/grammyjs/grammY/main/src/mod.ts>.
|
|
||||||
|
|
||||||
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)):
|
|
||||||
|
|
||||||
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
|
|
||||||
<!-- prettier-ignore-start -->
|
|
||||||
<!-- markdownlint-disable -->
|
|
||||||
<table>
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/KnorpelSenf"><img src="https://avatars.githubusercontent.com/u/12952387?v=4?s=100" width="100px;" alt="KnorpelSenf"/><br /><sub><b>KnorpelSenf</b></sub></a><br /><a href="#ideas-KnorpelSenf" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/grammyjs/grammY/commits?author=KnorpelSenf" title="Code">💻</a> <a href="https://github.com/grammyjs/grammY/commits?author=KnorpelSenf" title="Documentation">📖</a> <a href="#design-KnorpelSenf" title="Design">🎨</a> <a href="#example-KnorpelSenf" title="Examples">💡</a> <a href="https://github.com/grammyjs/grammY/commits?author=KnorpelSenf" title="Tests">⚠️</a> <a href="#plugin-KnorpelSenf" title="Plugin/utility libraries">🔌</a> <a href="#platform-KnorpelSenf" title="Packaging/porting to new platform">📦</a> <a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3AKnorpelSenf" title="Reviewed Pull Requests">👀</a> <a href="#mentoring-KnorpelSenf" title="Mentoring">🧑🏫</a> <a href="#projectManagement-KnorpelSenf" title="Project Management">📆</a> <a href="#infra-KnorpelSenf" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="#audio-KnorpelSenf" title="Audio">🔊</a> <a href="#a11y-KnorpelSenf" title="Accessibility">️️️️♿️</a> <a href="#talk-KnorpelSenf" title="Talks">📢</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/HeeroML"><img src="https://avatars.githubusercontent.com/u/42873000?v=4?s=100" width="100px;" alt="Heero"/><br /><sub><b>Heero</b></sub></a><br /><a href="#plugin-HeeroML" title="Plugin/utility libraries">🔌</a> <a href="#userTesting-HeeroML" title="User Testing">📓</a> <a href="#example-HeeroML" title="Examples">💡</a> <a href="https://github.com/grammyjs/grammY/commits?author=HeeroML" title="Documentation">📖</a> <a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3AHeeroML" title="Reviewed Pull Requests">👀</a> <a href="https://github.com/grammyjs/grammY/commits?author=HeeroML" title="Code">💻</a> <a href="#ideas-HeeroML" title="Ideas, Planning, & Feedback">🤔</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/wojpawlik"><img src="https://avatars.githubusercontent.com/u/23058303?v=4?s=100" width="100px;" alt="Wojciech Pawlik"/><br /><sub><b>Wojciech Pawlik</b></sub></a><br /><a href="#ideas-wojpawlik" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3Awojpawlik" title="Reviewed Pull Requests">👀</a> <a href="#infra-wojpawlik" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="#platform-wojpawlik" title="Packaging/porting to new platform">📦</a> <a href="#tool-wojpawlik" title="Tools">🔧</a> <a href="https://github.com/grammyjs/grammY/commits?author=wojpawlik" title="Code">💻</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/MegaITA"><img src="https://avatars.githubusercontent.com/u/32493080?v=4?s=100" width="100px;" alt="Alessandro Bertozzi"/><br /><sub><b>Alessandro Bertozzi</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=MegaITA" title="Documentation">📖</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://trgwii.no/"><img src="https://avatars.githubusercontent.com/u/11262022?v=4?s=100" width="100px;" alt="trgwii"/><br /><sub><b>trgwii</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=trgwii" title="Code">💻</a> <a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3Atrgwii" title="Reviewed Pull Requests">👀</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/KnightNiwrem"><img src="https://avatars.githubusercontent.com/u/9781814?v=4?s=100" width="100px;" alt="KnightNiwrem"/><br /><sub><b>KnightNiwrem</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=KnightNiwrem" title="Code">💻</a> <a href="https://github.com/grammyjs/grammY/issues?q=author%3AKnightNiwrem" title="Bug reports">🐛</a> <a href="#plugin-KnightNiwrem" title="Plugin/utility libraries">🔌</a> <a href="https://github.com/grammyjs/grammY/commits?author=KnightNiwrem" title="Documentation">📖</a> <a href="#example-KnightNiwrem" title="Examples">💡</a> <a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3AKnightNiwrem" title="Reviewed Pull Requests">👀</a> <a href="#mentoring-KnightNiwrem" title="Mentoring">🧑🏫</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://mkr.pw"><img src="https://avatars.githubusercontent.com/u/19621208?v=4?s=100" width="100px;" alt="Muthu Kumar"/><br /><sub><b>Muthu Kumar</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3AMKRhere" title="Reviewed Pull Requests">👀</a> <a href="https://github.com/grammyjs/grammY/issues?q=author%3AMKRhere" title="Bug reports">🐛</a> <a href="https://github.com/grammyjs/grammY/commits?author=MKRhere" title="Code">💻</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://edjopato.de/"><img src="https://avatars.githubusercontent.com/u/7953011?v=4?s=100" width="100px;" alt="EdJoPaTo"/><br /><sub><b>EdJoPaTo</b></sub></a><br /><a href="#plugin-EdJoPaTo" title="Plugin/utility libraries">🔌</a> <a href="https://github.com/grammyjs/grammY/commits?author=EdJoPaTo" title="Documentation">📖</a> <a href="#ideas-EdJoPaTo" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3AEdJoPaTo" title="Reviewed Pull Requests">👀</a> <a href="https://github.com/grammyjs/grammY/issues?q=author%3AEdJoPaTo" title="Bug reports">🐛</a> <a href="https://github.com/grammyjs/grammY/commits?author=EdJoPaTo" title="Code">💻</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/Amir-Zouerami"><img src="https://avatars.githubusercontent.com/u/53701884?v=4?s=100" width="100px;" alt="Amir Zouerami"/><br /><sub><b>Amir Zouerami</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=Amir-Zouerami" title="Documentation">📖</a> <a href="#plugin-Amir-Zouerami" title="Plugin/utility libraries">🔌</a> <a href="#example-Amir-Zouerami" title="Examples">💡</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/roj1512"><img src="https://avatars.githubusercontent.com/u/49933115?v=4?s=100" width="100px;" alt="Roj"/><br /><sub><b>Roj</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=roj1512" title="Documentation">📖</a> <a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3Aroj1512" title="Reviewed Pull Requests">👀</a> <a href="#infra-roj1512" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="#translation-roj1512" title="Translation">🌍</a> <a href="https://github.com/grammyjs/grammY/commits?author=roj1512" title="Code">💻</a> <a href="#ideas-roj1512" title="Ideas, Planning, & Feedback">🤔</a> <a href="#mentoring-roj1512" title="Mentoring">🧑🏫</a> <a href="#example-roj1512" title="Examples">💡</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/jokasimr"><img src="https://avatars.githubusercontent.com/u/20954731?v=4?s=100" width="100px;" alt="jokasimr"/><br /><sub><b>jokasimr</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/issues?q=author%3Ajokasimr" title="Bug reports">🐛</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/CikiMomogi"><img src="https://avatars.githubusercontent.com/u/74030149?v=4?s=100" width="100px;" alt="Ciki Momogi"/><br /><sub><b>Ciki Momogi</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=CikiMomogi" title="Documentation">📖</a> <a href="#translation-CikiMomogi" title="Translation">🌍</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/AndreoliBR"><img src="https://avatars.githubusercontent.com/u/15970011?v=4?s=100" width="100px;" alt="AndreoliBR"/><br /><sub><b>AndreoliBR</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3AAndreoliBR" title="Reviewed Pull Requests">👀</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/Loskir"><img src="https://avatars.githubusercontent.com/u/21295738?v=4?s=100" width="100px;" alt="Kirill Loskutov"/><br /><sub><b>Kirill Loskutov</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=Loskir" title="Documentation">📖</a> <a href="https://github.com/grammyjs/grammY/issues?q=author%3ALoskir" title="Bug reports">🐛</a> <a href="#ideas-Loskir" title="Ideas, Planning, & Feedback">🤔</a> <a href="#design-Loskir" title="Design">🎨</a> <a href="#question-Loskir" title="Answering Questions">💬</a> <a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3ALoskir" title="Reviewed Pull Requests">👀</a> <a href="https://github.com/grammyjs/grammY/commits?author=Loskir" title="Code">💻</a> <a href="#plugin-Loskir" title="Plugin/utility libraries">🔌</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://lungers.com/"><img src="https://avatars.githubusercontent.com/u/32808683?v=4?s=100" width="100px;" alt="Andrew Lane"/><br /><sub><b>Andrew Lane</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/issues?q=author%3AAndrewLaneX" title="Bug reports">🐛</a> <a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3AAndrewLaneX" title="Reviewed Pull Requests">👀</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/code-withAshish"><img src="https://avatars.githubusercontent.com/u/73625149?v=4?s=100" width="100px;" alt="code-withAshish"/><br /><sub><b>code-withAshish</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=code-withAshish" title="Documentation">📖</a> <a href="#question-code-withAshish" title="Answering Questions">💬</a> <a href="https://github.com/grammyjs/grammY/issues?q=author%3Acode-withAshish" title="Bug reports">🐛</a> <a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3Acode-withAshish" title="Reviewed Pull Requests">👀</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://beta.ku-di.com/waptik"><img src="https://avatars.githubusercontent.com/u/1687551?v=4?s=100" width="100px;" alt="Stephane Mensah"/><br /><sub><b>Stephane Mensah</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/issues?q=author%3Awaptik" title="Bug reports">🐛</a> <a href="#plugin-waptik" title="Plugin/utility libraries">🔌</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/Asaku01"><img src="https://avatars.githubusercontent.com/u/29716396?v=4?s=100" width="100px;" alt="Asaku01"/><br /><sub><b>Asaku01</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=Asaku01" title="Documentation">📖</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/ppsimn"><img src="https://avatars.githubusercontent.com/u/88509883?v=4?s=100" width="100px;" alt="ppsimn"/><br /><sub><b>ppsimn</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/issues?q=author%3Appsimn" title="Bug reports">🐛</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/satont"><img src="https://avatars.githubusercontent.com/u/42675886?v=4?s=100" width="100px;" alt="Satont"/><br /><sub><b>Satont</b></sub></a><br /><a href="#plugin-Satont" title="Plugin/utility libraries">🔌</a> <a href="https://github.com/grammyjs/grammY/commits?author=Satont" title="Documentation">📖</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/deptyped"><img src="https://avatars.githubusercontent.com/u/26162440?v=4?s=100" width="100px;" alt="deptyped"/><br /><sub><b>deptyped</b></sub></a><br /><a href="#example-deptyped" title="Examples">💡</a> <a href="https://github.com/grammyjs/grammY/commits?author=deptyped" title="Documentation">📖</a> <a href="#tutorial-deptyped" title="Tutorials">✅</a> <a href="https://github.com/grammyjs/grammY/issues?q=author%3Adeptyped" title="Bug reports">🐛</a> <a href="#translation-deptyped" title="Translation">🌍</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/dzek69"><img src="https://avatars.githubusercontent.com/u/4936805?v=4?s=100" width="100px;" alt="Jacek Nowacki"/><br /><sub><b>Jacek Nowacki</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=dzek69" title="Documentation">📖</a> <a href="https://github.com/grammyjs/grammY/commits?author=dzek69" title="Code">💻</a> <a href="https://github.com/grammyjs/grammY/issues?q=author%3Adzek69" title="Bug reports">🐛</a> <a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3Adzek69" title="Reviewed Pull Requests">👀</a> <a href="#ideas-dzek69" title="Ideas, Planning, & Feedback">🤔</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://blog.outv.im"><img src="https://avatars.githubusercontent.com/u/19144373?v=4?s=100" width="100px;" alt="Outvi V"/><br /><sub><b>Outvi V</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=outloudvi" title="Code">💻</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://bandism.net/"><img src="https://avatars.githubusercontent.com/u/22633385?v=4?s=100" width="100px;" alt="Ikko Ashimine"/><br /><sub><b>Ikko Ashimine</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=eltociear" title="Documentation">📖</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/amberlionk"><img src="https://avatars.githubusercontent.com/u/29119723?v=4?s=100" width="100px;" alt="Yevhen Denesiuk"/><br /><sub><b>Yevhen Denesiuk</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3Aamberlionk" title="Reviewed Pull Requests">👀</a> <a href="https://github.com/grammyjs/grammY/issues?q=author%3Aamberlionk" title="Bug reports">🐛</a> <a href="https://github.com/grammyjs/grammY/commits?author=amberlionk" title="Code">💻</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/prazedotid"><img src="https://avatars.githubusercontent.com/u/19567624?v=4?s=100" width="100px;" alt="prastian"/><br /><sub><b>prastian</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/issues?q=author%3Aprazedotid" title="Bug reports">🐛</a> <a href="https://github.com/grammyjs/grammY/commits?author=prazedotid" title="Code">💻</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://sayem.eu.org/"><img src="https://avatars.githubusercontent.com/u/14138401?v=4?s=100" width="100px;" alt="Sayem Chowdhury"/><br /><sub><b>Sayem Chowdhury</b></sub></a><br /><a href="#ideas-sayem314" title="Ideas, Planning, & Feedback">🤔</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/kospra"><img src="https://avatars.githubusercontent.com/u/42740406?v=4?s=100" width="100px;" alt="kospra"/><br /><sub><b>kospra</b></sub></a><br /><a href="#ideas-kospra" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/grammyjs/grammY/commits?author=kospra" title="Code">💻</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/chimit"><img src="https://avatars.githubusercontent.com/u/839349?v=4?s=100" width="100px;" alt="Chimit"/><br /><sub><b>Chimit</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=chimit" title="Documentation">📖</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/CalsiBotDev"><img src="https://avatars.githubusercontent.com/u/55633371?v=4?s=100" width="100px;" alt="Calsi"/><br /><sub><b>Calsi</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=CalsiBotDev" title="Documentation">📖</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://zohren.xyz"><img src="https://avatars.githubusercontent.com/u/15788906?v=4?s=100" width="100px;" alt="Jonas Zohren"/><br /><sub><b>Jonas Zohren</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/issues?q=author%3Ajfowl" title="Bug reports">🐛</a> <a href="https://github.com/grammyjs/grammY/commits?author=jfowl" title="Code">💻</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://zhemu.buzz/"><img src="https://avatars.githubusercontent.com/u/56839018?v=4?s=100" width="100px;" alt="linbuxiao"/><br /><sub><b>linbuxiao</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=linbuxiao" title="Documentation">📖</a> <a href="#translation-linbuxiao" title="Translation">🌍</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/JiquanWang99"><img src="https://avatars.githubusercontent.com/u/63894579?v=4?s=100" width="100px;" alt="JiquanWang99"/><br /><sub><b>JiquanWang99</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=JiquanWang99" title="Documentation">📖</a> <a href="#translation-JiquanWang99" title="Translation">🌍</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="http://bor691.ir/"><img src="https://avatars.githubusercontent.com/u/4184939?v=4?s=100" width="100px;" alt="Borhan Hafez"/><br /><sub><b>Borhan Hafez</b></sub></a><br /><a href="#plugin-zumoshi" title="Plugin/utility libraries">🔌</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://blog.limx.dev/"><img src="https://avatars.githubusercontent.com/u/6434137?v=4?s=100" width="100px;" alt="WingLim"/><br /><sub><b>WingLim</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=WingLim" title="Documentation">📖</a> <a href="#translation-WingLim" title="Translation">🌍</a> <a href="https://github.com/grammyjs/grammY/commits?author=WingLim" title="Code">💻</a> <a href="#plugin-WingLim" title="Plugin/utility libraries">🔌</a> <a href="#ideas-WingLim" title="Ideas, Planning, & Feedback">🤔</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/taotie111"><img src="https://avatars.githubusercontent.com/u/44166322?v=4?s=100" width="100px;" alt="taotie111"/><br /><sub><b>taotie111</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=taotie111" title="Documentation">📖</a> <a href="#translation-taotie111" title="Translation">🌍</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://www.linkedin.com/in/merlin-brandes-42328717a/"><img src="https://avatars.githubusercontent.com/u/14237330?v=4?s=100" width="100px;" alt="Merlin"/><br /><sub><b>Merlin</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=FatalMerlin" title="Documentation">📖</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://darve.sh"><img src="https://avatars.githubusercontent.com/u/22394081?v=4?s=100" width="100px;" alt="Darvesh"/><br /><sub><b>Darvesh</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/issues?q=author%3Adarvesh" title="Bug reports">🐛</a> <a href="https://github.com/grammyjs/grammY/commits?author=darvesh" title="Code">💻</a> <a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3Adarvesh" title="Reviewed Pull Requests">👀</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="http://telegram.me/dcdunkan"><img src="https://avatars.githubusercontent.com/u/70066170?v=4?s=100" width="100px;" alt="dcdunkan"/><br /><sub><b>dcdunkan</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/issues?q=author%3Adcdunkan" title="Bug reports">🐛</a> <a href="https://github.com/grammyjs/grammY/commits?author=dcdunkan" title="Code">💻</a> <a href="#plugin-dcdunkan" title="Plugin/utility libraries">🔌</a> <a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3Adcdunkan" title="Reviewed Pull Requests">👀</a> <a href="https://github.com/grammyjs/grammY/commits?author=dcdunkan" title="Documentation">📖</a> <a href="#ideas-dcdunkan" title="Ideas, Planning, & Feedback">🤔</a> <a href="#infra-dcdunkan" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="#tool-dcdunkan" title="Tools">🔧</a> <a href="#mentoring-dcdunkan" title="Mentoring">🧑🏫</a> <a href="#maintenance-dcdunkan" title="Maintenance">🚧</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://xuann.wang/"><img src="https://avatars.githubusercontent.com/u/44045911?v=4?s=100" width="100px;" alt="Kid"/><br /><sub><b>Kid</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=kidonng" title="Documentation">📖</a> <a href="#translation-kidonng" title="Translation">🌍</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="http://slava.fomin.io/"><img src="https://avatars.githubusercontent.com/u/1702725?v=4?s=100" width="100px;" alt="Slava Fomin II"/><br /><sub><b>Slava Fomin II</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/issues?q=author%3Aslavafomin" title="Bug reports">🐛</a> <a href="https://github.com/grammyjs/grammY/commits?author=slavafomin" title="Documentation">📖</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://kikobeats.com/"><img src="https://avatars.githubusercontent.com/u/2096101?v=4?s=100" width="100px;" alt="Kiko Beats"/><br /><sub><b>Kiko Beats</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=Kikobeats" title="Documentation">📖</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="http://///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////kraftwerk28.pp.ua"><img src="https://avatars.githubusercontent.com/u/31807671?v=4?s=100" width="100px;" alt="Vsevolod"/><br /><sub><b>Vsevolod</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=kraftwerk28" title="Code">💻</a> <a href="#ideas-kraftwerk28" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3Akraftwerk28" title="Reviewed Pull Requests">👀</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/habemuscode"><img src="https://avatars.githubusercontent.com/u/34692207?v=4?s=100" width="100px;" alt="Habemuscode"/><br /><sub><b>Habemuscode</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3Ahabemuscode" title="Reviewed Pull Requests">👀</a> <a href="https://github.com/grammyjs/grammY/commits?author=habemuscode" title="Documentation">📖</a> <a href="#translation-habemuscode" title="Translation">🌍</a> <a href="#maintenance-habemuscode" title="Maintenance">🚧</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://borodutch.com/"><img src="https://avatars.githubusercontent.com/u/3192028?v=4?s=100" width="100px;" alt="Nikita Kolmogorov"/><br /><sub><b>Nikita Kolmogorov</b></sub></a><br /><a href="#plugin-backmeupplz" title="Plugin/utility libraries">🔌</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="http://glukki.ru"><img src="https://avatars.githubusercontent.com/u/140462?v=4?s=100" width="100px;" alt="Vitaliy Meshchaninov"/><br /><sub><b>Vitaliy Meshchaninov</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/issues?q=author%3Aglukki" title="Bug reports">🐛</a> <a href="https://github.com/grammyjs/grammY/commits?author=glukki" title="Code">💻</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/dilyanpalauzov"><img src="https://avatars.githubusercontent.com/u/4992947?v=4?s=100" width="100px;" alt="Дилян Палаузов"/><br /><sub><b>Дилян Палаузов</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/issues?q=author%3Adilyanpalauzov" title="Bug reports">🐛</a> <a href="https://github.com/grammyjs/grammY/commits?author=dilyanpalauzov" title="Code">💻</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/lmx-Hexagram"><img src="https://avatars.githubusercontent.com/u/52130356?v=4?s=100" width="100px;" alt="lmx-Hexagram"/><br /><sub><b>lmx-Hexagram</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=lmx-Hexagram" title="Documentation">📖</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/IlyaSemenov"><img src="https://avatars.githubusercontent.com/u/128121?v=4?s=100" width="100px;" alt="Ilya Semenov"/><br /><sub><b>Ilya Semenov</b></sub></a><br /><a href="#ideas-IlyaSemenov" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3AIlyaSemenov" title="Reviewed Pull Requests">👀</a> <a href="https://github.com/grammyjs/grammY/commits?author=IlyaSemenov" title="Code">💻</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/abdollahzadehAli"><img src="https://avatars.githubusercontent.com/u/96317431?v=4?s=100" width="100px;" alt="abdollahzadehAli"/><br /><sub><b>abdollahzadehAli</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=abdollahzadehAli" title="Documentation">📖</a> <a href="#example-abdollahzadehAli" title="Examples">💡</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/MrSaeedNasiri"><img src="https://avatars.githubusercontent.com/u/17780289?v=4?s=100" width="100px;" alt="Saeed Nasiri"/><br /><sub><b>Saeed Nasiri</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=MrSaeedNasiri" title="Documentation">📖</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/Scrip7"><img src="https://avatars.githubusercontent.com/u/37535505?v=4?s=100" width="100px;" alt="Hesoyam"/><br /><sub><b>Hesoyam</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=Scrip7" title="Documentation">📖</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="http://yrz.am"><img src="https://avatars.githubusercontent.com/u/96742416?v=4?s=100" width="100px;" alt="yrzam"/><br /><sub><b>yrzam</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/issues?q=author%3Ayrzam" title="Bug reports">🐛</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/drmikecrowe"><img src="https://avatars.githubusercontent.com/u/90312?v=4?s=100" width="100px;" alt="drmikecrowe"/><br /><sub><b>drmikecrowe</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3Adrmikecrowe" title="Reviewed Pull Requests">👀</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://rys.pw"><img src="https://avatars.githubusercontent.com/u/1641362?v=4?s=100" width="100px;" alt="Martin"/><br /><sub><b>Martin</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=C0rn3j" title="Documentation">📖</a> <a href="https://github.com/grammyjs/grammY/issues?q=author%3AC0rn3j" title="Bug reports">🐛</a> <a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3AC0rn3j" title="Reviewed Pull Requests">👀</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="http://pavelpolyakov.com/"><img src="https://avatars.githubusercontent.com/u/839290?v=4?s=100" width="100px;" alt="Pavel"/><br /><sub><b>Pavel</b></sub></a><br /><a href="#example-PavelPolyakov" title="Examples">💡</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://youtube.com/thorwebdev"><img src="https://avatars.githubusercontent.com/u/5748289?v=4?s=100" width="100px;" alt="Thor 雷神 Schaeff"/><br /><sub><b>Thor 雷神 Schaeff</b></sub></a><br /><a href="#example-thorwebdev" title="Examples">💡</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/x066it"><img src="https://avatars.githubusercontent.com/u/75589380?v=4?s=100" width="100px;" alt="x066it"/><br /><sub><b>x066it</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/issues?q=author%3Ax066it" title="Bug reports">🐛</a> <a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3Ax066it" title="Reviewed Pull Requests">👀</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/kolay-v"><img src="https://avatars.githubusercontent.com/u/49853802?v=4?s=100" width="100px;" alt="kolay"/><br /><sub><b>kolay</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3Akolay-v" title="Reviewed Pull Requests">👀</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://enepom.com/"><img src="https://avatars.githubusercontent.com/u/2511553?v=4?s=100" width="100px;" alt="Evgeny Nepomnyashchiy"/><br /><sub><b>Evgeny Nepomnyashchiy</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3Apizzaeater" title="Reviewed Pull Requests">👀</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/anantakrishna"><img src="https://avatars.githubusercontent.com/u/6065071?v=4?s=100" width="100px;" alt="Ananta Krsna dasa"/><br /><sub><b>Ananta Krsna dasa</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=anantakrishna" title="Documentation">📖</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/Mi3liX9"><img src="https://avatars.githubusercontent.com/u/26169870?v=4?s=100" width="100px;" alt="Mighty Ali"/><br /><sub><b>Mighty Ali</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=Mi3liX9" title="Code">💻</a> <a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3AMi3liX9" title="Reviewed Pull Requests">👀</a> <a href="#ideas-Mi3liX9" title="Ideas, Planning, & Feedback">🤔</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://oott123.com"><img src="https://avatars.githubusercontent.com/u/905663?v=4?s=100" width="100px;" alt="三三"/><br /><sub><b>三三</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/issues?q=author%3Aoott123" title="Bug reports">🐛</a> <a href="https://github.com/grammyjs/grammY/commits?author=oott123" title="Code">💻</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="http://roz.ninja"><img src="https://avatars.githubusercontent.com/u/3948961?v=4?s=100" width="100px;" alt="Roz"/><br /><sub><b>Roz</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/issues?q=author%3Aroziscoding" title="Bug reports">🐛</a> <a href="https://github.com/grammyjs/grammY/commits?author=roziscoding" title="Code">💻</a> <a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3Aroziscoding" title="Reviewed Pull Requests">👀</a> <a href="#infra-roziscoding" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="#ideas-roziscoding" title="Ideas, Planning, & Feedback">🤔</a> <a href="#mentoring-roziscoding" title="Mentoring">🧑🏫</a> <a href="#plugin-roziscoding" title="Plugin/utility libraries">🔌</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/daniharo"><img src="https://avatars.githubusercontent.com/u/47931084?v=4?s=100" width="100px;" alt="Dani Haro"/><br /><sub><b>Dani Haro</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=daniharo" title="Code">💻</a> <a href="#plugin-daniharo" title="Plugin/utility libraries">🔌</a> <a href="https://github.com/grammyjs/grammY/commits?author=daniharo" title="Documentation">📖</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/Ryukaizen"><img src="https://avatars.githubusercontent.com/u/55140313?v=4?s=100" width="100px;" alt="Ryukaizen"/><br /><sub><b>Ryukaizen</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=Ryukaizen" title="Documentation">📖</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/mcpeblocker"><img src="https://avatars.githubusercontent.com/u/59408255?v=4?s=100" width="100px;" alt="Alisher Ortiqov"/><br /><sub><b>Alisher Ortiqov</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=mcpeblocker" title="Documentation">📖</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/tonytkachenko"><img src="https://avatars.githubusercontent.com/u/103267335?v=4?s=100" width="100px;" alt="Tony Tkachenko"/><br /><sub><b>Tony Tkachenko</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=tonytkachenko" title="Documentation">📖</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/rainrisa"><img src="https://avatars.githubusercontent.com/u/108156134?v=4?s=100" width="100px;" alt="Ra"/><br /><sub><b>Ra</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=rainrisa" title="Code">💻</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/sartoshi-foot-dao"><img src="https://avatars.githubusercontent.com/u/99770068?v=4?s=100" width="100px;" alt="sartoshi-foot-dao"/><br /><sub><b>sartoshi-foot-dao</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=sartoshi-foot-dao" title="Documentation">📖</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/yn4v4s"><img src="https://avatars.githubusercontent.com/u/35275827?v=4?s=100" width="100px;" alt="Yoel Navas E."/><br /><sub><b>Yoel Navas E.</b></sub></a><br /><a href="#ideas-yn4v4s" title="Ideas, Planning, & Feedback">🤔</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/vitorleo"><img src="https://avatars.githubusercontent.com/u/5118352?v=4?s=100" width="100px;" alt="Vitor Gomes"/><br /><sub><b>Vitor Gomes</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/issues?q=author%3Avitorleo" title="Bug reports">🐛</a> <a href="https://github.com/grammyjs/grammY/commits?author=vitorleo" title="Code">💻</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="http://xditya.me/"><img src="https://avatars.githubusercontent.com/u/58950863?v=4?s=100" width="100px;" alt="Aditya"/><br /><sub><b>Aditya</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/issues?q=author%3Axditya" title="Bug reports">🐛</a> <a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3Axditya" title="Reviewed Pull Requests">👀</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="http://uditkaro.de"><img src="https://avatars.githubusercontent.com/u/30829387?v=4?s=100" width="100px;" alt="Udit Karode"/><br /><sub><b>Udit Karode</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3Auditkarode" title="Reviewed Pull Requests">👀</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://rockett.pw"><img src="https://avatars.githubusercontent.com/u/4586280?v=4?s=100" width="100px;" alt="Mike Rockétt"/><br /><sub><b>Mike Rockétt</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3Amikerockett" title="Reviewed Pull Requests">👀</a> <a href="https://github.com/grammyjs/grammY/issues?q=author%3Amikerockett" title="Bug reports">🐛</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/MrVSiK"><img src="https://avatars.githubusercontent.com/u/79159341?v=4?s=100" width="100px;" alt="Srinivasa IK Varanasi"/><br /><sub><b>Srinivasa IK Varanasi</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=MrVSiK" title="Code">💻</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/abdoo9"><img src="https://avatars.githubusercontent.com/u/63903814?v=4?s=100" width="100px;" alt="abdoo9"/><br /><sub><b>abdoo9</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/issues?q=author%3Aabdoo9" title="Bug reports">🐛</a> <a href="https://github.com/grammyjs/grammY/commits?author=abdoo9" title="Code">💻</a> <a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3Aabdoo9" title="Reviewed Pull Requests">👀</a> <a href="https://github.com/grammyjs/grammY/commits?author=abdoo9" title="Documentation">📖</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="http://ak4zh.com"><img src="https://avatars.githubusercontent.com/u/26350053?v=4?s=100" width="100px;" alt="ak4zh"/><br /><sub><b>ak4zh</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3Aak4zh" title="Reviewed Pull Requests">👀</a> <a href="#ideas-ak4zh" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/grammyjs/grammY/commits?author=ak4zh" title="Code">💻</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/nlapshin"><img src="https://avatars.githubusercontent.com/u/39495311?v=4?s=100" width="100px;" alt="Nikolay Lapshin"/><br /><sub><b>Nikolay Lapshin</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=nlapshin" title="Code">💻</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/Aquathing"><img src="https://avatars.githubusercontent.com/u/81624781?v=4?s=100" width="100px;" alt="Aquatica"/><br /><sub><b>Aquatica</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=Aquathing" title="Documentation">📖</a> <a href="#question-Aquathing" title="Answering Questions">💬</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/fadzikri"><img src="https://avatars.githubusercontent.com/u/109416385?v=4?s=100" width="100px;" alt="Fa Dzikri"/><br /><sub><b>Fa Dzikri</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3Afadzikri" title="Reviewed Pull Requests">👀</a> <a href="https://github.com/grammyjs/grammY/commits?author=fadzikri" title="Documentation">📖</a> <a href="#translation-fadzikri" title="Translation">🌍</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/solidprinciples"><img src="https://avatars.githubusercontent.com/u/7939765?v=4?s=100" width="100px;" alt="Chandler Lattin"/><br /><sub><b>Chandler Lattin</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=solidprinciples" title="Code">💻</a> <a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3Asolidprinciples" title="Reviewed Pull Requests">👀</a> <a href="#plugin-solidprinciples" title="Plugin/utility libraries">🔌</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/sparfenyuk"><img src="https://avatars.githubusercontent.com/u/134065?v=4?s=100" width="100px;" alt="Sergey Parfenyuk"/><br /><sub><b>Sergey Parfenyuk</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/issues?q=author%3Asparfenyuk" title="Bug reports">🐛</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/felinto-dev"><img src="https://avatars.githubusercontent.com/u/32253743?v=4?s=100" width="100px;" alt="Émerson Felinto"/><br /><sub><b>Émerson Felinto</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/issues?q=author%3Afelinto-dev" title="Bug reports">🐛</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/stPitty"><img src="https://avatars.githubusercontent.com/u/85024641?v=4?s=100" width="100px;" alt="Petr Stankin"/><br /><sub><b>Petr Stankin</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/issues?q=author%3AstPitty" title="Bug reports">🐛</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/ByMsx"><img src="https://avatars.githubusercontent.com/u/5565836?v=4?s=100" width="100px;" alt="Maxim Lebedev"/><br /><sub><b>Maxim Lebedev</b></sub></a><br /><a href="#ideas-ByMsx" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/grammyjs/grammY/commits?author=ByMsx" title="Code">💻</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/Madnex"><img src="https://avatars.githubusercontent.com/u/14137610?v=4?s=100" width="100px;" alt="Madnex"/><br /><sub><b>Madnex</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=Madnex" title="Documentation">📖</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/tup4ienko"><img src="https://avatars.githubusercontent.com/u/89318613?v=4?s=100" width="100px;" alt="Svyatoslav Tupchienko"/><br /><sub><b>Svyatoslav Tupchienko</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=tup4ienko" title="Code">💻</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/evermake"><img src="https://avatars.githubusercontent.com/u/53311479?v=4?s=100" width="100px;" alt="Vladislav Deryabkin"/><br /><sub><b>Vladislav Deryabkin</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/issues?q=author%3Aevermake" title="Bug reports">🐛</a> <a href="https://github.com/grammyjs/grammY/commits?author=evermake" title="Code">💻</a> <a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3Aevermake" title="Reviewed Pull Requests">👀</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/kashyapndps00"><img src="https://avatars.githubusercontent.com/u/98746601?v=4?s=100" width="100px;" alt="Kashyap Sharma"/><br /><sub><b>Kashyap Sharma</b></sub></a><br /><a href="#example-kashyapndps00" title="Examples">💡</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/AlexOwl"><img src="https://avatars.githubusercontent.com/u/47189254?v=4?s=100" width="100px;" alt="AlexOwl"/><br /><sub><b>AlexOwl</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/issues?q=author%3AAlexOwl" title="Bug reports">🐛</a> <a href="https://github.com/grammyjs/grammY/commits?author=AlexOwl" title="Code">💻</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://www.shrimadhavuk.me/"><img src="https://avatars.githubusercontent.com/u/6317196?v=4?s=100" width="100px;" alt="Shrimadhav U K"/><br /><sub><b>Shrimadhav U K</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=SpEcHiDe" title="Code">💻</a> <a href="#ideas-SpEcHiDe" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/grammyjs/grammY/commits?author=SpEcHiDe" title="Tests">⚠️</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/binamralamsal"><img src="https://avatars.githubusercontent.com/u/61900781?v=4?s=100" width="100px;" alt="Binamra Lamsal"/><br /><sub><b>Binamra Lamsal</b></sub></a><br /><a href="#ideas-binamralamsal" title="Ideas, Planning, & Feedback">🤔</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/gertminov"><img src="https://avatars.githubusercontent.com/u/78727928?v=4?s=100" width="100px;" alt="gertminov"/><br /><sub><b>gertminov</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=gertminov" title="Documentation">📖</a> <a href="#tutorial-gertminov" title="Tutorials">✅</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/amanape"><img src="https://avatars.githubusercontent.com/u/83104063?v=4?s=100" width="100px;" alt="Stephan Psaras"/><br /><sub><b>Stephan Psaras</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/issues?q=author%3Aamanape" title="Bug reports">🐛</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/shevernitskiy"><img src="https://avatars.githubusercontent.com/u/28886342?v=4?s=100" width="100px;" alt="shevernitskiy"/><br /><sub><b>shevernitskiy</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/issues?q=author%3Ashevernitskiy" title="Bug reports">🐛</a> <a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3Ashevernitskiy" title="Reviewed Pull Requests">👀</a> <a href="https://github.com/grammyjs/grammY/commits?author=shevernitskiy" title="Code">💻</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/mrmaster009"><img src="https://avatars.githubusercontent.com/u/81420490?v=4?s=100" width="100px;" alt="mrmaster009"/><br /><sub><b>mrmaster009</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=mrmaster009" title="Documentation">📖</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://lwjerri.dev"><img src="https://avatars.githubusercontent.com/u/50290430?v=4?s=100" width="100px;" alt="Andrii Zontov"/><br /><sub><b>Andrii Zontov</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/issues?q=author%3ALWJerri" title="Bug reports">🐛</a> <a href="https://github.com/grammyjs/grammY/commits?author=LWJerri" title="Code">💻</a> <a href="#question-LWJerri" title="Answering Questions">💬</a> <a href="#ideas-LWJerri" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/grammyjs/grammY/commits?author=LWJerri" title="Documentation">📖</a> <a href="#translation-LWJerri" title="Translation">🌍</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/AbbassAlmusawi"><img src="https://avatars.githubusercontent.com/u/73327881?v=4?s=100" width="100px;" alt="Abbass Al-Musawi"/><br /><sub><b>Abbass Al-Musawi</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=AbbassAlmusawi" title="Documentation">📖</a> <a href="https://github.com/grammyjs/grammY/issues?q=author%3AAbbassAlmusawi" title="Bug reports">🐛</a> <a href="https://github.com/grammyjs/grammY/commits?author=AbbassAlmusawi" title="Code">💻</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/inji-gg"><img src="https://avatars.githubusercontent.com/u/5071242?v=4?s=100" width="100px;" alt="ArunR"/><br /><sub><b>ArunR</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/issues?q=author%3Ainji-gg" title="Bug reports">🐛</a> <a href="https://github.com/grammyjs/grammY/commits?author=inji-gg" title="Code">💻</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/ndatg"><img src="https://avatars.githubusercontent.com/u/108090198?v=4?s=100" width="100px;" alt="NDA"/><br /><sub><b>NDA</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/issues?q=author%3Andatg" title="Bug reports">🐛</a> <a href="#ideas-ndatg" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/grammyjs/grammY/commits?author=ndatg" title="Code">💻</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/MatyiFKBT"><img src="https://avatars.githubusercontent.com/u/6183867?v=4?s=100" width="100px;" alt="MatyiFKBT"/><br /><sub><b>MatyiFKBT</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=MatyiFKBT" title="Documentation">📖</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://chrisandrew.cl"><img src="https://avatars.githubusercontent.com/u/368831?v=4?s=100" width="100px;" alt="Chris Andrew C. L."/><br /><sub><b>Chris Andrew C. L.</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/issues?q=author%3Achrisandrewcl" title="Bug reports">🐛</a> <a href="https://github.com/grammyjs/grammY/commits?author=chrisandrewcl" title="Code">💻</a> <a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3Achrisandrewcl" title="Reviewed Pull Requests">👀</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/kiyasov"><img src="https://avatars.githubusercontent.com/u/16527461?v=4?s=100" width="100px;" alt="Islam Kiiasov"/><br /><sub><b>Islam Kiiasov</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=kiyasov" title="Code">💻</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/ssistoza"><img src="https://avatars.githubusercontent.com/u/17445445?v=4?s=100" width="100px;" alt="Shane Avery Sistoza"/><br /><sub><b>Shane Avery Sistoza</b></sub></a><br /><a href="#ideas-ssistoza" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/grammyjs/grammY/commits?author=ssistoza" title="Code">💻</a> <a href="https://github.com/grammyjs/grammY/commits?author=ssistoza" title="Tests">⚠️</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/MaicolAntali"><img src="https://avatars.githubusercontent.com/u/79454487?v=4?s=100" width="100px;" alt="Maicol"/><br /><sub><b>Maicol</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=MaicolAntali" title="Code">💻</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/Nazar-Ant"><img src="https://avatars.githubusercontent.com/u/75927667?v=4?s=100" width="100px;" alt="Nazar Antoniuk"/><br /><sub><b>Nazar Antoniuk</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=Nazar-Ant" title="Documentation">📖</a> <a href="#translation-Nazar-Ant" title="Translation">🌍</a> <a href="#maintenance-Nazar-Ant" title="Maintenance">🚧</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/MajorLettuce"><img src="https://avatars.githubusercontent.com/u/3730149?v=4?s=100" width="100px;" alt="Aleksei Ivanov"/><br /><sub><b>Aleksei Ivanov</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3AMajorLettuce" title="Reviewed Pull Requests">👀</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/PonomareVlad"><img src="https://avatars.githubusercontent.com/u/2877584?v=4?s=100" width="100px;" alt="Vladislav Ponomarev"/><br /><sub><b>Vladislav Ponomarev</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=PonomareVlad" title="Tests">⚠️</a> <a href="https://github.com/grammyjs/grammY/commits?author=PonomareVlad" title="Code">💻</a> <a href="#platform-PonomareVlad" title="Packaging/porting to new platform">📦</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/louietyj"><img src="https://avatars.githubusercontent.com/u/11096034?v=4?s=100" width="100px;" alt="Louie Tan"/><br /><sub><b>Louie Tan</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3Alouietyj" title="Reviewed Pull Requests">👀</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/lejovaar7"><img src="https://avatars.githubusercontent.com/u/26439842?v=4?s=100" width="100px;" alt="Leandro Vargas"/><br /><sub><b>Leandro Vargas</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/issues?q=author%3Alejovaar7" title="Bug reports">🐛</a> <a href="https://github.com/grammyjs/grammY/commits?author=lejovaar7" title="Code">💻</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/shaunnope"><img src="https://avatars.githubusercontent.com/u/19631195?v=4?s=100" width="100px;" alt="Sean Yap"/><br /><sub><b>Sean Yap</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/issues?q=author%3Ashaunnope" title="Bug reports">🐛</a> <a href="https://github.com/grammyjs/grammY/commits?author=shaunnope" title="Code">💻</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://sergeysolovev.com"><img src="https://avatars.githubusercontent.com/u/5831301?v=4?s=100" width="100px;" alt="Sergey Solovev"/><br /><sub><b>Sergey Solovev</b></sub></a><br /><a href="#ideas-sergeysolovev" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3Asergeysolovev" title="Reviewed Pull Requests">👀</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/HeySreelal"><img src="https://avatars.githubusercontent.com/u/94184909?v=4?s=100" width="100px;" alt="Sree (Taylor's Version)"/><br /><sub><b>Sree (Taylor's Version)</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/issues?q=author%3AHeySreelal" title="Bug reports">🐛</a> <a href="https://github.com/grammyjs/grammY/commits?author=HeySreelal" title="Code">💻</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="http://linkedin.com/in/thecoorum"><img src="https://avatars.githubusercontent.com/u/32096016?v=4?s=100" width="100px;" alt="Yaroslav Vovchenko"/><br /><sub><b>Yaroslav Vovchenko</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/issues?q=author%3Athecoorum" title="Bug reports">🐛</a> <a href="https://github.com/grammyjs/grammY/commits?author=thecoorum" title="Code">💻</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/gabeklavans"><img src="https://avatars.githubusercontent.com/u/32149200?v=4?s=100" width="100px;" alt="gabe"/><br /><sub><b>gabe</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3Agabeklavans" title="Reviewed Pull Requests">👀</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/Rnbsov"><img src="https://avatars.githubusercontent.com/u/73550760?v=4?s=100" width="100px;" alt="Lavrentiy Rubtsov"/><br /><sub><b>Lavrentiy Rubtsov</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=Rnbsov" title="Documentation">📖</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://linktr.ee/joshgillies"><img src="https://avatars.githubusercontent.com/u/319694?v=4?s=100" width="100px;" alt="Josh Gillies"/><br /><sub><b>Josh Gillies</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=joshgillies" title="Code">💻</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://secondthunder.github.io"><img src="https://avatars.githubusercontent.com/u/36604233?v=4?s=100" width="100px;" alt="Uladzislau Hramyka"/><br /><sub><b>Uladzislau Hramyka</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/issues?q=author%3ASecondThundeR" title="Bug reports">🐛</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="http://gabelluardo.github.io"><img src="https://avatars.githubusercontent.com/u/42920247?v=4?s=100" width="100px;" alt="Gabriele Belluardo"/><br /><sub><b>Gabriele Belluardo</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/issues?q=author%3Agabelluardo" title="Bug reports">🐛</a> <a href="https://github.com/grammyjs/grammY/commits?author=gabelluardo" title="Code">💻</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/dimpurr"><img src="https://avatars.githubusercontent.com/u/5173244?v=4?s=100" width="100px;" alt="Dim Chen"/><br /><sub><b>Dim Chen</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/issues?q=author%3Adimpurr" title="Bug reports">🐛</a> <a href="https://github.com/grammyjs/grammY/commits?author=dimpurr" title="Code">💻</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="http://www.fwqaq.us"><img src="https://avatars.githubusercontent.com/u/82551626?v=4?s=100" width="100px;" alt="fwqaaq"/><br /><sub><b>fwqaaq</b></sub></a><br /><a href="#ideas-fwqaaq" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/grammyjs/grammY/commits?author=fwqaaq" title="Code">💻</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/janek"><img src="https://avatars.githubusercontent.com/u/2146927?v=4?s=100" width="100px;" alt="Janek Szynal"/><br /><sub><b>Janek Szynal</b></sub></a><br /><a href="#ideas-janek" title="Ideas, Planning, & Feedback">🤔</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/mordv"><img src="https://avatars.githubusercontent.com/u/32086218?v=4?s=100" width="100px;" alt="Alexander Mordvinov"/><br /><sub><b>Alexander Mordvinov</b></sub></a><br /><a href="#ideas-mordv" title="Ideas, Planning, & Feedback">🤔</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="http://zi.vc/"><img src="https://avatars.githubusercontent.com/u/4239224?v=4?s=100" width="100px;" alt="Ash"/><br /><sub><b>Ash</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3Azivc" title="Reviewed Pull Requests">👀</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/winstxnhdw"><img src="https://avatars.githubusercontent.com/u/56998716?v=4?s=100" width="100px;" alt="Winston H."/><br /><sub><b>Winston H.</b></sub></a><br /><a href="#ideas-winstxnhdw" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/grammyjs/grammY/commits?author=winstxnhdw" title="Code">💻</a> <a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3Awinstxnhdw" title="Reviewed Pull Requests">👀</a> <a href="https://github.com/grammyjs/grammY/commits?author=winstxnhdw" title="Tests">⚠️</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/carafelix"><img src="https://avatars.githubusercontent.com/u/48109042?v=4?s=100" width="100px;" alt="Hero Protagonist"/><br /><sub><b>Hero Protagonist</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=carafelix" title="Code">💻</a> <a href="https://github.com/grammyjs/grammY/issues?q=author%3Acarafelix" title="Bug reports">🐛</a> <a href="#ideas-carafelix" title="Ideas, Planning, & Feedback">🤔</a> <a href="#plugin-carafelix" title="Plugin/utility libraries">🔌</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/MobinAskari"><img src="https://avatars.githubusercontent.com/u/132358316?v=4?s=100" width="100px;" alt="Mobin Askari"/><br /><sub><b>Mobin Askari</b></sub></a><br /><a href="#plugin-MobinAskari" title="Plugin/utility libraries">🔌</a> <a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3AMobinAskari" title="Reviewed Pull Requests">👀</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/ubertao"><img src="https://avatars.githubusercontent.com/u/4099333?v=4?s=100" width="100px;" alt="Ubertao"/><br /><sub><b>Ubertao</b></sub></a><br /><a href="#ideas-ubertao" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/grammyjs/grammY/commits?author=ubertao" title="Code">💻</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/SunsetTechuila"><img src="https://avatars.githubusercontent.com/u/115353812?v=4?s=100" width="100px;" alt="Grigory"/><br /><sub><b>Grigory</b></sub></a><br /><a href="#ideas-SunsetTechuila" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/grammyjs/grammY/commits?author=SunsetTechuila" title="Code">💻</a> <a href="https://github.com/grammyjs/grammY/commits?author=SunsetTechuila" title="Documentation">📖</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/aleveha"><img src="https://avatars.githubusercontent.com/u/63300936?v=4?s=100" width="100px;" alt="aleveha"/><br /><sub><b>aleveha</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=aleveha" title="Code">💻</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/barinbritva"><img src="https://avatars.githubusercontent.com/u/4758362?v=4?s=100" width="100px;" alt="barinbritva"/><br /><sub><b>barinbritva</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3Abarinbritva" title="Reviewed Pull Requests">👀</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/flmel"><img src="https://avatars.githubusercontent.com/u/55487633?v=4?s=100" width="100px;" alt="Lyudmil Ivanov"/><br /><sub><b>Lyudmil Ivanov</b></sub></a><br /><a href="#example-flmel" title="Examples">💡</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://consortiumkey.com/"><img src="https://avatars.githubusercontent.com/u/95214604?v=4?s=100" width="100px;" alt="lexomis"/><br /><sub><b>lexomis</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3Alexomis" title="Reviewed Pull Requests">👀</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/asologor"><img src="https://avatars.githubusercontent.com/u/97506048?v=4?s=100" width="100px;" alt="Andrew Sologor"/><br /><sub><b>Andrew Sologor</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3Aandrew-sol" title="Reviewed Pull Requests">👀</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/rayz1065"><img src="https://avatars.githubusercontent.com/u/37779815?v=4?s=100" width="100px;" alt="rayz"/><br /><sub><b>rayz</b></sub></a><br /><a href="#question-rayz1065" title="Answering Questions">💬</a> <a href="#ideas-rayz1065" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/grammyjs/grammY/commits?author=rayz1065" title="Code">💻</a> <a href="https://github.com/grammyjs/grammY/commits?author=rayz1065" title="Documentation">📖</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/z44d"><img src="https://avatars.githubusercontent.com/u/162994967?v=4?s=100" width="100px;" alt="Zaid"/><br /><sub><b>Zaid</b></sub></a><br /><a href="#tool-z44d" title="Tools">🔧</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/matmilbury"><img src="https://avatars.githubusercontent.com/u/73319876?v=4?s=100" width="100px;" alt="Mat Milbury"/><br /><sub><b>Mat Milbury</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/issues?q=author%3Amatmilbury" title="Bug reports">🐛</a> <a href="https://github.com/grammyjs/grammY/commits?author=matmilbury" title="Code">💻</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://lao.sb/"><img src="https://avatars.githubusercontent.com/u/2545261?v=4?s=100" width="100px;" alt="Shibo Lyu"/><br /><sub><b>Shibo Lyu</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=laosb" title="Code">💻</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://nometa.xyz/"><img src="https://avatars.githubusercontent.com/u/68379695?v=4?s=100" width="100px;" alt="Mased"/><br /><sub><b>Mased</b></sub></a><br /><a href="#translation-MasedMSD" title="Translation">🌍</a> <a href="https://github.com/grammyjs/grammY/commits?author=MasedMSD" title="Documentation">📖</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/ExposedCat"><img src="https://avatars.githubusercontent.com/u/44642024?v=4?s=100" width="100px;" alt="Artem Prokop"/><br /><sub><b>Artem Prokop</b></sub></a><br /><a href="#userTesting-ExposedCat" title="User Testing">📓</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://chinoman10.com/"><img src="https://avatars.githubusercontent.com/u/8300763?v=4?s=100" width="100px;" alt="Sérgio Rebelo"/><br /><sub><b>Sérgio Rebelo</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3AChinoman10" title="Reviewed Pull Requests">👀</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://blog.katsuba.dev"><img src="https://avatars.githubusercontent.com/u/10637135?v=4?s=100" width="100px;" alt="Igor Katsuba"/><br /><sub><b>Igor Katsuba</b></sub></a><br /><a href="#ideas-IKatsuba" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/grammyjs/grammY/commits?author=IKatsuba" title="Code">💻</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://tilon.uz"><img src="https://avatars.githubusercontent.com/u/105904746?v=4?s=100" width="100px;" alt="Oyatillo"/><br /><sub><b>Oyatillo</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3ABilagoNet" title="Reviewed Pull Requests">👀</a> <a href="https://github.com/grammyjs/grammY/issues?q=author%3ABilagoNet" title="Bug reports">🐛</a> <a href="https://github.com/grammyjs/grammY/commits?author=BilagoNet" title="Code">💻</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://www.vorant94.io/"><img src="https://avatars.githubusercontent.com/u/9719319?v=4?s=100" width="100px;" alt="Mordechai Dror"/><br /><sub><b>Mordechai Dror</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3Avorant94" title="Reviewed Pull Requests">👀</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/mahovich"><img src="https://avatars.githubusercontent.com/u/2377626?v=4?s=100" width="100px;" alt="mahovich"/><br /><sub><b>mahovich</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=mahovich" title="Documentation">📖</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/Hth4nh"><img src="https://avatars.githubusercontent.com/u/63627651?v=4?s=100" width="100px;" alt="Thành Hoàng Trần"/><br /><sub><b>Thành Hoàng Trần</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=Hth4nh" title="Documentation">📖</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/ikelax"><img src="https://avatars.githubusercontent.com/u/163678144?v=4?s=100" width="100px;" alt="ikelax"/><br /><sub><b>ikelax</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=ikelax" title="Documentation">📖</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="http://zeokku.com"><img src="https://avatars.githubusercontent.com/u/22231294?v=4?s=100" width="100px;" alt="Lutymane"/><br /><sub><b>Lutymane</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=Lutymane" title="Code">💻</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://thadaw.com"><img src="https://avatars.githubusercontent.com/u/3647850?v=4?s=100" width="100px;" alt="Thada Wangthammang"/><br /><sub><b>Thada Wangthammang</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/issues?q=author%3Amildronize" title="Bug reports">🐛</a> <a href="https://github.com/grammyjs/grammY/commits?author=mildronize" title="Tests">⚠️</a> <a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3Amildronize" title="Reviewed Pull Requests">👀</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/rtyt3000"><img src="https://avatars.githubusercontent.com/u/123096124?v=4?s=100" width="100px;" alt="Konstantin Ryshkov"/><br /><sub><b>Konstantin Ryshkov</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/issues?q=author%3Artyt3000" title="Bug reports">🐛</a> <a href="https://github.com/grammyjs/grammY/commits?author=rtyt3000" title="Documentation">📖</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/mishkatik"><img src="https://avatars.githubusercontent.com/u/101044644?v=4?s=100" width="100px;" alt="mish"/><br /><sub><b>mish</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/issues?q=author%3Amishkatik" title="Bug reports">🐛</a> <a href="https://github.com/grammyjs/grammY/commits?author=mishkatik" title="Code">💻</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/eddienubes"><img src="https://avatars.githubusercontent.com/u/53977359?v=4?s=100" width="100px;" alt="Dmytro Tiapukhin"/><br /><sub><b>Dmytro Tiapukhin</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=eddienubes" title="Documentation">📖</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/Arctomachine"><img src="https://avatars.githubusercontent.com/u/29041820?v=4?s=100" width="100px;" alt="Alexander"/><br /><sub><b>Alexander</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/commits?author=Arctomachine" title="Documentation">📖</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/OfficialCodinary"><img src="https://avatars.githubusercontent.com/u/133005277?v=4?s=100" width="100px;" alt="Codinary"/><br /><sub><b>Codinary</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3AOfficialCodinary" title="Reviewed Pull Requests">👀</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/dotvhs"><img src="https://avatars.githubusercontent.com/u/681416?v=4?s=100" width="100px;" alt=".vhs"/><br /><sub><b>.vhs</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/issues?q=author%3Adotvhs" title="Bug reports">🐛</a> <a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3Adotvhs" title="Reviewed Pull Requests">👀</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://agou.im/"><img src="https://avatars.githubusercontent.com/u/55237525?v=4?s=100" width="100px;" alt="agoudbg"/><br /><sub><b>agoudbg</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/issues?q=author%3Aagoudbg" title="Bug reports">🐛</a> <a href="https://github.com/grammyjs/grammY/commits?author=agoudbg" title="Code">💻</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/arunr-inji"><img src="https://avatars.githubusercontent.com/u/5071242?v=4?s=100" width="100px;" alt="ArunR"/><br /><sub><b>ArunR</b></sub></a><br /><a href="#ideas-arunr-inji" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/grammyjs/grammY/commits?author=arunr-inji" title="Code">💻</a> <a href="https://github.com/grammyjs/grammY/commits?author=arunr-inji" title="Tests">⚠️</a></td>
|
|
||||||
<td align="center" valign="top" width="11.11%"><a href="https://github.com/crwnd"><img src="https://avatars.githubusercontent.com/u/97118277?v=4?s=100" width="100px;" alt="A"/><br /><sub><b>A</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/issues?q=author%3Acrwnd" title="Bug reports">🐛</a> <a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3Acrwnd" title="Reviewed Pull Requests">👀</a></td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<!-- markdownlint-restore -->
|
|
||||||
<!-- prettier-ignore-end -->
|
|
||||||
|
|
||||||
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
|
||||||
|
|
||||||
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification.
|
|
||||||
Contributions of any kind welcome!
|
|
||||||
314
sandbox/tgbot/node_modules/grammy/out/bot.d.ts
generated
vendored
314
sandbox/tgbot/node_modules/grammy/out/bot.d.ts
generated
vendored
@@ -1,314 +0,0 @@
|
|||||||
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<Exclude<keyof Update, "update_id">>;
|
|
||||||
/**
|
|
||||||
* 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<void>;
|
|
||||||
}
|
|
||||||
export { BotError };
|
|
||||||
/**
|
|
||||||
* Error handler that can be installed on a bot to catch error thrown by
|
|
||||||
* middleware.
|
|
||||||
*/
|
|
||||||
export type ErrorHandler<C extends Context = Context> = (error: BotError<C>) => unknown;
|
|
||||||
/**
|
|
||||||
* Options to pass to the bot when creating it.
|
|
||||||
*/
|
|
||||||
export interface BotConfig<C extends Context> {
|
|
||||||
/**
|
|
||||||
* 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<typeof Context>) => 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('<secret-token>')
|
|
||||||
* // 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<C extends Context = Context, A extends Api = Api> extends Composer<C> {
|
|
||||||
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<C>;
|
|
||||||
/**
|
|
||||||
* 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<C>);
|
|
||||||
/**
|
|
||||||
* 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<Q extends FilterQuery>(filter: Q | Q[], ...middleware: Array<Middleware<Filter<C, Q>>>): Composer<Filter<C, Q>>;
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
reaction(reaction: MaybeArray<ReactionTypeEmoji["emoji"] | ReactionType>, ...middleware: Array<ReactionMiddleware<C>>): Composer<ReactionContext<C>>;
|
|
||||||
/**
|
|
||||||
* 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<void>;
|
|
||||||
/**
|
|
||||||
* 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<void>;
|
|
||||||
/**
|
|
||||||
* 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<void>;
|
|
||||||
/**
|
|
||||||
* 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<void>;
|
|
||||||
/**
|
|
||||||
* 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<C>): 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";
|
|
||||||
590
sandbox/tgbot/node_modules/grammy/out/bot.js
generated
vendored
590
sandbox/tgbot/node_modules/grammy/out/bot.js
generated
vendored
@@ -1,590 +0,0 @@
|
|||||||
"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('<secret-token>')
|
|
||||||
* // 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");
|
|
||||||
764
sandbox/tgbot/node_modules/grammy/out/composer.d.ts
generated
vendored
764
sandbox/tgbot/node_modules/grammy/out/composer.d.ts
generated
vendored
@@ -1,764 +0,0 @@
|
|||||||
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> = T | Promise<T>;
|
|
||||||
/**
|
|
||||||
* 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<void>;
|
|
||||||
/**
|
|
||||||
* Middleware in the form of a function.
|
|
||||||
*/
|
|
||||||
export type MiddlewareFn<C extends Context = Context> = (ctx: C, next: NextFunction) => MaybePromise<unknown>;
|
|
||||||
/**
|
|
||||||
* Middleware in the form of a container for a function.
|
|
||||||
*/
|
|
||||||
export interface MiddlewareObj<C extends Context = Context> {
|
|
||||||
/**
|
|
||||||
* Returns the contained middleware.
|
|
||||||
*/
|
|
||||||
middleware: () => MiddlewareFn<C>;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 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<C extends Context = Context> = MiddlewareFn<C> | MiddlewareObj<C>;
|
|
||||||
/**
|
|
||||||
* 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<C extends Context = Context> 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<C extends Context>(middleware: MiddlewareFn<C>, ctx: C): Promise<void>;
|
|
||||||
/**
|
|
||||||
* 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<C extends Context> implements MiddlewareObj<C> {
|
|
||||||
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<C>>);
|
|
||||||
middleware(): MiddlewareFn<C>;
|
|
||||||
/**
|
|
||||||
* 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<Middleware<C>>): Composer<C>;
|
|
||||||
/**
|
|
||||||
* 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<Q extends FilterQuery>(filter: Q | Q[], ...middleware: Array<Middleware<Filter<C, Q>>>): Composer<Filter<C, Q>>;
|
|
||||||
/**
|
|
||||||
* 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<string | RegExp>, ...middleware: Array<HearsMiddleware<C>>): Composer<HearsContext<C>>;
|
|
||||||
/**
|
|
||||||
* 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<StringWithCommandSuggestions>, ...middleware: Array<CommandMiddleware<C>>): Composer<CommandContext<C>>;
|
|
||||||
/**
|
|
||||||
* 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<ReactionTypeEmoji["emoji"] | ReactionType>, ...middleware: Array<ReactionMiddleware<C>>): Composer<ReactionContext<C>>;
|
|
||||||
/**
|
|
||||||
* 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<T extends Chat["type"]>(chatType: MaybeArray<T>, ...middleware: Array<Middleware<ChatTypeContext<C, T>>>): Composer<ChatTypeContext<C, T>>;
|
|
||||||
/**
|
|
||||||
* 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<string | RegExp>, ...middleware: Array<CallbackQueryMiddleware<C>>): Composer<CallbackQueryContext<C>>;
|
|
||||||
/**
|
|
||||||
* 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<string | RegExp>, ...middleware: Array<GameQueryMiddleware<C>>): Composer<GameQueryContext<C>>;
|
|
||||||
/**
|
|
||||||
* 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<string | RegExp>, ...middleware: Array<InlineQueryMiddleware<C>>): Composer<InlineQueryContext<C>>;
|
|
||||||
/**
|
|
||||||
* 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<string | RegExp>, ...middleware: Array<ChosenInlineResultMiddleware<C>>): Composer<ChosenInlineResultContext<C>>;
|
|
||||||
/**
|
|
||||||
* 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<string | RegExp>, ...middleware: Array<PreCheckoutQueryMiddleware<C>>): Composer<PreCheckoutQueryContext<C>>;
|
|
||||||
/**
|
|
||||||
* 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<string | RegExp>, ...middleware: Array<ShippingQueryMiddleware<C>>): Composer<ShippingQueryContext<C>>;
|
|
||||||
/**
|
|
||||||
* > 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<D extends C>(predicate: (ctx: C) => ctx is D, ...middleware: Array<Middleware<D>>): Composer<D>;
|
|
||||||
filter(predicate: (ctx: C) => MaybePromise<boolean>, ...middleware: Array<Middleware<C>>): Composer<C>;
|
|
||||||
/**
|
|
||||||
* > 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<boolean>, ...middleware: Array<Middleware<C>>): Composer<C>;
|
|
||||||
/**
|
|
||||||
* > 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<Middleware<C>>): Composer<C>;
|
|
||||||
/**
|
|
||||||
* > 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<MaybeArray<Middleware<C>>>): Composer<C>;
|
|
||||||
/**
|
|
||||||
* > 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<R extends Record<PropertyKey, Middleware<C>>>(router: (ctx: C) => MaybePromise<undefined | keyof R>, routeHandlers: R, fallback?: Middleware<C>): Composer<C>;
|
|
||||||
/**
|
|
||||||
* > 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<boolean>, trueMiddleware: MaybeArray<Middleware<C>>, falseMiddleware: MaybeArray<Middleware<C>>): Composer<C>;
|
|
||||||
/**
|
|
||||||
* > 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<C>, next: NextFunction) => MaybePromise<unknown>, ...middleware: Array<Middleware<C>>): Composer<C>;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 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<C extends Context> = Middleware<HearsContext<C>>;
|
|
||||||
/**
|
|
||||||
* 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<C extends Context> = Middleware<CommandContext<C>>;
|
|
||||||
/**
|
|
||||||
* 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<C extends Context> = Middleware<ReactionContext<C>>;
|
|
||||||
/**
|
|
||||||
* 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<C extends Context> = Middleware<CallbackQueryContext<C>>;
|
|
||||||
/**
|
|
||||||
* 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<C extends Context> = Middleware<GameQueryContext<C>>;
|
|
||||||
/**
|
|
||||||
* 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<C extends Context> = Middleware<InlineQueryContext<C>>;
|
|
||||||
/**
|
|
||||||
* 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<C extends Context> = Middleware<ChosenInlineResultContext<C>>;
|
|
||||||
/**
|
|
||||||
* 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<C extends Context> = Middleware<PreCheckoutQueryContext<C>>;
|
|
||||||
/**
|
|
||||||
* 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<C extends Context> = Middleware<ShippingQueryContext<C>>;
|
|
||||||
/**
|
|
||||||
* 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<C extends Context, T extends Chat["type"]> = Middleware<ChatTypeContext<C, T>>;
|
|
||||||
export {};
|
|
||||||
704
sandbox/tgbot/node_modules/grammy/out/composer.js
generated
vendored
704
sandbox/tgbot/node_modules/grammy/out/composer.js
generated
vendored
@@ -1,704 +0,0 @@
|
|||||||
"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;
|
|
||||||
1878
sandbox/tgbot/node_modules/grammy/out/context.d.ts
generated
vendored
1878
sandbox/tgbot/node_modules/grammy/out/context.d.ts
generated
vendored
File diff suppressed because it is too large
Load Diff
2481
sandbox/tgbot/node_modules/grammy/out/context.js
generated
vendored
2481
sandbox/tgbot/node_modules/grammy/out/context.js
generated
vendored
File diff suppressed because it is too large
Load Diff
98
sandbox/tgbot/node_modules/grammy/out/convenience/constants.d.ts
generated
vendored
98
sandbox/tgbot/node_modules/grammy/out/convenience/constants.d.ts
generated
vendored
@@ -1,98 +0,0 @@
|
|||||||
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<T> = {
|
|
||||||
[K in keyof T]: K extends keyof TypeOf ? Readonly<TypeOf[K]> : 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<ApiConstants>;
|
|
||||||
export {};
|
|
||||||
37
sandbox/tgbot/node_modules/grammy/out/convenience/constants.js
generated
vendored
37
sandbox/tgbot/node_modules/grammy/out/convenience/constants.js
generated
vendored
@@ -1,37 +0,0 @@
|
|||||||
"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);
|
|
||||||
226
sandbox/tgbot/node_modules/grammy/out/convenience/frameworks.d.ts
generated
vendored
226
sandbox/tgbot/node_modules/grammy/out/convenience/frameworks.d.ts
generated
vendored
@@ -1,226 +0,0 @@
|
|||||||
import { type Update } from "../types.js";
|
|
||||||
type MaybePromise<T> = T | Promise<T>;
|
|
||||||
/**
|
|
||||||
* 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<T = void> {
|
|
||||||
/**
|
|
||||||
* The update object sent from Telegram, usually resolves the request's JSON
|
|
||||||
* body
|
|
||||||
*/
|
|
||||||
update: MaybePromise<Update>;
|
|
||||||
/**
|
|
||||||
* 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<unknown>;
|
|
||||||
/**
|
|
||||||
* Responds that the request is unauthorized due to mismatching
|
|
||||||
* X-Telegram-Bot-Api-Secret-Token headers
|
|
||||||
*/
|
|
||||||
unauthorized: () => unknown | Promise<unknown>;
|
|
||||||
/**
|
|
||||||
* Some frameworks (e.g. Deno's std/http `listenAndServe`) assume that
|
|
||||||
* handler returns something
|
|
||||||
*/
|
|
||||||
handlerReturn?: Promise<T>;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 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<any>;
|
|
||||||
export type LambdaAdapter = (event: {
|
|
||||||
body?: string;
|
|
||||||
headers: Record<string, string | undefined>;
|
|
||||||
}, _context: unknown, callback: (arg0: unknown, arg1: Record<string, unknown>) => Promise<unknown>) => ReqResHandler;
|
|
||||||
export type LambdaAsyncAdapter = (event: {
|
|
||||||
body?: string;
|
|
||||||
headers: Record<string, string | undefined>;
|
|
||||||
}, _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<unknown>;
|
|
||||||
}) => ReqResHandler<{
|
|
||||||
status: number;
|
|
||||||
body?: string;
|
|
||||||
} | {
|
|
||||||
jsonBody: string;
|
|
||||||
}>;
|
|
||||||
export type BunAdapter = (request: {
|
|
||||||
headers: Headers;
|
|
||||||
json: () => Promise<unknown>;
|
|
||||||
}) => ReqResHandler<Response>;
|
|
||||||
export type CloudflareAdapter = (event: {
|
|
||||||
request: Body & {
|
|
||||||
method: string;
|
|
||||||
url: string;
|
|
||||||
headers: Headers;
|
|
||||||
};
|
|
||||||
respondWith: (response: Promise<Response>) => void;
|
|
||||||
}) => ReqResHandler;
|
|
||||||
export type CloudflareModuleAdapter = (request: Body & {
|
|
||||||
method: string;
|
|
||||||
url: string;
|
|
||||||
headers: Headers;
|
|
||||||
}) => ReqResHandler<Response>;
|
|
||||||
export type ElysiaAdapter = (ctx: {
|
|
||||||
body: unknown;
|
|
||||||
headers: Record<string, string | undefined>;
|
|
||||||
set: {
|
|
||||||
headers: Record<string, string | number>;
|
|
||||||
status?: string | number;
|
|
||||||
};
|
|
||||||
}) => ReqResHandler<string>;
|
|
||||||
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<string, string>) => typeof reply;
|
|
||||||
code: (code: number) => typeof reply;
|
|
||||||
send: {
|
|
||||||
(): typeof reply;
|
|
||||||
(json: string): typeof reply;
|
|
||||||
};
|
|
||||||
}) => ReqResHandler;
|
|
||||||
export type HonoAdapter = (c: {
|
|
||||||
req: {
|
|
||||||
json: <T>() => Promise<T>;
|
|
||||||
header: (header: string) => string | undefined;
|
|
||||||
};
|
|
||||||
body(data: string): Response;
|
|
||||||
body(data: null, status: 204): Response;
|
|
||||||
status: (status: any) => void;
|
|
||||||
json: (json: string) => Response;
|
|
||||||
}) => ReqResHandler<Response>;
|
|
||||||
export type HttpAdapter = (req: {
|
|
||||||
headers: Record<string, string | string[] | undefined>;
|
|
||||||
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<string, string>): 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<string, string | string[] | undefined>;
|
|
||||||
}, 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<Update>;
|
|
||||||
};
|
|
||||||
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<Response>;
|
|
||||||
export type SveltekitAdapter = ({ request }: {
|
|
||||||
request: Request;
|
|
||||||
}) => ReqResHandler<unknown>;
|
|
||||||
export type WorktopAdapter = (req: {
|
|
||||||
json: () => Promise<Update>;
|
|
||||||
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 {};
|
|
||||||
393
sandbox/tgbot/node_modules/grammy/out/convenience/frameworks.js
generated
vendored
393
sandbox/tgbot/node_modules/grammy/out/convenience/frameworks.js
generated
vendored
@@ -1,393 +0,0 @@
|
|||||||
"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<string>();
|
|
||||||
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,
|
|
||||||
};
|
|
||||||
401
sandbox/tgbot/node_modules/grammy/out/convenience/inline_query.d.ts
generated
vendored
401
sandbox/tgbot/node_modules/grammy/out/convenience/inline_query.d.ts
generated
vendored
@@ -1,401 +0,0 @@
|
|||||||
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<T, K extends keyof T> = Omit<T, "type" | "id" | "input_message_content" | K>;
|
|
||||||
type OptionalKeys<T> = {
|
|
||||||
[K in keyof T]-?: undefined extends T[K] ? K : never;
|
|
||||||
};
|
|
||||||
type OptionalFields<T> = Pick<T, OptionalKeys<T>[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<InlineQueryResultArticle, "title">): {
|
|
||||||
text(message_text: string, options?: OptionalFields<InputTextMessageContent>): InlineQueryResultArticle;
|
|
||||||
location(latitude: number, longitude: number, options?: OptionalFields<InputLocationMessageContent>): InlineQueryResultArticle;
|
|
||||||
venue(title: string, latitude: number, longitude: number, address: string, options: OptionalFields<InputVenueMessageContent>): InlineQueryResultArticle;
|
|
||||||
contact(first_name: string, phone_number: string, options?: OptionalFields<InputContactMessageContent>): InlineQueryResultArticle;
|
|
||||||
invoice(title: string, description: string, payload: string, provider_token: string, currency: string, prices: LabeledPrice[], options?: OptionalFields<InputInvoiceMessageContent>): 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, "title" | "audio_url">): InlineQueryResultAudio & {
|
|
||||||
text(message_text: string, options?: OptionalFields<InputTextMessageContent>): InlineQueryResultAudio;
|
|
||||||
location(latitude: number, longitude: number, options?: OptionalFields<InputLocationMessageContent>): InlineQueryResultAudio;
|
|
||||||
venue(title: string, latitude: number, longitude: number, address: string, options: OptionalFields<InputVenueMessageContent>): InlineQueryResultAudio;
|
|
||||||
contact(first_name: string, phone_number: string, options?: OptionalFields<InputContactMessageContent>): InlineQueryResultAudio;
|
|
||||||
invoice(title: string, description: string, payload: string, provider_token: string, currency: string, prices: LabeledPrice[], options?: OptionalFields<InputInvoiceMessageContent>): 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, "audio_file_id">): InlineQueryResultCachedAudio & {
|
|
||||||
text(message_text: string, options?: OptionalFields<InputTextMessageContent>): InlineQueryResultCachedAudio;
|
|
||||||
location(latitude: number, longitude: number, options?: OptionalFields<InputLocationMessageContent>): InlineQueryResultCachedAudio;
|
|
||||||
venue(title: string, latitude: number, longitude: number, address: string, options: OptionalFields<InputVenueMessageContent>): InlineQueryResultCachedAudio;
|
|
||||||
contact(first_name: string, phone_number: string, options?: OptionalFields<InputContactMessageContent>): InlineQueryResultCachedAudio;
|
|
||||||
invoice(title: string, description: string, payload: string, provider_token: string, currency: string, prices: LabeledPrice[], options?: OptionalFields<InputInvoiceMessageContent>): 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, "phone_number" | "first_name">): InlineQueryResultContact & {
|
|
||||||
text(message_text: string, options?: OptionalFields<InputTextMessageContent>): InlineQueryResultContact;
|
|
||||||
location(latitude: number, longitude: number, options?: OptionalFields<InputLocationMessageContent>): InlineQueryResultContact;
|
|
||||||
venue(title: string, latitude: number, longitude: number, address: string, options: OptionalFields<InputVenueMessageContent>): InlineQueryResultContact;
|
|
||||||
contact(first_name: string, phone_number: string, options?: OptionalFields<InputContactMessageContent>): InlineQueryResultContact;
|
|
||||||
invoice(title: string, description: string, payload: string, provider_token: string, currency: string, prices: LabeledPrice[], options?: OptionalFields<InputInvoiceMessageContent>): 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, "mime_type" | "title" | "document_url">): InlineQueryResultDocument & {
|
|
||||||
text(message_text: string, options?: OptionalFields<InputTextMessageContent>): InlineQueryResultDocument;
|
|
||||||
location(latitude: number, longitude: number, options?: OptionalFields<InputLocationMessageContent>): InlineQueryResultDocument;
|
|
||||||
venue(title: string, latitude: number, longitude: number, address: string, options: OptionalFields<InputVenueMessageContent>): InlineQueryResultDocument;
|
|
||||||
contact(first_name: string, phone_number: string, options?: OptionalFields<InputContactMessageContent>): InlineQueryResultDocument;
|
|
||||||
invoice(title: string, description: string, payload: string, provider_token: string, currency: string, prices: LabeledPrice[], options?: OptionalFields<InputInvoiceMessageContent>): 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, "mime_type" | "title" | "document_url">): InlineQueryResultDocument & {
|
|
||||||
text(message_text: string, options?: OptionalFields<InputTextMessageContent>): InlineQueryResultDocument;
|
|
||||||
location(latitude: number, longitude: number, options?: OptionalFields<InputLocationMessageContent>): InlineQueryResultDocument;
|
|
||||||
venue(title: string, latitude: number, longitude: number, address: string, options: OptionalFields<InputVenueMessageContent>): InlineQueryResultDocument;
|
|
||||||
contact(first_name: string, phone_number: string, options?: OptionalFields<InputContactMessageContent>): InlineQueryResultDocument;
|
|
||||||
invoice(title: string, description: string, payload: string, provider_token: string, currency: string, prices: LabeledPrice[], options?: OptionalFields<InputInvoiceMessageContent>): 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, "title" | "document_file_id">): InlineQueryResultCachedDocument & {
|
|
||||||
text(message_text: string, options?: OptionalFields<InputTextMessageContent>): InlineQueryResultCachedDocument;
|
|
||||||
location(latitude: number, longitude: number, options?: OptionalFields<InputLocationMessageContent>): InlineQueryResultCachedDocument;
|
|
||||||
venue(title: string, latitude: number, longitude: number, address: string, options: OptionalFields<InputVenueMessageContent>): InlineQueryResultCachedDocument;
|
|
||||||
contact(first_name: string, phone_number: string, options?: OptionalFields<InputContactMessageContent>): InlineQueryResultCachedDocument;
|
|
||||||
invoice(title: string, description: string, payload: string, provider_token: string, currency: string, prices: LabeledPrice[], options?: OptionalFields<InputInvoiceMessageContent>): 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<InlineQueryResultGame, "game_short_name">): {
|
|
||||||
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, "gif_url" | "thumbnail_url">): InlineQueryResultGif & {
|
|
||||||
text(message_text: string, options?: OptionalFields<InputTextMessageContent>): InlineQueryResultGif;
|
|
||||||
location(latitude: number, longitude: number, options?: OptionalFields<InputLocationMessageContent>): InlineQueryResultGif;
|
|
||||||
venue(title: string, latitude: number, longitude: number, address: string, options: OptionalFields<InputVenueMessageContent>): InlineQueryResultGif;
|
|
||||||
contact(first_name: string, phone_number: string, options?: OptionalFields<InputContactMessageContent>): InlineQueryResultGif;
|
|
||||||
invoice(title: string, description: string, payload: string, provider_token: string, currency: string, prices: LabeledPrice[], options?: OptionalFields<InputInvoiceMessageContent>): 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, "gif_file_id">): InlineQueryResultCachedGif & {
|
|
||||||
text(message_text: string, options?: OptionalFields<InputTextMessageContent>): InlineQueryResultCachedGif;
|
|
||||||
location(latitude: number, longitude: number, options?: OptionalFields<InputLocationMessageContent>): InlineQueryResultCachedGif;
|
|
||||||
venue(title: string, latitude: number, longitude: number, address: string, options: OptionalFields<InputVenueMessageContent>): InlineQueryResultCachedGif;
|
|
||||||
contact(first_name: string, phone_number: string, options?: OptionalFields<InputContactMessageContent>): InlineQueryResultCachedGif;
|
|
||||||
invoice(title: string, description: string, payload: string, provider_token: string, currency: string, prices: LabeledPrice[], options?: OptionalFields<InputInvoiceMessageContent>): 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, "title" | "latitude" | "longitude">): InlineQueryResultLocation & {
|
|
||||||
text(message_text: string, options?: OptionalFields<InputTextMessageContent>): InlineQueryResultLocation;
|
|
||||||
location(latitude: number, longitude: number, options?: OptionalFields<InputLocationMessageContent>): InlineQueryResultLocation;
|
|
||||||
venue(title: string, latitude: number, longitude: number, address: string, options: OptionalFields<InputVenueMessageContent>): InlineQueryResultLocation;
|
|
||||||
contact(first_name: string, phone_number: string, options?: OptionalFields<InputContactMessageContent>): InlineQueryResultLocation;
|
|
||||||
invoice(title: string, description: string, payload: string, provider_token: string, currency: string, prices: LabeledPrice[], options?: OptionalFields<InputInvoiceMessageContent>): 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, "mpeg4_url" | "thumbnail_url">): InlineQueryResultMpeg4Gif & {
|
|
||||||
text(message_text: string, options?: OptionalFields<InputTextMessageContent>): InlineQueryResultMpeg4Gif;
|
|
||||||
location(latitude: number, longitude: number, options?: OptionalFields<InputLocationMessageContent>): InlineQueryResultMpeg4Gif;
|
|
||||||
venue(title: string, latitude: number, longitude: number, address: string, options: OptionalFields<InputVenueMessageContent>): InlineQueryResultMpeg4Gif;
|
|
||||||
contact(first_name: string, phone_number: string, options?: OptionalFields<InputContactMessageContent>): InlineQueryResultMpeg4Gif;
|
|
||||||
invoice(title: string, description: string, payload: string, provider_token: string, currency: string, prices: LabeledPrice[], options?: OptionalFields<InputInvoiceMessageContent>): 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, "mpeg4_file_id">): InlineQueryResultCachedMpeg4Gif & {
|
|
||||||
text(message_text: string, options?: OptionalFields<InputTextMessageContent>): InlineQueryResultCachedMpeg4Gif;
|
|
||||||
location(latitude: number, longitude: number, options?: OptionalFields<InputLocationMessageContent>): InlineQueryResultCachedMpeg4Gif;
|
|
||||||
venue(title: string, latitude: number, longitude: number, address: string, options: OptionalFields<InputVenueMessageContent>): InlineQueryResultCachedMpeg4Gif;
|
|
||||||
contact(first_name: string, phone_number: string, options?: OptionalFields<InputContactMessageContent>): InlineQueryResultCachedMpeg4Gif;
|
|
||||||
invoice(title: string, description: string, payload: string, provider_token: string, currency: string, prices: LabeledPrice[], options?: OptionalFields<InputInvoiceMessageContent>): 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, "photo_url">): InlineQueryResultPhoto & {
|
|
||||||
text(message_text: string, options?: OptionalFields<InputTextMessageContent>): InlineQueryResultPhoto;
|
|
||||||
location(latitude: number, longitude: number, options?: OptionalFields<InputLocationMessageContent>): InlineQueryResultPhoto;
|
|
||||||
venue(title: string, latitude: number, longitude: number, address: string, options: OptionalFields<InputVenueMessageContent>): InlineQueryResultPhoto;
|
|
||||||
contact(first_name: string, phone_number: string, options?: OptionalFields<InputContactMessageContent>): InlineQueryResultPhoto;
|
|
||||||
invoice(title: string, description: string, payload: string, provider_token: string, currency: string, prices: LabeledPrice[], options?: OptionalFields<InputInvoiceMessageContent>): 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, "photo_file_id">): InlineQueryResultCachedPhoto & {
|
|
||||||
text(message_text: string, options?: OptionalFields<InputTextMessageContent>): InlineQueryResultCachedPhoto;
|
|
||||||
location(latitude: number, longitude: number, options?: OptionalFields<InputLocationMessageContent>): InlineQueryResultCachedPhoto;
|
|
||||||
venue(title: string, latitude: number, longitude: number, address: string, options: OptionalFields<InputVenueMessageContent>): InlineQueryResultCachedPhoto;
|
|
||||||
contact(first_name: string, phone_number: string, options?: OptionalFields<InputContactMessageContent>): InlineQueryResultCachedPhoto;
|
|
||||||
invoice(title: string, description: string, payload: string, provider_token: string, currency: string, prices: LabeledPrice[], options?: OptionalFields<InputInvoiceMessageContent>): 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, "sticker_file_id">): InlineQueryResultCachedSticker & {
|
|
||||||
text(message_text: string, options?: OptionalFields<InputTextMessageContent>): InlineQueryResultCachedSticker;
|
|
||||||
location(latitude: number, longitude: number, options?: OptionalFields<InputLocationMessageContent>): InlineQueryResultCachedSticker;
|
|
||||||
venue(title: string, latitude: number, longitude: number, address: string, options: OptionalFields<InputVenueMessageContent>): InlineQueryResultCachedSticker;
|
|
||||||
contact(first_name: string, phone_number: string, options?: OptionalFields<InputContactMessageContent>): InlineQueryResultCachedSticker;
|
|
||||||
invoice(title: string, description: string, payload: string, provider_token: string, currency: string, prices: LabeledPrice[], options?: OptionalFields<InputInvoiceMessageContent>): 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, "title" | "latitude" | "longitude" | "address">): InlineQueryResultVenue & {
|
|
||||||
text(message_text: string, options?: OptionalFields<InputTextMessageContent>): InlineQueryResultVenue;
|
|
||||||
location(latitude: number, longitude: number, options?: OptionalFields<InputLocationMessageContent>): InlineQueryResultVenue;
|
|
||||||
venue(title: string, latitude: number, longitude: number, address: string, options: OptionalFields<InputVenueMessageContent>): InlineQueryResultVenue;
|
|
||||||
contact(first_name: string, phone_number: string, options?: OptionalFields<InputContactMessageContent>): InlineQueryResultVenue;
|
|
||||||
invoice(title: string, description: string, payload: string, provider_token: string, currency: string, prices: LabeledPrice[], options?: OptionalFields<InputInvoiceMessageContent>): 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<InlineQueryResultVideo, "mime_type" | "title" | "video_url" | "thumbnail_url">): {
|
|
||||||
text(message_text: string, options?: OptionalFields<InputTextMessageContent>): InlineQueryResultVideo;
|
|
||||||
location(latitude: number, longitude: number, options?: OptionalFields<InputLocationMessageContent>): InlineQueryResultVideo;
|
|
||||||
venue(title: string, latitude: number, longitude: number, address: string, options: OptionalFields<InputVenueMessageContent>): InlineQueryResultVideo;
|
|
||||||
contact(first_name: string, phone_number: string, options?: OptionalFields<InputContactMessageContent>): InlineQueryResultVideo;
|
|
||||||
invoice(title: string, description: string, payload: string, provider_token: string, currency: string, prices: LabeledPrice[], options?: OptionalFields<InputInvoiceMessageContent>): 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, "mime_type" | "title" | "video_url" | "thumbnail_url">): InlineQueryResultVideo & {
|
|
||||||
text(message_text: string, options?: OptionalFields<InputTextMessageContent>): InlineQueryResultVideo;
|
|
||||||
location(latitude: number, longitude: number, options?: OptionalFields<InputLocationMessageContent>): InlineQueryResultVideo;
|
|
||||||
venue(title: string, latitude: number, longitude: number, address: string, options: OptionalFields<InputVenueMessageContent>): InlineQueryResultVideo;
|
|
||||||
contact(first_name: string, phone_number: string, options?: OptionalFields<InputContactMessageContent>): InlineQueryResultVideo;
|
|
||||||
invoice(title: string, description: string, payload: string, provider_token: string, currency: string, prices: LabeledPrice[], options?: OptionalFields<InputInvoiceMessageContent>): 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, "title" | "video_file_id">): InlineQueryResultCachedVideo & {
|
|
||||||
text(message_text: string, options?: OptionalFields<InputTextMessageContent>): InlineQueryResultCachedVideo;
|
|
||||||
location(latitude: number, longitude: number, options?: OptionalFields<InputLocationMessageContent>): InlineQueryResultCachedVideo;
|
|
||||||
venue(title: string, latitude: number, longitude: number, address: string, options: OptionalFields<InputVenueMessageContent>): InlineQueryResultCachedVideo;
|
|
||||||
contact(first_name: string, phone_number: string, options?: OptionalFields<InputContactMessageContent>): InlineQueryResultCachedVideo;
|
|
||||||
invoice(title: string, description: string, payload: string, provider_token: string, currency: string, prices: LabeledPrice[], options?: OptionalFields<InputInvoiceMessageContent>): 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, "title" | "voice_url">): InlineQueryResultVoice & {
|
|
||||||
text(message_text: string, options?: OptionalFields<InputTextMessageContent>): InlineQueryResultVoice;
|
|
||||||
location(latitude: number, longitude: number, options?: OptionalFields<InputLocationMessageContent>): InlineQueryResultVoice;
|
|
||||||
venue(title: string, latitude: number, longitude: number, address: string, options: OptionalFields<InputVenueMessageContent>): InlineQueryResultVoice;
|
|
||||||
contact(first_name: string, phone_number: string, options?: OptionalFields<InputContactMessageContent>): InlineQueryResultVoice;
|
|
||||||
invoice(title: string, description: string, payload: string, provider_token: string, currency: string, prices: LabeledPrice[], options?: OptionalFields<InputInvoiceMessageContent>): 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, "title" | "voice_file_id">): InlineQueryResultCachedVoice & {
|
|
||||||
text(message_text: string, options?: OptionalFields<InputTextMessageContent>): InlineQueryResultCachedVoice;
|
|
||||||
location(latitude: number, longitude: number, options?: OptionalFields<InputLocationMessageContent>): InlineQueryResultCachedVoice;
|
|
||||||
venue(title: string, latitude: number, longitude: number, address: string, options: OptionalFields<InputVenueMessageContent>): InlineQueryResultCachedVoice;
|
|
||||||
contact(first_name: string, phone_number: string, options?: OptionalFields<InputContactMessageContent>): InlineQueryResultCachedVoice;
|
|
||||||
invoice(title: string, description: string, payload: string, provider_token: string, currency: string, prices: LabeledPrice[], options?: OptionalFields<InputInvoiceMessageContent>): InlineQueryResultCachedVoice;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
export {};
|
|
||||||
461
sandbox/tgbot/node_modules/grammy/out/convenience/inline_query.js
generated
vendored
461
sandbox/tgbot/node_modules/grammy/out/convenience/inline_query.js
generated
vendored
@@ -1,461 +0,0 @@
|
|||||||
"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 });
|
|
||||||
},
|
|
||||||
};
|
|
||||||
72
sandbox/tgbot/node_modules/grammy/out/convenience/input_media.d.ts
generated
vendored
72
sandbox/tgbot/node_modules/grammy/out/convenience/input_media.d.ts
generated
vendored
@@ -1,72 +0,0 @@
|
|||||||
import { type InputFile, type InputMediaAnimation, type InputMediaAudio, type InputMediaDocument, type InputMediaPhoto, type InputMediaVideo } from "../types.js";
|
|
||||||
type InputMediaOptions<T> = Omit<T, "type" | "media">;
|
|
||||||
/**
|
|
||||||
* 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>): 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>): 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>): 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>): 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>): InputMediaDocument;
|
|
||||||
};
|
|
||||||
export {};
|
|
||||||
82
sandbox/tgbot/node_modules/grammy/out/convenience/input_media.js
generated
vendored
82
sandbox/tgbot/node_modules/grammy/out/convenience/input_media.js
generated
vendored
@@ -1,82 +0,0 @@
|
|||||||
"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 };
|
|
||||||
},
|
|
||||||
};
|
|
||||||
879
sandbox/tgbot/node_modules/grammy/out/convenience/keyboard.d.ts
generated
vendored
879
sandbox/tgbot/node_modules/grammy/out/convenience/keyboard.d.ts
generated
vendored
@@ -1,879 +0,0 @@
|
|||||||
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<KeyboardButton.CommonButton, "text">): 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, "text">): 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<KeyboardButtonRequestUsers, "request_id">): 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<KeyboardButtonRequestUsers, "request_id">): 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<KeyboardButtonRequestChat, "request_id">): 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<KeyboardButtonRequestChat, "request_id">): 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=<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=<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 {};
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user