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.4.0.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file nonebot_plugin_wait_a_minute-0.4.0.tar.gz.

File metadata

File hashes

Hashes for nonebot_plugin_wait_a_minute-0.4.0.tar.gz
Algorithm Hash digest
SHA256 2687103efd560fc45b84852743ee066db97b685bc0bb8e71b38b640f4d29452d
MD5 73d03f297b7c167b6da302b2f6e73af9
BLAKE2b-256 c7d1cfc681a259cac3d82ec79244cc807db72c8f7b8c1604de39f1372864b800

See more details on using hashes here.

File details

Details for the file nonebot_plugin_wait_a_minute-0.4.0-py3-none-any.whl.

File metadata

File hashes

Hashes for nonebot_plugin_wait_a_minute-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2ed0d0076c0ae46c1a33a9364d22a66ce38bc584aa628d798333b2585c3c90de
MD5 c67a3874c7e74382b5a10826425902d2
BLAKE2b-256 8c3c02841f353ba773519748f693c1e9c4ed7fac45621652f8e15cbd3545a606

See more details on using hashes here.

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