Skip to content

Commit

Permalink
🔖 version 0.13.0
Browse files Browse the repository at this point in the history
  • Loading branch information
RF-Tar-Railt committed Jul 31, 2023
1 parent cb5979d commit 6964f61
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/nonebot_plugin_alconna/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from .consts import ALCONNA_EXEC_RESULT as ALCONNA_EXEC_RESULT
from .rule import set_output_converter as set_output_converter

__version__ = "0.12.1"
__version__ = "0.13.0"

_meta_source = {
"name": "Alconna 插件",
Expand Down
4 changes: 3 additions & 1 deletion src/nonebot_plugin_alconna/adapters/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ def _handle_kmarkdown_met(seg: MessageSegment):
{
"at": lambda seg: At(seg, str(seg.data.get("qq", seg.data.get("user_id")))),
"mention": lambda seg: At(seg, seg.data.get("user_id", seg.data.get("text"))),
"mention_user": lambda seg: At(seg, str(seg.data.get("user_id", seg.data["mention_user"].user_id))),
"mention_user": lambda seg: At(
seg, str(seg.data.get("user_id", seg.data["mention_user"].user_id))
),
"mention_robot": lambda seg: At(seg, str(seg.data["mention_robot"].bot_id)),
"At": lambda seg: At(seg, str(seg, seg.data["target"])),
"kmarkdown": _handle_kmarkdown_met,
Expand Down
41 changes: 25 additions & 16 deletions src/nonebot_plugin_alconna/adapters/villa.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,38 @@ class VillaMessageArgv(MessageArgv):
)

Text = str
MentionUser = SegmentPattern("mention_user", MessageSegment, MessageSegment.mention_user)
MentionRobot = SegmentPattern("mention_robot", MessageSegment, MessageSegment.mention_robot)
MentionUser = SegmentPattern(
"mention_user", MessageSegment, MessageSegment.mention_user
)
MentionRobot = SegmentPattern(
"mention_robot", MessageSegment, MessageSegment.mention_robot
)
MentionAll = SegmentPattern("mention_all", MessageSegment, MessageSegment.mention_all)
RoomLink = SegmentPattern("room_link", MessageSegment, MessageSegment.room_link)
Link = SegmentPattern("link", MessageSegment, MessageSegment.link)
Quote = SegmentPattern("quote", MessageSegment, MessageSegment.quote)
Image = SegmentPattern("image", MessageSegment, MessageSegment.image)
Post = SegmentPattern("post", MessageSegment, MessageSegment.post)
PreviewLink = SegmentPattern("preview_link", MessageSegment, MessageSegment.preview_link)
PreviewLink = SegmentPattern(
"preview_link", MessageSegment, MessageSegment.preview_link
)
Badge = SegmentPattern("badge", MessageSegment, MessageSegment.badge)

ImgOrUrl = UnionPattern(
[
BasePattern(
model=PatternModel.TYPE_CONVERT,
origin=str,
converter=lambda _, x: x.data["file_id"],
alias="img",
accepts=[Image],
),
URL,
]
) @ "img_url"
ImgOrUrl = (
UnionPattern(
[
BasePattern(
model=PatternModel.TYPE_CONVERT,
origin=str,
converter=lambda _, x: x.data["file_id"],
alias="img",
accepts=[Image],
),
URL,
]
)
@ "img_url"
)
"""
内置类型, 允许传入图片元素(Image)或者链接(URL),返回链接
"""
Expand Down Expand Up @@ -79,4 +88,4 @@ class VillaMessageArgv(MessageArgv):
)
"""
内置类型,允许传入@用户 或者 @机器人 或者'@xxxx'式样的字符串或者数字, 返回数字
"""
"""
1 change: 1 addition & 0 deletions src/nonebot_plugin_alconna/typings.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ def _isinstance(
except (KeyError, AttributeError):
return None


def gen_unit(
model: type[T],
mapping: dict[str, Callable[[MessageSegment], T | Literal[False] | None]],
Expand Down

0 comments on commit 6964f61

Please sign in to comment.