A nonebot plugin for running some func before closing the bot
Project description
🤔 这是什么
这个插件为 NoneBot2 实现了优雅关机(Graceful Shutdown)(查看 nonebot/nonebot2#2479)
即等待事件处理完毕后再关机
同时它还允许你在关机前运行一些函数,类似于on_shutdown
但是优先级更高,可以保证在bot
断连之前执行
💿 安装
🚀 使用 uv
uv add nonebot-plugin-wait-a-minute
🚀 使用 PDM
pdm add nonebot-plugin-wait-a-minute
🚀 使用 poetry
poetry add nonebot-plugin-wait-a-minute
♿️ 如何使用
from nonebot import require, on_command
from nonebot.matcher import Matcher
require('nonebot_plugin_wait_a_minute') # require plugin
from nonebot_plugin_wait_a_minute import graceful, on_shutdown_before
# 优雅关机
@on_command('foo').handle()
@graceful() # 👈 添加 graceful 装饰器到 handle 装饰器下面
# 或者,你可以使用 @graceful(block=True) 来阻止进入关机等待时运行新的 handle
async def _(matcher: Matcher):
matcher.send('foo')
# 关机前 hook
@on_shutdown_before
def _():
# 整点啥()
...
# 或者使用 async
@on_shutdown_before
async def _():
# await 整点啥()
...
📄 LICENSE
本项目使用 MIT 许可证开源
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file nonebot_plugin_wait_a_minute-0.4.0.tar.gz
.
File metadata
- Download URL: nonebot_plugin_wait_a_minute-0.4.0.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: pdm/2.19.3 CPython/3.10.12 Linux/6.5.0-1025-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2687103efd560fc45b84852743ee066db97b685bc0bb8e71b38b640f4d29452d |
|
MD5 | 73d03f297b7c167b6da302b2f6e73af9 |
|
BLAKE2b-256 | c7d1cfc681a259cac3d82ec79244cc807db72c8f7b8c1604de39f1372864b800 |
File details
Details for the file nonebot_plugin_wait_a_minute-0.4.0-py3-none-any.whl
.
File metadata
- Download URL: nonebot_plugin_wait_a_minute-0.4.0-py3-none-any.whl
- Upload date:
- Size: 5.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: pdm/2.19.3 CPython/3.10.12 Linux/6.5.0-1025-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2ed0d0076c0ae46c1a33a9364d22a66ce38bc584aa628d798333b2585c3c90de |
|
MD5 | c67a3874c7e74382b5a10826425902d2 |
|
BLAKE2b-256 | 8c3c02841f353ba773519748f693c1e9c4ed7fac45621652f8e15cbd3545a606 |