Agent Skills › mocasus/unprompted › unprompted-telegram

unprompted-telegram

GitHub

提供Telegram机器人及Mini App的设计、审计与规范检查技能。涵盖BOT.md规格定义、命令表面管理、内联键盘预算、富媒体消息及 initData 验证等20项确定性规则,用于构建或审查Bot时的方向指引与合规性检查。

skills/unprompted-telegram/SKILL.md mocasus/unprompted

触发场景

设计 Telegram Bot 或 Mini App 审查 Telegram Bot 代码或交互流程 生成 BOT.md 规格文档 优化内联键盘布局与回调数据

安装

npx skills add mocasus/unprompted --skill unprompted-telegram -g -y
更多选项

不安装直接使用

npx skills use mocasus/unprompted@unprompted-telegram

指定 Agent (Claude Code)

npx skills add mocasus/unprompted --skill unprompted-telegram -a claude-code -g -y

安装 repo 全部 skill

npx skills add mocasus/unprompted --all -g -y

预览 repo 内 skill

npx skills add mocasus/unprompted --list

SKILL.md

Frontmatter
{
    "name": "unprompted-telegram",
    "license": "MIT",
    "version": "4.3.2",
    "metadata": {
        "author": "mocasus",
        "category": "telegram",
        "openclaw": {
            "emoji": "🤖",
            "requiredBins": [
                "node"
            ]
        },
        "repository": "https:\/\/github.com\/mocasus\/unprompted"
    },
    "description": "Design and audit Telegram bots and Mini Apps: BOT.md specs, inline keyboard budgets, Rich Messages streaming, initData verification, Stars payments, and a 20-rule deterministic audit. Load whenever building or reviewing a Telegram bot, keyboard flow, or Mini App.",
    "compatibility": [
        "windows",
        "macos",
        "linux"
    ]
}

unprompted-telegram — Bot Direction Protocol

Extends the v4 direction contract to chat surfaces. The UI protocol owns web pages; this skill owns the conversation: what the bot is for, which screen the user is on, what each button costs, and what proves it works.

Telegram rule IDs (TG-01…TG-20) are separate from D/S/W/A/M/E. They audit bot code, not markup, and they never change the 67-check totals.

1. Spec first (TG-00)

Write BOT.md before the first handler. A bot without a spec becomes a command list with no exit. Start from references/bot-md.md or run:

node <skills-dir>/unprompted-telegram/scripts/telegram-audit.mjs --init BOT.md

Through the CLI, --ask interviews the four decisions that matter (name, one job, success metric, non-goal) before writing the file:

npx github:mocasus/unprompted telegram --init BOT.md --ask

If no BOT.md exists, label the output DRAFT (NO BOT.MD) and keep it non-shippable. The spec fixes:

  • one job per screen, and the exit from it;
  • the command surface, capped at seven commands;
  • the keyboard map with callback_data values already allocated;
  • the states each screen can be in;
  • who pays, and for what.

2. Command surface

Commands are the public API of a bot. More than seven is a menu nobody reads.

Slot Rule
/start Onboarding plus the primary action. Never a wall of text.
/help One screen, same keyboard as the main menu.
/settings Only if the bot stores preferences.
Domain verbs Maximum three, each a noun the user would say.
/admin Hidden from setMyCommands for non-admins.

Command descriptions are under 120 characters, lowercase, and verb-first. The setMyCommands call is part of the deliverable, not an afterthought.

3. Inline keyboard contract

Inline keyboards carry the navigation. Reply keyboards are for data entry only (phone, location, a fixed answer set).

  • callback_data is 1-64 bytes. Budget it like a schema: ns:action:id (cart:add:42, page:next:3).
  • Three buttons per row maximum, twelve per screen unless paginated.
  • Every screen answers three questions: back, home, close.
  • Every press gets an answerCallbackQuery. Silence feels broken; the client shows a spinner for up to 15 seconds.
  • Toggles show their state in the label (Notifications: on), not in color.
  • Destructive actions confirm with two explicit buttons, never one ambiguous "OK".
  • Navigation edits the current message. Sending a new one floods history.

Full layout, pagination, and router patterns: references/inline-keyboards.md.

4. Rich Messages

