Skip to main content

An alternative for got-and-reject in Nonebot

Project description

nonebot-plugin-waiter

该插件提供一个 got-and-reject 会话控制的替代方案,可自由控制超时时间

安装

pip install nonebot-plugin-waiter

使用

from nonebot import on_command
from nonebot.adapters import Event
from nonebot_plugin_waiter import waiter

test = on_command("test")

@test.handle()
async def _(event: Event):
    await test.send("请输入数字")

    @waiter(test)
    async def check(event1: Event):
        if event.get_session_id() == event1.get_session_id():
            return event1.get_plaintext()

    async for resp in check(timeout=60):
        if resp is None:
            await test.send("等待超时")
            break
        if not resp.isdigit():
            await test.send("请输入数字")
            continue
        await test.send(f"你输入了{resp}")
        break

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_waiter-0.1.0.tar.gz (3.3 kB view hashes)

Uploaded Source

Built Distribution

nonebot_plugin_waiter-0.1.0-py3-none-any.whl (3.5 kB view hashes)

Uploaded Python 3

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