Skip to main content

A nonebot plugin for running some func before closing the bot

Project description

logo

等会先

✨ 一个 NoneBot2 插件,让你可以在关机前执行一些操作 ✨

Python PyPI - Version pdm-managed Ruff


简体中文 | English

🤔 这是什么

这个插件为 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

nonebot_plugin_wait_a_minute-0.3.1.tar.gz (4.6 kB view hashes)

Uploaded Source

Built Distribution

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page