mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2025-12-15 06:12:53 +08:00
✨ 部分功能适配QQ BOT (#1701)
This commit is contained in:
parent
7567bfb732
commit
3d3a2a5f7f
5
.vscode/settings.json
vendored
5
.vscode/settings.json
vendored
@ -13,18 +13,19 @@
|
||||
"getbbox",
|
||||
"hibiapi",
|
||||
"httpx",
|
||||
"jsdelivr",
|
||||
"kaiheila",
|
||||
"lolicon",
|
||||
"nonebot",
|
||||
"onebot",
|
||||
"pixiv",
|
||||
"qbot",
|
||||
"Setu",
|
||||
"tobytes",
|
||||
"ujson",
|
||||
"unban",
|
||||
"userinfo",
|
||||
"zhenxun",
|
||||
"jsdelivr"
|
||||
"zhenxun"
|
||||
],
|
||||
"python.analysis.autoImportCompletions": true,
|
||||
"python.testing.pytestArgs": ["tests"],
|
||||
|
||||
172
poetry.lock
generated
172
poetry.lock
generated
@ -2454,23 +2454,23 @@ reference = "ali"
|
||||
|
||||
[[package]]
|
||||
name = "nonebot-plugin-alconna"
|
||||
version = "0.53.0"
|
||||
version = "0.53.1"
|
||||
description = "Alconna Adapter for Nonebot"
|
||||
optional = false
|
||||
python-versions = ">=3.9"
|
||||
files = [
|
||||
{file = "nonebot_plugin_alconna-0.53.0-py3-none-any.whl", hash = "sha256:a0351de37e9d55a92b4dbf2977815e9d0cfe700cab4f0dc345a80fe2883253a0"},
|
||||
{file = "nonebot_plugin_alconna-0.53.0.tar.gz", hash = "sha256:404289034a9d41a8fbdb5b50d8fe2b069234c4aaffe20ccf417871aeb91f8cff"},
|
||||
{file = "nonebot_plugin_alconna-0.53.1-py3-none-any.whl", hash = "sha256:a7734d4c7f1b2fedec586b7d235da119ffaa23d0e17a8aa0a0acc0e76a1662d0"},
|
||||
{file = "nonebot_plugin_alconna-0.53.1.tar.gz", hash = "sha256:dc9eef228bb819d05ce9816f8a5a1bead455ee85d1ea7d5e409f9fb11665805e"},
|
||||
]
|
||||
|
||||
[package.dependencies]
|
||||
arclet-alconna = ">=1.8.29"
|
||||
arclet-alconna-tools = ">=0.7.9"
|
||||
arclet-alconna = ">=1.8.31,<2.0"
|
||||
arclet-alconna-tools = ">=0.7.10"
|
||||
importlib-metadata = ">=4.13.0"
|
||||
nepattern = ">=0.7.4"
|
||||
nepattern = ">=0.7.4,<1.0"
|
||||
nonebot-plugin-waiter = ">=0.6.0"
|
||||
nonebot2 = ">=2.3.0"
|
||||
tarina = ">=0.5.5"
|
||||
tarina = ">=0.6.3,<0.7"
|
||||
|
||||
[package.source]
|
||||
type = "legacy"
|
||||
@ -4304,88 +4304,88 @@ reference = "ali"
|
||||
|
||||
[[package]]
|
||||
name = "tarina"
|
||||
version = "0.6.1"
|
||||
version = "0.6.3"
|
||||
description = "A collection of common utils for Arclet"
|
||||
optional = false
|
||||
python-versions = ">=3.9"
|
||||
files = [
|
||||
{file = "tarina-0.6.1-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:f81108429347d78ff703061b6e071fe17183d3ec77d0e3a4386fef503ba7609e"},
|
||||
{file = "tarina-0.6.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:fc7ae6c003cd367a5e962c5c29ff525d7f4ec0ec0e040ba096aa13571ad36e25"},
|
||||
{file = "tarina-0.6.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:f445dcd502de9762812c97dcd7f94ebabb33353c173f81d26e97979a080d579e"},
|
||||
{file = "tarina-0.6.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:651faa58c8949485a72f28daa5e1f16c79e2c57ab78eebdb0c5b1e422b5e5d27"},
|
||||
{file = "tarina-0.6.1-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:14d45da795ab3e4ef53ef0088650f31f02e5ad424ffce1f7b499ed17d56930b8"},
|
||||
{file = "tarina-0.6.1-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:94d4b64e25f069ad912d258d360c136d96331ed8a04e590e576b5618edfda0e3"},
|
||||
{file = "tarina-0.6.1-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:c5b10559c3a4f14c051299fb8d504b6d06ecc5388fc6a58b0094450f63feeb93"},
|
||||
{file = "tarina-0.6.1-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2600bc9e113cbe7500e7deeee79dfd8bdf539b5a9a1dd7dd39c110ceb7ce2df0"},
|
||||
{file = "tarina-0.6.1-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:89fb41a2a3d0882ae3c76f59a5d59f082adc5844a1a5a9c1cd81ba392a81278d"},
|
||||
{file = "tarina-0.6.1-cp310-cp310-musllinux_1_2_i686.whl", hash = "sha256:a1592ee78428163245f610629060f1de47b4fff3ee9a459e7a2fa8a37396cfeb"},
|
||||
{file = "tarina-0.6.1-cp310-cp310-musllinux_1_2_ppc64le.whl", hash = "sha256:9fc37ec243622e05f8858382541948bc95f58529fb714eeb3edfd509862d9d25"},
|
||||
{file = "tarina-0.6.1-cp310-cp310-musllinux_1_2_s390x.whl", hash = "sha256:4eb330aa9d0253513e6946144d633abb184df6e9412824252e26df435b4c7e6a"},
|
||||
{file = "tarina-0.6.1-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:2eb88f319473117c6ce3a8adb42e72a8a1deecb25cf07a3661966d76125decd1"},
|
||||
{file = "tarina-0.6.1-cp310-cp310-win32.whl", hash = "sha256:470d4cb9e77d9950ec3c502b483d7672319033d6d9412e2505556136bbef6228"},
|
||||
{file = "tarina-0.6.1-cp310-cp310-win_amd64.whl", hash = "sha256:6331774d2fc4b53a443c7aea765bc0f5325d704556f5a54c5b493548c30d248e"},
|
||||
{file = "tarina-0.6.1-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:21d0d2668bfe266e40cfc63fcaad6d4b082d48e51d5dedef68480ce9ef93f0d1"},
|
||||
{file = "tarina-0.6.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:f89b816c22469f9f962e0546d83f2303b1ce76026ac0b01d860e78a063516ec9"},
|
||||
{file = "tarina-0.6.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:257f5de5dee0989f3fae910436b1033f89d59f6daf66caeaddb442ff0f300fdd"},
|
||||
{file = "tarina-0.6.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:89bbb091209cf901d2238c750cc7f18221363b6d4df0ca5ae349b6edcc010b92"},
|
||||
{file = "tarina-0.6.1-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:06e63492d43591e68ec9d0c6a44182db831723def84047aad1aae0ed2f0b6887"},
|
||||
{file = "tarina-0.6.1-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:710d80de800abc85cd5eb70e976c6faa9eeb463a819af57b24480111de1eb4f8"},
|
||||
{file = "tarina-0.6.1-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:73dabdb38b2495978dd38b49e6972326a8554c94a079cf6a76b4f51afdabe4f2"},
|
||||
{file = "tarina-0.6.1-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:168897ef791944a58aefa6107859662b678284e4a423a5004abd86404d23b422"},
|
||||
{file = "tarina-0.6.1-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:444a9fae02ac1cbbd1dda606999910165dcedcf3c1dc038ae776c7a79bf6038d"},
|
||||
{file = "tarina-0.6.1-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:5f174ce1df1f39f8ca0f4f20df86f0ed3e53d9abfd834c69647179312a4d7242"},
|
||||
{file = "tarina-0.6.1-cp311-cp311-musllinux_1_2_ppc64le.whl", hash = "sha256:cace7ab14894861e562a846f5555c6089763489ce949f8e1d7da2ab0c4d98c99"},
|
||||
{file = "tarina-0.6.1-cp311-cp311-musllinux_1_2_s390x.whl", hash = "sha256:b67ee3b1f97e89161f4e534c607d465c671c6958ebd8a8596576b589971f002f"},
|
||||
{file = "tarina-0.6.1-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:bfd4f5061e9a5d557265759d7225c24ab2bd609f73826369f700c4c4f7ae99f5"},
|
||||
{file = "tarina-0.6.1-cp311-cp311-win32.whl", hash = "sha256:e0729bd693f4a33b1656e3e5740279ea13a904ea798485040ac4017b7c38ad73"},
|
||||
{file = "tarina-0.6.1-cp311-cp311-win_amd64.whl", hash = "sha256:3e2d202116fb37210bb6962f5fa9c7e5c4463c8d1ac179abf81659df287edb59"},
|
||||
{file = "tarina-0.6.1-cp312-cp312-macosx_10_13_universal2.whl", hash = "sha256:3c763640cdbd1a64c3572e101db8dd430f70e2ffb69ab1857f161d5858572b89"},
|
||||
{file = "tarina-0.6.1-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:516ab567580b1baad5f9caedeea5aea64c82a690c8a66b1488fddb86db7181c4"},
|
||||
{file = "tarina-0.6.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:3cb0dd90866ba7041f935cbbddaecbc8a2dfedb17c4eb2d14b69aea0e9204722"},
|
||||
{file = "tarina-0.6.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:40fb6e397ebe35935f3aa4cf6dd1635bc7481021915a3610d35a59cb33e1e1ae"},
|
||||
{file = "tarina-0.6.1-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:5838c367f2d9819ece8343908c08f277d115b21a5d3bad18588f22dbc44f7410"},
|
||||
{file = "tarina-0.6.1-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:b9b6870463e6bcf7e2958bccf7f2824eb4f7ffc99c88c8b27f5dd9be2fef8702"},
|
||||
{file = "tarina-0.6.1-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:4a6875f34a7f0d4e2663525a356954b0e81241e59b8e7a8df6f66f646e8ad3e7"},
|
||||
{file = "tarina-0.6.1-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a0084193267ccc05058baffb550db7d814b3b2d8d13ee07fc363d4fe3fa947c4"},
|
||||
{file = "tarina-0.6.1-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:26ca97ef07d1ebc73ce44532c19d74f0a65087ffcd4ed193186ed98b8ca6db87"},
|
||||
{file = "tarina-0.6.1-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:bb123dde028433c612d207301d59f123a25ed25a0b2d13922b167b6595978d17"},
|
||||
{file = "tarina-0.6.1-cp312-cp312-musllinux_1_2_ppc64le.whl", hash = "sha256:3655e5cbd143be2ca7413202052f097fae36f9224cf12e5f2a790986803c5804"},
|
||||
{file = "tarina-0.6.1-cp312-cp312-musllinux_1_2_s390x.whl", hash = "sha256:fd70cf3b025de2fcc0d276e287aeafe2be3c05a0d2ef83a5b563c2f7d2bc9920"},
|
||||
{file = "tarina-0.6.1-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:bfd991c93400457d2fe58461b1d300e856d7e70881699c764c6912182525e0df"},
|
||||
{file = "tarina-0.6.1-cp312-cp312-win32.whl", hash = "sha256:a422689faebe0e2b701d9ca3b1a2d172e0d7434e1159fa42782c2a957f8828be"},
|
||||
{file = "tarina-0.6.1-cp312-cp312-win_amd64.whl", hash = "sha256:3104baf80f6a9e1e0a1fb3d6fabe87f7b6bc97db7c2941267a219869628f79af"},
|
||||
{file = "tarina-0.6.1-cp313-cp313-macosx_10_13_universal2.whl", hash = "sha256:a3be9f60c4b39eae8451f6c63adbadec585146fbc2d3698b7ed81289c8cc22d2"},
|
||||
{file = "tarina-0.6.1-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:af8e6f999dab61d96593fad7e32fd4ffefad64813cb993a45683e83ef486e70b"},
|
||||
{file = "tarina-0.6.1-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:b2f9c59ba6852c6cf441adf5d287fc6597a0019f80040155541b1e39dcbff20e"},
|
||||
{file = "tarina-0.6.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0148199bcba92ef14e639029356a65894bae33ec3872b63ad1f9a1a9130ecaec"},
|
||||
{file = "tarina-0.6.1-cp313-cp313-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:4c69cef0e15856d4d2eb5817f00a85701f69c444e8fca0c50618d7bfde5b4104"},
|
||||
{file = "tarina-0.6.1-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:b3c250ab55c75f073023d21118fbd706e661b76a49e4cac28a6cb71f0bf04873"},
|
||||
{file = "tarina-0.6.1-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:a06308187f13c41f857d79c0b33d407eae34c16974a03a5711aa6b3bd27c129e"},
|
||||
{file = "tarina-0.6.1-cp313-cp313-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ea1cf6026d81be5bc186882651f99a50d19ec7de33c580635848f52ecb0286e5"},
|
||||
{file = "tarina-0.6.1-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:4cfa83aa4fe0fe0d394a93a70b7ec502c734a692d6dd6dc465fd4b591a0a6411"},
|
||||
{file = "tarina-0.6.1-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:608f74951318b2f24c83e4d11b068479363073cc7346785a7b54fe09386676e9"},
|
||||
{file = "tarina-0.6.1-cp313-cp313-musllinux_1_2_ppc64le.whl", hash = "sha256:98532739c0044a4afe8b345d6e07906a117af2d212ebe6e5fec7d3bca0b55dcb"},
|
||||
{file = "tarina-0.6.1-cp313-cp313-musllinux_1_2_s390x.whl", hash = "sha256:611f3338df2fd80261f5b979e18554d3edc5608dcf2b5873d312123142f18031"},
|
||||
{file = "tarina-0.6.1-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:c76ce872ef3cb3ed3fc7cd4dc6048f210218fe26cb2b951902b7102fe94698c1"},
|
||||
{file = "tarina-0.6.1-cp313-cp313-win32.whl", hash = "sha256:3059bf2b308d9fa77be7f18506061b6a2aee4c0fd633d0281ad6b4299bc418f0"},
|
||||
{file = "tarina-0.6.1-cp313-cp313-win_amd64.whl", hash = "sha256:51aa1e65bff323838fb9205a66e5bdc299d507b8c52c62e9759949f77d68439a"},
|
||||
{file = "tarina-0.6.1-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:dbf72954eee214be1171c4d36216e6da253a8b2ce2ca6a1509489960bee4adbd"},
|
||||
{file = "tarina-0.6.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:15b8e4ebefd74a90c73151c3020ee335b83a24cc6255a4b0a8c58a90f40e2d7d"},
|
||||
{file = "tarina-0.6.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:761f61009f628a26b4ff1ed800c6b858bbc82372ba45775b19382136b48e60f8"},
|
||||
{file = "tarina-0.6.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:98a4229f4eb15a4a9b397684173a0013b5941273c68923e7ef464111e7ccf81f"},
|
||||
{file = "tarina-0.6.1-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:21f733def0ba7e9e4bef88bbacbfa978d1763dfc392abf8a5a3127812127d61a"},
|
||||
{file = "tarina-0.6.1-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:e24cd3a9fed98af412a3dc8c6a82143fb00e9a448337fe846cbf36d27f002214"},
|
||||
{file = "tarina-0.6.1-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:bde8c549a5ac165acd2e7578f501477c54ce47283b1a4cc09d468f9d93990d96"},
|
||||
{file = "tarina-0.6.1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:06f37682c6e6984ef51ee2692dc71f3949d0eb390efb660635459c53802c2948"},
|
||||
{file = "tarina-0.6.1-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:0730ab7a8c0a3be19ce3e3bbfaad893c946acaa2cf2d191f5287ba35c9bf9a11"},
|
||||
{file = "tarina-0.6.1-cp39-cp39-musllinux_1_2_i686.whl", hash = "sha256:1d9186b7584d6884be799b038e7cf93011177cea2184080ff9849b17aa8ce2a6"},
|
||||
{file = "tarina-0.6.1-cp39-cp39-musllinux_1_2_ppc64le.whl", hash = "sha256:246eabe13f1496c19c6ea9e975398db5e78a936ebb784182cbfb5101593e8b8e"},
|
||||
{file = "tarina-0.6.1-cp39-cp39-musllinux_1_2_s390x.whl", hash = "sha256:835b93ee5ca9e302e993666a692b175ebc8514831c67e09368c1bf3e08d04be6"},
|
||||
{file = "tarina-0.6.1-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:33539f80a6de9360f1c187370057988762d598fed5eae1f4789db4952f39a59d"},
|
||||
{file = "tarina-0.6.1-cp39-cp39-win32.whl", hash = "sha256:e260313f2d62946121df941c37a7b4521e1849fa92c65236a7f35e328e77e947"},
|
||||
{file = "tarina-0.6.1-cp39-cp39-win_amd64.whl", hash = "sha256:d59a5e3164a1c4f5095f8b8e16de1dbfd81eeb53a506a14ca1545ff7d0edbe2a"},
|
||||
{file = "tarina-0.6.1-py3-none-any.whl", hash = "sha256:cb9b95b62b2fee8fe86758af0acac147afa4646a7b0a7f272e0e74f3fc60cf3e"},
|
||||
{file = "tarina-0.6.1.tar.gz", hash = "sha256:153a415df95da7c08cf2a75a88c9f587e6d12fd8ec5caae01586bbbd2083f81c"},
|
||||
{file = "tarina-0.6.3-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:7dd3137978bb525ddc67abd4c1629acc015fb3c46cdc909ca05ddcfa5ef55b3c"},
|
||||
{file = "tarina-0.6.3-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:59f3ef88e2e79fc423fbf93e4ef5aca28546128c457956a9a8a918467366740b"},
|
||||
{file = "tarina-0.6.3-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:0f3e0caf010c5b87b536c3ce96d18989b37e31b4cd9e3117389bd7e47c2ef2c2"},
|
||||
{file = "tarina-0.6.3-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2276ed72ec88ee9953ee4e9078bbed466bf34f15659d4e70be04f62efdc168fd"},
|
||||
{file = "tarina-0.6.3-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:8eca923e945de830144a40b3bee23bd6939de0fdd17b720d13aac071b3bee597"},
|
||||
{file = "tarina-0.6.3-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:0a01ffc2a26293db6e575fced69fe15e92c0b4968a219792bc5a713436b2f879"},
|
||||
{file = "tarina-0.6.3-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:1e58caf70d227f4540694291ee26f592dd8485159aba1090a66da921ed362b41"},
|
||||
{file = "tarina-0.6.3-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:76a990459f25e3d78e165996a800e94d027198c0a19026d128745effa6c3eb5a"},
|
||||
{file = "tarina-0.6.3-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:e7f1334741a644e3fa9fc5d56015d0ab3a252083fcb3c1e62ec9623186f6d816"},
|
||||
{file = "tarina-0.6.3-cp310-cp310-musllinux_1_2_i686.whl", hash = "sha256:be8d874f35a805ec747f6c3c2b9b33e49a115b5196b10f72cb62765bb4da0bf6"},
|
||||
{file = "tarina-0.6.3-cp310-cp310-musllinux_1_2_ppc64le.whl", hash = "sha256:bdbd0b8fe124fbff828fb0cc182672cb218f2ec117c8d677b926df5727e2d68c"},
|
||||
{file = "tarina-0.6.3-cp310-cp310-musllinux_1_2_s390x.whl", hash = "sha256:3c0cde1de4c4e59888da9319320aa357122a1787accea1a3563191cc418b37c4"},
|
||||
{file = "tarina-0.6.3-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:dba072c215a21eaf0d37da6a1be310e430071dfe18721e469b144feaa484fad7"},
|
||||
{file = "tarina-0.6.3-cp310-cp310-win32.whl", hash = "sha256:62fa494d1f6458f446babee5002974e1c71aa4427e2375580188824d8b1d6c7a"},
|
||||
{file = "tarina-0.6.3-cp310-cp310-win_amd64.whl", hash = "sha256:c69e9e3c6c00fbfd667022ba52d155c041053841facfee2f2092e48ab18533f6"},
|
||||
{file = "tarina-0.6.3-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:2e8f95b6ff3704f93d5e03e2cdd0008cd2106b2f4eb4a2c8b6de48358a97b245"},
|
||||
{file = "tarina-0.6.3-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:c49edd608e9c057200873fafb7d39af2a68fcf9f63cb9bfd96ac51221dfcd595"},
|
||||
{file = "tarina-0.6.3-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:26b98096b3894a1da028ade1d68f895482ad74ea98c8770e76ed2354c0e1d5ae"},
|
||||
{file = "tarina-0.6.3-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:53474a64d9356502cd422bff076a79e275339db2eb1731c3433c7382037567d2"},
|
||||
{file = "tarina-0.6.3-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:58d301ab8ccba446929f8a8557e64c8116fe31bc9bf82a17b45486c51eb62a91"},
|
||||
{file = "tarina-0.6.3-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:1178bcc87e2feaa3c26ebf663f6260e00d77f7ed9ccc934c1a68d6d2b131ae39"},
|
||||
{file = "tarina-0.6.3-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:5514adace9088891d2f89d43f2c32623dbc4749fd005ade2aee65c059aa53407"},
|
||||
{file = "tarina-0.6.3-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f3cc7ea743fe1421ac32a45797d49bf672b8f43a6f783d3e6f058a39da1b7f75"},
|
||||
{file = "tarina-0.6.3-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:897d0755443a4755a7041528651f1aae546385cfb91a84ecdd436fbba66db5f2"},
|
||||
{file = "tarina-0.6.3-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:c1f23b69e9274494788b933602649af314b01d1d18da82cb927409f9dc0e6df1"},
|
||||
{file = "tarina-0.6.3-cp311-cp311-musllinux_1_2_ppc64le.whl", hash = "sha256:4c4a3a45db0be34ba29f1a6bece1e7ceba80618becc36d154f9a36f089904c32"},
|
||||
{file = "tarina-0.6.3-cp311-cp311-musllinux_1_2_s390x.whl", hash = "sha256:ec76367a19f30012938b0017ea12bb137b65c17233f486629d305998b54301f7"},
|
||||
{file = "tarina-0.6.3-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:1a4f52d627d9f5cf38302542cf02ce4cd0774d90d3fc3f63730499f0560e2a89"},
|
||||
{file = "tarina-0.6.3-cp311-cp311-win32.whl", hash = "sha256:09eda644268a0ee5921ed69c6d32d9fb37c384403b8ef28c708cfe19f9ca7bd1"},
|
||||
{file = "tarina-0.6.3-cp311-cp311-win_amd64.whl", hash = "sha256:e8a9b13d607a73dbe4935922a4fe7db6768fb4b9ccd17657f3ba5b31652bf064"},
|
||||
{file = "tarina-0.6.3-cp312-cp312-macosx_10_13_universal2.whl", hash = "sha256:6a7738b0c47e2ab04700bcab8f4c5bb80da38052e10944d249640ce08fe19f5a"},
|
||||
{file = "tarina-0.6.3-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:291261089f7c27998590323e54eba7af631cd64d0d2b71ff10fcc89a93980ba3"},
|
||||
{file = "tarina-0.6.3-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:cec66cb2c34fc112b1df15f74101cedec4d526515274cbfb6ebcb7103296cc1f"},
|
||||
{file = "tarina-0.6.3-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:536dc50a796f8dc1e08c07afe1435de5dc63251335417d16da17369c887e9f96"},
|
||||
{file = "tarina-0.6.3-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:17f3695fc5bb36f701ca050abccc439940663abcf312a93eeacbddcfe6324258"},
|
||||
{file = "tarina-0.6.3-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:8e1c4914cec84eb85021c1aaea7cf03ee1e48670fa9990bbd55d3a612a5dc0c9"},
|
||||
{file = "tarina-0.6.3-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:8a2fc2ae412afdf6e0a09177114d2f731fa8f9fdf37b5182edb791c1e1a3b57a"},
|
||||
{file = "tarina-0.6.3-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d6b401a7d12299feb4e3e730f9c656ba2b45183eb1edb4734cf160089e0d4f99"},
|
||||
{file = "tarina-0.6.3-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:11670c89060e1f6a13a08e66dbf214ab6c5ac24eb8b41a117dc7f58cd7d32b7b"},
|
||||
{file = "tarina-0.6.3-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:35059aa53739c5d99862c9e6cf1d88a6819ec9d00a9cdaea23d92e35c66f7dbe"},
|
||||
{file = "tarina-0.6.3-cp312-cp312-musllinux_1_2_ppc64le.whl", hash = "sha256:d99969c5304c9f2dd6a0a104f39a90a291b65e38b1c91defacc06993802b44c8"},
|
||||
{file = "tarina-0.6.3-cp312-cp312-musllinux_1_2_s390x.whl", hash = "sha256:13d623b29ea831ab9a99675ca1ce11f04dcf8d3089021f1543ee7fb87b617538"},
|
||||
{file = "tarina-0.6.3-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:fd4580d870918643945d1b630e6d15747bdd3d118817a731e4357853e31e40bf"},
|
||||
{file = "tarina-0.6.3-cp312-cp312-win32.whl", hash = "sha256:8783debe80384ab9e6947852a0c06803a157dc405a5a0954420191fbf81e3584"},
|
||||
{file = "tarina-0.6.3-cp312-cp312-win_amd64.whl", hash = "sha256:b5e1d9e20169bd840689152019433cc84d3886a11624202adc3f6ac9cfc02cf1"},
|
||||
{file = "tarina-0.6.3-cp313-cp313-macosx_10_13_universal2.whl", hash = "sha256:2ab9a4cd5c34e660b4e5dc4464571e0a821dbb778b2d5dbd5827c754613eb330"},
|
||||
{file = "tarina-0.6.3-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:e0512dd6e750750b3f1186adb364a849c62b834420a5b9c04c01b9c1d9ae3321"},
|
||||
{file = "tarina-0.6.3-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:0b762a6816528ebcdcb30aafca0894e8ce302d05397e6def136016d48d3ac824"},
|
||||
{file = "tarina-0.6.3-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f22f660e2fe4e0976a9de388b6b776e17f7f24e2b495d4ae8b23107a68b87f38"},
|
||||
{file = "tarina-0.6.3-cp313-cp313-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:8d5c7a7fdb522a7b7d1907d87233162e2041aad797d2aa2b81120bf5fa166d51"},
|
||||
{file = "tarina-0.6.3-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:f7fa81479e02062d8897773e4d538501cb7f03f0295060e4ffbbe7ea7bef6fa3"},
|
||||
{file = "tarina-0.6.3-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:23408b0149357b34139aa2dfc7cbcedfbef8751942577af1ceba119581115c7d"},
|
||||
{file = "tarina-0.6.3-cp313-cp313-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:bd6424bc435629cbf9cbcc15e7de2cd27fde971b5acb65d5dc397674c4954cd4"},
|
||||
{file = "tarina-0.6.3-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:55cef82500275cd65c8f3ead84f26982b9b6e1bb362b6e9ae87f48e1a1977f39"},
|
||||
{file = "tarina-0.6.3-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:891a0dd0d56d1fb40e9fab988cd2ca1ee5828fce35fa9389595546da44725764"},
|
||||
{file = "tarina-0.6.3-cp313-cp313-musllinux_1_2_ppc64le.whl", hash = "sha256:df4681bcfdf6a59f638e92afed1f7849dd3abdd44473a5b525ddbbdf86097e4a"},
|
||||
{file = "tarina-0.6.3-cp313-cp313-musllinux_1_2_s390x.whl", hash = "sha256:b6c8bbcf50a74749b4151c3198fd54db47fd3d70918aa95e1bb80608937580e1"},
|
||||
{file = "tarina-0.6.3-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:bb920f665dcbacee8e842f7e8ded67efbe7eec56d3e172f704f355d868839fa1"},
|
||||
{file = "tarina-0.6.3-cp313-cp313-win32.whl", hash = "sha256:6d084511e3e2aa6bf0e2e6d520ac906860144cf4bd1955782f7038821933d18e"},
|
||||
{file = "tarina-0.6.3-cp313-cp313-win_amd64.whl", hash = "sha256:c48b635827c79ae571981c7cd3f7a1a2779c5e8cfa3090c143032d3af07f3304"},
|
||||
{file = "tarina-0.6.3-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:9a8555e539f946ca3422e85a1448c19f5e4ae2b840861bee1d2f8c47710c2d73"},
|
||||
{file = "tarina-0.6.3-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:45237b2699c7dafbbbbaa66dfbda26a4813c52539fa8c447f0734bc98ea147b4"},
|
||||
{file = "tarina-0.6.3-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:04fc78eafe9a5e2e43cd1e275fa2a94c3ab15a54cbbe74c117cb5f385289e988"},
|
||||
{file = "tarina-0.6.3-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c3c420e298128a859ec1e1b19b861bb66c74af3fe7d2fe7d5247240837806629"},
|
||||
{file = "tarina-0.6.3-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:4e7af2da7d9eb6df2d02d4c8f1c4b5f362922abb19c0db4d5c821962ce5cca7f"},
|
||||
{file = "tarina-0.6.3-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:b3ee0fd20552a40c5910d6b24c1ec9fec5e809ae52f5a235b05dcf79dc3584f8"},
|
||||
{file = "tarina-0.6.3-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:c3988dae2bae1263199f855f1d5c96af72c82bf3676f5da3f6b9a0f3fb217359"},
|
||||
{file = "tarina-0.6.3-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d4eeb35e323cf1d64feac541d372a9c3ad7fe252e592fd1bbc51c885f38d8f2f"},
|
||||
{file = "tarina-0.6.3-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:ea872dc76965f829fcba779d3d98efb5991cedbd6401d44bb89bd681684f539a"},
|
||||
{file = "tarina-0.6.3-cp39-cp39-musllinux_1_2_i686.whl", hash = "sha256:289d52a74cff3ba9cdc312f400ae12bad5fc662762b1c1562ab17488a01ada98"},
|
||||
{file = "tarina-0.6.3-cp39-cp39-musllinux_1_2_ppc64le.whl", hash = "sha256:ede6e41d95c9fe0b91ab18c55887cba257a4569527b17b4b6cf35af65ec976f3"},
|
||||
{file = "tarina-0.6.3-cp39-cp39-musllinux_1_2_s390x.whl", hash = "sha256:5bbb5181444fb19f63fb47c0e36bcd519747008ace72fae47aab265abd9e3cda"},
|
||||
{file = "tarina-0.6.3-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:672274e5a57eb6e3618875b7a005d106374b74e0e296c8699eb0128af2c14144"},
|
||||
{file = "tarina-0.6.3-cp39-cp39-win32.whl", hash = "sha256:1a452bd905dd4c03381b0bf1c1d1386b767a7e97dd7895d30a8358d85a538e05"},
|
||||
{file = "tarina-0.6.3-cp39-cp39-win_amd64.whl", hash = "sha256:251517f571c10edeafd050c1ef89149068dea546ad2ca14a54f6577ef6d52157"},
|
||||
{file = "tarina-0.6.3-py3-none-any.whl", hash = "sha256:b60e83ae288f4db43cea5c57957bad1957910f7523541caa6c74b16452734697"},
|
||||
{file = "tarina-0.6.3.tar.gz", hash = "sha256:e97cf86f8a4e2a55e31c9f52b74791a4ce29360ce6e45e92584000e59998bd61"},
|
||||
]
|
||||
|
||||
[package.dependencies]
|
||||
@ -5146,4 +5146,4 @@ reference = "ali"
|
||||
[metadata]
|
||||
lock-version = "2.0"
|
||||
python-versions = "^3.10"
|
||||
content-hash = "097837fdfce7cb819d425e78c40d7eeec36929a52981b492e6424c1c1886586b"
|
||||
content-hash = "67d2b187c48521ac5c258ab3cee07ff5f6ba1ea2dc70e991b6896375594ae83a"
|
||||
|
||||
@ -50,7 +50,7 @@ python-multipart = "^0.0.9"
|
||||
aiocache = "^0.12.2"
|
||||
py-cpuinfo = "^9.0.0"
|
||||
nonebot-plugin-uninfo = "^0.4.1"
|
||||
nonebot-plugin-alconna = "^0.53.0"
|
||||
nonebot-plugin-alconna = "^0.53.1"
|
||||
|
||||
[tool.poetry.dev-dependencies]
|
||||
nonebug = "^0.3.2"
|
||||
|
||||
@ -9,6 +9,13 @@ from nonebot.adapters import Bot
|
||||
from nonebot.drivers import Driver
|
||||
from tortoise.exceptions import OperationalError
|
||||
|
||||
require("nonebot_plugin_apscheduler")
|
||||
require("nonebot_plugin_alconna")
|
||||
require("nonebot_plugin_session")
|
||||
require("nonebot_plugin_userinfo")
|
||||
require("nonebot_plugin_htmlrender")
|
||||
# require("nonebot_plugin_uninfo")
|
||||
|
||||
from zhenxun.services.log import logger
|
||||
from zhenxun.models.sign_user import SignUser
|
||||
from zhenxun.models.goods_info import GoodsInfo
|
||||
@ -17,14 +24,6 @@ from zhenxun.utils.decorator.shop import shop_register
|
||||
from zhenxun.models.bot_connect_log import BotConnectLog
|
||||
from zhenxun.models.group_member_info import GroupInfoUser
|
||||
|
||||
require("nonebot_plugin_apscheduler")
|
||||
require("nonebot_plugin_alconna")
|
||||
require("nonebot_plugin_session")
|
||||
require("nonebot_plugin_userinfo")
|
||||
require("nonebot_plugin_htmlrender")
|
||||
require("nonebot_plugin_uninfo")
|
||||
|
||||
|
||||
driver: Driver = nonebot.get_driver()
|
||||
|
||||
|
||||
|
||||
@ -2,12 +2,14 @@ from pathlib import Path
|
||||
|
||||
import aiofiles
|
||||
from nonebot.rule import to_me
|
||||
from nonebot_plugin_uninfo import Uninfo
|
||||
from nonebot.plugin import PluginMetadata
|
||||
from nonebot_plugin_session import EventSession
|
||||
from nonebot_plugin_alconna import Alconna, Arparma, on_alconna
|
||||
|
||||
from zhenxun.services.log import logger
|
||||
from zhenxun.utils.message import MessageUtils
|
||||
from zhenxun.utils.platform import PlatformUtils
|
||||
from zhenxun.configs.path_config import DATA_PATH
|
||||
from zhenxun.configs.utils import PluginExtraData
|
||||
|
||||
__plugin_meta__ = PluginMetadata(
|
||||
@ -25,19 +27,33 @@ _matcher = on_alconna(Alconna("关于"), priority=5, block=True, rule=to_me())
|
||||
|
||||
|
||||
@_matcher.handle()
|
||||
async def _(session: EventSession, arparma: Arparma):
|
||||
async def _(session: Uninfo, arparma: Arparma):
|
||||
ver_file = Path() / "__version__"
|
||||
version = None
|
||||
if ver_file.exists():
|
||||
async with aiofiles.open(ver_file, encoding="utf8") as f:
|
||||
if text := await f.read():
|
||||
version = text.split(":")[-1].strip()
|
||||
info = f"""
|
||||
if PlatformUtils.is_qbot(session):
|
||||
info: list[str | Path] = [
|
||||
f"""
|
||||
『绪山真寻Bot』
|
||||
版本:{version}
|
||||
简介:基于Nonebot2开发,支持多平台,是一个非常可爱的Bot呀,希望与大家要好好相处
|
||||
""".strip()
|
||||
]
|
||||
path = DATA_PATH / "about.png"
|
||||
if path.exists():
|
||||
info.append(path)
|
||||
else:
|
||||
info = [
|
||||
f"""
|
||||
『绪山真寻Bot』
|
||||
版本:{version}
|
||||
简介:基于Nonebot2开发,支持多平台,是一个非常可爱的Bot呀,希望与大家要好好相处
|
||||
项目地址:https://github.com/HibiKier/zhenxun_bot
|
||||
文档地址:https://hibikier.github.io/zhenxun_bot/
|
||||
""".strip()
|
||||
await MessageUtils.build_message(info).send()
|
||||
""".strip()
|
||||
]
|
||||
await MessageUtils.build_message(info).send() # type: ignore
|
||||
logger.info("查看关于", arparma.header_result, session=session)
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
from nonebot.rule import to_me
|
||||
from nonebot.adapters import Bot
|
||||
from nonebot_plugin_uninfo import Uninfo
|
||||
from nonebot.plugin import PluginMetadata
|
||||
from nonebot_plugin_session import EventSession
|
||||
from nonebot_plugin_alconna import (
|
||||
Args,
|
||||
Match,
|
||||
@ -58,28 +58,26 @@ _matcher = on_alconna(
|
||||
async def _(
|
||||
bot: Bot,
|
||||
name: Match[str],
|
||||
session: EventSession,
|
||||
session: Uninfo,
|
||||
is_superuser: Query[bool] = AlconnaQuery("superuser.value", False),
|
||||
):
|
||||
if not session.id1:
|
||||
await MessageUtils.build_message("用户id为空...").finish()
|
||||
_is_superuser = is_superuser.result if is_superuser.available else False
|
||||
if name.available:
|
||||
if _is_superuser and session.id1 not in bot.config.superusers:
|
||||
if _is_superuser and session.user.id not in bot.config.superusers:
|
||||
_is_superuser = False
|
||||
if result := await get_plugin_help(session.id1, name.result, _is_superuser):
|
||||
if result := await get_plugin_help(session.user.id, name.result, _is_superuser):
|
||||
await MessageUtils.build_message(result).send(reply_to=True)
|
||||
else:
|
||||
await MessageUtils.build_message("没有此功能的帮助信息...").send(
|
||||
reply_to=True
|
||||
)
|
||||
logger.info(f"查看帮助详情: {name.result}", "帮助", session=session)
|
||||
elif gid := session.id3 or session.id2:
|
||||
elif session.group and (gid := session.group.id):
|
||||
_image_path = GROUP_HELP_PATH / f"{gid}.png"
|
||||
if not _image_path.exists():
|
||||
await create_help_img(bot.self_id, gid, session.platform)
|
||||
await create_help_img(session, gid)
|
||||
await MessageUtils.build_message(_image_path).finish()
|
||||
else:
|
||||
if not SIMPLE_HELP_IMAGE.exists():
|
||||
await create_help_img(bot.self_id, None, session.platform)
|
||||
await create_help_img(session, None)
|
||||
await MessageUtils.build_message(SIMPLE_HELP_IMAGE).finish()
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import nonebot
|
||||
from nonebot_plugin_uninfo import Uninfo
|
||||
|
||||
from zhenxun.utils.enum import PluginType
|
||||
from zhenxun.models.level_user import LevelUser
|
||||
@ -19,19 +20,18 @@ background = IMAGE_PATH / "background" / "0.png"
|
||||
driver = nonebot.get_driver()
|
||||
|
||||
|
||||
async def create_help_img(bot_id: str, group_id: str | None, platform: str):
|
||||
async def create_help_img(session: Uninfo, group_id: str | None):
|
||||
"""生成帮助图片
|
||||
|
||||
参数:
|
||||
bot_id: bot id
|
||||
session: Uninfo
|
||||
group_id: 群号
|
||||
platform: 平台
|
||||
"""
|
||||
help_type: str = base_config.get("type")
|
||||
if help_type.lower() == "html":
|
||||
result = BuildImage.open(await build_html_image(group_id))
|
||||
elif help_type.lower() == "zhenxun":
|
||||
result = BuildImage.open(await build_zhenxun_image(bot_id, group_id, platform))
|
||||
result = BuildImage.open(await build_zhenxun_image(session, group_id))
|
||||
else:
|
||||
result = await build_normal_image(group_id)
|
||||
if group_id:
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
from pydantic import BaseModel
|
||||
from nonebot_plugin_uninfo import Uninfo
|
||||
from nonebot_plugin_htmlrender import template_to_pic
|
||||
|
||||
from zhenxun.utils.enum import BlockType
|
||||
from zhenxun.configs.config import BotConfig
|
||||
from zhenxun.utils.platform import PlatformUtils
|
||||
from zhenxun.models.plugin_info import PluginInfo
|
||||
from zhenxun.configs.path_config import TEMPLATE_PATH
|
||||
@ -60,7 +62,15 @@ def build_plugin_data(classify: dict[str, list[Item]]) -> list[dict[str, str]]:
|
||||
for menu, value in classify.items()
|
||||
]
|
||||
plugin_list = build_line_data(plugin_list)
|
||||
plugin_list.insert(0, build_plugin_line(menu_key, max_data, 30, 100))
|
||||
plugin_list.insert(
|
||||
0,
|
||||
build_plugin_line(
|
||||
menu_key if menu_key not in ["normal", "功能"] else "主要功能",
|
||||
max_data,
|
||||
30,
|
||||
100,
|
||||
),
|
||||
)
|
||||
return plugin_list
|
||||
|
||||
|
||||
@ -113,25 +123,25 @@ def build_line_data(plugin_list: list[dict]) -> list[dict]:
|
||||
return data
|
||||
|
||||
|
||||
async def build_zhenxun_image(
|
||||
bot_id: str, group_id: str | None, platform: str
|
||||
) -> bytes:
|
||||
async def build_zhenxun_image(session: Uninfo, group_id: str | None) -> bytes:
|
||||
"""构造真寻帮助图片
|
||||
|
||||
参数:
|
||||
bot_id: bot_id
|
||||
group_id: 群号
|
||||
platform: 平台
|
||||
"""
|
||||
classify = await classify_plugin(group_id, __handle_item)
|
||||
plugin_list = build_plugin_data(classify)
|
||||
platform = PlatformUtils.get_platform(session)
|
||||
bot_id = BotConfig.get_qbot_uid(session.self_id) or session.self_id
|
||||
bot_ava = PlatformUtils.get_user_avatar_url(bot_id, platform)
|
||||
return await template_to_pic(
|
||||
template_path=str((TEMPLATE_PATH / "ss_menu").absolute()),
|
||||
template_name="main.html",
|
||||
templates={
|
||||
"data": {
|
||||
"plugin_list": plugin_list,
|
||||
"ava": PlatformUtils.get_user_avatar_url(bot_id, platform),
|
||||
"ava": bot_ava,
|
||||
}
|
||||
},
|
||||
pages={
|
||||
|
||||
@ -1,13 +1,12 @@
|
||||
from nonebot.adapters import Bot
|
||||
from nonebot_plugin_uninfo import Uninfo
|
||||
from nonebot.plugin import PluginMetadata
|
||||
from nonebot_plugin_session import EventSession
|
||||
from playwright.async_api import TimeoutError
|
||||
from nonebot_plugin_alconna import At, Args, Match, Alconna, Arparma, on_alconna
|
||||
|
||||
from zhenxun.services.log import logger
|
||||
from zhenxun.utils.enum import PluginType
|
||||
from zhenxun.utils.depends import UserName
|
||||
from zhenxun.utils.message import MessageUtils
|
||||
from zhenxun.utils.platform import PlatformUtils
|
||||
from zhenxun.configs.utils import PluginExtraData
|
||||
from zhenxun.models.group_member_info import GroupInfoUser
|
||||
|
||||
@ -31,26 +30,29 @@ _matcher = on_alconna(Alconna("我的信息", Args["at_user?", At]), priority=5,
|
||||
@_matcher.handle()
|
||||
async def _(
|
||||
bot: Bot,
|
||||
session: EventSession,
|
||||
session: Uninfo,
|
||||
arparma: Arparma,
|
||||
at_user: Match[At],
|
||||
nickname: str = UserName(),
|
||||
):
|
||||
user_id = session.id1
|
||||
if at_user.available:
|
||||
user_id = session.user.id
|
||||
if at_user.available and session.group:
|
||||
user_id = at_user.result.target
|
||||
if user := await GroupInfoUser.get_or_none(
|
||||
user_id=user_id, group_id=session.id2
|
||||
user_id=user_id, group_id=session.group.id
|
||||
):
|
||||
nickname = user.user_name
|
||||
else:
|
||||
nickname = user_id
|
||||
if not user_id:
|
||||
await MessageUtils.build_message("用户id为空...").finish(reply_to=True)
|
||||
try:
|
||||
result = await get_user_info(bot, user_id, session.id2, nickname)
|
||||
result = await get_user_info(
|
||||
session, bot, user_id, session.group.id if session.group else None, nickname
|
||||
)
|
||||
await MessageUtils.build_message(result).send(at_sender=True)
|
||||
logger.info("获取用户信息", arparma.header_result, session=session)
|
||||
except TimeoutError as e:
|
||||
logger.error("获取用户信息超时", arparma.header_result, session=session, e=e)
|
||||
await MessageUtils.build_message("获取用户信息超时...").finish(reply_to=True)
|
||||
except Exception as e:
|
||||
logger.error("获取用户信息失败", arparma.header_result, session=session, e=e)
|
||||
await MessageUtils.build_message("获取用户信息失败...").finish(reply_to=True)
|
||||
|
||||
@ -4,6 +4,7 @@ from datetime import datetime, timedelta
|
||||
from nonebot.adapters import Bot
|
||||
from tortoise.functions import Count
|
||||
from tortoise.expressions import RawSQL
|
||||
from nonebot_plugin_uninfo import Uninfo
|
||||
from nonebot_plugin_htmlrender import template_to_pic
|
||||
|
||||
from zhenxun.models.sign_user import SignUser
|
||||
@ -130,11 +131,12 @@ async def get_chat_history(
|
||||
|
||||
|
||||
async def get_user_info(
|
||||
bot: Bot, user_id: str, group_id: str | None, nickname: str
|
||||
session: Uninfo, bot: Bot, user_id: str, group_id: str | None, nickname: str
|
||||
) -> bytes:
|
||||
"""获取用户个人信息
|
||||
|
||||
参数:
|
||||
session: Uninfo
|
||||
bot: Bot
|
||||
user_id: 用户id
|
||||
group_id: 群id
|
||||
@ -162,7 +164,7 @@ async def get_user_info(
|
||||
data = {
|
||||
"date": now.date(),
|
||||
"weather": weather,
|
||||
"ava_url": ava_url,
|
||||
"ava_url": session.user.avatar,
|
||||
"nickname": nickname,
|
||||
"title": "勇 者",
|
||||
"race": random.choice(RACE),
|
||||
|
||||
@ -1,11 +1,15 @@
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
import nonebot
|
||||
|
||||
from zhenxun.services.log import logger
|
||||
|
||||
path = Path(__file__).parent
|
||||
|
||||
for f in os.listdir(path):
|
||||
_p = path / f
|
||||
if _p.is_dir():
|
||||
nonebot.load_plugins(str(_p.resolve()))
|
||||
|
||||
try:
|
||||
from nonebot.adapters.onebot.v11 import Bot
|
||||
|
||||
nonebot.load_plugins(str((path / "qq").resolve()))
|
||||
except ImportError:
|
||||
logger.warning("未安装 onebot-adapter,无法加载QQ平台专用插件...")
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
from nonebot.adapters import Bot
|
||||
from nonebot_plugin_uninfo import Uninfo
|
||||
from nonebot import on_notice, on_request
|
||||
from nonebot.plugin import PluginMetadata
|
||||
from nonebot.adapters.onebot.v11 import (
|
||||
@ -100,7 +101,11 @@ add_group = on_request(priority=1, block=False)
|
||||
|
||||
|
||||
@group_increase_handle.handle()
|
||||
async def _(bot: Bot, event: GroupIncreaseNoticeEvent | GroupMemberIncreaseEvent):
|
||||
async def _(
|
||||
bot: Bot,
|
||||
session: Uninfo,
|
||||
event: GroupIncreaseNoticeEvent | GroupMemberIncreaseEvent,
|
||||
):
|
||||
user_id = str(event.user_id)
|
||||
group_id = str(event.group_id)
|
||||
if user_id == bot.self_id:
|
||||
@ -113,11 +118,15 @@ async def _(bot: Bot, event: GroupIncreaseNoticeEvent | GroupMemberIncreaseEvent
|
||||
except ForceAddGroupError as e:
|
||||
await PlatformUtils.send_superuser(bot, e.get_info())
|
||||
else:
|
||||
await GroupManager.add_user(bot, user_id, group_id)
|
||||
await GroupManager.add_user(session, bot, user_id, group_id)
|
||||
|
||||
|
||||
@group_decrease_handle.handle()
|
||||
async def _(bot: Bot, event: GroupDecreaseNoticeEvent | GroupMemberDecreaseEvent):
|
||||
async def _(
|
||||
bot: Bot,
|
||||
session: Uninfo,
|
||||
event: GroupDecreaseNoticeEvent | GroupMemberDecreaseEvent,
|
||||
):
|
||||
user_id = str(event.user_id)
|
||||
group_id = str(event.group_id)
|
||||
if event.sub_type == "kick_me":
|
||||
@ -128,6 +137,6 @@ async def _(bot: Bot, event: GroupDecreaseNoticeEvent | GroupMemberDecreaseEvent
|
||||
bot, user_id, group_id, str(event.operator_id), event.sub_type
|
||||
)
|
||||
if result and not await CommonUtils.task_is_block(
|
||||
"refund_group_remind", group_id
|
||||
session, "refund_group_remind"
|
||||
):
|
||||
await group_decrease_handle.send(result)
|
||||
|
||||
@ -7,6 +7,7 @@ from datetime import datetime
|
||||
import ujson as json
|
||||
from nonebot.adapters import Bot
|
||||
from nonebot_plugin_alconna import At
|
||||
from nonebot_plugin_uninfo import Uninfo
|
||||
|
||||
from zhenxun.services.log import logger
|
||||
from zhenxun.configs.config import Config
|
||||
@ -202,7 +203,7 @@ class GroupManager:
|
||||
).send()
|
||||
|
||||
@classmethod
|
||||
async def add_user(cls, bot: Bot, user_id: str, group_id: str):
|
||||
async def add_user(cls, session: Uninfo, bot: Bot, user_id: str, group_id: str):
|
||||
"""拉入用户
|
||||
|
||||
参数:
|
||||
@ -219,7 +220,7 @@ class GroupManager:
|
||||
)
|
||||
logger.info(f"用户{user_info['user_id']} 所属{user_info['group_id']} 更新成功")
|
||||
if not await CommonUtils.task_is_block(
|
||||
"group_welcome", group_id
|
||||
session, "group_welcome"
|
||||
) and cls._flmt.check(group_id):
|
||||
await cls.__send_welcome_message(user_id, group_id)
|
||||
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import nonebot
|
||||
from nonebot.adapters import Bot
|
||||
from nonebot.plugin import PluginMetadata
|
||||
from nonebot_plugin_apscheduler import scheduler
|
||||
|
||||
@ -26,15 +27,15 @@ __plugin_meta__ = PluginMetadata(
|
||||
driver = nonebot.get_driver()
|
||||
|
||||
|
||||
async def check(group_id: str) -> bool:
|
||||
return not await CommonUtils.task_is_block("morning_goodnight", group_id)
|
||||
async def check(bot: Bot, group_id: str) -> bool:
|
||||
return not await CommonUtils.task_is_block(bot, "morning_goodnight", group_id)
|
||||
|
||||
|
||||
# 早上好
|
||||
@scheduler.scheduled_job(
|
||||
"cron",
|
||||
hour=6,
|
||||
minute=1,
|
||||
hour=14,
|
||||
minute=52,
|
||||
)
|
||||
async def _():
|
||||
message = MessageUtils.build_message(["早上好", IMAGE_PATH / "zhenxun" / "zao.jpg"])
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
from nonebot.adapters import Bot, Event
|
||||
from nonebot_plugin_uninfo import Uninfo
|
||||
from nonebot.plugin import PluginMetadata
|
||||
from nonebot_plugin_session import EventSession
|
||||
from nonebot_plugin_userinfo import UserInfo, EventUserInfo
|
||||
from nonebot_plugin_alconna import (
|
||||
Args,
|
||||
Match,
|
||||
Query,
|
||||
Option,
|
||||
UniMsg,
|
||||
@ -17,6 +18,7 @@ from nonebot_plugin_alconna import (
|
||||
)
|
||||
|
||||
from zhenxun.services.log import logger
|
||||
from zhenxun.utils.depends import UserName
|
||||
from zhenxun.utils.message import MessageUtils
|
||||
from zhenxun.utils.exception import GoodsNotFound
|
||||
from zhenxun.utils.enum import BlockType, PluginType
|
||||
@ -53,8 +55,8 @@ _matcher = on_alconna(
|
||||
Option("--all", action=store_true),
|
||||
Subcommand("my-cost", help_text="我的金币"),
|
||||
Subcommand("my-props", help_text="我的道具"),
|
||||
Subcommand("buy", Args["name", str]["num", int, 1], help_text="购买道具"),
|
||||
Subcommand("use", Args["name", str]["num?", int, 1], help_text="使用道具"),
|
||||
Subcommand("buy", Args["name?", str]["num?", int], help_text="购买道具"),
|
||||
Subcommand("use", Args["name?", str]["num?", int], help_text="使用道具"),
|
||||
Subcommand("gold-list", Args["num?", int], help_text="金币排行"),
|
||||
),
|
||||
priority=5,
|
||||
@ -76,16 +78,16 @@ _matcher.shortcut(
|
||||
)
|
||||
|
||||
_matcher.shortcut(
|
||||
"购买道具",
|
||||
"购买道具(?P<name>.*?)",
|
||||
command="商店",
|
||||
arguments=["buy", "{%0}"],
|
||||
arguments=["buy", "{name}"],
|
||||
prefix=True,
|
||||
)
|
||||
|
||||
_matcher.shortcut(
|
||||
"使用道具",
|
||||
"使用道具(?P<name>.*?)",
|
||||
command="商店",
|
||||
arguments=["use", "{%0}"],
|
||||
arguments=["use", "{name}"],
|
||||
prefix=True,
|
||||
)
|
||||
|
||||
@ -122,14 +124,12 @@ async def _(session: EventSession, arparma: Arparma):
|
||||
|
||||
|
||||
@_matcher.assign("my-props")
|
||||
async def _(
|
||||
session: EventSession, arparma: Arparma, user_info: UserInfo = EventUserInfo()
|
||||
):
|
||||
async def _(session: EventSession, arparma: Arparma, nickname: str = UserName()):
|
||||
if session.id1:
|
||||
logger.info("查看道具", arparma.header_result, session=session)
|
||||
if image := await ShopManage.my_props(
|
||||
session.id1,
|
||||
user_info.user_displayname or user_info.user_name,
|
||||
nickname,
|
||||
session.platform,
|
||||
):
|
||||
await MessageUtils.build_message(image.pic2bytes()).finish(reply_to=True)
|
||||
@ -139,17 +139,23 @@ async def _(
|
||||
|
||||
|
||||
@_matcher.assign("buy")
|
||||
async def _(session: EventSession, arparma: Arparma, name: str, num: int):
|
||||
if session.id1:
|
||||
logger.info(
|
||||
f"购买道具 {name}, 数量: {num}",
|
||||
arparma.header_result,
|
||||
session=session,
|
||||
)
|
||||
result = await ShopManage.buy_prop(session.id1, name, num, session.platform)
|
||||
await MessageUtils.build_message(result).send(reply_to=True)
|
||||
else:
|
||||
await MessageUtils.build_message("用户id为空...").send(reply_to=True)
|
||||
async def _(
|
||||
session: Uninfo,
|
||||
arparma: Arparma,
|
||||
name: Match[str],
|
||||
num: Query[int] = AlconnaQuery("num", 1),
|
||||
):
|
||||
if not name.available:
|
||||
await MessageUtils.build_message(
|
||||
"请在指令后跟需要购买的道具名称或id..."
|
||||
).finish(reply_to=True)
|
||||
logger.info(
|
||||
f"购买道具 {name}, 数量: {num}",
|
||||
arparma.header_result,
|
||||
session=session,
|
||||
)
|
||||
result = await ShopManage.buy_prop(session.user.id, name.result, num.result)
|
||||
await MessageUtils.build_message(result).send(reply_to=True)
|
||||
|
||||
|
||||
@_matcher.assign("use")
|
||||
@ -159,11 +165,17 @@ async def _(
|
||||
message: UniMsg,
|
||||
session: EventSession,
|
||||
arparma: Arparma,
|
||||
name: str,
|
||||
num: int,
|
||||
name: Match[str],
|
||||
num: Query[int] = AlconnaQuery("num", 1),
|
||||
):
|
||||
if not name.available:
|
||||
await MessageUtils.build_message(
|
||||
"请在指令后跟需要使用的道具名称或id..."
|
||||
).finish(reply_to=True)
|
||||
try:
|
||||
result = await ShopManage.use(bot, event, session, message, name, num, "")
|
||||
result = await ShopManage.use(
|
||||
bot, event, session, message, name.result, num.result, ""
|
||||
)
|
||||
logger.info(
|
||||
f"使用道具 {name}, 数量: {num}", arparma.header_result, session=session
|
||||
)
|
||||
@ -179,24 +191,21 @@ async def _(
|
||||
|
||||
@_matcher.assign("gold-list")
|
||||
async def _(
|
||||
session: EventSession, arparma: Arparma, num: Query[int] = AlconnaQuery("num", 10)
|
||||
session: Uninfo, arparma: Arparma, num: Query[int] = AlconnaQuery("num", 10)
|
||||
):
|
||||
if num.result > 50:
|
||||
await MessageUtils.build_message("排行榜人数不能超过50哦...").finish()
|
||||
if session.id1:
|
||||
gid = session.id3 or session.id2
|
||||
if not arparma.find("all") and not gid:
|
||||
await MessageUtils.build_message(
|
||||
"私聊中无法查看 '金币排行',请发送 '金币总排行'"
|
||||
).finish()
|
||||
if arparma.find("all"):
|
||||
gid = None
|
||||
result = await gold_rank(session.id1, gid, num.result, session.platform)
|
||||
logger.info(
|
||||
"查看金币排行",
|
||||
arparma.header_result,
|
||||
session=session,
|
||||
)
|
||||
await MessageUtils.build_message(result).send(reply_to=True)
|
||||
else:
|
||||
await MessageUtils.build_message("用户id为空...").send(reply_to=True)
|
||||
gid = session.group.id if session.group else None
|
||||
if not arparma.find("all") and not gid:
|
||||
await MessageUtils.build_message(
|
||||
"私聊中无法查看 '金币排行',请发送 '金币总排行'"
|
||||
).finish()
|
||||
if arparma.find("all"):
|
||||
gid = None
|
||||
result = await gold_rank(session, gid, num.result)
|
||||
logger.info(
|
||||
"查看金币排行",
|
||||
arparma.header_result,
|
||||
session=session,
|
||||
)
|
||||
await MessageUtils.build_message(result).send(reply_to=True)
|
||||
|
||||
@ -6,6 +6,7 @@ from types import MappingProxyType
|
||||
from collections.abc import Callable
|
||||
|
||||
from nonebot.adapters import Bot, Event
|
||||
from nonebot_plugin_uninfo import Uninfo
|
||||
from pydantic import BaseModel, create_model
|
||||
from nonebot_plugin_session import EventSession
|
||||
from nonebot_plugin_alconna import UniMsg, UniMessage
|
||||
@ -58,9 +59,9 @@ class Goods(BaseModel):
|
||||
class ShopParam(BaseModel):
|
||||
goods_name: str
|
||||
"""商品名称"""
|
||||
user_id: int
|
||||
user_id: str
|
||||
"""用户id"""
|
||||
group_id: int
|
||||
group_id: str | None
|
||||
"""群聊id"""
|
||||
bot: Any
|
||||
"""bot"""
|
||||
@ -80,16 +81,17 @@ class ShopParam(BaseModel):
|
||||
"""UniMessage"""
|
||||
|
||||
|
||||
async def gold_rank(user_id: str, group_id: str | None, num: int, platform: str):
|
||||
async def gold_rank(session: Uninfo, group_id: str | None, num: int):
|
||||
query = UserConsole
|
||||
if group_id:
|
||||
uid_list = await GroupInfoUser.filter(group_id=group_id).values_list(
|
||||
"user_id", flat=True
|
||||
)
|
||||
query = query.filter(user_id__in=uid_list)
|
||||
if uid_list:
|
||||
query = query.filter(user_id__in=uid_list)
|
||||
user_list = await query.annotate().order_by("-gold").values_list("user_id", "gold")
|
||||
user_id_list = [user[0] for user in user_list]
|
||||
index = user_id_list.index(user_id) + 1
|
||||
index = user_id_list.index(session.user.id) + 1
|
||||
user_list = user_list[:num] if num < len(user_list) else user_list
|
||||
friend_user = await FriendUser.filter(user_id__in=user_id_list).values_list(
|
||||
"user_id", "user_name"
|
||||
@ -103,8 +105,11 @@ async def gold_rank(user_id: str, group_id: str | None, num: int, platform: str)
|
||||
uid2name[g[0]] = g[1]
|
||||
column_name = ["排名", "-", "名称", "金币", "平台"]
|
||||
data_list = []
|
||||
platform = PlatformUtils.get_platform(session)
|
||||
for i, user in enumerate(user_list):
|
||||
ava_bytes = await PlatformUtils.get_user_avatar(user[0], platform)
|
||||
ava_bytes = await PlatformUtils.get_user_avatar(
|
||||
user[0], platform, session.self_id
|
||||
)
|
||||
data_list.append(
|
||||
[
|
||||
f"{i+1}",
|
||||
@ -294,9 +299,12 @@ class ShopManage:
|
||||
str | MessageFactory | None: 使用完成后返回信息
|
||||
"""
|
||||
if goods_name.isdigit():
|
||||
user = await UserConsole.get_user(user_id=session.id1) # type: ignore
|
||||
uuid = list(user.props.keys())[int(goods_name)]
|
||||
goods_info = await GoodsInfo.get_or_none(uuid=uuid)
|
||||
try:
|
||||
user = await UserConsole.get_user(user_id=session.id1) # type: ignore
|
||||
uuid = list(user.props.keys())[int(goods_name)]
|
||||
goods_info = await GoodsInfo.get_or_none(uuid=uuid)
|
||||
except IndexError:
|
||||
return "仓库中道具不存在..."
|
||||
else:
|
||||
goods_info = await GoodsInfo.get_or_none(goods_name=goods_name)
|
||||
if not goods_info:
|
||||
@ -647,9 +655,10 @@ class ShopManage:
|
||||
shop = BuildImage(w, h, font_size=20, color="#f9f6f2")
|
||||
await shop.paste(A, (20, 230))
|
||||
await shop.paste(shop_logo, (450, 30))
|
||||
tip = "注【通过 购买道具 序号 或者 商品名称 购买】"
|
||||
await shop.text(
|
||||
(
|
||||
int((1000 - shop.getsize("注【通过 序号 或者 商品名称 购买】")[0]) / 2),
|
||||
int((1000 - shop.getsize(tip)[0]) / 2),
|
||||
170,
|
||||
),
|
||||
"注【通过 序号 或者 商品名称 购买】",
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
from nonebot_plugin_uninfo import Uninfo
|
||||
from nonebot.plugin import PluginMetadata
|
||||
from nonebot_plugin_session import EventSession
|
||||
from nonebot_plugin_apscheduler import scheduler
|
||||
@ -115,6 +116,13 @@ _sign_matcher.shortcut(
|
||||
prefix=True,
|
||||
)
|
||||
|
||||
_sign_matcher.shortcut(
|
||||
"签到排行",
|
||||
command="签到",
|
||||
arguments=["--list"],
|
||||
prefix=True,
|
||||
)
|
||||
|
||||
_sign_matcher.shortcut(
|
||||
"好感度总排行",
|
||||
command="签到",
|
||||
@ -122,43 +130,44 @@ _sign_matcher.shortcut(
|
||||
prefix=True,
|
||||
)
|
||||
|
||||
_sign_matcher.shortcut(
|
||||
"签到总排行",
|
||||
command="签到",
|
||||
arguments=["--global", "--list"],
|
||||
prefix=True,
|
||||
)
|
||||
|
||||
|
||||
@_sign_matcher.assign("$main")
|
||||
async def _(session: EventSession, arparma: Arparma, nickname: str = UserName()):
|
||||
if session.id1:
|
||||
if path := await SignManage.sign(session, nickname):
|
||||
logger.info("签到成功", arparma.header_result, session=session)
|
||||
await MessageUtils.build_message(path).finish()
|
||||
return MessageUtils.build_message("用户id为空...").send()
|
||||
async def _(session: Uninfo, arparma: Arparma, nickname: str = UserName()):
|
||||
path = await SignManage.sign(session, nickname)
|
||||
logger.info("签到成功", arparma.header_result, session=session)
|
||||
await MessageUtils.build_message(path).finish()
|
||||
|
||||
|
||||
@_sign_matcher.assign("my")
|
||||
async def _(session: EventSession, arparma: Arparma, nickname: str = UserName()):
|
||||
if session.id1:
|
||||
if image := await SignManage.sign(session, nickname, True):
|
||||
logger.info("查看我的签到", arparma.header_result, session=session)
|
||||
await MessageUtils.build_message(image).finish()
|
||||
return MessageUtils.build_message("用户id为空...").send()
|
||||
async def _(session: Uninfo, arparma: Arparma, nickname: str = UserName()):
|
||||
path = await SignManage.sign(session, nickname, True)
|
||||
logger.info("查看我的签到", arparma.header_result, session=session)
|
||||
await MessageUtils.build_message(path).finish()
|
||||
|
||||
|
||||
@_sign_matcher.assign("list")
|
||||
async def _(
|
||||
session: EventSession, arparma: Arparma, num: Query[int] = AlconnaQuery("num", 10)
|
||||
session: Uninfo, arparma: Arparma, num: Query[int] = AlconnaQuery("num", 10)
|
||||
):
|
||||
if num.result > 50:
|
||||
await MessageUtils.build_message("排行榜人数不能超过50哦...").finish()
|
||||
gid = session.id3 or session.id2
|
||||
gid = session.group.id if session.group else None
|
||||
if not arparma.find("global") and not gid:
|
||||
await MessageUtils.build_message(
|
||||
"私聊中无法查看 '好感度排行',请发送 '好感度总排行'"
|
||||
).finish()
|
||||
if session.id1:
|
||||
if arparma.find("global"):
|
||||
gid = None
|
||||
if image := await SignManage.rank(session.id1, num.result, gid):
|
||||
logger.info("查看签到排行", arparma.header_result, session=session)
|
||||
await MessageUtils.build_message(image).finish()
|
||||
return MessageUtils.build_message("用户id为空...").send()
|
||||
if arparma.find("global"):
|
||||
gid = None
|
||||
image = await SignManage.rank(session, num.result, gid)
|
||||
logger.info("查看签到排行", arparma.header_result, session=session)
|
||||
await MessageUtils.build_message(image).send()
|
||||
|
||||
|
||||
@scheduler.scheduled_job(
|
||||
|
||||
@ -4,12 +4,12 @@ from pathlib import Path
|
||||
from datetime import datetime
|
||||
|
||||
import pytz
|
||||
from nonebot_plugin_session import EventSession
|
||||
from nonebot_plugin_uninfo import Uninfo
|
||||
|
||||
from zhenxun.services.log import logger
|
||||
from zhenxun.models.sign_log import SignLog
|
||||
from zhenxun.models.sign_user import SignUser
|
||||
from zhenxun.utils.utils import get_user_avatar
|
||||
from zhenxun.utils.platform import PlatformUtils
|
||||
from zhenxun.models.friend_user import FriendUser
|
||||
from zhenxun.configs.path_config import IMAGE_PATH
|
||||
from zhenxun.models.user_console import UserConsole
|
||||
@ -32,12 +32,12 @@ PLATFORM_PATH = {
|
||||
class SignManage:
|
||||
@classmethod
|
||||
async def rank(
|
||||
cls, user_id: str, num: int, group_id: str | None = None
|
||||
cls, session: Uninfo, num: int, group_id: str | None = None
|
||||
) -> BuildImage: # sourcery skip: avoid-builtin-shadow
|
||||
"""好感度排行
|
||||
|
||||
参数:
|
||||
user_id: 用户id
|
||||
session: Uninfo
|
||||
num: 排行榜数量
|
||||
group_id: 群组id
|
||||
|
||||
@ -49,14 +49,15 @@ class SignManage:
|
||||
user_list = await GroupInfoUser.filter(group_id=group_id).values_list(
|
||||
"user_id", flat=True
|
||||
)
|
||||
query = query.filter(user_id__in=user_list)
|
||||
if user_list:
|
||||
query = query.filter(user_id__in=user_list)
|
||||
user_list = (
|
||||
await query.annotate()
|
||||
.order_by("-impression")
|
||||
.values_list("user_id", "impression", "sign_count", "platform")
|
||||
)
|
||||
user_id_list = [user[0] for user in user_list]
|
||||
index = user_id_list.index(user_id) + 1
|
||||
index = user_id_list.index(session.user.id) + 1
|
||||
user_list = user_list[:num] if num < len(user_list) else user_list
|
||||
column_name = ["排名", "-", "名称", "好感度", "签到次数", "平台"]
|
||||
friend_list = await FriendUser.filter(user_id__in=user_id_list).values_list(
|
||||
@ -70,8 +71,11 @@ class SignManage:
|
||||
for g in group_user:
|
||||
uid2name[g[0]] = g[1]
|
||||
data_list = []
|
||||
platform = PlatformUtils.get_platform(session)
|
||||
for i, user in enumerate(user_list):
|
||||
bytes = await get_user_avatar(user[0])
|
||||
bytes = await PlatformUtils.get_user_avatar(
|
||||
user[0], platform, session.self_id
|
||||
)
|
||||
data_list.append(
|
||||
[
|
||||
f"{i+1}",
|
||||
@ -92,28 +96,29 @@ class SignManage:
|
||||
|
||||
@classmethod
|
||||
async def sign(
|
||||
cls, session: EventSession, nickname: str, is_card_view: bool = False
|
||||
) -> Path | None:
|
||||
cls, session: Uninfo, nickname: str, is_card_view: bool = False
|
||||
) -> Path:
|
||||
"""签到
|
||||
|
||||
参数:
|
||||
session: Session
|
||||
session: Uninfo
|
||||
nickname: 用户昵称
|
||||
is_card_view: 是否展示卡片
|
||||
|
||||
返回:
|
||||
Path: 卡片路径
|
||||
"""
|
||||
if not session.id1:
|
||||
return None
|
||||
platform = PlatformUtils.get_platform(session)
|
||||
now = datetime.now(pytz.timezone("Asia/Shanghai"))
|
||||
user_console = await UserConsole.get_user(session.id1, session.platform)
|
||||
user_console = await UserConsole.get_user(session.user.id, platform)
|
||||
user, _ = await SignUser.get_or_create(
|
||||
user_id=session.id1,
|
||||
defaults={"user_console": user_console, "platform": session.platform},
|
||||
user_id=session.user.id,
|
||||
defaults={"user_console": user_console, "platform": platform},
|
||||
)
|
||||
new_log = (
|
||||
await SignLog.filter(user_id=session.id1).order_by("-create_time").first()
|
||||
await SignLog.filter(user_id=session.user.id)
|
||||
.order_by("-create_time")
|
||||
.first()
|
||||
)
|
||||
log_time = None
|
||||
if new_log:
|
||||
@ -123,7 +128,13 @@ class SignManage:
|
||||
if not is_card_view and (not new_log or (log_time and log_time != now.date())):
|
||||
return await cls._handle_sign_in(user, nickname, session)
|
||||
return await get_card(
|
||||
user, nickname, -1, user_console.gold, "", is_card_view=is_card_view
|
||||
user,
|
||||
session,
|
||||
nickname,
|
||||
-1,
|
||||
user_console.gold,
|
||||
"",
|
||||
is_card_view=is_card_view,
|
||||
)
|
||||
|
||||
@classmethod
|
||||
@ -131,36 +142,35 @@ class SignManage:
|
||||
cls,
|
||||
user: SignUser,
|
||||
nickname: str,
|
||||
session: EventSession,
|
||||
session: Uninfo,
|
||||
) -> Path:
|
||||
"""签到处理
|
||||
|
||||
参数:
|
||||
user: SignUser
|
||||
nickname: 用户昵称
|
||||
session: Session
|
||||
session: Uninfo
|
||||
|
||||
返回:
|
||||
Path: 卡片路径
|
||||
"""
|
||||
platform = PlatformUtils.get_platform(session)
|
||||
impression_added = (secrets.randbelow(99) + 1) / 100
|
||||
rand = random.random()
|
||||
add_probability = float(user.add_probability)
|
||||
specify_probability = user.specify_probability
|
||||
if rand + add_probability > 0.97 or rand < specify_probability:
|
||||
impression_added *= 2
|
||||
await SignUser.sign(user, impression_added, session.bot_id, session.platform)
|
||||
await SignUser.sign(user, impression_added, session.self_id, platform)
|
||||
gold = random.randint(1, 100)
|
||||
gift = random_event(float(user.impression))
|
||||
if isinstance(gift, int):
|
||||
gold += gift
|
||||
await UserConsole.add_gold(
|
||||
user.user_id, gold + gift, "sign_in", session.platform
|
||||
)
|
||||
await UserConsole.add_gold(user.user_id, gold + gift, "sign_in", platform)
|
||||
gift = f"额外金币 +{gift}"
|
||||
else:
|
||||
await UserConsole.add_gold(user.user_id, gold, "sign_in", session.platform)
|
||||
await UserConsole.add_props_by_name(user.user_id, gift, 1, session.platform)
|
||||
await UserConsole.add_gold(user.user_id, gold, "sign_in", platform)
|
||||
await UserConsole.add_props_by_name(user.user_id, gift, 1, platform)
|
||||
gift += " + 1"
|
||||
logger.info(
|
||||
f"签到成功. score: {user.impression:.2f} "
|
||||
@ -170,6 +180,7 @@ class SignManage:
|
||||
)
|
||||
return await get_card(
|
||||
user,
|
||||
session,
|
||||
nickname,
|
||||
impression_added,
|
||||
gold,
|
||||
|
||||
@ -7,13 +7,13 @@ from datetime import datetime
|
||||
import pytz
|
||||
import nonebot
|
||||
from nonebot.drivers import Driver
|
||||
from nonebot_plugin_uninfo import Uninfo
|
||||
from nonebot_plugin_htmlrender import template_to_pic
|
||||
|
||||
from zhenxun.models.sign_log import SignLog
|
||||
from zhenxun.models.sign_user import SignUser
|
||||
from zhenxun.utils.utils import get_user_avatar
|
||||
from zhenxun.utils.http_utils import AsyncHttpx
|
||||
from zhenxun.utils.image_utils import BuildImage
|
||||
from zhenxun.utils.platform import PlatformUtils
|
||||
from zhenxun.configs.config import Config, BotConfig
|
||||
from zhenxun.configs.path_config import IMAGE_PATH, TEMPLATE_PATH
|
||||
|
||||
@ -63,6 +63,7 @@ async def init_image():
|
||||
|
||||
async def get_card(
|
||||
user: SignUser,
|
||||
session: Uninfo,
|
||||
nickname: str,
|
||||
add_impression: float,
|
||||
gold: int | None,
|
||||
@ -74,6 +75,7 @@ async def get_card(
|
||||
|
||||
参数:
|
||||
user: SignUser
|
||||
session: Uninfo
|
||||
nickname: 用户昵称
|
||||
impression: 新增的好感度
|
||||
gold: 金币
|
||||
@ -99,17 +101,18 @@ async def get_card(
|
||||
is_card_view = True
|
||||
return (
|
||||
await _generate_html_card(
|
||||
user, nickname, add_impression, gold, gift, is_double, is_card_view
|
||||
user, session, nickname, add_impression, gold, gift, is_double, is_card_view
|
||||
)
|
||||
if base_config.get("IMAGE_STYLE") == "zhenxun"
|
||||
else await _generate_card(
|
||||
user, nickname, add_impression, gold, gift, is_double, is_card_view
|
||||
user, session, nickname, add_impression, gold, gift, is_double, is_card_view
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
async def _generate_card(
|
||||
user: SignUser,
|
||||
session: Uninfo,
|
||||
nickname: str,
|
||||
add_impression: float,
|
||||
gold: int | None,
|
||||
@ -121,6 +124,7 @@ async def _generate_card(
|
||||
|
||||
参数:
|
||||
user: SignUser
|
||||
session: Uninfo
|
||||
nickname: 用户昵称
|
||||
add_impression: 新增的好感度
|
||||
gold: 金币
|
||||
@ -137,7 +141,9 @@ async def _generate_card(
|
||||
140,
|
||||
background=SIGN_BORDER_PATH / "ava_border_01.png",
|
||||
)
|
||||
if user.platform == "qq" and (byt := await get_user_avatar(user.user_id)):
|
||||
if session.user.avatar and (
|
||||
byt := await AsyncHttpx.get_content(session.user.avatar)
|
||||
):
|
||||
ava = BuildImage(107, 107, background=BytesIO(byt))
|
||||
else:
|
||||
ava = BuildImage(107, 107, (0, 0, 0))
|
||||
@ -273,10 +279,6 @@ async def _generate_card(
|
||||
await bk.paste(nickname_img, (30, 15))
|
||||
await bk.paste(uid_img, (30, 85))
|
||||
await bk.paste(A, (0, 150))
|
||||
# await bk.text((30, 167), "Accumulative check-in for")
|
||||
# _x = bk.getsize("Accumulative check-in for")[0] + sign_day_img.width + 45
|
||||
# await bk.paste(sign_day_img, (398, 158))
|
||||
# await bk.text((_x, 167), "days")
|
||||
await bk.paste(tip_image, (10, 167))
|
||||
await bk.paste(date_img, (220, 370))
|
||||
await bk.paste(lik_text1_img, (220, 240))
|
||||
@ -377,6 +379,7 @@ def clear_sign_data_pic():
|
||||
|
||||
async def _generate_html_card(
|
||||
user: SignUser,
|
||||
session: Uninfo,
|
||||
nickname: str,
|
||||
add_impression: float,
|
||||
gold: int | None,
|
||||
@ -388,6 +391,7 @@ async def _generate_html_card(
|
||||
|
||||
参数:
|
||||
user: SignUser
|
||||
session: Uninfo
|
||||
nickname: 用户昵称
|
||||
add_impression: 新增的好感度
|
||||
gold: 金币
|
||||
@ -420,9 +424,8 @@ async def _generate_html_card(
|
||||
next_impression - previous_impression
|
||||
)
|
||||
now = datetime.now()
|
||||
ava_url = PlatformUtils.get_user_avatar_url(user.user_id, "qq")
|
||||
data = {
|
||||
"ava_url": ava_url,
|
||||
"ava_url": session.user.avatar,
|
||||
"name": nickname,
|
||||
"uid": uid,
|
||||
"sign_count": f"{user.sign_count}",
|
||||
|
||||
@ -16,7 +16,6 @@ from zhenxun.utils.common_utils import CommonUtils
|
||||
|
||||
|
||||
class BroadcastManage:
|
||||
|
||||
@classmethod
|
||||
async def send(
|
||||
cls, bot: Bot, message: UniMsg, session: EventSession
|
||||
@ -43,8 +42,9 @@ class BroadcastManage:
|
||||
for group in group_list:
|
||||
try:
|
||||
if not await CommonUtils.task_is_block(
|
||||
group.group_id,
|
||||
bot,
|
||||
"broadcast", # group.channel_id
|
||||
group.group_id,
|
||||
):
|
||||
target = PlatformUtils.get_target(
|
||||
bot, None, group.channel_id or group.group_id
|
||||
|
||||
@ -15,6 +15,19 @@ class BotSetting(BaseModel):
|
||||
"""数据库链接"""
|
||||
platform_superusers: dict[str, list[str]] = {}
|
||||
"""平台超级用户"""
|
||||
qbot_id_data: dict[str, str] = {}
|
||||
"""官bot id:账号id"""
|
||||
|
||||
def get_qbot_uid(self, qbot_id: str) -> str | None:
|
||||
"""获取官bot账号id
|
||||
|
||||
参数:
|
||||
qbot_id: 官bot id
|
||||
|
||||
返回:
|
||||
str: 账号id
|
||||
"""
|
||||
return self.qbot_id_data.get(qbot_id)
|
||||
|
||||
def get_superuser(self, platform: str) -> list[str]:
|
||||
"""获取超级用户
|
||||
|
||||
@ -1,2 +0,0 @@
|
||||
from .db_context import *
|
||||
from .log import *
|
||||
@ -4,13 +4,11 @@ from tortoise.models import Model as Model_
|
||||
from nonebot.utils import is_coroutine_callable
|
||||
|
||||
from zhenxun.configs.config import BotConfig
|
||||
from zhenxun.configs.path_config import DATA_PATH
|
||||
|
||||
from .log import logger
|
||||
|
||||
SCRIPT_METHOD = []
|
||||
MODELS: list[str] = []
|
||||
DATABASE_SETTING_FILE = DATA_PATH / "database.json"
|
||||
|
||||
|
||||
class Model(Model_):
|
||||
|
||||
@ -7,6 +7,7 @@ require("nonebot_plugin_session")
|
||||
from loguru import logger as logger_
|
||||
from nonebot_plugin_session import Session
|
||||
from nonebot.log import default_filter, default_format
|
||||
from nonebot_plugin_uninfo import Session as uninfoSession
|
||||
|
||||
from zhenxun.configs.path_config import LOG_PATH
|
||||
|
||||
@ -77,13 +78,25 @@ class logger:
|
||||
platform: str | None = None,
|
||||
): ...
|
||||
|
||||
@overload
|
||||
@classmethod
|
||||
def info(
|
||||
cls,
|
||||
info: str,
|
||||
command: str | None = None,
|
||||
*,
|
||||
session: int | str | Session | None = None,
|
||||
session: uninfoSession | None = None,
|
||||
target: Any = None,
|
||||
platform: str | None = None,
|
||||
): ...
|
||||
|
||||
@classmethod
|
||||
def info(
|
||||
cls,
|
||||
info: str,
|
||||
command: str | None = None,
|
||||
*,
|
||||
session: int | str | Session | uninfoSession | None = None,
|
||||
group_id: int | str | None = None,
|
||||
adapter: str | None = None,
|
||||
target: Any = None,
|
||||
@ -98,6 +111,12 @@ class logger:
|
||||
elif session.id2:
|
||||
group_id = f"{session.id2}"
|
||||
platform = platform or session.platform
|
||||
elif isinstance(session, uninfoSession):
|
||||
user_id = session.user.id
|
||||
adapter = session.adapter
|
||||
if session.group:
|
||||
group_id = session.group.id
|
||||
platform = session.basic["scope"]
|
||||
template = cls.__parser_template(
|
||||
info, command, user_id, group_id, adapter, target, platform
|
||||
)
|
||||
@ -150,13 +169,27 @@ class logger:
|
||||
e: Exception | None = None,
|
||||
): ...
|
||||
|
||||
@overload
|
||||
@classmethod
|
||||
def warning(
|
||||
cls,
|
||||
info: str,
|
||||
command: str | None = None,
|
||||
*,
|
||||
session: int | str | Session | None = None,
|
||||
session: uninfoSession | None = None,
|
||||
adapter: str | None = None,
|
||||
target: Any = None,
|
||||
platform: str | None = None,
|
||||
e: Exception | None = None,
|
||||
): ...
|
||||
|
||||
@classmethod
|
||||
def warning(
|
||||
cls,
|
||||
info: str,
|
||||
command: str | None = None,
|
||||
*,
|
||||
session: int | str | Session | uninfoSession | None = None,
|
||||
group_id: int | str | None = None,
|
||||
adapter: str | None = None,
|
||||
target: Any = None,
|
||||
@ -172,6 +205,12 @@ class logger:
|
||||
elif session.id2:
|
||||
group_id = f"{session.id2}"
|
||||
platform = platform or session.platform
|
||||
elif isinstance(session, uninfoSession):
|
||||
user_id = session.user.id
|
||||
adapter = session.adapter
|
||||
if session.group:
|
||||
group_id = session.group.id
|
||||
platform = session.basic["scope"]
|
||||
template = cls.__parser_template(
|
||||
info, command, user_id, group_id, adapter, target, platform
|
||||
)
|
||||
@ -210,13 +249,26 @@ class logger:
|
||||
e: Exception | None = None,
|
||||
): ...
|
||||
|
||||
@overload
|
||||
@classmethod
|
||||
def error(
|
||||
cls,
|
||||
info: str,
|
||||
command: str | None = None,
|
||||
*,
|
||||
session: int | str | Session | None = None,
|
||||
session: uninfoSession | None = None,
|
||||
target: Any = None,
|
||||
platform: str | None = None,
|
||||
e: Exception | None = None,
|
||||
): ...
|
||||
|
||||
@classmethod
|
||||
def error(
|
||||
cls,
|
||||
info: str,
|
||||
command: str | None = None,
|
||||
*,
|
||||
session: int | str | Session | uninfoSession | None = None,
|
||||
group_id: int | str | None = None,
|
||||
adapter: str | None = None,
|
||||
target: Any = None,
|
||||
@ -232,6 +284,12 @@ class logger:
|
||||
elif session.id2:
|
||||
group_id = f"{session.id2}"
|
||||
platform = platform or session.platform
|
||||
elif isinstance(session, uninfoSession):
|
||||
user_id = session.user.id
|
||||
adapter = session.adapter
|
||||
if session.group:
|
||||
group_id = session.group.id
|
||||
platform = session.basic["scope"]
|
||||
template = cls.__parser_template(
|
||||
info, command, user_id, group_id, adapter, target, platform
|
||||
)
|
||||
@ -270,13 +328,26 @@ class logger:
|
||||
e: Exception | None = None,
|
||||
): ...
|
||||
|
||||
@overload
|
||||
@classmethod
|
||||
def debug(
|
||||
cls,
|
||||
info: str,
|
||||
command: str | None = None,
|
||||
*,
|
||||
session: int | str | Session | None = None,
|
||||
session: uninfoSession | None = None,
|
||||
target: Any = None,
|
||||
platform: str | None = None,
|
||||
e: Exception | None = None,
|
||||
): ...
|
||||
|
||||
@classmethod
|
||||
def debug(
|
||||
cls,
|
||||
info: str,
|
||||
command: str | None = None,
|
||||
*,
|
||||
session: int | str | Session | uninfoSession | None = None,
|
||||
group_id: int | str | None = None,
|
||||
adapter: str | None = None,
|
||||
target: Any = None,
|
||||
@ -292,6 +363,12 @@ class logger:
|
||||
elif session.id2:
|
||||
group_id = f"{session.id2}"
|
||||
platform = platform or session.platform
|
||||
elif isinstance(session, uninfoSession):
|
||||
user_id = session.user.id
|
||||
adapter = session.adapter
|
||||
if session.group:
|
||||
group_id = session.group.id
|
||||
platform = session.basic["scope"]
|
||||
template = cls.__parser_template(
|
||||
info, command, user_id, group_id, adapter, target, platform
|
||||
)
|
||||
|
||||
@ -1,3 +1,6 @@
|
||||
from nonebot.adapters import Bot
|
||||
from nonebot_plugin_uninfo import Uninfo, Session, SupportScope, get_interface
|
||||
|
||||
from zhenxun.services.log import logger
|
||||
from zhenxun.configs.config import BotConfig
|
||||
from zhenxun.models.task_info import TaskInfo
|
||||
@ -6,9 +9,10 @@ from zhenxun.models.group_console import GroupConsole
|
||||
|
||||
|
||||
class CommonUtils:
|
||||
|
||||
@classmethod
|
||||
async def task_is_block(cls, module: str, group_id: str | None) -> bool:
|
||||
async def task_is_block(
|
||||
cls, session: Uninfo | Bot, module: str, group_id: str | None = None
|
||||
) -> bool:
|
||||
"""判断被动技能是否可以发送
|
||||
|
||||
参数:
|
||||
@ -18,6 +22,19 @@ class CommonUtils:
|
||||
返回:
|
||||
bool: 是否可以发送
|
||||
"""
|
||||
if isinstance(session, Bot):
|
||||
if interface := get_interface(session):
|
||||
info = interface.basic_info()
|
||||
if info["scope"] == SupportScope.qq_api:
|
||||
logger.info("q官bot放弃所有被动技能发言...")
|
||||
"""q官bot放弃所有被动技能发言"""
|
||||
return False
|
||||
if session.scene == SupportScope.qq_api:
|
||||
"""q官bot放弃所有被动技能发言"""
|
||||
logger.info("q官bot放弃所有被动技能发言...")
|
||||
return False
|
||||
if not group_id and isinstance(session, Session):
|
||||
group_id = session.group.id if session.group else None
|
||||
if task := await TaskInfo.get_or_none(module=module):
|
||||
"""被动全局状态"""
|
||||
if not task.status:
|
||||
@ -39,7 +56,6 @@ class CommonUtils:
|
||||
|
||||
|
||||
class SqlUtils:
|
||||
|
||||
@classmethod
|
||||
def random(cls, query, limit: int = 1) -> str:
|
||||
db_class_name = BotConfig.get_sql_type()
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
from typing import Any
|
||||
|
||||
from nonebot.internal.params import Depends
|
||||
from nonebot.matcher import Matcher
|
||||
from nonebot.params import Command
|
||||
from nonebot.matcher import Matcher
|
||||
from nonebot_plugin_uninfo import Uninfo
|
||||
from nonebot.internal.params import Depends
|
||||
from nonebot_plugin_session import EventSession
|
||||
from nonebot_plugin_userinfo import EventUserInfo, UserInfo
|
||||
|
||||
from zhenxun.configs.config import Config
|
||||
from zhenxun.utils.message import MessageUtils
|
||||
@ -49,10 +49,8 @@ def UserName():
|
||||
用户名称
|
||||
"""
|
||||
|
||||
async def dependency(user_info: UserInfo = EventUserInfo()):
|
||||
return (
|
||||
user_info.user_displayname or user_info.user_remark or user_info.user_name
|
||||
) or ""
|
||||
async def dependency(user_info: Uninfo):
|
||||
return user_info.user.nick or user_info.user.name or ""
|
||||
|
||||
return Depends(dependency)
|
||||
|
||||
|
||||
@ -202,6 +202,11 @@ class AsyncHttpx:
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
@classmethod
|
||||
async def get_content(cls, url: str, **kwargs) -> bytes | None:
|
||||
res = await cls.get(url, **kwargs)
|
||||
return res.content if res and res.status_code == 200 else None
|
||||
|
||||
@classmethod
|
||||
async def download_file(
|
||||
cls,
|
||||
|
||||
@ -7,20 +7,24 @@ import nonebot
|
||||
from pydantic import BaseModel
|
||||
from nonebot.adapters import Bot
|
||||
from nonebot.utils import is_coroutine_callable
|
||||
from nonebot_plugin_uninfo import get_interface
|
||||
from nonebot_plugin_alconna import SupportScope
|
||||
from nonebot.adapters.dodo import Bot as DodoBot
|
||||
from nonebot.adapters.onebot.v11 import Bot as v11Bot
|
||||
from nonebot.adapters.onebot.v12 import Bot as v12Bot
|
||||
from nonebot_plugin_uninfo import Uninfo, get_interface
|
||||
from nonebot.adapters.kaiheila import Bot as KaiheilaBot
|
||||
from nonebot_plugin_alconna.uniseg import Target, Receipt, UniMessage
|
||||
|
||||
from zhenxun.services.log import logger
|
||||
from zhenxun.configs.config import BotConfig
|
||||
from zhenxun.utils.message import MessageUtils
|
||||
from zhenxun.utils.http_utils import AsyncHttpx
|
||||
from zhenxun.models.friend_user import FriendUser
|
||||
from zhenxun.utils.exception import NotFindSuperuser
|
||||
from zhenxun.models.group_console import GroupConsole
|
||||
|
||||
driver = nonebot.get_driver()
|
||||
|
||||
|
||||
class UserData(BaseModel):
|
||||
name: str
|
||||
@ -40,6 +44,18 @@ class UserData(BaseModel):
|
||||
|
||||
|
||||
class PlatformUtils:
|
||||
@classmethod
|
||||
def is_qbot(cls, session: Uninfo) -> bool:
|
||||
"""判断bot是否为qq官bot
|
||||
|
||||
参数:
|
||||
session: Uninfo
|
||||
|
||||
返回:
|
||||
bool: 是否为官bot
|
||||
"""
|
||||
return session.scope == SupportScope.qq_api
|
||||
|
||||
@classmethod
|
||||
async def ban_user(cls, bot: Bot, user_id: str, group_id: str, duration: int):
|
||||
"""禁言
|
||||
@ -244,30 +260,27 @@ class PlatformUtils:
|
||||
return None
|
||||
|
||||
@classmethod
|
||||
async def get_user_avatar(cls, user_id: str, platform: str) -> bytes | None:
|
||||
async def get_user_avatar(
|
||||
cls, user_id: str, platform: str, appid: str | None = None
|
||||
) -> bytes | None:
|
||||
"""快捷获取用户头像
|
||||
|
||||
参数:
|
||||
user_id: 用户id
|
||||
platform: 平台
|
||||
"""
|
||||
url = None
|
||||
if platform == "qq":
|
||||
url = f"http://q1.qlogo.cn/g?b=qq&nk={user_id}&s=160"
|
||||
async with httpx.AsyncClient() as client:
|
||||
for _ in range(3):
|
||||
try:
|
||||
return (await client.get(url)).content
|
||||
except Exception:
|
||||
logger.error(
|
||||
"获取用户头像错误",
|
||||
"Util",
|
||||
target=user_id,
|
||||
platform=platform,
|
||||
)
|
||||
return None
|
||||
if user_id.isdigit():
|
||||
url = f"http://q1.qlogo.cn/g?b=qq&nk={user_id}&s=160"
|
||||
else:
|
||||
url = f"https://q.qlogo.cn/qqapp/{appid}/{user_id}/100"
|
||||
return await AsyncHttpx.get_content(url) if url else None
|
||||
|
||||
@classmethod
|
||||
def get_user_avatar_url(cls, user_id: str, platform: str) -> str | None:
|
||||
def get_user_avatar_url(
|
||||
cls, user_id: str, platform: str, appid: str | None = None
|
||||
) -> str | None:
|
||||
"""快捷获取用户头像url
|
||||
|
||||
参数:
|
||||
@ -275,8 +288,13 @@ class PlatformUtils:
|
||||
platform: 平台
|
||||
"""
|
||||
if platform == "qq":
|
||||
return f"http://q1.qlogo.cn/g?b=qq&nk={user_id}&s=160"
|
||||
return None
|
||||
return (
|
||||
f"http://q1.qlogo.cn/g?b=qq&nk={user_id}&s=160"
|
||||
if user_id.isdigit()
|
||||
else f"https://q.qlogo.cn/qqapp/{appid}/{user_id}/100"
|
||||
)
|
||||
else:
|
||||
return None
|
||||
|
||||
@classmethod
|
||||
async def get_group_avatar(cls, gid: str, platform: str) -> bytes | None:
|
||||
@ -371,7 +389,7 @@ class PlatformUtils:
|
||||
return len(create_list)
|
||||
|
||||
@classmethod
|
||||
def get_platform(cls, bot: Bot) -> str | None:
|
||||
def get_platform(cls, t: Bot | Uninfo) -> str:
|
||||
"""获取平台
|
||||
|
||||
参数:
|
||||
@ -380,9 +398,13 @@ class PlatformUtils:
|
||||
返回:
|
||||
str | None: 平台
|
||||
"""
|
||||
if interface := get_interface(bot):
|
||||
info = interface.basic_info()
|
||||
platform = info["scope"].lower()
|
||||
if isinstance(t, Bot):
|
||||
if interface := get_interface(t):
|
||||
info = interface.basic_info()
|
||||
platform = info["scope"].lower()
|
||||
return "qq" if platform.startswith("qq") else platform
|
||||
else:
|
||||
platform = t.basic["scope"].lower()
|
||||
return "qq" if platform.startswith("qq") else platform
|
||||
return "unknown"
|
||||
|
||||
@ -548,7 +570,7 @@ async def broadcast_group(
|
||||
bot: Bot | list[Bot] | None = None,
|
||||
bot_id: str | set[str] | None = None,
|
||||
ignore_group: set[int] | None = None,
|
||||
check_func: Callable[[str], Awaitable] | None = None,
|
||||
check_func: Callable[[Bot, str], Awaitable] | None = None,
|
||||
log_cmd: str | None = None,
|
||||
platform: Literal["qq", "dodo", "kaiheila"] | None = None,
|
||||
):
|
||||
@ -611,9 +633,9 @@ async def broadcast_group(
|
||||
is_run = False
|
||||
if check_func:
|
||||
if is_coroutine_callable(check_func):
|
||||
is_run = await check_func(group.group_id)
|
||||
is_run = await check_func(_bot, group.group_id)
|
||||
else:
|
||||
is_run = check_func(group.group_id)
|
||||
is_run = check_func(_bot, group.group_id)
|
||||
if not is_run:
|
||||
logger.debug(
|
||||
"广播方法检测运行方法为 False, 已跳过...",
|
||||
|
||||
@ -1,10 +1,12 @@
|
||||
from nonebot.internal.rule import Rule
|
||||
from nonebot.adapters import Bot, Event
|
||||
from nonebot.permission import SUPERUSER
|
||||
from nonebot_plugin_session import EventSession, SessionLevel
|
||||
from nonebot_plugin_uninfo import Uninfo
|
||||
from nonebot_plugin_session import EventSession
|
||||
|
||||
from zhenxun.configs.config import Config
|
||||
from zhenxun.models.level_user import LevelUser
|
||||
from zhenxun.utils.platform import PlatformUtils
|
||||
|
||||
|
||||
def admin_check(a: int | str, key: str | None = None) -> Rule:
|
||||
@ -19,33 +21,38 @@ def admin_check(a: int | str, key: str | None = None) -> Rule:
|
||||
Rule: Rule
|
||||
"""
|
||||
|
||||
async def _rule(bot: Bot, event: Event, session: EventSession) -> bool:
|
||||
async def _rule(bot: Bot, event: Event, session: Uninfo) -> bool:
|
||||
if await SUPERUSER(bot, event):
|
||||
return True
|
||||
if session.id1 and session.id2:
|
||||
if PlatformUtils.is_qbot(session):
|
||||
"""官bot接口,放弃所有权限检查"""
|
||||
return False
|
||||
if session.id and session.group:
|
||||
level = a
|
||||
if isinstance(a, str) and key:
|
||||
level = Config.get_config(a, key)
|
||||
if level is not None:
|
||||
return bool(
|
||||
await LevelUser.check_level(session.id1, session.id2, int(level))
|
||||
await LevelUser.check_level(
|
||||
session.id, session.group.id, int(level)
|
||||
)
|
||||
)
|
||||
return False
|
||||
|
||||
return Rule(_rule)
|
||||
|
||||
|
||||
def ensure_group(session: EventSession) -> bool:
|
||||
def ensure_group(session: Uninfo) -> bool:
|
||||
"""
|
||||
是否在群聊中
|
||||
|
||||
参数:
|
||||
session: session
|
||||
session: Uninfo
|
||||
|
||||
返回:
|
||||
bool: bool
|
||||
"""
|
||||
return session.level in [SessionLevel.LEVEL2, SessionLevel.LEVEL3]
|
||||
return bool(session.group)
|
||||
|
||||
|
||||
def ensure_private(session: EventSession) -> bool:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user