astrbot-plugin-dev

Guide for developing AstrBot plugins. Supports creating commands, filters, hooks, handling messages, integrating with LLMs, and building agents. Use when requested to create or update an AstrBot plugin.

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "astrbot-plugin-dev" with this command: npx skills add camera-2018/astrbot-plugin-dev-skill/camera-2018-astrbot-plugin-dev-skill-astrbot-plugin-dev

AstrBot Plugin Development

This skill provides the procedural knowledge to develop AstrBot plugins.

Quick Start: Basic Command Plugin

Create a main.py in your plugin directory:

from astrbot.api.event import filter, AstrMessageEvent
from astrbot.api.star import Context, Star
from astrbot.api import logger

class MyPlugin(Star):
    def __init__(self, context: Context):
        super().__init__(context)

    @filter.command("helloworld")
    async def helloworld(self, event: AstrMessageEvent):
        '''A hello world command'''
        user_name = event.get_sender_name()
        message_str = event.message_str
        logger.info("helloworld triggered!")
        yield event.plain_result(f"Hello, {user_name}!")

    async def terminate(self):
        '''Called when the plugin is unloaded/disabled.'''

Note: The @register decorator is deprecated in newer versions of AstrBot. Please use metadata.yaml to define plugin metadata. AstrBot automatically detects the plugin class inheriting from Star.

Core Workflows

1. Project Setup and Metadata

A complete plugin requires metadata.yaml for identification, requirements.txt for dependencies, and optionally logo.png, _conf_schema.json, and a README.md.

  • Plugin names should start with astrbot_plugin_, be lowercase, have no spaces, and be short.
  • See references/project-structure.md for mandatory files, dev environment setup, and publishing.

2. Registering Commands and Filters

Commands are registered using @filter.command(name). AstrBot auto-parses command parameters by type hints. You can also use command groups, command aliases, and filter by event type, platform, or user permission.

  • See references/core-api.md for full list of filters, hooks, the platform compatibility matrix, and event propagation control.

3. Handling Messages and Responses

AstrBot uses a "Message Chain" system. You can respond with plain text, images, or a mix of components. Proactive (bot-initiated) messages are supported via unified_msg_origin and MessageChain.

4. Advanced Integrations

  • Configuration: Use _conf_schema.json for user settings (supports string, int, bool, object, list, dict, file, template_list, and special selectors).
  • LLM Tools: Register tools via @filter.llm_tool decorator or Pydantic FunctionTool dataclass.
  • LLM Direct Calls: Use self.context.llm_generate() to call LLMs directly (>= v4.5.7).
  • Agent / Multi-Agent: Use self.context.tool_loop_agent() to run tool-loop agents or compose multi-agent systems.
  • Stateful Interaction: Use session_waiter for multi-step prompts with custom session filters.
  • T2I: Render text or HTML/Jinja2 templates to images.
  • Conversation & Persona Managers: Access LLM conversation history and persona settings.

See references/advanced-features.md for examples.

Elegant Design Patterns

Follow these patterns for robust, user-friendly plugins:

  • Use unified logging via from astrbot.api import logger.
  • Handle errors gracefully to avoid bot crashes.
  • Use KV storage (put_kv_data/get_kv_data) or the plugin_data directory for persistence.
  • Ensure all IO operations are non-blocking (async).
  • Access platform instances, loaded plugins, and protocol-level APIs when needed.

See references/patterns.md for detailed code patterns.

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Coding

openclaw-version-monitor

监控 OpenClaw GitHub 版本更新,获取最新版本发布说明,翻译成中文, 并推送到 Telegram 和 Feishu。用于:(1) 定时检查版本更新 (2) 推送版本更新通知 (3) 生成中文版发布说明

Archived SourceRecently Updated
Coding

ask-claude

Delegate a task to Claude Code CLI and immediately report the result back in chat. Supports persistent sessions with full context memory. Safe execution: no data exfiltration, no external calls, file operations confined to workspace. Use when the user asks to run Claude, delegate a coding task, continue a previous Claude session, or any task benefiting from Claude Code's tools (file editing, code analysis, bash, etc.).

Archived SourceRecently Updated
Coding

ai-dating

This skill enables dating and matchmaking workflows. Use it when a user asks to make friends, find a partner, run matchmaking, or provide dating preferences/profile updates. The skill should execute `dating-cli` commands to complete profile setup, task creation/update, match checking, contact reveal, and review.

Archived SourceRecently Updated
Coding

clawhub-rate-limited-publisher

Queue and publish local skills to ClawHub with a strict 5-per-hour cap using the local clawhub CLI and host scheduler.

Archived SourceRecently Updated