mirror of
https://github.com/KimigaiiWuyi/GenshinUID.git
synced 2025-07-03 21:43:30 +00:00
Compare commits
549 Commits
QQGuildBot
...
ntchat
Author | SHA1 | Date | |
---|---|---|---|
42e8693463 | |||
92e032077c | |||
00b1ebd71e | |||
de71e83be8 | |||
a398fcc0f3 | |||
11840e0f75 | |||
77a597cfca | |||
b128fd38b8 | |||
447b24dde9 | |||
72c36be0a9 | |||
2c07c490bb | |||
914ff0e83b | |||
a9eacfbe0c | |||
91f0ee82b9 | |||
8727fb0bc1 | |||
6cb7bd7ab8 | |||
efa924c1a8 | |||
01b9d48b38 | |||
b84764d907 | |||
236fbebd3b | |||
a9600d85b7 | |||
b087dd7f24 | |||
083f55d852 | |||
5aec15e9f4 | |||
d952e1bf78 | |||
2e4120bf89 | |||
a325bfe4f2 | |||
f9e84e5fdf | |||
c8588a2848 | |||
79d1e86200 | |||
40217dba09 | |||
2cb0ccd452 | |||
52b1c06125 | |||
1f54160e2b | |||
15fc075878 | |||
2a03b056da | |||
6bf9cef4f4 | |||
c3562ae49e | |||
de312d2314 | |||
db96d23876 | |||
ecb286b33f | |||
a93787bfea | |||
f93eb116f1 | |||
3265e2cf0d | |||
2c4c3589fc | |||
77ea5118a2 | |||
a7e0477f72 | |||
fe59404ee9 | |||
402184496f | |||
6a3504026b | |||
59184adea7 | |||
83fd57ec54 | |||
e6979b75be | |||
7878f0e278 | |||
e318984801 | |||
d62ab6e341 | |||
d5a379d0ef | |||
02375b1284 | |||
2aaf5aa1c6 | |||
54701a448b | |||
d74959b751 | |||
d087e75e4e | |||
79a4faf5c4 | |||
38f08262d4 | |||
13c5fe2eb0 | |||
92844b1897 | |||
2984f4e578 | |||
8407d556ee | |||
d68cbc24fa | |||
8032841408 | |||
9eaf184f19 | |||
a215bc16cb | |||
ed412e890c | |||
99ea01d9e4 | |||
ad385bd77c | |||
18fd5e2cd0 | |||
cd2303d37d | |||
6ba82d4d1b | |||
96227fe4be | |||
fa35be809f | |||
9f7db4e5b2 | |||
5c6008381b | |||
461911e186 | |||
ef1d7eb997 | |||
8f2d3ae8e5 | |||
21c40bcfe5 | |||
fbb1cec548 | |||
0371014fd6 | |||
d367197838 | |||
4cfd3537f0 | |||
a221356da4 | |||
5bc15948fe | |||
a8040c7321 | |||
5cb62671fc | |||
9b959b0f2c | |||
bb2b19ec22 | |||
c5e1d9e88a | |||
82842b25fc | |||
56700bf420 | |||
c3e8aaa6fc | |||
8c53148488 | |||
96b40242e8 | |||
7df0a67f8d | |||
bf17cc3caf | |||
a1002d91ec | |||
9ae5605af0 | |||
f79dbd03b4 | |||
8c08e1c2d6 | |||
6e76e909d3 | |||
a39e3c7365 | |||
46444af78c | |||
166d530f35 | |||
571b9bd97a | |||
18e5c968ad | |||
142995766e | |||
9db963ea18 | |||
996a4e8c29 | |||
4a7f822b94 | |||
f04e8ccc48 | |||
98907c5671 | |||
f6e4f8c129 | |||
f20c0b7e1f | |||
9f9106d788 | |||
cdab68347c | |||
87885db01e | |||
90ce5b77fe | |||
dc4ba1811f | |||
32f391e629 | |||
46a176283d | |||
7b15e44f9d | |||
1204b5a5e7 | |||
b0b09cdc70 | |||
eb17cebc28 | |||
d9eeca0ba8 | |||
7c30452e15 | |||
9c7a51e749 | |||
bc9af2b8d6 | |||
2a92081968 | |||
1f4322b769 | |||
bbb301d72a | |||
bcce62c85e | |||
f7fe9f9d63 | |||
2f972be222 | |||
a1a101425b | |||
6dd162c3b7 | |||
f769b8b99c | |||
f670dfa390 | |||
e4457570d7 | |||
adb056d09d | |||
751c7bb813 | |||
8bb3dd89f2 | |||
ce46e947e4 | |||
bb90787f66 | |||
1bda35d1de | |||
9bff5c32a6 | |||
cf679eec07 | |||
f08fb41a7e | |||
7cce007c35 | |||
cb5fb92402 | |||
56ab7b7526 | |||
2ee4c88e0c | |||
dad448df15 | |||
6e650a5cb8 | |||
04dabc83b5 | |||
bd6d3f68e9 | |||
a2a14693c6 | |||
9a3a4310ca | |||
233d6c9d32 | |||
50b4b085d0 | |||
9af2948e32 | |||
5f5617055d | |||
fb26df7402 | |||
d4df7fe3aa | |||
8be890316d | |||
6a67436cae | |||
5ad3cb3bf0 | |||
a3689f53a6 | |||
b646c47762 | |||
44311e2fc2 | |||
9ef5d35ea2 | |||
3dc89d9762 | |||
64972b76f8 | |||
190a688767 | |||
468314a874 | |||
5d827ea8b2 | |||
6929e05da0 | |||
724c5ed2fc | |||
fabd1b6860 | |||
4c07ac3d36 | |||
78f35d5545 | |||
30a55f8dcf | |||
088c74e500 | |||
ec2b508f2c | |||
c561836a73 | |||
6f5e098873 | |||
33709d90c9 | |||
30978e619a | |||
918625a2fa | |||
c4696df1c1 | |||
8f213eade3 | |||
1c390d08d5 | |||
a2153a5898 | |||
d7315d3ab3 | |||
aaf34f8018 | |||
e714a9e1ca | |||
91a716d455 | |||
a13b70f57a | |||
c7a69ec603 | |||
8296c1cd6c | |||
2e16de59b4 | |||
3fc66a8513 | |||
25447ee622 | |||
10b2ddde15 | |||
9be4447a24 | |||
ef87a6b4f7 | |||
c2a2d31254 | |||
52e465ea7e | |||
1303cb391e | |||
357579046b | |||
d44e5044d9 | |||
30269eb214 | |||
624c9e7b3f | |||
3bd8cb5373 | |||
b33297a03c | |||
bc6d56da0b | |||
67fb636d3e | |||
22899cb9fe | |||
b755593b59 | |||
40e4a97a42 | |||
ecfc1695f5 | |||
d7369bc79c | |||
ea7e78eb3b | |||
cd96ddbea8 | |||
bc61e2e112 | |||
44385d3104 | |||
fff4ec1c84 | |||
8973de82f9 | |||
b0c30e0489 | |||
bff3185cb8 | |||
04f4e77973 | |||
560b3f8f8f | |||
e0c4f3c5cc | |||
02e295b1f0 | |||
127573b353 | |||
8f79f3d5de | |||
3b5008c13b | |||
aa8e09d131 | |||
76d7ed3524 | |||
d6a1099a76 | |||
5fa33b8f60 | |||
6415280014 | |||
814536fb15 | |||
7f67d17829 | |||
5fefcc7cd4 | |||
1bc24ded0f | |||
48c252aaf4 | |||
43f17cea2f | |||
883c0443b1 | |||
ce72a4eb96 | |||
2268efd9dc | |||
f057f7e213 | |||
84f8285760 | |||
5a1c07986c | |||
5de1084b6f | |||
406d91bf71 | |||
ea3d0273e7 | |||
d0a3be1646 | |||
645e2c0035 | |||
17caf6bedf | |||
68a62e2aaa | |||
d629eaacbb | |||
b9f716d84e | |||
e26bebabdf | |||
d6155898ce | |||
db7eb0fc60 | |||
e4dc7f8f41 | |||
d9643dc0f1 | |||
4b97ef858c | |||
6417d470b8 | |||
a7499054ed | |||
1e107e36fe | |||
7c0fff9da4 | |||
04d197f6b4 | |||
7294f1d15f | |||
5de4d63cc5 | |||
27cf8c2f3b | |||
d4166edaf6 | |||
04a615cf85 | |||
c438f54668 | |||
099f375e2e | |||
09cc494672 | |||
ec95a3934d | |||
21703b4984 | |||
fad0f6521d | |||
520bec43fb | |||
ecdd35b853 | |||
c886522b49 | |||
0f53f9ba17 | |||
66981b91eb | |||
0741c25741 | |||
3f524a7251 | |||
4a718ff5ed | |||
940b93f851 | |||
5d497294c2 | |||
161cc8ba69 | |||
4afde3744f | |||
2262798ade | |||
5b2703fa24 | |||
7ff9c3896f | |||
6c58a98aa5 | |||
d1cac471f6 | |||
ceb2ee9082 | |||
789ae23773 | |||
45d375ca49 | |||
08f78df595 | |||
6cb4817827 | |||
26acc0850b | |||
34a7497b1d | |||
5d31805c49 | |||
87debcd6ad | |||
4e3798bb7c | |||
50b2bc1e56 | |||
d68d3c3ff7 | |||
72a2bdc454 | |||
f5931ac77f | |||
2ef7e72dfd | |||
a6f092a7b4 | |||
f9a8d99257 | |||
4d377306ef | |||
61293fb072 | |||
27bc2a6aa5 | |||
634cb616ed | |||
8ed0bb9c8f | |||
3c48903335 | |||
490528b716 | |||
11a5da22ef | |||
752e6b8d40 | |||
9ef8b4000b | |||
ebb6b8f3d2 | |||
d11d79ab80 | |||
7b9d06fd2f | |||
e5bf2e088c | |||
0683a4240f | |||
c8035ddbd2 | |||
271d29c8ef | |||
2e0a2df4a2 | |||
12ad30f44f | |||
3bfc5d1d19 | |||
6c63d87e28 | |||
73c49de621 | |||
36c5cf910c | |||
5e117556ae | |||
f62a53ef5e | |||
b70a9a01f6 | |||
62b4593ef9 | |||
facbfde165 | |||
919f33449a | |||
3207c02eab | |||
48c3f05af0 | |||
434106c933 | |||
024a1debd7 | |||
71bc1135d1 | |||
3156e18083 | |||
77586e0a08 | |||
2b6e03505d | |||
019308146f | |||
8deea2a879 | |||
2afc633f64 | |||
46d672fc2c | |||
70a2eee1c0 | |||
011d158b7d | |||
ec9e51dc35 | |||
99820423c3 | |||
d454fe5bfe | |||
5e1555ff21 | |||
6d8ddf5033 | |||
cfb19604cc | |||
4126bfc48a | |||
c246a5165f | |||
8b59b9f371 | |||
0caf3c605a | |||
1308dc7ec9 | |||
10a2cc7bc7 | |||
f77195dee6 | |||
c11d79e672 | |||
2df9eef519 | |||
4cbb7afacb | |||
9b73ea2ebf | |||
719779f226 | |||
b3e85d04c8 | |||
35b06d2b1d | |||
5a469cc46c | |||
595cf50af4 | |||
cd7ad11fc3 | |||
65c705cddf | |||
d4667a7446 | |||
70438d55f0 | |||
1eb0592d0e | |||
24611c63e9 | |||
6d6ec3b8f1 | |||
872d39dbf5 | |||
1af2565237 | |||
70f3a7a513 | |||
5bcdd57bfe | |||
5dc2154073 | |||
4bc1f15335 | |||
24349d5e24 | |||
8d2959544b | |||
696034acc2 | |||
8530e690fd | |||
a370d65ecb | |||
5eccdc246a | |||
3ea4f0898a | |||
e7f992491d | |||
e462ccf60e | |||
a5c6f9c260 | |||
e7d6a709d4 | |||
4805e306b1 | |||
86b95f0891 | |||
ce3c1e7b07 | |||
b8358b064c | |||
3cfec0e799 | |||
7a5380e27f | |||
2e70e18b2d | |||
56ae609c94 | |||
c4669d72ec | |||
1c2b80cba5 | |||
172b4ef263 | |||
f3c94c2b4d | |||
e552b8b89d | |||
e6f3d61995 | |||
7c9a901d00 | |||
b5a67757fc | |||
c658ec1f2c | |||
515ee27ab2 | |||
df317e5183 | |||
23a9d47961 | |||
eb8411fa3a | |||
53a6358c20 | |||
38cfe192e7 | |||
88cf977de4 | |||
ee0270cc08 | |||
eb24ca088a | |||
f3d958f555 | |||
46e9654870 | |||
fb41af1183 | |||
7c6f3811ae | |||
d06c586325 | |||
525c6791f9 | |||
ae0c66b056 | |||
2a864fb118 | |||
a0874f0077 | |||
40bd69f6ba | |||
acf6e7ead3 | |||
97381b916d | |||
218a35e24d | |||
622cbdda8c | |||
bdb3e6287d | |||
9e33e21f5b | |||
3a0c6c44af | |||
d823089dfc | |||
cfc755dc0a | |||
8fd1ad6e8f | |||
02f3595ede | |||
22c54fafe6 | |||
cd134222e2 | |||
a2313d7f93 | |||
017333c05d | |||
969d306b64 | |||
d98d95e53a | |||
8cfeafc85a | |||
bd7e96524e | |||
7cb518f9b6 | |||
73e128c082 | |||
02d6e85756 | |||
3f561b0e88 | |||
a110618754 | |||
3faf460b50 | |||
4e326368a2 | |||
b80464a8ca | |||
d26849207a | |||
a2b1f47256 | |||
60cb1943fc | |||
d652a96f9e | |||
dbe8ebf6bc | |||
f762d81105 | |||
f90bc5d658 | |||
8b7aff98cd | |||
7a508c505b | |||
b919491339 | |||
20e14ec7b3 | |||
3be56e5e2c | |||
db5d4d46f6 | |||
e439cd9f58 | |||
7e63649a55 | |||
1367222266 | |||
fd0a04e052 | |||
9d1716b82d | |||
033eed619d | |||
d25b05e802 | |||
afb9a61be2 | |||
e3b8e9b8ca | |||
287e861d06 | |||
41bcb89a38 | |||
4edf1ccb49 | |||
4bb0faa49e | |||
4664fa805d | |||
4c9f0d9f3f | |||
d614b0bf8b | |||
c365d7bce9 | |||
919c55adb1 | |||
2c21f035d4 | |||
d10d9dd982 | |||
21607fe2a7 | |||
49fdecfa25 | |||
5d11ec7998 | |||
47a9595785 | |||
5ca303c2f9 | |||
42bc1d68b9 | |||
fa143d4bf5 | |||
a4d948563e | |||
25bbede003 | |||
4d687770ef | |||
8cf1dd6b37 | |||
ec39704b72 | |||
e99928687c | |||
c7b2b14703 | |||
a4f8b3f12b | |||
a79c139077 | |||
365f5eb7e3 | |||
0b3595f9c3 | |||
899f0e7ce9 | |||
b7100af0f0 | |||
5ca4013639 | |||
83b548c2f2 | |||
5f3d37852a | |||
76b010a1bb | |||
02ee0427b8 | |||
41efadd0a3 | |||
b0392fc4c7 | |||
8a81f51679 | |||
e8f4b23741 | |||
f06a3baff9 | |||
eadd9656b3 | |||
12f7f2f77d | |||
089e69799f | |||
a95b27c181 | |||
3d8c4b8ba2 | |||
dc93f9e962 |
54
.github/workflows/pre-commit.yml
vendored
54
.github/workflows/pre-commit.yml
vendored
@ -1,54 +0,0 @@
|
||||
name: Pre Commit
|
||||
on:
|
||||
- pull_request
|
||||
jobs:
|
||||
Pre-Commit:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.head.ref }}
|
||||
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: "3.10"
|
||||
architecture: "x64"
|
||||
|
||||
- name: Setup pre-commit and actions-toolkit
|
||||
run: "python3 -m pip install pre-commit actions-toolkit"
|
||||
|
||||
- name: Run pre-commit
|
||||
run: python3 -c "import os;os.system('python3 -m pre_commit run --color never -a > result.txt')"
|
||||
|
||||
- name: Commit and push
|
||||
run: |
|
||||
git config user.name github-actions[bot]
|
||||
git config user.email github-actions[bot]@users.noreply.github.com
|
||||
git add .
|
||||
git diff-index --quiet HEAD || git commit -m ":rotating_light: auto fix by pre-commit"
|
||||
git push
|
||||
|
||||
- name: Read result
|
||||
id: rr
|
||||
run: python3 -c "from pathlib import Path;from actions_toolkit.core import set_output;comment=Path('./result.txt').read_text();set_output('comment', comment)"
|
||||
|
||||
- name: Find Comment
|
||||
uses: peter-evans/find-comment@v2
|
||||
id: fc
|
||||
with:
|
||||
issue-number: ${{ github.event.pull_request.number }}
|
||||
comment-author: "github-actions[bot]"
|
||||
body-includes: "pre-commit"
|
||||
|
||||
- name: Create or update comment
|
||||
uses: peter-evans/create-or-update-comment@v2
|
||||
with:
|
||||
comment-id: ${{ steps.fc.outputs.comment-id }}
|
||||
issue-number: ${{ github.event.pull_request.number }}
|
||||
body: |
|
||||
pre-commit output:
|
||||
```
|
||||
${{ steps.rr.outputs.COMMENT }}
|
||||
```
|
||||
edit-mode: replace
|
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
@ -7,6 +7,8 @@
|
||||
"genshin",
|
||||
"genshinuid",
|
||||
"minigg",
|
||||
"nonebot",
|
||||
"nonebug",
|
||||
"weapontype"
|
||||
],
|
||||
"[python]": {
|
||||
|
@ -3,9 +3,6 @@ from nonebot import require, load_all_plugins, get_plugin_by_module_name
|
||||
|
||||
require('nonebot_plugin_apscheduler')
|
||||
|
||||
# from .utils.nonebot2.send import patch_send
|
||||
|
||||
# patch_send()
|
||||
if get_plugin_by_module_name("GenshinUID"):
|
||||
logger.info("推荐直接加载 GenshinUID 仓库文件夹")
|
||||
load_all_plugins(
|
||||
|
@ -1,5 +1,5 @@
|
||||
from nonebot import get_driver
|
||||
|
||||
config = get_driver().config
|
||||
SUPERUSERS = {int(x) for x in config.superusers}
|
||||
SUPERUSERS = {x for x in config.superusers}
|
||||
priority = 2
|
||||
|
@ -3,17 +3,16 @@ from typing import Any, Tuple
|
||||
from nonebot import on_regex
|
||||
from nonebot.log import logger
|
||||
from nonebot.matcher import Matcher
|
||||
from nonebot.params import Depends, RegexGroup
|
||||
from nonebot.adapters.qqguild import MessageEvent, MessageSegment
|
||||
from nonebot.params import RegexGroup
|
||||
from nonebot.adapters.ntchat import MessageSegment, TextMessageEvent
|
||||
|
||||
from ..genshinuid_meta import register_menu
|
||||
from .draw_abyss_card import draw_abyss_img
|
||||
from ..utils.message.error_reply import UID_HINT
|
||||
from ..utils.message.cast_type import cast_to_int
|
||||
from ..utils.db_operation.db_operation import select_db
|
||||
from ..utils.message.get_image_and_at import ImageAndAt
|
||||
from ..utils.mhy_api.convert_mysid_to_uid import convert_mysid
|
||||
from ..utils.exception.handle_exception import handle_exception
|
||||
from ..utils.draw_image_tools.send_image_tool import convert_img
|
||||
|
||||
get_abyss_info = on_regex(
|
||||
r'^(\[CQ:at,qq=[0-9]+\])?( )?'
|
||||
@ -22,6 +21,7 @@ get_abyss_info = on_regex(
|
||||
r'(\[CQ:at,qq=[0-9]+\])?( )?$',
|
||||
block=True,
|
||||
)
|
||||
# 恢复了查询二字,和其他的查询打架下次解决
|
||||
|
||||
|
||||
@get_abyss_info.handle()
|
||||
@ -31,38 +31,45 @@ get_abyss_info = on_regex(
|
||||
'查询(@某人)(上期)深渊(xx层)',
|
||||
'查询你的或者指定人的深渊战绩',
|
||||
detail_des=(
|
||||
'指令:'
|
||||
'<ft color=(238,120,0)>[查询</ft>'
|
||||
'介绍:\n'
|
||||
'可以用来查看你的或者指定人的深渊战绩,可以指定层数,默认为最高层数\n'
|
||||
'可以在命令文本后带一张图以自定义背景图\n'
|
||||
' \n' # 如果想要空行,请在换行符前面打个空格,不然会忽略换行符
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>{查询</ft>'
|
||||
'<ft color=(125,125,125)>(@某人)</ft>'
|
||||
'<ft color=(238,120,0)>/uidxxx/mysxxx]</ft>'
|
||||
'<ft color=(238,120,0)>|uid</ft><ft color=(0,148,200)>xx</ft>'
|
||||
'<ft color=(238,120,0)>|mys</ft><ft color=(0,148,200)>xx</ft>'
|
||||
'<ft color=(238,120,0)>}</ft>'
|
||||
'<ft color=(125,125,125)>(上期)</ft>'
|
||||
'<ft color=(238,120,0)>深渊</ft>'
|
||||
'<ft color=(125,125,125)>(xx层)</ft>\n'
|
||||
' \n' # 如果想要空行,请在换行符前面打个空格,不然会忽略换行符
|
||||
'可以用来查看你的或者指定人的深渊战绩,可以指定层数,默认为最高层数\n'
|
||||
'可以在命令文本后带一张图以自定义背景图\n'
|
||||
' \n'
|
||||
'示例:\n'
|
||||
'<ft color=(238,120,0)>查询深渊</ft>;\n'
|
||||
'<ft color=(238,120,0)>uid123456789上期深渊</ft>;\n'
|
||||
'<ft color=(238,120,0)>查询</ft><ft color=(0,148,200)>@无疑Wuyi</ft> '
|
||||
'- <ft color=(238,120,0)>查询深渊</ft>\n'
|
||||
'- <ft color=(238,120,0)>uid123456789上期深渊</ft>\n'
|
||||
'- <ft color=(238,120,0)>查询</ft><ft color=(0,123,67)>@无疑Wuyi</ft> '
|
||||
'<ft color=(238,120,0)>上期深渊12层</ft>'
|
||||
),
|
||||
)
|
||||
async def send_abyss_info(
|
||||
event: MessageEvent,
|
||||
event: TextMessageEvent,
|
||||
matcher: Matcher,
|
||||
args: Tuple[Any, ...] = RegexGroup(),
|
||||
custom: ImageAndAt = Depends(),
|
||||
):
|
||||
logger.info('开始执行[查询深渊信息]')
|
||||
logger.info(f'[查询深渊信息]参数: {args}')
|
||||
at = custom.get_first_at()
|
||||
qid = at or cast_to_int(event.author)
|
||||
qid = event.from_wxid
|
||||
if event.at_user_list:
|
||||
for user in event.at_user_list:
|
||||
user = user.strip()
|
||||
if user != "":
|
||||
qid = user
|
||||
|
||||
if args[2] == 'mys':
|
||||
uid = await convert_mysid(args[3])
|
||||
elif args[3] is None:
|
||||
uid = await select_db(str(qid), mode='uid')
|
||||
uid = await select_db(qid, mode='uid')
|
||||
uid = str(uid)
|
||||
elif len(args[3]) != 9:
|
||||
return
|
||||
@ -91,6 +98,7 @@ async def send_abyss_info(
|
||||
if isinstance(im, str):
|
||||
await matcher.finish(im)
|
||||
elif isinstance(im, bytes):
|
||||
await matcher.finish(MessageSegment.file_image(im))
|
||||
im = await convert_img(im)
|
||||
await matcher.finish(MessageSegment.image(im))
|
||||
else:
|
||||
await matcher.finish('发生了未知错误,请联系管理员检查后台输出!')
|
||||
|
@ -2,7 +2,7 @@ from nonebot import on_command
|
||||
from nonebot.log import logger
|
||||
from nonebot.matcher import Matcher
|
||||
from nonebot.params import CommandArg
|
||||
from nonebot.adapters.qqguild import Message
|
||||
from nonebot.adapters.ntchat import Message
|
||||
|
||||
from ..config import priority
|
||||
from .get_achi_desc import get_achi, get_daily_achi
|
||||
|
@ -23,15 +23,17 @@ get_weapon_adv = on_regex(
|
||||
'xx用什么',
|
||||
'查询角色武器/圣遗物推荐配置',
|
||||
detail_des=(
|
||||
'指令:'
|
||||
'<ft color=(238,120,0)>[角色名][用什么/能用啥/怎么养]</ft>\n'
|
||||
' \n'
|
||||
'介绍:\n'
|
||||
'可以查询某角色的武器/圣遗物推荐配置\n'
|
||||
'支持部分角色别名\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(0,148,200)>[角色名]</ft>'
|
||||
'<ft color=(238,120,0)>{用什么|能用啥|怎么养}</ft>\n'
|
||||
' \n'
|
||||
'示例:\n'
|
||||
'<ft color=(238,120,0)>钟离用什么</ft>;\n'
|
||||
'<ft color=(238,120,0)>公子怎么养</ft>'
|
||||
'- <ft color=(238,120,0)>钟离用什么</ft>\n'
|
||||
'- <ft color=(238,120,0)>公子怎么养</ft>'
|
||||
),
|
||||
)
|
||||
async def send_char_adv(
|
||||
@ -49,15 +51,17 @@ async def send_char_adv(
|
||||
'xx能给谁',
|
||||
'查询某武器/圣遗物能给谁用',
|
||||
detail_des=(
|
||||
'指令:'
|
||||
'<ft color=(238,120,0)>[角色名][能给谁/给谁用/要给谁/谁能用]</ft>\n'
|
||||
' \n'
|
||||
'介绍:\n'
|
||||
'可以通过武器/圣遗物名反查适用的角色\n'
|
||||
'支持部分别名\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(0,148,200)>[武器名]</ft>'
|
||||
'<ft color=(238,120,0)>{能给谁|给谁用|要给谁|谁能用}</ft>\n'
|
||||
' \n'
|
||||
'示例:\n'
|
||||
'<ft color=(238,120,0)>四风原典能给谁</ft>;\n'
|
||||
'<ft color=(238,120,0)>千岩给谁用</ft>'
|
||||
'- <ft color=(238,120,0)>四风原典能给谁</ft>\n'
|
||||
'- <ft color=(238,120,0)>千岩给谁用</ft>'
|
||||
),
|
||||
)
|
||||
async def send_weapon_adv(
|
||||
|
@ -1,3 +1,4 @@
|
||||
import base64
|
||||
import random
|
||||
import asyncio
|
||||
|
||||
@ -7,14 +8,18 @@ from nonebot.params import CommandArg
|
||||
from nonebot import get_bot, on_command
|
||||
from nonebot.permission import SUPERUSER
|
||||
from nonebot_plugin_apscheduler import scheduler
|
||||
from nonebot.adapters.qqguild import Message, MessageEvent, MessageSegment
|
||||
from nonebot.adapters.ntchat.message import Message
|
||||
from nonebot.adapters.ntchat import (
|
||||
MessageEvent,
|
||||
MessageSegment,
|
||||
TextMessageEvent,
|
||||
)
|
||||
|
||||
from .util import black_ids
|
||||
from ..config import priority
|
||||
from .main import ann, consume_remind
|
||||
from ..utils.nonebot2.rule import FullCommand
|
||||
from ..utils.message.error_reply import UID_HINT
|
||||
from ..utils.message.cast_type import cast_to_int
|
||||
from ..utils.db_operation.db_operation import select_db
|
||||
from ..genshinuid_config.default_config import string_config
|
||||
from ..utils.exception.handle_exception import handle_exception
|
||||
@ -45,31 +50,31 @@ async def send_ann_pic(
|
||||
|
||||
if not ann_id:
|
||||
img = await ann_list_card()
|
||||
await matcher.finish(MessageSegment.file_image(img))
|
||||
await matcher.finish(MessageSegment.image(img))
|
||||
|
||||
if not ann_id.isdigit():
|
||||
raise Exception("公告ID不正确")
|
||||
|
||||
img = await ann_detail_card(int(ann_id))
|
||||
await matcher.finish(MessageSegment.file_image(img))
|
||||
await matcher.finish(MessageSegment.image(img))
|
||||
|
||||
|
||||
@reg_ann.handle()
|
||||
@handle_exception('设置原神公告', '设置原神公告失败')
|
||||
async def send_reg_ann(
|
||||
event: MessageEvent,
|
||||
event: TextMessageEvent,
|
||||
matcher: Matcher,
|
||||
):
|
||||
await matcher.finish(sub_ann(event.channel_id))
|
||||
await matcher.finish(sub_ann(event.room_wxid))
|
||||
|
||||
|
||||
@unreg_ann.handle()
|
||||
@handle_exception('取消原神公告', '取消设置原神公告失败')
|
||||
async def send_unreg_ann(
|
||||
event: MessageEvent,
|
||||
event: TextMessageEvent,
|
||||
matcher: Matcher,
|
||||
):
|
||||
await matcher.finish(unsub_ann(event.channel_id))
|
||||
await matcher.finish(unsub_ann(event.room_wxid))
|
||||
|
||||
|
||||
@consume_ann.handle()
|
||||
@ -78,7 +83,7 @@ async def send_consume_ann(
|
||||
event: MessageEvent,
|
||||
matcher: Matcher,
|
||||
):
|
||||
qid = str(cast_to_int(event.author))
|
||||
qid = event.from_wxid
|
||||
uid = await select_db(qid, mode='uid')
|
||||
uid = str(uid)
|
||||
if '未找到绑定的UID' in uid:
|
||||
@ -95,11 +100,9 @@ async def check_ann_state():
|
||||
logger.info('[原神公告] 定时任务: 原神公告查询..')
|
||||
ids = string_config.get_config('Ann_Ids')
|
||||
sub_list = string_config.get_config('Ann_Groups')
|
||||
|
||||
if not sub_list:
|
||||
logger.info('没有群订阅, 取消获取数据')
|
||||
return
|
||||
|
||||
if not ids:
|
||||
ids = await ann().get_ann_ids()
|
||||
if not ids:
|
||||
@ -107,10 +110,9 @@ async def check_ann_state():
|
||||
string_config.set_config('Ann_Ids', ids)
|
||||
logger.info('初始成功, 将在下个轮询中更新.')
|
||||
return
|
||||
|
||||
new_ids = await ann().get_ann_ids()
|
||||
new_ann = set(ids) ^ set(new_ids)
|
||||
|
||||
new_ann = set(ids) ^ set(new_ids)
|
||||
if not new_ann:
|
||||
logger.info('[原神公告] 没有最新公告')
|
||||
return
|
||||
@ -121,18 +123,20 @@ async def check_ann_state():
|
||||
try:
|
||||
img = await ann_detail_card(ann_id) # 防止抛出异常报错
|
||||
bot = get_bot()
|
||||
b64img = base64.b64encode(img)
|
||||
|
||||
for group in sub_list:
|
||||
try:
|
||||
await bot.call_api(
|
||||
api='_post_messages',
|
||||
channel_id=group,
|
||||
content=img,
|
||||
api='send_image',
|
||||
to_wxid=str(group),
|
||||
file_path="base64://" + b64img.decode(),
|
||||
)
|
||||
await asyncio.sleep(random.uniform(1, 3))
|
||||
except Exception as e:
|
||||
logger.exception(e)
|
||||
except Exception as e:
|
||||
logger.exception(str(e))
|
||||
logger.exception(e)
|
||||
|
||||
logger.info('[原神公告] 推送完毕, 更新数据库')
|
||||
string_config.set_config('Ann_Ids', new_ids)
|
||||
|
@ -2,10 +2,11 @@ import random
|
||||
import asyncio
|
||||
|
||||
from nonebot import on_command
|
||||
from nonebot.log import logger
|
||||
from nonebot.matcher import Matcher
|
||||
from nonebot.permission import SUPERUSER
|
||||
from nonebot_plugin_apscheduler import scheduler
|
||||
from nonebot.adapters.qqguild import Bot, MessageEvent
|
||||
from nonebot.adapters.ntchat import Bot, TextMessageEvent
|
||||
|
||||
from ..config import priority
|
||||
from .backup_data import data_backup
|
||||
@ -13,12 +14,23 @@ from ..genshinuid_meta import register_menu
|
||||
from ..utils.nonebot2.rule import FullCommand
|
||||
from ..utils.exception.handle_exception import handle_exception
|
||||
from ..utils.db_operation.db_cache_and_check import check_db, check_stoken_db
|
||||
from ..utils.db_operation.db_operation import delete_cookies, get_all_push_list
|
||||
from ..utils.message.get_cqhttp_data import (
|
||||
get_all_friend_list,
|
||||
get_group_member_list,
|
||||
)
|
||||
|
||||
backup = on_command('gs清除缓存', rule=FullCommand(), priority=priority)
|
||||
check = on_command('校验全部Cookies', rule=FullCommand(), priority=priority)
|
||||
check_stoken = on_command('校验全部Stoken', rule=FullCommand(), priority=priority)
|
||||
backup = on_command(
|
||||
'gs清除缓存', rule=FullCommand(), priority=priority, permission=SUPERUSER
|
||||
)
|
||||
check = on_command(
|
||||
'校验全部Cookies', rule=FullCommand(), priority=priority, permission=SUPERUSER
|
||||
)
|
||||
check_stoken = on_command(
|
||||
'校验全部Stoken', rule=FullCommand(), priority=priority, permission=SUPERUSER
|
||||
)
|
||||
remove_invalid_user = on_command(
|
||||
'清除无效用户', rule=FullCommand(), priority=priority
|
||||
'清除无效用户', rule=FullCommand(), priority=priority, permission=SUPERUSER
|
||||
)
|
||||
|
||||
backup_scheduler = scheduler
|
||||
@ -31,9 +43,22 @@ async def daily_refresh_charData():
|
||||
|
||||
@backup.handle()
|
||||
@handle_exception('清除缓存', '清除缓存错误')
|
||||
@register_menu(
|
||||
'清除缓存',
|
||||
'清除缓存',
|
||||
'清除插件产生的缓存数据',
|
||||
trigger_method='超级用户指令',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'备份一份插件数据库后清除插件产生的文件与数据库缓存\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>清除缓存</ft>'
|
||||
),
|
||||
)
|
||||
async def send_backup_msg(
|
||||
bot: Bot,
|
||||
event: MessageEvent,
|
||||
event: TextMessageEvent,
|
||||
matcher: Matcher,
|
||||
):
|
||||
if not await SUPERUSER(bot, event):
|
||||
@ -42,6 +67,52 @@ async def send_backup_msg(
|
||||
await matcher.finish('操作成功完成!')
|
||||
|
||||
|
||||
@remove_invalid_user.handle()
|
||||
@handle_exception('清除无效用户', '清除无效用户错误')
|
||||
@register_menu(
|
||||
'清除无效用户',
|
||||
'清除无效用户',
|
||||
'清除非好友或非推送群成员的数据',
|
||||
trigger_method='超级用户指令',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'从数据库中删除掉 开启了私聊推送但不是Bot好友的用户 '
|
||||
'以及 开启了群聊推送但不在推送目标群的用户 的数据\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>清除无效用户</ft>'
|
||||
),
|
||||
)
|
||||
async def send_remove_invalid_user_msg(
|
||||
bot: Bot,
|
||||
event: TextMessageEvent,
|
||||
matcher: Matcher,
|
||||
):
|
||||
if not await SUPERUSER(bot, event):
|
||||
return
|
||||
im_list = []
|
||||
invalid_user = {}
|
||||
invalid_uid_list = []
|
||||
user_list = await get_all_push_list()
|
||||
friend_list = await get_all_friend_list(bot)
|
||||
for user in user_list:
|
||||
if user['StatusA'] == 'on':
|
||||
if user['QID'] not in friend_list:
|
||||
invalid_user['qid'] = user['UID']
|
||||
invalid_uid_list.append(user['UID'])
|
||||
else:
|
||||
group_member_list = await get_group_member_list(
|
||||
bot, int(user['StatusA'])
|
||||
)
|
||||
if user['QID'] not in group_member_list:
|
||||
invalid_user['qid'] = user['UID']
|
||||
invalid_uid_list.append(user['UID'])
|
||||
for uid in invalid_uid_list:
|
||||
im_list.append(await delete_cookies(str(uid)))
|
||||
logger.warning(f'无效UID已被删除: {uid}')
|
||||
await matcher.finish(f'已清理失效用户{len(im_list)}个!')
|
||||
|
||||
|
||||
# 群聊内 校验Cookies 是否正常的功能,不正常自动删掉
|
||||
@check.handle()
|
||||
@handle_exception('Cookie校验', 'Cookie校验错误')
|
||||
@ -49,14 +120,14 @@ async def send_backup_msg(
|
||||
'校验全部Cookies',
|
||||
'校验全部Cookies',
|
||||
'校验数据库内所有Cookies是否正常',
|
||||
trigger_method='管理员指令',
|
||||
detail_des=(
|
||||
'指令:'
|
||||
'<ft color=(238,120,0)>校验全部Cookies</ft>\n'
|
||||
'注意<ft color=(238,120,0)>Cookies</ft>的'
|
||||
'<ft color=(238,120,0)>C</ft>为大写\n'
|
||||
'介绍:\n'
|
||||
'校验数据库内所有Cookies是否正常,不正常的会自动删除\n'
|
||||
' \n'
|
||||
'校验数据库内所有Cookies是否正常,不正常的会自动删除'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>校验全部Cookies</ft>\n'
|
||||
'注意<ft color=(238,120,0)>Cookies</ft>的'
|
||||
'<ft color=(238,120,0)>C</ft>为大写'
|
||||
),
|
||||
)
|
||||
async def send_check_cookie(bot: Bot, matcher: Matcher):
|
||||
@ -86,13 +157,13 @@ async def send_check_cookie(bot: Bot, matcher: Matcher):
|
||||
'校验全部Stoken',
|
||||
'校验全部Stoken',
|
||||
'校验数据库内所有Stoken是否正常',
|
||||
trigger_method='管理员指令',
|
||||
detail_des=(
|
||||
'指令:'
|
||||
'<ft color=(238,120,0)>校验全部Stoken</ft>\n'
|
||||
'注意<ft color=(238,120,0)>Stoken</ft>的<ft color=(238,120,0)>S</ft>为大写\n'
|
||||
'介绍:\n'
|
||||
'校验数据库内所有Stoken是否正常,不正常的会自动删除\n'
|
||||
' \n'
|
||||
'校验数据库内所有Stoken是否正常,不正常的会自动删除'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>校验全部Stoken</ft>\n'
|
||||
'注意<ft color=(238,120,0)>Stoken</ft>的<ft color=(238,120,0)>S</ft>为大写'
|
||||
),
|
||||
)
|
||||
async def send_check_stoken(bot: Bot, matcher: Matcher):
|
||||
|
@ -1,14 +1,13 @@
|
||||
from nonebot import on_command
|
||||
from nonebot.log import logger
|
||||
from nonebot.matcher import Matcher
|
||||
from nonebot.params import Depends, CommandArg
|
||||
from nonebot.adapters.qqguild import Message, MessageEvent, MessageSegment
|
||||
from nonebot.params import CommandArg
|
||||
from nonebot.adapters.ntchat.message import Message
|
||||
from nonebot.adapters.ntchat import MessageSegment, TextMessageEvent
|
||||
|
||||
from ..genshinuid_meta import register_menu
|
||||
from ..utils.data_convert.get_uid import get_uid
|
||||
from ..utils.message.error_reply import UID_HINT
|
||||
from ..utils.message.cast_type import cast_to_int
|
||||
from ..utils.message.get_image_and_at import ImageAndAt
|
||||
from ..utils.exception.handle_exception import handle_exception
|
||||
from .draw_collection_card import draw_explora_img, draw_collection_img
|
||||
|
||||
@ -23,34 +22,37 @@ get_explora_info = on_command('查询探索', aliases={'探索', 'ts'}, block=Tr
|
||||
'查询(@某人)收集',
|
||||
'查询你的或者指定人的宝箱收集度',
|
||||
detail_des=(
|
||||
'指令:'
|
||||
'<ft color=(238,120,0)>[查询</ft>'
|
||||
'<ft color=(125,125,125)>(@某人)</ft>'
|
||||
'<ft color=(238,120,0)>/uidxxx/mysxxx]</ft>'
|
||||
'<ft color=(238,120,0)>[收集/宝箱/sj/bx]</ft>\n'
|
||||
' \n'
|
||||
'介绍:\n'
|
||||
'可以用来查看你的或者指定人的宝箱收集度\n'
|
||||
'可以在命令文本后带一张图以自定义背景图\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>{查询</ft>'
|
||||
'<ft color=(125,125,125)>(@某人)</ft>'
|
||||
'<ft color=(238,120,0)>|uid</ft><ft color=(0,148,200)>xx</ft>'
|
||||
'<ft color=(238,120,0)>|mys</ft><ft color=(0,148,200)>xx</ft>'
|
||||
'<ft color=(238,120,0)>}</ft>'
|
||||
'<ft color=(238,120,0)>{收集|宝箱|sj|bx}</ft>\n'
|
||||
' \n'
|
||||
'示例:\n'
|
||||
'<ft color=(238,120,0)>查询收集</ft>;\n'
|
||||
'<ft color=(238,120,0)>uid123456789宝箱</ft>;\n'
|
||||
'<ft color=(238,120,0)>查询</ft><ft color=(0,148,200)>@无疑Wuyi'
|
||||
'- <ft color=(238,120,0)>查询收集</ft>\n'
|
||||
'- <ft color=(238,120,0)>uid123456789宝箱</ft>\n'
|
||||
'- <ft color=(238,120,0)>查询</ft><ft color=(0,123,67)>@无疑Wuyi'
|
||||
'</ft> <ft color=(238,120,0)>bx</ft>'
|
||||
),
|
||||
)
|
||||
async def send_collection_info(
|
||||
event: MessageEvent,
|
||||
event: TextMessageEvent,
|
||||
matcher: Matcher,
|
||||
args: Message = CommandArg(),
|
||||
custom: ImageAndAt = Depends(),
|
||||
):
|
||||
logger.info('开始执行[查询收集信息]')
|
||||
logger.info('[查询收集信息]参数: {}'.format(args))
|
||||
raw_mes = args.extract_plain_text().strip()
|
||||
at = custom.get_first_at()
|
||||
qid = at or cast_to_int(event.author)
|
||||
qid = str(qid)
|
||||
if event.at_user_list:
|
||||
qid = event.at_user_list[0]
|
||||
else:
|
||||
qid = event.from_wxid
|
||||
|
||||
uid = await get_uid(qid, raw_mes)
|
||||
logger.info('[查询收集信息]uid: {}'.format(uid))
|
||||
@ -62,7 +64,7 @@ async def send_collection_info(
|
||||
if isinstance(im, str):
|
||||
await matcher.finish(im)
|
||||
elif isinstance(im, bytes):
|
||||
await matcher.finish(MessageSegment.file_image(im))
|
||||
await matcher.finish(MessageSegment.image(im))
|
||||
else:
|
||||
await matcher.finish('发生了未知错误,请联系管理员检查后台输出!')
|
||||
|
||||
@ -70,17 +72,17 @@ async def send_collection_info(
|
||||
@get_explora_info.handle()
|
||||
@handle_exception('查询探索信息')
|
||||
async def send_explora_info(
|
||||
event: MessageEvent,
|
||||
event: TextMessageEvent,
|
||||
matcher: Matcher,
|
||||
args: Message = CommandArg(),
|
||||
custom: ImageAndAt = Depends(),
|
||||
):
|
||||
logger.info('开始执行[查询探索信息]')
|
||||
logger.info('[查询探索信息]参数: {}'.format(args))
|
||||
raw_mes = args.extract_plain_text().strip()
|
||||
at = custom.get_first_at()
|
||||
qid = at or cast_to_int(event.author)
|
||||
qid = str(qid)
|
||||
if event.at_user_list:
|
||||
qid = event.at_user_list[0]
|
||||
else:
|
||||
qid = event.from_wxid
|
||||
|
||||
uid = await get_uid(qid, raw_mes)
|
||||
logger.info('[查询探索信息]uid: {}'.format(uid))
|
||||
@ -92,6 +94,6 @@ async def send_explora_info(
|
||||
if isinstance(im, str):
|
||||
await matcher.finish(im)
|
||||
elif isinstance(im, bytes):
|
||||
await matcher.finish(MessageSegment.file_image(im))
|
||||
await matcher.finish(MessageSegment.image(im))
|
||||
else:
|
||||
await matcher.finish('发生了未知错误,请联系管理员检查后台输出!')
|
||||
|
@ -2,16 +2,16 @@ from typing import Any, Tuple
|
||||
|
||||
from nonebot.log import logger
|
||||
from nonebot.matcher import Matcher
|
||||
from nonebot.params import RegexGroup
|
||||
from nonebot import on_regex, on_command
|
||||
from nonebot.permission import SUPERUSER
|
||||
from nonebot.params import Depends, CommandArg, RegexGroup
|
||||
from nonebot.adapters.qqguild import Bot, Message, MessageEvent, MessageSegment
|
||||
from nonebot.adapters.ntchat import Bot, MessageSegment, TextMessageEvent
|
||||
|
||||
from ..genshinuid_meta import register_menu
|
||||
from ..utils.nonebot2.rule import FullCommand
|
||||
from .draw_config_card import draw_config_img
|
||||
from ..utils.message.error_reply import UID_HINT
|
||||
from ..utils.message.cast_type import cast_to_int
|
||||
from ..utils.db_operation.db_operation import select_db
|
||||
from ..utils.message.get_image_and_at import ImageAndAt
|
||||
from .set_config import set_push_value, set_config_func
|
||||
from ..utils.exception.handle_exception import handle_exception
|
||||
|
||||
@ -27,105 +27,185 @@ push_config = on_regex(
|
||||
r'(\[CQ:at,qq=[0-9]+\])?( )?$'
|
||||
)
|
||||
|
||||
config_card = on_command('gs配置')
|
||||
config_card = on_command('gs配置', rule=FullCommand())
|
||||
|
||||
|
||||
@config_card.handle()
|
||||
@handle_exception('发送配置表')
|
||||
async def send_config_card(matcher: Matcher, args: Message = CommandArg()):
|
||||
if args:
|
||||
await matcher.finish()
|
||||
@register_menu(
|
||||
'发送配置表',
|
||||
'gs配置',
|
||||
'查看插件当前配置项开关情况',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'查看插件当前配置项开关情况\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>gs配置</ft>'
|
||||
),
|
||||
)
|
||||
async def send_config_card(matcher: Matcher):
|
||||
logger.info('开始执行[gs配置]')
|
||||
im = await draw_config_img()
|
||||
if isinstance(im, str):
|
||||
await matcher.finish(im)
|
||||
elif isinstance(im, bytes):
|
||||
await matcher.finish(MessageSegment.file_image(im))
|
||||
await matcher.finish(MessageSegment.image(im))
|
||||
else:
|
||||
await matcher.finish('发生了未知错误,请联系管理员检查后台输出!')
|
||||
|
||||
|
||||
@push_config.handle()
|
||||
@handle_exception('设置推送服务')
|
||||
@register_menu(
|
||||
'设置推送阈值',
|
||||
'gs设置xx(@某人)',
|
||||
'设置自己或指定人的推送服务阈值',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'设置某人的推送服务阈值\n'
|
||||
'超级用户可以设置他人的推送服务阈值\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>gs设置</ft>'
|
||||
'<ft color=(0,148,200)>[服务名称][阈值]</ft>'
|
||||
'<ft color=(125,125,125)>(@某人)</ft>\n'
|
||||
' \n'
|
||||
'示例:\n'
|
||||
'- <ft color=(238,120,0)>gs设置推送140</ft>'
|
||||
),
|
||||
)
|
||||
async def send_config_msg(
|
||||
bot: Bot,
|
||||
event: MessageEvent,
|
||||
event: TextMessageEvent,
|
||||
matcher: Matcher,
|
||||
args: Tuple[Any, ...] = RegexGroup(),
|
||||
custom: ImageAndAt = Depends(),
|
||||
):
|
||||
logger.info('开始执行[设置阈值信息]')
|
||||
logger.info('[设置阈值信息]参数: {}'.format(args))
|
||||
qid = cast_to_int(event.author)
|
||||
at = custom.get_first_at()
|
||||
wxid_list = []
|
||||
wxid_list.append(event.from_wxid)
|
||||
qid = event.from_wxid
|
||||
if event.at_user_list:
|
||||
for user in event.at_user_list:
|
||||
user = user.strip()
|
||||
if user != "" and await SUPERUSER(bot, event):
|
||||
qid = user
|
||||
else:
|
||||
await matcher.finish(
|
||||
MessageSegment.room_at_msg(
|
||||
content="{$@}你没有权限操作别人的状态噢~", at_list=wxid_list
|
||||
)
|
||||
)
|
||||
|
||||
if at and await SUPERUSER(bot, event):
|
||||
qid = at
|
||||
elif at and at != qid:
|
||||
await matcher.finish('你没有权限操作别人的状态噢~', at_sender=True)
|
||||
logger.info('[设置阈值信息]qid: {}'.format(qid))
|
||||
|
||||
try:
|
||||
uid = await select_db(str(qid), mode='uid')
|
||||
uid = await select_db(qid, mode='uid')
|
||||
except TypeError:
|
||||
await matcher.finish(UID_HINT)
|
||||
await matcher.finish(
|
||||
MessageSegment.room_at_msg(
|
||||
content='{$@}' + UID_HINT, at_list=wxid_list
|
||||
)
|
||||
)
|
||||
|
||||
func = args[4].replace('阈值', '')
|
||||
if args[5]:
|
||||
try:
|
||||
value = int(args[5])
|
||||
except ValueError:
|
||||
await matcher.finish('请输入数字哦~', at_sender=True)
|
||||
await matcher.finish(
|
||||
MessageSegment.room_at_msg(
|
||||
content="{$@}请输入数字哦~", at_list=wxid_list
|
||||
)
|
||||
)
|
||||
else:
|
||||
await matcher.finish('请输入正确的阈值数字!', at_sender=True)
|
||||
await matcher.finish(
|
||||
MessageSegment.room_at_msg(
|
||||
content="{$@}请输入正确的阈值数字!", at_list=wxid_list
|
||||
)
|
||||
)
|
||||
logger.info('[设置阈值信息]func: {}, value: {}'.format(func, value))
|
||||
im = await set_push_value(func, str(uid), value)
|
||||
await matcher.finish(im, at_sender=True)
|
||||
await matcher.finish(
|
||||
MessageSegment.room_at_msg(content="{$@}" + f"{im}", at_list=wxid_list)
|
||||
)
|
||||
|
||||
|
||||
# 开启 自动签到 和 推送树脂提醒 功能
|
||||
@open_and_close_switch.handle()
|
||||
@register_menu(
|
||||
'开关推送服务',
|
||||
'gs{开启|关闭}xx(@某人)',
|
||||
'开关自己或指定人的推送服务状态',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'设置某人的推送服务开关状态\n'
|
||||
'超级用户可以设置他人的推送服务状态\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>gs{开启|关闭}</ft>'
|
||||
'<ft color=(0,148,200)>[服务名称]</ft>'
|
||||
'<ft color=(125,125,125)>(@某人)</ft>\n'
|
||||
' \n'
|
||||
'示例:\n'
|
||||
'- <ft color=(238,120,0)>gs开启推送</ft>'
|
||||
),
|
||||
)
|
||||
async def open_switch_func(
|
||||
bot: Bot,
|
||||
event: MessageEvent,
|
||||
event: TextMessageEvent,
|
||||
matcher: Matcher,
|
||||
args: Tuple[Any, ...] = RegexGroup(),
|
||||
at: ImageAndAt = Depends(),
|
||||
):
|
||||
qid = cast_to_int(event.author)
|
||||
if at:
|
||||
at = at.get_first_at() # type: ignore
|
||||
wxid_list = []
|
||||
wxid_list.append(event.from_wxid)
|
||||
qid = event.from_wxid
|
||||
if event.at_user_list:
|
||||
for user in event.at_user_list:
|
||||
user = user.strip()
|
||||
if user != "" and await SUPERUSER(bot, event):
|
||||
qid = user
|
||||
else:
|
||||
await matcher.finish(
|
||||
MessageSegment.room_at_msg(
|
||||
content="{$@}你没有权限操作别人的状态噢~", at_list=wxid_list
|
||||
)
|
||||
)
|
||||
|
||||
config_name = args[4]
|
||||
|
||||
logger.info(f'[{qid}]尝试[{args[3]}]了[{config_name}]功能')
|
||||
|
||||
fake_seession = f'group_{event.room_wxid}_{event.from_wxid}'
|
||||
|
||||
if args[3] == '开启':
|
||||
query = 'OPEN'
|
||||
gid = (
|
||||
event.get_session_id().split('_')[1]
|
||||
if len(event.get_session_id().split('_')) == 3
|
||||
fake_seession.split('_')[1]
|
||||
if len(fake_seession.split('_')) == 3
|
||||
else 'on'
|
||||
)
|
||||
else:
|
||||
query = 'CLOSED'
|
||||
gid = 'off'
|
||||
is_admin = await SUPERUSER(bot, event)
|
||||
if at and is_admin:
|
||||
qid = at
|
||||
elif at and at != qid:
|
||||
await matcher.finish('你没有权限操作别人的状态噢~', at_sender=True)
|
||||
|
||||
try:
|
||||
uid = await select_db(str(qid), mode='uid')
|
||||
except TypeError:
|
||||
await matcher.finish(UID_HINT)
|
||||
uid = await select_db(qid, mode='uid')
|
||||
if uid is None or not isinstance(uid, str) or not uid.isdecimal():
|
||||
await matcher.finish(
|
||||
MessageSegment.room_at_msg(
|
||||
content='{$@}' + UID_HINT, at_list=wxid_list
|
||||
)
|
||||
)
|
||||
|
||||
im = await set_config_func(
|
||||
config_name=config_name,
|
||||
uid=uid, # type: ignore
|
||||
qid=qid, # type: ignore
|
||||
uid=uid,
|
||||
qid=str(qid),
|
||||
option=gid,
|
||||
query=query,
|
||||
is_admin=is_admin,
|
||||
is_admin=await SUPERUSER(bot, event),
|
||||
)
|
||||
await matcher.finish(
|
||||
MessageSegment.room_at_msg(content="{$@}" + f"{im}", at_list=wxid_list)
|
||||
)
|
||||
await matcher.finish(im, at_sender=True)
|
||||
|
@ -5,7 +5,7 @@ from ..utils.download_resource.RESOURCE_PATH import MAIN_PATH
|
||||
from ..utils.db_operation.db_operation import get_all_bind, get_user_bind_data
|
||||
|
||||
DATA_PATH = MAIN_PATH / 'v3_data.json'
|
||||
BOT_ID = 'qqguild'
|
||||
BOT_ID = 'ntchat'
|
||||
RECOGNIZE_SERVER = {
|
||||
'1': 'cn_gf01',
|
||||
'2': 'cn_gf01',
|
||||
|
@ -6,28 +6,34 @@ from typing import Tuple
|
||||
from nonebot import on_command
|
||||
from nonebot.log import logger
|
||||
from nonebot.matcher import Matcher
|
||||
from nonebot.params import CommandArg
|
||||
from nonebot.permission import SUPERUSER
|
||||
from nonebot.params import Depends, CommandArg
|
||||
from nonebot_plugin_apscheduler import scheduler
|
||||
from nonebot.adapters.qqguild import Bot, Message, MessageEvent, MessageSegment
|
||||
from nonebot.adapters.ntchat.message import Message
|
||||
from nonebot.adapters.ntchat import (
|
||||
Bot,
|
||||
MessageEvent,
|
||||
MessageSegment,
|
||||
TextMessageEvent,
|
||||
QuoteMessageEvent,
|
||||
)
|
||||
|
||||
from ..config import priority
|
||||
from .get_enka_img import draw_enka_img
|
||||
from ..genshinuid_meta import register_menu
|
||||
from ..utils.nonebot2.rule import FullCommand
|
||||
from .draw_char_rank import draw_cahrcard_list
|
||||
from ..utils.message.error_reply import UID_HINT
|
||||
from ..utils.message.cast_type import cast_to_int
|
||||
from ..utils.enka_api.get_enka_data import switch_api
|
||||
from ..utils.enka_api.enka_to_card import enka_to_card
|
||||
from ..utils.enka_api.enka_to_data import enka_to_data
|
||||
from ..utils.message.get_image_and_at import ImageAndAt
|
||||
from ..utils.download_resource.RESOURCE_PATH import TEMP_PATH
|
||||
from ..utils.exception.handle_exception import handle_exception
|
||||
from ..utils.db_operation.db_operation import select_db, get_all_uid
|
||||
|
||||
refresh = on_command('强制刷新')
|
||||
original_pic = on_command('原图')
|
||||
change_api = on_command('切换api')
|
||||
original_pic = on_command('原图', rule=FullCommand())
|
||||
change_api = on_command('切换api', rule=FullCommand())
|
||||
get_charcard_list = on_command('毕业度统计')
|
||||
get_char_info = on_command(
|
||||
'查询',
|
||||
@ -40,13 +46,24 @@ refresh_scheduler = scheduler
|
||||
|
||||
@change_api.handle()
|
||||
@handle_exception('切换api')
|
||||
@register_menu(
|
||||
'切换API',
|
||||
'切换api',
|
||||
'切换获取角色面板时使用的API',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'切换获取角色面板时使用的Enka Network API\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>切换api</ft>'
|
||||
),
|
||||
)
|
||||
async def send_change_api_info(
|
||||
bot: Bot,
|
||||
event: MessageEvent,
|
||||
matcher: Matcher,
|
||||
args: Message = CommandArg(),
|
||||
):
|
||||
if args or not await SUPERUSER(bot, event):
|
||||
if not await SUPERUSER(bot, event):
|
||||
return
|
||||
|
||||
im = await switch_api()
|
||||
@ -55,18 +72,29 @@ async def send_change_api_info(
|
||||
|
||||
@original_pic.handle()
|
||||
@handle_exception('原图')
|
||||
@register_menu(
|
||||
'查看面板原图',
|
||||
'原图',
|
||||
'查看角色面板中原随机图',
|
||||
trigger_method='回复+指令',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'查看开启随机图功能时角色面板中角色位置的原图,需要回复要查看原图的面板图片消息\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>原图</ft>'
|
||||
),
|
||||
)
|
||||
async def send_original_pic(
|
||||
event: MessageEvent,
|
||||
event: QuoteMessageEvent,
|
||||
matcher: Matcher,
|
||||
):
|
||||
ev = event.__dict__
|
||||
if 'message_reference' in ev:
|
||||
msg_id = ev['message_reference'].__dict__['message_id']
|
||||
path = TEMP_PATH / f'{msg_id}.jpg'
|
||||
if path.exists():
|
||||
logger.info('[原图]访问图片: {}'.format(path))
|
||||
with open(path, 'rb') as f:
|
||||
await matcher.finish(MessageSegment.file_image(f.read()))
|
||||
msg_id = event.quote_message_id
|
||||
path = TEMP_PATH / f'{msg_id}.jpg'
|
||||
if path.exists():
|
||||
logger.info('[原图]访问图片: {}'.format(path))
|
||||
with open(path, 'rb') as f:
|
||||
await matcher.finish(MessageSegment.image(f.read()))
|
||||
|
||||
|
||||
@get_char_info.handle()
|
||||
@ -76,42 +104,74 @@ async def send_original_pic(
|
||||
'查询(@某人)角色名',
|
||||
'查询你的或者指定人的已缓存展柜角色的面板',
|
||||
detail_des=(
|
||||
'指令:'
|
||||
'<ft color=(238,120,0)>[查询</ft>'
|
||||
'<ft color=(125,125,125)>(@某人)</ft>'
|
||||
'<ft color=(238,120,0)>/uidxxx/mysxxx]</ft>'
|
||||
'<ft color=(238,120,0)>角色名</ft>\n'
|
||||
' \n'
|
||||
'介绍:\n'
|
||||
'可以用来查看你的或者指定人的已缓存展柜角色的面板\n'
|
||||
'支持部分角色别名\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>{查询</ft>'
|
||||
'<ft color=(125,125,125)>(@某人)</ft>'
|
||||
'<ft color=(238,120,0)>|uid</ft><ft color=(0,148,200)>xx</ft>'
|
||||
'<ft color=(238,120,0)>|mys</ft><ft color=(0,148,200)>xx</ft>'
|
||||
'<ft color=(238,120,0)>}</ft>'
|
||||
'<ft color=(0,148,200)>[角色名]</ft>\n'
|
||||
'后面可以跟 '
|
||||
'<ft color=(238,120,0)>换</ft>'
|
||||
'<ft color=(125,125,125)>(精{一|二|三|四|五})</ft>'
|
||||
'<ft color=(0,148,200)>[武器名]</ft> '
|
||||
'来更换展示的武器\n'
|
||||
'可以跟 '
|
||||
'<ft color=(125,125,125)>(成长)</ft><ft color=(238,120,0)>曲线</ft> '
|
||||
'来查询该角色成长曲线\n'
|
||||
' \n'
|
||||
'示例:\n'
|
||||
'<ft color=(238,120,0)>查询宵宫</ft>;\n'
|
||||
'<ft color=(238,120,0)>查询</ft><ft color=(0,148,200)>@无疑Wuyi</ft>'
|
||||
'- <ft color=(238,120,0)>查询宵宫</ft>\n'
|
||||
'- <ft color=(238,120,0)>查询绫华换精五雾切</ft>\n'
|
||||
'- <ft color=(238,120,0)>查询一斗成长曲线</ft>\n'
|
||||
'- <ft color=(238,120,0)>查询</ft><ft color=(0,123,67)>@无疑Wuyi</ft>'
|
||||
' <ft color=(238,120,0)>公子</ft>'
|
||||
),
|
||||
)
|
||||
@register_menu(
|
||||
'查询展柜角色',
|
||||
'查询展柜角色',
|
||||
'查询插件已缓存的展柜角色列表',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'查询插件当前已缓存的展柜角色列表\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>查询展柜角色</ft>'
|
||||
),
|
||||
)
|
||||
async def send_char_info(
|
||||
event: MessageEvent,
|
||||
event: TextMessageEvent,
|
||||
matcher: Matcher,
|
||||
args: Message = CommandArg(),
|
||||
custom: ImageAndAt = Depends(),
|
||||
):
|
||||
raw_mes = args.extract_plain_text().strip()
|
||||
name = ''.join(re.findall('[\u4e00-\u9fa5]', raw_mes))
|
||||
# 如果输入中(查询之后的内容)没有其他字符串(如角色名等)则忽略。
|
||||
if not name:
|
||||
return
|
||||
# 若查询中有@则排除@后内容,排除后若@前没有 其他内容则不继续运行下方代码 防止与roleinfo查询打架
|
||||
# 修改后@人应该在命令末尾 如:查询万叶@XXXX
|
||||
if "@" in raw_mes:
|
||||
raw_mes = raw_mes.split("@")[0]
|
||||
if not raw_mes:
|
||||
return
|
||||
logger.info('开始执行[查询角色面板]')
|
||||
at = custom.get_first_at()
|
||||
img = custom.get_first_image()
|
||||
|
||||
qid = at or cast_to_int(event.author)
|
||||
qid = str(qid)
|
||||
|
||||
logger.info('[查询角色面板]QQ: {}'.format(qid))
|
||||
# 获取被@的Wxid,排除""
|
||||
qid = event.from_wxid
|
||||
if event.at_user_list:
|
||||
for user in event.at_user_list:
|
||||
user = user.strip()
|
||||
if user != "":
|
||||
qid = user
|
||||
logger.info('[查询角色面板]WXID: {}'.format(qid))
|
||||
|
||||
# 获取uid
|
||||
uid = re.findall(r'\d+', raw_mes)
|
||||
uid = re.findall(r'\d+', raw_mes.split("@")[0])
|
||||
if uid:
|
||||
uid = uid[0]
|
||||
else:
|
||||
@ -122,19 +182,15 @@ async def send_char_info(
|
||||
if '未找到绑定的UID' in uid:
|
||||
await matcher.finish(UID_HINT)
|
||||
|
||||
# 获取角色名
|
||||
msg = ''.join(re.findall('[\u4e00-\u9fa5]', raw_mes))
|
||||
im = await draw_enka_img(msg, uid, img)
|
||||
im = await draw_enka_img(raw_mes, uid, None)
|
||||
|
||||
if isinstance(im, str):
|
||||
await matcher.finish(im)
|
||||
elif isinstance(im, Tuple):
|
||||
if isinstance(im[0], str):
|
||||
await matcher.finish(im[0])
|
||||
req = await matcher.send(MessageSegment.file_image(im[0]))
|
||||
msg_id = req.id
|
||||
await matcher.send(MessageSegment.image(im[0]))
|
||||
# msg_id = req['message_id']
|
||||
if im[1]:
|
||||
with open(TEMP_PATH / f'{msg_id}.jpg', 'wb') as f:
|
||||
with open(TEMP_PATH / f'{uid}.jpg', 'wb') as f:
|
||||
f.write(im[1])
|
||||
else:
|
||||
await matcher.finish('发生了未知错误,请联系管理员检查后台输出!')
|
||||
@ -192,17 +248,19 @@ async def daily_refresh_charData():
|
||||
async def send_card_info(
|
||||
bot: Bot,
|
||||
matcher: Matcher,
|
||||
event: MessageEvent,
|
||||
custom: ImageAndAt = Depends(),
|
||||
event: TextMessageEvent,
|
||||
args: Message = CommandArg(),
|
||||
):
|
||||
message = args.extract_plain_text().strip().replace(' ', '')
|
||||
uid = re.findall(r'\d+', message) # str
|
||||
uid = re.findall(r'\d+', message.split("@")[0]) # str
|
||||
m = ''.join(re.findall('[\u4e00-\u9fa5]', message))
|
||||
qid = str(cast_to_int(event.author))
|
||||
at = custom.get_first_at()
|
||||
if at:
|
||||
qid = at
|
||||
# 获取被@的Wxid,排除""
|
||||
qid = event.from_wxid
|
||||
if event.at_user_list:
|
||||
for user in event.at_user_list:
|
||||
user = user.strip()
|
||||
if user != "":
|
||||
qid = user
|
||||
|
||||
if len(uid) >= 1:
|
||||
uid = uid[0]
|
||||
@ -220,10 +278,13 @@ async def send_card_info(
|
||||
if not uid:
|
||||
await matcher.finish(UID_HINT)
|
||||
im = await enka_to_card(uid)
|
||||
logger.info(f'UID{uid}获取角色数据成功!')
|
||||
|
||||
if isinstance(im, str):
|
||||
await matcher.finish(im)
|
||||
await matcher.finish(MessageSegment.file_image(im))
|
||||
elif isinstance(im, bytes):
|
||||
await matcher.finish(MessageSegment.image(im))
|
||||
else:
|
||||
await matcher.finish('发生了未知错误,请联系管理员检查后台输出!')
|
||||
|
||||
|
||||
@get_charcard_list.handle()
|
||||
@ -245,33 +306,31 @@ async def send_card_info(
|
||||
),
|
||||
)
|
||||
async def send_charcard_list(
|
||||
event: MessageEvent,
|
||||
event: TextMessageEvent,
|
||||
matcher: Matcher,
|
||||
args: Message = CommandArg(),
|
||||
custom: ImageAndAt = Depends(),
|
||||
):
|
||||
raw_mes = args.extract_plain_text().strip()
|
||||
qid = str(cast_to_int(event.author))
|
||||
at = custom.get_first_at()
|
||||
if at:
|
||||
qid = at
|
||||
# 获取被@的Wxid,排除""
|
||||
qid = event.from_wxid
|
||||
if event.at_user_list:
|
||||
for user in event.at_user_list:
|
||||
user = user.strip()
|
||||
if user != "":
|
||||
qid = user
|
||||
|
||||
# 获取uid
|
||||
uid = re.findall(r'\d+', raw_mes)
|
||||
uid = re.findall(r'\d+', raw_mes.split("@")[0])
|
||||
if uid:
|
||||
uid = uid[0]
|
||||
else:
|
||||
uid = await select_db(qid, mode='uid')
|
||||
uid = str(uid)
|
||||
|
||||
if event.author and event.author.avatar:
|
||||
avatar = event.author.avatar
|
||||
else:
|
||||
avatar = '3399214199'
|
||||
|
||||
im = await draw_cahrcard_list(str(uid), avatar)
|
||||
im = await draw_cahrcard_list(str(uid), qid)
|
||||
|
||||
logger.info(f'UID{uid}获取角色数据成功!')
|
||||
if isinstance(im, bytes):
|
||||
await matcher.finish(MessageSegment.file_image(im))
|
||||
await matcher.finish(MessageSegment.image(im))
|
||||
else:
|
||||
await matcher.finish(str(im))
|
||||
|
@ -5,7 +5,8 @@ from nonebot.log import logger
|
||||
from nonebot.matcher import Matcher
|
||||
from nonebot import on_regex, on_command
|
||||
from nonebot.params import CommandArg, RegexGroup
|
||||
from nonebot.adapters.qqguild import Message, MessageSegment
|
||||
from nonebot.adapters.ntchat import MessageSegment
|
||||
from nonebot.adapters.ntchat.message import Message
|
||||
|
||||
from ..version import Genshin_version
|
||||
from ..genshinuid_meta import register_menu
|
||||
@ -25,15 +26,16 @@ IMG_PATH = Path(__file__).parent / 'img_data'
|
||||
'版本规划(版本号)',
|
||||
'发送一张指定版本的原石规划图',
|
||||
detail_des=(
|
||||
'指令:'
|
||||
'<ft color=(238,120,0)>版本规划</ft>'
|
||||
'<ft color=(125,125,125)>(版本号)</ft>\n'
|
||||
' \n'
|
||||
'介绍:\n'
|
||||
'发送一张指定版本的原石规划图\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>版本规划</ft><ft color=(125,125,125)>(版本号)</ft>\n'
|
||||
'- <ft color=(238,120,0)>原石预估</ft><ft color=(125,125,125)>(版本号)</ft>\n'
|
||||
' \n'
|
||||
'示例:\n'
|
||||
'<ft color=(238,120,0)>版本规划</ft>;\n'
|
||||
'<ft color=(238,120,0)>版本规划3.0</ft>'
|
||||
'- <ft color=(238,120,0)>版本规划</ft>\n'
|
||||
'- <ft color=(238,120,0)>版本规划3.0</ft>'
|
||||
),
|
||||
)
|
||||
async def send_primogems_data(matcher: Matcher, args: Message = CommandArg()):
|
||||
@ -48,38 +50,62 @@ async def send_primogems_data(matcher: Matcher, args: Message = CommandArg()):
|
||||
else:
|
||||
img = f'{Genshin_version[:3]}.png'
|
||||
primogems_img = PRIMOGEMS_DATA_PATH / img
|
||||
logger.info('[图片][版本规划]访问图片: {}'.format(img))
|
||||
await matcher.finish(MessageSegment.file_image(primogems_img))
|
||||
if primogems_img.exists():
|
||||
logger.info('[图片][版本规划]访问图片: {}'.format(img))
|
||||
with open(primogems_img, 'rb') as f:
|
||||
await matcher.finish(MessageSegment.image(f.read()))
|
||||
else:
|
||||
await matcher.finish()
|
||||
|
||||
|
||||
@get_img_data.handle()
|
||||
@handle_exception('杂图')
|
||||
@register_menu(
|
||||
'伤害乘区图',
|
||||
'伤害乘区',
|
||||
'(查询)伤害乘区',
|
||||
'发送一张理论伤害计算公式图',
|
||||
detail_des=(
|
||||
'指令:' '<ft color=(238,120,0)>伤害乘区</ft>\n' ' \n' '发送一张理论伤害计算公式图'
|
||||
'介绍:\n'
|
||||
'发送一张理论伤害计算公式图\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(125,125,125)>(查询)</ft><ft color=(238,120,0)>伤害乘区</ft>'
|
||||
),
|
||||
)
|
||||
@register_menu(
|
||||
'怪物血量表',
|
||||
'血量表',
|
||||
'(查询)血量表',
|
||||
'发送一张原神怪物血量表图',
|
||||
detail_des=('指令:' '<ft color=(238,120,0)>血量表</ft>\n' ' \n' '发送一张原神怪物血量表图'),
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'发送一张原神怪物血量表图\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(125,125,125)>(查询)</ft><ft color=(238,120,0)>血量表</ft>'
|
||||
),
|
||||
)
|
||||
@register_menu(
|
||||
'怪物抗性表',
|
||||
'抗性表',
|
||||
'(查询)抗性表',
|
||||
'发送一张原神怪物抗性表图',
|
||||
detail_des=('指令:' '<ft color=(238,120,0)>抗性表</ft>\n' ' \n' '发送一张原神怪物抗性表图'),
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'发送一张原神怪物抗性表图\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(125,125,125)>(查询)</ft><ft color=(238,120,0)>抗性表</ft>'
|
||||
),
|
||||
)
|
||||
@register_menu(
|
||||
'怪物血量排行',
|
||||
'血量排行',
|
||||
'(查询)血量排行',
|
||||
'发送一张原神怪物血量排行图',
|
||||
detail_des=(
|
||||
'指令:' '<ft color=(238,120,0)>血量排行</ft>\n' ' \n' '发送一张原神怪物血量排行图'
|
||||
'介绍:\n'
|
||||
'发送一张原神怪物血量排行图\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(125,125,125)>(查询)</ft><ft color=(238,120,0)>血量排行</ft>'
|
||||
),
|
||||
)
|
||||
async def send_img_data(
|
||||
@ -89,4 +115,5 @@ async def send_img_data(
|
||||
logger.info('[图片][杂图]参数: {}'.format(args))
|
||||
img = IMG_PATH / f'{args[1]}.jpg'
|
||||
if img.exists():
|
||||
await matcher.finish(MessageSegment.file_image(img))
|
||||
with open(img, 'rb') as f:
|
||||
await matcher.finish(MessageSegment.image(f.read()))
|
||||
|
@ -1,14 +1,16 @@
|
||||
from nonebot import on_regex
|
||||
from nonebot import on_command
|
||||
from nonebot.matcher import Matcher
|
||||
from nonebot_plugin_apscheduler import scheduler
|
||||
from nonebot.adapters.qqguild import MessageSegment
|
||||
from nonebot.adapters.ntchat import MessageSegment
|
||||
|
||||
from ..config import priority
|
||||
from ..genshinuid_meta import register_menu
|
||||
from ..utils.nonebot2.rule import FullCommand
|
||||
from .draw_event_img import get_event_img, get_all_event_img
|
||||
from ..utils.exception.handle_exception import handle_exception
|
||||
|
||||
get_event = on_regex(r'^活动列表$')
|
||||
get_gacha = on_regex(r'^卡池列表$')
|
||||
get_event = on_command('活动列表', priority=priority, rule=FullCommand())
|
||||
get_gacha = on_command('卡池列表', priority=priority, rule=FullCommand())
|
||||
|
||||
|
||||
@scheduler.scheduled_job('cron', hour='2')
|
||||
@ -22,21 +24,33 @@ async def draw_event():
|
||||
'活动列表',
|
||||
'活动列表',
|
||||
'查询当前版本活动日程表',
|
||||
detail_des=('指令:' '<ft color=(238,120,0)>活动列表</ft>\n' ' \n' '查询当前版本活动日程表'),
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'查询当前版本活动日程表\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>活动列表</ft>'
|
||||
),
|
||||
)
|
||||
async def send_events(matcher: Matcher):
|
||||
img = await get_event_img('EVENT')
|
||||
await matcher.finish(MessageSegment.file_image(img))
|
||||
await matcher.finish(MessageSegment.image(img))
|
||||
|
||||
|
||||
@get_gacha.handle()
|
||||
@handle_exception('卡池')
|
||||
@handle_exception('活动')
|
||||
@register_menu(
|
||||
'卡池列表',
|
||||
'卡池列表',
|
||||
'查询当前版本卡池列表',
|
||||
detail_des=('指令:' '<ft color=(238,120,0)>卡池列表</ft>\n' ' \n' '查询当前版本卡池列表'),
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'查询当前版本卡池列表\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>卡池列表</ft>'
|
||||
),
|
||||
)
|
||||
async def send_gachas(matcher: Matcher):
|
||||
img = await get_event_img('GACHA')
|
||||
await matcher.finish(MessageSegment.file_image(img))
|
||||
await matcher.finish(MessageSegment.image(img))
|
||||
|
BIN
GenshinUID/genshinuid_eventlist/event.jpg
Normal file
BIN
GenshinUID/genshinuid_eventlist/event.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 307 KiB |
BIN
GenshinUID/genshinuid_eventlist/gacha.jpg
Normal file
BIN
GenshinUID/genshinuid_eventlist/gacha.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 411 KiB |
@ -1,34 +1,54 @@
|
||||
import os
|
||||
import asyncio
|
||||
|
||||
from nonebot.log import logger
|
||||
from nonebot.rule import is_type
|
||||
from nonebot.matcher import Matcher
|
||||
from nonebot import get_bot, on_notice, on_command
|
||||
from nonebot.adapters.qqguild import MessageEvent, MessageSegment
|
||||
from nonebot import get_bot, on_command, on_message
|
||||
from nonebot.adapters.ntchat.permission import GROUP
|
||||
from nonebot.adapters.ntchat import (
|
||||
MessageSegment,
|
||||
FileMessageEvent,
|
||||
TextMessageEvent,
|
||||
)
|
||||
|
||||
from .get_gachalogs import save_gachalogs
|
||||
from ..genshinuid_meta import register_menu
|
||||
from ..utils.nonebot2.rule import FullCommand
|
||||
from .draw_gachalogs import draw_gachalogs_img
|
||||
from ..utils.message.error_reply import UID_HINT
|
||||
from ..utils.message.cast_type import cast_to_int
|
||||
from ..utils.db_operation.db_operation import select_db
|
||||
from ..utils.exception.handle_exception import handle_exception
|
||||
from .export_and_import import export_gachalogs, import_gachalogs
|
||||
|
||||
get_gacha_log = on_command('刷新抽卡记录', aliases={'强制刷新抽卡记录'}, rule=FullCommand())
|
||||
get_gacha_log_card = on_command('抽卡记录', rule=FullCommand())
|
||||
import_gacha_log = on_notice()
|
||||
export_gacha_log = on_command('导出抽卡记录', rule=FullCommand())
|
||||
import_gacha_log = on_message(block=False, rule=(is_type(FileMessageEvent)))
|
||||
export_gacha_log = on_command('导出抽卡记录', rule=FullCommand(), permission=GROUP)
|
||||
|
||||
|
||||
@export_gacha_log.handle()
|
||||
@handle_exception('导出抽卡记录')
|
||||
@register_menu(
|
||||
'导出抽卡记录',
|
||||
'导出抽卡记录',
|
||||
'导出符合UIGF规范的抽卡记录',
|
||||
trigger_method='群聊指令',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'导出UIGF格式规范的json格式抽卡记录上传到群文件\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>导出抽卡记录</ft>'
|
||||
),
|
||||
)
|
||||
async def export_gacha_log_info(
|
||||
event: MessageEvent,
|
||||
event: TextMessageEvent,
|
||||
matcher: Matcher,
|
||||
):
|
||||
|
||||
logger.info('开始执行[导出抽卡记录]')
|
||||
qid = str(str(cast_to_int(event.author)))
|
||||
gid = event.channel_id
|
||||
qid = event.from_wxid
|
||||
gid = event.room_wxid
|
||||
uid = await select_db(qid, mode='uid')
|
||||
bot = get_bot()
|
||||
if not isinstance(uid, str) or '未找到绑定的UID' in uid:
|
||||
@ -36,10 +56,9 @@ async def export_gacha_log_info(
|
||||
raw_data = await export_gachalogs(uid)
|
||||
if raw_data['retcode'] == 'ok':
|
||||
await bot.call_api(
|
||||
'upload_group_file',
|
||||
group_id=gid,
|
||||
name=raw_data['name'],
|
||||
file=raw_data['url'],
|
||||
'send_file',
|
||||
to_wxid=gid,
|
||||
file_path=raw_data['url'],
|
||||
)
|
||||
logger.info(f'[导出抽卡记录] UID{uid}成功!')
|
||||
await matcher.finish('上传成功!')
|
||||
@ -50,21 +69,35 @@ async def export_gacha_log_info(
|
||||
|
||||
@import_gacha_log.handle()
|
||||
@handle_exception('导入抽卡记录')
|
||||
async def import_gacha_log_info(event: MessageEvent, matcher: Matcher):
|
||||
args = event.dict()
|
||||
if args['notice_type'] != 'offline_file':
|
||||
@register_menu(
|
||||
'导入抽卡记录',
|
||||
'json格式文件',
|
||||
'导入符合UIGF规范的抽卡记录',
|
||||
trigger_method='私聊离线文件',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'导入UIGF格式规范的json格式抽卡记录到插件本地缓存\n'
|
||||
' \n'
|
||||
'触发方式:\n'
|
||||
'- <ft color=(238,120,0)>私聊发送json格式的离线文件</ft>'
|
||||
),
|
||||
)
|
||||
async def import_gacha_log_info(event: FileMessageEvent, matcher: Matcher):
|
||||
await asyncio.sleep(2) # 等待下载文件,避免占用
|
||||
# 检测文件是否存在并小于8MB
|
||||
if (
|
||||
os.path.exists(event.file)
|
||||
and os.path.getsize(event.file) <= 8 * 1024 * 1024
|
||||
and event.file_name.endswith(".json")
|
||||
):
|
||||
uid = await select_db(event.from_wxid, mode='uid')
|
||||
if not isinstance(uid, str) or '未找到绑定的UID' in uid:
|
||||
await matcher.finish(UID_HINT)
|
||||
logger.info('开始执行[导入抽卡记录]')
|
||||
im = await import_gachalogs(event.file, uid)
|
||||
await matcher.finish(im)
|
||||
else:
|
||||
await matcher.finish()
|
||||
url = args['file']['url']
|
||||
name: str = args['file']['name']
|
||||
if not name.endswith('.json'):
|
||||
return
|
||||
qid = args['user_id']
|
||||
uid = await select_db(qid, mode='uid')
|
||||
if not isinstance(uid, str) or '未找到绑定的UID' in uid:
|
||||
await matcher.finish(UID_HINT)
|
||||
logger.info('开始执行[导入抽卡记录]')
|
||||
im = await import_gachalogs(url, uid)
|
||||
await matcher.finish(im)
|
||||
|
||||
|
||||
@get_gacha_log_card.handle()
|
||||
@ -74,28 +107,25 @@ async def import_gacha_log_info(event: MessageEvent, matcher: Matcher):
|
||||
'抽卡记录',
|
||||
'查询你的原神抽卡记录',
|
||||
detail_des=(
|
||||
'指令:'
|
||||
'<ft color=(238,120,0)>抽卡记录</ft>\n'
|
||||
' \n'
|
||||
'介绍:\n'
|
||||
'查询你的原神抽卡记录\n'
|
||||
'需要<ft color=(238,120,0)>绑定Stoken</ft>'
|
||||
'需要<ft color=(238,120,0)>绑定Stoken</ft>\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'<ft color=(238,120,0)>抽卡记录</ft>'
|
||||
),
|
||||
)
|
||||
async def send_gacha_log_card_info(
|
||||
event: MessageEvent,
|
||||
event: TextMessageEvent,
|
||||
matcher: Matcher,
|
||||
):
|
||||
logger.info('开始执行[抽卡记录]')
|
||||
|
||||
uid = await select_db(str(cast_to_int(event.author)), mode='uid')
|
||||
if event.author and event.author.avatar:
|
||||
avatar = event.author.avatar
|
||||
else:
|
||||
avatar = '3399214199'
|
||||
uid = await select_db(event.from_wxid, mode='uid')
|
||||
if isinstance(uid, str):
|
||||
im = await draw_gachalogs_img(uid, avatar) # type: ignore
|
||||
im = await draw_gachalogs_img(uid, event.from_wxid) # type: ignore
|
||||
if isinstance(im, bytes):
|
||||
await matcher.finish(MessageSegment.file_image(im))
|
||||
await matcher.finish(MessageSegment.image(im))
|
||||
else:
|
||||
await matcher.finish(im)
|
||||
else:
|
||||
@ -109,23 +139,30 @@ async def send_gacha_log_card_info(
|
||||
'刷新抽卡记录',
|
||||
'刷新你的原神抽卡记录本地缓存',
|
||||
detail_des=(
|
||||
'指令:'
|
||||
'<ft color=(238,120,0)>刷新抽卡记录</ft>\n'
|
||||
' \n'
|
||||
'介绍:\n'
|
||||
'刷新你的原神抽卡记录本地缓存\n'
|
||||
'需要<ft color=(238,120,0)>绑定Stoken</ft>'
|
||||
'需要<ft color=(238,120,0)>绑定Stoken</ft>\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>刷新抽卡记录</ft>'
|
||||
),
|
||||
)
|
||||
async def send_daily_info(
|
||||
event: MessageEvent,
|
||||
event: TextMessageEvent,
|
||||
matcher: Matcher,
|
||||
):
|
||||
logger.info('开始执行[刷新抽卡记录]')
|
||||
uid = await select_db(str(cast_to_int(event.author)), mode='uid')
|
||||
wxid_list = []
|
||||
wxid_list.append(event.from_wxid)
|
||||
uid = await select_db(event.from_wxid, mode='uid')
|
||||
if isinstance(uid, str):
|
||||
is_force = False
|
||||
if event.content and event.content.startswith('强制'):
|
||||
if event.msg.startswith('强制'):
|
||||
is_force = True
|
||||
tip = '正在刷新抽卡记录,请耐心等待,不要重复发送命令。'
|
||||
await matcher.send(
|
||||
MessageSegment.room_at_msg(content=tip, at_list=wxid_list)
|
||||
)
|
||||
im = await save_gachalogs(uid, None, is_force)
|
||||
await matcher.finish(im)
|
||||
else:
|
||||
|
@ -16,22 +16,30 @@ INT_TO_TYPE = {
|
||||
|
||||
|
||||
async def import_gachalogs(history_url: str, uid: str) -> str:
|
||||
history_data: dict = json.loads(get(history_url).text)
|
||||
data_uid = history_data['info']['uid']
|
||||
if data_uid != uid:
|
||||
return f'该抽卡记录UID{data_uid}与你绑定UID{uid}不符合!'
|
||||
raw_data = history_data['list']
|
||||
result = {'新手祈愿': [], '常驻祈愿': [], '角色祈愿': [], '武器祈愿': []}
|
||||
for item in raw_data:
|
||||
item['uid'] = uid
|
||||
item['item_id'] = ''
|
||||
item['count'] = '1'
|
||||
item['lang'] = 'zh-cn'
|
||||
item['id'] = str(item['id'])
|
||||
del item['uigf_gacha_type']
|
||||
result[INT_TO_TYPE[item['gacha_type']]].append(item)
|
||||
im = await save_gachalogs(uid, result)
|
||||
return im
|
||||
# 是否Json文件检测
|
||||
try:
|
||||
if not history_url.startswith(('http', 'https')):
|
||||
with open(history_url, 'r', encoding='utf-8') as history_url_files:
|
||||
history_data = json.load(history_url_files)
|
||||
else:
|
||||
history_data: dict = get(history_url).json()
|
||||
data_uid = history_data['info']['uid']
|
||||
if data_uid != uid:
|
||||
return f'该抽卡记录UID{data_uid}与你绑定UID{uid}不符合!'
|
||||
raw_data = history_data['list']
|
||||
result = {'新手祈愿': [], '常驻祈愿': [], '角色祈愿': [], '武器祈愿': []}
|
||||
for item in raw_data:
|
||||
item['uid'] = uid
|
||||
item['item_id'] = ''
|
||||
item['count'] = '1'
|
||||
item['lang'] = 'zh-cn'
|
||||
item['id'] = str(item['id'])
|
||||
del item['uigf_gacha_type']
|
||||
result[INT_TO_TYPE[item['gacha_type']]].append(item)
|
||||
im = await save_gachalogs(uid, result)
|
||||
return im
|
||||
except Exception:
|
||||
return '导入失败,请检查你的Json文件!'
|
||||
|
||||
|
||||
async def export_gachalogs(uid: str) -> dict:
|
||||
|
@ -3,14 +3,13 @@ import re
|
||||
from nonebot import on_command
|
||||
from nonebot.log import logger
|
||||
from nonebot.matcher import Matcher
|
||||
from nonebot.params import Depends, CommandArg
|
||||
from nonebot.adapters.qqguild import Message, MessageEvent, MessageSegment
|
||||
from nonebot.params import CommandArg
|
||||
from nonebot.adapters.ntchat.message import Message
|
||||
from nonebot.adapters.ntchat import MessageSegment, TextMessageEvent
|
||||
|
||||
from ..config import priority
|
||||
from .draw_gcginfo import draw_gcg_info
|
||||
from ..utils.message.cast_type import cast_to_int
|
||||
from ..utils.db_operation.db_operation import select_db
|
||||
from ..utils.message.get_image_and_at import ImageAndAt
|
||||
from ..utils.message.error_reply import CK_HINT, UID_HINT
|
||||
from ..utils.exception.handle_exception import handle_exception
|
||||
|
||||
@ -21,25 +20,30 @@ get_gcg_info = on_command('七圣召唤', aliases={'七圣', '召唤'}, priority
|
||||
@get_gcg_info.handle()
|
||||
@handle_exception('七圣召唤', '获取/发送七圣召唤失败', '@未找到绑定信息\n' + CK_HINT)
|
||||
async def send_gcg_pic(
|
||||
event: MessageEvent,
|
||||
event: TextMessageEvent,
|
||||
matcher: Matcher,
|
||||
args: Message = CommandArg(),
|
||||
custom: ImageAndAt = Depends(),
|
||||
):
|
||||
raw_mes = args.extract_plain_text().strip().replace(' ', '')
|
||||
name = ''.join(re.findall('[\u4e00-\u9fa5]', raw_mes))
|
||||
if name:
|
||||
return
|
||||
at = custom.get_first_at()
|
||||
if "@" in raw_mes:
|
||||
name = ''.join(re.findall('^[\u4e00-\u9fa5]+', raw_mes.split("@")[0]))
|
||||
if name:
|
||||
return
|
||||
else:
|
||||
name = ''.join(re.findall('^[\u4e00-\u9fa5]+', raw_mes))
|
||||
if name:
|
||||
return
|
||||
logger.info('开始执行[七圣召唤]')
|
||||
|
||||
qid = at or cast_to_int(event.author)
|
||||
qid = str(qid)
|
||||
|
||||
logger.info('[七圣召唤]QQ: {}'.format(qid))
|
||||
qid = event.from_wxid
|
||||
if event.at_user_list:
|
||||
for user in event.at_user_list:
|
||||
user = user.strip()
|
||||
if user != "":
|
||||
qid = user
|
||||
logger.info('[七圣召唤]WXID: {}'.format(qid))
|
||||
|
||||
# 获取uid
|
||||
uid = re.findall(r'\d+', raw_mes)
|
||||
uid = re.findall(r'\d+', raw_mes.split("@")[0])
|
||||
if uid:
|
||||
uid = uid[0]
|
||||
else:
|
||||
@ -55,6 +59,6 @@ async def send_gcg_pic(
|
||||
if isinstance(im, str):
|
||||
await matcher.finish(im)
|
||||
elif isinstance(im, bytes):
|
||||
await matcher.finish(MessageSegment.file_image(im))
|
||||
await matcher.finish(MessageSegment.image(im))
|
||||
else:
|
||||
await matcher.finish('发生了未知错误,请联系管理员检查后台输出!')
|
||||
|
@ -7,7 +7,8 @@ from nonebot.log import logger
|
||||
from nonebot.matcher import Matcher
|
||||
from nonebot import on_regex, on_command
|
||||
from nonebot.params import CommandArg, RegexGroup
|
||||
from nonebot.adapters.qqguild import Message, MessageSegment
|
||||
from nonebot.adapters.ntchat import MessageSegment
|
||||
from nonebot.adapters.ntchat.message import Message
|
||||
|
||||
from .get_card import get_gs_card
|
||||
from .get_guide import get_gs_guide
|
||||
@ -32,15 +33,17 @@ IMG_PATH = Path(__file__).parent / 'img'
|
||||
'xx攻略',
|
||||
'发送一张对应角色的西风驿站攻略图',
|
||||
detail_des=(
|
||||
'指令:'
|
||||
'<ft color=(238,120,0)>角色名[推荐/攻略]</ft>\n'
|
||||
' \n'
|
||||
'介绍:\n'
|
||||
'发送一张对应角色的米游社西风驿站攻略图\n'
|
||||
'支持部分角色别名\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(0,148,200)>[角色名]</ft>'
|
||||
'<ft color=(238,120,0)>{推荐|攻略}</ft>\n'
|
||||
' \n'
|
||||
'示例:\n'
|
||||
'<ft color=(238,120,0)>钟离推荐</ft>;\n'
|
||||
'<ft color=(238,120,0)>公子攻略</ft>'
|
||||
'- <ft color=(238,120,0)>钟离推荐</ft>\n'
|
||||
'- <ft color=(238,120,0)>公子攻略</ft>'
|
||||
),
|
||||
)
|
||||
async def send_guide_pic(
|
||||
@ -52,8 +55,7 @@ async def send_guide_pic(
|
||||
im = await get_gs_guide(name)
|
||||
if im:
|
||||
logger.info('获得{}攻略成功!'.format(name))
|
||||
print('gg')
|
||||
await matcher.finish(MessageSegment.file_image(im))
|
||||
await matcher.finish(MessageSegment.image(im))
|
||||
else:
|
||||
logger.warning('未找到{}攻略图片'.format(name))
|
||||
|
||||
@ -65,15 +67,17 @@ async def send_guide_pic(
|
||||
'参考面板[角色名/元素名]',
|
||||
'发送一张对应角色/元素的参考面板图',
|
||||
detail_des=(
|
||||
'指令:'
|
||||
'<ft color=(238,120,0)>参考面板[角色名/元素名]</ft>\n'
|
||||
' \n'
|
||||
'介绍:\n'
|
||||
'发送一张对应角色/元素的参考面板图\n'
|
||||
'支持部分角色别名\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>参考面板</ft>'
|
||||
'<ft color=(0,148,200)>[角色名/元素名]</ft>\n'
|
||||
' \n'
|
||||
'示例:\n'
|
||||
'<ft color=(238,120,0)>参考面板火</ft>;\n'
|
||||
'<ft color=(238,120,0)>参考面板公子</ft>'
|
||||
'- <ft color=(238,120,0)>参考面板火</ft>\n'
|
||||
'- <ft color=(238,120,0)>参考面板公子</ft>'
|
||||
),
|
||||
)
|
||||
async def send_bluekun_pic(matcher: Matcher, args: Message = CommandArg()):
|
||||
@ -83,8 +87,10 @@ async def send_bluekun_pic(matcher: Matcher, args: Message = CommandArg()):
|
||||
name = await alias_to_char_name(str(args[0]))
|
||||
img = IMG_PATH / '{}.jpg'.format(name)
|
||||
if img.exists():
|
||||
with open(img, 'rb') as f:
|
||||
im = MessageSegment.image(f.read())
|
||||
logger.info('获得{}参考面板图片成功!'.format(name))
|
||||
await matcher.finish(MessageSegment.file_image(img))
|
||||
await matcher.finish(im)
|
||||
else:
|
||||
logger.warning('未找到{}参考面板图片'.format(name))
|
||||
|
||||
@ -98,7 +104,7 @@ async def send_gscard_pic(matcher: Matcher, args: Message = CommandArg()):
|
||||
im = await get_gs_card(name)
|
||||
if im:
|
||||
logger.info('获得{}原牌成功!'.format(name))
|
||||
await matcher.finish(MessageSegment.file_image(im))
|
||||
await matcher.finish(MessageSegment.image(im))
|
||||
else:
|
||||
logger.warning('未找到{}原牌图片'.format(name))
|
||||
|
||||
@ -120,7 +126,7 @@ async def send_abyss_review(
|
||||
elif isinstance(im, str):
|
||||
await matcher.finish(im)
|
||||
elif isinstance(im, bytes):
|
||||
await matcher.finish(MessageSegment.file_image(im))
|
||||
await matcher.finish(MessageSegment.image(im))
|
||||
else:
|
||||
await matcher.finish('发生了未知错误,请联系管理员检查后台输出!')
|
||||
|
||||
|
@ -1,139 +0,0 @@
|
||||
import asyncio
|
||||
from typing import List
|
||||
|
||||
from nonebot import on_command
|
||||
from nonebot.log import logger
|
||||
from nonebot.matcher import Matcher
|
||||
from nonebot.permission import SUPERUSER
|
||||
from nonebot.message import event_preprocessor
|
||||
from nonebot.adapters.qqguild.message import Text
|
||||
from nonebot.adapters.qqguild import Bot, MessageEvent
|
||||
from nonebot.adapters.qqguild.api.model import DMS, Guild, MessageMarkdown
|
||||
|
||||
from ..utils.nonebot2.rule import FullCommand
|
||||
from ..utils.exception.handle_exception import handle_exception
|
||||
|
||||
_md = '''## 这是一个自定义MD文本
|
||||
'''
|
||||
|
||||
guild_detail = on_command('频道统计', block=True, rule=FullCommand())
|
||||
get_dirct_msg = on_command(
|
||||
'给我发消息',
|
||||
aliases={'给我发私信', '给我发短信', '给我发信息'},
|
||||
block=True,
|
||||
rule=FullCommand(),
|
||||
)
|
||||
get_markdown_msg = on_command(
|
||||
'给我发md',
|
||||
aliases={'给我发markdown'},
|
||||
block=True,
|
||||
rule=FullCommand(),
|
||||
)
|
||||
|
||||
|
||||
@get_markdown_msg.handle()
|
||||
@handle_exception('发md')
|
||||
async def send_markdown_msg(bot: Bot, event: MessageEvent, matcher: Matcher):
|
||||
if not event.author:
|
||||
return
|
||||
|
||||
await bot.call_api(
|
||||
'post_markdown_message',
|
||||
channel_id=str(event.channel_id),
|
||||
content=_md,
|
||||
)
|
||||
|
||||
await matcher.finish('已发送消息!')
|
||||
|
||||
|
||||
@get_dirct_msg.handle()
|
||||
@handle_exception('发私信')
|
||||
async def send_dirct_msg(
|
||||
bot: Bot,
|
||||
event: MessageEvent,
|
||||
matcher: Matcher,
|
||||
):
|
||||
if not event.author:
|
||||
return
|
||||
|
||||
dms: DMS = await bot.call_api(
|
||||
'post_dms',
|
||||
recipient_id=str(event.author.id),
|
||||
source_guild_id=str(event.guild_id),
|
||||
)
|
||||
|
||||
await bot.call_api(
|
||||
'post_dms_messages',
|
||||
guild_id=dms.guild_id,
|
||||
content='一条消息!',
|
||||
)
|
||||
|
||||
await matcher.finish('已发送消息!')
|
||||
|
||||
|
||||
@event_preprocessor
|
||||
async def _(event: MessageEvent):
|
||||
msg = event.get_message().extract_content()
|
||||
msg = msg.replace(' ', '').replace('/', '')
|
||||
r_msg = None
|
||||
new_msg = []
|
||||
for i in event._message: # type: ignore
|
||||
if isinstance(i, Text):
|
||||
i.data['text'] = msg
|
||||
if '毕业都统计' in i.data['text']:
|
||||
i.data['text'].replace('都', '度')
|
||||
|
||||
if r_msg:
|
||||
new_msg.insert(0, r_msg)
|
||||
event._message = new_msg
|
||||
|
||||
if event.content:
|
||||
event.content = event.content.replace(' ', '').replace('/', '')
|
||||
|
||||
|
||||
@guild_detail.handle()
|
||||
@handle_exception('频道统计')
|
||||
async def send_create_map_msg(
|
||||
bot: Bot,
|
||||
event: MessageEvent,
|
||||
matcher: Matcher,
|
||||
):
|
||||
if not await SUPERUSER(bot, event):
|
||||
return
|
||||
logger.info('[频道统计]正在执行...')
|
||||
await matcher.send('频道统计正在执行...可能需要较长时间!')
|
||||
|
||||
# 初始化最后的计数
|
||||
ALL_MEMBER = 0
|
||||
HIDE = 0
|
||||
|
||||
# 开始分页
|
||||
after = None
|
||||
# 初始化频道列表
|
||||
guild_list = []
|
||||
# 开始循环
|
||||
while True:
|
||||
# 本次获取的频道列表
|
||||
new_guild_list: List[Guild] = await bot.call_api(
|
||||
'guilds', before=None, after=after, limit=None
|
||||
)
|
||||
# 遍历频道列表
|
||||
for guild in new_guild_list:
|
||||
# 如果该频道人数展示
|
||||
if guild.member_count:
|
||||
# 总人数加上该频道的人数
|
||||
ALL_MEMBER += guild.member_count
|
||||
else:
|
||||
HIDE += 1
|
||||
logger.info(f'频道{guild.id}隐藏频道人数信息,已跳过计算...')
|
||||
# 重新设定拉取值
|
||||
after = guild.id
|
||||
# 把本次拉取的频道列表 合并到总频道列表
|
||||
guild_list.extend(new_guild_list)
|
||||
logger.info(f'当前页gid={after}')
|
||||
# 如果已经拉取不到频道了,就退出循环
|
||||
if new_guild_list == []:
|
||||
break
|
||||
await asyncio.sleep(0.5)
|
||||
im = f'当前Bot加入频道数{len(guild_list)}\n总人数为{ALL_MEMBER}\n隐藏人数频道数量{HIDE}!'
|
||||
await matcher.finish(im)
|
@ -5,7 +5,7 @@ from pathlib import Path
|
||||
from nonebot import on_command
|
||||
from nonebot.log import logger
|
||||
from nonebot.matcher import Matcher
|
||||
from nonebot.adapters.qqguild import MessageSegment
|
||||
from nonebot.adapters.ntchat import MessageSegment
|
||||
|
||||
from .draw_help_card import draw_help_img
|
||||
from ..genshinuid_meta import register_menu
|
||||
@ -22,12 +22,15 @@ HELP_IMG = Path(__file__).parent / 'help.png'
|
||||
'插件帮助',
|
||||
'gs帮助',
|
||||
'查看插件功能帮助图',
|
||||
detail_des=('指令:' '<ft color=(238,120,0)>gs帮助</ft>\n' ' \n' '查看插件功能帮助图'),
|
||||
detail_des=(
|
||||
'介绍:\n' '查看插件功能帮助图\n' ' \n' '指令:\n' '- <ft color=(238,120,0)>gs帮助</ft>'
|
||||
),
|
||||
)
|
||||
async def send_guide_pic(matcher: Matcher):
|
||||
logger.info('获得gs帮助图片成功!')
|
||||
if HELP_IMG.exists():
|
||||
await matcher.finish(MessageSegment.file_image(HELP_IMG))
|
||||
with open(HELP_IMG, 'rb') as f:
|
||||
await matcher.finish(MessageSegment.image(f.read()))
|
||||
else:
|
||||
await matcher.finish('帮助图不存在!')
|
||||
|
||||
|
@ -1,16 +1,11 @@
|
||||
from typing import Any, Dict, Union
|
||||
from typing import Any, Dict
|
||||
|
||||
from nonebot.log import logger
|
||||
from nonebot.matcher import Matcher
|
||||
from nonebot.params import RegexDict
|
||||
from nonebot import on_regex, on_command
|
||||
from nonebot.permission import SUPERUSER
|
||||
from nonebot.adapters.onebot.v11 import (
|
||||
Bot,
|
||||
MessageSegment,
|
||||
GroupMessageEvent,
|
||||
PrivateMessageEvent,
|
||||
)
|
||||
from nonebot.adapters.ntchat import Bot, MessageSegment, TextMessageEvent
|
||||
|
||||
from ..config import priority
|
||||
from ..genshinuid_meta import register_menu
|
||||
@ -60,7 +55,7 @@ MAP_CHN_NAME = {
|
||||
)
|
||||
async def send_change_map_msg(
|
||||
bot: Bot,
|
||||
event: Union[GroupMessageEvent, PrivateMessageEvent],
|
||||
event: TextMessageEvent,
|
||||
matcher: Matcher,
|
||||
):
|
||||
if not await SUPERUSER(bot, event):
|
||||
|
@ -12,8 +12,17 @@ __plugin_meta__ = PluginMetadata(
|
||||
'<ft color=(0,148,200)>[序号]</ft> '
|
||||
'指令获取某功能详细介绍\n'
|
||||
' \n'
|
||||
'示例指令小括号中的内容为可选参数,可以省略;\n'
|
||||
'中括号中的内容或者用“xx”代表的内容为必选参数,请将它们替换为对应的参数'
|
||||
'菜单描述中的指令:\n'
|
||||
'<ft color=(0,148,200)>[中括号及其中的内容]</ft>,'
|
||||
'或<ft color=(0,148,200)>用“xx”代表的内容</ft> '
|
||||
'为<ft color=(238,120,0)>必选</ft>的参数,'
|
||||
'请将它们替换为适当的值;\n'
|
||||
'<ft color=(125,125,125)>(小括号及其中的内容)</ft> '
|
||||
'为<ft color=(238,120,0)>可选</ft>参数,'
|
||||
'可以省略;\n'
|
||||
'<ft color=(238,120,0)>{大括号及其中的内容}</ft> '
|
||||
'为<ft color=(238,120,0)>选择其一</ft>参数,'
|
||||
'请将它们替换为用 <ft color=(238,120,0)>|</ft> 分割后括号中内容的其中一个值'
|
||||
),
|
||||
extra={'menu_data': sub_menus, 'menu_template': 'default'},
|
||||
)
|
||||
|
@ -6,9 +6,10 @@ from nonebot.matcher import Matcher
|
||||
from nonebot import get_bot, on_command
|
||||
from nonebot.permission import SUPERUSER
|
||||
from nonebot_plugin_apscheduler import scheduler
|
||||
from nonebot.adapters.qqguild import MessageEvent
|
||||
from nonebot.adapters.ntchat import Bot, MessageEvent, MessageSegment
|
||||
|
||||
from ..config import SUPERUSERS, priority
|
||||
from ..genshinuid_meta import register_menu
|
||||
from ..utils.nonebot2.rule import FullCommand
|
||||
from ..utils.db_operation.db_operation import config_check
|
||||
from ..utils.exception.handle_exception import handle_exception
|
||||
@ -18,28 +19,59 @@ bbscoin_scheduler = scheduler
|
||||
|
||||
get_mihoyo_coin = on_command('开始获取米游币', priority=priority, rule=FullCommand())
|
||||
all_bbscoin_recheck = on_command(
|
||||
'全部重获取', permission=SUPERUSER, priority=priority, rule=FullCommand()
|
||||
'全部重获取', priority=priority, rule=FullCommand()
|
||||
)
|
||||
|
||||
|
||||
# 获取米游币
|
||||
@get_mihoyo_coin.handle()
|
||||
@handle_exception('获取米游币')
|
||||
@register_menu(
|
||||
'手动获取米游币',
|
||||
'开始获取米游币',
|
||||
'手动触发米游社米游币任务',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'手动触发米游社获取米游币的任务\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>开始获取米游币</ft>'
|
||||
),
|
||||
)
|
||||
async def send_mihoyo_coin(event: MessageEvent, matcher: Matcher):
|
||||
await matcher.send('开始操作……', at_sender=True)
|
||||
qid = int(event.sender.user_id) # type: ignore
|
||||
wxid_list = []
|
||||
wxid_list.append(event.from_wxid)
|
||||
await matcher.send(
|
||||
MessageSegment.room_at_msg(content='{$@}开始操作……', at_list=wxid_list)
|
||||
)
|
||||
qid = event.from_wxid
|
||||
im = await mihoyo_coin(qid)
|
||||
await matcher.finish(im, at_sender=True)
|
||||
await matcher.finish(
|
||||
MessageSegment.room_at_msg(content="{$@}" + f'{im}', at_list=wxid_list)
|
||||
)
|
||||
|
||||
|
||||
@all_bbscoin_recheck.handle()
|
||||
@handle_exception('米游币全部重获取')
|
||||
async def bbs_recheck(
|
||||
matcher: Matcher,
|
||||
):
|
||||
await matcher.send('已开始执行!可能需要较久时间!')
|
||||
await send_daily_mihoyo_bbs_sign()
|
||||
await matcher.finish('执行完成!')
|
||||
@register_menu(
|
||||
'重新获取米游币',
|
||||
'全部重获取',
|
||||
'重新运行所有自动获取米游币的任务',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'重新运行所有自动获取米游币的任务\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>全部重获取</ft>'
|
||||
),
|
||||
)
|
||||
async def bbs_recheck(bot: Bot, event: MessageEvent, matcher: Matcher):
|
||||
if await SUPERUSER(bot, event):
|
||||
await matcher.send('已开始执行!可能需要较久时间!')
|
||||
await send_daily_mihoyo_bbs_sign()
|
||||
await matcher.finish('执行完成!')
|
||||
else:
|
||||
return
|
||||
|
||||
|
||||
# 每日一点十六分进行米游币获取
|
||||
@ -54,12 +86,12 @@ async def send_daily_mihoyo_bbs_sign():
|
||||
im, im_private = await all_daily_mihoyo_bbs_coin()
|
||||
if im_private:
|
||||
for user_id in im_private:
|
||||
await bot.send_private_msg(
|
||||
user_id=user_id, message=im_private[user_id]
|
||||
await bot.call_api(
|
||||
'send_text', to_wxid=user_id, content=im_private[user_id]
|
||||
)
|
||||
await asyncio.sleep(5 + random.randint(1, 3))
|
||||
if await config_check('PrivateReport'):
|
||||
for qid in SUPERUSERS:
|
||||
await bot.call_api(api='send_private_msg', user_id=qid, message=im)
|
||||
await bot.call_api(api='send_text', to_wxid=qid, content=im)
|
||||
await asyncio.sleep(5 + random.randint(1, 3))
|
||||
logger.info('米游币获取已结束。')
|
||||
|
@ -1,18 +1,22 @@
|
||||
import asyncio
|
||||
from typing import Any, Tuple
|
||||
|
||||
from nonebot.log import logger
|
||||
from nonebot.matcher import Matcher
|
||||
from nonebot.params import RegexGroup
|
||||
from nonebot import on_regex, on_command
|
||||
from nonebot.adapters.qqguild import Bot, MessageEvent, MessageSegment
|
||||
from nonebot.adapters.ntchat import (
|
||||
Bot,
|
||||
MessageEvent,
|
||||
MessageSegment,
|
||||
TextMessageEvent,
|
||||
)
|
||||
|
||||
from ..config import priority
|
||||
from .get_lots_data import get_lots_msg
|
||||
from .get_meme_card import get_meme_img
|
||||
from .get_mys_data import get_task_detail
|
||||
from ..genshinuid_meta import register_menu
|
||||
from ..utils.nonebot2.rule import FullCommand
|
||||
from ..utils.message.cast_type import cast_to_int
|
||||
from ..utils.exception.handle_exception import handle_exception
|
||||
|
||||
get_task_adv = on_regex(
|
||||
@ -24,15 +28,33 @@ get_lots = on_command('御神签', priority=priority, rule=FullCommand())
|
||||
|
||||
@get_task_adv.handle()
|
||||
@handle_exception('任务攻略')
|
||||
@register_menu(
|
||||
'任务攻略',
|
||||
'任务xx',
|
||||
'查询某任务的攻略',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'查询指定任务或指定地区的攻略\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>{原神任务|任务|任务详情|任务攻略}</ft>'
|
||||
'<ft color=(238,120,0)>{</ft>'
|
||||
'<ft color=(0,148,200)>[任务名]</ft>'
|
||||
'<ft color=(238,120,0)>|须弥|层岩|海岛}</ft>\n'
|
||||
' \n'
|
||||
'示例:\n'
|
||||
'- <ft color=(238,120,0)>任务神樱大祓</ft>\n'
|
||||
'- <ft color=(238,120,0)>任务须弥</ft>'
|
||||
),
|
||||
)
|
||||
async def send_task_adv(
|
||||
bot: Bot,
|
||||
event: MessageEvent,
|
||||
event: TextMessageEvent,
|
||||
matcher: Matcher,
|
||||
args: Tuple[Any, ...] = RegexGroup(),
|
||||
):
|
||||
'''
|
||||
if str(args[2]) in ['须弥', '层岩', '海岛']:
|
||||
pass
|
||||
'''
|
||||
im = await get_region_task(str(args[2]))
|
||||
for i in im:
|
||||
await bot.call_api(
|
||||
@ -40,24 +62,44 @@ async def send_task_adv(
|
||||
)
|
||||
await asyncio.sleep(1)
|
||||
await matcher.finish()
|
||||
'''
|
||||
else:
|
||||
im = await get_task_detail(str(args[2]))
|
||||
await matcher.finish(im)
|
||||
'''
|
||||
im = await get_task_detail(str(args[2]))
|
||||
await matcher.finish(im)
|
||||
|
||||
|
||||
@get_meme.handle()
|
||||
@handle_exception('抽表情')
|
||||
@register_menu(
|
||||
'抽表情',
|
||||
'抽表情',
|
||||
'随机发送一张札记角色表情',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'随机发送一张札记角色表情\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>抽表情</ft>'
|
||||
),
|
||||
)
|
||||
async def send_meme_card(matcher: Matcher):
|
||||
logger.info('开始执行[抽表情]')
|
||||
img = await get_meme_img()
|
||||
await matcher.finish(MessageSegment.file_image(img))
|
||||
await matcher.finish(MessageSegment.image(img))
|
||||
|
||||
|
||||
@get_lots.handle()
|
||||
@handle_exception('御神签')
|
||||
@register_menu(
|
||||
'御神签',
|
||||
'御神签',
|
||||
'鸣神大社御神签',
|
||||
detail_des=(
|
||||
'介绍:\n' '抽一签鸣神大社御神签\n' ' \n' '指令:\n' '- <ft color=(238,120,0)>御神签</ft>'
|
||||
),
|
||||
)
|
||||
async def send_lots_data(matcher: Matcher, event: MessageEvent):
|
||||
qid = cast_to_int(event.author)
|
||||
qid = event.from_wxid
|
||||
logger.info('开始执行[御神签]')
|
||||
im = await get_lots_msg(qid)
|
||||
await matcher.finish(im)
|
||||
|
@ -1,13 +1,13 @@
|
||||
from nonebot import on_command
|
||||
from nonebot.log import logger
|
||||
from nonebot.matcher import Matcher
|
||||
from nonebot.adapters.qqguild import MessageEvent, MessageSegment
|
||||
from nonebot.adapters.ntchat import MessageEvent, MessageSegment
|
||||
|
||||
from .note_text import award
|
||||
from ..config import priority
|
||||
from .draw_note_card import draw_note_img
|
||||
from ..genshinuid_meta import register_menu
|
||||
from ..utils.nonebot2.rule import FullCommand
|
||||
from ..utils.message.cast_type import cast_to_int
|
||||
from ..utils.db_operation.db_operation import select_db
|
||||
from ..utils.message.error_reply import CK_HINT, UID_HINT
|
||||
from ..utils.exception.handle_exception import handle_exception
|
||||
@ -21,35 +21,69 @@ get_genshin_info = on_command(
|
||||
# 群聊内 每月统计 功能
|
||||
@monthly_data.handle()
|
||||
@handle_exception('每月统计', '获取/发送每月统计失败', '@未找到绑定信息\n' + CK_HINT)
|
||||
@register_menu(
|
||||
'文字札记',
|
||||
'每月统计',
|
||||
'文字形式米游社札记',
|
||||
detail_des=(
|
||||
'介绍:\n' '文字形式米游社札记\n' ' \n' '指令:\n' '- <ft color=(238,120,0)>每月统计</ft>'
|
||||
),
|
||||
)
|
||||
async def send_monthly_data(
|
||||
event: MessageEvent,
|
||||
matcher: Matcher,
|
||||
):
|
||||
qid = cast_to_int(event.author)
|
||||
logger.info('[每月统计]QQ号: {}'.format(qid))
|
||||
uid = await select_db(str(qid), mode='uid')
|
||||
qid = event.from_wxid
|
||||
wxid_list = []
|
||||
wxid_list.append(event.from_wxid)
|
||||
uid = await select_db(qid, mode='uid')
|
||||
if isinstance(uid, str):
|
||||
if '未找到绑定的UID' in uid:
|
||||
await matcher.finish(UID_HINT)
|
||||
await matcher.finish(
|
||||
MessageSegment.room_at_msg(
|
||||
content='{$@}' + UID_HINT, at_list=wxid_list
|
||||
)
|
||||
)
|
||||
else:
|
||||
await matcher.finish('发生未知错误...')
|
||||
im = await award(uid)
|
||||
await matcher.finish(im, at_sender=True)
|
||||
await matcher.finish(
|
||||
MessageSegment.room_at_msg(content="{$@}" + f'{im}', at_list=wxid_list)
|
||||
)
|
||||
|
||||
|
||||
# 群聊内 每月统计 功能
|
||||
@get_genshin_info.handle()
|
||||
@handle_exception('每月统计', '获取/发送每月统计失败', '@未找到绑定信息\n' + CK_HINT)
|
||||
@register_menu(
|
||||
'图片札记',
|
||||
'当前信息',
|
||||
'图片形式米游社札记',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'图片形式米游社札记\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>当前信息</ft>\n'
|
||||
'- <ft color=(125,125,125)>(原石)</ft><ft color=(238,120,0)>札记</ft>\n'
|
||||
'- <ft color=(238,120,0)>zj</ft>'
|
||||
),
|
||||
)
|
||||
async def send_monthly_pic(
|
||||
event: MessageEvent,
|
||||
matcher: Matcher,
|
||||
):
|
||||
qid = cast_to_int(event.author)
|
||||
logger.info('[原石札记]QQ号: {}'.format(qid))
|
||||
uid = await select_db(str(qid), mode='uid')
|
||||
qid = event.from_wxid
|
||||
wxid_list = []
|
||||
wxid_list.append(event.from_wxid)
|
||||
uid = await select_db(qid, mode='uid')
|
||||
if isinstance(uid, str):
|
||||
if '未找到绑定的UID' in uid:
|
||||
await matcher.finish(UID_HINT)
|
||||
await matcher.finish(
|
||||
MessageSegment.room_at_msg(
|
||||
content='{$@}' + UID_HINT, at_list=wxid_list
|
||||
)
|
||||
)
|
||||
else:
|
||||
await matcher.finish('发生未知错误...')
|
||||
logger.info(f'[原石札记] 开始绘制,UID: {uid}')
|
||||
@ -57,6 +91,6 @@ async def send_monthly_pic(
|
||||
if isinstance(im, str):
|
||||
await matcher.finish(im)
|
||||
elif isinstance(im, bytes):
|
||||
await matcher.finish(MessageSegment.file_image(im))
|
||||
await matcher.finish(MessageSegment.image(im))
|
||||
else:
|
||||
await matcher.finish('发生了未知错误,请联系管理员检查后台输出!')
|
||||
|
@ -1,20 +1,18 @@
|
||||
import asyncio
|
||||
|
||||
from nonebot.log import logger
|
||||
from nonebot.params import Depends
|
||||
from nonebot.matcher import Matcher
|
||||
from nonebot import get_bot, on_command
|
||||
from nonebot_plugin_apscheduler import scheduler
|
||||
from nonebot.adapters.qqguild import MessageEvent, MessageSegment
|
||||
from nonebot.adapters.ntchat import MessageSegment, TextMessageEvent
|
||||
|
||||
from .notice import get_notice_list
|
||||
from .resin_text import get_resin_text
|
||||
from .draw_resin_card import get_resin_img
|
||||
from ..genshinuid_meta import register_menu
|
||||
from ..utils.nonebot2.rule import FullCommand
|
||||
from ..utils.message.error_reply import UID_HINT
|
||||
from ..utils.message.cast_type import cast_to_int
|
||||
from ..utils.db_operation.db_operation import select_db
|
||||
from ..utils.message.get_image_and_at import ImageAndAt
|
||||
from ..utils.exception.handle_exception import handle_exception
|
||||
|
||||
notice_scheduler = scheduler
|
||||
@ -29,17 +27,30 @@ get_daily_info = on_command('当前状态', rule=FullCommand())
|
||||
|
||||
@get_daily_info.handle()
|
||||
@handle_exception('每日信息文字版')
|
||||
@register_menu(
|
||||
'文字实时便笺',
|
||||
'当前信息',
|
||||
'米游社实时便笺文字版',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'米游社实时便笺文字版\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>当前状态</ft>'
|
||||
),
|
||||
)
|
||||
async def send_daily_info(
|
||||
event: MessageEvent,
|
||||
event: TextMessageEvent,
|
||||
matcher: Matcher,
|
||||
custom: ImageAndAt = Depends(),
|
||||
):
|
||||
logger.info('开始执行[每日信息文字版]')
|
||||
|
||||
at = custom.get_first_at()
|
||||
qid = at or cast_to_int(event.author)
|
||||
if at:
|
||||
qid = at
|
||||
qid = event.from_wxid
|
||||
if event.at_user_list:
|
||||
for user in event.at_user_list:
|
||||
user = user.strip()
|
||||
if user != "":
|
||||
qid = user
|
||||
logger.info('[每日信息文字版]QQ号: {}'.format(qid))
|
||||
|
||||
uid: str = await select_db(qid, mode='uid') # type: ignore
|
||||
@ -85,23 +96,39 @@ async def notice_job():
|
||||
|
||||
@get_resin_info.handle()
|
||||
@handle_exception('每日信息')
|
||||
@register_menu(
|
||||
'图片实时便笺',
|
||||
'每日',
|
||||
'图片形式米游社实时便笺',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'图片形式米游社实时便笺\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>每日</ft>\n'
|
||||
'- <ft color=(238,120,0)>mr</ft>\n'
|
||||
'- <ft color=(238,120,0)>状态</ft>\n'
|
||||
'- <ft color=(125,125,125)>(实时)</ft><ft color=(238,120,0)>便笺</ft>\n'
|
||||
'- <ft color=(238,120,0)>便签</ft>'
|
||||
),
|
||||
)
|
||||
async def send_uid_info(
|
||||
event: MessageEvent,
|
||||
event: TextMessageEvent,
|
||||
matcher: Matcher,
|
||||
custom: ImageAndAt = Depends(),
|
||||
):
|
||||
logger.info('开始执行[每日信息]')
|
||||
|
||||
at = custom.get_first_at()
|
||||
qid = at or cast_to_int(event.author)
|
||||
if at:
|
||||
qid = at
|
||||
qid = event.from_wxid
|
||||
if event.at_user_list:
|
||||
for user in event.at_user_list:
|
||||
user = user.strip()
|
||||
if user != "":
|
||||
qid = user
|
||||
logger.info('[每日信息]QQ号: {}'.format(qid))
|
||||
qid = int(qid)
|
||||
im = await get_resin_img(qid)
|
||||
|
||||
im = await get_resin_img(qid) # type:ignore
|
||||
if isinstance(im, str):
|
||||
await matcher.finish(im)
|
||||
elif isinstance(im, bytes):
|
||||
await matcher.finish(MessageSegment.file_image(im))
|
||||
await matcher.finish(MessageSegment.image(im))
|
||||
else:
|
||||
await matcher.finish('发生了未知错误,请联系管理员检查后台输出!')
|
||||
|
@ -5,8 +5,9 @@ from nonebot import on_command
|
||||
from nonebot.log import logger
|
||||
from nonebot.matcher import Matcher
|
||||
from nonebot.permission import SUPERUSER
|
||||
from nonebot.adapters.qqguild import Bot, MessageEvent
|
||||
from nonebot.adapters.ntchat import Bot, TextMessageEvent
|
||||
|
||||
from ..genshinuid_meta import register_menu
|
||||
from ..utils.nonebot2.rule import FullCommand
|
||||
from ..utils.exception.handle_exception import handle_exception
|
||||
from ..utils.download_resource.download_all_resource import (
|
||||
@ -18,9 +19,22 @@ download_resource = on_command('下载全部资源', rule=FullCommand())
|
||||
|
||||
@download_resource.handle()
|
||||
@handle_exception('下载全部资源', '资源下载错误')
|
||||
@register_menu(
|
||||
'下载全部资源',
|
||||
'下载全部资源',
|
||||
'手动下载插件运行所需的资源',
|
||||
trigger_method='管理员指令',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'手动下载插件正常运行所需的资源(一般每次启动会自动检查并下载)\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>下载全部资源</ft>'
|
||||
),
|
||||
)
|
||||
async def send_download_resource_msg(
|
||||
bot: Bot,
|
||||
event: MessageEvent,
|
||||
event: TextMessageEvent,
|
||||
matcher: Matcher,
|
||||
):
|
||||
if not await SUPERUSER(bot, event):
|
||||
|
@ -3,16 +3,16 @@ import re
|
||||
from nonebot import on_command
|
||||
from nonebot.log import logger
|
||||
from nonebot.matcher import Matcher
|
||||
from nonebot.params import Depends, CommandArg
|
||||
from nonebot.adapters.qqguild import Message, MessageEvent, MessageSegment
|
||||
from nonebot.params import CommandArg
|
||||
from nonebot.adapters.ntchat.message import Message
|
||||
from nonebot.adapters.ntchat import MessageSegment, TextMessageEvent
|
||||
|
||||
from .get_regtime import calc_reg_time
|
||||
from .draw_roleinfo_card import draw_pic
|
||||
from ..genshinuid_meta import register_menu
|
||||
from ..utils.nonebot2.rule import FullCommand
|
||||
from ..utils.message.error_reply import UID_HINT
|
||||
from ..utils.message.cast_type import cast_to_int
|
||||
from ..utils.db_operation.db_operation import select_db
|
||||
from ..utils.message.get_image_and_at import ImageAndAt
|
||||
from ..utils.exception.handle_exception import handle_exception
|
||||
|
||||
get_role_info = on_command('uid', aliases={'查询'})
|
||||
@ -23,32 +23,62 @@ get_reg_time = on_command(
|
||||
|
||||
@get_role_info.handle()
|
||||
@handle_exception('查询角色信息')
|
||||
@register_menu(
|
||||
'查询帐号信息',
|
||||
'查询',
|
||||
'帐号基础数据与角色信息总览',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'查询帐号探索度、声望、宝箱收集、角色总览等等基础数据\n'
|
||||
'未绑定CK时最多只能查询8个角色信息\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>{查询|uid}</ft>'
|
||||
'<ft color=(125,125,125)>({@某人|[UID]})</ft>\n'
|
||||
'- <ft color=(238,120,0)>mys</ft>'
|
||||
'<ft color=(125,125,125)>({@某人|[米游社ID]})</ft>\n'
|
||||
'- <ft color=(238,120,0)>直接发送九位数UID</ft>\n'
|
||||
' \n'
|
||||
'示例:\n'
|
||||
'- <ft color=(238,120,0)>查询</ft>\n'
|
||||
'- <ft color=(238,120,0)>查询</ft><ft color=(0,123,67)>@无疑Wuyi</ft>\n'
|
||||
'- <ft color=(238,120,0)>uid123456789</ft>\n'
|
||||
'- <ft color=(238,120,0)>123456789</ft>'
|
||||
),
|
||||
)
|
||||
async def send_role_info(
|
||||
event: MessageEvent,
|
||||
event: TextMessageEvent,
|
||||
matcher: Matcher,
|
||||
args: Message = CommandArg(),
|
||||
custom: ImageAndAt = Depends(),
|
||||
):
|
||||
raw_mes = args.extract_plain_text().strip().replace(' ', '')
|
||||
name = ''.join(re.findall('[\u4e00-\u9fa5]', raw_mes))
|
||||
if name:
|
||||
return
|
||||
# 若@在文本中 先无视@后面内容 如果@前面有内容则无视并停止执行下方命令 避免与enka查询打架
|
||||
if "@" in raw_mes:
|
||||
name = ''.join(re.findall('^[\u4e00-\u9fa5]+', raw_mes.split("@")[0]))
|
||||
if name:
|
||||
return
|
||||
else:
|
||||
name = ''.join(re.findall('^[\u4e00-\u9fa5]+', raw_mes))
|
||||
if name:
|
||||
return
|
||||
|
||||
at = custom.get_first_at()
|
||||
qid = at or cast_to_int(event.author)
|
||||
if at:
|
||||
qid = at
|
||||
qid = str(qid)
|
||||
qid = event.from_wxid
|
||||
# 识别@的人 排除空
|
||||
if event.at_user_list:
|
||||
for user in event.at_user_list:
|
||||
user = user.strip()
|
||||
if user != "":
|
||||
qid = user
|
||||
|
||||
# 获取uid
|
||||
uid = re.findall(r'\d+', raw_mes)
|
||||
uid = re.findall(r'\d+', raw_mes.split("@")[0])
|
||||
if uid:
|
||||
uid = uid[0]
|
||||
else:
|
||||
uid = await select_db(qid, mode='uid')
|
||||
uid = str(uid)
|
||||
logger.info('开始执行[查询角色信息]')
|
||||
|
||||
logger.info('开始执行[查询角色信息]')
|
||||
logger.info('[查询角色信息]参数: {}'.format(args))
|
||||
logger.info('[查询角色信息]uid: {}'.format(uid))
|
||||
|
||||
@ -60,22 +90,23 @@ async def send_role_info(
|
||||
if isinstance(im, str):
|
||||
await matcher.finish(im)
|
||||
elif isinstance(im, bytes):
|
||||
await matcher.finish(MessageSegment.file_image(im))
|
||||
await matcher.finish(MessageSegment.image(im))
|
||||
else:
|
||||
await matcher.finish('发生了未知错误,请联系管理员检查后台输出!')
|
||||
|
||||
|
||||
@get_reg_time.handle()
|
||||
async def regtime(
|
||||
event: MessageEvent,
|
||||
event: TextMessageEvent,
|
||||
matcher: Matcher,
|
||||
custom: ImageAndAt = Depends(),
|
||||
):
|
||||
at = custom.get_first_at()
|
||||
qid = at or cast_to_int(event.author)
|
||||
if at:
|
||||
qid = at
|
||||
qid = str(qid)
|
||||
qid = event.from_wxid
|
||||
# 识别@的人 排除空
|
||||
if event.at_user_list:
|
||||
for user in event.at_user_list:
|
||||
user = user.strip()
|
||||
if user != "":
|
||||
qid = user
|
||||
|
||||
uid = await select_db(qid, mode='uid')
|
||||
uid = str(uid)
|
||||
|
@ -6,7 +6,7 @@ from nonebot.matcher import Matcher
|
||||
from nonebot import get_bot, on_command
|
||||
from nonebot.permission import SUPERUSER
|
||||
from nonebot_plugin_apscheduler import scheduler
|
||||
from nonebot.adapters.qqguild import MessageEvent
|
||||
from nonebot.adapters.ntchat import Bot, MessageEvent, MessageSegment
|
||||
|
||||
from ..config import priority
|
||||
|
||||
@ -15,17 +15,15 @@ try:
|
||||
except ImportError:
|
||||
from .sign import sign_in, daily_sign
|
||||
|
||||
from ..genshinuid_meta import register_menu
|
||||
from ..utils.nonebot2.rule import FullCommand
|
||||
from ..utils.message.cast_type import cast_to_int
|
||||
from ..utils.exception.handle_exception import handle_exception
|
||||
from ..utils.db_operation.db_operation import select_db, config_check
|
||||
|
||||
sign_scheduler = scheduler
|
||||
|
||||
get_sign = on_command('签到', priority=priority, rule=FullCommand())
|
||||
all_recheck = on_command(
|
||||
'全部重签', permission=SUPERUSER, priority=priority, rule=FullCommand()
|
||||
)
|
||||
all_recheck = on_command('全部重签', priority=priority, rule=FullCommand())
|
||||
|
||||
|
||||
# 每日零点半执行米游社原神签到
|
||||
@ -38,22 +36,52 @@ async def sign_at_night():
|
||||
# 群聊内 签到 功能
|
||||
@get_sign.handle()
|
||||
@handle_exception('签到')
|
||||
@register_menu(
|
||||
'手动米游社原神签到',
|
||||
'签到',
|
||||
'手动触发米游社原神签到任务',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'手动触发米游社原神签到任务\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>签到</ft>'
|
||||
),
|
||||
)
|
||||
async def get_sign_func(
|
||||
event: MessageEvent,
|
||||
matcher: Matcher,
|
||||
):
|
||||
logger.info('开始执行[签到]')
|
||||
qid = cast_to_int(event.author)
|
||||
qid = event.from_wxid
|
||||
wxid_list = []
|
||||
wxid_list.append(event.from_wxid)
|
||||
logger.info('[签到]QQ号: {}'.format(qid))
|
||||
uid = await select_db(str(qid), mode='uid')
|
||||
uid = await select_db(qid, mode='uid')
|
||||
logger.info('[签到]UID: {}'.format(uid))
|
||||
im = await sign_in(uid)
|
||||
await matcher.finish(im, at_sender=True)
|
||||
await matcher.finish(
|
||||
MessageSegment.room_at_msg(content="{$@}" + f'{im}', at_list=wxid_list)
|
||||
)
|
||||
|
||||
|
||||
@all_recheck.handle()
|
||||
@handle_exception('全部重签')
|
||||
async def recheck(matcher: Matcher):
|
||||
@register_menu(
|
||||
'米游社原神重签到',
|
||||
'全部重签',
|
||||
'重新运行所有自动米游社原神签到任务',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'重新运行所有自动米游社原神签到任务\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>全部重签</ft>'
|
||||
),
|
||||
)
|
||||
async def recheck(bot: Bot, event: MessageEvent, matcher: Matcher):
|
||||
if not await SUPERUSER(bot, event):
|
||||
return
|
||||
logger.info('开始执行[全部重签]')
|
||||
await matcher.send('已开始执行')
|
||||
await send_daily_sign()
|
||||
@ -73,9 +101,9 @@ async def send_daily_sign():
|
||||
for qid in private_msg_list:
|
||||
try:
|
||||
await bot.call_api(
|
||||
api='send_private_msg',
|
||||
user_id=qid,
|
||||
message=private_msg_list[qid],
|
||||
api='send_text',
|
||||
to_wxid=qid,
|
||||
content=private_msg_list[qid],
|
||||
)
|
||||
except Exception:
|
||||
logger.warning(f'[每日全部签到] QQ {qid} 私聊推送失败!')
|
||||
@ -97,13 +125,16 @@ async def send_daily_sign():
|
||||
report,
|
||||
)
|
||||
else:
|
||||
msg_title = group_msg_list[gid]['push_message']
|
||||
msg_title = group_msg_list[gid]['push_message'].rstrip()
|
||||
# 发送群消息
|
||||
at_wxid = []
|
||||
at_wxid.append(group_msg_list[gid]['wxid'])
|
||||
try:
|
||||
await bot.call_api(
|
||||
api='send_group_msg',
|
||||
group_id=gid,
|
||||
message=msg_title,
|
||||
api='send_room_at_msg',
|
||||
to_wxid=gid,
|
||||
at_list=at_wxid,
|
||||
content=msg_title,
|
||||
)
|
||||
except Exception:
|
||||
logger.warning(f'[每日全部签到]群 {gid} 推送失败!')
|
||||
|
@ -139,16 +139,18 @@ async def single_daily_sign(uid: str, gid: str, qid: str):
|
||||
# 如果失败, 则添加到推送列表
|
||||
if im.startswith('签到失败') or im.startswith('网络有点忙'):
|
||||
# 不用MessageSegment.at(row[2]),因为不方便移植
|
||||
message = f'[CQ:at,qq={qid}] {im}'
|
||||
message = f'UID:{uid} | {im}'
|
||||
group_msg_list[gid]['failed'] += 1
|
||||
group_msg_list[gid]['push_message'] += '\n' + message
|
||||
group_msg_list[gid]['push_message'] += message + '\n'
|
||||
else:
|
||||
group_msg_list[gid]['success'] += 1
|
||||
# 没有开启简洁签到, 则每条消息都要携带@信息
|
||||
else:
|
||||
# 不用MessageSegment.at(row[2]),因为不方便移植
|
||||
message = f'[CQ:at,qq={qid}] {im}'
|
||||
group_msg_list[gid]['push_message'] += '\n' + message
|
||||
# message = '{$@}' + f'UID:{uid} | {im}'
|
||||
message = f'UID:{uid} | {im}'
|
||||
group_msg_list[gid]['wxid'] = qid
|
||||
group_msg_list[gid]['push_message'] += message + '\n'
|
||||
group_msg_list[gid]['success'] -= 1
|
||||
|
||||
|
||||
|
@ -4,22 +4,26 @@ from nonebot.log import logger
|
||||
from nonebot.matcher import Matcher
|
||||
from nonebot.params import RegexGroup
|
||||
from nonebot.permission import SUPERUSER
|
||||
from nonebot import get_bot, on_regex, get_driver
|
||||
from nonebot.adapters.qqguild import Bot, MessageEvent, MessageSegment
|
||||
from nonebot import get_bot, on_regex, get_driver, on_command
|
||||
from nonebot.adapters.ntchat import Bot, MessageEvent, MessageSegment
|
||||
|
||||
from ..genshinuid_meta import register_menu
|
||||
from ..utils.nonebot2.rule import FullCommand
|
||||
from .draw_update_log import draw_update_log_img
|
||||
from ..utils.message.cast_type import cast_to_int
|
||||
from .restart import restart_message, restart_genshinuid
|
||||
|
||||
gs_restart = on_regex(r'^(gs)(重启)$')
|
||||
get_update_log = on_regex(r'更新记录')
|
||||
gs_restart = on_command('gs重启', rule=FullCommand())
|
||||
get_update_log = on_command('更新记录', rule=FullCommand())
|
||||
gs_update = on_regex(
|
||||
r'^(gs)(强行)?(强制)?(更新)$',
|
||||
block=True,
|
||||
)
|
||||
|
||||
|
||||
@get_driver().on_bot_connect
|
||||
driver = get_driver()
|
||||
|
||||
|
||||
@driver.on_bot_connect
|
||||
async def _():
|
||||
logger.info('检查遗留信息...')
|
||||
bot = get_bot()
|
||||
@ -28,35 +32,32 @@ async def _():
|
||||
return
|
||||
if update_log['send_type'] == 'group':
|
||||
await bot.call_api(
|
||||
api='send_group_msg',
|
||||
group_id=update_log['send_to'],
|
||||
message=update_log['msg'],
|
||||
api='send_room_at_msg',
|
||||
to_wxid=update_log['send_to'],
|
||||
content=update_log['msg'],
|
||||
)
|
||||
else:
|
||||
await bot.call_api(
|
||||
api='send_private_msg',
|
||||
user_id=update_log['send_to'],
|
||||
message=update_log['msg'],
|
||||
api='send_text',
|
||||
to_wxid=update_log['send_to'],
|
||||
content=update_log['msg'],
|
||||
)
|
||||
logger.info('遗留信息检查完毕!')
|
||||
|
||||
|
||||
@gs_restart.handle()
|
||||
async def send_restart_msg(
|
||||
bot: Bot,
|
||||
event: MessageEvent,
|
||||
matcher: Matcher,
|
||||
):
|
||||
if not await SUPERUSER(bot, event):
|
||||
return
|
||||
logger.warning('开始执行[重启]')
|
||||
send_id = cast_to_int(event.author)
|
||||
send_type = 'group'
|
||||
await matcher.send('正在执行[gs重启]...')
|
||||
await restart_genshinuid(send_type, str(send_id))
|
||||
|
||||
|
||||
@get_update_log.handle()
|
||||
@register_menu(
|
||||
'更新记录',
|
||||
'更新记录',
|
||||
'查看插件最近的更新记录',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'查看插件最近的有效Git更新记录\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>更新记录</ft>'
|
||||
),
|
||||
)
|
||||
async def send_updatelog_msg(
|
||||
matcher: Matcher,
|
||||
):
|
||||
@ -65,12 +66,57 @@ async def send_updatelog_msg(
|
||||
if isinstance(im, str):
|
||||
await matcher.finish(im)
|
||||
elif isinstance(im, bytes):
|
||||
await matcher.finish(MessageSegment.file_image(im))
|
||||
await matcher.finish(MessageSegment.image(im))
|
||||
else:
|
||||
await matcher.finish('发生了未知错误,请联系管理员检查后台输出!')
|
||||
|
||||
|
||||
@gs_restart.handle()
|
||||
@register_menu(
|
||||
'重启Bot',
|
||||
'gs重启',
|
||||
'重启Bot框架',
|
||||
trigger_method='超级用户指令',
|
||||
detail_des=(
|
||||
'介绍:\n' '重启Bot框架\n' ' \n' '指令:\n' '- <ft color=(238,120,0)>gs重启</ft>'
|
||||
),
|
||||
)
|
||||
async def send_restart_msg(
|
||||
bot: Bot,
|
||||
event: MessageEvent,
|
||||
matcher: Matcher,
|
||||
):
|
||||
if not await SUPERUSER(bot, event):
|
||||
return
|
||||
logger.warning('开始执行[重启]')
|
||||
qid = event.from_wxid
|
||||
if len(event.get_session_id().split('_')) == 3:
|
||||
send_id = event.get_session_id().split('_')[1]
|
||||
send_type = 'group'
|
||||
else:
|
||||
send_id = qid
|
||||
send_type = 'private'
|
||||
await matcher.send('正在执行[gs重启]...')
|
||||
await restart_genshinuid(send_type, str(send_id))
|
||||
|
||||
|
||||
@gs_update.handle()
|
||||
@register_menu(
|
||||
'更新插件',
|
||||
'gs更新',
|
||||
'手动更新插件',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'手动更新插件(执行 git pull)\n'
|
||||
'每加上一个可选参数,执行等级加1\n'
|
||||
'当执行等级≥1时会还原上次更改,等级≥2时会清空暂存\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>gs</ft>'
|
||||
'<ft color=(125,125,125)>(强行)(强制)</ft>'
|
||||
'<ft color=(238,120,0)>更新</ft>'
|
||||
),
|
||||
)
|
||||
async def send_update_msg(
|
||||
bot: Bot,
|
||||
event: MessageEvent,
|
||||
@ -92,6 +138,6 @@ async def send_update_msg(
|
||||
if isinstance(im, str):
|
||||
await matcher.finish(im)
|
||||
elif isinstance(im, bytes):
|
||||
await matcher.finish(MessageSegment.file_image(im))
|
||||
await matcher.finish(MessageSegment.image(im))
|
||||
else:
|
||||
await matcher.finish('发生了未知错误,请联系管理员检查后台输出!')
|
||||
|
@ -6,26 +6,39 @@ from nonebot.matcher import Matcher
|
||||
from nonebot import on_regex, on_command
|
||||
from nonebot.permission import SUPERUSER
|
||||
from nonebot.params import CommandArg, RegexGroup
|
||||
from nonebot.adapters.qqguild import Message, MessageEvent, MessageSegment
|
||||
from nonebot.adapters.ntchat.message import Message
|
||||
from nonebot.adapters.ntchat.permission import PRIVATE
|
||||
from nonebot.adapters.ntchat import (
|
||||
Bot,
|
||||
MessageEvent,
|
||||
MessageSegment,
|
||||
TextMessageEvent,
|
||||
)
|
||||
|
||||
from ..config import priority
|
||||
from .topup import GOODS, topup_
|
||||
from .qrlogin import qrcode_login
|
||||
from ..utils.nonebot2.perm import DIRECT
|
||||
from .get_ck_help_msg import get_ck_help
|
||||
from .draw_user_card import get_user_card
|
||||
from ..genshinuid_meta import register_menu
|
||||
from ..utils.nonebot2.rule import FullCommand
|
||||
from ..utils.message.cast_type import cast_to_int
|
||||
from .get_ck_help_msg import get_ck_help, get_qr_help
|
||||
from ..utils.exception.handle_exception import handle_exception
|
||||
from .add_ck import deal_ck, get_ck_by_stoken, get_ck_by_all_stoken
|
||||
from ..utils.db_operation.db_operation import bind_db, delete_db, switch_db
|
||||
|
||||
add_cookie = on_command('添加', permission=DIRECT)
|
||||
add_cookie = on_command('添加', permission=PRIVATE)
|
||||
get_ck_msg = on_command(
|
||||
'绑定ck说明',
|
||||
aliases={'ck帮助', '绑定ck'},
|
||||
block=True,
|
||||
rule=FullCommand(),
|
||||
)
|
||||
get_qr_msg = on_command(
|
||||
'扫码登录说明',
|
||||
aliases={'扫码帮助', '登录帮助', '登陆帮助'},
|
||||
block=True,
|
||||
rule=FullCommand(),
|
||||
)
|
||||
bind_info = on_command(
|
||||
'绑定信息', priority=priority, block=True, rule=FullCommand()
|
||||
)
|
||||
@ -50,9 +63,42 @@ bind = on_regex(
|
||||
get_qrcode_login = on_command(
|
||||
'扫码登录',
|
||||
aliases={'扫码登陆', '扫码登入'},
|
||||
permission=DIRECT,
|
||||
rule=FullCommand(),
|
||||
)
|
||||
get_topup = on_command(
|
||||
'gsrc', priority=priority, block=True, aliases={'原神充值', 'pay'}
|
||||
)
|
||||
|
||||
|
||||
@get_topup.handle()
|
||||
async def send_topup(
|
||||
matcher: Matcher, event: TextMessageEvent, args: Message = CommandArg()
|
||||
):
|
||||
# 获取被@的Wxid,排除""
|
||||
qid = event.from_wxid
|
||||
if event.at_user_list:
|
||||
for user in event.at_user_list:
|
||||
user = user.strip()
|
||||
if user != "":
|
||||
qid = user
|
||||
|
||||
goods_id, method = 0, "alipay"
|
||||
for s in str(args).split():
|
||||
# 支持指定支付方式
|
||||
if "微信" in s or "wx" in s:
|
||||
method = "weixin"
|
||||
continue
|
||||
if "支付宝" in s or "zfb" in s:
|
||||
method = "alipay"
|
||||
# 输入物品别名识别
|
||||
for gId, gData in GOODS.items():
|
||||
if (s == gId) or (s in gData["aliases"]):
|
||||
goods_id = gId
|
||||
break
|
||||
group_id = event.room_wxid
|
||||
await matcher.finish(
|
||||
await topup_(matcher, qid, group_id, goods_id, method)
|
||||
)
|
||||
|
||||
|
||||
@refresh_all_ck.handle()
|
||||
@ -72,70 +118,136 @@ async def send_refresh_ck_msg(
|
||||
matcher: Matcher,
|
||||
):
|
||||
logger.info('开始执行[刷新CK]')
|
||||
qid = cast_to_int(event.author)
|
||||
qid = event.from_wxid
|
||||
im = await get_ck_by_stoken(qid)
|
||||
if isinstance(im, str):
|
||||
await matcher.finish(im)
|
||||
await matcher.finish(MessageSegment.file_image(im))
|
||||
await matcher.finish(MessageSegment.image(im))
|
||||
|
||||
|
||||
@get_qrcode_login.handle()
|
||||
async def send_qrcode_login(
|
||||
bot: Bot,
|
||||
event: MessageEvent,
|
||||
matcher: Matcher,
|
||||
):
|
||||
logger.info('开始执行[扫码登陆]')
|
||||
qid = cast_to_int(event.author)
|
||||
qid = event.from_wxid
|
||||
im = await qrcode_login(matcher, qid)
|
||||
if not im:
|
||||
return
|
||||
im = await deal_ck(im, qid)
|
||||
if isinstance(im, str):
|
||||
await matcher.finish(im)
|
||||
await matcher.finish(MessageSegment.file_image(im))
|
||||
await matcher.finish(MessageSegment.image(im))
|
||||
|
||||
|
||||
@bind_info.handle()
|
||||
@register_menu(
|
||||
'绑定状态',
|
||||
'绑定信息',
|
||||
'查询你绑定UID的绑定和推送状态',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'查询你绑定的UID列表以及它们的CK、SK绑定状态和推送设置\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>绑定信息</ft>'
|
||||
),
|
||||
)
|
||||
async def send_bind_card(
|
||||
event: MessageEvent,
|
||||
matcher: Matcher,
|
||||
):
|
||||
logger.info('开始执行[查询用户绑定状态]')
|
||||
qid = cast_to_int(event.author)
|
||||
if qid is None:
|
||||
await matcher.finish('QID为空,请重试!')
|
||||
im = await get_user_card(str(qid))
|
||||
qid = event.from_wxid
|
||||
im = await get_user_card(qid)
|
||||
logger.info('[查询用户绑定状态]完成!等待图片发送中...')
|
||||
await matcher.finish(MessageSegment.file_image(im))
|
||||
await matcher.finish(MessageSegment.image(im))
|
||||
|
||||
|
||||
@add_cookie.handle()
|
||||
@handle_exception('Cookie', '校验失败!请输入正确的Cookies!')
|
||||
@register_menu(
|
||||
'绑定CK、SK',
|
||||
'添加[CK或SK]',
|
||||
'绑定你的Cookies以及Stoken',
|
||||
trigger_method='好友私聊指令',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'绑定你的Cookies以及Stoken\n'
|
||||
'Cookies (CK):米游社Cookies;Stoken (SK):米哈游通行证Cookies\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>添加</ft><ft color=(0,148,200)>[CK或SK]</ft>'
|
||||
),
|
||||
)
|
||||
async def send_add_ck_msg(
|
||||
event: MessageEvent, matcher: Matcher, args: Message = CommandArg()
|
||||
):
|
||||
mes = args.extract_plain_text().strip().replace(' ', '')
|
||||
qid = cast_to_int(event.author)
|
||||
if qid is None:
|
||||
await matcher.finish('QID为空,请重试!')
|
||||
qid = str(qid)
|
||||
qid = event.from_wxid
|
||||
im = await deal_ck(mes, qid)
|
||||
if isinstance(im, str):
|
||||
await matcher.finish(im)
|
||||
await matcher.finish(MessageSegment.file_image(im))
|
||||
await matcher.finish(MessageSegment.image(im))
|
||||
|
||||
|
||||
# 群聊内 绑定uid或者mysid 的命令,会绑定至当前qq号上
|
||||
@bind.handle()
|
||||
@handle_exception('绑定ID', '绑定ID异常')
|
||||
@register_menu(
|
||||
'绑定UID',
|
||||
'绑定xx',
|
||||
'绑定原神UID或米游社UID',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'绑定原神UID或米游社UID\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>绑定'
|
||||
'{uid</ft><ft color=(0,148,200)>[原神UID]</ft>'
|
||||
'<ft color=(238,120,0)>|mys</ft><ft color=(0,148,200)>[米游社UID]</ft>'
|
||||
'<ft color=(238,120,0)>}</ft>'
|
||||
),
|
||||
)
|
||||
@register_menu(
|
||||
'解绑UID',
|
||||
'解绑xx',
|
||||
'解绑原神UID或米游社UID',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'解绑原神UID或米游社UID\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>{解绑|删除}'
|
||||
'{uid</ft><ft color=(0,148,200)>[原神UID]</ft>'
|
||||
'<ft color=(238,120,0)>|mys</ft><ft color=(0,148,200)>[米游社UID]</ft>'
|
||||
'<ft color=(238,120,0)>}</ft>'
|
||||
),
|
||||
)
|
||||
@register_menu(
|
||||
'切换UID',
|
||||
'切换xx',
|
||||
'切换当前原神UID或米游社UID',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'切换当前原神UID或米游社UID\n'
|
||||
'绑定一个UID的情况下无法切换\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>切换'
|
||||
'{uid</ft><ft color=(0,148,200)>[原神UID]</ft>'
|
||||
'<ft color=(238,120,0)>|mys</ft><ft color=(0,148,200)>[米游社UID]</ft>'
|
||||
'<ft color=(238,120,0)>}</ft>'
|
||||
),
|
||||
)
|
||||
async def send_link_uid_msg(
|
||||
event: MessageEvent, matcher: Matcher, args: Tuple[Any, ...] = RegexGroup()
|
||||
):
|
||||
logger.info('开始执行[绑定/解绑用户信息]')
|
||||
logger.info('[绑定/解绑]参数: {}'.format(args))
|
||||
qid = cast_to_int(event.author)
|
||||
if qid is None:
|
||||
await matcher.finish('QID为空,请重试!')
|
||||
qid = event.from_wxid
|
||||
wxid_list = []
|
||||
wxid_list.append(event.from_wxid)
|
||||
logger.info('[绑定/解绑]UserID: {}'.format(qid))
|
||||
|
||||
if args[0] in ('绑定'):
|
||||
@ -143,17 +255,19 @@ async def send_link_uid_msg(
|
||||
await matcher.finish('请输入正确的uid或者mysid!')
|
||||
|
||||
if args[1] in ('uid', 'UID'):
|
||||
im = await bind_db(str(qid), args[2])
|
||||
im = await bind_db(qid, args[2])
|
||||
else:
|
||||
im = await bind_db(str(qid), None, args[2])
|
||||
im = await bind_db(qid, None, args[2])
|
||||
elif args[0] in ('切换'):
|
||||
im = await switch_db(str(qid), args[2])
|
||||
im = await switch_db(qid, args[2])
|
||||
else:
|
||||
if args[1] in ('uid', 'UID'):
|
||||
im = await delete_db(str(qid), {'UID': args[2]})
|
||||
im = await delete_db(qid, {'UID': args[2]})
|
||||
else:
|
||||
im = await delete_db(str(qid), {'MYSID': args[2]})
|
||||
await matcher.finish(im, at_sender=True)
|
||||
im = await delete_db(qid, {'MYSID': args[2]})
|
||||
await matcher.finish(
|
||||
MessageSegment.room_at_msg(content="{$@}" + f'{im}', at_list=wxid_list)
|
||||
)
|
||||
|
||||
|
||||
@get_ck_msg.handle()
|
||||
@ -162,3 +276,12 @@ async def send_ck_help(matcher: Matcher):
|
||||
for msg in msg_list:
|
||||
await matcher.send(msg)
|
||||
await asyncio.sleep(0.5)
|
||||
|
||||
|
||||
@get_qr_msg.handle()
|
||||
async def send_qr_help(matcher: Matcher):
|
||||
msg_list = await get_qr_help()
|
||||
for msg in msg_list:
|
||||
await matcher.send(msg)
|
||||
await asyncio.sleep(0.5)
|
||||
await asyncio.sleep(0.5)
|
||||
|
@ -55,7 +55,7 @@ async def get_ck_by_all_stoken():
|
||||
return im
|
||||
|
||||
|
||||
async def get_ck_by_stoken(qid: int):
|
||||
async def get_ck_by_stoken(qid: str):
|
||||
uid_list: List = await select_db(qid, mode='list') # type: ignore
|
||||
uid_dict = {uid: qid for uid in uid_list}
|
||||
im = await refresh_ck_by_uid_list(uid_dict)
|
||||
|
241
GenshinUID/genshinuid_user/draw_topup_img.py
Normal file
241
GenshinUID/genshinuid_user/draw_topup_img.py
Normal file
@ -0,0 +1,241 @@
|
||||
from io import BytesIO
|
||||
from time import strftime, localtime
|
||||
|
||||
from httpx import AsyncClient
|
||||
from PIL import Image, ImageDraw, ImageFont
|
||||
|
||||
from ..utils.genshin_fonts.genshin_fonts import FONT_ORIGIN_PATH
|
||||
|
||||
|
||||
def font(size: int) -> ImageFont.FreeTypeFont:
|
||||
"""Pillow 绘制字体设置"""
|
||||
return ImageFont.truetype(str(FONT_ORIGIN_PATH), size=size)
|
||||
|
||||
|
||||
# 支付宝充值图片绘制
|
||||
async def draw_ali(
|
||||
uid,
|
||||
item_info: str,
|
||||
item_price: str,
|
||||
item_order_no: str,
|
||||
qrcode,
|
||||
item_icon: str,
|
||||
item_create_time: int,
|
||||
item_id: str,
|
||||
) -> bytes:
|
||||
"""充值图片绘制"""
|
||||
async with AsyncClient() as client:
|
||||
_img = await client.get(item_icon, timeout=10.0)
|
||||
itemImg = Image.open(BytesIO(_img.content)).convert("RGBA")
|
||||
|
||||
themeColor = "#1678ff"
|
||||
warning = 20 if item_id == 'ys_chn_blessofmoon_tier5' else 0
|
||||
res = Image.new("RGBA", (450, 530), themeColor)
|
||||
drawer = ImageDraw.Draw(res)
|
||||
resample = getattr(Image, "Resampling", Image).LANCZOS
|
||||
|
||||
# 头部矩形背景
|
||||
drawer.rectangle(
|
||||
(75, 50 - warning, 375 - 1, 150 - warning), fill="#E5F9FF", width=0
|
||||
)
|
||||
# 商品图片
|
||||
item = itemImg.resize((90, 90), resample=resample)
|
||||
res.paste(item, (80, 55 - warning), item)
|
||||
# 二维码图片
|
||||
qrcode = Image.open(qrcode)
|
||||
qrcode = qrcode.resize((300, 300), resample=resample)
|
||||
res.paste(qrcode, (75, 150 + warning), qrcode)
|
||||
# 商品名称
|
||||
drawer.text(
|
||||
(
|
||||
int(175 + (195 - font(25).getlength(item_info)) / 2),
|
||||
int(70 - warning + (30 - font(25).getbbox(item_info)[-1]) / 2),
|
||||
),
|
||||
item_info,
|
||||
fill="#000000",
|
||||
font=font(25),
|
||||
)
|
||||
# 价格
|
||||
drawer.text(
|
||||
(
|
||||
int(175 + (195 - font(25).getlength(item_price)) / 2),
|
||||
int(105 - warning + (30 - font(25).getbbox(item_price)[-1]) / 2),
|
||||
),
|
||||
item_price,
|
||||
fill="#000000",
|
||||
font=font(25),
|
||||
)
|
||||
# 商品充值 UID
|
||||
drawer.text(
|
||||
(
|
||||
int((460 - font(15).getlength(f"充值到 UID{uid}")) / 2),
|
||||
int(
|
||||
155
|
||||
+ warning
|
||||
+ (20 - font(15).getbbox(f"充值到 UID{uid}")[-1]) / 2
|
||||
),
|
||||
),
|
||||
f"充值到 UID{uid}",
|
||||
fill="#333333",
|
||||
font=font(15),
|
||||
)
|
||||
# 月卡相关商品警告
|
||||
if warning:
|
||||
# 首部矩形背景
|
||||
drawer.rectangle((75, 130, 375 - 1, 170), fill="#eeeeee", width=0)
|
||||
# 转换警告文字
|
||||
warning_text = "特殊情况将直接返还 330 创世结晶"
|
||||
drawer.text(
|
||||
(
|
||||
int((450 - font(15).getlength(warning_text)) / 2),
|
||||
int(130 + (40 - font(15).getbbox(warning_text)[-1]) / 2),
|
||||
),
|
||||
warning_text,
|
||||
fill="#ff5652",
|
||||
font=font(15),
|
||||
)
|
||||
# 图片生成时间
|
||||
timestamp = strftime("%Y-%m-%d %H:%M:%S", localtime(int(item_create_time)))
|
||||
drawer.text(
|
||||
(int((460 - font(15).getlength(timestamp)) / 2), 425 + warning),
|
||||
timestamp,
|
||||
fill="#1678ff",
|
||||
font=font(15),
|
||||
)
|
||||
# 账单信息
|
||||
ticket = f"支付宝账单编号 {item_order_no}"
|
||||
drawer.text(
|
||||
(int((450 - font(15).getlength(ticket)) / 2), 460 + warning),
|
||||
ticket,
|
||||
fill="#ffffff",
|
||||
font=font(15),
|
||||
)
|
||||
# 免责声明
|
||||
drawer.text(
|
||||
(
|
||||
int(
|
||||
(
|
||||
410
|
||||
- font(15).getlength(
|
||||
"免责声明:该充值接口由米游社提供,不对充值结果负责。\n请在充值前仔细阅读米哈游的充值条款。"
|
||||
)
|
||||
/ 2
|
||||
)
|
||||
),
|
||||
490 + warning,
|
||||
),
|
||||
"免责声明:该充值接口由米游社提供,不对充值结果负责。\n 请在充值前仔细阅读米哈游的充值条款。",
|
||||
fill="#FFA500",
|
||||
font=font(12),
|
||||
)
|
||||
buf = BytesIO()
|
||||
res.convert("RGB").save(buf, format="PNG")
|
||||
return buf.getvalue()
|
||||
|
||||
|
||||
# 微信充值图片绘制
|
||||
async def draw_wx(
|
||||
uid,
|
||||
item_info: str,
|
||||
item_price: str,
|
||||
item_order_no: str,
|
||||
item_icon: str,
|
||||
item_create_time: int,
|
||||
item_id: str,
|
||||
) -> bytes:
|
||||
"""充值图片绘制"""
|
||||
async with AsyncClient() as client:
|
||||
_img = await client.get(item_icon, timeout=10.0)
|
||||
itemImg = Image.open(BytesIO(_img.content)).convert("RGBA")
|
||||
|
||||
themeColor = "#29ac66"
|
||||
warning = 20 if item_id == 'ys_chn_blessofmoon_tier5' else 0
|
||||
res = Image.new("RGBA", (450, 200), themeColor)
|
||||
drawer = ImageDraw.Draw(res)
|
||||
resample = getattr(Image, "Resampling", Image).LANCZOS
|
||||
left = (450 - 370) / 2 # (图片宽度 - 矩形宽度) / 2
|
||||
top = (200 - 130) / 2 # (图片高度 - 矩形高度) / 2
|
||||
# 头部矩形背景
|
||||
drawer.rectangle(
|
||||
(
|
||||
left,
|
||||
top - warning,
|
||||
left + 370,
|
||||
top + 130 - warning,
|
||||
), # 使用新的左上角和右下角的坐标
|
||||
fill="#E5F9FF", # 保留原有的填充色
|
||||
width=0, # 保留原有的边框宽度
|
||||
)
|
||||
|
||||
# 商品图片
|
||||
item = itemImg.resize((110, 110), resample=resample)
|
||||
res.paste(item, (55, 50 - warning), item)
|
||||
# 商品名称
|
||||
drawer.text(
|
||||
(
|
||||
int(175 + (215 - font(25).getlength(item_info)) / 2),
|
||||
int(50 - warning + (30 - font(25).getbbox(item_info)[-1]) / 2),
|
||||
),
|
||||
item_info,
|
||||
fill="#000000",
|
||||
font=font(25),
|
||||
)
|
||||
# 价格
|
||||
drawer.text(
|
||||
(
|
||||
int(180 + (195 - font(25).getlength(item_price)) / 2),
|
||||
int(80 - warning + (30 - font(25).getbbox(item_price)[-1]) / 2),
|
||||
),
|
||||
item_price,
|
||||
fill="#000000",
|
||||
font=font(25),
|
||||
)
|
||||
# 商品充值 UID
|
||||
drawer.text(
|
||||
(
|
||||
int(185 + (195 - font(15).getlength(f"充值到 UID{uid}")) / 2),
|
||||
int(
|
||||
120
|
||||
- warning
|
||||
+ (20 - font(15).getbbox(f"充值到 UID{uid}")[-1]) / 2
|
||||
),
|
||||
),
|
||||
f"充值到 UID{uid}",
|
||||
fill="#000000",
|
||||
font=font(15),
|
||||
)
|
||||
# 图片生成时间
|
||||
timestamp = strftime("%Y-%m-%d %H:%M:%S", localtime(int(item_create_time)))
|
||||
drawer.text(
|
||||
(int(185 + (195 - font(15).getlength(timestamp)) / 2), 140 - warning),
|
||||
timestamp,
|
||||
fill="#29ac66",
|
||||
font=font(15),
|
||||
)
|
||||
if warning:
|
||||
# 首部矩形背景
|
||||
drawer.rectangle(
|
||||
(left, top + 110, left + 370, top + 130), fill="#eeeeee", width=0
|
||||
)
|
||||
# 转换警告文字
|
||||
warning_text = "特殊情况将直接返还 330 创世结晶"
|
||||
drawer.text(
|
||||
(
|
||||
int((450 - font(15).getlength(warning_text)) / 2),
|
||||
int(135 + (40 - font(15).getbbox(warning_text)[-1]) / 2),
|
||||
),
|
||||
warning_text,
|
||||
fill="#ff5652",
|
||||
font=font(15),
|
||||
)
|
||||
# 账单信息
|
||||
ticket = f"微信支付账单编号 {item_order_no}"
|
||||
drawer.text(
|
||||
(int((450 - font(15).getlength(ticket)) / 2), 170),
|
||||
ticket,
|
||||
fill="#ffffff",
|
||||
font=font(15),
|
||||
)
|
||||
buf = BytesIO()
|
||||
res.convert("RGB").save(buf, format="PNG")
|
||||
return buf.getvalue()
|
@ -38,7 +38,7 @@ async def get_user_card(qid: str) -> bytes:
|
||||
uid_title = Image.open(TEXT_PATH / 'uid_title.png')
|
||||
uid_title_draw = ImageDraw.Draw(uid_title)
|
||||
uid_title_draw.text(
|
||||
(47, 70), f'频道ID {str(qid)}', (106, 100, 89), font=gs_font_26
|
||||
(47, 70), f'QQ号{str(qid)}', (106, 100, 89), font=gs_font_26
|
||||
)
|
||||
img.paste(uid_title, (0, 50), uid_title)
|
||||
img.paste(uid_hint, (0, 145 + len(uid_list) * 210), uid_hint)
|
||||
|
@ -26,6 +26,10 @@ http://user.mihoyo.com/(国服)
|
||||
然后在和机器人的私聊窗口,粘贴发送即可
|
||||
'''
|
||||
|
||||
QRL = '''请在群里发送【扫码登录】并用米游社/原神进行扫码绑定
|
||||
如果使用该功能,请先绑定UID后再进行登录
|
||||
注意不要乱扫他人二维码'''
|
||||
|
||||
|
||||
async def get_ck_help() -> List:
|
||||
msg_list = []
|
||||
@ -34,3 +38,9 @@ async def get_ck_help() -> List:
|
||||
msg_list.append(CK_URL)
|
||||
msg_list.append(SK_URL)
|
||||
return msg_list
|
||||
|
||||
|
||||
async def get_qr_help() -> List:
|
||||
msg_list = []
|
||||
msg_list.append(QRL)
|
||||
return msg_list
|
||||
|
@ -3,27 +3,32 @@ import json
|
||||
import base64
|
||||
import asyncio
|
||||
from http.cookies import SimpleCookie
|
||||
from typing import Any, Tuple, Union, Literal
|
||||
from typing import Any, List, Tuple, Union, Literal, NoReturn
|
||||
|
||||
import qrcode
|
||||
from nonebot.log import logger
|
||||
from nonebot.matcher import Matcher
|
||||
from qrcode.constants import ERROR_CORRECT_L
|
||||
from nonebot.adapters.qqguild import MessageSegment
|
||||
from nonebot.adapters.ntchat import MessageSegment
|
||||
|
||||
from ..utils.message.error_reply import UID_HINT
|
||||
from ..utils.db_operation.db_operation import select_db
|
||||
from ..utils.mhy_api.get_mhy_data import (
|
||||
check_qrcode,
|
||||
get_cookie_token,
|
||||
create_qrcode_url,
|
||||
get_mihoyo_bbs_info,
|
||||
get_stoken_by_game_token,
|
||||
get_cookie_token_by_stoken,
|
||||
)
|
||||
|
||||
disnote = '''免责声明:您将通过扫码完成获取米游社sk以及ck。
|
||||
本Bot将不会保存您的登录状态。
|
||||
我方仅提供米游社查询及相关游戏内容服务
|
||||
disnote = '''免责声明:您将通过扫码完成获取米游社sk以及ck。
|
||||
登录米游社相当于将账号授权于机器人,可能会带来未知的账号风险。
|
||||
若您的账号封禁、被盗等处罚与我方无关。
|
||||
害怕风险请勿扫码!
|
||||
'''
|
||||
登录后即代表您同意机器人使用协议并知晓会带来未知的账号风险!
|
||||
若想取消授权,请到米游社退出登录以清除机器人绑定的登录状态。
|
||||
|
||||
请用米游社/原神扫描下方二维码登录:'''
|
||||
|
||||
|
||||
def get_qrcode_base64(url):
|
||||
@ -61,40 +66,82 @@ async def refresh(
|
||||
continue
|
||||
if status_data['data']['stat'] == 'Confirmed':
|
||||
logger.info('二维码已确认')
|
||||
# print(status_data['data']['payload']['raw'])
|
||||
break
|
||||
return True, json.loads(status_data['data']['payload']['raw'])
|
||||
|
||||
|
||||
async def qrcode_login(matcher: Matcher, user_id) -> str:
|
||||
async def send_group_msg(msg: str, at_list: List) -> NoReturn:
|
||||
await matcher.finish(
|
||||
MessageSegment.room_at_msg(content=msg, at_list=at_list)
|
||||
)
|
||||
|
||||
wxid_list = []
|
||||
wxid_list.append(user_id)
|
||||
code_data = await create_qrcode_url()
|
||||
try:
|
||||
await matcher.send(
|
||||
MessageSegment.file_image(get_qrcode_base64(code_data["url"])) # type: ignore
|
||||
MessageSegment.image(
|
||||
f'base64://{get_qrcode_base64(code_data["url"])}'
|
||||
)
|
||||
)
|
||||
await matcher.send('请绑定UID之后使用米游社扫描上方二维码登录')
|
||||
await matcher.send(disnote)
|
||||
except Exception as e:
|
||||
logger.debug(e)
|
||||
await matcher.send(
|
||||
MessageSegment.room_at_msg(
|
||||
content='{$@}' + disnote, at_list=wxid_list
|
||||
)
|
||||
)
|
||||
except Exception:
|
||||
logger.warning('[扫码登录] {user_id} 图片发送失败')
|
||||
status, game_token_data = await refresh(code_data)
|
||||
if status:
|
||||
assert game_token_data is not None # 骗过 pyright
|
||||
logger.info('game_token获取成功')
|
||||
logger.info('[扫码登录]game_token获取成功')
|
||||
cookie_token = await get_cookie_token(**game_token_data)
|
||||
stoken_data = await get_stoken_by_game_token(
|
||||
account_id=int(game_token_data['uid']),
|
||||
game_token=game_token_data['token'],
|
||||
)
|
||||
return SimpleCookie(
|
||||
{
|
||||
'stoken_v2': stoken_data['data']['token']['token'],
|
||||
'stuid': stoken_data['data']['user_info']['aid'],
|
||||
'mid': stoken_data['data']['user_info']['mid'],
|
||||
'cookie_token': cookie_token['data']['cookie_token'],
|
||||
}
|
||||
).output(header='', sep=';')
|
||||
account_id = game_token_data['uid']
|
||||
stoken = stoken_data['data']['token']['token']
|
||||
mid = stoken_data['data']['user_info']['mid']
|
||||
app_cookie = f'stuid={account_id};stoken={stoken};mid={mid}'
|
||||
ck = await get_cookie_token_by_stoken(stoken, account_id, app_cookie)
|
||||
ck = ck['data']['cookie_token']
|
||||
cookie_check = f'account_id={account_id};cookie_token={ck}'
|
||||
get_uid = await get_mihoyo_bbs_info(account_id, cookie_check)
|
||||
im = None
|
||||
if get_uid:
|
||||
for i in get_uid['data']['list']:
|
||||
if i['game_id'] == 2:
|
||||
uid_check = i['game_role_id']
|
||||
break
|
||||
else:
|
||||
im = f'你的米游社账号{account_id}尚未绑定原神账号,请前往米游社操作!'
|
||||
await send_group_msg(im, wxid_list)
|
||||
else:
|
||||
im = '请求失败, 请稍后再试...'
|
||||
await send_group_msg(im, wxid_list)
|
||||
|
||||
uid_bind = await select_db(user_id, mode='uid')
|
||||
if uid_bind == "未找到绑定的UID~":
|
||||
logger.warning('game_token获取失败')
|
||||
await matcher.finish(UID_HINT)
|
||||
if str(uid_bind) == uid_check or str(uid_bind) == account_id:
|
||||
return SimpleCookie(
|
||||
{
|
||||
'stoken_v2': stoken_data['data']['token']['token'],
|
||||
'stuid': stoken_data['data']['user_info']['aid'],
|
||||
'mid': stoken_data['data']['user_info']['mid'],
|
||||
'cookie_token': cookie_token['data']['cookie_token'],
|
||||
}
|
||||
).output(header='', sep=';')
|
||||
else:
|
||||
logger.warning('game_token获取失败:非触发者本人扫码')
|
||||
im = (
|
||||
'{$@}' + f'检测到扫码登录UID{uid_check}与绑定UID{uid_bind}不同,'
|
||||
'gametoken获取失败,请重新发送[扫码登录]进行登录'
|
||||
)
|
||||
await send_group_msg(im, wxid_list)
|
||||
else:
|
||||
logger.warning('game_token获取失败')
|
||||
await matcher.send('game_token获取失败:二维码已过期')
|
||||
return ''
|
||||
await send_group_msg('{$@}game_token获取失败:二维码已过期', wxid_list)
|
||||
|
185
GenshinUID/genshinuid_user/topup.py
Normal file
185
GenshinUID/genshinuid_user/topup.py
Normal file
@ -0,0 +1,185 @@
|
||||
import io
|
||||
import base64
|
||||
import asyncio
|
||||
import traceback
|
||||
from typing import List, NoReturn
|
||||
|
||||
import qrcode
|
||||
from nonebot.log import logger
|
||||
from nonebot.matcher import Matcher
|
||||
from qrcode.constants import ERROR_CORRECT_L
|
||||
from nonebot.adapters.ntchat import MessageSegment
|
||||
|
||||
from .draw_topup_img import draw_wx, draw_ali
|
||||
from ..utils.message.error_reply import UID_HINT
|
||||
from ..utils.db_operation.db_operation import select_db
|
||||
from ..utils.mhy_api.get_mhy_data import topup, checkorder, fetchgoods
|
||||
|
||||
disnote = '''免责声明:该充值接口由米游社提供,不对充值结果负责。
|
||||
请在充值前仔细阅读米哈游的充值条款。'''
|
||||
|
||||
GOODS = {
|
||||
0: {
|
||||
"title": "创世结晶×60",
|
||||
"aliases": ["创世结晶x60", "结晶×60", "结晶x60", "创世结晶60", "结晶60"],
|
||||
},
|
||||
1: {
|
||||
"title": "创世结晶×300",
|
||||
"aliases": ["创世结晶x300", "结晶×300", "结晶x300", "创世结晶300", "结晶300", "30"],
|
||||
},
|
||||
2: {
|
||||
"title": "创世结晶×980",
|
||||
"aliases": ["创世结晶x980", "结晶×980", "结晶x980", "创世结晶980", "结晶980", "98"],
|
||||
},
|
||||
3: {
|
||||
"title": "创世结晶×1980",
|
||||
"aliases": [
|
||||
"创世结晶x1980",
|
||||
"结晶×1980",
|
||||
"结晶x1980",
|
||||
"创世结晶1980",
|
||||
"结晶1980",
|
||||
"198",
|
||||
],
|
||||
},
|
||||
4: {
|
||||
"title": "创世结晶×3280",
|
||||
"aliases": [
|
||||
"创世结晶x3280",
|
||||
"结晶×3280",
|
||||
"结晶x3280",
|
||||
"创世结晶3280",
|
||||
"结晶3280",
|
||||
"328",
|
||||
],
|
||||
},
|
||||
5: {
|
||||
"title": "创世结晶×6480",
|
||||
"aliases": [
|
||||
"创世结晶x6480",
|
||||
"结晶×6480",
|
||||
"结晶x6480",
|
||||
"创世结晶6480",
|
||||
"结晶6480",
|
||||
"648",
|
||||
],
|
||||
},
|
||||
6: {
|
||||
"title": "空月祝福",
|
||||
"aliases": ["空月", "祝福", "月卡", "小月卡"],
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
def get_qrcode_base64(url):
|
||||
qr = qrcode.QRCode(
|
||||
version=1,
|
||||
error_correction=ERROR_CORRECT_L,
|
||||
box_size=10,
|
||||
border=4,
|
||||
)
|
||||
qr.add_data(url)
|
||||
qr.make(fit=True)
|
||||
img = qr.make_image(fill_color="black", back_color="white")
|
||||
img_byte = io.BytesIO()
|
||||
img.save(img_byte, format="PNG") # type: ignore
|
||||
img_byte = img_byte.getvalue()
|
||||
return base64.b64encode(img_byte).decode()
|
||||
|
||||
|
||||
async def refresh(order, uid, oid):
|
||||
times = 0
|
||||
while True:
|
||||
await asyncio.sleep(5)
|
||||
order_status = await checkorder(order, uid)
|
||||
if order_status != 900:
|
||||
pass
|
||||
else:
|
||||
return "{$@}" + f"支付成功!\nUID:{uid}\n订单号:{oid}"
|
||||
times += 1
|
||||
if times > 60:
|
||||
return "{$@}" + f"支付超时!\nUID:{uid}\n订单号:{oid}"
|
||||
|
||||
|
||||
async def topup_(matcher: Matcher, qid, group_id, goods_id, method):
|
||||
async def send_group_msg(msg: str, at_list: List) -> NoReturn:
|
||||
await matcher.finish(
|
||||
MessageSegment.room_at_msg(content=msg, at_list=at_list)
|
||||
)
|
||||
|
||||
wxid_list = []
|
||||
wxid_list.append(qid)
|
||||
uid = await select_db(qid, mode="uid")
|
||||
if uid is None:
|
||||
await send_group_msg("{$@}" + UID_HINT, wxid_list)
|
||||
fetchgoods_data = await fetchgoods()
|
||||
try:
|
||||
goods_data = fetchgoods_data[goods_id]
|
||||
except Exception as e:
|
||||
logger.warning(f'[充值]错误 {e}')
|
||||
await send_group_msg(
|
||||
"{$@}商品不存在,最大为" + str(len(fetchgoods_data) - 1), wxid_list
|
||||
)
|
||||
try:
|
||||
order = await topup(uid, goods_data, method)
|
||||
except Exception as e:
|
||||
logger.warning(f"[充值] {group_id} {qid} 错误:{e}")
|
||||
await send_group_msg("{$@}出错了,可能是Cookie过期或接口出错。", wxid_list)
|
||||
try:
|
||||
b64_data = get_qrcode_base64(order["encode_order"])
|
||||
img_b64decode = base64.b64decode(b64_data)
|
||||
qrimage = io.BytesIO(img_b64decode) # 二维码
|
||||
item_icon_url: str = goods_data['goods_icon'] # 图标
|
||||
item_id: str = goods_data['goods_id'] # 商品内部id
|
||||
item_pay_url: str = order['encode_order'] # 支付链接
|
||||
item_name_full = (
|
||||
f"{goods_data['goods_name']}×{str(goods_data['goods_unit'])}"
|
||||
)
|
||||
# 物品名字(非月卡)
|
||||
item_name: str = (
|
||||
item_name_full
|
||||
if int(goods_data['goods_unit']) > 0
|
||||
else goods_data["goods_name"]
|
||||
)
|
||||
# 物品名字
|
||||
item_price: str = order["currency"] + str(
|
||||
int(order["amount"]) / 100
|
||||
) # 价格
|
||||
item_order_no: str = order['order_no'] # 订单号
|
||||
item_create_time: int = order['create_time'] # 创建时间
|
||||
|
||||
if method == 'alipay':
|
||||
img_data = await draw_ali(
|
||||
uid,
|
||||
item_name,
|
||||
item_price,
|
||||
item_order_no,
|
||||
qrimage,
|
||||
item_icon_url,
|
||||
item_create_time,
|
||||
item_id,
|
||||
)
|
||||
return MessageSegment.image(img_data)
|
||||
else:
|
||||
img_data = await draw_wx(
|
||||
uid,
|
||||
item_name,
|
||||
item_price,
|
||||
item_order_no,
|
||||
item_icon_url,
|
||||
item_create_time,
|
||||
item_id,
|
||||
)
|
||||
msg_text = '{$@}' + f' UID:{uid}\n{item_name}\n{item_create_time}'
|
||||
msg_text2 = msg_text + f'\n\nZF:{item_pay_url}\n\n{disnote}'
|
||||
at_msg = MessageSegment.room_at_msg(
|
||||
content=msg_text2, at_list=wxid_list
|
||||
)
|
||||
return MessageSegment.image(img_data) + at_msg
|
||||
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
logger.warning(f"[充值] {group_id} 图片发送失败: {e}")
|
||||
await send_group_msg(
|
||||
await refresh(order, uid, order['order_no']), wxid_list
|
||||
)
|
@ -64,6 +64,7 @@ footer_html = f'''
|
||||
</p>
|
||||
'''
|
||||
|
||||
|
||||
# 还原高版本的注册按钮丢失
|
||||
@overrides(user_auth_admin.UserLoginFormAdmin)
|
||||
async def get_form(self, request: Request) -> Form:
|
||||
|
@ -3,13 +3,13 @@ import re
|
||||
from nonebot import on_command
|
||||
from nonebot.matcher import Matcher
|
||||
from nonebot.params import CommandArg
|
||||
from nonebot.adapters.qqguild import Bot, Message, MessageEvent
|
||||
from nonebot.adapters.ntchat.message import Message
|
||||
|
||||
from ..config import priority
|
||||
from ..genshinuid_meta import register_menu
|
||||
from ..utils.exception.handle_exception import handle_exception
|
||||
from .get_wiki_text import (
|
||||
char_wiki,
|
||||
audio_wiki,
|
||||
foods_wiki,
|
||||
weapon_wiki,
|
||||
enemies_wiki,
|
||||
@ -22,14 +22,29 @@ get_cost = on_command('材料', priority=priority)
|
||||
get_polar = on_command('命座', priority=priority)
|
||||
get_talents = on_command('天赋', priority=priority)
|
||||
get_enemies = on_command('原魔', priority=priority)
|
||||
# get_audio = on_command('语音', priority=priority)
|
||||
get_audio = on_command('语音', priority=priority)
|
||||
get_artifacts = on_command('圣遗物', priority=priority)
|
||||
get_food = on_command('食物', priority=priority)
|
||||
|
||||
|
||||
'''频道无法使用语音相关
|
||||
# 语音暂时不支持
|
||||
'''
|
||||
@get_audio.handle()
|
||||
@handle_exception('语音', '语音发送失败,可能是FFmpeg环境未配置。')
|
||||
@register_menu(
|
||||
'角色语音',
|
||||
'语音[ID]',
|
||||
'获取角色语音',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'获取角色语音\n'
|
||||
'获取语言ID列表请使用指令 <ft color=(238,120,0)>语音列表</ft>\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>语音{列表|</ft>'
|
||||
'<ft color=(0,148,200)>[语音ID]</ft>'
|
||||
'<ft color=(238,120,0)>}</ft>'
|
||||
),
|
||||
)
|
||||
async def send_audio(matcher: Matcher, args: Message = CommandArg()):
|
||||
message = args.extract_plain_text().strip().replace(' ', '')
|
||||
name = ''.join(re.findall('[\u4e00-\u9fa5]', message))
|
||||
@ -46,6 +61,18 @@ async def send_audio(matcher: Matcher, args: Message = CommandArg()):
|
||||
|
||||
@get_enemies.handle()
|
||||
@handle_exception('怪物')
|
||||
@register_menu(
|
||||
'怪物图鉴',
|
||||
'怪物xx',
|
||||
'获取怪物Wiki',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'获取怪物Wiki\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>怪物</ft><ft color=(0,148,200)>[怪物名称]</ft>'
|
||||
),
|
||||
)
|
||||
async def send_enemies(matcher: Matcher, args: Message = CommandArg()):
|
||||
message = args.extract_plain_text().strip().replace(' ', '')
|
||||
im = await enemies_wiki(message)
|
||||
@ -54,6 +81,18 @@ async def send_enemies(matcher: Matcher, args: Message = CommandArg()):
|
||||
|
||||
@get_food.handle()
|
||||
@handle_exception('食物')
|
||||
@register_menu(
|
||||
'食物图鉴',
|
||||
'食物xx',
|
||||
'获取食物Wiki',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'获取食物Wiki\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>食物</ft><ft color=(0,148,200)>[食物名称]</ft>'
|
||||
),
|
||||
)
|
||||
async def send_food(matcher: Matcher, args: Message = CommandArg()):
|
||||
message = args.extract_plain_text().strip().replace(' ', '')
|
||||
im = await foods_wiki(message)
|
||||
@ -62,6 +101,18 @@ async def send_food(matcher: Matcher, args: Message = CommandArg()):
|
||||
|
||||
@get_artifacts.handle()
|
||||
@handle_exception('圣遗物')
|
||||
@register_menu(
|
||||
'圣遗物图鉴',
|
||||
'圣遗物xx',
|
||||
'获取怪物Wiki',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'获取圣遗物Wiki\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>圣遗物</ft><ft color=(0,148,200)>[圣遗物名称]</ft>'
|
||||
),
|
||||
)
|
||||
async def send_artifacts(matcher: Matcher, args: Message = CommandArg()):
|
||||
message = args.extract_plain_text().strip().replace(' ', '')
|
||||
im = await artifacts_wiki(message)
|
||||
@ -70,6 +121,23 @@ async def send_artifacts(matcher: Matcher, args: Message = CommandArg()):
|
||||
|
||||
@get_weapon.handle()
|
||||
@handle_exception('武器')
|
||||
@register_menu(
|
||||
'武器图鉴',
|
||||
'武器xx',
|
||||
'获取武器Wiki',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'获取武器Wiki\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>武器</ft><ft color=(0,148,200)>[武器名称]</ft>'
|
||||
'<ft color=(125,125,125)>(级数)</ft>\n'
|
||||
' \n'
|
||||
'示例:\n'
|
||||
'- <ft color=(238,120,0)>武器雾切</ft>\n'
|
||||
'- <ft color=(238,120,0)>武器无工之剑90</ft>'
|
||||
),
|
||||
)
|
||||
async def send_weapon(matcher: Matcher, args: Message = CommandArg()):
|
||||
message = args.extract_plain_text().strip().replace(' ', '')
|
||||
name = ''.join(re.findall('[\u4e00-\u9fa5]', message))
|
||||
@ -81,12 +149,28 @@ async def send_weapon(matcher: Matcher, args: Message = CommandArg()):
|
||||
await matcher.finish(im)
|
||||
|
||||
|
||||
'''频道无法发送合并转发消息
|
||||
# 天赋暂时不支持
|
||||
'''
|
||||
@get_talents.handle()
|
||||
@handle_exception('天赋')
|
||||
@register_menu(
|
||||
'天赋效果',
|
||||
'天赋[角色][天赋序号]',
|
||||
'查询角色天赋技能效果',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'查询角色天赋技能效果\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>天赋</ft>'
|
||||
'<ft color=(0,148,200)>[角色名称][天赋序号]</ft>\n'
|
||||
' \n'
|
||||
'示例:\n'
|
||||
'- <ft color=(238,120,0)>天赋绫华2</ft>'
|
||||
),
|
||||
)
|
||||
async def send_talents(
|
||||
bot: Bot,
|
||||
event: MessageEvent,
|
||||
matcher: Matcher,
|
||||
args: Message = CommandArg(),
|
||||
):
|
||||
@ -100,7 +184,6 @@ async def send_talents(
|
||||
'send_group_forward_msg', group_id=event.group_id, messages=im
|
||||
)
|
||||
await matcher.finish()
|
||||
return
|
||||
else:
|
||||
im = '参数不正确。'
|
||||
await matcher.finish(im)
|
||||
@ -109,6 +192,23 @@ async def send_talents(
|
||||
|
||||
@get_char.handle()
|
||||
@handle_exception('角色')
|
||||
@register_menu(
|
||||
'角色图鉴',
|
||||
'角色xx',
|
||||
'获取角色Wiki',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'获取角色Wiki\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>角色</ft><ft color=(0,148,200)>[角色名称]</ft>'
|
||||
'<ft color=(125,125,125)>(等级)</ft>\n'
|
||||
' \n'
|
||||
'示例:\n'
|
||||
'- <ft color=(238,120,0)>角色可莉</ft>\n'
|
||||
'- <ft color=(238,120,0)>角色可莉90</ft>'
|
||||
),
|
||||
)
|
||||
async def send_char(matcher: Matcher, args: Message = CommandArg()):
|
||||
message = args.extract_plain_text().strip().replace(' ', '')
|
||||
name = ''.join(re.findall('[\u4e00-\u9fa5]', message))
|
||||
@ -122,6 +222,18 @@ async def send_char(matcher: Matcher, args: Message = CommandArg()):
|
||||
|
||||
@get_cost.handle()
|
||||
@handle_exception('材料')
|
||||
@register_menu(
|
||||
'材料图鉴',
|
||||
'材料xx',
|
||||
'获取材料Wiki',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'获取材料Wiki\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>材料</ft><ft color=(0,148,200)>[材料名称]</ft>'
|
||||
),
|
||||
)
|
||||
async def send_cost(matcher: Matcher, args: Message = CommandArg()):
|
||||
message = args.extract_plain_text().strip().replace(' ', '')
|
||||
im = await char_wiki(message, 'costs')
|
||||
@ -130,6 +242,22 @@ async def send_cost(matcher: Matcher, args: Message = CommandArg()):
|
||||
|
||||
@get_polar.handle()
|
||||
@handle_exception('命座')
|
||||
@register_menu(
|
||||
'角色命座图鉴',
|
||||
'命座[角色][等级]',
|
||||
'获取角色命座Wiki',
|
||||
detail_des=(
|
||||
'介绍:\n'
|
||||
'获取角色命座Wiki\n'
|
||||
' \n'
|
||||
'指令:\n'
|
||||
'- <ft color=(238,120,0)>命座</ft>'
|
||||
'<ft color=(0,148,200)>[角色名称][命座等级]</ft>\n'
|
||||
' \n'
|
||||
'示例:\n'
|
||||
'- <ft color=(238,120,0)>命座胡桃1</ft>'
|
||||
),
|
||||
)
|
||||
async def send_polar(matcher: Matcher, args: Message = CommandArg()):
|
||||
message = args.extract_plain_text().strip().replace(' ', '')
|
||||
num = int(re.findall(r'\d+', message)[0]) # str
|
||||
|
@ -6,7 +6,7 @@ from nonebot import on_command
|
||||
from nonebot.log import logger
|
||||
from nonebot.matcher import Matcher
|
||||
from nonebot_plugin_apscheduler import scheduler
|
||||
from nonebot.adapters.qqguild import MessageSegment
|
||||
from nonebot.adapters.ntchat import MessageSegment
|
||||
|
||||
from .draw_abyss_total import TOTAL_IMG, draw_xk_abyss_img
|
||||
from ..utils.exception.handle_exception import handle_exception
|
||||
@ -26,7 +26,8 @@ async def scheduled_draw_abyss():
|
||||
async def send_guide_pic(matcher: Matcher):
|
||||
if TOTAL_IMG.exists():
|
||||
logger.info('获得深渊概览成功!')
|
||||
await matcher.finish(MessageSegment.file_image(TOTAL_IMG))
|
||||
with open(TOTAL_IMG, 'rb') as f:
|
||||
await matcher.finish(MessageSegment.image(f.read()))
|
||||
else:
|
||||
await matcher.finish('深渊概览图不存在!')
|
||||
|
||||
|
@ -17,7 +17,10 @@ path = Path(__file__).parents[1] / 'genshinuid_adv'
|
||||
wb = load_workbook(str(path / 'Genshin All Char.xlsx'))
|
||||
ws = wb.active
|
||||
for char_i in range(2, 336, 5): # 角色行
|
||||
char_name = ws.cell(char_i, 1).value.replace('\n', '') # type: ignore
|
||||
char = ws.cell(char_i, 1).value
|
||||
if not isinstance(char, str):
|
||||
continue
|
||||
char_name = char.replace('\n', '')
|
||||
char_sample = copy.deepcopy(sample)
|
||||
for i in range(5):
|
||||
row = i + char_i
|
||||
|
@ -251,7 +251,7 @@ class CookiesDAL:
|
||||
await self.db_session.flush()
|
||||
return True
|
||||
|
||||
async def add_cookie_db(self, userid: str, uid: str, cookies: str) -> bool:
|
||||
async def add_cookie_db(self, userid: int, uid: str, cookies: str) -> bool:
|
||||
"""
|
||||
:说明:
|
||||
绑定Cookies
|
||||
|
@ -105,7 +105,7 @@ class UidDataDAL:
|
||||
切换前 -> 12_13_14
|
||||
切换后 -> 13_12_14
|
||||
:参数:
|
||||
* userid (int): QQ号。
|
||||
* userid (int): WX号。
|
||||
* uid (str): 切换的UID, 可选, 不传入的话自动切换下一个。
|
||||
:返回:
|
||||
* msg (str): 回调信息。
|
||||
@ -181,7 +181,7 @@ class UidDataDAL:
|
||||
:说明:
|
||||
绑定UID或者MYSID
|
||||
:参数:
|
||||
* userid (str): 频道用户 ID。
|
||||
* userid (int): QQ号。
|
||||
* data (dict): 绑定的UID或者MYSID, 至少填写一项。
|
||||
data = {'UID': UID, 'MYSID': MYSID}
|
||||
:返回:
|
||||
|
@ -33,10 +33,7 @@ class PushData(SQLModel, table=True):
|
||||
|
||||
class UidData(SQLModel, table=True):
|
||||
__table_args__ = {'keep_existing': True}
|
||||
ID: int = Field(
|
||||
default=1, primary_key=True, sa_column_kwargs={"autoincrement": 1}
|
||||
)
|
||||
USERID: str = Field(default="100000000", primary_key=True, title='QQ号')
|
||||
USERID: str = Field(default='WX_100001', primary_key=True, title='WX号')
|
||||
UID: Optional[str] = Field(title='UID')
|
||||
MYSID: Optional[str] = Field(title='米游社通行证(废弃)')
|
||||
|
||||
|
@ -9,7 +9,7 @@ from .database.db_config import async_session
|
||||
|
||||
|
||||
async def get_push_status(uid, func) -> List:
|
||||
async with async_session() as session: # type: ignore
|
||||
async with async_session() as session:
|
||||
async with session.begin():
|
||||
PushData = PushDataDAL(session)
|
||||
push_dict = await PushData.get_user_data(uid)
|
||||
@ -23,7 +23,7 @@ async def get_push_status(uid, func) -> List:
|
||||
|
||||
|
||||
async def update_push_status(uid: int, func: str, status: str) -> bool:
|
||||
async with async_session() as session: # type: ignore
|
||||
async with async_session() as session:
|
||||
async with session.begin():
|
||||
PushData = PushDataDAL(session)
|
||||
return await PushData.update_user_data(
|
||||
@ -32,7 +32,7 @@ async def update_push_status(uid: int, func: str, status: str) -> bool:
|
||||
|
||||
|
||||
async def update_push_value(uid: int, func: str, value: int) -> bool:
|
||||
async with async_session() as session: # type: ignore
|
||||
async with async_session() as session:
|
||||
async with session.begin():
|
||||
PushData = PushDataDAL(session)
|
||||
return await PushData.update_user_data(
|
||||
@ -43,7 +43,7 @@ async def update_push_value(uid: int, func: str, value: int) -> bool:
|
||||
async def update_is_pushed(
|
||||
uid: int, func: str, is_pushed: str = 'off'
|
||||
) -> bool:
|
||||
async with async_session() as session: # type: ignore
|
||||
async with async_session() as session:
|
||||
async with session.begin():
|
||||
PushData = PushDataDAL(session)
|
||||
return await PushData.update_user_data(
|
||||
@ -52,7 +52,7 @@ async def update_is_pushed(
|
||||
|
||||
|
||||
async def bind_db(userid, uid=None, mys=None):
|
||||
async with async_session() as session: # type: ignore
|
||||
async with async_session() as session:
|
||||
async with session.begin():
|
||||
UidData = UidDataDAL(session)
|
||||
im = await UidData.bind_db(userid, {'UID': uid, 'MYSID': mys})
|
||||
@ -68,7 +68,7 @@ async def get_all_bind() -> List[Dict]:
|
||||
|
||||
|
||||
async def get_all_uid() -> List:
|
||||
async with async_session() as session: # type: ignore
|
||||
async with async_session() as session:
|
||||
async with session.begin():
|
||||
UidData = UidDataDAL(session)
|
||||
lst = await UidData.get_all_uid_list()
|
||||
@ -76,7 +76,7 @@ async def get_all_uid() -> List:
|
||||
|
||||
|
||||
async def get_all_cookie() -> List:
|
||||
async with async_session() as session: # type: ignore
|
||||
async with async_session() as session:
|
||||
async with session.begin():
|
||||
Cookies = CookiesDAL(session)
|
||||
lst = await Cookies.get_all_cookie_list()
|
||||
@ -84,14 +84,16 @@ async def get_all_cookie() -> List:
|
||||
|
||||
|
||||
async def get_all_stoken() -> List:
|
||||
async with async_session() as session: # type: ignore
|
||||
async with async_session() as session:
|
||||
async with session.begin():
|
||||
Cookies = CookiesDAL(session)
|
||||
lst = await Cookies.get_all_stoken_list()
|
||||
return lst
|
||||
|
||||
|
||||
async def select_db(userid: str, mode='auto') -> Union[List, str, None]:
|
||||
async def select_db(
|
||||
userid: str, mode: str = 'auto'
|
||||
) -> Union[List[str], str, None]:
|
||||
"""
|
||||
:说明:
|
||||
选择绑定uid/mys库
|
||||
@ -108,7 +110,7 @@ async def select_db(userid: str, mode='auto') -> Union[List, str, None]:
|
||||
其他情况下data[0]为需要的uid/mysid
|
||||
data[1]表示data[0]是`uid` or `mysid`
|
||||
"""
|
||||
async with async_session() as session: # type: ignore
|
||||
async with async_session() as session:
|
||||
async with session.begin():
|
||||
UidData = UidDataDAL(session)
|
||||
if mode == 'auto':
|
||||
@ -131,11 +133,11 @@ async def switch_db(userid: str, uid: Optional[str] = None) -> str:
|
||||
切换前 -> 12_13_14
|
||||
切换后 -> 13_14_12
|
||||
:参数:
|
||||
* userid (str): QQ号。
|
||||
* userid (str): WX号。
|
||||
:返回:
|
||||
* im (str): 回调信息。
|
||||
"""
|
||||
async with async_session() as session: # type: ignore
|
||||
async with async_session() as session:
|
||||
async with session.begin():
|
||||
UidData = UidDataDAL(session)
|
||||
im = await UidData.switch_uid(userid, uid)
|
||||
@ -153,15 +155,15 @@ async def delete_db(userid: str, data: dict) -> str:
|
||||
:返回:
|
||||
* im (str): 回调信息。
|
||||
"""
|
||||
async with async_session() as session: # type: ignore
|
||||
async with async_session() as session:
|
||||
async with session.begin():
|
||||
UidData = UidDataDAL(session)
|
||||
im = await UidData.delete_db(userid, data)
|
||||
return im
|
||||
|
||||
|
||||
async def cookies_db(uid: str, cookies: str, qid: str):
|
||||
async with async_session() as session: # type: ignore
|
||||
async def cookies_db(uid: str, cookies: str, qid: int):
|
||||
async with async_session() as session:
|
||||
async with session.begin():
|
||||
Cookies = CookiesDAL(session)
|
||||
im = await Cookies.add_cookie_db(qid, uid, cookies)
|
||||
@ -169,7 +171,7 @@ async def cookies_db(uid: str, cookies: str, qid: str):
|
||||
|
||||
|
||||
async def error_db(cookies: str, error: str):
|
||||
async with async_session() as session: # type: ignore
|
||||
async with async_session() as session:
|
||||
async with session.begin():
|
||||
Cookies = CookiesDAL(session)
|
||||
im = await Cookies.add_error_db(cookies, error)
|
||||
@ -177,7 +179,7 @@ async def error_db(cookies: str, error: str):
|
||||
|
||||
|
||||
async def owner_cookies(uid: str) -> str:
|
||||
async with async_session() as session: # type: ignore
|
||||
async with async_session() as session:
|
||||
async with session.begin():
|
||||
Cookies = CookiesDAL(session)
|
||||
owner_ck = await Cookies.get_user_ck(uid)
|
||||
@ -189,7 +191,7 @@ async def owner_cookies(uid: str) -> str:
|
||||
|
||||
|
||||
async def delete_cookies(uid: str) -> str:
|
||||
async with async_session() as session: # type: ignore
|
||||
async with async_session() as session:
|
||||
async with session.begin():
|
||||
Cookies = CookiesDAL(session)
|
||||
result = await Cookies.delete_user(uid)
|
||||
@ -200,7 +202,7 @@ async def delete_cookies(uid: str) -> str:
|
||||
|
||||
|
||||
async def get_stoken(uid: str) -> str:
|
||||
async with async_session() as session: # type: ignore
|
||||
async with async_session() as session:
|
||||
async with session.begin():
|
||||
Cookies = CookiesDAL(session)
|
||||
stoken = await Cookies.get_user_stoken(uid)
|
||||
@ -208,7 +210,7 @@ async def get_stoken(uid: str) -> str:
|
||||
|
||||
|
||||
async def get_user_bind_data(uid: str) -> dict:
|
||||
async with async_session() as session: # type: ignore
|
||||
async with async_session() as session:
|
||||
async with session.begin():
|
||||
Cookies = CookiesDAL(session)
|
||||
lst = await Cookies.get_user_data_dict(uid)
|
||||
@ -216,7 +218,7 @@ async def get_user_bind_data(uid: str) -> dict:
|
||||
|
||||
|
||||
async def stoken_db(s_cookies: str, uid: str) -> str:
|
||||
async with async_session() as session: # type: ignore
|
||||
async with async_session() as session:
|
||||
async with session.begin():
|
||||
Cookies = CookiesDAL(session)
|
||||
im = await Cookies.add_stoken_db(uid, s_cookies)
|
||||
@ -224,7 +226,7 @@ async def stoken_db(s_cookies: str, uid: str) -> str:
|
||||
|
||||
|
||||
async def open_push(uid, qid, status, func):
|
||||
async with async_session() as session: # type: ignore
|
||||
async with async_session() as session:
|
||||
async with session.begin():
|
||||
Cookies = CookiesDAL(session)
|
||||
im = await Cookies.update_user_status(
|
||||
@ -241,7 +243,7 @@ async def empty_cache():
|
||||
|
||||
|
||||
async def config_check(func, mode='CHECK') -> bool:
|
||||
async with async_session() as session: # type: ignore
|
||||
async with async_session() as session:
|
||||
async with session.begin():
|
||||
Config = ConfigDAL(session)
|
||||
im = False
|
||||
@ -255,7 +257,7 @@ async def config_check(func, mode='CHECK') -> bool:
|
||||
|
||||
|
||||
async def get_all_signin_list() -> List:
|
||||
async with async_session() as session: # type: ignore
|
||||
async with async_session() as session:
|
||||
async with session.begin():
|
||||
Cookies = CookiesDAL(session)
|
||||
im = await Cookies.get_status_list('StatusB')
|
||||
@ -263,7 +265,7 @@ async def get_all_signin_list() -> List:
|
||||
|
||||
|
||||
async def get_all_push_list() -> List:
|
||||
async with async_session() as session: # type: ignore
|
||||
async with async_session() as session:
|
||||
async with session.begin():
|
||||
Cookies = CookiesDAL(session)
|
||||
im = await Cookies.get_status_list('StatusA')
|
||||
@ -271,7 +273,7 @@ async def get_all_push_list() -> List:
|
||||
|
||||
|
||||
async def get_push_data(uid: int) -> dict:
|
||||
async with async_session() as session: # type: ignore
|
||||
async with async_session() as session:
|
||||
async with session.begin():
|
||||
PushData = PushDataDAL(session)
|
||||
push_data = await PushData.get_user_data(uid)
|
||||
|
@ -184,10 +184,7 @@ async def get_level_pic(level: int) -> Image.Image:
|
||||
async def get_qq_avatar(
|
||||
qid: Optional[Union[int, str]] = None, avatar_url: Optional[str] = None
|
||||
) -> Image.Image:
|
||||
if qid:
|
||||
avatar_url = f'http://q1.qlogo.cn/g?b=qq&nk={qid}&s=640'
|
||||
elif avatar_url is None:
|
||||
avatar_url = 'https://q1.qlogo.cn/g?b=qq&nk=3399214199&s=640'
|
||||
avatar_url = 'https://s2.loli.net/2022/01/31/kwCIl3cF1Z2GxnR.png'
|
||||
char_pic = Image.open(BytesIO(get(avatar_url).content)).convert('RGBA')
|
||||
return char_pic
|
||||
|
||||
|
@ -52,4 +52,4 @@ async def convert_img(
|
||||
else:
|
||||
async with aiofiles.open(img, 'rb') as fp:
|
||||
img = await fp.read()
|
||||
return f'[CQ:image,file=base64://{b64encode(img).decode()}]'
|
||||
return f'base64://{b64encode(img).decode()}'
|
||||
|
@ -4,7 +4,6 @@ from typing import Optional
|
||||
from nonebot.log import logger
|
||||
from nonebot.matcher import Matcher
|
||||
from nonebot.exception import FinishedException
|
||||
from nonebot.adapters.onebot.v11 import ActionFailed
|
||||
|
||||
|
||||
def handle_exception(
|
||||
@ -30,10 +29,6 @@ def handle_exception(
|
||||
matcher: Matcher = kwargs['matcher']
|
||||
try:
|
||||
await func(**kwargs)
|
||||
except ActionFailed as e:
|
||||
# 此为bot本身由于风控或网络问题发不出消息,并非代码本身出问题
|
||||
await matcher.send(f'发送消息失败{e.info["wording"]}')
|
||||
logger.exception(f'发送{name}消息失败')
|
||||
except FinishedException:
|
||||
# `finish` 会抛出此异常,应予以抛出而不处理
|
||||
raise
|
||||
@ -46,9 +41,7 @@ def handle_exception(
|
||||
if not fail_msg:
|
||||
fail_msg = log_msg
|
||||
if fail_msg[0] == '@':
|
||||
await matcher.send(
|
||||
f'{fail_msg[1:]}\n错误信息为{e}', at_sender=True
|
||||
)
|
||||
await matcher.send(f'{fail_msg[1:]}\n错误信息为{e}')
|
||||
else:
|
||||
await matcher.send(f'{fail_msg}\n错误信息为{e}')
|
||||
if log_msg[0] == '@':
|
||||
|
@ -1,7 +0,0 @@
|
||||
from typing import Optional, cast
|
||||
|
||||
from nonebot.adapters.qqguild.api.model import User
|
||||
|
||||
|
||||
def cast_to_int(user: Optional[User]) -> int:
|
||||
return cast(int, cast(User, user).id)
|
21
GenshinUID/utils/message/get_cqhttp_data.py
Normal file
21
GenshinUID/utils/message/get_cqhttp_data.py
Normal file
@ -0,0 +1,21 @@
|
||||
from typing import List
|
||||
|
||||
from nonebot.adapters.ntchat import Bot
|
||||
|
||||
|
||||
async def get_all_friend_list(bot: Bot) -> List[int]:
|
||||
friend_list = []
|
||||
friend_dict_list = await bot.call_api('get_contacts')
|
||||
for friend in friend_dict_list:
|
||||
friend_list.append(friend['user_id'])
|
||||
return friend_list
|
||||
|
||||
|
||||
async def get_group_member_list(bot: Bot, group_id: int) -> List[int]:
|
||||
member_list = []
|
||||
group_member_list = await bot.call_api(
|
||||
'get_room_members', group_id=group_id
|
||||
)
|
||||
for group_member in group_member_list:
|
||||
member_list.append(group_member['user_id'])
|
||||
return member_list
|
@ -1,6 +1,6 @@
|
||||
from typing import Optional
|
||||
from typing import Union
|
||||
|
||||
from nonebot.adapters.qqguild import MessageEvent
|
||||
from nonebot.adapters.onebot.v11 import MessageEvent
|
||||
|
||||
|
||||
# https://v2.nonebot.dev/docs/advanced/di/dependency-injection#class-%E4%BD%9C%E4%B8%BA%E4%BE%9D%E8%B5%96
|
||||
@ -8,11 +8,15 @@ class ImageAndAt:
|
||||
def __init__(self, event: MessageEvent):
|
||||
self.images = []
|
||||
self.at = []
|
||||
for i in event.get_message():
|
||||
if i.type == "attachment":
|
||||
self.images.append(i.data["url"])
|
||||
elif i.type == "mention_user":
|
||||
self.at.append(i.data["user_id"])
|
||||
for i in event.message:
|
||||
if i.type == "image":
|
||||
data = i.data
|
||||
if url := data.get("url"):
|
||||
self.images.append(url)
|
||||
else:
|
||||
continue
|
||||
elif i.type == "at":
|
||||
self.at.append(i.data["qq"])
|
||||
|
||||
def get_at(self):
|
||||
return self.at
|
||||
@ -20,8 +24,14 @@ class ImageAndAt:
|
||||
def get_image(self):
|
||||
return self.images
|
||||
|
||||
def get_first_image(self) -> Optional[str]:
|
||||
return self.images[0] if len(self.images) else None
|
||||
def get_first_image(self) -> Union[str, None]:
|
||||
try:
|
||||
return self.images[0]
|
||||
except IndexError:
|
||||
return None
|
||||
|
||||
def get_first_at(self) -> Optional[str]:
|
||||
return self.at[0] if len(self.at) else None
|
||||
def get_first_at(self) -> Union[int, None]:
|
||||
try:
|
||||
return self.at[0]
|
||||
except IndexError:
|
||||
return None
|
||||
|
@ -17,6 +17,7 @@ from ..mhy_api.mhy_api_tools import (
|
||||
random_hex,
|
||||
random_text,
|
||||
get_ds_token,
|
||||
gen_payment_sign,
|
||||
generate_passport_ds,
|
||||
generate_dynamic_secret,
|
||||
old_version_get_ds_token,
|
||||
@ -56,6 +57,9 @@ from ..mhy_api.mhy_api import ( # noqa
|
||||
MIHOYO_BBS_PLAYER_INFO_URL,
|
||||
MIHOYO_BBS_PLAYER_INFO_URL_OS,
|
||||
GET_COOKIE_TOKEN_BY_GAME_TOKEN,
|
||||
CheckOrderurl,
|
||||
CreateOrderurl,
|
||||
fetchGoodsurl,
|
||||
)
|
||||
|
||||
PROXY_URL = string_config.get_config('proxy')
|
||||
@ -545,7 +549,7 @@ async def get_gcg_info(uid: str):
|
||||
|
||||
async def create_qrcode_url():
|
||||
device_id: str = ''.join(random.choices(ascii_letters + digits, k=64))
|
||||
app_id: str = '4'
|
||||
app_id: str = '8'
|
||||
data = await _mhy_request(
|
||||
CREATE_QRCODE,
|
||||
'POST',
|
||||
@ -854,3 +858,77 @@ async def get_regtime_data(uid: str) -> Any:
|
||||
use_proxy=True,
|
||||
)
|
||||
return data
|
||||
|
||||
|
||||
async def fetchgoods():
|
||||
data = {
|
||||
"released_flag": True,
|
||||
"game": "hk4e_cn",
|
||||
"region": "cn_gf01",
|
||||
"uid": "1",
|
||||
"account": "1",
|
||||
}
|
||||
goodslist = await _mhy_request(
|
||||
url=fetchGoodsurl,
|
||||
method='POST',
|
||||
data=data,
|
||||
)
|
||||
# print(json.dumps(goodslist.json(),indent=4,ensure_ascii=False))
|
||||
return goodslist["data"]["goods_list"]
|
||||
|
||||
|
||||
async def topup(uid, goods, method):
|
||||
device_id = str(uuid.uuid4())
|
||||
HEADER = copy.deepcopy(_HEADER)
|
||||
HEADER["Cookie"] = await owner_cookies(uid)
|
||||
account = HEADER["Cookie"].split("account_id=")[1].split(";")[0]
|
||||
order = {
|
||||
"account": str(account),
|
||||
"region": "cn_gf01",
|
||||
"uid": uid,
|
||||
"delivery_url": "",
|
||||
"device": device_id,
|
||||
"channel_id": 1,
|
||||
"client_ip": "",
|
||||
"client_type": 4,
|
||||
"game": "hk4e_cn",
|
||||
"amount": goods["price"],
|
||||
# "amount": 600,
|
||||
"goods_num": 1,
|
||||
"goods_id": goods["goods_id"],
|
||||
"goods_title": f"{goods['goods_name']}×{str(goods['goods_unit'])}"
|
||||
if int(goods['goods_unit']) > 0
|
||||
else goods["goods_name"],
|
||||
"price_tier": goods["tier_id"],
|
||||
# "price_tier": "Tier_1",
|
||||
"currency": "CNY",
|
||||
"pay_plat": method,
|
||||
}
|
||||
data = {"order": order, "sign": gen_payment_sign(order)}
|
||||
HEADER["x-rpc-device_id"] = device_id
|
||||
HEADER["x-rpc-client_type"] = "4"
|
||||
order = await _mhy_request(
|
||||
url=CreateOrderurl,
|
||||
method='POST',
|
||||
header=HEADER,
|
||||
data=data,
|
||||
)
|
||||
return order["data"]
|
||||
|
||||
|
||||
async def checkorder(order, uid):
|
||||
HEADER = copy.deepcopy(_HEADER)
|
||||
HEADER["Cookie"] = await owner_cookies(uid)
|
||||
data = {
|
||||
"order_no": order["order_no"],
|
||||
"game": "hk4e_cn",
|
||||
"region": "cn_gf01",
|
||||
"uid": uid,
|
||||
}
|
||||
order = await _mhy_request(
|
||||
url=CheckOrderurl,
|
||||
method='GET',
|
||||
header=HEADER,
|
||||
params=data,
|
||||
)
|
||||
return order["data"]["status"]
|
||||
|
@ -115,3 +115,9 @@ bbs_Listurl = (
|
||||
bbs_Detailurl = BBS_URL + '/post/api/getPostFull?post_id={}'
|
||||
bbs_Shareurl = BBS_URL + '/apihub/api/getShareConf?entity_id={}&entity_type=1'
|
||||
bbs_Likeurl = f'{BBS_URL}/apihub/sapi/upvotePost'
|
||||
|
||||
# 原神充值中心
|
||||
fetchGoodsurl = f"{HK4_SDK_URL}/hk4e_cn/mdk/shopwindow/shopwindow/fetchGoods"
|
||||
CreateOrderurl = f"{HK4_SDK_URL}/hk4e_cn/mdk/atropos/api/createOrder"
|
||||
CheckOrderurl = f"{HK4_SDK_URL}/hk4e_cn/mdk/atropos/api/checkOrder"
|
||||
PriceTierurl = f"{HK4_SDK_URL}/hk4e_cn/mdk/shopwindow/shopwindow/listPriceTier"
|
||||
|
@ -1,3 +1,4 @@
|
||||
import hmac
|
||||
import json
|
||||
import time
|
||||
import random
|
||||
@ -75,3 +76,17 @@ def generate_passport_ds(q: str = '', b: Optional[Dict[str, Any]] = None):
|
||||
return _random_str_ds(
|
||||
"JwYDpKvLj6MrMqqYU6jTKF17KNO2PXoS", string.ascii_letters, True, q, b
|
||||
)
|
||||
|
||||
|
||||
def HMCASHA256(data, key):
|
||||
key = key.encode('utf-8')
|
||||
message = data.encode('utf-8')
|
||||
sign = hmac.new(key, message, digestmod=hashlib.sha256).digest()
|
||||
return sign.hex()
|
||||
|
||||
|
||||
def gen_payment_sign(data):
|
||||
data = dict(sorted(data.items(), key=lambda x: x[0]))
|
||||
value = "".join([str(i) for i in data.values()])
|
||||
sign = HMCASHA256(value, "6bdc3982c25f3f3c38668a32d287d16b")
|
||||
return sign
|
||||
|
@ -1,9 +0,0 @@
|
||||
from nonebot.permission import Permission
|
||||
from nonebot.adapters.qqguild.event import DirectMessageCreateEvent
|
||||
|
||||
|
||||
async def is_direct(_: DirectMessageCreateEvent) -> bool:
|
||||
return True
|
||||
|
||||
|
||||
DIRECT = Permission(is_direct)
|
@ -1,6 +1,6 @@
|
||||
from nonebot.rule import Rule
|
||||
from nonebot.adapters.qqguild import Message
|
||||
from nonebot.params import Depends, CommandArg
|
||||
from nonebot.adapters.ntchat.message import Message
|
||||
|
||||
|
||||
async def full_command(arg: Message = CommandArg()) -> bool:
|
||||
|
@ -1,154 +0,0 @@
|
||||
import json
|
||||
from io import BytesIO
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict, List, Union, Optional
|
||||
|
||||
from nonebot.log import logger
|
||||
from aiohttp import ClientSession
|
||||
from nonebot.drivers import Request
|
||||
from nonebot.typing import overrides
|
||||
from nonebot.adapters.qqguild.bot import Bot
|
||||
from pydantic import BaseModel, parse_obj_as
|
||||
from nonebot.adapters.qqguild.adapter import Adapter
|
||||
from nonebot.adapters.qqguild.api.request import _request
|
||||
from nonebot.adapters.qqguild.api.handle import API_HANDLERS
|
||||
from nonebot.adapters.qqguild.api.model import Message as APIMessage
|
||||
from nonebot.adapters.qqguild.message import Message, MessageSegment
|
||||
from nonebot.adapters.qqguild.event import (
|
||||
Event,
|
||||
MessageEvent,
|
||||
DirectMessageCreateEvent,
|
||||
)
|
||||
from nonebot.adapters.qqguild.api.model import (
|
||||
MessageArk,
|
||||
MessageEmbed,
|
||||
MessageMarkdown,
|
||||
MessageReference,
|
||||
)
|
||||
|
||||
|
||||
class LocalImage(MessageSegment):
|
||||
@overrides(MessageSegment)
|
||||
def __str__(self) -> str:
|
||||
return "<local_image>"
|
||||
|
||||
|
||||
def local_image(data: Union[str, Path, bytes, BytesIO]) -> LocalImage:
|
||||
if isinstance(data, (str, Path)):
|
||||
with open(data, "rb") as f:
|
||||
b = f.read()
|
||||
elif isinstance(data, BytesIO):
|
||||
b = data.getvalue()
|
||||
else:
|
||||
b = data
|
||||
return LocalImage("local_image", data={"content": b})
|
||||
|
||||
|
||||
class MessageSend(BaseModel):
|
||||
content: Optional[str] = None
|
||||
embed: Optional[MessageEmbed] = None
|
||||
ark: Optional[MessageArk] = None
|
||||
markdown: Optional[MessageMarkdown] = None
|
||||
message_reference: Optional[MessageReference] = None
|
||||
image: Optional[str] = None
|
||||
msg_id: Optional[str] = None
|
||||
|
||||
|
||||
def patch_send():
|
||||
logger.info("注入本地图片发送猴子补丁")
|
||||
|
||||
@overrides(Bot)
|
||||
async def send(
|
||||
self,
|
||||
event: Event,
|
||||
message: Union[str, Message, MessageSegment],
|
||||
**kwargs,
|
||||
) -> Any:
|
||||
if (
|
||||
not isinstance(event, MessageEvent)
|
||||
or not event.channel_id
|
||||
or not event.id
|
||||
):
|
||||
raise RuntimeError("Event cannot be replied to!")
|
||||
message = (
|
||||
MessageSegment.text(message)
|
||||
if isinstance(message, str)
|
||||
else message
|
||||
)
|
||||
|
||||
message = message if isinstance(message, Message) else Message(message)
|
||||
content = message.extract_content() or None
|
||||
guild_id = None
|
||||
if isinstance(event, DirectMessageCreateEvent):
|
||||
event_dict = event.__dict__
|
||||
guild_id = event_dict['guild_id']
|
||||
if embed := (message["embed"] or None):
|
||||
embed = embed[-1].data["embed"]
|
||||
if ark := (message["ark"] or None):
|
||||
ark = ark[-1].data["ark"]
|
||||
if image := (message["attachment"] or None):
|
||||
image = image[-1].data["url"]
|
||||
if local_image := (message["local_image"] or None):
|
||||
local_image = local_image[-1].data["content"]
|
||||
if markdown := (message["markdown"] or None):
|
||||
markdown = markdown[-1].data["markdown"]
|
||||
return await self.post_messages(
|
||||
channel_id=event.channel_id,
|
||||
guild_id=guild_id,
|
||||
msg_id=event.id,
|
||||
content=content,
|
||||
embed=embed,
|
||||
ark=ark,
|
||||
markdown=markdown,
|
||||
image=image,
|
||||
file_image=local_image,
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
Bot.send = send
|
||||
|
||||
async def post_messages(
|
||||
adapter: Adapter, bot: Bot, channel_id: int, guild_id: int, **data
|
||||
) -> Union[APIMessage, List[APIMessage]]:
|
||||
headers = {"Authorization": adapter.get_authorization(bot.bot_info)}
|
||||
model_data = MessageSend(**data).dict(exclude_none=True)
|
||||
d_api = adapter.get_api_base() / f"channels/{channel_id}/messages"
|
||||
if guild_id:
|
||||
d_api = adapter.get_api_base() / f"dms/{guild_id}/messages"
|
||||
if "file_image" in model_data.keys() and (
|
||||
file_image := model_data.pop("file_image")
|
||||
):
|
||||
new_data: Dict[str, Union[BytesIO, str]] = {
|
||||
"file_image": BytesIO(file_image)
|
||||
}
|
||||
for k, v in model_data.items():
|
||||
# 当字段类型为对象或数组时需要将字段序列化为 JSON 字符串后进行调用
|
||||
# https://bot.q.qq.com/wiki/develop/api/openapi/message/post_messages.html#form-data-%E6%A0%BC%E5%BC%8F%E7%A4%BA%E4%BE%8B
|
||||
if isinstance(v, BaseModel):
|
||||
new_data[k] = v.json()
|
||||
elif isinstance(v, (list, dict)):
|
||||
new_data[k] = json.dumps(v)
|
||||
|
||||
else:
|
||||
new_data[k] = v
|
||||
async with ClientSession(headers=headers) as session:
|
||||
req = await session.post(
|
||||
d_api,
|
||||
data=new_data,
|
||||
)
|
||||
data = await req.json()
|
||||
else:
|
||||
request = Request(
|
||||
"POST",
|
||||
d_api,
|
||||
json=model_data,
|
||||
headers=headers,
|
||||
)
|
||||
data = await _request(adapter, bot, request)
|
||||
if guild_id:
|
||||
return parse_obj_as(List[APIMessage], data)
|
||||
else:
|
||||
return parse_obj_as(APIMessage, data)
|
||||
|
||||
API_HANDLERS["post_messages"] = post_messages
|
||||
logger.success("本地图片发送猴子补丁已注入")
|
43
poetry.lock
generated
43
poetry.lock
generated
@ -889,32 +889,32 @@ test = ["objgraph", "psutil"]
|
||||
|
||||
[[package]]
|
||||
name = "h11"
|
||||
version = "0.14.0"
|
||||
version = "0.12.0"
|
||||
description = "A pure-Python, bring-your-own-I/O implementation of HTTP/1.1"
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = ">=3.7"
|
||||
python-versions = ">=3.6"
|
||||
files = [
|
||||
{file = "h11-0.14.0-py3-none-any.whl", hash = "sha256:e3fe4ac4b851c468cc8363d500db52c2ead036020723024a109d37346efaa761"},
|
||||
{file = "h11-0.14.0.tar.gz", hash = "sha256:8f19fbbe99e72420ff35c00b27a34cb9937e902a8b810e2c88300c6f0a3b699d"},
|
||||
{file = "h11-0.12.0-py3-none-any.whl", hash = "sha256:36a3cb8c0a032f56e2da7084577878a035d3b61d104230d4bd49c0c6b555a9c6"},
|
||||
{file = "h11-0.12.0.tar.gz", hash = "sha256:47222cb6067e4a307d535814917cd98fd0a57b6788ce715755fa2b6c28b56042"},
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "httpcore"
|
||||
version = "0.16.3"
|
||||
version = "0.15.0"
|
||||
description = "A minimal low-level HTTP client."
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = ">=3.7"
|
||||
files = [
|
||||
{file = "httpcore-0.16.3-py3-none-any.whl", hash = "sha256:da1fb708784a938aa084bde4feb8317056c55037247c787bd7e19eb2c2949dc0"},
|
||||
{file = "httpcore-0.16.3.tar.gz", hash = "sha256:c5d6f04e2fc530f39e0c077e6a30caa53f1451096120f1f38b954afd0b17c0cb"},
|
||||
{file = "httpcore-0.15.0-py3-none-any.whl", hash = "sha256:1105b8b73c025f23ff7c36468e4432226cbb959176eab66864b8e31c4ee27fa6"},
|
||||
{file = "httpcore-0.15.0.tar.gz", hash = "sha256:18b68ab86a3ccf3e7dc0f43598eaddcf472b602aba29f9aa6ab85fe2ada3980b"},
|
||||
]
|
||||
|
||||
[package.dependencies]
|
||||
anyio = ">=3.0,<5.0"
|
||||
anyio = ">=3.0.0,<4.0.0"
|
||||
certifi = "*"
|
||||
h11 = ">=0.13,<0.15"
|
||||
h11 = ">=0.11,<0.13"
|
||||
sniffio = ">=1.0.0,<2.0.0"
|
||||
|
||||
[package.extras]
|
||||
@ -923,19 +923,19 @@ socks = ["socksio (>=1.0.0,<2.0.0)"]
|
||||
|
||||
[[package]]
|
||||
name = "httpx"
|
||||
version = "0.23.3"
|
||||
version = "0.23.0"
|
||||
description = "The next generation HTTP client."
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = ">=3.7"
|
||||
files = [
|
||||
{file = "httpx-0.23.3-py3-none-any.whl", hash = "sha256:a211fcce9b1254ea24f0cd6af9869b3d29aba40154e947d2a07bb499b3e310d6"},
|
||||
{file = "httpx-0.23.3.tar.gz", hash = "sha256:9818458eb565bb54898ccb9b8b251a28785dd4a55afbc23d0eb410754fe7d0f9"},
|
||||
{file = "httpx-0.23.0-py3-none-any.whl", hash = "sha256:42974f577483e1e932c3cdc3cd2303e883cbfba17fe228b0f63589764d7b9c4b"},
|
||||
{file = "httpx-0.23.0.tar.gz", hash = "sha256:f28eac771ec9eb4866d3fb4ab65abd42d38c424739e80c08d8d20570de60b0ef"},
|
||||
]
|
||||
|
||||
[package.dependencies]
|
||||
certifi = "*"
|
||||
httpcore = ">=0.15.0,<0.17.0"
|
||||
httpcore = ">=0.15.0,<0.16.0"
|
||||
rfc3986 = {version = ">=1.3,<2", extras = ["idna2008"]}
|
||||
sniffio = "*"
|
||||
|
||||
@ -1286,20 +1286,19 @@ files = [
|
||||
setuptools = "*"
|
||||
|
||||
[[package]]
|
||||
name = "nonebot-adapter-qqguild"
|
||||
version = "0.2.1"
|
||||
description = "QQ Guild adapter for nonebot2"
|
||||
name = "nonebot-adapter-ntchat"
|
||||
version = "0.3.5"
|
||||
description = "a wechat adapter for nonebot2"
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = ">=3.8,<4.0"
|
||||
python-versions = ">=3.8"
|
||||
files = [
|
||||
{file = "nonebot_adapter_qqguild-0.2.1-py3-none-any.whl", hash = "sha256:0f0d195ef6f27b99727a0d5cedb007833ac31d483f200bb0defc704bbb54616b"},
|
||||
{file = "nonebot_adapter_qqguild-0.2.1.tar.gz", hash = "sha256:bbde4260206663a67bfdccf76c7e062432af1d344ee80652c1d439eecca93bba"},
|
||||
{file = "nonebot-adapter-ntchat-0.3.5.tar.gz", hash = "sha256:52a19d9eeb71a534e5543f3804c5cb68997411f309d9b3c848f27f39de25301e"},
|
||||
{file = "nonebot_adapter_ntchat-0.3.5-py3-none-any.whl", hash = "sha256:ee8851ac28b6463413066dc32ccae08f478df68c6b37e117d48c43698f5e5881"},
|
||||
]
|
||||
|
||||
[package.dependencies]
|
||||
nonebot2 = ">=2.0.0-beta.1,<3.0.0"
|
||||
pydantic = ">=1.9.0,<2.0.0"
|
||||
httpx = "0.23.0"
|
||||
|
||||
[[package]]
|
||||
name = "nonebot-plugin-apscheduler"
|
||||
@ -2379,4 +2378,4 @@ multidict = ">=4.0"
|
||||
[metadata]
|
||||
lock-version = "2.0"
|
||||
python-versions = "^3.8.1"
|
||||
content-hash = "20a3950358ff0c7df2fc8dde966cb5e2fcad0ec695ca605c9d23c84d6a2567ce"
|
||||
content-hash = "c2a8ce5e8f1cc95b81fb90639eb323995941dd9bbd60372327e7e7067572e8c7"
|
||||
|
@ -28,7 +28,7 @@ description = "基于HoshinoBot/NoneBot2/QQ官方频道/微信Bot的原神面板
|
||||
authors = ["KimigaiiWuyi <444835641@qq.com>"]
|
||||
license = "GPL-3.0-or-later"
|
||||
readme = "README.md"
|
||||
homepage = "https://github.com/KimigaiiWuyi/GenshinUID/tree/nonebot2-beta1"
|
||||
homepage = "https://github.com/KimigaiiWuyi/GenshinUID/tree/ntchat"
|
||||
repository = "https://github.com/KimigaiiWuyi/GenshinUID"
|
||||
documentation = "https://github.com/KimigaiiWuyi/GenshinUID/wiki"
|
||||
packages = [
|
||||
@ -42,7 +42,7 @@ exclude = ["tests", "deploy"]
|
||||
[tool.poetry.dependencies]
|
||||
python = "^3.8.1"
|
||||
nonebot2 = ">=2.0.0b4"
|
||||
nonebot-adapter-qqguild = ">=0.1.2"
|
||||
nonebot-adapter-ntchat = ">=0.3.4"
|
||||
httpx = ">=0.23.0"
|
||||
beautifulsoup4 = ">=4.11.1"
|
||||
lxml = ">=4.9.2"
|
||||
|
@ -22,20 +22,20 @@ frozenlist==1.3.3 ; python_full_version >= "3.8.1" and python_full_version < "4.
|
||||
gitdb==4.0.10 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
||||
gitpython==3.1.31 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
||||
greenlet==2.0.2 ; python_full_version >= "3.8.1" and (platform_machine == "aarch64" or platform_machine == "ppc64le" or platform_machine == "x86_64" or platform_machine == "amd64" or platform_machine == "AMD64" or platform_machine == "win32" or platform_machine == "WIN32") and python_full_version < "4.0.0"
|
||||
h11==0.14.0 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
||||
httpcore==0.16.3 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
||||
httpx==0.23.3 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
||||
h11==0.12.0 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
||||
httpcore==0.15.0 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
||||
httpx==0.23.0 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
||||
idna==3.4 ; python_full_version >= "3.8.1" and python_version < "4.0"
|
||||
loguru==0.6.0 ; python_full_version >= "3.8.1" and python_version < "4.0"
|
||||
lxml==4.9.2 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
||||
multidict==6.0.4 ; python_full_version >= "3.8.1" and python_version < "4.0"
|
||||
nonebot-adapter-qqguild==0.2.1 ; python_full_version >= "3.8.1" and python_version < "4.0"
|
||||
nonebot-adapter-ntchat==0.3.5 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
||||
nonebot-plugin-apscheduler==0.2.0 ; python_full_version >= "3.8.1" and python_version < "4.0"
|
||||
nonebot2==2.0.0rc3 ; python_full_version >= "3.8.1" and python_version < "4.0"
|
||||
openpyxl==3.1.1 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
||||
passlib==1.7.4 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
||||
pillow==9.4.0 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
||||
pydantic==1.10.6 ; python_full_version >= "3.8.1" and python_version < "4.0"
|
||||
pydantic==1.10.6 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
||||
pydantic[dotenv]==1.10.6 ; python_full_version >= "3.8.1" and python_version < "4.0"
|
||||
pygtrie==2.5.0 ; python_full_version >= "3.8.1" and python_version < "4.0"
|
||||
pypng==0.20220715.0 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
||||
|
@ -3,72 +3,72 @@ from pathlib import Path
|
||||
import pytest
|
||||
from nonebug import App
|
||||
|
||||
# TODO: update guide tests
|
||||
# @pytest.mark.asyncio
|
||||
# @pytest.mark.parametrize(
|
||||
# argnames="alias",
|
||||
# argvalues=[
|
||||
# "钟离推荐",
|
||||
# "钟离攻略",
|
||||
# "岩王爷攻略", # alias
|
||||
# ],
|
||||
# )
|
||||
# async def test_get_guide_pic(app: App, alias, load_guide: None):
|
||||
# from utils import make_event
|
||||
# from nonebot.adapters.onebot.v11 import Bot, Message, MessageSegment
|
||||
|
||||
# from GenshinUID.genshinuid_guide import get_guide_pic
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.parametrize(
|
||||
argnames="alias",
|
||||
argvalues=[
|
||||
"钟离推荐",
|
||||
"钟离攻略",
|
||||
"岩王爷攻略", # alias
|
||||
],
|
||||
)
|
||||
async def test_get_guide_pic(app: App, alias, load_guide: None):
|
||||
from utils import make_event
|
||||
from nonebot.adapters.onebot.v11 import Bot, Message, MessageSegment
|
||||
|
||||
# async with app.test_matcher(get_guide_pic) as ctx:
|
||||
# bot = ctx.create_bot(base=Bot)
|
||||
from GenshinUID.genshinuid_guide import get_guide_pic
|
||||
|
||||
# event = make_event(message=Message(alias))
|
||||
# ctx.receive_event(bot, event)
|
||||
# ctx.should_call_send(
|
||||
# event,
|
||||
# MessageSegment.image(
|
||||
# "https://file.microgg.cn/MiniGG/guide/钟离.jpg"
|
||||
# ),
|
||||
# True,
|
||||
# )
|
||||
# ctx.should_finished()
|
||||
async with app.test_matcher(get_guide_pic) as ctx:
|
||||
bot = ctx.create_bot(base=Bot)
|
||||
|
||||
event = make_event(message=Message(alias))
|
||||
ctx.receive_event(bot, event)
|
||||
ctx.should_call_send(
|
||||
event,
|
||||
MessageSegment.image(
|
||||
"https://file.microgg.cn/MiniGG/guide/钟离.jpg"
|
||||
),
|
||||
True,
|
||||
)
|
||||
ctx.should_finished()
|
||||
|
||||
|
||||
# @pytest.mark.asyncio
|
||||
# async def test_get_guide_pic_traveler(app: App, load_guide: None):
|
||||
# from utils import make_event
|
||||
# from nonebot.adapters.onebot.v11 import Bot, Message, MessageSegment
|
||||
@pytest.mark.asyncio
|
||||
async def test_get_guide_pic_traveler(app: App, load_guide: None):
|
||||
from utils import make_event
|
||||
from nonebot.adapters.onebot.v11 import Bot, Message, MessageSegment
|
||||
|
||||
# from GenshinUID.genshinuid_guide import get_guide_pic
|
||||
from GenshinUID.genshinuid_guide import get_guide_pic
|
||||
|
||||
# async with app.test_matcher(get_guide_pic) as ctx:
|
||||
# bot = ctx.create_bot(base=Bot)
|
||||
async with app.test_matcher(get_guide_pic) as ctx:
|
||||
bot = ctx.create_bot(base=Bot)
|
||||
|
||||
# event = make_event(message=Message("旅行者风推荐"))
|
||||
# ctx.receive_event(bot, event)
|
||||
# ctx.should_call_send(
|
||||
# event,
|
||||
# MessageSegment.image(
|
||||
# "https://file.microgg.cn/MiniGG/guide/旅行者-风.jpg"
|
||||
# ),
|
||||
# True,
|
||||
# )
|
||||
# ctx.should_finished()
|
||||
event = make_event(message=Message("旅行者风推荐"))
|
||||
ctx.receive_event(bot, event)
|
||||
ctx.should_call_send(
|
||||
event,
|
||||
MessageSegment.image(
|
||||
"https://file.microgg.cn/MiniGG/guide/旅行者-风.jpg"
|
||||
),
|
||||
True,
|
||||
)
|
||||
ctx.should_finished()
|
||||
|
||||
|
||||
# @pytest.mark.asyncio
|
||||
# async def test_get_guide_pic_failed(app: App, load_guide: None):
|
||||
# from utils import make_event
|
||||
# from nonebot.adapters.onebot.v11 import Bot, Message
|
||||
@pytest.mark.asyncio
|
||||
async def test_get_guide_pic_failed(app: App, load_guide: None):
|
||||
from utils import make_event
|
||||
from nonebot.adapters.onebot.v11 import Bot, Message
|
||||
|
||||
# from GenshinUID.genshinuid_guide import get_guide_pic
|
||||
from GenshinUID.genshinuid_guide import get_guide_pic
|
||||
|
||||
# async with app.test_matcher(get_guide_pic) as ctx:
|
||||
# bot = ctx.create_bot(base=Bot)
|
||||
async with app.test_matcher(get_guide_pic) as ctx:
|
||||
bot = ctx.create_bot(base=Bot)
|
||||
|
||||
# event = make_event(message=Message("蔡徐坤攻略"))
|
||||
# ctx.receive_event(bot, event)
|
||||
# ctx.should_finished()
|
||||
event = make_event(message=Message("蔡徐坤攻略"))
|
||||
ctx.receive_event(bot, event)
|
||||
ctx.should_finished()
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
@ -104,5 +104,6 @@ def make_event(
|
||||
"anonymous": anonymous,
|
||||
**kwargs,
|
||||
},
|
||||
str(self_id),
|
||||
),
|
||||
)
|
||||
|
Reference in New Issue
Block a user