更新 pluginsjobs 文档

This commit is contained in:
洛水居室 2022-07-11 16:56:46 +08:00
parent 1b78a7ae5c
commit 03758998e3
No known key found for this signature in database
GPG Key ID: C9DE87DA724B88FC
2 changed files with 40 additions and 1 deletions

39
jobs/README.md Normal file
View File

@ -0,0 +1,39 @@
# jobs 目录
## 说明
改目录存放 BOT 的工作队列呸注册和具体实现
## 基础代码
``` python
import datetime
from telegram.ext import CallbackContext
from jobs.base import RunDailyHandler
from logger import Log
from manager import listener_jobs_class
@listener_jobs_class()
class JobTest:
@classmethod
def build_jobs(cls) -> list:
test = cls()
# 注册每日执行任务
# 执行时间为21点45分
return [
RunDailyHandler(test.test, datetime.time(21, 45, 00), name="测试Job")
]
async def test(self, context: CallbackContext):
Log.info("测试Job[OK]")
```
### 注意
jobs 模块下的类必须提供 `build_jobs` 类方法作为构建相应处理程序给 `handle.py`
只需在构建的类前加上 `@listener_jobs_class()` 修饰器即可

View File

@ -37,7 +37,7 @@ class Example(BasePlugins):
plugins 模块下的类需要继承 `BasePlugins` plugins 模块下的类需要继承 `BasePlugins`
plugins 模块下的类必须提供 `create_handlers` 静态函数作为构建相应处理程序给 `handle.py` plugins 模块下的类必须提供 `create_handlers` 类方法作为构建相应处理程序给 `handle.py`
在函数注册为命令处理过程(如 `CommandHandler` )需要添加 `conversation_error_handler` 修饰器作为错误统一处理 在函数注册为命令处理过程(如 `CommandHandler` )需要添加 `conversation_error_handler` 修饰器作为错误统一处理