50 lines
1.1 KiB
Markdown
50 lines
1.1 KiB
Markdown
# OverUB Plugin Guide
|
|
|
|
## Structure
|
|
A plugin is a Python package placed in `plugins/external/<plugin_name>` with an `__init__.py` file.
|
|
|
|
## Minimal Plugin
|
|
```python
|
|
from core.plugin import Plugin
|
|
|
|
class HelloPlugin(Plugin):
|
|
name = "hello"
|
|
version = "1.0.0"
|
|
author = "you"
|
|
description = "Simple hello plugin"
|
|
|
|
async def on_load(self):
|
|
self.log.info("Hello plugin loaded")
|
|
```
|
|
|
|
## Configuration Schema
|
|
```python
|
|
class MyPlugin(Plugin):
|
|
name = "my_plugin"
|
|
config_schema = {
|
|
"enabled": bool,
|
|
"settings": dict,
|
|
}
|
|
```
|
|
|
|
## Secrets
|
|
```python
|
|
value = self.get_secret("api_key")
|
|
```
|
|
|
|
## Sandbox
|
|
Use `self.context.sandbox` for safe file operations when possible.
|
|
|
|
## Loading
|
|
Enable plugins in `config/config.yml` and place the plugin package in `plugins/external`.
|
|
|
|
## Testing
|
|
Use `core/testing.py` as a base for plugin test scaffolding.
|
|
|
|
## CLI
|
|
- `python -m __main__ create-plugin <name>`
|
|
- `python -m __main__ validate-plugin <path>`
|
|
- `python -m __main__ build-plugin <path>`
|
|
- `python -m __main__ docs-plugin <path>`
|
|
- `python -m __main__ test-plugin <path>`
|