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 AlconnaDispatcher, Match, AlconnaProperty, AlconnaSchema
from arclet.alconna import Alconna, Args
...
channel = Channel.current()
alc = Alconna("!jrrp", Args["sth", str, 1123])
@channel.use(AlconnaSchema(AlconnaDispatcher(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 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}")
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
: ������������������������������������������
������������
Query
Match
������������
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)
������
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 arclet-alconna-graia-0.4.7.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | d43748a59fed2c9331f937d986965fe1c8c34791e0270d49bdd95f2046cdbdcf |
|
MD5 | def1908a744f84e2eb8d077d4a8f8266 |
|
BLAKE2b-256 | a8389f277ceae2d4b6fcb5eb27d0c68bf188979dff2b43da3bb43fbb9ca4b536 |
Close
Hashes for arclet_alconna_graia-0.4.7.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7c1e4a56950018c0f69e51d049fde7bff1ff952d29c01a4340a5971f496575f5 |
|
MD5 | f738d52e6247f2d85d2ec3b51fb716be |
|
BLAKE2b-256 | 00e5981c328a0a3e0520a35283cf86daf1fe9d4fa2eb924f873d76173a9df40b |