From ff479138a9a438f82b1d1613cbb05fab65ec30cf Mon Sep 17 00:00:00 2001 From: RF-Tar-Railt Date: Sat, 23 Nov 2024 15:13:51 +0800 Subject: [PATCH] :bookmark: version 0.54.0 --- README.md | 39 ++++++++++--------- pdm.lock | 38 +++++++++--------- src/nonebot_plugin_alconna/__init__.py | 2 +- .../adapters/__init__.py | 1 + src/nonebot_plugin_alconna/adapters/mail.py | 14 +++++++ src/nonebot_plugin_alconna/argv.py | 4 +- src/nonebot_plugin_alconna/uniseg/__init__.py | 2 +- 7 files changed, 59 insertions(+), 41 deletions(-) create mode 100644 src/nonebot_plugin_alconna/adapters/mail.py diff --git a/README.md b/README.md index afedff7..46c54cc 100644 --- a/README.md +++ b/README.md @@ -93,6 +93,7 @@ async def _(): | [Dodo IM](https://github.com/nonebot/adapter-dodo) | adapters.dodo | | [Kritor](https://github.com/nonebot/adapter-kritor) | adapters.kritor | | [Tailchat](https://github.com/eya46/nonebot-adapter-tailchat) | adapters.tailchat | +| [Mail](https://github.com/mobyw/nonebot-adapter-mail) | adapters.mail | ### 支持的消息元素 @@ -107,25 +108,25 @@ async def _(): > [!WARNING] > 斜体的协议名称意味着其协议或其适配器长时间未维护或已失效 -| 元素\适配器 | 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 | ✅ | ✅ | ✅ | ✅ | ➖ | ✅ | ✅ | ➖ | ✅ | ✅ | ✅ | ➖ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | +| 元素\适配器 | OneBot V11 | OneBot V12 | Telegram | 飞书 | Github | QQ-API | _钉钉_ | Console | 开黑啦 | Mirai | _Ntchat_ | MineCraft | Discord | _Red_ | Satori | Dodo IM | Kritor | Tailchat | Mail | +|------------------|------------|------------|----------|----|--------|--------|------|---------|-----|-------|----------|-----------|---------|-------|--------|---------|--------|----------|------| +| 文本 Text | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | +| 样式文本 Styled Text | 🚫 | 🚫 | ✅ | 🚫 | ✅ | ✅ | ❌ | ✅ | ✅ | 🚫 | 🚫 | ✅ | 🚫 | 🚫 | ✅ | 🚫 | 🚫 | ✅ | ✅ | +| 提及用户 At(user) | ✅ | ✅ | ✅ | ✅ | ⬆️ | ✅ | ✅ | 🚫 | ✅ | ✅ | ❌ | 🚫 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ⬆️ | +| 提及角色 At(role) | 🚫 | 🚫 | 🚫 | 🚫 | 🚫 | 🚫 | 🚫 | 🚫 | ✅ | 🚫 | 🚫 | 🚫 | ✅ | 🚫 | ✅ | ✅ | 🚫 | 🚫 | 🚫 | +| 提及频道 At(channel) | 🚫 | 🚫 | 🚫 | 🚫 | 🚫 | ✅ | 🚫 | 🚫 | ✅ | 🚫 | 🚫 | 🚫 | ✅ | 🚫 | ✅ | ✅ | 🚫 | ✅ | ⬆️ | +| 提交全体 AtAll | ✅ | ✅ | 🚫 | ✅ | 🚫 | ✅ | ✅ | 🚫 | ✅ | ✅ | 🚫 | 🚫 | ✅ | ✅ | ✅ | ✅ | ✅ | 🚫 | 🚫 | +| 表情 Emoji | ✅ | 🚫 | ✅ | 🚫 | 🚫 | ✅ | 🚫 | ✅ | ✅ | ✅ | 🚫 | 🚫 | ✅ | ✅ | 🚫 | 🚫 | ✅ | ✅ | 🚫 | +| 图片 Image | ✅ | ✅ | ✅ | ✅ | ⬆️ | ✅ | ✅ | 🚫 | ✅ | ✅ | ✅ | ❌ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | +| 音频 Audio | ⬆️ | ✅ | ✅ | ✅ | 🚫 | ✅ | 🚫 | 🚫 | ✅ | ⬆️ | ⬇️ | 🚫 | ⬆️ | ⬆️ | ✅ | 🚫 | ⬆️ | 🚫 | ✅ | +| 语音 Voice | ✅ | ✅ | ✅ | ⬆️ | 🚫 | ⬆️ | 🚫 | 🚫 | ⬆️ | ✅ | ⬇️ | 🚫 | ⬆️ | ✅ | ⬆️ | 🚫 | ✅ | 🚫 | ✅ | +| 视频 Video | ✅ | ✅ | ✅ | ✅ | 🚫 | ✅ | 🚫 | 🚫 | ✅ | ✅ | ✅ | 🚫 | ⬆️ | ✅ | ✅ | ✅ | ✅ | 🚫 | ✅ | +| 文件 File | ⬇️ | ✅ | ✅ | ✅ | 🚫 | ✅ | 🚫 | 🚫 | ✅ | ✅ | ✅ | 🚫 | ⬆️ | ✅ | ✅ | ⬇️ | ⬇️ | ✅ | ✅ | +| 回复 Reply | ✅ | ✅ | ✅ | ✅ | 🚫 | ✅ | 🚫 | 🚫 | ✅ | ✅ | ✅ | 🚫 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | +| 引用转发 Reference | ✅ | 🚫 | 🚫 | 🚫 | 🚫 | 🚫 | 🚫 | 🚫 | 🚫 | ✅ | 🚫 | 🚫 | 🚫 | ✅ | ✅ | 🚫 | ✅ | 🚫 | 🚫 | +| 超级消息 Hyper | ✅ | 🚫 | 🚫 | ⬇️ | 🚫 | ✅ | 🚫 | 🚫 | ✅ | ✅ | ✅ | 🚫 | 🚫 | ✅ | 🚫 | 🚫 | ✅ | 🚫 | 🚫 | +| 按钮 Button | 🚫 | 🚫 | ⬆️ | 🚫 | 🚫 | ✅ | 🚫 | 🚫 | 🚫 | 🚫 | 🚫 | ⬆️ | ✅ | 🚫 | ✅ | 🚫 | ✅ | 🚫 | 🚫 | +| 其余 Other | ✅ | ✅ | ✅ | ✅ | ➖ | ✅ | ✅ | ➖ | ✅ | ✅ | ✅ | ➖ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ➖ | ## 配置项 diff --git a/pdm.lock b/pdm.lock index 4b3223d..2b038f8 100644 --- a/pdm.lock +++ b/pdm.lock @@ -1919,28 +1919,28 @@ files = [ [[package]] name = "ruff" -version = "0.7.4" +version = "0.8.0" requires_python = ">=3.7" summary = "An extremely fast Python linter and code formatter, written in Rust." files = [ - {file = "ruff-0.7.4-py3-none-linux_armv6l.whl", hash = "sha256:a4919925e7684a3f18e18243cd6bea7cfb8e968a6eaa8437971f681b7ec51478"}, - {file = "ruff-0.7.4-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:cfb365c135b830778dda8c04fb7d4280ed0b984e1aec27f574445231e20d6c63"}, - {file = "ruff-0.7.4-py3-none-macosx_11_0_arm64.whl", hash = "sha256:63a569b36bc66fbadec5beaa539dd81e0527cb258b94e29e0531ce41bacc1f20"}, - {file = "ruff-0.7.4-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0d06218747d361d06fd2fdac734e7fa92df36df93035db3dc2ad7aa9852cb109"}, - {file = "ruff-0.7.4-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:e0cea28d0944f74ebc33e9f934238f15c758841f9f5edd180b5315c203293452"}, - {file = "ruff-0.7.4-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:80094ecd4793c68b2571b128f91754d60f692d64bc0d7272ec9197fdd09bf9ea"}, - {file = "ruff-0.7.4-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:997512325c6620d1c4c2b15db49ef59543ef9cd0f4aa8065ec2ae5103cedc7e7"}, - {file = "ruff-0.7.4-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:00b4cf3a6b5fad6d1a66e7574d78956bbd09abfd6c8a997798f01f5da3d46a05"}, - {file = "ruff-0.7.4-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:7dbdc7d8274e1422722933d1edddfdc65b4336abf0b16dfcb9dedd6e6a517d06"}, - {file = "ruff-0.7.4-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0e92dfb5f00eaedb1501b2f906ccabfd67b2355bdf117fea9719fc99ac2145bc"}, - {file = "ruff-0.7.4-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:3bd726099f277d735dc38900b6a8d6cf070f80828877941983a57bca1cd92172"}, - {file = "ruff-0.7.4-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:2e32829c429dd081ee5ba39aef436603e5b22335c3d3fff013cd585806a6486a"}, - {file = "ruff-0.7.4-py3-none-musllinux_1_2_i686.whl", hash = "sha256:662a63b4971807623f6f90c1fb664613f67cc182dc4d991471c23c541fee62dd"}, - {file = "ruff-0.7.4-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:876f5e09eaae3eb76814c1d3b68879891d6fde4824c015d48e7a7da4cf066a3a"}, - {file = "ruff-0.7.4-py3-none-win32.whl", hash = "sha256:75c53f54904be42dd52a548728a5b572344b50d9b2873d13a3f8c5e3b91f5cac"}, - {file = "ruff-0.7.4-py3-none-win_amd64.whl", hash = "sha256:745775c7b39f914238ed1f1b0bebed0b9155a17cd8bc0b08d3c87e4703b990d6"}, - {file = "ruff-0.7.4-py3-none-win_arm64.whl", hash = "sha256:11bff065102c3ae9d3ea4dc9ecdfe5a5171349cdd0787c1fc64761212fc9cf1f"}, - {file = "ruff-0.7.4.tar.gz", hash = "sha256:cd12e35031f5af6b9b93715d8c4f40360070b2041f81273d0527683d5708fce2"}, + {file = "ruff-0.8.0-py3-none-linux_armv6l.whl", hash = "sha256:fcb1bf2cc6706adae9d79c8d86478677e3bbd4ced796ccad106fd4776d395fea"}, + {file = "ruff-0.8.0-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:295bb4c02d58ff2ef4378a1870c20af30723013f441c9d1637a008baaf928c8b"}, + {file = "ruff-0.8.0-py3-none-macosx_11_0_arm64.whl", hash = "sha256:7b1f1c76b47c18fa92ee78b60d2d20d7e866c55ee603e7d19c1e991fad933a9a"}, + {file = "ruff-0.8.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:eb0d4f250a7711b67ad513fde67e8870109e5ce590a801c3722580fe98c33a99"}, + {file = "ruff-0.8.0-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:0e55cce9aa93c5d0d4e3937e47b169035c7e91c8655b0974e61bb79cf398d49c"}, + {file = "ruff-0.8.0-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:3f4cd64916d8e732ce6b87f3f5296a8942d285bbbc161acee7fe561134af64f9"}, + {file = "ruff-0.8.0-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:c5c1466be2a2ebdf7c5450dd5d980cc87c8ba6976fb82582fea18823da6fa362"}, + {file = "ruff-0.8.0-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:2dabfd05b96b7b8f2da00d53c514eea842bff83e41e1cceb08ae1966254a51df"}, + {file = "ruff-0.8.0-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:facebdfe5a5af6b1588a1d26d170635ead6892d0e314477e80256ef4a8470cf3"}, + {file = "ruff-0.8.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:87a8e86bae0dbd749c815211ca11e3a7bd559b9710746c559ed63106d382bd9c"}, + {file = "ruff-0.8.0-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:85e654f0ded7befe2d61eeaf3d3b1e4ef3894469cd664ffa85006c7720f1e4a2"}, + {file = "ruff-0.8.0-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:83a55679c4cb449fa527b8497cadf54f076603cc36779b2170b24f704171ce70"}, + {file = "ruff-0.8.0-py3-none-musllinux_1_2_i686.whl", hash = "sha256:812e2052121634cf13cd6fddf0c1871d0ead1aad40a1a258753c04c18bb71bbd"}, + {file = "ruff-0.8.0-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:780d5d8523c04202184405e60c98d7595bdb498c3c6abba3b6d4cdf2ca2af426"}, + {file = "ruff-0.8.0-py3-none-win32.whl", hash = "sha256:5fdb6efecc3eb60bba5819679466471fd7d13c53487df7248d6e27146e985468"}, + {file = "ruff-0.8.0-py3-none-win_amd64.whl", hash = "sha256:582891c57b96228d146725975fbb942e1f30a0c4ba19722e692ca3eb25cc9b4f"}, + {file = "ruff-0.8.0-py3-none-win_arm64.whl", hash = "sha256:ba93e6294e9a737cd726b74b09a6972e36bb511f9a102f1d9a7e1ce94dd206a6"}, + {file = "ruff-0.8.0.tar.gz", hash = "sha256:a7ccfe6331bf8c8dad715753e157457faf7351c2b69f62f32c165c2dbcbacd44"}, ] [[package]] diff --git a/src/nonebot_plugin_alconna/__init__.py b/src/nonebot_plugin_alconna/__init__.py index 5e118c1..7d0029a 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.53.1" +__version__ = "0.54.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 81c7184..26bc118 100644 --- a/src/nonebot_plugin_alconna/adapters/__init__.py +++ b/src/nonebot_plugin_alconna/adapters/__init__.py @@ -7,6 +7,7 @@ "Github": "github", "Kritor": "kritor", "Kaiheila": "kook", + "Mail": "mail", "Minecraft": "minecraft", "Mirai": "mirai", "ntchat": "ntchat", diff --git a/src/nonebot_plugin_alconna/adapters/mail.py b/src/nonebot_plugin_alconna/adapters/mail.py new file mode 100644 index 0000000..ead5505 --- /dev/null +++ b/src/nonebot_plugin_alconna/adapters/mail.py @@ -0,0 +1,14 @@ +from nonebot.adapters.mail.message import MessageSegment + +from nonebot_plugin_alconna.uniseg.segment import Text, Media +from nonebot_plugin_alconna.typings import SegmentPattern, TextSegmentPattern + +Attachment = SegmentPattern("attachment", MessageSegment, Media, MessageSegment.attachment) + + +def is_html(self, text: Text): + if text.extract_most_style().startswith("html"): + return MessageSegment.html(text.text) + + +Markup = TextSegmentPattern("html", MessageSegment, MessageSegment.html, is_html) diff --git a/src/nonebot_plugin_alconna/argv.py b/src/nonebot_plugin_alconna/argv.py index 89058e1..9e09e87 100644 --- a/src/nonebot_plugin_alconna/argv.py +++ b/src/nonebot_plugin_alconna/argv.py @@ -9,7 +9,7 @@ from nonebot.adapters import Message from arclet.alconna import NullMessage from nepattern import MatchMode, BasePattern, MatchFailed -from arclet.alconna.argv import Argv, argv_config, set_default_argv_type +from arclet.alconna.argv import Argv, argv_config, set_default_argv_type, set_namespace_argv_type from .uniseg import Text, Segment, UniMessage @@ -183,3 +183,5 @@ def converter(data: str | list[str | Segment]) -> UniMessage: argv_config(MessageArgv, converter=converter) set_default_argv_type(MessageArgv) +set_namespace_argv_type("nonebot", MessageArgv) +set_namespace_argv_type("arclet", Argv) diff --git a/src/nonebot_plugin_alconna/uniseg/__init__.py b/src/nonebot_plugin_alconna/uniseg/__init__.py index beff9f5..782ea55 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 alter_get_builder, alter_get_fetcher, alter_get_exporter -__version__ = "0.53.1" +__version__ = "0.54.0" __plugin_meta__ = PluginMetadata( name="Universal Segment 插件",