Skip to main content

A nonebot plugin for running some func before closing the bot

Project description

logo

等会先

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

Python PyPI - Version uv 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.5.0.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nonebot_plugin_wait_a_minute-0.5.0-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: nonebot_plugin_wait_a_minute-0.5.0.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for nonebot_plugin_wait_a_minute-0.5.0.tar.gz
Algorithm Hash digest
SHA256 cb4cd59d84104c42dc584a7e06632aa6f8030125bc80125eb6aef241a48cd61b
MD5 69d467cab3e43f46414632241526aeca
BLAKE2b-256 96411ba835a5f8d965400df77c3f9364509a436aac649f740a53354fdafca517

See more details on using hashes here.

File details

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

File metadata

  • Download URL: nonebot_plugin_wait_a_minute-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 4.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for nonebot_plugin_wait_a_minute-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 28d930615390411e94f3e6f9b96d29968bc3ad96e777cf8ff5ec8fcb6e89b045
MD5 52e4f12e29e883ab1f0b8e4d9c5f4a6c
BLAKE2b-256 f6b3c7cc8f7c74a76f7e6f55ffe61aa692738d23f98dae1243d6f9ec585e3be4

See more details on using hashes here.

Supported by

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