From 1a7911d4d36bbef1da550ea10456e1314ee1326f Mon Sep 17 00:00:00 2001 From: RF-Tar-Railt Date: Sat, 24 Aug 2024 15:21:35 +0800 Subject: [PATCH] :fire: version 0.52.0 --- README.md | 39 +++++++++---------- docs.md | 3 +- example/bot.py | 2 +- src/nonebot_plugin_alconna/__init__.py | 2 +- .../adapters/__init__.py | 1 - .../adapters/bilibili.py | 1 - src/nonebot_plugin_alconna/rule.py | 8 ++-- src/nonebot_plugin_alconna/uniseg/__init__.py | 2 +- .../uniseg/adapters/bilibili/__init__.py | 17 -------- .../uniseg/adapters/bilibili/builder.py | 15 ------- .../uniseg/adapters/bilibili/exporter.py | 39 ------------------- .../uniseg/constraint.py | 3 -- src/nonebot_plugin_alconna/uniseg/segment.py | 2 +- src/nonebot_plugin_alconna/uniseg/target.py | 7 ---- 14 files changed, 29 insertions(+), 112 deletions(-) delete mode 100644 src/nonebot_plugin_alconna/adapters/bilibili.py delete mode 100644 src/nonebot_plugin_alconna/uniseg/adapters/bilibili/__init__.py delete mode 100644 src/nonebot_plugin_alconna/uniseg/adapters/bilibili/builder.py delete mode 100644 src/nonebot_plugin_alconna/uniseg/adapters/bilibili/exporter.py diff --git a/README.md b/README.md index 579d3d5..eb75e44 100644 --- a/README.md +++ b/README.md @@ -86,7 +86,6 @@ async def _(): | [Mirai](https://docs.mirai.mamoe.net/mirai-api-http/) | adapters.mirai | | [Ntchat](https://github.com/JustUndertaker/adapter-ntchat) | adapters.ntchat | | [MineCraft](https://github.com/17TheWord/nonebot-adapter-minecraft) | adapters.minecraft | -| [BiliBili Live](https://github.com/wwweww/adapter-bilibili) | adapters.bilibili | | [Walle-Q](https://github.com/onebot-walle/nonebot_adapter_walleq) | adapters.onebot12 | | [Discord](https://github.com/nonebot/adapter-discord) | adapters.discord | | [Red 协议](https://github.com/nonebot/adapter-red) | adapters.red | @@ -108,25 +107,25 @@ async def _(): > [!WARNING] > 斜体的协议名称意味着其协议或其适配器长时间未维护或已失效 -| 元素\适配器 | OneBot V11 | OneBot V12 | Telegram | 飞书 | Github | QQ-API | _钉钉_ | Console | 开黑啦 | Mirai | _Ntchat_ | MineCraft | _BiliBili Live_ | Discord | _Red_ | Satori | Dodo IM | Kritor | Tailchat | -|------------------|------------|------------|----------|----|--------|--------|------|---------|-----|-------|----------|-----------|-----------------|---------|-------|--------|---------|--------|----------| -| 文本 Text | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| 样式文本 Styled Text | 🚫 | 🚫 | ✅ | 🚫 | ✅ | ✅ | ❌ | ✅ | ✅ | 🚫 | 🚫 | ✅ | 🚫 | 🚫 | 🚫 | ✅ | 🚫 | 🚫 | ✅ | -| 提及用户 At(user) | ✅ | ✅ | ✅ | ✅ | ⬆️ | ✅ | ✅ | 🚫 | ✅ | ✅ | ❌ | 🚫 | 🚫 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| 提及角色 At(role) | 🚫 | 🚫 | 🚫 | 🚫 | 🚫 | 🚫 | 🚫 | 🚫 | ✅ | 🚫 | 🚫 | 🚫 | 🚫 | ✅ | 🚫 | ✅ | ✅ | 🚫 | 🚫 | -| 提及频道 At(channel) | 🚫 | 🚫 | 🚫 | 🚫 | 🚫 | ✅ | 🚫 | 🚫 | ✅ | 🚫 | 🚫 | 🚫 | 🚫 | ✅ | 🚫 | ✅ | ✅ | 🚫 | ✅ | -| 提交全体 AtAll | ✅ | ✅ | 🚫 | ✅ | 🚫 | ✅ | ✅ | 🚫 | ✅ | ✅ | 🚫 | 🚫 | 🚫 | ✅ | ✅ | ✅ | ✅ | ✅ | 🚫 | -| 表情 Emoji | ✅ | 🚫 | ✅ | 🚫 | 🚫 | ✅ | 🚫 | ✅ | ✅ | ✅ | 🚫 | 🚫 | 🚫 | ✅ | ✅ | 🚫 | 🚫 | ✅ | ✅ | -| 图片 Image | ✅ | ✅ | ✅ | ✅ | ⬆️ | ✅ | ✅ | 🚫 | ✅ | ✅ | ✅ | ❌ | 🚫 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| 音频 Audio | ⬆️ | ✅ | ✅ | ✅ | 🚫 | ✅ | 🚫 | 🚫 | ✅ | ⬆️ | ⬇️ | 🚫 | 🚫 | ⬆️ | ⬆️ | ✅ | 🚫 | ⬆️ | 🚫 | -| 语音 Voice | ✅ | ✅ | ✅ | ⬆️ | 🚫 | ⬆️ | 🚫 | 🚫 | ⬆️ | ✅ | ⬇️ | 🚫 | 🚫 | ⬆️ | ✅ | ⬆️ | 🚫 | ✅ | 🚫 | -| 视频 Video | ✅ | ✅ | ✅ | ✅ | 🚫 | ✅ | 🚫 | 🚫 | ✅ | ✅ | ✅ | 🚫 | 🚫 | ⬆️ | ✅ | ✅ | ✅ | ✅ | 🚫 | -| 文件 File | ⬇️ | ✅ | ✅ | ✅ | 🚫 | ✅ | 🚫 | 🚫 | ✅ | ✅ | ✅ | 🚫 | 🚫 | ⬆️ | ✅ | ✅ | ⬇️ | ⬇️ | ✅ | -| 回复 Reply | ✅ | ✅ | ✅ | ✅ | 🚫 | ✅ | 🚫 | 🚫 | ✅ | ✅ | ✅ | 🚫 | 🚫 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| 引用转发 Reference | ✅ | 🚫 | 🚫 | 🚫 | 🚫 | 🚫 | 🚫 | 🚫 | 🚫 | ✅ | 🚫 | 🚫 | 🚫 | 🚫 | ✅ | ✅ | 🚫 | ✅ | 🚫 | -| 超级消息 Hyper | ✅ | 🚫 | 🚫 | ⬇️ | 🚫 | ✅ | 🚫 | 🚫 | ✅ | ✅ | ✅ | 🚫 | 🚫 | 🚫 | ✅ | 🚫 | 🚫 | ✅ | 🚫 | -| 按钮 Button | 🚫 | 🚫 | ⬆️ | 🚫 | 🚫 | ✅ | 🚫 | 🚫 | 🚫 | 🚫 | 🚫 | ⬆️ | 🚫 | ✅ | 🚫 | ✅ | 🚫 | ✅ | 🚫 | -| 其余 Other | ✅ | ✅ | ✅ | ✅ | ➖ | ✅ | ✅ | ➖ | ✅ | ✅ | ✅ | ➖ | ➖ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | +| 元素\适配器 | OneBot V11 | OneBot V12 | Telegram | 飞书 | Github | QQ-API | _钉钉_ | Console | 开黑啦 | Mirai | _Ntchat_ | MineCraft | Discord | _Red_ | Satori | Dodo IM | Kritor | Tailchat | +|------------------|------------|------------|----------|----|--------|--------|------|---------|-----|-------|----------|-----------|---------|-------|--------|---------|--------|----------| +| 文本 Text | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | +| 样式文本 Styled Text | 🚫 | 🚫 | ✅ | 🚫 | ✅ | ✅ | ❌ | ✅ | ✅ | 🚫 | 🚫 | ✅ | 🚫 | 🚫 | ✅ | 🚫 | 🚫 | ✅ | +| 提及用户 At(user) | ✅ | ✅ | ✅ | ✅ | ⬆️ | ✅ | ✅ | 🚫 | ✅ | ✅ | ❌ | 🚫 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | +| 提及角色 At(role) | 🚫 | 🚫 | 🚫 | 🚫 | 🚫 | 🚫 | 🚫 | 🚫 | ✅ | 🚫 | 🚫 | 🚫 | ✅ | 🚫 | ✅ | ✅ | 🚫 | 🚫 | +| 提及频道 At(channel) | 🚫 | 🚫 | 🚫 | 🚫 | 🚫 | ✅ | 🚫 | 🚫 | ✅ | 🚫 | 🚫 | 🚫 | ✅ | 🚫 | ✅ | ✅ | 🚫 | ✅ | +| 提交全体 AtAll | ✅ | ✅ | 🚫 | ✅ | 🚫 | ✅ | ✅ | 🚫 | ✅ | ✅ | 🚫 | 🚫 | ✅ | ✅ | ✅ | ✅ | ✅ | 🚫 | +| 表情 Emoji | ✅ | 🚫 | ✅ | 🚫 | 🚫 | ✅ | 🚫 | ✅ | ✅ | ✅ | 🚫 | 🚫 | ✅ | ✅ | 🚫 | 🚫 | ✅ | ✅ | +| 图片 Image | ✅ | ✅ | ✅ | ✅ | ⬆️ | ✅ | ✅ | 🚫 | ✅ | ✅ | ✅ | ❌ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | +| 音频 Audio | ⬆️ | ✅ | ✅ | ✅ | 🚫 | ✅ | 🚫 | 🚫 | ✅ | ⬆️ | ⬇️ | 🚫 | ⬆️ | ⬆️ | ✅ | 🚫 | ⬆️ | 🚫 | +| 语音 Voice | ✅ | ✅ | ✅ | ⬆️ | 🚫 | ⬆️ | 🚫 | 🚫 | ⬆️ | ✅ | ⬇️ | 🚫 | ⬆️ | ✅ | ⬆️ | 🚫 | ✅ | 🚫 | +| 视频 Video | ✅ | ✅ | ✅ | ✅ | 🚫 | ✅ | 🚫 | 🚫 | ✅ | ✅ | ✅ | 🚫 | ⬆️ | ✅ | ✅ | ✅ | ✅ | 🚫 | +| 文件 File | ⬇️ | ✅ | ✅ | ✅ | 🚫 | ✅ | 🚫 | 🚫 | ✅ | ✅ | ✅ | 🚫 | ⬆️ | ✅ | ✅ | ⬇️ | ⬇️ | ✅ | +| 回复 Reply | ✅ | ✅ | ✅ | ✅ | 🚫 | ✅ | 🚫 | 🚫 | ✅ | ✅ | ✅ | 🚫 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | +| 引用转发 Reference | ✅ | 🚫 | 🚫 | 🚫 | 🚫 | 🚫 | 🚫 | 🚫 | 🚫 | ✅ | 🚫 | 🚫 | 🚫 | ✅ | ✅ | 🚫 | ✅ | 🚫 | +| 超级消息 Hyper | ✅ | 🚫 | 🚫 | ⬇️ | 🚫 | ✅ | 🚫 | 🚫 | ✅ | ✅ | ✅ | 🚫 | 🚫 | ✅ | 🚫 | 🚫 | ✅ | 🚫 | +| 按钮 Button | 🚫 | 🚫 | ⬆️ | 🚫 | 🚫 | ✅ | 🚫 | 🚫 | 🚫 | 🚫 | 🚫 | ⬆️ | ✅ | 🚫 | ✅ | 🚫 | ✅ | 🚫 | +| 其余 Other | ✅ | ✅ | ✅ | ✅ | ➖ | ✅ | ✅ | ➖ | ✅ | ✅ | ✅ | ➖ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ## 配置项 diff --git a/docs.md b/docs.md index e67b4cf..64206f7 100644 --- a/docs.md +++ b/docs.md @@ -423,10 +423,9 @@ async def handle(): | [钉钉](https://github.com/nonebot/adapter-ding) | adapters.ding | | [Console](https://github.com/nonebot/adapter-console) | adapters.console | | [开黑啦](https://github.com/Tian-que/nonebot-adapter-kaiheila) | adapters.kook | -| [Mirai](https://github.com/ieew/nonebot_adapter_mirai2) | adapters.mirai, adapters.mirai2 | +| [Mirai](https://github.com/nonebot/adapter-mirai) | adapters.mirai, adapters.mirai2 | | [Ntchat](https://github.com/JustUndertaker/adapter-ntchat) | adapters.ntchat | | [MineCraft](https://github.com/17TheWord/nonebot-adapter-minecraft) | adapters.minecraft | -| [BiliBili Live](https://github.com/wwweww/adapter-bilibili) | adapters.bilibili | | [Walle-Q](https://github.com/onebot-walle/nonebot_adapter_walleq) | adapters.onebot12 | | [Discord](https://github.com/nonebot/adapter-discord) | adapters.discord | | [Red 协议](https://github.com/nonebot/adapter-red) | adapters.red | diff --git a/example/bot.py b/example/bot.py index 7ac6a34..d25a359 100644 --- a/example/bot.py +++ b/example/bot.py @@ -10,7 +10,7 @@ # driver.register_adapter(SatoriAdapter) # nonebot.require("nonebot_plugin_alconna") -nonebot.load_plugin("plugins.demo") +nonebot.load_plugin("plugins.demo1") async def _(): diff --git a/src/nonebot_plugin_alconna/__init__.py b/src/nonebot_plugin_alconna/__init__.py index dc93575..8b794a9 100644 --- a/src/nonebot_plugin_alconna/__init__.py +++ b/src/nonebot_plugin_alconna/__init__.py @@ -137,7 +137,7 @@ from .uniseg import SupportAdapterModule as SupportAdapterModule from .extension import add_global_extension as add_global_extension -__version__ = "0.51.4" +__version__ = "0.52.0" __plugin_meta__ = PluginMetadata( name="Alconna 插件", diff --git a/src/nonebot_plugin_alconna/adapters/__init__.py b/src/nonebot_plugin_alconna/adapters/__init__.py index 62a37a2..81c7184 100644 --- a/src/nonebot_plugin_alconna/adapters/__init__.py +++ b/src/nonebot_plugin_alconna/adapters/__init__.py @@ -1,5 +1,4 @@ MAPPING = { - "BilibiliLive": "bilibili", "Console": "console", "Ding": "ding", "Discord": "discord", diff --git a/src/nonebot_plugin_alconna/adapters/bilibili.py b/src/nonebot_plugin_alconna/adapters/bilibili.py deleted file mode 100644 index dd80d2d..0000000 --- a/src/nonebot_plugin_alconna/adapters/bilibili.py +++ /dev/null @@ -1 +0,0 @@ -Danmu = str diff --git a/src/nonebot_plugin_alconna/rule.py b/src/nonebot_plugin_alconna/rule.py index ba73ddc..fc00272 100644 --- a/src/nonebot_plugin_alconna/rule.py +++ b/src/nonebot_plugin_alconna/rule.py @@ -77,9 +77,11 @@ def __init__( self.auto_send = True if config.alconna_auto_send_output is None else config.alconna_auto_send_output else: self.auto_send = auto_send_output - if ( - config.alconna_use_command_start if use_cmd_start is None else use_cmd_start - ) and global_config.command_start: + if use_cmd_start is None: + _use_cmd_start = False if config.alconna_use_command_start is None else config.alconna_use_command_start + else: + _use_cmd_start = use_cmd_start + if _use_cmd_start and global_config.command_start: with command_manager.update(command): if command.prefixes: if command.command: diff --git a/src/nonebot_plugin_alconna/uniseg/__init__.py b/src/nonebot_plugin_alconna/uniseg/__init__.py index db9cbdc..b9bf495 100644 --- a/src/nonebot_plugin_alconna/uniseg/__init__.py +++ b/src/nonebot_plugin_alconna/uniseg/__init__.py @@ -58,7 +58,7 @@ from .constraint import SupportAdapterModule as SupportAdapterModule from .adapters import BUILDER_MAPPING, FETCHER_MAPPING, EXPORTER_MAPPING -__version__ = "0.51.4" +__version__ = "0.52.0" __plugin_meta__ = PluginMetadata( name="Universal Segment 插件", diff --git a/src/nonebot_plugin_alconna/uniseg/adapters/bilibili/__init__.py b/src/nonebot_plugin_alconna/uniseg/adapters/bilibili/__init__.py deleted file mode 100644 index 9370b5d..0000000 --- a/src/nonebot_plugin_alconna/uniseg/adapters/bilibili/__init__.py +++ /dev/null @@ -1,17 +0,0 @@ -from nonebot_plugin_alconna.uniseg.loader import BaseLoader -from nonebot_plugin_alconna.uniseg.constraint import SupportAdapter - - -class Loader(BaseLoader): - def get_adapter(self) -> SupportAdapter: - return SupportAdapter.bilibili - - def get_builder(self): - from .builder import BilibiliMessageBuilder - - return BilibiliMessageBuilder() - - def get_exporter(self): - from .exporter import BilibiliMessageExporter - - return BilibiliMessageExporter() diff --git a/src/nonebot_plugin_alconna/uniseg/adapters/bilibili/builder.py b/src/nonebot_plugin_alconna/uniseg/adapters/bilibili/builder.py deleted file mode 100644 index 706ac2d..0000000 --- a/src/nonebot_plugin_alconna/uniseg/adapters/bilibili/builder.py +++ /dev/null @@ -1,15 +0,0 @@ -from nonebot.adapters.bilibili.message import MessageSegment # type: ignore - -from nonebot_plugin_alconna.uniseg.segment import Text -from nonebot_plugin_alconna.uniseg.constraint import SupportAdapter -from nonebot_plugin_alconna.uniseg.builder import MessageBuilder, build - - -class BilibiliMessageBuilder(MessageBuilder): - @classmethod - def get_adapter(cls) -> SupportAdapter: - return SupportAdapter.bilibili - - @build("text") - def text(self, seg: MessageSegment): - return Text(seg.data["text"]) diff --git a/src/nonebot_plugin_alconna/uniseg/adapters/bilibili/exporter.py b/src/nonebot_plugin_alconna/uniseg/adapters/bilibili/exporter.py deleted file mode 100644 index fe2c747..0000000 --- a/src/nonebot_plugin_alconna/uniseg/adapters/bilibili/exporter.py +++ /dev/null @@ -1,39 +0,0 @@ -from typing import Union, cast - -from nonebot.adapters import Bot, Event -from nonebot.adapters.bilibili.adapter import Adapter # type: ignore -from nonebot.adapters.bilibili.event import MessageEvent # type: ignore -from nonebot.adapters.bilibili.message import Message, MessageSegment # type: ignore - -from nonebot_plugin_alconna.uniseg.segment import Text -from nonebot_plugin_alconna.uniseg.constraint import SupportScope, SupportAdapter -from nonebot_plugin_alconna.uniseg.exporter import Target, MessageExporter, export - - -class BilibiliMessageExporter(MessageExporter["Message"]): - def get_message_type(self): - return Message - - @classmethod - def get_adapter(cls) -> SupportAdapter: - return SupportAdapter.bilibili - - def get_target(self, event: Event, bot: Union[Bot, None] = None) -> Target: - return Target( - event.get_user_id(), - adapter=self.get_adapter(), - self_id=bot.self_id if bot else None, - scope=SupportScope.bilibili, - ) - - def get_message_id(self, event: Event) -> str: - assert isinstance(event, MessageEvent) - return str(event.session_id) # type: ignore - - @export - async def text(self, seg: Text, bot: Union[Bot, None]) -> MessageSegment: - return MessageSegment.danmu(seg.text) - - async def send_to(self, target: Union[Target, Event], bot: Bot, message: Message, **kwargs): - adapter: Adapter = cast(Adapter, bot.adapter) - return await adapter.bili.send(str(message), bot.self_id) diff --git a/src/nonebot_plugin_alconna/uniseg/constraint.py b/src/nonebot_plugin_alconna/uniseg/constraint.py index 3ddcbef..a24192d 100644 --- a/src/nonebot_plugin_alconna/uniseg/constraint.py +++ b/src/nonebot_plugin_alconna/uniseg/constraint.py @@ -11,7 +11,6 @@ class SupportAdapter(str, Enum): """支持的适配器""" - bilibili = "BilibiliLive" console = "Console" ding = "Ding" discord = "Discord" @@ -50,7 +49,6 @@ class SupportScope(str, Enum): kook = "Kaiheila" minecraft = "Minecraft" github = "GitHub" - bilibili = "Bilibili" console = "Console" ding = "Ding" wechat = "WeChat" @@ -96,7 +94,6 @@ def ensure_satori(platform: str): class SupportAdapterModule(str, Enum): """支持的适配器的模块路径""" - bilibili = "nonebot.adapters.bilibili" console = "nonebot.adapters.console" ding = "nonebot.adapters.ding" discord = "nonebot.adapters.discord" diff --git a/src/nonebot_plugin_alconna/uniseg/segment.py b/src/nonebot_plugin_alconna/uniseg/segment.py index 1ade0f8..8d990d7 100644 --- a/src/nonebot_plugin_alconna/uniseg/segment.py +++ b/src/nonebot_plugin_alconna/uniseg/segment.py @@ -95,7 +95,7 @@ def data(self) -> dict[str, Any]: res.pop("_children", None) return res - def __call__(self, *segments: Union[str, "Segment"]) -> Self: + def __call__(self, *segments: Union[str, "TS"]) -> Self: if not segments: return self self._children.extend(Text(s) if isinstance(s, str) else s for s in segments) diff --git a/src/nonebot_plugin_alconna/uniseg/target.py b/src/nonebot_plugin_alconna/uniseg/target.py index 3b2d2f3..cbf9a76 100644 --- a/src/nonebot_plugin_alconna/uniseg/target.py +++ b/src/nonebot_plugin_alconna/uniseg/target.py @@ -429,13 +429,6 @@ async def select_github(target: "Target", bot: Bot): return bot.adapter.get_name() == SupportAdapter.github -@_register(SupportScope.bilibili) -async def select_bilibili(target: "Target", bot: Bot): - if target.channel or target.private: - return False - return bot.adapter.get_name() == SupportAdapter.bilibili - - @_register(SupportScope.console) async def select_console(target: "Target", bot: Bot): if target.channel: