mirror of
https://github.com/PaiGramTeam/PaiGram.git
synced 2024-11-22 07:07:46 +00:00
✨更新 plugins
和 jobs
文档
This commit is contained in:
parent
1b78a7ae5c
commit
03758998e3
39
jobs/README.md
Normal file
39
jobs/README.md
Normal 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()` 修饰器即可
|
@ -37,7 +37,7 @@ class Example(BasePlugins):
|
||||
|
||||
plugins 模块下的类需要继承 `BasePlugins`
|
||||
|
||||
plugins 模块下的类必须提供 `create_handlers` 静态函数作为构建相应处理程序给 `handle.py`
|
||||
plugins 模块下的类必须提供 `create_handlers` 类方法作为构建相应处理程序给 `handle.py`
|
||||
|
||||
在函数注册为命令处理过程(如 `CommandHandler` )需要添加 `conversation_error_handler` 修饰器作为错误统一处理
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user