Support Alconna to GraiaProject
Project description
Alconna Graia
������������ Alconna
��� GraiaProject
������������������������
������������������Dispatcher���SayaSchema ��� ������������
������������
���������
from arclet.alconna.graia import AlconnaDispatcher, Match, AlconnaProperty
from arclet.alconna import Alconna, Args
...
app = Ariadne(...)
alc = Alconna("!jrrp", Args["sth", str, 1123])
@app.broadcast.receiver(
GroupMessage,
dispatchers=[AlconnaDispatcher(alc, send_flag='stay')]
)
async def test2(
group: Group,
result: AlconnaProperty[GroupMessage],
sth: Match[str]
):
print("sign:", result.result)
print("sender:", group)
print("match", sth.available, sth.result)
������ Saya
in module.py:
from arclet.alconna.graia import Alc, Match, AlconnaProperty, AlconnaSchema
from arclet.alconna import Alconna, Args
...
channel = Channel.current()
alc = Alconna("!jrrp", Args["sth", str, 1123])
@channel.use(AlconnaSchema(Alc(alc)))
@channel.use(ListenerSchema([GroupMessage]))
async def test2(group: Group, result: AlconnaProperty[GroupMessage], sth: Match[str]):
print("sign:", result.result)
print("sender:", group)
print("match", sth.available, sth.result)
in main.py:
from arclet.alconna.graia import AlconnaBehaviour
from creart import create
...
saya = create(Saya)
create(AlconnaBehaviour)
with saya.module_context():
saya.require("module")
������ Saya Util
in module.py:
from graia.ariadne.util.saya import listen
from arclet.alconna.graia import Match, command, from_command
from arclet.alconna import Alconna, Args, Arpamar
...
@command(Alconna("!jrrp", Args["sth", str, 1123]), private=False)
async def test2(group: Group, result: Arpamar, sth: Match[str]):
print("sign:", result)
print("sender:", group)
print("match", sth.available, sth.result)
@from_command("foo bar {baz}")
@listen(GroupMessage)
async def test2(baz: int):
print("baz", baz)
in main.py:
from creart import create
...
saya = create(Saya)
with saya.module_context():
saya.require("module")
AlconnaDispatcher ������������
class AlconnaDispatcher(BaseDispatcher):
def __init__(
self,
command: Union[Alconna, AlconnaGroup],
*,
send_flag: Literal["reply", "post", "stay"] = "stay",
skip_for_unmatch: bool = True,
send_handler: Optional[Callable[[str], MessageChain]] = None,
allow_quote: bool = False
): ...
command
: ��������� Alconna ������
send_flag
: ���������������������������������������
- reply: ������������������������������
- post: ��������������� Broadcast ������
- stay: ������ AlconnaProperty ������������������������
skip_for_unmatch
: ���������������������������, ��������������������� send_flag ������
send_handler
: send_flag ��� reply ��� ���������������������������
allow_quote
: ������������������������������������������
������������
-
Match
: ������������������������������������foo: Match[int]
���������������Match.available
������������������������������Match.result
������������������ -
Query
: ������������������������������������������sth: Query[int] = Query("foo.bar")
���������������������������Query("foo.bar", 1234)
���������������Query.available
������������������������������Query.result
������������������
������������
from arclet.alconna.graia import Alc, Match
...
app = Ariadne(...)
@app.broadcast.receiver(
GroupMessage, dispatchers=[Alc.from_format("foo bar {baz:int}")]
)
async def test2(group: Group, baz: Match[int]):
print("sender:", group)
print("match", baz.available, baz.result)
or
from arclet.alconna.graia import Match, AlconnaSchema
...
channel = Channel.current()
@channel.use(AlconnaSchema.from_("foo <arg:str>", "bar"))
@channel.use(ListenerSchema([GroupMessage]))
async def test2(group: Group, sth: Match[str]):
print("sender:", group)
print("match", sth.available, sth.result)
������
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
Hashes for arclet-alconna-graia-0.4.8.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | f3d7e50ba65deaa7a97a956e72b26f704101c071e4959de065ab9e08a1a3581e |
|
MD5 | 5702ba02151bbaf3f57b5155130fb75a |
|
BLAKE2b-256 | b14b4fa6e66a2ae1b770ec0c6a8430fd2a1a5d456d47ba246f4d712262fec5ff |
Hashes for arclet_alconna_graia-0.4.8-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bbff7424a73ea5336a46b788601ee5ce79d1ff443196524395033b5ba0b1ca64 |
|
MD5 | 01b17e61b5d5f3f7a6ebd19eb9ab2abb |
|
BLAKE2b-256 | ebd6f6246a8fc68fdaf55754c508afc9b0ea21bf60d06f45ea6f59ae3eeba732 |