Bot API 10.3 added rich messages: structured blocks, streaming drafts, and ephemeral replies. Use them for receipts, comparisons, articles, and any content that would otherwise become a wall of parse_mode text.

  • Build InputRichMessage with blocks for tables, lists, details, and slideshows; keep markdown or html only for short prose.
  • Stream long answers with sendRichMessageDraft, throttled to 250-500 ms, then finish with sendRichMessage or editMessageText.
  • Always ship a fallback for clients without 10.3: isVersionAtLeast or a sendMessage path. A missing fallback is a blank chat.
  • Ephemeral messages replace toasts for confirmations that should not persist.

Details and block selection: references/rich-messages.md.

5. Mini Apps

A Mini App is a web page with a Telegram contract. The contract is not optional.

  • Verify initData on the server with HMAC-SHA256 before trusting any field. Never trust the client copy.
  • Read themeParams into CSS variables; hardcoded colors break dark mode.
  • Respect safeAreaInset and contentSafeAreaInset; call expand() and ready() on boot.
  • MainButton owns the primary action: disable it while submitting and show progress instead of accepting double taps.
  • BackButton mirrors navigation; closing confirmation protects unsaved input.

Full lifecycle and snippets: references/mini-apps.md.

6. Payments

  • Create invoices with XTR (Stars) unless the product is physical.
  • Answer pre_checkout_query within 10 seconds, always, even to reject.
  • Verify successful_payment by telegram_payment_charge_id, store it once, and make the handler idempotent.
  • Refunds use refundStarPayment; never hand-roll balances.

references/payments-stars.md has the flow and the failure table.

7. States and copy

Every screen ships four states: loading, empty, error, success. A bot that only renders the happy path is a demo.

  • Error copy names the failed action and the next step, not "Something went wrong".
  • Empty copy says why it is empty and what fills it.
  • Loading is one line, edited in place, not a second message.
  • Cancellation is always available and always returns to a known screen.

8. Evidence gate

Run the auditor on changed bot sources:

node <skills-dir>/unprompted-telegram/scripts/telegram-audit.mjs --validate BOT.md
node <skills-dir>/unprompted-telegram/scripts/telegram-audit.mjs <files-or-dirs>
node <skills-dir>/unprompted-telegram/scripts/telegram-audit.mjs <files> --spec BOT.md

The validator checks the spec before the code exists: required sections, command cap, screen states, the callback budget, namespace registration, idempotency keys, Mini App auth, and the evidence list. A skeleton with placeholders fails on purpose.

--spec bridges the two: every callback_data in code is matched against the BOT.md keyboard map, so an unregistered namespace (SB-01), a registered button nobody wired (SB-02), or a namespace with no key (SB-03) shows up as drift instead of shipping silently.

Add --strict in CI to fail on warnings. Close substantive deliveries with:

UNPROMPTED BOT REPORT
- Spec      : BOT.md | DRAFT (NO BOT.MD)
- Rules     : TG 20/20 evaluated
- Errors    : 0
- Warnings  : 0
- Score     : 100/100
- Evidence  : keyboard matrix at 320/768/1440, callback table, initData proof
- Verdict   : PASS

Never print PASS when the audit reports errors or when the keyboard matrix is missing. Use REVIEW for warnings and BLOCK for errors.

Sub-references

File Use when
references/bot-md.md Starting a bot, or the spec is missing
references/inline-keyboards.md Designing navigation, pagination, callbacks
references/rich-messages.md Formatting receipts, articles, streaming answers
references/mini-apps.md Building a Web App surface
references/payments-stars.md Selling anything for Stars
references/anti-patterns.md Reviewing an existing bot

Starters

Copy from assets/ instead of starting blank. All three pass the auditor at 100/100.

File Use
assets/miniapp-shell.html Theme params, safe areas, ready()/expand(), four states, guarded MainButton
assets/miniapp-verify.mjs initData HMAC verification plus an Express-style guard
assets/keyboard-router.ts Namespaced callback router, clamped pagination, stale-button fallback

版本历史

  • 3d2867a 当前 2026-12-05 21:58
  • 342968c 2026-12-05 15:46

依赖关系

  • optional github:mocasus/unprompted

同 Skill 集合

skills/unprompted-a11y/SKILL.md
skills/unprompted-code/SKILL.md
skills/unprompted-copywriting/SKILL.md
skills/unprompted-direction/SKILL.md
skills/unprompted-mobile/SKILL.md
skills/unprompted-ui/SKILL.md
skills/unprompted/SKILL.md

元信息

文件数
0
版本
3d2867a
Hash
152a1376
收录时间
2026-12-05 15:46

首页 - Wiki
Copyright © 2011-2026 iteam. Current version is 2.156.0. UTC+08:00, 2026-12-05 22:13
浙ICP备14020137号-1