Token导航 LogoToken导航TokenDH.com
研究检索需要联网github未标认证来源可访问许可证需确认审计提醒

gramiogramio 搜索

Agent Skill

gramio 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

3,684

周安装

152

GitHub Stars

7

下载量

1,204
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:gramio(gramio 搜索)
来源仓库:https://github.com/gramiojs/documentation
仓库路径:skills/gramio
安装命令:
npx skills add https://github.com/gramiojs/documentation --skill gramio
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/gramiojs/documentation --skill gramio

简介

gramio 用于查找、检索和筛选相关信息,支持基于关键词快速定位内容。

  • 适用于 Codex、Claude、Cursor、Gemini CLI 中的研究检索场景。
  • 通过 npx skills add 从 GitHub 仓库安装并使用。
  • 安装前需确认权限范围、维护状态及是否触发联网或文件读写。
  • 建议结合原始 README 继续核验具体用法和功能细节。

SKILL.md

GramIO

GramIO is a modern, type-safe Telegram Bot API framework for TypeScript. It runs on Node.js, Bun, and Deno with full Bot API coverage, a composable plugin system, and first-class TypeScript support.

When to Use This Skill

  • Creating or modifying Telegram bots
  • Setting up bot commands, callbacks, inline queries, or reactions
  • Building keyboards (reply, inline, remove, force reply)
  • Formatting messages with entities (bold, italic, code, links, mentions)
  • Uploading/downloading files and media
  • Managing user sessions or multi-step conversation flows (scenes)
  • Writing custom plugins
  • Configuring webhooks or long polling
  • Handling payments with Telegram Stars
  • Broadcasting messages with rate limit handling
  • Building Telegram Mini Apps (TMA) with backend auth
  • Containerizing bots with Docker
  • Using standalone @gramio/types for custom Bot API wrappers
  • Writing and publishing custom plugins
  • Migrating bots from puregram, grammY, Telegraf, or node-telegram-bot-api to GramIO

Quick Start

npm create gramio bot-name
cd bot-name
npm run dev

Basic Pattern

import { Bot } from "gramio";

const bot = new Bot(process.env.BOT_TOKEN as string)
    .command("start", (context) => context.send("Hello!"))
    .onStart(({ info }) => console.log(`@${info.username} started`))
    .onError(({ context, kind, error }) => console.error(`[${kind}]`, error));

bot.start();

Introspection Tools

This skill ships four Node.js scripts under tools/ that parse the installed @gramio/* and gramio packages on disk. Prefer these over URL-fetching or loading the telegram-api-index — each call returns one focused, version-accurate signature instead of a wall of docs.

Run from the user's project root (where node_modules/ lives). Tools print to stdout; errors and auto-correct hints go to stderr.

ToolUse it when
tools/get-bot-api-method.mjs <name>You need the signature of a Bot API method (e.g. sendMessage, createChatInviteLink) — returns JSDoc + params/return type from @gramio/types. --list shows all methods, --search <term> filters by name/description.
tools/get-bot-api-type.mjs <name>You need a Telegram type definition (e.g. Message, ChatInviteLink). Accepts short (Message) or full (TelegramMessage) names. Same --list / --search flags.
tools/get-context-getter.mjs <ClassName>You need to know what getters/methods a context exposes (MessageContext, CallbackQueryContext, User, Chat). Add --deep to pull in mixins + merged interfaces recursively. --search <name> finds every class that exposes a given getter/method (e.g. firstName lives on User, Chat, Contact, SharedUser).
tools/get-plugin.mjs <name>You need a plugin's entry function signature + what it derives onto context (e.g. session, scenes, i18n). --list shows every installed @gramio/* package.
node tools/get-bot-api-method.mjs sendMessage
node tools/get-bot-api-type.mjs InlineKeyboardMarkup
node tools/get-context-getter.mjs MessageContext --deep
node tools/get-context-getter.mjs --search chatId
node tools/get-plugin.mjs session

The scripts fuzzy-match (sendMesagesendMessage) and suggest alternatives on miss. They require the relevant package to be installed — if not, they print the exact npm install hint.

Critical Concepts

  1. Callback routing — NEVER parse callback data manually. CallbackData.pack() produces a 6-character hash prefix (sha1-base64url of the schema name) + serialized payload — NOT a literal prefix like "nav:". Checks like ctx.data.startsWith("nav:") always fail at runtime. Use one of these four patterns, picked by shape of data: ` // Fixed string → exact string match bot.callbackQuery("refresh", (ctx) => ctx.answer("Refreshed")); // Pattern / variable slug → RegExp with capture groups bot.callbackQuery(/^user_(\d+)$/, (ctx) => {const [, id] = ctx.match!; ctx.answer(User ${id});}); // Structured data → CallbackData schema (preferred for multi-field payloads) import {CallbackData} from "gramio"; const nav = new CallbackData("nav").enum("to", ["home", "history", "admin"]); bot.callbackQuery(nav, (ctx) => {ctx.queryData.to; // "home" | "history" | "admin" — fully typed}); // Stale-safe unpack (when inline keyboard may outlive a schema change) const result = nav.safeUnpack(ctx.data!); if (!result.success) return ctx.answer("Button expired"); result.data.to; // typed // ❌ NEVER — hashed prefix means string compare won't match, // and you lose full type safety. if (ctx.data?.startsWith("nav:")) {const [, to] = ctx.data.slice(4).split(":"); //...}` See callback-data and middleware-routing for overlapping-handler behavior across plugins.
  2. Method chaining — handlers, hooks, and plugins chain via .command(), .on(), .extend(), etc. Order matters: when two handlers match the same update, the first-registered one wins unless it calls next(). See middleware-routing.
  3. Type-safe context — context is automatically typed based on the update type. Use context.is("message") for type narrowing in generic handlers. After .derive()/.decorate()/.extend(plugin), new fields appear on the inferred context type automatically — never cast with ctx as unknown as {myField}. Export the bot's context type and reuse it (see context → "Context typing after derive").
  4. **Context getters — always camelCase; never touch ctx.payload or ctx.update.*** — every Telegram field is exposed as a camelCase getter (ctx.from, ctx.firstName, ctx.chatId, ctx.messageId, ctx.text, ctx.data, ctx.queryData). Both ctx.payload AND ctx.update are raw snake_case internal objects — treat them as off-limits in handler code.
  5. Plugin systemnew Plugin("name").derive(() => ({...})) adds typed properties to context. Register via bot.extend(plugin).
  6. Hooks lifecycle — onStart → (updates with onError) → onStop. API calls: preRequest → call → onResponse/onResponseError.
  7. Error suppressionbot.api.method({suppress: true}) returns error instead of throwing.
  8. Lazy plugins — async plugins (without await) load at bot.start(). Use await for immediate loading.
  9. Derive vs Decorate.derive() runs per-update (computed), .decorate() injects static values once.
  10. Formatting — four critical rules (read formatting before writing any message text):

- Never use parse_modeformat produces MessageEntity arrays, not HTML/Markdown strings. Adding parse_mode: "HTML" or "MarkdownV2" will break the message. GramIO passes entities automatically. - Never use native .join() on arrays of formatted values — it calls .toString() on each Formattable, silently destroying all styling. Always use the join helper: join(items, (x) => bold(x), "\n"). - Always wrap styled content in format\`` when composing or reusing — embedding aFormattable` in a plain template literal ( `${boldx}` ) strips all entities. Use `format${boldx}` instead. - **Never call .toString() on a FormattableString** — pass it directly as the text:/caption: param to send, editMessageText, editMessageCaption, etc. Calling .toString()` strips all entities. This is the #1 reason magic-links and formatted entities "stop working" after an edit.

  1. Scenes — step semantics and update-type filteringcontext.scene.step.go(N) and context.scene.step.next() run the scene's middleware chain immediately, but each .step(updateName, handler) filters by context.is(updateName). If your current context is callback_query and the next step is .step("message", …), it will not fire — you must either send the UI directly before return step.next(), use .step(["message", "callback_query"], …), or render the prompt in onEnter / the current step's callback handler. Prefer .ask("field", zodSchema, "prompt") for single-value validated input. See scenes.
  2. InlineQueryResult builders — use InlineQueryResult.article(id, title, InputMessageContent.text(...)) and similar builder methods for inline results. bot.inlineQuery(/regex/, handler) routes inline queries. See triggers.
  3. Composing screens — prefer @gramio/views over inline ctx.send / ctx.editText — for any bot with more than a couple of screens, use the @gramio/views plugin to define reusable view templates and render them with context.render(view, params). It auto-detects send-vs-edit based on update type, centralises text/keyboards/media (incl. JSON-driven templates with {{param}} / {{$global}} interpolation and i18n via adapter factory), and eliminates the common failure mode of duplicating message bodies across ctx.send(...) and ctx.editText(...) call sites. The plain render-function pattern is fine for trivial menu-only bots (2-3 screens, no media, no i18n) — anything more graduates to @gramio/views. @gramio/views is marked work-in-progress (helper/adapter details may evolve), but the core shape (initViewsBuilder, .render(fn), context.render(...)) is stable and is the recommended direction for view composition in GramIO. See views.
  4. @gramio/prompt is in-memory only — NOT persistent. Use Scenes + .ask() for any multi-step / connect / onboarding flow. The Promise returned by context.prompt(...) / context.wait(...) lives in the current Node.js process. The moment the process restarts (deploy, crash, container reschedule, dyno cycling), the Promise is gone: the user's next message is not treated as an answer, no error is thrown, the bot silently "forgets" where the user was. This is fatal for OAuth-connect flows (Spotify/Last.fm/etc.), onboarding wizards, payment collection, any question-sequence that must survive a deploy. Scenes, by contrast, persist step index and collected answers in the configured storage (Redis / Cloudflare / custom) and rehydrate on the next update. Rule: @gramio/prompt is acceptable only for single-question, in-process prompts where losing the flow on restart is acceptable (e.g. throwaway confirmations, debug helpers). Every question-sequence that matters — and every "ask → validate → ask again" connect flow — belongs in a Scene with .ask("field", zodSchema, "prompt message"). .ask() kills the same firstTime branching and validation-retry boilerplate as prompt, plus it persists. Do not recommend @gramio/prompt as a simpler alternative to scenes for multi-step flows; that is the recommendation trap this concept exists to block. See scenes and prompt.
  5. Subagent delegation — skills do not auto-activate inside subagent sessions. When spawning a subagent that will write bot code, explicitly pass the relevant reference-file paths (e.g. skills/references/callback-data.md, skills/plugins/scenes.md, skills/references/formatting.md, skills/references/middleware-routing.md) in the agent prompt, or include the key rules inline.
  6. No any anywhere in examples — never write ctx: any, as any, <any>, or implicit-any parameters in any file under skills/ (examples, markdown code blocks, plugin docs). Skill examples are templates that AI copies verbatim into user bots; every any here multiplies into every downstream bot. Derive the proper type from ContextType<typeof bot, "update_name">, CallbackQueryShorthandContext<typeof bot, typeof schema>, or export a BotContext = typeof bot['_']['context'] alias. If a value is genuinely unknown at a system boundary, use unknown + narrowing. No exceptions, even in "what-not-to-do" snippets — use @ts-expect-error on the specific line with a comment instead of a broad any.
  7. Button-first UX — users tap, they don't type. Navigation belongs to inline keyboards, not slash commands. /start should be a short hero (bold title + blockquote description) with an inline keyboard of primary actions — not a wall of text listing /help, /settings, /delete. Nested menus need breadcrumbs in the title (⚙️ Settings · home › settings), a ◀ Back button on every non-home screen, and 🏠 Home anywhere deeper than two levels. Navigation clicks edit the current message (ctx.editText), never send new ones — new sends are for events (results, notifications), not navigation. Toggle buttons carry their state in the label (✅ Notifications / ⬜ Notifications) and one handler flips the session field + rerenders. Destructive actions always go through a confirm screen with the safe default on the left. Every callback handler starts with ctx.answer() so the spinner stops immediately — empty is fine for navigation, short text for toast feedback, {show_alert: true} only for errors the user must acknowledge. Commands exist for discovery (register with setMyCommands so they appear in Telegram's menu button), not as the primary UI. See ux-patterns for the full playbook and examples/ux-menu.ts for a worked example covering hero /start, nested menu, toggles, and destructive confirm.
  8. Run bun run check:skills before finishing any skill edit — any change to skills/**/*.ts or TypeScript code blocks in skills/**/*.md must typecheck cleanly against the currently installed gramio versions. The check:skills script runs tsc --noEmit over skills/examples/*.ts with strict mode. If it reports errors, fix them — don't ship. If a pre-existing example breaks because gramio's API evolved, update the example to match the current API (check node_modules/gramio/dist/index.d.ts and node_modules/@gramio/*/dist/index.d.ts for current signatures).

