Skip to content

Commit

Permalink
⬆️ version 0.48.0
Browse files Browse the repository at this point in the history
RF-Tar-Railt committed Jun 26, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 67b162c commit bf7dd6e
Showing 7 changed files with 44 additions and 35 deletions.
8 changes: 4 additions & 4 deletions pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ authors = [
dependencies = [
"tarina>=0.5.4",
"nepattern>=0.7.4",
"arclet-alconna>=1.8.15",
"arclet-alconna>=1.8.16",
"arclet-alconna-tools>=0.7.6",
"importlib-metadata>=4.13.0",
"nonebot2>=2.3.0",
2 changes: 1 addition & 1 deletion src/nonebot_plugin_alconna/__init__.py
Original file line number Diff line number Diff line change
@@ -126,7 +126,7 @@
from .uniseg import SupportAdapterModule as SupportAdapterModule
from .extension import add_global_extension as add_global_extension

__version__ = "0.47.2"
__version__ = "0.48.0"

__plugin_meta__ = PluginMetadata(
name="Alconna 插件",
38 changes: 20 additions & 18 deletions src/nonebot_plugin_alconna/builtins/uniseg/music_share.py
Original file line number Diff line number Diff line change
@@ -7,8 +7,8 @@

from nonebot_plugin_alconna.uniseg.builder import MessageBuilder
from nonebot_plugin_alconna.uniseg.exporter import MessageExporter
from nonebot_plugin_alconna.uniseg import Segment, custom_handler, custom_register
from nonebot_plugin_alconna.uniseg.constraint import SupportAdapter
from nonebot_plugin_alconna.uniseg import Segment, custom_handler, custom_register


class MusicShareKind(str, Enum):
@@ -70,14 +70,22 @@ class MusicShare(Segment):
def music_build(builder: MessageBuilder, seg: BaseMessageSegment):
if builder.get_adapter() is SupportAdapter.kritor:
from nonebot.adapters.kritor.protos.kritor.common import MusicElementMusicPlatform

kind = {
MusicElementMusicPlatform.NETEASE: MusicShareKind.NeteaseCloudMusic,
MusicElementMusicPlatform.QQ: MusicShareKind.QQMusic,
}.get(seg.data["platform"], MusicShareKind.Custom)
if "id" in seg.data:
return MusicShare(kind=kind, id=seg.data["id"])
data = seg.data["custom"]
return MusicShare(kind=kind, url=data["url"], title=data["title"], brief=data["author"], thumbnail=data["pic"], audio=data["audio"])
return MusicShare(
kind=kind,
url=data["url"],
title=data["title"],
brief=data["author"],
thumbnail=data["pic"],
audio=data["audio"],
)
elif builder.get_adapter() is SupportAdapter.mirai_official:
data = seg.data
return MusicShare(
@@ -87,7 +95,7 @@ def music_build(builder: MessageBuilder, seg: BaseMessageSegment):
url=data["jump_url"],
thumbnail=data["picture_url"],
audio=data["music_url"],
brief=data["brief"]
brief=data["brief"],
)


@@ -101,19 +109,19 @@ def music_mirai_community(builder: MessageBuilder, seg: BaseMessageSegment):
url=data["jumpUrl"],
thumbnail=data["pictureUrl"],
audio=data["musicUrl"],
brief=data["brief"]
brief=data["brief"],
)


@custom_handler(MusicShare)
async def music_export(exporter: MessageExporter, seg: MusicShare, bot: Bot, fallback):
if exporter.get_adapter() is SupportAdapter.kritor:
from nonebot.adapters.kritor.protos.kritor.common import MusicElementMusicPlatform
from nonebot.adapters.kritor.message import Music
from nonebot.adapters.kritor.protos.kritor.common import MusicElementMusicPlatform

platform = {
MusicShareKind.NeteaseCloudMusic: MusicElementMusicPlatform.NETEASE,
MusicShareKind.QQMusic: MusicElementMusicPlatform.QQ
MusicShareKind.QQMusic: MusicElementMusicPlatform.QQ,
}.get(seg.kind, MusicElementMusicPlatform.CUSTOM)

if seg.id:
@@ -127,22 +135,16 @@ async def music_export(exporter: MessageExporter, seg: MusicShare, bot: Bot, fal
"audio": seg.audio or "",
"title": seg.title or "",
"author": seg.brief or seg.content or "",
"pic": seg.thumbnail or ""
}
}
"pic": seg.thumbnail or "",
},
},
)

if exporter.get_adapter() is SupportAdapter.mirai_official:
from nonebot.adapters.mirai.message import MessageSegment

return MessageSegment.music(
seg.kind.value,
seg.title,
seg.content,
seg.url,
seg.thumbnail,
seg.audio,
seg.brief
seg.kind.value, seg.title, seg.content, seg.url, seg.thumbnail, seg.audio, seg.brief
)

if exporter.get_adapter() is SupportAdapter.mirai_community:
@@ -155,7 +157,7 @@ async def music_export(exporter: MessageExporter, seg: MusicShare, bot: Bot, fal
seg.url or "",
seg.thumbnail or "",
seg.audio or "",
seg.brief or ""
seg.brief or "",
)

if exporter.get_adapter() is SupportAdapter.onebot11:
@@ -176,7 +178,7 @@ async def music_export(exporter: MessageExporter, seg: MusicShare, bot: Bot, fal
audio=seg.audio or "",
title=seg.title or "",
content=seg.content or seg.brief or "",
img_url=seg.thumbnail or ""
img_url=seg.thumbnail or "",
)
res.data["subtype"] = platform
return res
10 changes: 5 additions & 5 deletions src/nonebot_plugin_alconna/uniseg/__init__.py
Original file line number Diff line number Diff line change
@@ -51,7 +51,7 @@
from .constraint import SupportAdapterModule as SupportAdapterModule
from .adapters import BUILDER_MAPPING, FETCHER_MAPPING, EXPORTER_MAPPING

__version__ = "0.47.2"
__version__ = "0.48.0"

__plugin_meta__ = PluginMetadata(
name="Universal Segment 插件",
@@ -73,15 +73,15 @@


def patch_saa() -> _Dispose:
from .utils import saa
from .utils.saa import patch

return saa.dispose
return patch()


def patch_matcher_send() -> _Dispose:
from .utils import matcher
from .utils.matcher import patch

return matcher.dispose
return patch()


def apply_filehost():
10 changes: 7 additions & 3 deletions src/nonebot_plugin_alconna/uniseg/utils/matcher.py
Original file line number Diff line number Diff line change
@@ -38,8 +38,12 @@ async def send(

_OLD_SEND = Matcher.send

Matcher.send = classmethod(send) # type: ignore

def patch():

def dispose():
Matcher.send = _OLD_SEND # type: ignore
Matcher.send = classmethod(send) # type: ignore

def dispose():
Matcher.send = classmethod(_OLD_SEND) # type: ignore

return dispose
9 changes: 6 additions & 3 deletions src/nonebot_plugin_alconna/uniseg/utils/saa.py
Original file line number Diff line number Diff line change
@@ -89,8 +89,11 @@ async def send(self: MessageFactory, *, at_sender=False, reply=False) -> "SaaRec
_OLD_SEND = MessageFactory.send


MessageFactory.send = send
def patch():

MessageFactory.send = send

def dispose():
MessageFactory.send = _OLD_SEND # type: ignore
def dispose():
MessageFactory.send = _OLD_SEND # type: ignore

return dispose

0 comments on commit bf7dd6e

Please sign in to comment.