[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M730XSP85KBZ340K2VJA0R54":3,"skill-same:01M730XSP85KBZ340K2VJA0R54":51},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":27,"commitSha":28,"skillDirectory":29,"forksCount":30,"repositoryHtmlUrl":31,"repositoryHomepageUrl":32,"ownerHtmlUrl":33,"ownerBlogUrl":34,"ownerDescription":35,"updatedAt":36,"install":37,"resources":50},"01M730XSP85KBZ340K2VJA0R54","bot-from-scratch",null,"Use when building a chat-platform bot (Discord\u002FTelegram\u002FSlack\u002FTwitter-style) from first principles — the event loop, command routing, and platform API integration, not an LLM agent framework. Triggers on: 'build a discord bot from scratch', 'implement a telegram bot event loop', 'webhook vs polling for a bot', 'command router for a chat bot', 'rate limiting a platform API bot'. Covers polling vs webhook architecture, command parsing\u002Frouting, and state management.","Horonomos-laps\u002FYana-AI","Horonomos-laps","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F355299122?v=4","01M76B3QPXE88ET2SQPDPVATZT"," Horonomos-laps","01M72ZQRJPCYPSSWT4D00VJR2A",13,"Apache-2.0","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fbot-from-scratch\u002FSKILL.md",[],[],"2026-11-11 15:11:14",false,"---\nname: bot-from-scratch\ndescription: \"Use when building a chat-platform bot (Discord\u002FTelegram\u002FSlack\u002FTwitter-style) from first principles — the event loop, command routing, and platform API integration, not an LLM agent framework. Triggers on: 'build a discord bot from scratch', 'implement a telegram bot event loop', 'webhook vs polling for a bot', 'command router for a chat bot', 'rate limiting a platform API bot'. Covers polling vs webhook architecture, command parsing\u002Frouting, and state management.\"\norigin: yana-ai — synthesized from public chat-platform bot API documentation patterns (Discord\u002FTelegram Bot API design) and community from-scratch tutorials indexed in codecrafters-io\u002Fbuild-your-own-x\nlicense: Apache-2.0\nversion: 1.0.0\ncompatibility: yana-ai >= 0.43.2\n---\n\n# \u002Fbot-from-scratch\n\n## When to Use\n\n- Building a chat-platform bot's core message loop (Discord, Telegram, Slack, Twitter\u002FX, IRC) from the platform's raw API, without a heavy bot framework.\n- Deciding between polling and webhook architecture for receiving platform events.\n- Implementing command parsing\u002Frouting and per-user\u002Fper-channel state for a bot.\n\n## Do NOT use for\n\n- Building an LLM-powered conversational agent's reasoning\u002Ftool-use loop — that's a different problem (prompting, tool orchestration, memory); see `agency-agents`, `voice-agents`, `hermes-conversation-loop`, or `openclaw-persona-forge` for AI-agent-specific patterns. This skill is about the *platform integration* layer a bot (AI-powered or not) sits behind.\n- Web scraping or browser automation bots — see `browser-use`\u002F`stealth-browser-automation` for that different category of \"bot.\"\n- General webhook infrastructure unrelated to chat platforms — see `api-gateway-engineer`\u002Frelevant backend skills for that.\n\n---\n\n## Architecture Decision: Polling vs Webhook\n\n```\nSimple deployment, no public HTTPS endpoint available, low message volume?\n  → Polling (Step 1) — bot repeatedly asks the platform \"any new events?\"\n\nProduction deployment with a reachable HTTPS endpoint, want lower latency\nand lower request volume?\n  → Webhook (Step 2) — platform pushes events to your endpoint as they happen\n```\n\nMost platform bot APIs (Telegram, Discord's gateway, Slack) support both; polling is simpler to get running locally, webhooks are what real deployments typically use.\n\n## Step 1: Polling Architecture\n\n```\nloop:\n  events = GET platform_api\u002Fget_updates?offset=last_seen_id\n  for event in events:\n    handle(event)\n    last_seen_id = event.id + 1\n  sleep(poll_interval)   # or use long-polling if the platform supports it\n```\n\n**Long-polling** (the request itself blocks server-side for up to N seconds waiting for a new event, rather than returning immediately with an empty list) is far more efficient than short-polling with a fixed sleep — it gets near-webhook latency without needing a public endpoint. Telegram's `getUpdates` supports this via a `timeout` parameter; check whether your target platform does before defaulting to fixed-interval short polling.\n\n**Idempotency via offset\u002Fcursor**: always track the last-processed event ID and request only events after it (`offset=last_seen_id`) — without this, a restart re-delivers already-handled events, causing duplicate responses\u002Factions.\n\n## Step 2: Webhook Architecture\n\nThe platform makes an HTTP POST to your public endpoint whenever an event occurs. Requirements this introduces that polling doesn't have:\n\n- **A public HTTPS endpoint** — most platforms (Telegram, Slack, Discord interactions API) require TLS; a self-signed cert usually isn't accepted, use a real cert (Let's Encrypt) or a platform-provided tunnel for local dev (ngrok-style).\n- **Verify the request is genuinely from the platform** — most platforms sign webhook payloads (a header like `X-Signature` computed as an HMAC of the body using a secret only you and the platform know); verify this signature before processing, or anyone who discovers your endpoint URL can inject fake events. See `stripe-webhook-security` for the general pattern if unfamiliar with webhook signature verification.\n- **Respond fast, process async**: platforms expect a quick 200 OK (often within a few seconds) to consider the webhook delivered; if handling an event involves slow work (calling an LLM, hitting a slow API), acknowledge the webhook immediately and do the actual work in a background task\u002Fqueue — a slow handler that blocks the HTTP response risks the platform treating the delivery as failed and retrying, causing duplicate processing.\n\n## Step 3: Command Parsing & Routing\n\nMost chat bots follow a command-router pattern regardless of platform:\n\n```\nparse: \"!ban @user 3d spamming\" → command=\"ban\", args=[\"@user\", \"3d\", \"spamming\"]\nroute: lookup \"ban\" in a command table → call ban_handler(event, args)\n```\n\n```python\nCOMMANDS = {\n    \"ban\": handle_ban,\n    \"help\": handle_help,\n}\n\ndef route(event):\n    if not event.text.startswith(PREFIX):\n        return\n    command, *args = event.text[len(PREFIX):].split()\n    handler = COMMANDS.get(command.lower())\n    if handler:\n        handler(event, args)\n    else:\n        reply(event, f\"Unknown command: {command}\")\n```\n\nFor platforms with native slash-command support (Discord interactions, Slack slash commands), the platform does the parsing and delivers structured `(command, args)` directly — prefer that over text parsing when available, since it also gets you free autocomplete\u002Fvalidation in the client UI.\n\n## Step 4: State Management\n\nBots are usually stateless per-message but need memory across messages (conversation context, per-user settings, rate-limit counters, active game\u002Fsession state). Keep state keyed by the smallest scope that's actually correct for the feature — per-user, per-channel, or per-guild\u002Fworkspace are different scopes with different lifetimes, and conflating them is a common bug (e.g. a \"current game\" keyed globally instead of per-channel breaks the moment two channels play simultaneously).\n\nFor anything beyond a single-process toy bot, back state with persistent storage (Redis for ephemeral\u002Ffast-expiring state like rate limits, a real database for anything that must survive a restart) rather than in-memory dicts — an in-memory-only bot loses all state on every deploy\u002Fcrash.\n\n## Step 5: Rate Limiting Against the Platform API\n\nEvery chat platform enforces its own rate limits (Discord: per-route limits with `X-RateLimit-*` response headers; Telegram: ~30 messages\u002Fsecond global, 1\u002Fsecond per chat). Two directions to handle:\n\n- **Respect the platform's limit**: read rate-limit headers when provided and back off accordingly (a `429` response usually includes a `Retry-After`); a bot that ignores this gets temporarily or permanently blocked by the platform.\n- **Rate-limit your own users**: independent of the platform's limits, apply your own per-user cooldowns on expensive commands (anything that calls an LLM, hits a paid API, or does heavy compute) to prevent one user from exhausting your own resources or the platform quota for everyone.\n\n## What NOT to Do\n\n- Don't skip webhook signature verification — an unverified webhook endpoint accepts forged events from anyone who finds the URL, not just the real platform.\n- Don't do slow work synchronously inside a webhook handler — see Step 2; this causes duplicate-delivery retries and, at scale, platform-side timeout penalties.\n- Don't key shared state at the wrong scope (global instead of per-channel\u002Fper-user) — see Step 4; this is the most common multi-instance-of-the-same-feature bug.\n- Don't ignore platform rate-limit response headers — a bot that gets rate-limited and keeps retrying at the same pace makes the backoff worse, not better; honor `Retry-After` explicitly.\n","# \u002Fbot-from-scratch\n\n## When to Use\n\n- Building a chat-platform bot's core message loop (Discord, Telegram, Slack, Twitter\u002FX, IRC) from the platform's raw API, without a heavy bot framework.\n- Deciding between polling and webhook architecture for receiving platform events.\n- Implementing command parsing\u002Frouting and per-user\u002Fper-channel state for a bot.\n\n## Do NOT use for\n\n- Building an LLM-powered conversational agent's reasoning\u002Ftool-use loop — that's a different problem (prompting, tool orchestration, memory); see `agency-agents`, `voice-agents`, `hermes-conversation-loop`, or `openclaw-persona-forge` for AI-agent-specific patterns. This skill is about the *platform integration* layer a bot (AI-powered or not) sits behind.\n- Web scraping or browser automation bots — see `browser-use`\u002F`stealth-browser-automation` for that different category of \"bot.\"\n- General webhook infrastructure unrelated to chat platforms — see `api-gateway-engineer`\u002Frelevant backend skills for that.\n\n---\n\n## Architecture Decision: Polling vs Webhook\n\n```\nSimple deployment, no public HTTPS endpoint available, low message volume?\n  → Polling (Step 1) — bot repeatedly asks the platform \"any new events?\"\n\nProduction deployment with a reachable HTTPS endpoint, want lower latency\nand lower request volume?\n  → Webhook (Step 2) — platform pushes events to your endpoint as they happen\n```\n\nMost platform bot APIs (Telegram, Discord's gateway, Slack) support both; polling is simpler to get running locally, webhooks are what real deployments typically use.\n\n## Step 1: Polling Architecture\n\n```\nloop:\n  events = GET platform_api\u002Fget_updates?offset=last_seen_id\n  for event in events:\n    handle(event)\n    last_seen_id = event.id + 1\n  sleep(poll_interval)   # or use long-polling if the platform supports it\n```\n\n**Long-polling** (the request itself blocks server-side for up to N seconds waiting for a new event, rather than returning immediately with an empty list) is far more efficient than short-polling with a fixed sleep — it gets near-webhook latency without needing a public endpoint. Telegram's `getUpdates` supports this via a `timeout` parameter; check whether your target platform does before defaulting to fixed-interval short polling.\n\n**Idempotency via offset\u002Fcursor**: always track the last-processed event ID and request only events after it (`offset=last_seen_id`) — without this, a restart re-delivers already-handled events, causing duplicate responses\u002Factions.\n\n## Step 2: Webhook Architecture\n\nThe platform makes an HTTP POST to your public endpoint whenever an event occurs. Requirements this introduces that polling doesn't have:\n\n- **A public HTTPS endpoint** — most platforms (Telegram, Slack, Discord interactions API) require TLS; a self-signed cert usually isn't accepted, use a real cert (Let's Encrypt) or a platform-provided tunnel for local dev (ngrok-style).\n- **Verify the request is genuinely from the platform** — most platforms sign webhook payloads (a header like `X-Signature` computed as an HMAC of the body using a secret only you and the platform know); verify this signature before processing, or anyone who discovers your endpoint URL can inject fake events. See `stripe-webhook-security` for the general pattern if unfamiliar with webhook signature verification.\n- **Respond fast, process async**: platforms expect a quick 200 OK (often within a few seconds) to consider the webhook delivered; if handling an event involves slow work (calling an LLM, hitting a slow API), acknowledge the webhook immediately and do the actual work in a background task\u002Fqueue — a slow handler that blocks the HTTP response risks the platform treating the delivery as failed and retrying, causing duplicate processing.\n\n## Step 3: Command Parsing & Routing\n\nMost chat bots follow a command-router pattern regardless of platform:\n\n```\nparse: \"!ban @user 3d spamming\" → command=\"ban\", args=[\"@user\", \"3d\", \"spamming\"]\nroute: lookup \"ban\" in a command table → call ban_handler(event, args)\n```\n\n```python\nCOMMANDS = {\n    \"ban\": handle_ban,\n    \"help\": handle_help,\n}\n\ndef route(event):\n    if not event.text.startswith(PREFIX):\n        return\n    command, *args = event.text[len(PREFIX):].split()\n    handler = COMMANDS.get(command.lower())\n    if handler:\n        handler(event, args)\n    else:\n        reply(event, f\"Unknown command: {command}\")\n```\n\nFor platforms with native slash-command support (Discord interactions, Slack slash commands), the platform does the parsing and delivers structured `(command, args)` directly — prefer that over text parsing when available, since it also gets you free autocomplete\u002Fvalidation in the client UI.\n\n## Step 4: State Management\n\nBots are usually stateless per-message but need memory across messages (conversation context, per-user settings, rate-limit counters, active game\u002Fsession state). Keep state keyed by the smallest scope that's actually correct for the feature — per-user, per-channel, or per-guild\u002Fworkspace are different scopes with different lifetimes, and conflating them is a common bug (e.g. a \"current game\" keyed globally instead of per-channel breaks the moment two channels play simultaneously).\n\nFor anything beyond a single-process toy bot, back state with persistent storage (Redis for ephemeral\u002Ffast-expiring state like rate limits, a real database for anything that must survive a restart) rather than in-memory dicts — an in-memory-only bot loses all state on every deploy\u002Fcrash.\n\n## Step 5: Rate Limiting Against the Platform API\n\nEvery chat platform enforces its own rate limits (Discord: per-route limits with `X-RateLimit-*` response headers; Telegram: ~30 messages\u002Fsecond global, 1\u002Fsecond per chat). Two directions to handle:\n\n- **Respect the platform's limit**: read rate-limit headers when provided and back off accordingly (a `429` response usually includes a `Retry-After`); a bot that ignores this gets temporarily or permanently blocked by the platform.\n- **Rate-limit your own users**: independent of the platform's limits, apply your own per-user cooldowns on expensive commands (anything that calls an LLM, hits a paid API, or does heavy compute) to prevent one user from exhausting your own resources or the platform quota for everyone.\n\n## What NOT to Do\n\n- Don't skip webhook signature verification — an unverified webhook endpoint accepts forged events from anyone who finds the URL, not just the real platform.\n- Don't do slow work synchronously inside a webhook handler — see Step 2; this causes duplicate-delivery retries and, at scale, platform-side timeout penalties.\n- Don't key shared state at the wrong scope (global instead of per-channel\u002Fper-user) — see Step 4; this is the most common multi-instance-of-the-same-feature bug.\n- Don't ignore platform rate-limit response headers — a bot that gets rate-limited and keeps retrying at the same pace makes the backoff worse, not better; honor `Retry-After` explicitly.\n",{"name":5,"origin":24,"license":15,"version":25,"description":7,"compatibility":26},"yana-ai — synthesized from public chat-platform bot API documentation patterns (Discord\u002FTelegram Bot API design) and community from-scratch tutorials indexed in codecrafters-io\u002Fbuild-your-own-x","1.0.0","yana-ai >= 0.43.2","main","481dcd7dd2e288b9d627a2bd017db70e64e6c6fa",".claude\u002Fskills\u002Fbot-from-scratch",2,"https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI","https:\u002F\u002Fyana.vutam.link\u002F","https:\u002F\u002Fgithub.com\u002FHoronomos-laps","https:\u002F\u002Fyana.vutam.link","An open-source governed runtime & execution environment for multi-agent AI systems.","2026-11-14 13:24:09",{"source":8,"skillName":5,"commands":38,"prompt":48,"zipAvailable":49},[39,42,45],{"tool":40,"command":41},"npx","npx skills add Horonomos-laps\u002FYana-AI --skill bot-from-scratch",{"tool":43,"command":44},"bunx","bunx skills add Horonomos-laps\u002FYana-AI --skill bot-from-scratch",{"tool":46,"command":47},"pnpm","pnpm dlx skills add Horonomos-laps\u002FYana-AI --skill bot-from-scratch","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fbot-from-scratch\u002FSKILL.md",true,[],[52,60,67,75,83,91],{"skillNo":53,"name":54,"nameZh":6,"description":55,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":56,"licenseFileUrl":6,"sourceHtmlUrl":57,"categories":58,"keywords":59,"publishedAt":19},"01M735GKET5YVYKAY62W2P5YXB","openai--sentry--sentry","Use when the user asks to inspect Sentry issues or events, summarize recent production errors, or pull basic Sentry health data via the Sentry API; perform read-only queries with the bundled script and require `SENTRY_AUTH_TOKEN`.","MIT","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fopenai--sentry--sentry\u002FSKILL.md",[],[],{"skillNo":61,"name":62,"nameZh":6,"description":63,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":64,"categories":65,"keywords":66,"publishedAt":19},"01M73DCAP83T17HY7SMGK7MGFE","ito-basket-compare","Compare Itô prediction-market baskets against a user's knowledge base, portfolio notes, financial context, watchlist, or research thesis. Use for read-only basket comparison and gap analysis without investment advice or live trading.","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002Fcore\u002Fskills\u002Fito-basket-compare\u002FSKILL.md",[],[],{"skillNo":68,"name":69,"nameZh":6,"description":70,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":71,"sourceHtmlUrl":72,"categories":73,"keywords":74,"publishedAt":19},"01M734CYEMZFDR3KH6SW0JP8TD","implementing-network-traffic-baselining","Build network traffic baselines from NetFlow\u002FIPFIX data using Python pandas for statistical analysis, z-score anomaly detection, and hourly\u002Fdaily traffic pattern profiling","https:\u002F\u002Fgithub.com\u002Fyanacuti1121\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fimplementing-network-traffic-baselining\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fimplementing-network-traffic-baselining\u002FSKILL.md",[],[],{"skillNo":76,"name":77,"nameZh":6,"description":78,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":79,"sourceHtmlUrl":80,"categories":81,"keywords":82,"publishedAt":19},"01M73ASZ6NJRJM44Z2P84NGQ3Q","detecting-evasion-techniques-in-endpoint-logs","Detects defense evasion techniques used by adversaries in endpoint logs including log tampering, timestomping, process injection, and security tool disabling. Use when investigating suspicious endpoint behavior, building detection rules for evasion tactics, or conducting threat hunting for stealthy adversary activity. Activates for requests involving evasion detection, defense evasion analysis, log tampering detection, or MITRE ATT&CK TA0005.","https:\u002F\u002Fgithub.com\u002Fyanacuti1121\u002FYana-AI\u002Fblob\u002Fmain\u002Fcore\u002Fskills\u002Fdetecting-evasion-techniques-in-endpoint-logs\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002Fcore\u002Fskills\u002Fdetecting-evasion-techniques-in-endpoint-logs\u002FSKILL.md",[],[],{"skillNo":84,"name":85,"nameZh":6,"description":86,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":87,"sourceHtmlUrl":88,"categories":89,"keywords":90,"publishedAt":19},"01M734AFNXD06Z78QRK0VKGT7Q","implementing-microsegmentation-with-guardicore","Implementing microsegmentation using Akamai Guardicore Segmentation to map application dependencies, create granular network policies, visualize east-west traffic flows, and enforce least-privilege communication between workloads across data centers and cloud.","https:\u002F\u002Fgithub.com\u002Fyanacuti1121\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fimplementing-microsegmentation-with-guardicore\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fimplementing-microsegmentation-with-guardicore\u002FSKILL.md",[],[],{"skillNo":92,"name":93,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":94,"categories":95,"keywords":96,"publishedAt":19},"01M736TK27QMCXK0DVCH25SJN5","ramdisk-tmpfs-patterns","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Framdisk-tmpfs-patterns\u002FSKILL.md",[],[]]