Official Plugins

PluginPackagePurpose
Session@gramio/sessionPersistent per-user data storage
Scenes@gramio/scenesMulti-step conversation flows
I18n@gramio/i18nInternationalization (TS-native or Fluent)
Autoload@gramio/autoloadFile-based handler loading
Prompt@gramio/promptSingle-question prompts — in-memory only, not persistent. Use Scenes .ask() for anything that must survive restarts
Views@gramio/viewsRecommended for screen composition — reusable templates (programmatic + JSON), auto send/edit, keyboards, media, i18n
JSX@gramio/jsxJSX syntax for formatting + keyboards (no React)
Pagination@gramio/paginationPaginated inline-keyboard menus with fluent builder
Auto Retry@gramio/auto-retryRetry on 429 rate limits
Media Cache@gramio/media-cacheCache file_ids
Media Group@gramio/media-groupHandle album messages
Split@gramio/splitSplit long messages
Auto Answer CB@gramio/auto-answer-callback-queryAuto-answer callbacks
PostHog@gramio/posthogAnalytics + feature flags
OpenTelemetry@gramio/opentelemetryDistributed tracing and spans
Sentry@gramio/sentryError tracking + performance monitoring

Telegram Bot API Reference Pages

GramIO docs include a dedicated reference page for every Telegram Bot API method and type:

  • Methods: https://gramio.dev/telegram/methods/{methodName} — e.g. sendMessage, createChatInviteLink, answerCallbackQuery
  • Types: https://gramio.dev/telegram/types/{typeName} — e.g. Message, ChatInviteLink, InlineKeyboard

