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.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 76afd57eb0c303f56ed910537dbd6499a0da0e8e1061029816252b7c2be9f35f |
|
MD5 | 115b0228dde0aa6631aa4ce370f6b8ae |
|
BLAKE2b-256 | 799fb321ef2fffdfda466529df9db57617b9c15db998c3e52899d69eeddf0a35 |
Hashes for arclet_alconna_graia-0.4.8.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5493208c6c789b98a3d12638fc93315e93df2e1cfa81a1454194848b5b7ee652 |
|
MD5 | 1bf757e876cd0cb5dd79ec10a3ad7fed |
|
BLAKE2b-256 | f363a43dfcbf077739022896579d1a54d5c63755cee303625a24eab1c70aada2 |