Files
PWF/README.md
2025-11-05 16:57:37 +08:00

84 lines
1.9 KiB
Markdown

# README
## Clone
use recursive
```bash
git clone --recursive <repository_url>
```
or
```bash
git clone <repository_url>
cd Convention
git submodule update --init --recursive
```
## First Start
use
```bash
python app.py
```
to start and generate **Assets** Folder(generate by [ProjectConfig](Convention/Runtime/GlobalConfig.py))
## Assets
Every default argument define in **Assets/config.json**,
properties in **find** is define the arguments value where you not setting
Sometimes some property not exists in config,
just because program not running to the place where argument been referenced
## Arguments
### Commandline and Config
- **--main-webhook-url** main target of the message will be send, **needed**
- **--host** default: 0.0.0.0
- **--port** default: 8000
- **--verbose** default: false
### Only Config
- **max_concurrent_requests** default: 100
- **database_path** file on [Assets](Assets), default: db.db
- **plugin_dir** where plugins load, default: Plugins
## Plugins
First import interface and define class
```python
from CoreModules.plugin_interface import PluginInterface, DatabaseModel
class MyPlugin(PluginInterface):
def generate_router_callback(self):
"""生成路由回调函数,必需实现"""
async def callback():
return {"message": "Hello from MyPlugin"}
return callback
def register_db_model(self):
"""注册数据库模型,可选实现"""
return DatabaseModel(
table_name="my_plugin_table",
column_names=["id", "data", "created_at"],
column_defs={
"id": "INTEGER PRIMARY KEY",
"data": "TEXT",
"created_at": "INTEGER"
}
)
def dependencies(self):
"""定义依赖的插件类,可选实现"""
return [] # 返回空列表表示无依赖
def wake_up(self):
"""依赖插件注册完成后调用,可选实现"""
pass
```