From 24c00dd9b941dc2dca125b859e205c5b45042be7 Mon Sep 17 00:00:00 2001 From: RF-Tar-Railt Date: Sun, 8 Dec 2024 17:55:04 +0800 Subject: [PATCH] :sparkles: global completion-session config --- README.md | 2 +- example/.env.prod | 5 + example/bot.py | 2 +- pdm.lock | 156 +++++++++--------- pyproject.toml | 2 +- src/nonebot_plugin_alconna/config.py | 5 + src/nonebot_plugin_alconna/i18n/.config.json | 3 +- .../i18n/.lang.schema.json | 22 +-- .../i18n/.template.json | 11 +- src/nonebot_plugin_alconna/i18n/en-US.json | 8 +- src/nonebot_plugin_alconna/i18n/model.py | 20 +-- src/nonebot_plugin_alconna/i18n/zh-CN.json | 8 +- src/nonebot_plugin_alconna/model.py | 4 +- src/nonebot_plugin_alconna/rule.py | 34 ++-- 14 files changed, 134 insertions(+), 148 deletions(-) diff --git a/README.md b/README.md index 51a10cb..e4694e1 100644 --- a/README.md +++ b/README.md @@ -133,7 +133,7 @@ async def _(): - ALCONNA_AUTO_SEND_OUTPUT : 是否全局启用输出信息自动发送 - ALCONNA_USE_COMMAND_START : 是否将 COMMAND_START 作为全局命令前缀 -- ALCONNA_AUTO_COMPLETION: 是否全局启用补全会话功能 +- ALCONNA_GLOBAL_COMPLETION: 全局的补全会话配置 (不代表全局启用补全会话) - ALCONNA_USE_ORIGIN: 是否全局使用原始消息 (即未经过 to_me 等处理的) - ALCONNA_USE_PARAM: 是否使用特制的 Param 提供更好的依赖注入 - ALCONNA_USE_CMD_SEP: 是否将 COMMAND_SEP 作为全局命令分隔符 diff --git a/example/.env.prod b/example/.env.prod index fc1450e..f6fb7a0 100644 --- a/example/.env.prod +++ b/example/.env.prod @@ -3,6 +3,11 @@ HOST=127.0.0.1 PORT=9555 ALCONNA_AUTO_SEND_OUTPUT=true ALCONNA_USE_COMMAND_START=true +ALCONNA_GLOBAL_COMPLETION=' +{ + "tab": "true" +} +' NBP_ALC_PAGE_SIZE=6 LOG_LEVEL=DEBUG COMMAND_START=["."] diff --git a/example/bot.py b/example/bot.py index 53a3a4d..5a4f1b1 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_plugins("plugins") async def _(): diff --git a/pdm.lock b/pdm.lock index 2b038f8..0fb471f 100644 --- a/pdm.lock +++ b/pdm.lock @@ -2001,90 +2001,90 @@ files = [ [[package]] name = "tarina" -version = "0.6.7" +version = "0.6.8" requires_python = ">=3.9" summary = "A collection of common utils for Arclet" dependencies = [ "typing-extensions>=4.4.0", ] files = [ - {file = "tarina-0.6.7-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:a54c0dd2a8213eef78ae9229f8214e497a012a7c3da25423a239e417e39b0775"}, - {file = "tarina-0.6.7-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:e3106022d5655bc142b5766f17620c0f9a6ba5a0036c482f9e9c6156ce3ac738"}, - {file = "tarina-0.6.7-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:d3cae2e29c3d57c81cca84b99e634ef9633e92f2d6c41b564c1af9ec05a71c47"}, - {file = "tarina-0.6.7-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e3c47ab9ad835807d357fbbd6ad158a36e9a4944c4edda0e46f9a3bfb5b75ea9"}, - {file = "tarina-0.6.7-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:32639e1197a9c54b8dcfc4cef5de01af64f874e99ec842172ed256a1b821594b"}, - {file = "tarina-0.6.7-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:a0c3a50094dd2d6271e79775462a9a253c9bf49c42769edd7ce173ee250e9a4b"}, - {file = "tarina-0.6.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3c239b48dc82c0be24c55a92d261268cb890737ecf8024ea260e635cdb2a0650"}, - {file = "tarina-0.6.7-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:3c6669c78be73cf2f1b89e60e2e3b2946f03c9eaf69dcfe4ea747a8e1f2d7290"}, - {file = "tarina-0.6.7-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:b5f3303be5ef3d41325902d907a726eb008dde485ea8946dd47fe00d160c2ec6"}, - {file = "tarina-0.6.7-cp310-cp310-musllinux_1_2_i686.whl", hash = "sha256:177a29a5184ac52a6cc79f201eecd7e70159dfdfb270fd2c0f35d78ce9082094"}, - {file = "tarina-0.6.7-cp310-cp310-musllinux_1_2_ppc64le.whl", hash = "sha256:de3ff80d7d8014799f157b8bf3e0836ee93ce0e79eb978b1211a43599a675518"}, - {file = "tarina-0.6.7-cp310-cp310-musllinux_1_2_s390x.whl", hash = "sha256:b402eafdfe455eab55db7a6c2884a555e4c212c23a84b69fb0202781ed3587a4"}, - {file = "tarina-0.6.7-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:f91b737345e703c18f3fc7b802b5b8437636282f893ca0ebca08a9322d8433fc"}, - {file = "tarina-0.6.7-cp310-cp310-win32.whl", hash = "sha256:8d4622952c44c26efd9752edad46689eaf0ff720f538a9de6d44fb8fc3c0b09b"}, - {file = "tarina-0.6.7-cp310-cp310-win_amd64.whl", hash = "sha256:68871b82399e5afe6f2bab0d2e15868e632d53470a51b7c99c7b24aff25f9fc1"}, - {file = "tarina-0.6.7-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:b9057930edad8e7ab3395acfed3eb740b55f0f531e3c7759b52ff88bba1f76f7"}, - {file = "tarina-0.6.7-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:549f3eea41e61e5ffbb3bcac190b9cf23f2d0679622df789d314bdec456064b2"}, - {file = "tarina-0.6.7-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:1e792d0c6a73c02590ee9ad8903ad5314805bc9952b8dbf4a56f08b8d863c664"}, - {file = "tarina-0.6.7-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ee0a3af2f1cf6c8c97a692e5dd4bc1bc42ebd09101e2e2ba8dfbc31de7c37afd"}, - {file = "tarina-0.6.7-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:f2875d1eab24c658e84a9dfd26ed04bb4f1ec629b6842544968a76641176693f"}, - {file = "tarina-0.6.7-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:d49d17d25eab0961b3130436252b7e570fb1131e866a268e18c84a4bc284ae56"}, - {file = "tarina-0.6.7-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:41f0da6676a438547d126446a0b66df3d4aee864efe7b6329c882d928ca1fad9"}, - {file = "tarina-0.6.7-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:cb7a52b2bd8a0df8e69eabd5701a0080e874363c37c6eb283c8a908977ea042b"}, - {file = "tarina-0.6.7-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:e42fbeef636fce7ad2893a6d2c66f4370ea6acc696b6e5e45a99b776a14b6f97"}, - {file = "tarina-0.6.7-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:40adb6061171d1f28a29f88542cc3d6473cdd8b628c8ee6082437003af06211d"}, - {file = "tarina-0.6.7-cp311-cp311-musllinux_1_2_ppc64le.whl", hash = "sha256:f5b801343ee24f709aee5fe1d233c7ec4e12e560d61ce4a85b03a62c42aa1ffd"}, - {file = "tarina-0.6.7-cp311-cp311-musllinux_1_2_s390x.whl", hash = "sha256:d25f6f6509eacf70764cd9f9441ba5354030e3024225f21c04132966804c349d"}, - {file = "tarina-0.6.7-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:74cc5cbbe005bef865c62ed1b416e46e713f49ed539e9ea3efa203985019d0aa"}, - {file = "tarina-0.6.7-cp311-cp311-win32.whl", hash = "sha256:f0035391edbe0e3a0e6936a43ad26ba4231aeed9764307b60bf88d74793f11b5"}, - {file = "tarina-0.6.7-cp311-cp311-win_amd64.whl", hash = "sha256:e96485bdb994ea46cd9d9112f034a03873f774e8e82cd47d4741d6c2e34bc83d"}, - {file = "tarina-0.6.7-cp312-cp312-macosx_10_13_universal2.whl", hash = "sha256:e67ba4557f47baee42cababc59910e26ed0d1462e2ffc93cbb67bf8a536dd157"}, - {file = "tarina-0.6.7-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:8a44a6c51a80ce6b1b0dd1329c1c8fcfa318110da815e89e273c932c30e0bc26"}, - {file = "tarina-0.6.7-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:67eda037393ef8c930ea9ff12c0eb606a64c4ed5d5c2043afa6d61f77afd648d"}, - {file = "tarina-0.6.7-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6d676af1e8ccbc6289c815359492fb85c31628274a356a965de87ba5c130d135"}, - {file = "tarina-0.6.7-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:69c8675605d52b6698587d107041d63b2c8a08a3fc893a274fce6d66d1df8160"}, - {file = "tarina-0.6.7-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:a3be97e27613d7063b815e137fd044ca89b4d3216bc6d5ac3cc8a610b24df237"}, - {file = "tarina-0.6.7-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7272f37c95fed555846bfa7f3cd51c13597d67bedf0f9715ecb4e95fc02dc1ea"}, - {file = "tarina-0.6.7-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:42227541d5fe23180bb80ac997a305876872b6d73bd03d1d3edc835f71a63f23"}, - {file = "tarina-0.6.7-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:b6c1e0bb0900cb16a15dc7f3e2798522bebb28e45e16ae6d70384057ebf1b878"}, - {file = "tarina-0.6.7-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:22e3073b825ffd84bbc0bb01e2a8086837f50ed2f446193fdc1d0d93fed71330"}, - {file = "tarina-0.6.7-cp312-cp312-musllinux_1_2_ppc64le.whl", hash = "sha256:d3dd51630b4e31b21ef58ef02392bf723f5005d921e7df0beea40c29f0462113"}, - {file = "tarina-0.6.7-cp312-cp312-musllinux_1_2_s390x.whl", hash = "sha256:f17a0f91fd8c3ddbbb190012fe214434a8ece9b6959c7f3116b5a4500ff58882"}, - {file = "tarina-0.6.7-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:63d2f39942ac717f64755a148eca0cf4893c1ea88ee6bfbadd61332d53b50315"}, - {file = "tarina-0.6.7-cp312-cp312-win32.whl", hash = "sha256:ad268fb4b27cf2569382bea33fb1174f72c6c687d776807bdd5fce9939a2762f"}, - {file = "tarina-0.6.7-cp312-cp312-win_amd64.whl", hash = "sha256:5b5b400574c47b865927d9999e5aff19500188fc2e2aa28148bd603aacd0d292"}, - {file = "tarina-0.6.7-cp313-cp313-macosx_10_13_universal2.whl", hash = "sha256:b4a64041f26bf85f6513aecc9f9ee5f5a3e6c02311af31a62508136e747655ef"}, - {file = "tarina-0.6.7-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:5fd6428f1fd5e2b697dc187e4afaea469e5feb0abd3ebe7287a5f66e72892451"}, - {file = "tarina-0.6.7-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:29b48578fa77b683582772edf775a08e0525f7d3691db50cef94eee596a296bc"}, - {file = "tarina-0.6.7-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:97dd4afb6b1913088a37bc225b774cc963d752a843c9369d635f41582f94310f"}, - {file = "tarina-0.6.7-cp313-cp313-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:1548653c7be058ccc42018b831a9dc7c3a27072d874c930e5eef09976cbe810b"}, - {file = "tarina-0.6.7-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:d05d7cc5b8ac50ea0d9f43d4ae03da81d5aa3bfe73bf5c8d9c352f5d404e7547"}, - {file = "tarina-0.6.7-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d7f938b400d3b6bd67706943311208c44b681e615d8aadecf2fc4a76958a08ba"}, - {file = "tarina-0.6.7-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:5236595ba59208369b36dc4cad566712257317c3e1fa054216967cf7afd4c674"}, - {file = "tarina-0.6.7-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:d7e1111585c9c9d0e8bd1cad618bd3cd07beefdb5f4cc26c63776a1f3549038e"}, - {file = "tarina-0.6.7-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:0891713041066787ced4489909ec46744d1ee3a540e7bc87ece7a0aac86b1ba3"}, - {file = "tarina-0.6.7-cp313-cp313-musllinux_1_2_ppc64le.whl", hash = "sha256:44699bbca310bac434f3cf55a2ee776a3bd590b87b2d9a82916791fee01f00ea"}, - {file = "tarina-0.6.7-cp313-cp313-musllinux_1_2_s390x.whl", hash = "sha256:031d80b07526b6ff96b9d08b0e51039b2749c24ffc607443a19318861a579f18"}, - {file = "tarina-0.6.7-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:0fc26864184b4358e3c880fc63541a0d058161885e7c37a7194e08313d1ba6c0"}, - {file = "tarina-0.6.7-cp313-cp313-win32.whl", hash = "sha256:d8ef824db2ea175b5b00b30efcbabdee54f1e83f24f980ceeb1f067577096743"}, - {file = "tarina-0.6.7-cp313-cp313-win_amd64.whl", hash = "sha256:55d3d79a2f5dc58372cdb7afef2e8d140aab36f86b95ff5805b5344e58f763df"}, - {file = "tarina-0.6.7-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:30451271eadd9fc0e7271ad810559f63a2213a1c43c52cec3f1cff445d959140"}, - {file = "tarina-0.6.7-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:43be241118a2a813324d7adfe16fcedb5d3ec411a8a010f68e4ffd034d584aa1"}, - {file = "tarina-0.6.7-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:ac6971cd82dbd07e01b76498c94cc4d7311eca36c8fe854503b4ff6eb52c1db2"}, - {file = "tarina-0.6.7-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:11192123e86a747ce6fb9367edeeccaf1ba8dc0d2a695e0f2695c5fb96c2cdf1"}, - {file = "tarina-0.6.7-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:aa7409f81a8f3c00fe45831f9f6028fde428068993934b7988b9ee7aff3a96d1"}, - {file = "tarina-0.6.7-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:6714c74e0ff041d851050e2f8cf70ddc16b460d98587d68e474d25dc2110ace4"}, - {file = "tarina-0.6.7-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:888917801e905652b89ea0c4d778cce8d46a0d1deea6707e8082a25eb67cdceb"}, - {file = "tarina-0.6.7-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:0f3b2826136f34d7ad582c02cb00494f8b2f32ed012d70c813c96218f68bb110"}, - {file = "tarina-0.6.7-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:6d43395792afc505d08068f55b18958a756a00d048ac6803cd5b0c2a9f1790ed"}, - {file = "tarina-0.6.7-cp39-cp39-musllinux_1_2_i686.whl", hash = "sha256:3f6419375a8707cb8794c9871c723ebdcf4781e1ec5bb08d7dea2d824871a7bc"}, - {file = "tarina-0.6.7-cp39-cp39-musllinux_1_2_ppc64le.whl", hash = "sha256:e8c43c3385b32fb667cfbd5ea1056f788895bb50243b2e3857c1363ef0b598cd"}, - {file = "tarina-0.6.7-cp39-cp39-musllinux_1_2_s390x.whl", hash = "sha256:e2fa7019bb3f6bd1019ae4a967b300d4e874deda303c750ca7128b552c8b8fe8"}, - {file = "tarina-0.6.7-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:5569da8e59e0ff15d518191bb3e2e102a89227d292788ef487afa963670a5472"}, - {file = "tarina-0.6.7-cp39-cp39-win32.whl", hash = "sha256:545936c84824194800564199fe52411641785d1dfcd41efa54a1a97b8d634903"}, - {file = "tarina-0.6.7-cp39-cp39-win_amd64.whl", hash = "sha256:3795a1ee986952157bae2061e764cbf9c5898d6c56096f7760a2bedaf1ef1373"}, - {file = "tarina-0.6.7-py3-none-any.whl", hash = "sha256:fa440f0c6f262675ad23eb3743cdf80e12fd3819632f4c3f7eec7a3fc686c55a"}, - {file = "tarina-0.6.7.tar.gz", hash = "sha256:c990cb7bd7e76dbd10772a97c82450d176e66aab81890da11c650aec43657b6c"}, + {file = "tarina-0.6.8-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:a2f7b7e61912a020d6ba3c591c4edbc31bb468544640bd814470c69a07dcc4cd"}, + {file = "tarina-0.6.8-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:1cac7cbd49317b8e63eba7d0ce0ba11e1218ab51c9d6ee9df8404b5e226db15b"}, + {file = "tarina-0.6.8-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:69d9923d888948ccc9d20a191ab1f6ff2bc097f4154b6a3780c45dc78ae047cd"}, + {file = "tarina-0.6.8-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6b0f12395301584e0d56c7edd6118c5b5732b456067735ee7f0800575d5d490f"}, + {file = "tarina-0.6.8-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:84bd95b18c7f6a55606b0071654137b98f70faf5d12343d361377cf0d81ecde6"}, + {file = "tarina-0.6.8-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:94e6ee4df273e1fd3eaf36de7c78a93dde08bf2ad67526122afab1b077e344d9"}, + {file = "tarina-0.6.8-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7afc1a8a11983f39cce18ad7f8d27601c4d34b1ffe1a1aca2a59b4111d181d01"}, + {file = "tarina-0.6.8-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:e0f74dc96979b774d7e23b964886137f7cf5f58cb2d652c23c3e2d42c1ad39a9"}, + {file = "tarina-0.6.8-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:3493d59ef19d1ded232e7a33e52c7d6ebfff66f30ac4c3649ae765b14dacc393"}, + {file = "tarina-0.6.8-cp310-cp310-musllinux_1_2_i686.whl", hash = "sha256:323351247817dac174f609104c54fcdc4923aaf3ac5e4a4a81c3efaa007d5778"}, + {file = "tarina-0.6.8-cp310-cp310-musllinux_1_2_ppc64le.whl", hash = "sha256:eb7407046d8051b062f71440b90a11be3ef1a64e99b1c6be157312fe2889e4f4"}, + {file = "tarina-0.6.8-cp310-cp310-musllinux_1_2_s390x.whl", hash = "sha256:50bbbb249d0849855cf43f4fa09c4eecac53e76a54c876ef1a7fb967f17d35b6"}, + {file = "tarina-0.6.8-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:8a05063e41f01f64c3c6e87b740c1e2cebffdcae20b9d89014a934bb2707a2b7"}, + {file = "tarina-0.6.8-cp310-cp310-win32.whl", hash = "sha256:162756b5c0872856c11cc97ed1a618a9118fef3fb6999edc917578b56f3eb67f"}, + {file = "tarina-0.6.8-cp310-cp310-win_amd64.whl", hash = "sha256:a58a8a6e36e43de8f3a0561cb264abe300ec6bb4a4215f16c316f1db564de6fb"}, + {file = "tarina-0.6.8-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:c05d38546712014aafcf123e89d90ad75f08ebd40c5a7e4c76db40d2ae11b387"}, + {file = "tarina-0.6.8-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:b036d53d2f8ec46fff9f649b5ec70431cdee3a2b99c8706f67d8d55ea4d4e493"}, + {file = "tarina-0.6.8-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:195d2b4a8a8ec2e946ecd8abab70cf3065fbba67e18e971e0412a74a8417a656"}, + {file = "tarina-0.6.8-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f9bbe85a83904eb29143a43511c04a3fea9a7392c70a6216fcec3ba06cf1b83a"}, + {file = "tarina-0.6.8-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:4d6b5893b735d24d2a57f6dbb26de92bb5e09e476077a16408e2054f06263530"}, + {file = "tarina-0.6.8-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:a74cc68f4678d37d517a2d661184712f15da608510de6b1bb9103d85d6014409"}, + {file = "tarina-0.6.8-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6dd0f0d769e503fb81d07bd2d342585347f5149803bd7b4b233deaff1833451f"}, + {file = "tarina-0.6.8-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:d3b7c91a488aa616e141c337cddce1ba1e0bdac6b98362bc15ce76bd3cd71e17"}, + {file = "tarina-0.6.8-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:4f0b91da85a816e34a3eb4670d21c26a3909872b1f5525797bedc32a45efd98d"}, + {file = "tarina-0.6.8-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:bf3a5a8fe912d5984627f64cdd187c8a0801c6f3b2f7f12c68cdb5babf691155"}, + {file = "tarina-0.6.8-cp311-cp311-musllinux_1_2_ppc64le.whl", hash = "sha256:622e226553453a9a873fca5a2d495d2d28003a23834503147954d651186146c4"}, + {file = "tarina-0.6.8-cp311-cp311-musllinux_1_2_s390x.whl", hash = "sha256:198102e526d096f37bfb868f815cb3bfc864e136aa8b70e90a107a38ffb82c15"}, + {file = "tarina-0.6.8-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:07b252f686410fbf1fe64b3b6705dd40ff218bc1d6a67efac640a0a246f66da3"}, + {file = "tarina-0.6.8-cp311-cp311-win32.whl", hash = "sha256:9e4f56478c58706548e0f08bd277666bac783d918257950be49c4a5d8a35e7b0"}, + {file = "tarina-0.6.8-cp311-cp311-win_amd64.whl", hash = "sha256:d0a92b5368a8a1700f0482d0bc3891dccdfc6dc61f7e66101f68544fca10f096"}, + {file = "tarina-0.6.8-cp312-cp312-macosx_10_13_universal2.whl", hash = "sha256:e8e4bf8ed36c92af7b2a973905f5f4f58dabf7490c5dda695534bf5e3b20d92e"}, + {file = "tarina-0.6.8-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:175754132a107c2830a341d3efcae60f44bfd8e0eab56d92537cc6f849ad44e3"}, + {file = "tarina-0.6.8-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:c5f983f0c84959589f884777c7ac0b22786d6d183ae367e53265f09e9ed7dc9f"}, + {file = "tarina-0.6.8-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2c8cc5f1bf3c2099377b5de76b0e192bb4fae3dcfcc245be9ed14315b29c8c75"}, + {file = "tarina-0.6.8-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:e7067131af4081d8ca3d4e70c96e8903c9e483e4d5af4910b93051602f7e8b34"}, + {file = "tarina-0.6.8-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:a66ea0778dcbd9e9b9b226529ed1822261722956468de026655e09b41feee42b"}, + {file = "tarina-0.6.8-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:dd8501b0cd51ad8c0e294b46614ef27ef6773324099b5a24711534db55ded44d"}, + {file = "tarina-0.6.8-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:5812e903c79c02029bfe61fd0ff30bf2a5ac58e7c5b1ab3abfb0f0b57260c5b8"}, + {file = "tarina-0.6.8-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:60ea05cb8e07a629096d9abbd11258df2bcea03168bc8ef8f369ca0dddfc504a"}, + {file = "tarina-0.6.8-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:b2635d27c34353e9431cb995acece3a0b607cde0934ebf8df35f0e4ae70a0335"}, + {file = "tarina-0.6.8-cp312-cp312-musllinux_1_2_ppc64le.whl", hash = "sha256:542b5359d23f969f275f9e80960ce7f19a2684e93cd3ab659afaeb7ee06de038"}, + {file = "tarina-0.6.8-cp312-cp312-musllinux_1_2_s390x.whl", hash = "sha256:4ba2018a855f59c28f087ec1ec1d892c6afccdd0da8f4347fbf8e3219145d66c"}, + {file = "tarina-0.6.8-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:fdf9c5c44d402041df79e747ff9f82c6794875febb053376acdb724043770975"}, + {file = "tarina-0.6.8-cp312-cp312-win32.whl", hash = "sha256:cf44ca009d79d0ecc8541b9067a3b7d086d1939de3bc1b04c164286b0fcf2112"}, + {file = "tarina-0.6.8-cp312-cp312-win_amd64.whl", hash = "sha256:8cd9ff00e2eb9ed6c42b80504005c9b6de4a9afe9ef36771f63b8f9492e38a90"}, + {file = "tarina-0.6.8-cp313-cp313-macosx_10_13_universal2.whl", hash = "sha256:af3ff4742b0324d590298812997d028a6d6892bfab5680cd266bed0c1bbf90b0"}, + {file = "tarina-0.6.8-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:e7919d53f20e7d780b44e1804f7c9006bcf5832f87cfeb8d5432f1c832953ed4"}, + {file = "tarina-0.6.8-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:878f8d9411ed36cf4408751e209a09c5e2363fc06b6074e966995cdbdc365a9d"}, + {file = "tarina-0.6.8-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:afa166fe58b65be6aed113fca54851b236cfd5c23e33f5e61c403f7b71eda17a"}, + {file = "tarina-0.6.8-cp313-cp313-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:04ea6b8f4568fe5b4f167d002fbe05879bfa04a4121b4ca3d294580cfc86b85d"}, + {file = "tarina-0.6.8-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:cbdf37600789f34c1eba6bf05e246f8e9a5b46cf93f9652e92d355e767bbc430"}, + {file = "tarina-0.6.8-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:eb748ad914898c293771ccdb32c73b3117a15a3234c9d5eb001f834533cf67ef"}, + {file = "tarina-0.6.8-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:55ca473eb8f3bbd70af71a29d59c6c0951e19ae24f3be86259b884fc097028a0"}, + {file = "tarina-0.6.8-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:4b124eee1ce8e25f1c1aba0464c95226ce5ed1b35f079f0fce0f993f38d3393b"}, + {file = "tarina-0.6.8-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:4295448f4dd9f54703adde2683cf6a515f0944687868da4ec500d595e6a9122d"}, + {file = "tarina-0.6.8-cp313-cp313-musllinux_1_2_ppc64le.whl", hash = "sha256:77392b3e53e9e1069b9131b1eb2037c53b360e4d7f3cfa8ae04277fe4e785eb1"}, + {file = "tarina-0.6.8-cp313-cp313-musllinux_1_2_s390x.whl", hash = "sha256:da9771f40ddcd9da087a4fc2d472b548c0da2bb61ad642b7e186ea7098120be6"}, + {file = "tarina-0.6.8-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:fac01686a3f9d4461b8ce6ba3afadb5b24138e27f725ee11efc4b057d98d4e4a"}, + {file = "tarina-0.6.8-cp313-cp313-win32.whl", hash = "sha256:a977e3e38535455b38e018ec345f9982c4d2b40945b330aa5c70c1a24a2f8f5b"}, + {file = "tarina-0.6.8-cp313-cp313-win_amd64.whl", hash = "sha256:62445e9a7c0ab7ac8f9c316836ade382f4b9780492f0a8a35a658f827bcb1d7f"}, + {file = "tarina-0.6.8-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:491b46bfd030f64edc8daac99051e9e1a82d4592aaa9d91c86d18da7f1816a8d"}, + {file = "tarina-0.6.8-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:8dab1c7ff584f427ae671ecd0379b5795f3ddfee867c5c8997fb110c35b72901"}, + {file = "tarina-0.6.8-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:9f998c32df568da30f236876118f5c359caf00d4935249c78c2e6e15caa1a72f"}, + {file = "tarina-0.6.8-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b427b03be5e9d19882558dafd8cae6decc4406f1511741409f1b75a5ce0bf447"}, + {file = "tarina-0.6.8-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:ec0bb5da7bbea3df20750acab45403c5fbd5a0b5c4dd7267e6d0cb3669935db4"}, + {file = "tarina-0.6.8-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:7acbc4b547fd623beb174431e2d01b2bc2a5d7451fe3d0e9ae3e0118d862d375"}, + {file = "tarina-0.6.8-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ed03a67986b00411aa5d3cd02896e5daf0e5af44247fd0ef79484b06780a2462"}, + {file = "tarina-0.6.8-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:637740055c0e7da77793e0f2d56189f4620e9db31578c590234f85240364e80d"}, + {file = "tarina-0.6.8-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:9df3d4441b36b7e6ac290b05dd9a1e6193ff0acc2d970be2b855283b76d0ad40"}, + {file = "tarina-0.6.8-cp39-cp39-musllinux_1_2_i686.whl", hash = "sha256:ff583c3579e5ea939da67c6a32ebced76b270c884d9f686a003f66f32a0cecdc"}, + {file = "tarina-0.6.8-cp39-cp39-musllinux_1_2_ppc64le.whl", hash = "sha256:91589c96904f6a07ccf7fec977c403bab52aad63bd3a801a32e11d2ee85e1d46"}, + {file = "tarina-0.6.8-cp39-cp39-musllinux_1_2_s390x.whl", hash = "sha256:4a7448cacff18d536c3cf4453282ee29cf401442cba1a50f02981e5d4c374d7f"}, + {file = "tarina-0.6.8-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:96fe4a3a33fa20cc3bd996ef9e4a909b00c37d89bd24d594a6024ca59a26c6c4"}, + {file = "tarina-0.6.8-cp39-cp39-win32.whl", hash = "sha256:cbff457659568f46fbbb8e594644278b51efddb532890117b4965b8c059d4d4a"}, + {file = "tarina-0.6.8-cp39-cp39-win_amd64.whl", hash = "sha256:bace5eeaed47048e9a8e9dd7953aadc11aace8c8a5db8457906d8f9c52604fc5"}, + {file = "tarina-0.6.8-py3-none-any.whl", hash = "sha256:0e8a04eecb741937244d97da54f8cd36995819fc12a6b60c9b3f3f3d2860ebe6"}, + {file = "tarina-0.6.8.tar.gz", hash = "sha256:d77d68948967a130066b61e85b21189259030f80ad19295bd81ff6b52f348316"}, ] [[package]] diff --git a/pyproject.toml b/pyproject.toml index c278ed6..1ccc396 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ authors = [ {name = "RF-Tar-Railt", email = "rf_tar_railt@qq.com"}, ] dependencies = [ - "tarina<0.7,>=0.6.3", + "tarina<0.7,>=0.6.8", "nepattern<1.0,>=0.7.7", "arclet-alconna<2.0,>=1.8.34", "arclet-alconna-tools>=0.7.10", diff --git a/src/nonebot_plugin_alconna/config.py b/src/nonebot_plugin_alconna/config.py index 7cf6ead..96e515c 100644 --- a/src/nonebot_plugin_alconna/config.py +++ b/src/nonebot_plugin_alconna/config.py @@ -2,6 +2,8 @@ from pydantic import Field, BaseModel +from .model import CompConfig + class Config(BaseModel): """Plugin Config Here""" @@ -12,6 +14,9 @@ class Config(BaseModel): alconna_use_command_start: bool = False """是否将 COMMAND_START 作为全局命令前缀""" + alconna_global_completion: Optional[CompConfig] = Field(None, strict=True) + """全局的补全会话配置 (不代表全局启用补全会话)""" + alconna_use_origin: bool = False """是否全局使用原始消息 (即未经过 to_me 等处理的)""" diff --git a/src/nonebot_plugin_alconna/i18n/.config.json b/src/nonebot_plugin_alconna/i18n/.config.json index f9c92db..a5d2840 100644 --- a/src/nonebot_plugin_alconna/i18n/.config.json +++ b/src/nonebot_plugin_alconna/i18n/.config.json @@ -1,10 +1,9 @@ { "default": "zh-CN", "frozen": [ - "completion.nonebot" + "nbp-alc:completion" ], "require": [ - "completion.nonebot", "nbp-alc" ], "name": "nonebot_plugin_alconna" diff --git a/src/nonebot_plugin_alconna/i18n/.lang.schema.json b/src/nonebot_plugin_alconna/i18n/.lang.schema.json index a141e09..9ef92d5 100644 --- a/src/nonebot_plugin_alconna/i18n/.lang.schema.json +++ b/src/nonebot_plugin_alconna/i18n/.lang.schema.json @@ -3,15 +3,15 @@ "description": "Schema for lang file", "type": "object", "properties": { - "completion": { - "title": "Completion", - "description": "Scope 'completion' of lang item", + "nbp-alc": { + "title": "Nbp-alc", + "description": "Scope 'nbp-alc' of lang item", "type": "object", "additionalProperties": false, "properties": { - "nonebot": { - "title": "Nonebot", - "description": "Scope 'nonebot' of lang item", + "completion": { + "title": "Completion", + "description": "Scope 'completion' of lang item", "type": "object", "additionalProperties": false, "properties": { @@ -46,15 +46,7 @@ "type": "string" } } - } - } - }, - "nbp-alc": { - "title": "Nbp-alc", - "description": "Scope 'nbp-alc' of lang item", - "type": "object", - "additionalProperties": false, - "properties": { + }, "log": { "title": "Log", "description": "Scope 'log' of lang item", diff --git a/src/nonebot_plugin_alconna/i18n/.template.json b/src/nonebot_plugin_alconna/i18n/.template.json index 969180c..285bc04 100644 --- a/src/nonebot_plugin_alconna/i18n/.template.json +++ b/src/nonebot_plugin_alconna/i18n/.template.json @@ -3,10 +3,10 @@ "$schema": "./.template.schema.json", "scopes": [ { - "scope": "completion", + "scope": "nbp-alc", "types": [ { - "subtype": "nonebot", + "subtype": "completion", "types": [ "tab", "enter", @@ -15,12 +15,7 @@ "timeout", "exited" ] - } - ] - }, - { - "scope": "nbp-alc", - "types": [ + }, { "subtype": "log", "types": [ diff --git a/src/nonebot_plugin_alconna/i18n/en-US.json b/src/nonebot_plugin_alconna/i18n/en-US.json index 779c024..106b6ee 100644 --- a/src/nonebot_plugin_alconna/i18n/en-US.json +++ b/src/nonebot_plugin_alconna/i18n/en-US.json @@ -1,16 +1,14 @@ { "$schema": ".lang.schema.json", - "completion": { - "nonebot": { + "nbp-alc": { + "completion": { "tab": "Send a {cmd} to toggle prompt", "enter": "Send {cmd} to confirm the prompt as the input", "exit": "Send {cmd} to exit the completion session", "other": "Input which not in above will be confirmed as the input", "timeout": "Completion session timed out. Exited automatically", "exited": "Completion session exited" - } - }, - "nbp-alc": { + }, "log": { "load_global_extensions": "Loading global extension from {path}", "got_path": { diff --git a/src/nonebot_plugin_alconna/i18n/model.py b/src/nonebot_plugin_alconna/i18n/model.py index 79ae59c..2393164 100644 --- a/src/nonebot_plugin_alconna/i18n/model.py +++ b/src/nonebot_plugin_alconna/i18n/model.py @@ -4,17 +4,13 @@ from tarina.lang.model import LangItem, LangModel -class CompletionNonebot: - tab: LangItem = LangItem("completion", "nonebot.tab") - enter: LangItem = LangItem("completion", "nonebot.enter") - exit: LangItem = LangItem("completion", "nonebot.exit") - other: LangItem = LangItem("completion", "nonebot.other") - timeout: LangItem = LangItem("completion", "nonebot.timeout") - exited: LangItem = LangItem("completion", "nonebot.exited") - - -class Completion: - nonebot = CompletionNonebot +class NbpAlcCompletion: + tab: LangItem = LangItem("nbp-alc", "completion.tab") + enter: LangItem = LangItem("nbp-alc", "completion.enter") + exit: LangItem = LangItem("nbp-alc", "completion.exit") + other: LangItem = LangItem("nbp-alc", "completion.other") + timeout: LangItem = LangItem("nbp-alc", "completion.timeout") + exited: LangItem = LangItem("nbp-alc", "completion.exited") class NbpAlcLogGotPath: @@ -55,6 +51,7 @@ class NbpAlcTest: class NbpAlc: + completion = NbpAlcCompletion log = NbpAlcLog error = NbpAlcError test = NbpAlcTest @@ -83,6 +80,5 @@ class NbpAlcBuiltin: class Lang(LangModel): - completion = Completion nbp_alc = NbpAlc nbp_alc_builtin = NbpAlcBuiltin diff --git a/src/nonebot_plugin_alconna/i18n/zh-CN.json b/src/nonebot_plugin_alconna/i18n/zh-CN.json index 81193c8..40f75ba 100644 --- a/src/nonebot_plugin_alconna/i18n/zh-CN.json +++ b/src/nonebot_plugin_alconna/i18n/zh-CN.json @@ -1,16 +1,14 @@ { "$schema": ".lang.schema.json", - "completion": { - "nonebot": { + "nbp-alc": { + "completion": { "tab": "发送 {cmd} 切换提示", "enter": "发送 {cmd} 以使用提示内容作为输入", "exit": "发送 {cmd} 退出补全会话", "other": "以上选项之外的输入将作为参数输入", "timeout": "补全会话超时, 已自动退出", "exited": "补全会话已退出" - } - }, - "nbp-alc": { + }, "log": { "load_global_extensions": "正在从 {path} 加载全局扩展 。。。", "got_path": { diff --git a/src/nonebot_plugin_alconna/model.py b/src/nonebot_plugin_alconna/model.py index a1820ca..806da39 100644 --- a/src/nonebot_plugin_alconna/model.py +++ b/src/nonebot_plugin_alconna/model.py @@ -1,5 +1,5 @@ -from typing_extensions import NotRequired -from typing import Any, Union, Generic, Literal, TypeVar, Optional, TypedDict +from typing_extensions import TypedDict, NotRequired +from typing import Any, Union, Generic, Literal, TypeVar, Optional from pydantic import Field, BaseModel from arclet.alconna.action import Action diff --git a/src/nonebot_plugin_alconna/rule.py b/src/nonebot_plugin_alconna/rule.py index 1295e55..3aa5467 100644 --- a/src/nonebot_plugin_alconna/rule.py +++ b/src/nonebot_plugin_alconna/rule.py @@ -14,6 +14,7 @@ from arclet.alconna.exceptions import SpecialOptionTriggered from arclet.alconna import Alconna, Arparma, CompSession, output_manager, command_manager +from .i18n import Lang from .config import Config from .adapters import MAPPING from .uniseg import UniMsg, UniMessage @@ -71,7 +72,7 @@ def __init__( command: Alconna, skip_for_unmatch: bool = True, auto_send_output: Optional[bool] = None, - comp_config: Optional[CompConfig] = None, + comp_config: Optional[Union[CompConfig, bool]] = None, extensions: Optional[list[Union[type[Extension], Extension]]] = None, exclude_ext: Optional[list[Union[type[Extension], str]]] = None, use_origin: Optional[bool] = None, @@ -80,11 +81,16 @@ def __init__( response_self: Optional[bool] = None, _aliases: Optional[Union[set[str], tuple[str, ...]]] = None, ): - self.comp_config = comp_config + if isinstance(comp_config, bool): + self.comp_config = {} if comp_config else None + else: + self.comp_config = comp_config self.use_origin = use_origin or False try: global_config = get_driver().config config = get_plugin_config(Config) + if config.alconna_global_completion is not None and self.comp_config == {}: + self.comp_config = config.alconna_global_completion if auto_send_output is None: self.auto_send = True if config.alconna_auto_send_output is None else config.alconna_auto_send_output else: @@ -152,19 +158,11 @@ def _update(cmd_id: int): hides = {"tab", "enter", "exit"} hides |= disables if len(hides) < 3: - template = f"\n\n{{}}{{}}{{}}{lang.require('completion', 'nonebot.other')}\n" + template = f"\n\n{{}}{{}}{{}}{Lang.nbp_alc.completion.other()}\n" self._comp_help = template.format( - (f"{lang.require('completion', 'nonebot.tab').format(cmd=_tab)}\n" if "tab" not in hides else ""), - ( - f"{lang.require('completion', 'nonebot.enter').format(cmd=_enter)}\n" - if "enter" not in hides - else "" - ), - ( - f"{lang.require('completion', 'nonebot.exit').format(cmd=_exit)}\n" - if "exit" not in hides - else "" - ), + (f"{Lang.nbp_alc.completion.tab(cmd=_tab)}\n" if "tab" not in hides else ""), + (f"{Lang.nbp_alc.completion.enter(cmd=_enter)}\n" if "enter" not in hides else ""), + (f"{Lang.nbp_alc.completion.exit(cmd=_exit)}\n" if "exit" not in hides else ""), ) async def _waiter_handle(_bot: Bot, _event: Event, _matcher: Matcher, content: UniMsg): @@ -261,7 +259,7 @@ def _clear(): try: await asyncio.wait_for(_futures[session_id], timeout=self.comp_config.get("timeout", 60)) except asyncio.TimeoutError: - await self.send(lang.require("completion", "nonebot.timeout"), bot, event, res) + await self.send(Lang.nbp_alc.completion.timeout(), bot, event, res) _clear() return res finally: @@ -270,7 +268,7 @@ def _clear(): ans: Union[UniMessage, bool, None] = _futures[session_id].result() _futures[session_id] = asyncio.get_running_loop().create_future() if ans is False: - await self.send(lang.require("completion", "nonebot.exited"), bot, event, res) + await self.send(Lang.nbp_alc.completion.exited(), bot, event, res) _clear() return res elif ans is None: @@ -326,14 +324,14 @@ async def __call__(self, event: Event, state: T_State, bot: Bot) -> bool: if not arp.matched and not may_help_text and self.skip: log( "TRACE", - escape_tag(lang.require("nbp-alc", "log.parse").format(msg=msg, cmd=self._path, arp=arp)), + escape_tag(Lang.nbp_alc.log.parse(msg=msg, cmd=self._path, arp=arp)), ) self.executor.clear() return False if arp.head_matched: log( "DEBUG", - escape_tag(lang.require("nbp-alc", "log.parse").format(msg=msg, cmd=self._path, arp=arp)), + escape_tag(Lang.nbp_alc.log.parse(msg=msg, cmd=self._path, arp=arp)), ) if not may_help_text and arp.error_info: may_help_text = str(arp.error_info)