Each page contains: GramIO TypeScript examples, parameter details, error table with causes and fixes, tips & gotchas, and related links. When a user asks about a specific Telegram API method or type, you can fetch or reference the corresponding page for accurate GramIO-specific usage.

Tip for LLMs: Any GramIO docs page can be fetched as clean Markdown by appending .md to the URL: https://gramio.dev/telegram/methods/sendMessage.md — clean Markdown instead of HTML. This works for all sections of the docs, not just API pages.
These pages are not included in this skill by default — fetch them on demand when the user asks about a specific method/type.

To quickly find which methods exist — use the pre-built index: telegram-api-index. It lists all 165+ Bot API methods with short descriptions in one file. Load it when you need to discover a method name or confirm one exists before fetching a full page.

References

Core

TopicDescriptionReference
Bot ConfigurationConstructor, API options, proxy, test DC, debuggingbot-configuration
Bot APICalling methods, suppress, withRetries, type helpersbot-api
Context & Updatesderive, decorate, middleware, start/stop, type narrowingcontext
Triggerscommand, hears, callbackQuery, inlineQuery, reactiontriggers
Middleware Routinghandler priority, next(), overlapping CallbackData, centralized routingmiddleware-routing
Scene ↔ Composer inheritanceshare named .as("scoped") composer derives between bot-level handlers and Scene steps; file split to avoid circular importsscene-composer-inheritance
HooksonStart, onStop, onError, preRequest, onResponsehooks
Updates & Lifecyclestart/stop options, graceful shutdown (SIGINT/SIGTERM)updates

