Skip to content

Commit

Permalink
🐛 version 0.36.1
Browse files Browse the repository at this point in the history
fix rule order
  • Loading branch information
RF-Tar-Railt committed Feb 1, 2024
1 parent 483ec6e commit eb7c0d0
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 3 deletions.
68 changes: 68 additions & 0 deletions example/plugins/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
Option,
Alconna,
Arparma,
MultiVar,
Subcommand,
Duplication,
SubcommandStub,
Expand Down Expand Up @@ -443,3 +444,70 @@ async def receive(event1: Event, msg: UniMsg):
break
await cmd.send("验证失败,请重新输入:")
continue


hd = on_alconna(
Alconna(
"请求处理",
Args["handle", ["-fa", "-fr", "-fi", "-ga", "-gr", "-gi"]]["id", str],
)
)

hd.shortcut(
r"dddd(\d+)",
fuzzy=False,
command="请求处理 -fa {0}",
)

hd.shortcut(
"dddd",
fuzzy=True,
command="请求处理 -fa {%0}",
)


@hd.handle()
async def hd_h(handle: str, id: str):
await hd.send(f"handle: {handle}\nid: {id}")


setu = on_alconna(
Alconna(
"setu",
Args["count", int, 1],
Option("r18", action=store_true, default=False, help_text="是否开启R18模式"),
Option("tags", Args["tags", MultiVar(str, "*")], help_text="指定标签"),
)
)


def wrapper(slot: Union[int, str], content: str):
if slot == 0:
if not content:
return "1"
if content == "点":
import random

return str(random.randint(1, 5))
return content


setu.shortcut(
r"(?:要|我要|给我|来|抽)(点|\d*)(?:张|个|份|幅)?(?:涩|色|瑟)图",
command="setu {0} tags",
fuzzy=True,
wrapper=wrapper,
)

setu.shortcut(
r"(?:要|我要|给我|来|抽)(点|\d*)(?:张|个|份|幅)?(.+?)的?(?:涩|色|瑟)图",
command="setu {0}",
arguments=["tags", "{1}"],
fuzzy=True,
wrapper=wrapper,
)


@setu.handle()
async def setu_h(count: int, tags: Match[tuple[str, ...]]):
await setu.send(f"数量: {count}\n标签: {tags.result}")
2 changes: 1 addition & 1 deletion src/nonebot_plugin_alconna/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
from .consts import ALCONNA_EXEC_RESULT as ALCONNA_EXEC_RESULT
from .extension import add_global_extension as add_global_extension

__version__ = "0.36.0"
__version__ = "0.36.1"

__plugin_meta__ = PluginMetadata(
name="Alconna 插件",
Expand Down
2 changes: 1 addition & 1 deletion src/nonebot_plugin_alconna/matcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -945,7 +945,7 @@ def on_alconna(
{
"_source": source,
"type": "",
"rule": rule & _rule,
"rule": _rule & rule,
"permission": Permission() | permission,
"handlers": [
handler
Expand Down
2 changes: 1 addition & 1 deletion src/nonebot_plugin_alconna/uniseg/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
from .params import UniversalMessage as UniversalMessage
from .params import UniversalSegment as UniversalSegment

__version__ = "0.36.0"
__version__ = "0.36.1"

__plugin_meta__ = PluginMetadata(
name="Universal Segment 插件",
Expand Down

0 comments on commit eb7c0d0

Please sign in to comment.