-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
en dev star plugin new
Welcome to the AstrBot Plugin Development Guide! This section will guide you through developing AstrBot plugins. Before we begin, we hope you have the following foundational knowledge:
- Some experience with Python programming.
- Some experience with Git and GitHub.
- Open the AstrBot plugin template: helloworld
- Click
Use this templatein the upper right corner - Then click
Create new repository. - Fill in your plugin name in the
Repository namefield. Plugin naming conventions:- Recommended to start with
astrbot_plugin_; - Must not contain spaces;
- Keep all letters lowercase;
- Keep it concise.
- Recommended to start with
- Click
Create repositoryin the lower right corner.
Clone both the AstrBot main project and the plugin repository you just created to your local machine.
git clone https://github.com/AstrBotDevs/AstrBot
mkdir -p AstrBot/data/plugins
cd AstrBot/data/plugins
git clone <your-plugin-repository-url>Then, use VSCode to open the AstrBot project. Navigate to the data/plugins/<your-plugin-name> directory.
Update the metadata.yaml file with your plugin's metadata information.
Warning
Please make sure to modify this file, as AstrBot relies on the metadata.yaml file to recognize plugin metadata.
You can add a logo.png file in the plugin directory as the plugin's logo. Please maintain an aspect ratio of 1:1, with a recommended size of 256x256.
You can modify (or add) the display_name field in the metadata.yaml file to serve as the plugin's display name in scenarios like the plugin marketplace, making it easier for users to read.
You can add a support_platforms field (list[str]) to metadata.yaml to declare which platform adapters your plugin supports. The WebUI plugin page will display this field.
support_platforms:
- telegram
- discordThe values in support_platforms must be keys from ADAPTER_NAME_2_TYPE. Currently supported:
aiocqhttpqq_officialtelegramwecomlarkdingtalkdiscordslackkookvocechatweixin_official_accountsatorimisskeyline
You can add an astrbot_version field in metadata.yaml to declare the required AstrBot version range for your plugin. The format follows dependency specifiers in pyproject.toml (PEP 440), and must not include a v prefix.
astrbot_version: ">=4.16,<5"Examples:
>=4.17.0>=4.16,<5~=4.17
If you only want to declare a minimum version, use:
>=4.17.0
If the current AstrBot version does not satisfy this range, the plugin will be blocked from loading with a compatibility error. In the WebUI installation flow, you can choose to "Ignore Warning and Install" to bypass this check.
AstrBot uses a runtime plugin injection mechanism. Therefore, when debugging plugins, you need to start the AstrBot main application.
You can use AstrBot's hot reload feature to streamline the development process.
After modifying the plugin code, you can find your plugin in the AstrBot WebUI's plugin management section, click the ... button in the upper right corner, and select Reload Plugin.
If the plugin fails to load due to code errors or other reasons, you can also click "Try one-click reload fix" in the error prompt on the admin panel to reload it.
Currently, AstrBot manages plugin dependencies using pip's built-in requirements.txt file. If your plugin requires third-party libraries, please be sure to create a requirements.txt file in the plugin directory and list the dependencies used, to prevent Module Not Found errors when users install your plugin.
For the complete format of
requirements.txt, please refer to the pip official documentation.
Thank you for contributing to the AstrBot ecosystem. Please follow these principles when developing plugins, which are also good programming practices:
- Features must be tested.
- Include comprehensive comments.
- Store persistent data in the
datadirectory, not in the plugin's own directory, to prevent data loss when updating/reinstalling the plugin. - Implement robust error handling mechanisms; don't let a single error crash the plugin.
- Before committing, please use the ruff tool to format your code.
- Do not use the
requestslibrary for network requests; use asynchronous network request libraries such asaiohttporhttpx. - If you're extending functionality for an existing plugin, please prioritize submitting a PR to that plugin rather than creating a separate one (unless the original plugin author has stopped maintaining it).
- 首页
- 文档入口
- Top Level
- community events
- deploy
- dev
- others
- platform
- 接入 OneBot v11 协议实现
- 接入钉钉 DingTalk
- 接入 Discord
- 接入 Kook
- 接入飞书
- 接入 LINE
- 接入 Matrix
- 接入 Mattermost
- 接入 Misskey 平台
- 接入 QQ 官方机器人平台
- 通过 QQ官方机器人 接入 QQ (Webhook)
- 通过 QQ官方机器人 接入 QQ (Websockets)
- 接入 Satori 协议
- 接入 server-satori (基于 Koishi)
- 接入 Slack
- 接入消息平台
- 接入 Telegram
- 接入 VoceChat
- AstrBot 接入企业微信
- 接入企业微信智能机器人平台
- AstrBot 接入微信公众平台
- 接入个人微信
- providers
- use
- Home
- Docs Entry
- Top Level
- config
- deploy
- Deploy AstrBot on 1Panel
- Deploy AstrBot on BT Panel
- Deploy AstrBot on CasaOS
- Deploy AstrBot from Source Code
- Community-Provided Deployment Methods
- Deploy via Compshare
- Deploy AstrBot with Docker
- Deploy AstrBot with Kubernetes
- Deploy AstrBot with AstrBot Launcher
- Other Deployments
- Package Manager Deployment (uv)
- Installation via System Package Manager
- Preface
- dev
- ospp
- others
- platform
- Connect OneBot v11 Protocol Implementations
- Connect to DingTalk
- Connecting to Discord
- Connect to KOOK
- Connecting to Lark
- Connecting to LINE
- Connecting to Matrix
- Connecting to Mattermost
- Connecting to Misskey Platform
- Connect QQ Official Bot
- Connect QQ via QQ Official Bot (Webhook)
- Connect QQ via QQ Official Bot (Websockets)
- Connect to Satori Protocol
- Connect server-satori (Koishi)
- Connecting to Slack
- Messaging Platforms
- Connecting to Telegram
- Connect to VoceChat
- Connect AstrBot to WeCom
- Connect to WeCom AI Bot Platform
- Connect AstrBot to WeChat Official Account Platform
- Connect Personal WeChat
- providers
- 接入 302.AI
- Agent Runners
- Built-in Agent Runner
- Connect to Coze
- Connect to Alibaba Cloud Bailian Application
- Connect to DeerFlow
- Connect to Dify
- Connect AIHubMix
- coze
- dashscope
- dify
- 大语言模型提供商
- NewAPI
- 接入 PPIO 派欧云
- 接入 LM Studio 使用 DeepSeek-R1 等模型
- Integrating Ollama
- Connecting to SiliconFlow
- Connecting Model Services
- Connecting to TokenPony
- use
- Agent Runner
- Agent Sandbox Environment ⛵️
- astrbot sandbox
- Docker-based Code Interpreter
- Built-in Commands
- Computer Use
- Context Compression
- Custom Rules
- Function Calling
- AstrBot Knowledge Base
- MCP
- AstrBot Star
- Proactive Capabilities
- Anthropic Skills
- Agent Handoff and SubAgent
- Unified Webhook Mode
- Web Search
- Admin Panel
