Alconna Adapter for Nonebot
Project description
NoneBot Plugin Alconna
✨ Alconna Usage For NoneBot2 ✨
该插件提供了 Alconna 的 Nonebot2
适配版本与工具
使用方法
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
Built Distribution
Close
Hashes for nonebot-plugin-alconna-0.1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 38dfd7a515e61a2c3d169795d83ba0d4b4f64d6c41ab970070b7671b55f0eb51 |
|
MD5 | 86220bdc96dba826adb7a79a9db0cc3c |
|
BLAKE2b-256 | 14a663e75771a8d49f5fbccb1594d4d4eccafac3cb666ee7d5b3b0fd791972ff |
Close
Hashes for nonebot_plugin_alconna-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e21edfc8ee2a8781e668472ca1d30d32d184315534bebd89662f50844fcb8592 |
|
MD5 | 9473067112263e6d7577ce3dd9fe5096 |
|
BLAKE2b-256 | 93c277b4b001cbeacb2988c5606dacb106929b46c532376e9de117c24fd1b0ac |