Skip to main content

Alconna Adapter for Nonebot

Project description

nonebot

NoneBot Plugin Alconna

✨ Alconna Usage For NoneBot2 ✨

license pypi python

该插件提供了 AlconnaNonebot2 适配版本与工具

使用方法

Matcher 与 依赖注入

from nonebot_plugin_alconna import (
    on_alconna, 
    Match, 
    AlconnaMatch, 
    AlconnaResult, 
    AlconnaMatches,
    AlconnaCommandResult
)
from arclet.alconna import Alconna, Args, Arparma

test = on_alconna(Alconna("test", Args["foo", int]["bar", bool]))


@test.handle()
async def handle_test1(result: AlconnaCommandResult = AlconnaResult()):
    await test.send(f"matched: {result.matched}")
    await test.send(f"maybe output: {result.output}")

@test.handle()
async def handle_test2(result: Arparma = AlconnaMatches()):
    await test.send(f"head result: {result.header_result}")
    await test.send(f"args: {result.all_matched_args}")

@test.handle()
async def handle_test3(foo: Match[int] = AlconnaMatch("foo")):
    if foo.available:    
        await test.send(f"foo={foo.result}")

MessageSegment Mark

from nonebot_plugin_alconna.adapters.onebot import Mention
from nonebot.adapters.onebot.v12 import Message, MessageSegment
from arclet.alconna import Alconna, Args

msg = Message(["Hello!", MessageSegment.mention("123")])
print(msg)  # Hello![mention:user_id=123]

alc = Alconna("Hello!", Args["target", Mention])
res = alc.parse(msg)
assert res.matched
assert res.target.data['user_id'] == '123'

提供了 MessageSegment Mark 的协议:

协议名称 状态
OneBot 协议
Telegram
飞书
GitHub
QQ 频道
钉钉
Console
开黑啦 🚧
Mirai 🚧
Ntchat 🚧
MineCraft (Spigot) 🚧
BiliBili Live 🚧

Project details


Release history Release notifications | RSS feed

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

Uploaded Source

Built Distribution

nonebot_plugin_alconna-0.1.0-py3-none-any.whl (12.1 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