Features

TopicDescriptionReference
KeyboardsKeyboard, InlineKeyboard, layout helpers, stylingkeyboards
Formattingentity helpers, join (never native .join()!), variable composition, no parse_modeformatting
UX Patternsbutton-first nav, /start anatomy, nested menus, toggles, destructive confirm, empty states, formatting hierarchy, command discovery, deep linksux-patterns
FilesMediaUpload, MediaInput, download, Bun.file()files
CallbackDataType-safe callback data schemascallback-data
StorageIn-memory, Redis, Cloudflare adaptersstorage
Telegram StarsPayments, invoices, subscriptions, inline invoices, refunds, test modetelegram-stars
Types@gramio/types, type helpers, Proxy wrapper, declaration mergingtypes

Infrastructure

TopicDescriptionReference
WebhookFramework integration, tunneling, custom handlerswebhook
Rate LimitswithRetries, broadcasting, queuesrate-limits
DockerDockerfile, multi-stage build, Docker Composedocker
TMAMini Apps, mkcert HTTPS, @gramio/init-data authtma
TestingEvent-driven bot testing, user actors, API mockingtesting

Migrations

Load when the user wants to migrate an existing bot to GramIO.

FromDescriptionReference
puregramSymbol mapping, API comparisons, checklist for puregram → GramIO refactormigration-from-puregram
TelegrafSymbol mapping, context typing, Scenes/WizardScene, webhook differences, checklistmigration-from-telegraf
node-telegram-bot-apiSymbol mapping, middleware concepts, keyboard builders, session, checklistmigration-from-ntba

Plugins

PluginDescriptionReference
SessionPer-user data, Redis supportsession
ScenesMulti-step flows, state, navigationscenes
I18nTS-native and Fluent internationalizationi18n
AutoloadFile-based handler discoveryautoload
PromptSend + wait for response — in-memory only, lost on restart; use Scenes .ask() for persistent question sequencesprompt
ViewsRecommended pattern@gramio/views plugin (templates, JSON, i18n, auto send/edit); plain render-fn fallback for trivial botsviews
JSXJSX syntax for formatting + keyboards (no React runtime)jsx
PaginationFluent paginated inline keyboards (prev/next/first/last, page info)pagination
OpenTelemetryDistributed tracing, spans, instrumentationopentelemetry
SentryError tracking, performance monitoringsentry
Othersauto-retry, media-cache, media-group, split, posthogother
Plugin DevelopmentWriting custom plugins, derive/decorate/error, lazy loadingplugin-development

Examples

ExampleDescriptionFile
Basic botCommands, hooks, error handlingbasic.ts
KeyboardsReply, inline, columns, conditionalkeyboards.ts
UX menuHero /start, nested menu with breadcrumbs + Back, toggle buttons, destructive confirm stepux-menu.ts
CallbackDataType-safe callback schemascallback-data.ts
FormattingEntity types, join helper, variable composition, parse_mode anti-patternformatting.ts
File uploadPath, URL, buffer, media groupsfile-upload.ts
Error handlingCustom errors, suppress, scopederror-handling.ts
WebhookFramework integrationwebhook.ts
SessionCounters, settings, Redissession.ts
ScenesRegistration flow with stepsscenes.ts
Wizard sceneCallback-driven scene, mixed callback+message steps, global exitwizard-scene.ts
Scene composer inheritance3-file package: named scoped composer + Scene.extend + file split for circular-import-safe layoutscene-composer-inheritance/
Callback routingCentralized router, shared nav CallbackData across featurescallback-routing.ts
Telegram StarsPayments, invoices, refundstelegram-stars.ts
TMAElysia server, init-data auth, webhooktma.ts
DockerGraceful shutdown, webhook/polling toggledocker.ts
TestingUser simulation, API mocking, error testingtesting.ts

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

37.12%
按下载量换算447

Claude

27.37%
按下载量换算330

Cursor

20.36%
按下载量换算245

Gemini CLI

9.84%
按下载量换算118

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

可疑

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在 warning/failed 结果,不能写成本站确认安全。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills