mirror of
https://github.com/KimigaiiWuyi/GenshinUID.git
synced 2025-07-04 14:03:31 +00:00
Compare commits
582 Commits
nonebot2-b
...
main
Author | SHA1 | Date | |
---|---|---|---|
574d908fd4 | |||
42c57c0fda | |||
dc98f25514 | |||
303aad8df6 | |||
87cbd2af64 | |||
c27704089d | |||
8c6d5ed29e | |||
09d318bf2e | |||
96570f7774 | |||
05c89cdcff | |||
60e7e71f48 | |||
4baf75ef55 | |||
f16fd2d383 | |||
ed4b519d89 | |||
86b454ab99 | |||
49f61d1fc8 | |||
be009834ec | |||
57766ef6e4 | |||
ad06c09305 | |||
08d9ab738d | |||
2961685798 | |||
386ed31f85 | |||
f4b48c05f1 | |||
32c5b081e3 | |||
c0f2968dfe | |||
5a38f1575e | |||
5e223820e5 | |||
d203cdbfe9 | |||
0489649a59 | |||
845b55a9c8 | |||
bfb0c1d6a5 | |||
d937db7ddf | |||
ae5ea9f806 | |||
d2c73d0b35 | |||
b8511958c3 | |||
c7834872cb | |||
9bbff850c3 | |||
892160c347 | |||
bb6738407e | |||
ebcf210193 | |||
5805b502f7 | |||
7d9fbbb2d7 | |||
bf85710a0c | |||
204d265997 | |||
ab57306806 | |||
4dd4f44fdf | |||
b502a75f0e | |||
097c6cf0e7 | |||
f5214ac84a | |||
f2b6f410a1 | |||
b6849a0b8f | |||
a60cd5311a | |||
fe895c7360 | |||
91b199cb8e | |||
75f9784c42 | |||
e361833691 | |||
983ee6ee2e | |||
4ef3e580ed | |||
e2dd96f9f4 | |||
a26016842e | |||
63983ca097 | |||
85b53199d9 | |||
1e6f3eb833 | |||
f03d9eb79c | |||
8516093a54 | |||
d3f7bb00a7 | |||
10d7030b89 | |||
7a643f3614 | |||
30533608a3 | |||
a6df16a77e | |||
1278e462a5 | |||
544ff51f70 | |||
2b0a753f6b | |||
d93c8a91ef | |||
064bec0b44 | |||
0be8350990 | |||
2cab5fc497 | |||
55cd588fda | |||
2e3a796de4 | |||
fc30ef62e2 | |||
6ff4c6dc4e | |||
a37333902e | |||
f6f2ed13ec | |||
ab46d03bec | |||
2ed1b6120a | |||
21065764f2 | |||
a7055bc926 | |||
94ad87b725 | |||
c0d36979ac | |||
f361f0067a | |||
55dad23026 | |||
799bfdce3e | |||
3453905a82 | |||
923240c4d2 | |||
a97a01a7d9 | |||
2ec298be3a | |||
a1f086d24b | |||
5279c23e7f | |||
40cd95f3ca | |||
1e5aa0a899 | |||
6518166bd0 | |||
c68c2fab99 | |||
4e620b29e4 | |||
4323fd52d8 | |||
4fc5ae5d03 | |||
a6c3ccc890 | |||
19a7fb6219 | |||
ac4888469f | |||
8ab1a26df7 | |||
742cc36ca4 | |||
b6a301f796 | |||
3dcf462138 | |||
a1632a5fba | |||
f531e9422f | |||
b28f41f543 | |||
89ad282ed4 | |||
7d2864a40c | |||
96dad7e0ce | |||
b48789aa69 | |||
4664b80137 | |||
a395fc9f7e | |||
1f34c9d8a2 | |||
ebfde531e6 | |||
cc132c3e36 | |||
f16edc8b63 | |||
b7a19253da | |||
8fc962857c | |||
281d028878 | |||
a23e12b62e | |||
1df00f92ed | |||
1ce7348f62 | |||
e381d43fff | |||
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 | |||
d2ab169128 | |||
97260c8696 | |||
1b14f7986d | |||
2a8e54d1f0 | |||
6e92ed1daf | |||
d3c69bf2b1 | |||
93eba1e036 | |||
4d911c31ec | |||
d81d3db719 | |||
e9d4ae58be | |||
2c7148410f | |||
0a8d936839 | |||
64915421eb | |||
3ca8a28a02 | |||
711a7ed943 | |||
56ad8f5f33 | |||
3f5cf907d3 | |||
56e99ec00c | |||
b32ff63d6e | |||
88f2f66377 | |||
5fd0bbf27a | |||
29567d22ee | |||
0462f28d76 | |||
644c825e2f | |||
1e89b72e0d | |||
f8a7e1c34b | |||
ed7e5c5b79 | |||
82ad1efb19 | |||
fb555a9595 | |||
9a5fdd6690 | |||
8c8cb29cc4 | |||
012981f566 | |||
fb43d02c5a | |||
ac6631b9cd | |||
5ac8e61da1 | |||
b7e7a4e5e9 | |||
39c1ee24c7 | |||
60523102d2 | |||
035496965f | |||
f9701195a0 | |||
0ecb4b4b26 |
@ -1,16 +0,0 @@
|
|||||||
# .git
|
|
||||||
.vscode
|
|
||||||
.env
|
|
||||||
.venv
|
|
||||||
env
|
|
||||||
venv
|
|
||||||
.pytest_cache
|
|
||||||
*.pyc
|
|
||||||
*.pyo
|
|
||||||
*.pyd
|
|
||||||
.Python
|
|
||||||
tests
|
|
||||||
GenshinUID.egg-info
|
|
||||||
build
|
|
||||||
__pycache__
|
|
||||||
.pytest_cache
|
|
42
.github/workflows/unittest.yml
vendored
42
.github/workflows/unittest.yml
vendored
@ -1,42 +0,0 @@
|
|||||||
name: Unittest
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- nonebot2-beta1
|
|
||||||
pull_request:
|
|
||||||
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
test:
|
|
||||||
name: Test
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
version: ["3.8", "3.9", "3.10", "3.11"]
|
|
||||||
os: [ubuntu-latest, windows-latest]
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
env:
|
|
||||||
OS: ${{ matrix.os }}
|
|
||||||
PYTHON_VERSION: ${{ matrix.python-version }}
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
|
|
||||||
- name: Install poetry
|
|
||||||
run: pipx install poetry
|
|
||||||
shell: bash
|
|
||||||
|
|
||||||
- uses: actions/setup-python@v4
|
|
||||||
with:
|
|
||||||
python-version: ${{ matrix.version }}
|
|
||||||
architecture: "x64"
|
|
||||||
cache: "poetry"
|
|
||||||
|
|
||||||
- name: Install dependencies
|
|
||||||
run: poetry install --with test --without dev
|
|
||||||
shell: bash
|
|
||||||
|
|
||||||
- name: Run Pytest
|
|
||||||
run: |
|
|
||||||
cd tests
|
|
||||||
poetry run pytest
|
|
7
.gitignore
vendored
7
.gitignore
vendored
@ -210,7 +210,7 @@ celerybeat.pid
|
|||||||
*.sage.py
|
*.sage.py
|
||||||
|
|
||||||
# Environments
|
# Environments
|
||||||
.env/
|
.env
|
||||||
.venv
|
.venv
|
||||||
env/
|
env/
|
||||||
venv/
|
venv/
|
||||||
@ -668,6 +668,5 @@ result.txt
|
|||||||
### GenshinUID ###
|
### GenshinUID ###
|
||||||
GenshinUID/genshinuid_help/help.png
|
GenshinUID/genshinuid_help/help.png
|
||||||
GenshinUID/genshinuid_map/map_data
|
GenshinUID/genshinuid_map/map_data
|
||||||
|
.vscode/settings.json
|
||||||
### Debug ###
|
.vscode/settings.json
|
||||||
testnb2/
|
|
||||||
|
@ -1,12 +1,15 @@
|
|||||||
ci:
|
ci:
|
||||||
autofix_commit_msg: ":rotating_light: auto fix by pre-commit-ci"
|
autofix_commit_msg: ":rotating_light: auto fix by pre-commit-ci"
|
||||||
skip:
|
|
||||||
- "poetry-lock"
|
|
||||||
autofix_prs: true
|
autofix_prs: true
|
||||||
autoupdate_branch: master
|
autoupdate_branch: master
|
||||||
autoupdate_schedule: monthly
|
autoupdate_schedule: monthly
|
||||||
autoupdate_commit_msg: ":arrow_up: auto update by pre-commit-ci"
|
autoupdate_commit_msg: ":arrow_up: auto update by pre-commit-ci"
|
||||||
repos:
|
repos:
|
||||||
|
- repo: https://github.com/hadialqattan/pycln
|
||||||
|
rev: v2.1.2
|
||||||
|
hooks:
|
||||||
|
- id: pycln
|
||||||
|
|
||||||
- repo: https://github.com/pycqa/isort
|
- repo: https://github.com/pycqa/isort
|
||||||
rev: 5.11.5
|
rev: 5.11.5
|
||||||
hooks:
|
hooks:
|
||||||
@ -22,16 +25,17 @@ repos:
|
|||||||
hooks:
|
hooks:
|
||||||
- id: flake8
|
- id: flake8
|
||||||
|
|
||||||
- repo: https://github.com/hadialqattan/pycln
|
|
||||||
rev: v2.1.2
|
|
||||||
hooks:
|
|
||||||
- id: pycln
|
|
||||||
|
|
||||||
- repo: https://github.com/python-poetry/poetry
|
- repo: https://github.com/python-poetry/poetry
|
||||||
rev: 1.3.1
|
rev: 1.3.1
|
||||||
hooks:
|
hooks:
|
||||||
- id: poetry-check
|
- id: poetry-check
|
||||||
- id: poetry-lock
|
|
||||||
- id: poetry-export
|
- id: poetry-export
|
||||||
args: ["-f", "requirements.txt", "--without-hashes", "-o", "requirements.txt"]
|
args:
|
||||||
|
[
|
||||||
|
"-f",
|
||||||
|
"requirements.txt",
|
||||||
|
"--without-hashes",
|
||||||
|
"-o",
|
||||||
|
"requirements.txt",
|
||||||
|
]
|
||||||
verbose: true
|
verbose: true
|
||||||
|
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"python.languageServer": "Pylance",
|
"python.languageServer": "Pylance",
|
||||||
"python.analysis.typeCheckingMode": "basic",
|
"python.analysis.typeCheckingMode": "off",
|
||||||
"cSpell.words": [
|
"cSpell.words": [
|
||||||
"audioid",
|
"audioid",
|
||||||
"enka",
|
"enka",
|
||||||
|
43
Dockerfile
43
Dockerfile
@ -1,43 +0,0 @@
|
|||||||
FROM python:3.9
|
|
||||||
|
|
||||||
# 1. 环境设置
|
|
||||||
|
|
||||||
# 使用镜像源
|
|
||||||
RUN pip config set global.index-url https://mirrors.aliyun.com/pypi/simple
|
|
||||||
|
|
||||||
RUN apt-get update && apt-get install -y tzdata
|
|
||||||
|
|
||||||
ENV TZ Asia/Shanghai
|
|
||||||
|
|
||||||
# 2. 安装 GenshinUID
|
|
||||||
WORKDIR /plugin
|
|
||||||
|
|
||||||
COPY ./pyproject.toml ./LICENSE ./README.md /plugin/
|
|
||||||
|
|
||||||
COPY ./GenshinUID /plugin/GenshinUID/
|
|
||||||
|
|
||||||
RUN pip install --editable "."
|
|
||||||
|
|
||||||
COPY ./.git /plugin/.git
|
|
||||||
|
|
||||||
# 3. 生成 nb2 项目
|
|
||||||
WORKDIR /nb2
|
|
||||||
|
|
||||||
RUN pip install tomlkit "cookiecutter>=2.1.1"
|
|
||||||
|
|
||||||
COPY ./deploy/cookiecutter.yml ./deploy/update_pyproject.py /nb2/
|
|
||||||
|
|
||||||
# RUN cookiecutter --config-file ./cookiecutter.yml https://github.com/nonebot/nb-cli.git --directory="nb_cli/project" --no-input
|
|
||||||
# 使用镜像源
|
|
||||||
RUN cookiecutter --config-file ./cookiecutter.yml https://ghproxy.com/https://github.com/nonebot/nb-cli.git --directory="nb_cli/project" --no-input
|
|
||||||
|
|
||||||
RUN python update_pyproject.py
|
|
||||||
|
|
||||||
COPY ./deploy/.env.dev /nb2/nb2/
|
|
||||||
|
|
||||||
WORKDIR /nb2/nb2
|
|
||||||
|
|
||||||
EXPOSE 8080
|
|
||||||
|
|
||||||
|
|
||||||
CMD python bot.py
|
|
@ -1,25 +0,0 @@
|
|||||||
from pathlib import Path
|
|
||||||
from pkgutil import iter_modules
|
|
||||||
|
|
||||||
from nonebot.log import logger
|
|
||||||
from nonebot import require, load_all_plugins, get_plugin_by_module_name
|
|
||||||
|
|
||||||
from .config import config as _config
|
|
||||||
|
|
||||||
require('nonebot_plugin_apscheduler')
|
|
||||||
|
|
||||||
if get_plugin_by_module_name("GenshinUID"):
|
|
||||||
logger.info("推荐直接加载 GenshinUID 仓库文件夹")
|
|
||||||
load_all_plugins(
|
|
||||||
[
|
|
||||||
f"GenshinUID.{module.name}"
|
|
||||||
for module in iter_modules([str(Path(__file__).parent)])
|
|
||||||
if module.ispkg
|
|
||||||
and (
|
|
||||||
(name := module.name[11:]) == "meta"
|
|
||||||
or name not in _config.disabled_plugins
|
|
||||||
)
|
|
||||||
# module.name[:11] == genshinuid_
|
|
||||||
],
|
|
||||||
[],
|
|
||||||
)
|
|
||||||
|
6
GenshinUID/base.py
Normal file
6
GenshinUID/base.py
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
import hoshino
|
||||||
|
from hoshino import Service
|
||||||
|
|
||||||
|
sv = Service('genshinuid', bundle='genshin', help_='发送"原神帮助"查看详情')
|
||||||
|
hoshino_bot = hoshino.get_bot()
|
||||||
|
logger = sv.logger
|
@ -1,15 +0,0 @@
|
|||||||
from typing import Set
|
|
||||||
|
|
||||||
from nonebot import get_driver
|
|
||||||
from pydantic import Field, BaseModel
|
|
||||||
|
|
||||||
|
|
||||||
class Config(BaseModel):
|
|
||||||
disabled_plugins: Set[str] = Field(
|
|
||||||
default_factory=set, alias="genshinuid_disabled_plugins"
|
|
||||||
)
|
|
||||||
priority: int = Field(2, alias="genshinuid_priority")
|
|
||||||
|
|
||||||
|
|
||||||
config = Config.parse_obj(get_driver().config)
|
|
||||||
priority = config.priority
|
|
@ -1,84 +1,59 @@
|
|||||||
from typing import Any, Tuple, Union
|
import re
|
||||||
|
|
||||||
from nonebot import on_regex
|
from hoshino.typing import CQEvent, HoshinoBot
|
||||||
from nonebot.log import logger
|
|
||||||
from nonebot.matcher import Matcher
|
|
||||||
from nonebot.params import Depends, RegexGroup
|
|
||||||
from nonebot.adapters.onebot.v11 import (
|
|
||||||
MessageSegment,
|
|
||||||
GroupMessageEvent,
|
|
||||||
PrivateMessageEvent,
|
|
||||||
)
|
|
||||||
|
|
||||||
from ..genshinuid_meta import register_menu
|
from ..base import sv, logger
|
||||||
from .draw_abyss_card import draw_abyss_img
|
from .draw_abyss_card import draw_abyss_img
|
||||||
from ..utils.message.error_reply import UID_HINT
|
from ..utils.message.error_reply import UID_HINT
|
||||||
from ..utils.db_operation.db_operation import select_db
|
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.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(
|
|
||||||
|
@sv.on_rex(
|
||||||
r'^(\[CQ:at,qq=[0-9]+\])?( )?'
|
r'^(\[CQ:at,qq=[0-9]+\])?( )?'
|
||||||
r'(uid|查询|mys)?([0-9]+)?(上期)?(深渊|sy)'
|
r'(uid|查询|mys)?([0-9]+)?(上期)?(深渊|sy)'
|
||||||
r'(9|10|11|12|九|十|十一|十二)?(层)?'
|
r'(9|10|11|12|九|十|十一|十二)?(层)?'
|
||||||
r'(\[CQ:at,qq=[0-9]+\])?( )?$',
|
r'(\[CQ:at,qq=[0-9]+\])?( )?$',
|
||||||
block=True,
|
|
||||||
)
|
)
|
||||||
|
async def send_abyss_info(bot: HoshinoBot, ev: CQEvent):
|
||||||
|
args = ev['match'].groups()
|
||||||
@get_abyss_info.handle()
|
|
||||||
@handle_exception('查询深渊信息')
|
|
||||||
@register_menu(
|
|
||||||
'查询深渊信息',
|
|
||||||
'查询(@某人)(上期)深渊(xx层)',
|
|
||||||
'查询你的或者指定人的深渊战绩',
|
|
||||||
detail_des=(
|
|
||||||
'介绍:\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=(125,125,125)>(上期)</ft>'
|
|
||||||
'<ft color=(238,120,0)>深渊</ft>'
|
|
||||||
'<ft color=(125,125,125)>(xx层)</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,123,67)>@无疑Wuyi</ft> '
|
|
||||||
'<ft color=(238,120,0)>上期深渊12层</ft>'
|
|
||||||
),
|
|
||||||
)
|
|
||||||
async def send_abyss_info(
|
|
||||||
event: Union[GroupMessageEvent, PrivateMessageEvent],
|
|
||||||
matcher: Matcher,
|
|
||||||
args: Tuple[Any, ...] = RegexGroup(),
|
|
||||||
custom: ImageAndAt = Depends(),
|
|
||||||
):
|
|
||||||
logger.info('开始执行[查询深渊信息]')
|
logger.info('开始执行[查询深渊信息]')
|
||||||
logger.info(f'[查询深渊信息]参数: {args}')
|
logger.info('[查询深渊信息]参数: {}'.format(args))
|
||||||
at = custom.get_first_at()
|
at = re.search(r'\[CQ:at,qq=(\d*)]', str(ev.message))
|
||||||
qid = at or event.user_id
|
|
||||||
if args[2] == 'mys':
|
if at:
|
||||||
uid = await convert_mysid(args[3])
|
qid = int(at.group(1))
|
||||||
elif args[3] is None:
|
|
||||||
uid = await select_db(qid, mode='uid')
|
|
||||||
uid = str(uid)
|
|
||||||
elif len(args[3]) != 9:
|
|
||||||
return
|
|
||||||
else:
|
else:
|
||||||
uid = args[3]
|
if ev.sender:
|
||||||
logger.info(f'[查询深渊信息]uid: {uid}')
|
qid = int(ev.sender['user_id'])
|
||||||
|
else:
|
||||||
|
return
|
||||||
|
|
||||||
|
# 判断uid
|
||||||
|
if args[2] != 'mys':
|
||||||
|
if args[3] is None:
|
||||||
|
uid = await select_db(qid, mode='uid')
|
||||||
|
uid = str(uid)
|
||||||
|
elif len(args[3]) != 9:
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
uid = args[3]
|
||||||
|
else:
|
||||||
|
uid = await convert_mysid(args[3])
|
||||||
|
|
||||||
|
logger.info('[查询深渊信息]uid: {}'.format(uid))
|
||||||
|
|
||||||
if '未找到绑定的UID' in uid:
|
if '未找到绑定的UID' in uid:
|
||||||
await matcher.finish(UID_HINT)
|
await bot.send(ev, UID_HINT)
|
||||||
schedule_type = '1' if args[4] is None else '2'
|
|
||||||
logger.info(f'[查询深渊信息]深渊期数: {schedule_type}')
|
# 判断深渊期数
|
||||||
|
if args[4] is None:
|
||||||
|
schedule_type = '1'
|
||||||
|
else:
|
||||||
|
schedule_type = '2'
|
||||||
|
logger.info('[查询深渊信息]深渊期数: {}'.format(schedule_type))
|
||||||
|
|
||||||
if args[6] in ['九', '十', '十一', '十二']:
|
if args[6] in ['九', '十', '十一', '十二']:
|
||||||
floor = (
|
floor = (
|
||||||
args[6]
|
args[6]
|
||||||
@ -87,16 +62,17 @@ async def send_abyss_info(
|
|||||||
.replace('十二', '12')
|
.replace('十二', '12')
|
||||||
.replace('十', '10')
|
.replace('十', '10')
|
||||||
)
|
)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
floor = args[6]
|
floor = args[6]
|
||||||
if floor is not None:
|
if floor is not None:
|
||||||
floor = int(floor)
|
floor = int(floor)
|
||||||
logger.info(f'[查询深渊信息]深渊层数: {floor}')
|
logger.info('[查询深渊信息]深渊层数: {}'.format(floor))
|
||||||
|
|
||||||
im = await draw_abyss_img(uid, floor, schedule_type)
|
im = await draw_abyss_img(uid, floor, schedule_type)
|
||||||
if isinstance(im, str):
|
if isinstance(im, str):
|
||||||
await matcher.finish(im)
|
await bot.send(ev, im)
|
||||||
elif isinstance(im, bytes):
|
elif isinstance(im, bytes):
|
||||||
await matcher.finish(MessageSegment.image(im))
|
im = await convert_img(im)
|
||||||
|
await bot.send(ev, im)
|
||||||
else:
|
else:
|
||||||
await matcher.finish('发生了未知错误,请联系管理员检查后台输出!')
|
await bot.send(ev, '发生了未知错误,请联系管理员检查后台输出!')
|
||||||
|
@ -1,34 +1,36 @@
|
|||||||
from nonebot import on_command
|
from hoshino.typing import CQEvent, HoshinoBot
|
||||||
from nonebot.log import logger
|
|
||||||
from nonebot.matcher import Matcher
|
|
||||||
from nonebot.params import CommandArg
|
|
||||||
from nonebot.adapters.onebot.v11 import Message
|
|
||||||
|
|
||||||
from ..config import priority
|
from ..base import sv, logger
|
||||||
from .get_achi_desc import get_achi, get_daily_achi
|
from .get_achi_desc import get_achi, get_daily_achi
|
||||||
from ..utils.exception.handle_exception import handle_exception
|
|
||||||
|
|
||||||
get_task_info = on_command('查委托', aliases={'委托'}, priority=priority)
|
|
||||||
get_achi_info = on_command('查成就', aliases={'成就'}, priority=priority)
|
|
||||||
|
|
||||||
|
|
||||||
@get_task_info.handle()
|
@sv.on_prefix('查委托')
|
||||||
@handle_exception('查委托')
|
async def send_task_info(bot: HoshinoBot, ev: CQEvent):
|
||||||
async def send_task_info(matcher: Matcher, args: Message = CommandArg()):
|
if ev.message:
|
||||||
if not args:
|
message = ev.message.extract_plain_text().replace(' ', '')
|
||||||
|
else:
|
||||||
return
|
return
|
||||||
name = str(args[0])
|
|
||||||
|
if message == '':
|
||||||
|
return
|
||||||
|
|
||||||
|
name = str(message)
|
||||||
logger.info(f'[查委托] 参数:{name}')
|
logger.info(f'[查委托] 参数:{name}')
|
||||||
im = await get_daily_achi(name)
|
im = await get_daily_achi(name)
|
||||||
await matcher.finish(im)
|
await bot.send(ev, im)
|
||||||
|
|
||||||
|
|
||||||
@get_achi_info.handle()
|
@sv.on_prefix('查成就')
|
||||||
@handle_exception('查成就')
|
async def send_achi_info(bot: HoshinoBot, ev: CQEvent):
|
||||||
async def send_achi_info(matcher: Matcher, args: Message = CommandArg()):
|
if ev.message:
|
||||||
if not args:
|
message = ev.message.extract_plain_text().replace(' ', '')
|
||||||
|
else:
|
||||||
return
|
return
|
||||||
name = str(args[0])
|
|
||||||
|
if message == '':
|
||||||
|
return
|
||||||
|
|
||||||
|
name = str(message)
|
||||||
logger.info(f'[查成就] 参数:{name}')
|
logger.info(f'[查成就] 参数:{name}')
|
||||||
im = await get_achi(name)
|
im = await get_achi(name)
|
||||||
await matcher.finish(im)
|
await bot.send(ev, im)
|
||||||
|
@ -1,72 +1,19 @@
|
|||||||
from typing import Any, Tuple
|
from hoshino.typing import CQEvent, HoshinoBot
|
||||||
|
|
||||||
from nonebot import on_regex
|
from ..base import sv
|
||||||
from nonebot.matcher import Matcher
|
|
||||||
from nonebot.params import RegexGroup
|
|
||||||
|
|
||||||
from ..config import priority
|
|
||||||
from .get_adv import char_adv, weapon_adv
|
from .get_adv import char_adv, weapon_adv
|
||||||
from ..genshinuid_meta import register_menu
|
|
||||||
from ..utils.alias.alias_to_char_name import alias_to_char_name
|
from ..utils.alias.alias_to_char_name import alias_to_char_name
|
||||||
from ..utils.exception.handle_exception import handle_exception
|
|
||||||
|
|
||||||
get_char_adv = on_regex('([\u4e00-\u9fa5]+)(用什么|能用啥|怎么养)', priority=priority)
|
|
||||||
get_weapon_adv = on_regex(
|
|
||||||
'([\u4e00-\u9fa5]+)(能给谁|给谁用|要给谁|谁能用)', priority=priority
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@get_char_adv.handle()
|
@sv.on_rex(r'([\u4e00-\u9fa5]+)(用什么|能用啥|怎么养)')
|
||||||
@handle_exception('建议')
|
async def send_char_adv(bot: HoshinoBot, ev: CQEvent):
|
||||||
@register_menu(
|
name = await alias_to_char_name(str(ev['match'].group(1)))
|
||||||
'角色配置推荐',
|
|
||||||
'xx用什么',
|
|
||||||
'查询角色武器/圣遗物推荐配置',
|
|
||||||
detail_des=(
|
|
||||||
'介绍:\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>'
|
|
||||||
),
|
|
||||||
)
|
|
||||||
async def send_char_adv(
|
|
||||||
matcher: Matcher, args: Tuple[Any, ...] = RegexGroup()
|
|
||||||
):
|
|
||||||
name = await alias_to_char_name(str(args[0]))
|
|
||||||
im = await char_adv(name)
|
im = await char_adv(name)
|
||||||
await matcher.finish(im)
|
await bot.send(ev, im)
|
||||||
|
|
||||||
|
|
||||||
@get_weapon_adv.handle()
|
@sv.on_rex(r'([\u4e00-\u9fa5]+)(能给谁|给谁用|要给谁|谁能用)')
|
||||||
@handle_exception('建议')
|
async def send_weapon_adv(bot: HoshinoBot, ev: CQEvent):
|
||||||
@register_menu(
|
name = await alias_to_char_name(str(ev['match'].group(1)))
|
||||||
'装备适用角色',
|
|
||||||
'xx能给谁',
|
|
||||||
'查询某武器/圣遗物能给谁用',
|
|
||||||
detail_des=(
|
|
||||||
'介绍:\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>'
|
|
||||||
),
|
|
||||||
)
|
|
||||||
async def send_weapon_adv(
|
|
||||||
matcher: Matcher, args: Tuple[Any, ...] = RegexGroup()
|
|
||||||
):
|
|
||||||
name = await alias_to_char_name(str(args[0]))
|
|
||||||
im = await weapon_adv(name)
|
im = await weapon_adv(name)
|
||||||
await matcher.finish(im)
|
await bot.send(ev, im)
|
||||||
|
@ -1,96 +1,90 @@
|
|||||||
import random
|
import random
|
||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
from nonebot.log import logger
|
from nonebot import get_bot
|
||||||
from nonebot.matcher import Matcher
|
from hoshino import Service, priv
|
||||||
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.onebot.v11 import (
|
|
||||||
Message,
|
|
||||||
MessageEvent,
|
|
||||||
MessageSegment,
|
|
||||||
GroupMessageEvent,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
from ..base import logger
|
||||||
from .util import black_ids
|
from .util import black_ids
|
||||||
from ..config import priority
|
|
||||||
from .main import ann, consume_remind
|
from .main import ann, consume_remind
|
||||||
from ..utils.nonebot2.rule import FullCommand
|
|
||||||
from ..utils.message.error_reply import UID_HINT
|
from ..utils.message.error_reply import UID_HINT
|
||||||
from ..utils.db_operation.db_operation import select_db
|
from ..utils.db_operation.db_operation import select_db
|
||||||
from ..genshinuid_config.default_config import string_config
|
from ..genshinuid_config.default_config import string_config
|
||||||
from ..utils.exception.handle_exception import handle_exception
|
from ..utils.draw_image_tools.send_image_tool import convert_img
|
||||||
from .ann_card import sub_ann, unsub_ann, ann_list_card, ann_detail_card
|
from .ann_card import sub_ann, unsub_ann, ann_list_card, ann_detail_card
|
||||||
|
|
||||||
update_ann_scheduler = scheduler
|
sv_help = '''
|
||||||
get_ann_info = on_command('原神公告', priority=priority)
|
原神公告
|
||||||
reg_ann = on_command(
|
原神公告#ID
|
||||||
'订阅原神公告', priority=priority, rule=FullCommand(), permission=SUPERUSER
|
'''.strip()
|
||||||
|
|
||||||
|
sv = Service(
|
||||||
|
name='原神公告', # 功能名
|
||||||
|
use_priv=priv.NORMAL, # 使用权限
|
||||||
|
manage_priv=priv.ADMIN, # 管理权限
|
||||||
|
visible=True, # 可见性
|
||||||
|
enable_on_default=True, # 默认启用
|
||||||
|
# bundle = '娱乐', #分组归类
|
||||||
|
help_=sv_help, # 帮助说明
|
||||||
)
|
)
|
||||||
unreg_ann = on_command(
|
|
||||||
'取消订阅原神公告',
|
prefix = '原神'
|
||||||
aliases={'取消原神公告', '退订原神公告'},
|
|
||||||
priority=priority,
|
|
||||||
rule=FullCommand(),
|
|
||||||
permission=SUPERUSER,
|
|
||||||
)
|
|
||||||
consume_ann = on_command('清除原神公告红点', priority=priority, rule=FullCommand())
|
|
||||||
|
|
||||||
|
|
||||||
@get_ann_info.handle()
|
@sv.on_prefix((f'{prefix}公告#', f'{prefix}公告'))
|
||||||
@handle_exception('原神公告', '获取/发送原神公告失败')
|
async def ann_(bot, ev):
|
||||||
async def send_ann_pic(
|
ann_id = ev.message.extract_plain_text().strip()
|
||||||
matcher: Matcher,
|
|
||||||
args: Message = CommandArg(),
|
|
||||||
):
|
|
||||||
ann_id = str(args).replace(' ', '').replace('#', '')
|
|
||||||
|
|
||||||
if not ann_id:
|
if not ann_id:
|
||||||
img = await ann_list_card()
|
img = await ann_list_card()
|
||||||
await matcher.finish(MessageSegment.image(img))
|
img = await convert_img(img)
|
||||||
|
await bot.send(ev, img, at_sender=True)
|
||||||
|
return
|
||||||
|
|
||||||
if not ann_id.isdigit():
|
if not ann_id.isdigit():
|
||||||
raise Exception("公告ID不正确")
|
raise Exception("公告ID不正确")
|
||||||
|
try:
|
||||||
img = await ann_detail_card(int(ann_id))
|
img = await ann_detail_card(int(ann_id))
|
||||||
await matcher.finish(MessageSegment.image(img))
|
img = await convert_img(img)
|
||||||
|
await bot.send(ev, img, at_sender=True)
|
||||||
|
except Exception as e:
|
||||||
|
await bot.finish(ev, str(e))
|
||||||
|
|
||||||
|
|
||||||
@reg_ann.handle()
|
@sv.on_fullmatch(f'订阅{prefix}公告')
|
||||||
@handle_exception('设置原神公告', '设置原神公告失败')
|
async def sub_ann_(bot, ev):
|
||||||
async def send_reg_ann(
|
if not priv.check_priv(ev, priv.ADMIN):
|
||||||
event: GroupMessageEvent,
|
raise Exception("你没有权限开启原神公告推送")
|
||||||
matcher: Matcher,
|
try:
|
||||||
):
|
await bot.send(ev, sub_ann(ev.group_id))
|
||||||
await matcher.finish(sub_ann(event.group_id))
|
except Exception as e:
|
||||||
|
await bot.finish(ev, str(e))
|
||||||
|
|
||||||
|
|
||||||
@unreg_ann.handle()
|
@sv.on_fullmatch((f'取消订阅{prefix}公告', f'取消{prefix}公告', f'退订{prefix}公告'))
|
||||||
@handle_exception('取消原神公告', '取消设置原神公告失败')
|
async def unsub_ann_(bot, ev):
|
||||||
async def send_unreg_ann(
|
if not priv.check_priv(ev, priv.ADMIN):
|
||||||
event: GroupMessageEvent,
|
raise Exception("你没有权限取消原神公告推送")
|
||||||
matcher: Matcher,
|
try:
|
||||||
):
|
await bot.send(ev, unsub_ann(ev.group_id))
|
||||||
await matcher.finish(unsub_ann(event.group_id))
|
except Exception as e:
|
||||||
|
await bot.finish(ev, str(e))
|
||||||
|
|
||||||
|
|
||||||
@consume_ann.handle()
|
@sv.on_fullmatch(f'取消{prefix}公告红点')
|
||||||
@handle_exception('取消原神公告红点', '取消红点失败')
|
async def consume_remind_(bot, ev):
|
||||||
async def send_consume_ann(
|
try:
|
||||||
event: MessageEvent,
|
qid = int(ev.sender['user_id'])
|
||||||
matcher: Matcher,
|
uid = await select_db(qid, mode='uid')
|
||||||
):
|
uid = str(uid)
|
||||||
qid = event.user_id
|
if '未找到绑定的UID' in uid:
|
||||||
uid = await select_db(qid, mode='uid')
|
await bot.send(ev, UID_HINT)
|
||||||
uid = str(uid)
|
return
|
||||||
if '未找到绑定的UID' in uid:
|
await bot.send(ev, await consume_remind(uid), at_sender=True)
|
||||||
await matcher.finish(UID_HINT)
|
except Exception as e:
|
||||||
await matcher.finish(await consume_remind(uid))
|
await bot.finish(ev, str(e))
|
||||||
|
|
||||||
|
|
||||||
@update_ann_scheduler.scheduled_job('cron', minute=10)
|
@sv.scheduled_job('cron', minute=10)
|
||||||
async def check_ann():
|
async def check_ann():
|
||||||
await check_ann_state()
|
await check_ann_state()
|
||||||
|
|
||||||
@ -123,15 +117,12 @@ async def check_ann_state():
|
|||||||
if ann_id in black_ids:
|
if ann_id in black_ids:
|
||||||
continue
|
continue
|
||||||
try:
|
try:
|
||||||
img = await ann_detail_card(ann_id) # 防止抛出异常报错
|
img = await ann_detail_card(ann_id)
|
||||||
|
img = await convert_img(img)
|
||||||
bot = get_bot()
|
bot = get_bot()
|
||||||
for group in sub_list:
|
for group in sub_list:
|
||||||
try:
|
try:
|
||||||
await bot.call_api(
|
await bot.send_group_msg(group_id=group, message=img)
|
||||||
api='send_group_msg',
|
|
||||||
group_id=group,
|
|
||||||
message=MessageSegment.image(img),
|
|
||||||
)
|
|
||||||
await asyncio.sleep(random.uniform(1, 3))
|
await asyncio.sleep(random.uniform(1, 3))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.exception(e)
|
logger.exception(e)
|
||||||
|
@ -1,23 +1,10 @@
|
|||||||
import random
|
import random
|
||||||
import asyncio
|
import asyncio
|
||||||
from typing import Union
|
|
||||||
|
|
||||||
from nonebot import on_command
|
from hoshino.typing import CQEvent, HoshinoBot
|
||||||
from nonebot.log import logger
|
|
||||||
from nonebot.matcher import Matcher
|
|
||||||
from nonebot.permission import SUPERUSER
|
|
||||||
from nonebot_plugin_apscheduler import scheduler
|
|
||||||
from nonebot.adapters.onebot.v11 import (
|
|
||||||
Bot,
|
|
||||||
GroupMessageEvent,
|
|
||||||
PrivateMessageEvent,
|
|
||||||
)
|
|
||||||
|
|
||||||
from ..config import priority
|
from ..base import sv, logger
|
||||||
from .backup_data import data_backup
|
from .backup_data import data_backup
|
||||||
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_cache_and_check import check_db, check_stoken_db
|
||||||
from ..utils.db_operation.db_operation import delete_cookies, get_all_push_list
|
from ..utils.db_operation.db_operation import delete_cookies, get_all_push_list
|
||||||
from ..utils.message.get_cqhttp_data import (
|
from ..utils.message.get_cqhttp_data import (
|
||||||
@ -25,69 +12,35 @@ from ..utils.message.get_cqhttp_data import (
|
|||||||
get_group_member_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)
|
|
||||||
remove_invalid_user = on_command(
|
|
||||||
'清除无效用户', rule=FullCommand(), priority=priority
|
|
||||||
)
|
|
||||||
|
|
||||||
backup_scheduler = scheduler
|
@sv.scheduled_job('cron', hour=0)
|
||||||
|
|
||||||
|
|
||||||
@backup_scheduler.scheduled_job('cron', hour=0)
|
|
||||||
async def daily_refresh_charData():
|
async def daily_refresh_charData():
|
||||||
await data_backup()
|
await data_backup()
|
||||||
|
|
||||||
|
|
||||||
@backup.handle()
|
@sv.on_fullmatch('gs清除缓存')
|
||||||
@handle_exception('清除缓存', '清除缓存错误')
|
|
||||||
@register_menu(
|
|
||||||
'清除缓存',
|
|
||||||
'清除缓存',
|
|
||||||
'清除插件产生的缓存数据',
|
|
||||||
trigger_method='超级用户指令',
|
|
||||||
detail_des=(
|
|
||||||
'介绍:\n'
|
|
||||||
'备份一份插件数据库后清除插件产生的文件与数据库缓存\n'
|
|
||||||
' \n'
|
|
||||||
'指令:\n'
|
|
||||||
'- <ft color=(238,120,0)>清除缓存</ft>'
|
|
||||||
),
|
|
||||||
)
|
|
||||||
async def send_backup_msg(
|
async def send_backup_msg(
|
||||||
bot: Bot,
|
bot: HoshinoBot,
|
||||||
event: Union[GroupMessageEvent, PrivateMessageEvent],
|
ev: CQEvent,
|
||||||
matcher: Matcher,
|
|
||||||
):
|
):
|
||||||
if not await SUPERUSER(bot, event):
|
if ev.sender:
|
||||||
|
qid = int(ev.sender['user_id'])
|
||||||
|
else:
|
||||||
return
|
return
|
||||||
|
if qid not in bot.config.SUPERUSERS:
|
||||||
|
return
|
||||||
|
|
||||||
await data_backup()
|
await data_backup()
|
||||||
await matcher.finish('操作成功完成!')
|
await bot.send(ev, '操作成功完成!')
|
||||||
|
|
||||||
|
|
||||||
@remove_invalid_user.handle()
|
@sv.on_fullmatch('清除无效用户')
|
||||||
@handle_exception('清除无效用户', '清除无效用户错误')
|
async def send_remove_invalid_user_msg(bot: HoshinoBot, ev: CQEvent):
|
||||||
@register_menu(
|
if ev.sender:
|
||||||
'清除无效用户',
|
qid = int(ev.sender['user_id'])
|
||||||
'清除无效用户',
|
else:
|
||||||
'清除非好友或非推送群成员的数据',
|
return
|
||||||
trigger_method='超级用户指令',
|
if qid not in bot.config.SUPERUSERS:
|
||||||
detail_des=(
|
|
||||||
'介绍:\n'
|
|
||||||
'从数据库中删除掉 开启了私聊推送但不是Bot好友的用户 '
|
|
||||||
'以及 开启了群聊推送但不在推送目标群的用户 的数据\n'
|
|
||||||
' \n'
|
|
||||||
'指令:\n'
|
|
||||||
'- <ft color=(238,120,0)>清除无效用户</ft>'
|
|
||||||
),
|
|
||||||
)
|
|
||||||
async def send_remove_invalid_user_msg(
|
|
||||||
bot: Bot,
|
|
||||||
event: Union[GroupMessageEvent, PrivateMessageEvent],
|
|
||||||
matcher: Matcher,
|
|
||||||
):
|
|
||||||
if not await SUPERUSER(bot, event):
|
|
||||||
return
|
return
|
||||||
im_list = []
|
im_list = []
|
||||||
invalid_user = {}
|
invalid_user = {}
|
||||||
@ -109,78 +62,40 @@ async def send_remove_invalid_user_msg(
|
|||||||
for uid in invalid_uid_list:
|
for uid in invalid_uid_list:
|
||||||
im_list.append(await delete_cookies(str(uid)))
|
im_list.append(await delete_cookies(str(uid)))
|
||||||
logger.warning(f'无效UID已被删除: {uid}')
|
logger.warning(f'无效UID已被删除: {uid}')
|
||||||
await matcher.finish(f'已清理失效用户{len(im_list)}个!')
|
await bot.send(ev, f'已清理失效用户{len(im_list)}个!')
|
||||||
|
|
||||||
|
|
||||||
# 群聊内 校验Cookies 是否正常的功能,不正常自动删掉
|
# 群聊内 校验Cookies 是否正常的功能,不正常自动删掉
|
||||||
@check.handle()
|
@sv.on_fullmatch('校验全部Cookies')
|
||||||
@handle_exception('Cookie校验', 'Cookie校验错误')
|
async def send_check_cookies(bot: HoshinoBot, ev: CQEvent):
|
||||||
@register_menu(
|
|
||||||
'校验全部Cookies',
|
|
||||||
'校验全部Cookies',
|
|
||||||
'校验数据库内所有Cookies是否正常',
|
|
||||||
detail_des=(
|
|
||||||
'介绍:\n'
|
|
||||||
'校验数据库内所有Cookies是否正常,不正常的会自动删除\n'
|
|
||||||
' \n'
|
|
||||||
'指令:\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):
|
|
||||||
raw_mes = await check_db()
|
raw_mes = await check_db()
|
||||||
im = raw_mes[0]
|
im = raw_mes[0]
|
||||||
await matcher.send(im)
|
await bot.send(ev, im)
|
||||||
for i in raw_mes[1]:
|
for i in raw_mes[1]:
|
||||||
await bot.call_api(
|
await bot.send_private_msg(
|
||||||
api='send_private_msg',
|
user_id=i[0],
|
||||||
**{
|
message=(
|
||||||
'user_id': i[0],
|
'您绑定的Cookies(uid{})已失效,以下功能将会受到影响:\n'
|
||||||
'message': (
|
'查看完整信息列表\n查看深渊配队\n自动签到/当前状态/每月统计\n'
|
||||||
'您绑定的Cookies(uid{})已失效,以下功能将会受到影响:\n'
|
'请及时重新绑定Cookies并重新开关相应功能。'
|
||||||
'查看完整信息列表\n查看深渊配队\n自动签到/当前状态/每月统计\n'
|
).format(i[1]),
|
||||||
'请及时重新绑定Cookies并重新开关相应功能。'
|
|
||||||
).format(i[1]),
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
await asyncio.sleep(3 + random.randint(1, 3))
|
await asyncio.sleep(3 + random.randint(1, 3))
|
||||||
await matcher.finish()
|
|
||||||
|
|
||||||
|
|
||||||
# 群聊内 校验Stoken 是否正常的功能,不正常自动删掉
|
# 群聊内 校验Stoken 是否正常的功能,不正常自动删掉
|
||||||
@check_stoken.handle()
|
@sv.on_fullmatch('校验全部Stoken')
|
||||||
@handle_exception('Stoken校验', 'Stoken校验错误')
|
async def send_check_stoken(bot: HoshinoBot, ev: CQEvent):
|
||||||
@register_menu(
|
|
||||||
'校验全部Stoken',
|
|
||||||
'校验全部Stoken',
|
|
||||||
'校验数据库内所有Stoken是否正常',
|
|
||||||
detail_des=(
|
|
||||||
'介绍:\n'
|
|
||||||
'校验数据库内所有Stoken是否正常,不正常的会自动删除\n'
|
|
||||||
' \n'
|
|
||||||
'指令:\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):
|
|
||||||
raw_mes = await check_stoken_db()
|
raw_mes = await check_stoken_db()
|
||||||
im = raw_mes[0]
|
im = raw_mes[0]
|
||||||
await matcher.send(im)
|
await bot.send(ev, im)
|
||||||
for i in raw_mes[1]:
|
for i in raw_mes[1]:
|
||||||
await bot.call_api(
|
await bot.send_private_msg(
|
||||||
api='send_private_msg',
|
user_id=i[0],
|
||||||
**{
|
message=(
|
||||||
'user_id': i[0],
|
'您绑定的Stoken(uid{})已失效,以下功能将会受到影响:\n'
|
||||||
'message': (
|
'gs开启自动米游币,开始获取米游币。\n'
|
||||||
'您绑定的Stoken(uid{})已失效,以下功能将会受到影响:\n'
|
'重新添加后需要重新开启自动米游币。'
|
||||||
'gs开启自动米游币,开始获取米游币。\n'
|
).format(i[1]),
|
||||||
'重新添加后需要重新开启自动米游币。'
|
|
||||||
).format(i[1]),
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
await asyncio.sleep(3 + random.randint(1, 3))
|
await asyncio.sleep(3 + random.randint(1, 3))
|
||||||
|
|
||||||
await matcher.finish()
|
|
||||||
|
@ -1,112 +1,70 @@
|
|||||||
from typing import Union
|
import re
|
||||||
|
|
||||||
from nonebot import on_command
|
from hoshino.typing import CQEvent, HoshinoBot
|
||||||
from nonebot.log import logger
|
|
||||||
from nonebot.matcher import Matcher
|
|
||||||
from nonebot.params import Depends, CommandArg
|
|
||||||
from nonebot.adapters.onebot.v11 import (
|
|
||||||
Message,
|
|
||||||
MessageSegment,
|
|
||||||
GroupMessageEvent,
|
|
||||||
PrivateMessageEvent,
|
|
||||||
)
|
|
||||||
|
|
||||||
from ..genshinuid_meta import register_menu
|
from ..base import sv, logger
|
||||||
from ..utils.data_convert.get_uid import get_uid
|
from ..utils.data_convert.get_uid import get_uid
|
||||||
from ..utils.message.error_reply import UID_HINT
|
from ..utils.message.error_reply import UID_HINT
|
||||||
from ..utils.message.get_image_and_at import ImageAndAt
|
from ..utils.message.error_reply import * # noqa: F403,F401
|
||||||
from ..utils.exception.handle_exception import handle_exception
|
from ..utils.draw_image_tools.send_image_tool import convert_img
|
||||||
from .draw_collection_card import draw_explora_img, draw_collection_img
|
from .draw_collection_card import draw_explora_img, draw_collection_img
|
||||||
|
|
||||||
get_collection_info = on_command('查询收集', aliases={'收集', 'sj'}, block=True)
|
|
||||||
get_explora_info = on_command('查询探索', aliases={'探索', 'ts'}, block=True)
|
|
||||||
|
|
||||||
|
@sv.on_prefix(('查询收集', '收集', 'sj'))
|
||||||
@get_collection_info.handle()
|
async def send_collection_info(bot: HoshinoBot, ev: CQEvent):
|
||||||
@handle_exception('查询收集信息')
|
raw_mes = ev.message.extract_plain_text().replace(' ', '')
|
||||||
@register_menu(
|
|
||||||
'查询收集信息',
|
|
||||||
'查询(@某人)收集',
|
|
||||||
'查询你的或者指定人的宝箱收集度',
|
|
||||||
detail_des=(
|
|
||||||
'介绍:\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,123,67)>@无疑Wuyi'
|
|
||||||
'</ft> <ft color=(238,120,0)>bx</ft>'
|
|
||||||
),
|
|
||||||
)
|
|
||||||
async def send_collection_info(
|
|
||||||
event: Union[GroupMessageEvent, PrivateMessageEvent],
|
|
||||||
matcher: Matcher,
|
|
||||||
args: Message = CommandArg(),
|
|
||||||
custom: ImageAndAt = Depends(),
|
|
||||||
):
|
|
||||||
logger.info('开始执行[查询收集信息]')
|
logger.info('开始执行[查询收集信息]')
|
||||||
logger.info('[查询收集信息]参数: {}'.format(args))
|
at = re.search(r'\[CQ:at,qq=(\d*)]', raw_mes)
|
||||||
raw_mes = args.extract_plain_text().strip()
|
|
||||||
at = custom.get_first_at()
|
if at:
|
||||||
if at:
|
qid = int(at.group(1))
|
||||||
qid = at
|
else:
|
||||||
else:
|
if ev.sender:
|
||||||
qid = event.user_id
|
qid = int(ev.sender['user_id'])
|
||||||
|
else:
|
||||||
|
return
|
||||||
|
|
||||||
# 获取uid
|
|
||||||
uid = await get_uid(qid, raw_mes)
|
uid = await get_uid(qid, raw_mes)
|
||||||
logger.info('[查询角色面板]uid: {}'.format(uid))
|
logger.info('[查询收集信息]uid: {}'.format(uid))
|
||||||
|
|
||||||
if '未找到绑定的UID' in uid:
|
if '未找到绑定的UID' in uid:
|
||||||
await matcher.finish(UID_HINT)
|
await bot.send(ev, UID_HINT)
|
||||||
|
|
||||||
im = await draw_collection_img(qid, uid)
|
im = await draw_collection_img(qid, uid)
|
||||||
if isinstance(im, str):
|
if isinstance(im, str):
|
||||||
await matcher.finish(im)
|
await bot.send(ev, im)
|
||||||
elif isinstance(im, bytes):
|
elif isinstance(im, bytes):
|
||||||
await matcher.finish(MessageSegment.image(im))
|
im = await convert_img(im)
|
||||||
|
await bot.send(ev, im)
|
||||||
else:
|
else:
|
||||||
await matcher.finish('发生了未知错误,请联系管理员检查后台输出!')
|
await bot.send(ev, '发生了未知错误,请联系管理员检查后台输出!')
|
||||||
|
|
||||||
|
|
||||||
@get_explora_info.handle()
|
@sv.on_prefix(('查询探索', '探索', 'ts'))
|
||||||
@handle_exception('查询探索信息')
|
async def send_explora_info(bot: HoshinoBot, ev: CQEvent):
|
||||||
async def send_explora_info(
|
raw_mes = ev.message.extract_plain_text().replace(' ', '')
|
||||||
event: Union[GroupMessageEvent, PrivateMessageEvent],
|
|
||||||
matcher: Matcher,
|
|
||||||
args: Message = CommandArg(),
|
|
||||||
custom: ImageAndAt = Depends(),
|
|
||||||
):
|
|
||||||
logger.info('开始执行[查询探索信息]')
|
logger.info('开始执行[查询探索信息]')
|
||||||
logger.info('[查询探索信息]参数: {}'.format(args))
|
at = re.search(r'\[CQ:at,qq=(\d*)]', raw_mes)
|
||||||
raw_mes = args.extract_plain_text().strip()
|
|
||||||
at = custom.get_first_at()
|
if at:
|
||||||
if at:
|
qid = int(at.group(1))
|
||||||
qid = at
|
else:
|
||||||
else:
|
if ev.sender:
|
||||||
qid = event.user_id
|
qid = int(ev.sender['user_id'])
|
||||||
|
else:
|
||||||
|
return
|
||||||
|
|
||||||
# 获取uid
|
|
||||||
uid = await get_uid(qid, raw_mes)
|
uid = await get_uid(qid, raw_mes)
|
||||||
logger.info('[查询角色面板]uid: {}'.format(uid))
|
logger.info('[查询探索信息]uid: {}'.format(uid))
|
||||||
|
|
||||||
if '未找到绑定的UID' in uid:
|
if '未找到绑定的UID' in uid:
|
||||||
await matcher.finish(UID_HINT)
|
await bot.send(ev, UID_HINT)
|
||||||
|
|
||||||
im = await draw_explora_img(qid, uid)
|
im = await draw_explora_img(qid, uid)
|
||||||
if isinstance(im, str):
|
if isinstance(im, str):
|
||||||
await matcher.finish(im)
|
await bot.send(ev, im)
|
||||||
elif isinstance(im, bytes):
|
elif isinstance(im, bytes):
|
||||||
await matcher.finish(MessageSegment.image(im))
|
im = await convert_img(im)
|
||||||
|
await bot.send(ev, im)
|
||||||
else:
|
else:
|
||||||
await matcher.finish('发生了未知错误,请联系管理员检查后台输出!')
|
await bot.send(ev, '发生了未知错误,请联系管理员检查后台输出!')
|
||||||
|
@ -1,153 +1,98 @@
|
|||||||
from typing import Any, Tuple, Union
|
import re
|
||||||
|
|
||||||
from nonebot.log import logger
|
from hoshino.typing import CQEvent, HoshinoBot
|
||||||
from nonebot.matcher import Matcher
|
|
||||||
from nonebot import on_regex, on_command
|
|
||||||
from nonebot.permission import SUPERUSER
|
|
||||||
from nonebot.params import Depends, CommandArg, RegexGroup
|
|
||||||
from nonebot.adapters.onebot.v11 import (
|
|
||||||
Bot,
|
|
||||||
Message,
|
|
||||||
MessageSegment,
|
|
||||||
GroupMessageEvent,
|
|
||||||
PrivateMessageEvent,
|
|
||||||
)
|
|
||||||
|
|
||||||
from ..genshinuid_meta import register_menu
|
from ..base import sv, logger
|
||||||
from .draw_config_card import draw_config_img
|
from .draw_config_card import draw_config_img
|
||||||
from ..utils.message.error_reply import UID_HINT
|
from ..utils.message.error_reply import UID_HINT
|
||||||
from ..utils.db_operation.db_operation import select_db
|
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 .set_config import set_push_value, set_config_func
|
||||||
from ..utils.exception.handle_exception import handle_exception
|
from ..utils.message.error_reply import * # noqa: F403,F401
|
||||||
|
from ..utils.draw_image_tools.send_image_tool import convert_img
|
||||||
|
|
||||||
open_and_close_switch = on_regex(
|
|
||||||
r'^(\[CQ:at,qq=[0-9]+\])?( )?'
|
|
||||||
r'(gs)(开启|关闭)(.*)'
|
|
||||||
r'(\[CQ:at,qq=[0-9]+\])?( )?$'
|
|
||||||
)
|
|
||||||
|
|
||||||
push_config = on_regex(
|
@sv.on_fullmatch('gs配置')
|
||||||
|
async def send_config_card(bot: HoshinoBot, ev: CQEvent):
|
||||||
|
logger.info('开始执行[gs配置]')
|
||||||
|
im = await draw_config_img()
|
||||||
|
if isinstance(im, str):
|
||||||
|
await bot.send(ev, im)
|
||||||
|
elif isinstance(im, bytes):
|
||||||
|
im = await convert_img(im)
|
||||||
|
await bot.send(ev, im)
|
||||||
|
else:
|
||||||
|
await bot.send(ev, '发生了未知错误,请联系管理员检查后台输出!')
|
||||||
|
|
||||||
|
|
||||||
|
@sv.on_rex(
|
||||||
r'^(\[CQ:at,qq=[0-9]+\])?( )?'
|
r'^(\[CQ:at,qq=[0-9]+\])?( )?'
|
||||||
r'(gs)(设置)([\u4e00-\u9fffa-zA-Z]*)([0-9]*)'
|
r'(gs)(设置)([\u4e00-\u9fffa-zA-Z]*)([0-9]*)'
|
||||||
r'(\[CQ:at,qq=[0-9]+\])?( )?$'
|
r'(\[CQ:at,qq=[0-9]+\])?( )?$'
|
||||||
)
|
)
|
||||||
|
async def send_config_msg(bot: HoshinoBot, ev: CQEvent):
|
||||||
config_card = on_command('gs配置')
|
args = ev['match'].groups()
|
||||||
|
|
||||||
|
|
||||||
@config_card.handle()
|
|
||||||
@handle_exception('发送配置表')
|
|
||||||
@register_menu(
|
|
||||||
'发送配置表',
|
|
||||||
'gs配置',
|
|
||||||
'查看插件当前配置项开关情况',
|
|
||||||
detail_des=(
|
|
||||||
'介绍:\n'
|
|
||||||
'查看插件当前配置项开关情况\n'
|
|
||||||
' \n'
|
|
||||||
'指令:\n'
|
|
||||||
'- <ft color=(238,120,0)>gs配置</ft>'
|
|
||||||
),
|
|
||||||
)
|
|
||||||
async def send_config_card(matcher: Matcher, args: Message = CommandArg()):
|
|
||||||
if args:
|
|
||||||
await matcher.finish()
|
|
||||||
logger.info('开始执行[gs配置]')
|
|
||||||
im = await draw_config_img()
|
|
||||||
if isinstance(im, str):
|
|
||||||
await matcher.finish(im)
|
|
||||||
elif isinstance(im, bytes):
|
|
||||||
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: Union[GroupMessageEvent, PrivateMessageEvent],
|
|
||||||
matcher: Matcher,
|
|
||||||
args: Tuple[Any, ...] = RegexGroup(),
|
|
||||||
custom: ImageAndAt = Depends(),
|
|
||||||
):
|
|
||||||
logger.info('开始执行[设置阈值信息]')
|
logger.info('开始执行[设置阈值信息]')
|
||||||
logger.info('[设置阈值信息]参数: {}'.format(args))
|
logger.info('[设置阈值信息]参数: {}'.format(args))
|
||||||
qid = event.user_id
|
|
||||||
at = custom.get_first_at()
|
|
||||||
|
|
||||||
if at and await SUPERUSER(bot, event):
|
at = re.search(r'\[CQ:at,qq=(\d*)]', str(ev.message))
|
||||||
|
|
||||||
|
if at:
|
||||||
|
qid = int(at.group(1))
|
||||||
|
else:
|
||||||
|
if ev.sender:
|
||||||
|
qid = int(ev.sender['user_id'])
|
||||||
|
else:
|
||||||
|
return
|
||||||
|
|
||||||
|
if qid in bot.config.SUPERUSERS:
|
||||||
|
is_admin = True
|
||||||
|
else:
|
||||||
|
is_admin = False
|
||||||
|
|
||||||
|
if at and is_admin:
|
||||||
qid = at
|
qid = at
|
||||||
elif at and at != qid:
|
elif at and at != qid:
|
||||||
await matcher.finish('你没有权限操作别人的状态噢~', at_sender=True)
|
await bot.send(ev, '你没有权限操作别人的状态噢~', at_sender=True)
|
||||||
logger.info('[设置阈值信息]qid: {}'.format(qid))
|
logger.info('[设置阈值信息]qid: {}'.format(qid))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
uid = await select_db(qid, mode='uid')
|
uid = await select_db(qid, mode='uid')
|
||||||
except TypeError:
|
except TypeError:
|
||||||
await matcher.finish(UID_HINT)
|
await bot.send(ev, UID_HINT)
|
||||||
|
return
|
||||||
|
|
||||||
func = args[4].replace('阈值', '')
|
func = args[4].replace('阈值', '')
|
||||||
if args[5]:
|
if args[5]:
|
||||||
try:
|
try:
|
||||||
value = int(args[5])
|
value = int(args[5])
|
||||||
except ValueError:
|
except ValueError:
|
||||||
await matcher.finish('请输入数字哦~', at_sender=True)
|
await bot.send(ev, '请输入数字哦~', at_sender=True)
|
||||||
|
return
|
||||||
else:
|
else:
|
||||||
await matcher.finish('请输入正确的阈值数字!', at_sender=True)
|
await bot.send(ev, '请输入正确的阈值数字!', at_sender=True)
|
||||||
|
return
|
||||||
logger.info('[设置阈值信息]func: {}, value: {}'.format(func, value))
|
logger.info('[设置阈值信息]func: {}, value: {}'.format(func, value))
|
||||||
im = await set_push_value(func, str(uid), value)
|
im = await set_push_value(func, str(uid), value)
|
||||||
await matcher.finish(im, at_sender=True)
|
await bot.send(ev, im, at_sender=True)
|
||||||
|
|
||||||
|
|
||||||
# 开启 自动签到 和 推送树脂提醒 功能
|
# 开启 自动签到 和 推送树脂提醒 功能
|
||||||
@open_and_close_switch.handle()
|
@sv.on_rex(
|
||||||
@register_menu(
|
r'^(\[CQ:at,qq=[0-9]+\])?( )?'
|
||||||
'开关推送服务',
|
r'(gs)(开启|关闭)(.*)'
|
||||||
'gs{开启|关闭}xx(@某人)',
|
r'(\[CQ:at,qq=[0-9]+\])?( )?$'
|
||||||
'开关自己或指定人的推送服务状态',
|
|
||||||
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(
|
async def open_switch_func(bot: HoshinoBot, ev: CQEvent):
|
||||||
bot: Bot,
|
args = ev['match'].groups()
|
||||||
event: Union[GroupMessageEvent, PrivateMessageEvent],
|
at = re.search(r'\[CQ:at,qq=(\d*)]', str(ev.message))
|
||||||
matcher: Matcher,
|
|
||||||
args: Tuple[Any, ...] = RegexGroup(),
|
if at:
|
||||||
at: ImageAndAt = Depends(),
|
qid = int(at.group(1))
|
||||||
):
|
else:
|
||||||
qid = event.user_id
|
if ev.sender:
|
||||||
atqq = at.get_first_at() if at else None
|
qid = int(ev.sender['user_id'])
|
||||||
|
else:
|
||||||
|
return
|
||||||
|
|
||||||
config_name = args[4]
|
config_name = args[4]
|
||||||
|
|
||||||
@ -155,31 +100,34 @@ async def open_switch_func(
|
|||||||
|
|
||||||
if args[3] == '开启':
|
if args[3] == '开启':
|
||||||
query = 'OPEN'
|
query = 'OPEN'
|
||||||
gid = (
|
gid = str(ev.group_id) if ev.group_id else 'on'
|
||||||
event.get_session_id().split('_')[1]
|
|
||||||
if len(event.get_session_id().split('_')) == 3
|
|
||||||
else 'on'
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
query = 'CLOSED'
|
query = 'CLOSED'
|
||||||
gid = 'off'
|
gid = 'off'
|
||||||
is_admin = await SUPERUSER(bot, event)
|
|
||||||
if atqq:
|
|
||||||
if is_admin:
|
|
||||||
qid = atqq
|
|
||||||
elif atqq != qid:
|
|
||||||
await matcher.finish('你没有权限操作别人的状态噢~', at_sender=True)
|
|
||||||
|
|
||||||
uid = await select_db(qid, mode='uid')
|
if qid in bot.config.SUPERUSERS:
|
||||||
if uid is None or not isinstance(uid, str) or not uid.isdecimal():
|
is_admin = True
|
||||||
await matcher.finish(UID_HINT)
|
else:
|
||||||
|
is_admin = False
|
||||||
|
|
||||||
|
if at and is_admin:
|
||||||
|
qid = at
|
||||||
|
elif at and at != qid:
|
||||||
|
bot.send(ev, '你没有权限操作别人的状态噢~', at_sender=True)
|
||||||
|
return
|
||||||
|
|
||||||
|
try:
|
||||||
|
uid = await select_db(qid, mode='uid')
|
||||||
|
except TypeError:
|
||||||
|
await bot.send(ev, UID_HINT)
|
||||||
|
return
|
||||||
|
|
||||||
im = await set_config_func(
|
im = await set_config_func(
|
||||||
config_name=config_name,
|
config_name=config_name,
|
||||||
uid=uid,
|
uid=uid, # type: ignore
|
||||||
qid=str(qid),
|
qid=qid, # type: ignore
|
||||||
option=gid,
|
option=gid,
|
||||||
query=query,
|
query=query,
|
||||||
is_admin=is_admin,
|
is_admin=is_admin,
|
||||||
)
|
)
|
||||||
await matcher.finish(im, at_sender=True)
|
await bot.send(ev, im, at_sender=True)
|
||||||
|
@ -1,15 +1,17 @@
|
|||||||
from nonebot import on_command
|
from hoshino.typing import CQEvent, HoshinoBot
|
||||||
from nonebot.matcher import Matcher
|
|
||||||
from nonebot.permission import SUPERUSER
|
|
||||||
|
|
||||||
|
from ..base import sv
|
||||||
from .export_data import export_v3
|
from .export_data import export_v3
|
||||||
from ..utils.nonebot2.rule import FullCommand
|
|
||||||
|
|
||||||
export_v3_data = on_command('导出v3数据', permission=SUPERUSER, rule=FullCommand())
|
|
||||||
|
|
||||||
|
|
||||||
@export_v3_data.handle()
|
@sv.on_prefix(('导出v3数据'))
|
||||||
async def send_export_msg(matcher: Matcher):
|
async def send_export_msg(bot: HoshinoBot, ev: CQEvent):
|
||||||
await matcher.send('开始导出数据..可能需要一定时间!')
|
if ev.sender:
|
||||||
|
qid = int(ev.sender['user_id'])
|
||||||
|
else:
|
||||||
|
return
|
||||||
|
if qid not in bot.config.SUPERUSERS:
|
||||||
|
return
|
||||||
|
await bot.send(ev, '开始导出数据..可能需要一定时间!')
|
||||||
await export_v3()
|
await export_v3()
|
||||||
await matcher.send('导出数据成功!')
|
await bot.send(ev, '导出数据成功!')
|
||||||
|
@ -1,196 +1,106 @@
|
|||||||
import re
|
import re
|
||||||
import random
|
import random
|
||||||
import asyncio
|
import asyncio
|
||||||
from typing import Tuple, Union
|
from typing import Tuple
|
||||||
|
|
||||||
from nonebot import on_command
|
from hoshino.typing import CQEvent, HoshinoBot
|
||||||
from nonebot.log import logger
|
|
||||||
from nonebot.matcher import Matcher
|
|
||||||
from nonebot.permission import SUPERUSER
|
|
||||||
from nonebot.params import Depends, CommandArg
|
|
||||||
from nonebot_plugin_apscheduler import scheduler
|
|
||||||
from nonebot.adapters.onebot.v11 import (
|
|
||||||
Bot,
|
|
||||||
Message,
|
|
||||||
MessageSegment,
|
|
||||||
GroupMessageEvent,
|
|
||||||
PrivateMessageEvent,
|
|
||||||
)
|
|
||||||
|
|
||||||
from ..config import priority
|
from ..base import sv, logger
|
||||||
from .get_enka_img import draw_enka_img
|
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 .draw_char_rank import draw_cahrcard_list
|
||||||
from ..utils.message.error_reply import UID_HINT
|
from ..utils.message.error_reply import UID_HINT
|
||||||
from ..utils.enka_api.get_enka_data import switch_api
|
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_card import enka_to_card
|
||||||
from ..utils.enka_api.enka_to_data import enka_to_data
|
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.download_resource.RESOURCE_PATH import TEMP_PATH
|
||||||
from ..utils.exception.handle_exception import handle_exception
|
from ..utils.draw_image_tools.send_image_tool import convert_img
|
||||||
from ..utils.db_operation.db_operation import select_db, get_all_uid
|
from ..utils.db_operation.db_operation import select_db, get_all_uid
|
||||||
|
|
||||||
refresh = on_command('强制刷新')
|
|
||||||
original_pic = on_command('原图', rule=FullCommand())
|
|
||||||
change_api = on_command('切换api')
|
|
||||||
get_charcard_list = on_command('毕业度统计')
|
|
||||||
get_char_info = on_command(
|
|
||||||
'查询',
|
|
||||||
priority=priority,
|
|
||||||
)
|
|
||||||
|
|
||||||
AUTO_REFRESH = False
|
AUTO_REFRESH = False
|
||||||
refresh_scheduler = scheduler
|
|
||||||
|
|
||||||
|
|
||||||
@change_api.handle()
|
@sv.on_fullmatch('切换api')
|
||||||
@handle_exception('切换api')
|
async def send_change_api_info(bot: HoshinoBot, ev: CQEvent):
|
||||||
@register_menu(
|
print(ev)
|
||||||
'切换API',
|
if ev.sender:
|
||||||
'切换api',
|
qid = int(ev.sender['user_id'])
|
||||||
'切换获取角色面板时使用的API',
|
else:
|
||||||
detail_des=(
|
return
|
||||||
'介绍:\n'
|
|
||||||
'切换获取角色面板时使用的Enka Network API\n'
|
if qid not in bot.config.SUPERUSERS:
|
||||||
' \n'
|
|
||||||
'指令:\n'
|
|
||||||
'- <ft color=(238,120,0)>切换api</ft>'
|
|
||||||
),
|
|
||||||
)
|
|
||||||
async def send_change_api_info(
|
|
||||||
bot: Bot,
|
|
||||||
event: Union[GroupMessageEvent, PrivateMessageEvent],
|
|
||||||
matcher: Matcher,
|
|
||||||
args: Message = CommandArg(),
|
|
||||||
):
|
|
||||||
if args or not await SUPERUSER(bot, event):
|
|
||||||
return
|
return
|
||||||
|
|
||||||
im = await switch_api()
|
im = await switch_api()
|
||||||
await matcher.finish(im)
|
await bot.send(ev, im)
|
||||||
|
|
||||||
|
|
||||||
@original_pic.handle()
|
@sv.on_rex(r'^(\[CQ:reply,id=[0-9]+\])?( )?(\[CQ:at,qq=[0-9]+\])?( )?原图')
|
||||||
@handle_exception('原图')
|
async def send_original_pic(bot: HoshinoBot, ev: CQEvent):
|
||||||
@register_menu(
|
for msg in ev.message:
|
||||||
'查看面板原图',
|
if msg['type'] == 'reply':
|
||||||
'原图',
|
msg_id = msg['data']['id']
|
||||||
'查看角色面板中原随机图',
|
path = TEMP_PATH / f'{msg_id}.jpg'
|
||||||
trigger_method='回复+指令',
|
if path.exists():
|
||||||
detail_des=(
|
logger.info('[原图]访问图片: {}'.format(path))
|
||||||
'介绍:\n'
|
with open(path, 'rb') as f:
|
||||||
'查看开启随机图功能时角色面板中角色位置的原图,需要回复要查看原图的面板图片消息\n'
|
im = await convert_img(f.read())
|
||||||
' \n'
|
await bot.send(ev, im)
|
||||||
'指令:\n'
|
|
||||||
'- <ft color=(238,120,0)>原图</ft>'
|
|
||||||
),
|
@sv.on_rex(
|
||||||
|
r'^(\[CQ:at,qq=[0-9]+\])?( )?'
|
||||||
|
r'(uid|查询|mys)([0-9]+)?'
|
||||||
|
r'([\u4e00-\u9fa5]+)'
|
||||||
|
r'(\[CQ:at,qq=[0-9]+\])?( )?',
|
||||||
)
|
)
|
||||||
async def send_original_pic(
|
async def send_char_info(bot: HoshinoBot, ev: CQEvent):
|
||||||
event: Union[GroupMessageEvent, PrivateMessageEvent],
|
args = ev['match'].groups()
|
||||||
matcher: Matcher,
|
if args[4] is None:
|
||||||
):
|
|
||||||
if event.reply:
|
|
||||||
msg_id = event.reply.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()
|
|
||||||
@handle_exception('查询角色面板')
|
|
||||||
@register_menu(
|
|
||||||
'查询角色面板',
|
|
||||||
'查询(@某人)角色名',
|
|
||||||
'查询你的或者指定人的已缓存展柜角色的面板',
|
|
||||||
detail_des=(
|
|
||||||
'介绍:\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>\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: Union[GroupMessageEvent, PrivateMessageEvent],
|
|
||||||
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
|
return
|
||||||
|
# 获取角色名
|
||||||
|
msg = ''.join(re.findall('[\u4e00-\u9fa5]', args[4]))
|
||||||
logger.info('开始执行[查询角色面板]')
|
logger.info('开始执行[查询角色面板]')
|
||||||
at = custom.get_first_at()
|
logger.info('[查询角色面板]参数: {}'.format(args))
|
||||||
img = custom.get_first_image()
|
# 获取角色名
|
||||||
|
at = re.search(r'\[CQ:at,qq=(\d*)]', str(ev.message))
|
||||||
|
image = re.search(r'\[CQ:image,file=(.*),url=(.*)]', str(ev.message))
|
||||||
|
|
||||||
|
img = None
|
||||||
|
if image:
|
||||||
|
img = image.group(2)
|
||||||
if at:
|
if at:
|
||||||
qid = at
|
qid = int(at.group(1))
|
||||||
else:
|
else:
|
||||||
qid = event.user_id
|
if ev.sender:
|
||||||
|
qid = int(ev.sender['user_id'])
|
||||||
|
else:
|
||||||
|
return
|
||||||
logger.info('[查询角色面板]QQ: {}'.format(qid))
|
logger.info('[查询角色面板]QQ: {}'.format(qid))
|
||||||
|
|
||||||
# 获取uid
|
# 获取uid
|
||||||
uid = re.findall(r'\d+', raw_mes)
|
if args[3] is None:
|
||||||
if uid:
|
|
||||||
uid = uid[0]
|
|
||||||
else:
|
|
||||||
uid = await select_db(qid, mode='uid')
|
uid = await select_db(qid, mode='uid')
|
||||||
uid = str(uid)
|
uid = str(uid)
|
||||||
|
else:
|
||||||
|
uid = args[3]
|
||||||
logger.info('[查询角色面板]uid: {}'.format(uid))
|
logger.info('[查询角色面板]uid: {}'.format(uid))
|
||||||
|
|
||||||
if '未找到绑定的UID' in uid:
|
if '未找到绑定的UID' in uid:
|
||||||
await matcher.finish(UID_HINT)
|
await bot.send(ev, UID_HINT)
|
||||||
|
|
||||||
im = await draw_enka_img(raw_mes, uid, img)
|
im = await draw_enka_img(msg, uid, img)
|
||||||
|
|
||||||
if isinstance(im, str):
|
if isinstance(im, str):
|
||||||
await matcher.finish(im)
|
await bot.send(ev, im)
|
||||||
elif isinstance(im, Tuple):
|
elif isinstance(im, Tuple):
|
||||||
req = await matcher.send(MessageSegment.image(im[0]))
|
img = await convert_img(im[0])
|
||||||
|
req = await bot.send(ev, img)
|
||||||
msg_id = req['message_id']
|
msg_id = req['message_id']
|
||||||
if im[1]:
|
if im[1]:
|
||||||
with open(TEMP_PATH / f'{msg_id}.jpg', 'wb') as f:
|
with open(TEMP_PATH / f'{msg_id}.jpg', 'wb') as f:
|
||||||
f.write(im[1])
|
f.write(im[1])
|
||||||
else:
|
else:
|
||||||
await matcher.finish('发生了未知错误,请联系管理员检查后台输出!')
|
await bot.send(ev, '发生了未知错误,请联系管理员检查后台输出!')
|
||||||
|
|
||||||
|
|
||||||
async def refresh_char_data():
|
async def refresh_char_data():
|
||||||
@ -215,115 +125,92 @@ async def refresh_char_data():
|
|||||||
return f'执行成功!共刷新{str(t)}个角色!'
|
return f'执行成功!共刷新{str(t)}个角色!'
|
||||||
|
|
||||||
|
|
||||||
@refresh_scheduler.scheduled_job('cron', hour='4')
|
@sv.scheduled_job('cron', hour='4')
|
||||||
async def daily_refresh_charData():
|
async def daily_refresh_charData():
|
||||||
global AUTO_REFRESH
|
global AUTO_REFRESH
|
||||||
if AUTO_REFRESH:
|
if AUTO_REFRESH:
|
||||||
await refresh_char_data()
|
await refresh_char_data()
|
||||||
|
|
||||||
|
|
||||||
@refresh.handle()
|
@sv.on_prefix('强制刷新')
|
||||||
@handle_exception('强制刷新')
|
async def send_card_info(bot: HoshinoBot, ev: CQEvent):
|
||||||
@register_menu(
|
if ev.message:
|
||||||
'刷新展柜缓存',
|
message = ev.message.extract_plain_text().replace(' ', '')
|
||||||
'强制刷新',
|
else:
|
||||||
'强制刷新你的或者指定人缓存的角色展柜数据',
|
return
|
||||||
detail_des=(
|
|
||||||
'指令:'
|
at = re.search(r'\[CQ:at,qq=(\d*)]', str(ev.message))
|
||||||
'<ft color=(238,120,0)>强制刷新</ft>'
|
|
||||||
'<ft color=(125,125,125)>(uid/全部数据)</ft>\n'
|
if at:
|
||||||
' \n'
|
qid = int(at.group(1))
|
||||||
'用于强制刷新你的或者指定人缓存的角色展柜数据\n'
|
message = message.replace(str(at), '')
|
||||||
'当刷新全部数据时需要机器人管理员权限\n'
|
else:
|
||||||
' \n'
|
if ev.sender:
|
||||||
'示例:\n'
|
qid = int(ev.sender['user_id'])
|
||||||
'<ft color=(238,120,0)>强制刷新</ft>;\n'
|
else:
|
||||||
'<ft color=(238,120,0)>强制刷新123456789</ft>;\n'
|
return
|
||||||
'<ft color=(238,120,0)>强制刷新全部数据</ft>'
|
|
||||||
),
|
|
||||||
)
|
|
||||||
async def send_card_info(
|
|
||||||
bot: Bot,
|
|
||||||
matcher: Matcher,
|
|
||||||
event: Union[GroupMessageEvent, PrivateMessageEvent],
|
|
||||||
args: Message = CommandArg(),
|
|
||||||
custom: ImageAndAt = Depends(),
|
|
||||||
):
|
|
||||||
message = args.extract_plain_text().strip().replace(' ', '')
|
|
||||||
uid = re.findall(r'\d+', message) # str
|
uid = re.findall(r'\d+', message) # str
|
||||||
m = ''.join(re.findall('[\u4e00-\u9fa5]', message))
|
m = ''.join(re.findall('[\u4e00-\u9fa5]', message))
|
||||||
qid = event.user_id
|
|
||||||
at = custom.get_first_at()
|
|
||||||
if at:
|
|
||||||
qid = at
|
|
||||||
|
|
||||||
if len(uid) >= 1:
|
if len(uid) >= 1:
|
||||||
uid = uid[0]
|
uid = uid[0]
|
||||||
else:
|
else:
|
||||||
if m == '全部数据':
|
if m == '全部数据':
|
||||||
if await SUPERUSER(bot, event):
|
if qid in bot.config.SUPERUSERS:
|
||||||
await matcher.send('开始刷新全部数据,这可能需要相当长的一段时间!!')
|
await bot.send(ev, '开始刷新全部数据,这可能需要相当长的一段时间!!')
|
||||||
im = await refresh_char_data()
|
im = await refresh_char_data()
|
||||||
await matcher.finish(str(im))
|
await bot.send(ev, str(im))
|
||||||
|
return
|
||||||
else:
|
else:
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
uid = await select_db(qid, mode='uid')
|
uid = await select_db(qid, mode='uid')
|
||||||
uid = str(uid)
|
uid = str(uid)
|
||||||
if not uid:
|
if '未找到绑定的UID' in uid:
|
||||||
await matcher.finish(UID_HINT)
|
await bot.send(ev, UID_HINT)
|
||||||
|
return
|
||||||
im = await enka_to_card(uid)
|
im = await enka_to_card(uid)
|
||||||
|
|
||||||
if isinstance(im, str):
|
if isinstance(im, str):
|
||||||
await matcher.finish(im)
|
await bot.send(ev, im)
|
||||||
elif isinstance(im, bytes):
|
elif isinstance(im, bytes):
|
||||||
await matcher.finish(MessageSegment.image(im))
|
im = await convert_img(im)
|
||||||
|
await bot.send(ev, im)
|
||||||
else:
|
else:
|
||||||
await matcher.finish('发生了未知错误,请联系管理员检查后台输出!')
|
await bot.send(ev, '发生了未知错误,请联系管理员检查后台输出!')
|
||||||
|
|
||||||
|
|
||||||
@get_charcard_list.handle()
|
@sv.on_prefix('毕业度统计')
|
||||||
@handle_exception('毕业度统计')
|
async def send_charcard_list(bot: HoshinoBot, ev: CQEvent):
|
||||||
@register_menu(
|
if ev.message:
|
||||||
'毕业度统计',
|
message = ev.message.extract_plain_text().replace(' ', '')
|
||||||
'毕业度统计',
|
else:
|
||||||
'查看你或指定人已缓存的展柜角色毕业度',
|
return
|
||||||
detail_des=(
|
|
||||||
'指令:'
|
at = re.search(r'\[CQ:at,qq=(\d*)]', str(ev.message))
|
||||||
'<ft color=(238,120,0)>毕业度统计</ft>'
|
|
||||||
'<ft color=(125,125,125)>(@某人)</ft>\n'
|
|
||||||
' \n'
|
|
||||||
'可以查看你或指定人已缓存的所有展柜角色毕业度\n'
|
|
||||||
' \n'
|
|
||||||
'示例:\n'
|
|
||||||
'<ft color=(238,120,0)>毕业度统计</ft>;\n'
|
|
||||||
'<ft color=(238,120,0)>毕业度统计</ft><ft color=(0,148,200)>@无疑Wuyi</ft>'
|
|
||||||
),
|
|
||||||
)
|
|
||||||
async def send_charcard_list(
|
|
||||||
event: Union[GroupMessageEvent, PrivateMessageEvent],
|
|
||||||
matcher: Matcher,
|
|
||||||
args: Message = CommandArg(),
|
|
||||||
custom: ImageAndAt = Depends(),
|
|
||||||
):
|
|
||||||
raw_mes = args.extract_plain_text().strip()
|
|
||||||
qid = event.user_id
|
|
||||||
at = custom.get_first_at()
|
|
||||||
if at:
|
if at:
|
||||||
qid = at
|
qid = int(at.group(1))
|
||||||
|
message = message.replace(str(at), '')
|
||||||
|
else:
|
||||||
|
if ev.sender:
|
||||||
|
qid = int(ev.sender['user_id'])
|
||||||
|
else:
|
||||||
|
return
|
||||||
|
|
||||||
# 获取uid
|
# 获取uid
|
||||||
uid = re.findall(r'\d+', raw_mes)
|
uid = re.findall(r'\d+', message)
|
||||||
if uid:
|
if uid:
|
||||||
uid = uid[0]
|
uid = uid[0]
|
||||||
else:
|
else:
|
||||||
uid = await select_db(qid, mode='uid')
|
uid = await select_db(qid, mode='uid')
|
||||||
uid = str(uid)
|
|
||||||
|
|
||||||
im = await draw_cahrcard_list(str(uid), qid)
|
im = await draw_cahrcard_list(str(uid), qid)
|
||||||
|
|
||||||
logger.info(f'UID{uid}获取角色数据成功!')
|
logger.info(f'UID{uid}获取角色数据成功!')
|
||||||
if isinstance(im, bytes):
|
if isinstance(im, bytes):
|
||||||
await matcher.finish(MessageSegment.image(im))
|
im = await convert_img(im)
|
||||||
|
await bot.send(ev, im)
|
||||||
else:
|
else:
|
||||||
await matcher.finish(str(im))
|
await bot.send(ev, str(im))
|
||||||
|
@ -501,7 +501,7 @@ class Character:
|
|||||||
|
|
||||||
# 重新计算加成值
|
# 重新计算加成值
|
||||||
# base_effect_list = [
|
# base_effect_list = [
|
||||||
# [limit_list, effect_attr, effect_value, effect_base]
|
# [limit_list, effect_attr, effect_value,effect_base]
|
||||||
# ]
|
# ]
|
||||||
for effect in base_effect_list:
|
for effect in base_effect_list:
|
||||||
prop = await self.get_buff_value(prop, *effect)
|
prop = await self.get_buff_value(prop, *effect)
|
||||||
@ -614,12 +614,8 @@ class Character:
|
|||||||
'type': '攻击力',
|
'type': '攻击力',
|
||||||
'plus': 1,
|
'plus': 1,
|
||||||
'value': [
|
'value': [
|
||||||
f'''{
|
f'''{int(i[:-1]) +
|
||||||
int(i[:-1]) + int(
|
int(self.power_list["A霜华矢·霜华绽发伤害"]["value"][index][:-1])
|
||||||
self.power_list[
|
|
||||||
"A霜华矢·霜华绽发伤害"
|
|
||||||
]["value"][index][:-1]
|
|
||||||
)
|
|
||||||
}%'''
|
}%'''
|
||||||
for index, i in enumerate(
|
for index, i in enumerate(
|
||||||
self.power_list['A霜华矢命中伤害']['value']
|
self.power_list['A霜华矢命中伤害']['value']
|
||||||
|
@ -216,8 +216,8 @@ class Fight:
|
|||||||
if '前台' in char.power_list[char.power_name]['name']:
|
if '前台' in char.power_list[char.power_name]['name']:
|
||||||
if char.char_name == '纳西妲':
|
if char.char_name == '纳西妲':
|
||||||
em = char.fight_prop[f'{char.attack_type}_elementalMastery']
|
em = char.fight_prop[f'{char.attack_type}_elementalMastery']
|
||||||
effect = f'''
|
effect = f'''elementalMastery+
|
||||||
elementalMastery+{0.25 * em if 0.25 * em <= 250 else 250}
|
{0.25 * em if 0.25 * em <= 250 else 250}
|
||||||
'''.strip()
|
'''.strip()
|
||||||
effect_list.append(effect)
|
effect_list.append(effect)
|
||||||
|
|
||||||
|
@ -1,118 +1,42 @@
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any, Tuple
|
|
||||||
|
|
||||||
from nonebot.log import logger
|
from hoshino.typing import CQEvent, HoshinoBot
|
||||||
from nonebot.matcher import Matcher
|
|
||||||
from nonebot import on_regex, on_command
|
|
||||||
from nonebot.params import CommandArg, RegexGroup
|
|
||||||
from nonebot.adapters.onebot.v11 import Message, MessageSegment
|
|
||||||
|
|
||||||
|
from ..base import sv, logger
|
||||||
from ..version import Genshin_version
|
from ..version import Genshin_version
|
||||||
from ..genshinuid_meta import register_menu
|
from ..utils.draw_image_tools.send_image_tool import convert_img
|
||||||
from ..utils.exception.handle_exception import handle_exception
|
|
||||||
|
|
||||||
get_primogems_data = on_command('版本规划', aliases={'原石预估'})
|
|
||||||
get_img_data = on_regex(r'^(查询)?(伤害乘区|血量表|抗性表|血量排行)$')
|
|
||||||
|
|
||||||
PRIMOGEMS_DATA_PATH = Path(__file__).parent / 'primogems_data'
|
PRIMOGEMS_DATA_PATH = Path(__file__).parent / 'primogems_data'
|
||||||
IMG_PATH = Path(__file__).parent / 'img_data'
|
IMG_PATH = Path(__file__).parent / 'img_data'
|
||||||
|
|
||||||
|
|
||||||
@get_primogems_data.handle()
|
@sv.on_rex(r'^(版本规划|原石预估)(\S+)?$')
|
||||||
@handle_exception('版本规划')
|
async def send_primogems_data(bot: HoshinoBot, ev: CQEvent):
|
||||||
@register_menu(
|
args = ev['match'].groups()
|
||||||
'版本原石规划',
|
|
||||||
'版本规划(版本号)',
|
|
||||||
'发送一张指定版本的原石规划图',
|
|
||||||
detail_des=(
|
|
||||||
'介绍:\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>'
|
|
||||||
),
|
|
||||||
)
|
|
||||||
async def send_primogems_data(matcher: Matcher, args: Message = CommandArg()):
|
|
||||||
logger.info('开始执行[图片][版本规划]')
|
logger.info('开始执行[图片][版本规划]')
|
||||||
logger.info('[图片][版本规划]参数: {}'.format(args))
|
logger.info('[图片][版本规划]参数: {}'.format(args))
|
||||||
if args:
|
if args[1]:
|
||||||
path = PRIMOGEMS_DATA_PATH / f'{str(args)}.png'
|
path = PRIMOGEMS_DATA_PATH / f'{str(args[1])}.png'
|
||||||
if path.exists():
|
if path.exists():
|
||||||
img = f'{str(args)}.png'
|
img = f'{str(args[1])}.png'
|
||||||
else:
|
else:
|
||||||
await matcher.finish()
|
return
|
||||||
else:
|
else:
|
||||||
img = f'{Genshin_version[:3]}.png'
|
img = f'{Genshin_version[:3]}.png'
|
||||||
primogems_img = PRIMOGEMS_DATA_PATH / img
|
primogems_img = PRIMOGEMS_DATA_PATH / img
|
||||||
if primogems_img.exists():
|
logger.info('[图片][版本规划]访问图片: {}'.format(img))
|
||||||
logger.info('[图片][版本规划]访问图片: {}'.format(img))
|
primogems_img = await convert_img(primogems_img)
|
||||||
with open(primogems_img, 'rb') as f:
|
await bot.send(ev, primogems_img)
|
||||||
await matcher.finish(MessageSegment.image(f.read()))
|
|
||||||
else:
|
|
||||||
await matcher.finish()
|
|
||||||
|
|
||||||
|
|
||||||
@get_img_data.handle()
|
@sv.on_rex(r'^(查询)?(伤害乘区|血量表|抗性表|血量排行)$')
|
||||||
@handle_exception('杂图')
|
async def send_img_data(bot: HoshinoBot, ev: CQEvent):
|
||||||
@register_menu(
|
args = ev['match'].groups()
|
||||||
'伤害乘区图',
|
|
||||||
'(查询)伤害乘区',
|
|
||||||
'发送一张理论伤害计算公式图',
|
|
||||||
detail_des=(
|
|
||||||
'介绍:\n'
|
|
||||||
'发送一张理论伤害计算公式图\n'
|
|
||||||
' \n'
|
|
||||||
'指令:\n'
|
|
||||||
'- <ft color=(125,125,125)>(查询)</ft><ft color=(238,120,0)>伤害乘区</ft>'
|
|
||||||
),
|
|
||||||
)
|
|
||||||
@register_menu(
|
|
||||||
'怪物血量表',
|
|
||||||
'(查询)血量表',
|
|
||||||
'发送一张原神怪物血量表图',
|
|
||||||
detail_des=(
|
|
||||||
'介绍:\n'
|
|
||||||
'发送一张原神怪物血量表图\n'
|
|
||||||
' \n'
|
|
||||||
'指令:\n'
|
|
||||||
'- <ft color=(125,125,125)>(查询)</ft><ft color=(238,120,0)>血量表</ft>'
|
|
||||||
),
|
|
||||||
)
|
|
||||||
@register_menu(
|
|
||||||
'怪物抗性表',
|
|
||||||
'(查询)抗性表',
|
|
||||||
'发送一张原神怪物抗性表图',
|
|
||||||
detail_des=(
|
|
||||||
'介绍:\n'
|
|
||||||
'发送一张原神怪物抗性表图\n'
|
|
||||||
' \n'
|
|
||||||
'指令:\n'
|
|
||||||
'- <ft color=(125,125,125)>(查询)</ft><ft color=(238,120,0)>抗性表</ft>'
|
|
||||||
),
|
|
||||||
)
|
|
||||||
@register_menu(
|
|
||||||
'怪物血量排行',
|
|
||||||
'(查询)血量排行',
|
|
||||||
'发送一张原神怪物血量排行图',
|
|
||||||
detail_des=(
|
|
||||||
'介绍:\n'
|
|
||||||
'发送一张原神怪物血量排行图\n'
|
|
||||||
' \n'
|
|
||||||
'指令:\n'
|
|
||||||
'- <ft color=(125,125,125)>(查询)</ft><ft color=(238,120,0)>血量排行</ft>'
|
|
||||||
),
|
|
||||||
)
|
|
||||||
async def send_img_data(
|
|
||||||
matcher: Matcher, args: Tuple[Any, ...] = RegexGroup()
|
|
||||||
):
|
|
||||||
logger.info('开始执行[图片][杂图]')
|
logger.info('开始执行[图片][杂图]')
|
||||||
logger.info('[图片][杂图]参数: {}'.format(args))
|
logger.info('[图片][杂图]参数: {}'.format(args))
|
||||||
img = IMG_PATH / f'{args[1]}.jpg'
|
img = IMG_PATH / f'{args[1]}.jpg'
|
||||||
if img.exists():
|
if img.exists():
|
||||||
with open(img, 'rb') as f:
|
img = await convert_img(img)
|
||||||
await matcher.finish(MessageSegment.image(f.read()))
|
await bot.send(ev, img)
|
||||||
|
else:
|
||||||
|
return
|
||||||
|
@ -1,56 +1,24 @@
|
|||||||
from nonebot import on_command
|
from hoshino.typing import CQEvent, HoshinoBot
|
||||||
from nonebot.matcher import Matcher
|
|
||||||
from nonebot_plugin_apscheduler import scheduler
|
|
||||||
from nonebot.adapters.onebot.v11 import MessageSegment
|
|
||||||
|
|
||||||
from ..config import priority
|
from ..base import sv
|
||||||
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 .draw_event_img import get_event_img, get_all_event_img
|
||||||
from ..utils.exception.handle_exception import handle_exception
|
from ..utils.draw_image_tools.send_image_tool import convert_img
|
||||||
|
|
||||||
get_event = on_command('活动列表', priority=priority, rule=FullCommand())
|
|
||||||
get_gacha = on_command('卡池列表', priority=priority, rule=FullCommand())
|
|
||||||
|
|
||||||
|
|
||||||
@scheduler.scheduled_job('cron', hour='2')
|
@sv.scheduled_job('cron', hour='2')
|
||||||
async def draw_event():
|
async def draw_event():
|
||||||
await get_all_event_img()
|
await get_all_event_img()
|
||||||
|
|
||||||
|
|
||||||
@get_event.handle()
|
@sv.on_fullmatch('活动列表')
|
||||||
@handle_exception('活动')
|
async def send_events(bot: HoshinoBot, ev: CQEvent):
|
||||||
@register_menu(
|
|
||||||
'活动列表',
|
|
||||||
'活动列表',
|
|
||||||
'查询当前版本活动日程表',
|
|
||||||
detail_des=(
|
|
||||||
'介绍:\n'
|
|
||||||
'查询当前版本活动日程表\n'
|
|
||||||
' \n'
|
|
||||||
'指令:\n'
|
|
||||||
'- <ft color=(238,120,0)>活动列表</ft>'
|
|
||||||
),
|
|
||||||
)
|
|
||||||
async def send_events(matcher: Matcher):
|
|
||||||
img = await get_event_img('EVENT')
|
img = await get_event_img('EVENT')
|
||||||
await matcher.finish(MessageSegment.image(img))
|
im = await convert_img(img)
|
||||||
|
await bot.send(ev, im)
|
||||||
|
|
||||||
|
|
||||||
@get_gacha.handle()
|
@sv.on_fullmatch('卡池列表')
|
||||||
@handle_exception('活动')
|
async def send_gachas(bot: HoshinoBot, ev: CQEvent):
|
||||||
@register_menu(
|
|
||||||
'卡池列表',
|
|
||||||
'卡池列表',
|
|
||||||
'查询当前版本卡池列表',
|
|
||||||
detail_des=(
|
|
||||||
'介绍:\n'
|
|
||||||
'查询当前版本卡池列表\n'
|
|
||||||
' \n'
|
|
||||||
'指令:\n'
|
|
||||||
'- <ft color=(238,120,0)>卡池列表</ft>'
|
|
||||||
),
|
|
||||||
)
|
|
||||||
async def send_gachas(matcher: Matcher):
|
|
||||||
img = await get_event_img('GACHA')
|
img = await get_event_img('GACHA')
|
||||||
await matcher.finish(MessageSegment.image(img))
|
im = await convert_img(img)
|
||||||
|
await bot.send(ev, im)
|
||||||
|
@ -1,161 +1,93 @@
|
|||||||
from typing import Union
|
from nonebot import get_bot
|
||||||
|
from hoshino.typing import CQEvent, HoshinoBot, NoticeSession
|
||||||
from nonebot.log import logger
|
|
||||||
from nonebot.matcher import Matcher
|
|
||||||
from nonebot import get_bot, on_notice, on_command
|
|
||||||
from nonebot.adapters.onebot.v11 import (
|
|
||||||
NoticeEvent,
|
|
||||||
MessageSegment,
|
|
||||||
GroupMessageEvent,
|
|
||||||
PrivateMessageEvent,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
from ..base import sv, logger
|
||||||
from .get_gachalogs import save_gachalogs
|
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 .draw_gachalogs import draw_gachalogs_img
|
||||||
from ..utils.message.error_reply import UID_HINT
|
from ..utils.message.error_reply import UID_HINT
|
||||||
from ..utils.db_operation.db_operation import select_db
|
from ..utils.db_operation.db_operation import select_db
|
||||||
from ..utils.exception.handle_exception import handle_exception
|
from ..utils.draw_image_tools.send_image_tool import convert_img
|
||||||
from .export_and_import import export_gachalogs, import_gachalogs
|
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())
|
@sv.on_notice()
|
||||||
import_gacha_log = on_notice()
|
async def import_gacha_log_info(session: NoticeSession):
|
||||||
export_gacha_log = on_command('导出抽卡记录', rule=FullCommand())
|
ev = session.event
|
||||||
|
if ev['notice_type'] != 'offline_file':
|
||||||
|
return
|
||||||
|
url = ev['file']['url']
|
||||||
|
name: str = ev['file']['name']
|
||||||
|
if not name.endswith('.json'):
|
||||||
|
return
|
||||||
|
qid = ev['user_id']
|
||||||
|
uid = await select_db(qid, mode='uid')
|
||||||
|
if not isinstance(uid, str) or '未找到绑定的UID' in uid:
|
||||||
|
await session.send(UID_HINT)
|
||||||
|
return
|
||||||
|
logger.info('开始执行[导入抽卡记录]')
|
||||||
|
im = await import_gachalogs(url, uid)
|
||||||
|
await session.send(im, at_sender=True)
|
||||||
|
|
||||||
|
|
||||||
@export_gacha_log.handle()
|
@sv.on_fullmatch('导出抽卡记录')
|
||||||
@handle_exception('导出抽卡记录')
|
async def export_gacha_log_info(bot: HoshinoBot, ev: CQEvent):
|
||||||
@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: GroupMessageEvent,
|
|
||||||
matcher: Matcher,
|
|
||||||
):
|
|
||||||
logger.info('开始执行[导出抽卡记录]')
|
logger.info('开始执行[导出抽卡记录]')
|
||||||
qid = event.user_id
|
qid = int(ev.sender['user_id'])
|
||||||
gid = event.group_id
|
gid = int(ev.group_id)
|
||||||
uid = await select_db(qid, mode='uid')
|
uid = await select_db(qid, mode='uid')
|
||||||
bot = get_bot()
|
bot = get_bot()
|
||||||
if not isinstance(uid, str) or '未找到绑定的UID' in uid:
|
if not isinstance(uid, str) or '未找到绑定的UID' in uid:
|
||||||
await matcher.finish(UID_HINT)
|
await bot.send(ev, UID_HINT)
|
||||||
|
return
|
||||||
raw_data = await export_gachalogs(uid)
|
raw_data = await export_gachalogs(uid)
|
||||||
if raw_data['retcode'] == 'ok':
|
if raw_data['retcode'] == 'ok':
|
||||||
await bot.call_api(
|
await bot.call_action(
|
||||||
'upload_group_file',
|
action='upload_group_file',
|
||||||
group_id=gid,
|
group_id=gid,
|
||||||
name=raw_data['name'],
|
name=raw_data['name'],
|
||||||
file=raw_data['url'],
|
file=raw_data['url'],
|
||||||
)
|
)
|
||||||
logger.info(f'[导出抽卡记录] UID{uid}成功!')
|
logger.info(f'[导出抽卡记录] UID{uid}成功!')
|
||||||
await matcher.finish('上传成功!')
|
await bot.send(ev, '上传成功!')
|
||||||
else:
|
else:
|
||||||
logger.warning(f'[导出抽卡记录] UID{uid}失败!')
|
logger.warning(f'[导出抽卡记录] UID{uid}失败!')
|
||||||
await matcher.finish('导出抽卡记录失败!')
|
await bot.send(ev, '导出抽卡记录失败!')
|
||||||
|
|
||||||
|
|
||||||
@import_gacha_log.handle()
|
@sv.on_fullmatch('抽卡记录')
|
||||||
@handle_exception('导入抽卡记录')
|
async def send_gacha_log_card_info(bot: HoshinoBot, ev: CQEvent):
|
||||||
@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: NoticeEvent, matcher: Matcher):
|
|
||||||
args = event.dict()
|
|
||||||
if args['notice_type'] != 'offline_file':
|
|
||||||
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()
|
|
||||||
@handle_exception('抽卡记录')
|
|
||||||
@register_menu(
|
|
||||||
'查询抽卡记录',
|
|
||||||
'抽卡记录',
|
|
||||||
'查询你的原神抽卡记录',
|
|
||||||
detail_des=(
|
|
||||||
'介绍:\n'
|
|
||||||
'查询你的原神抽卡记录\n'
|
|
||||||
'需要<ft color=(238,120,0)>绑定Stoken</ft>\n'
|
|
||||||
' \n'
|
|
||||||
'指令:\n'
|
|
||||||
'<ft color=(238,120,0)>抽卡记录</ft>'
|
|
||||||
),
|
|
||||||
)
|
|
||||||
async def send_gacha_log_card_info(
|
|
||||||
event: Union[GroupMessageEvent, PrivateMessageEvent],
|
|
||||||
matcher: Matcher,
|
|
||||||
):
|
|
||||||
logger.info('开始执行[抽卡记录]')
|
logger.info('开始执行[抽卡记录]')
|
||||||
|
if ev.sender:
|
||||||
uid = await select_db(event.user_id, mode='uid')
|
qid = int(ev.sender['user_id'])
|
||||||
if isinstance(uid, str):
|
|
||||||
im = await draw_gachalogs_img(uid, event.user_id)
|
|
||||||
if isinstance(im, bytes):
|
|
||||||
await matcher.finish(MessageSegment.image(im))
|
|
||||||
else:
|
|
||||||
await matcher.finish(im)
|
|
||||||
else:
|
else:
|
||||||
await matcher.finish(UID_HINT)
|
return
|
||||||
|
uid = await select_db(qid, mode='uid')
|
||||||
|
|
||||||
|
if isinstance(uid, str):
|
||||||
|
im = await draw_gachalogs_img(uid, qid)
|
||||||
|
if isinstance(im, bytes):
|
||||||
|
im = await convert_img(im)
|
||||||
|
await bot.send(ev, im)
|
||||||
|
else:
|
||||||
|
await bot.send(ev, im)
|
||||||
|
else:
|
||||||
|
await bot.send(ev, UID_HINT)
|
||||||
|
|
||||||
|
|
||||||
@get_gacha_log.handle()
|
@sv.on_fullmatch(('刷新抽卡记录', '强制刷新抽卡记录'))
|
||||||
@handle_exception('刷新抽卡记录')
|
async def send_daily_info(bot: HoshinoBot, ev: CQEvent):
|
||||||
@register_menu(
|
|
||||||
'刷新抽卡记录',
|
|
||||||
'刷新抽卡记录',
|
|
||||||
'刷新你的原神抽卡记录本地缓存',
|
|
||||||
detail_des=(
|
|
||||||
'介绍:\n'
|
|
||||||
'刷新你的原神抽卡记录本地缓存\n'
|
|
||||||
'需要<ft color=(238,120,0)>绑定Stoken</ft>\n'
|
|
||||||
' \n'
|
|
||||||
'指令:\n'
|
|
||||||
'- <ft color=(238,120,0)>刷新抽卡记录</ft>'
|
|
||||||
),
|
|
||||||
)
|
|
||||||
async def send_daily_info(
|
|
||||||
event: Union[GroupMessageEvent, PrivateMessageEvent],
|
|
||||||
matcher: Matcher,
|
|
||||||
):
|
|
||||||
logger.info('开始执行[刷新抽卡记录]')
|
logger.info('开始执行[刷新抽卡记录]')
|
||||||
uid = await select_db(event.user_id, mode='uid')
|
if ev.sender:
|
||||||
|
qid = int(ev.sender['user_id'])
|
||||||
|
else:
|
||||||
|
return
|
||||||
|
uid = await select_db(qid, mode='uid')
|
||||||
if isinstance(uid, str):
|
if isinstance(uid, str):
|
||||||
is_force = False
|
is_force = False
|
||||||
if event.raw_message.startswith('强制'):
|
if ev.raw_message and str(ev.raw_message).startswith('强制'):
|
||||||
|
logger.info('[WARNING]本次为强制刷新')
|
||||||
is_force = True
|
is_force = True
|
||||||
im = await save_gachalogs(uid, None, is_force)
|
im = await save_gachalogs(uid, None, is_force)
|
||||||
await matcher.finish(im)
|
await bot.send(ev, im)
|
||||||
else:
|
else:
|
||||||
await matcher.finish(UID_HINT)
|
await bot.send(ev, UID_HINT)
|
||||||
|
@ -1,43 +0,0 @@
|
|||||||
from nonebot import on_command
|
|
||||||
from nonebot.log import logger
|
|
||||||
from nonebot.matcher import Matcher
|
|
||||||
from nonebot.adapters.onebot.v11 import Bot, GroupMessageEvent
|
|
||||||
|
|
||||||
from .gacha_url import post_url
|
|
||||||
from ..genshinuid_meta import register_menu
|
|
||||||
from ..utils.nonebot2.rule import FullCommand
|
|
||||||
from ..utils.message.error_reply import UID_HINT
|
|
||||||
from ..utils.db_operation.db_operation import select_db
|
|
||||||
from ..utils.exception.handle_exception import handle_exception
|
|
||||||
|
|
||||||
get_gacha_url = on_command(
|
|
||||||
'获取抽卡记录链接', aliases={'抽卡链接', '抽卡记录链接'}, rule=FullCommand()
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@get_gacha_url.handle()
|
|
||||||
@handle_exception('获取抽卡记录链接')
|
|
||||||
@register_menu(
|
|
||||||
'获取抽卡记录链接',
|
|
||||||
'获取抽卡记录链接',
|
|
||||||
'获取用户的抽卡记录链接',
|
|
||||||
trigger_method='群聊指令',
|
|
||||||
detail_des=(
|
|
||||||
'介绍:\n'
|
|
||||||
'导出抽卡记录的链接以用于原神小程序\n'
|
|
||||||
' \n'
|
|
||||||
'指令:\n'
|
|
||||||
'- <ft color=(238,120,0)>抽卡链接</ft>'
|
|
||||||
),
|
|
||||||
)
|
|
||||||
async def _(
|
|
||||||
bot: Bot,
|
|
||||||
event: GroupMessageEvent,
|
|
||||||
matcher: Matcher,
|
|
||||||
):
|
|
||||||
await get_gacha_url.send("正在获取抽卡记录链接")
|
|
||||||
logger.info('开始执行[获取抽卡记录链接]')
|
|
||||||
uid = await select_db(event.user_id, mode='uid')
|
|
||||||
if not isinstance(uid, str) or '未找到绑定的UID' in uid:
|
|
||||||
await matcher.finish(UID_HINT)
|
|
||||||
await post_url(bot, uid, str(event.group_id), str(event.user_id))
|
|
@ -1,53 +0,0 @@
|
|||||||
import time
|
|
||||||
from urllib.parse import quote
|
|
||||||
|
|
||||||
from nonebot.adapters.onebot.v11 import Bot
|
|
||||||
|
|
||||||
from ..utils.message.error_reply import SK_HINT
|
|
||||||
from ..utils.message.send_msg import send_forward_msg
|
|
||||||
from ..utils.mhy_api.get_mhy_data import get_authkey_by_cookie
|
|
||||||
|
|
||||||
|
|
||||||
async def post_url(bot: Bot, uid: str, group_id: str, qid: str):
|
|
||||||
async def send_group_msg(msg: str):
|
|
||||||
await bot.call_api(
|
|
||||||
api='send_group_msg',
|
|
||||||
group_id=group_id,
|
|
||||||
message=msg,
|
|
||||||
)
|
|
||||||
return ''
|
|
||||||
|
|
||||||
authkey = await get_authkey_by_cookie(uid)
|
|
||||||
if authkey == {}:
|
|
||||||
return await send_group_msg(SK_HINT)
|
|
||||||
authkey = authkey['data']['authkey']
|
|
||||||
now = time.time()
|
|
||||||
region = ""
|
|
||||||
if uid[0] == "1" or uid[0] == "2":
|
|
||||||
region = 'cn_gf01'
|
|
||||||
elif uid[0] == "5":
|
|
||||||
region = "'cn_qd01'"
|
|
||||||
elif uid[0] == "6":
|
|
||||||
region = "'os_usa'"
|
|
||||||
elif uid[0] == "7":
|
|
||||||
region = "'os_euro'"
|
|
||||||
elif uid[0] == "8":
|
|
||||||
region = "'os_asia'"
|
|
||||||
elif uid[0] == "9":
|
|
||||||
region = "'os_cht'"
|
|
||||||
else:
|
|
||||||
region = 'cn_gf01'
|
|
||||||
msgs = []
|
|
||||||
msgs.append(f"uid:{uid}的抽卡记录链接为:")
|
|
||||||
url = (
|
|
||||||
f"https://hk4e-api.mihoyo.com/event/gacha_info/api/getGachaLog?"
|
|
||||||
f"authkey_ver=1&sign_type=2&auth_appid=webview_gacha&init_type=301&"
|
|
||||||
f"gacha_id=fecafa7b6560db5f3182222395d88aaa6aaac1bc"
|
|
||||||
f"×tamp={str(int(now))}"
|
|
||||||
f"&lang=zh-cn&device_type=mobile&plat_type=ios®ion={region}"
|
|
||||||
f"&authkey={quote(authkey,'utf-8')}"
|
|
||||||
f"&game_biz=hk4e_cn&gacha_type=301&page=1&size=5&end_id=0"
|
|
||||||
)
|
|
||||||
msgs.append(url)
|
|
||||||
await send_forward_msg(bot, group_id, "抽卡链接", qid, msgs)
|
|
||||||
return "成功执行"
|
|
@ -1,41 +1,28 @@
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
from nonebot import on_command
|
from hoshino.typing import CQEvent, HoshinoBot
|
||||||
from nonebot.log import logger
|
|
||||||
from nonebot.matcher import Matcher
|
|
||||||
from nonebot.params import Depends, CommandArg
|
|
||||||
from nonebot.adapters.onebot.v11 import Message, MessageEvent, MessageSegment
|
|
||||||
|
|
||||||
from ..config import priority
|
from ..base import sv, logger
|
||||||
from .draw_gcginfo import draw_gcg_info
|
from .draw_gcginfo import draw_gcg_info
|
||||||
|
from ..utils.message.error_reply import UID_HINT
|
||||||
from ..utils.db_operation.db_operation import select_db
|
from ..utils.db_operation.db_operation import select_db
|
||||||
from ..utils.message.get_image_and_at import ImageAndAt
|
from ..utils.draw_image_tools.send_image_tool import convert_img
|
||||||
from ..utils.message.error_reply import CK_HINT, UID_HINT
|
|
||||||
from ..utils.exception.handle_exception import handle_exception
|
|
||||||
|
|
||||||
get_gcg_info = on_command('七圣召唤', aliases={'七圣', '召唤'}, priority=priority)
|
|
||||||
|
|
||||||
|
|
||||||
# 群聊内 每月统计 功能
|
@sv.on_prefix(('七圣召唤', '七圣', '召唤'))
|
||||||
@get_gcg_info.handle()
|
async def send_gcg_pic(bot: HoshinoBot, ev: CQEvent):
|
||||||
@handle_exception('七圣召唤', '获取/发送七圣召唤失败', '@未找到绑定信息\n' + CK_HINT)
|
if ev.message:
|
||||||
async def send_gcg_pic(
|
raw_mes = ev.message.extract_plain_text().replace(' ', '')
|
||||||
event: MessageEvent,
|
else:
|
||||||
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
|
return
|
||||||
at = custom.get_first_at()
|
|
||||||
|
at = re.search(r'\[CQ:at,qq=(\d*)]', str(ev.message))
|
||||||
logger.info('开始执行[七圣召唤]')
|
logger.info('开始执行[七圣召唤]')
|
||||||
|
|
||||||
if at:
|
if at:
|
||||||
qid = at
|
qid = int(at.group(1))
|
||||||
else:
|
else:
|
||||||
qid = event.user_id
|
qid = int(ev.sender['user_id'])
|
||||||
logger.info('[七圣召唤]QQ: {}'.format(qid))
|
logger.info('[七圣召唤]QQ: {}'.format(qid))
|
||||||
|
|
||||||
# 获取uid
|
# 获取uid
|
||||||
@ -45,16 +32,18 @@ async def send_gcg_pic(
|
|||||||
else:
|
else:
|
||||||
uid = await select_db(qid, mode='uid')
|
uid = await select_db(qid, mode='uid')
|
||||||
uid = str(uid)
|
uid = str(uid)
|
||||||
|
|
||||||
logger.info('[七圣召唤]uid: {}'.format(uid))
|
logger.info('[七圣召唤]uid: {}'.format(uid))
|
||||||
|
|
||||||
if '未找到绑定的UID' in uid:
|
if '未找到绑定的UID' in uid:
|
||||||
await matcher.finish(UID_HINT)
|
await bot.send(ev, UID_HINT)
|
||||||
|
|
||||||
im = await draw_gcg_info(uid)
|
im = await draw_gcg_info(uid)
|
||||||
|
|
||||||
if isinstance(im, str):
|
if isinstance(im, str):
|
||||||
await matcher.finish(im)
|
await bot.send(ev, im)
|
||||||
elif isinstance(im, bytes):
|
elif isinstance(im, bytes):
|
||||||
await matcher.finish(MessageSegment.image(im))
|
im = await convert_img(im)
|
||||||
|
await bot.send(ev, im)
|
||||||
else:
|
else:
|
||||||
await matcher.finish('发生了未知错误,请联系管理员检查后台输出!')
|
await bot.send(ev, '发生了未知错误,请联系管理员检查后台输出!')
|
||||||
|
@ -1,132 +1,96 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
import threading
|
import threading
|
||||||
|
from typing import List
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any, List, Tuple
|
|
||||||
|
|
||||||
from nonebot.log import logger
|
from hoshino.typing import CQEvent, HoshinoBot
|
||||||
from nonebot.matcher import Matcher
|
|
||||||
from nonebot import on_regex, on_command
|
|
||||||
from nonebot.params import CommandArg, RegexGroup
|
|
||||||
from nonebot.adapters.onebot.v11 import (
|
|
||||||
Bot,
|
|
||||||
Message,
|
|
||||||
MessageSegment,
|
|
||||||
GroupMessageEvent,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
from ..base import sv, logger
|
||||||
from .get_card import get_gs_card
|
from .get_card import get_gs_card
|
||||||
from .get_guide import get_gs_guide
|
from .get_guide import get_gs_guide
|
||||||
from ..version import Genshin_version
|
from ..version import Genshin_version
|
||||||
from ..genshinuid_meta import register_menu
|
|
||||||
from .get_abyss_data import get_review, generate_data
|
from .get_abyss_data import get_review, generate_data
|
||||||
from ..utils.alias.alias_to_char_name import alias_to_char_name
|
from ..utils.alias.alias_to_char_name import alias_to_char_name
|
||||||
from ..utils.exception.handle_exception import handle_exception
|
from ..utils.draw_image_tools.send_image_tool import convert_img
|
||||||
|
|
||||||
get_guide_pic = on_regex('([\u4e00-\u9fa5]+)(推荐|攻略)')
|
|
||||||
get_bluekun_pic = on_command('参考面板')
|
|
||||||
get_card = on_command('原牌')
|
|
||||||
get_abyss = on_command('版本深渊')
|
|
||||||
|
|
||||||
|
|
||||||
IMG_PATH = Path(__file__).parent / 'img'
|
IMG_PATH = Path(__file__).parent / 'img'
|
||||||
|
|
||||||
|
|
||||||
@get_guide_pic.handle()
|
@sv.on_rex('([\u4e00-\u9fa5]+)(推荐|攻略)')
|
||||||
@handle_exception('建议')
|
async def send_guide_pic(bot: HoshinoBot, ev: CQEvent):
|
||||||
@register_menu(
|
if ev.message:
|
||||||
'角色攻略',
|
name = name = str(ev['match'].group(1))
|
||||||
'xx攻略',
|
else:
|
||||||
'发送一张对应角色的西风驿站攻略图',
|
|
||||||
detail_des=(
|
|
||||||
'介绍:\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>'
|
|
||||||
),
|
|
||||||
)
|
|
||||||
async def send_guide_pic(
|
|
||||||
matcher: Matcher, args: Tuple[Any, ...] = RegexGroup()
|
|
||||||
):
|
|
||||||
if not args:
|
|
||||||
return
|
return
|
||||||
name = str(args[0])
|
|
||||||
|
if name == '':
|
||||||
|
return
|
||||||
|
|
||||||
im = await get_gs_guide(name)
|
im = await get_gs_guide(name)
|
||||||
|
|
||||||
if im:
|
if im:
|
||||||
logger.info('获得{}攻略成功!'.format(name))
|
logger.info('获得{}攻略成功!'.format(name))
|
||||||
await matcher.finish(MessageSegment.image(im))
|
im = await convert_img(im)
|
||||||
|
await bot.send(ev, im)
|
||||||
else:
|
else:
|
||||||
logger.warning('未找到{}攻略图片'.format(name))
|
logger.warning('未找到{}攻略图片'.format(name))
|
||||||
|
|
||||||
|
|
||||||
@get_bluekun_pic.handle()
|
@sv.on_prefix('参考面板')
|
||||||
@handle_exception('参考面板')
|
async def send_bluekun_pic(bot: HoshinoBot, ev: CQEvent):
|
||||||
@register_menu(
|
if ev.message:
|
||||||
'参考面板',
|
message = ev.message.extract_plain_text().replace(' ', '')
|
||||||
'参考面板[角色名/元素名]',
|
|
||||||
'发送一张对应角色/元素的参考面板图',
|
|
||||||
detail_des=(
|
|
||||||
'介绍:\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>'
|
|
||||||
),
|
|
||||||
)
|
|
||||||
async def send_bluekun_pic(matcher: Matcher, args: Message = CommandArg()):
|
|
||||||
if str(args[0]) in ['冰', '水', '火', '草', '雷', '风', '岩']:
|
|
||||||
name = str(args[0])
|
|
||||||
else:
|
else:
|
||||||
name = await alias_to_char_name(str(args[0]))
|
return
|
||||||
|
|
||||||
|
if message == '':
|
||||||
|
return
|
||||||
|
|
||||||
|
if str(message) in ['冰', '水', '火', '草', '雷', '风', '岩']:
|
||||||
|
name = str(message)
|
||||||
|
else:
|
||||||
|
name = await alias_to_char_name(str(message))
|
||||||
img = IMG_PATH / '{}.jpg'.format(name)
|
img = IMG_PATH / '{}.jpg'.format(name)
|
||||||
if img.exists():
|
if img.exists():
|
||||||
with open(img, 'rb') as f:
|
img = await convert_img(img)
|
||||||
im = MessageSegment.image(f.read())
|
|
||||||
logger.info('获得{}参考面板图片成功!'.format(name))
|
logger.info('获得{}参考面板图片成功!'.format(name))
|
||||||
await matcher.finish(im)
|
await bot.send(ev, img)
|
||||||
else:
|
else:
|
||||||
logger.warning('未找到{}参考面板图片'.format(name))
|
logger.warning('未找到{}参考面板图片'.format(name))
|
||||||
|
|
||||||
|
|
||||||
@get_card.handle()
|
@sv.on_prefix('原牌')
|
||||||
@handle_exception('原牌')
|
async def send_gscard_pic(bot: HoshinoBot, ev: CQEvent):
|
||||||
async def send_gscard_pic(matcher: Matcher, args: Message = CommandArg()):
|
if ev.message:
|
||||||
if not args:
|
name = ev.message.extract_plain_text().replace(' ', '')
|
||||||
|
else:
|
||||||
return
|
return
|
||||||
name = str(args[0])
|
|
||||||
|
if name == '':
|
||||||
|
return
|
||||||
|
|
||||||
im = await get_gs_card(name)
|
im = await get_gs_card(name)
|
||||||
|
|
||||||
if im:
|
if im:
|
||||||
logger.info('获得{}原牌成功!'.format(name))
|
logger.info('获得{}原牌成功!'.format(name))
|
||||||
await matcher.finish(MessageSegment.image(im))
|
im = await convert_img(im)
|
||||||
|
await bot.send(ev, im)
|
||||||
else:
|
else:
|
||||||
logger.warning('未找到{}原牌图片'.format(name))
|
logger.warning('未找到{}原牌图片'.format(name))
|
||||||
|
|
||||||
|
|
||||||
@get_abyss.handle()
|
@sv.on_prefix('版本深渊')
|
||||||
@handle_exception('原牌')
|
async def send_abyss_review(bot: HoshinoBot, ev: CQEvent):
|
||||||
async def send_abyss_review(
|
if ev.message:
|
||||||
bot: Bot,
|
version = ev.message.extract_plain_text().replace(' ', '')
|
||||||
event: GroupMessageEvent,
|
|
||||||
matcher: Matcher,
|
|
||||||
args: Message = CommandArg(),
|
|
||||||
):
|
|
||||||
if not args:
|
|
||||||
version = Genshin_version[:-2]
|
|
||||||
else:
|
else:
|
||||||
version = str(args[0])
|
return
|
||||||
|
|
||||||
|
if version == '':
|
||||||
|
version = Genshin_version[:-2]
|
||||||
|
|
||||||
im = await get_review(version)
|
im = await get_review(version)
|
||||||
|
|
||||||
if isinstance(im, List):
|
if isinstance(im, List):
|
||||||
mes = []
|
mes = []
|
||||||
for msg in im:
|
for msg in im:
|
||||||
@ -140,16 +104,14 @@ async def send_abyss_review(
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
await bot.call_api(
|
await bot.send_group_forward_msg(group_id=ev.group_id, messages=mes)
|
||||||
'send_group_forward_msg', group_id=event.group_id, messages=mes
|
|
||||||
)
|
|
||||||
await matcher.finish()
|
|
||||||
elif isinstance(im, str):
|
elif isinstance(im, str):
|
||||||
await matcher.finish(im)
|
await bot.send(ev, im)
|
||||||
elif isinstance(im, bytes):
|
elif isinstance(im, bytes):
|
||||||
await matcher.finish(MessageSegment.image(im))
|
im = await convert_img(im)
|
||||||
|
await bot.send(ev, im)
|
||||||
else:
|
else:
|
||||||
await matcher.finish('发生了未知错误,请联系管理员检查后台输出!')
|
await bot.send(ev, '发生了未知错误,请联系管理员检查后台输出!')
|
||||||
|
|
||||||
|
|
||||||
threading.Thread(
|
threading.Thread(
|
||||||
|
@ -2,37 +2,18 @@ import asyncio
|
|||||||
import threading
|
import threading
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from nonebot import on_command
|
from ..base import sv, logger
|
||||||
from nonebot.log import logger
|
|
||||||
from nonebot.matcher import Matcher
|
|
||||||
from nonebot.adapters.onebot.v11 import MessageSegment
|
|
||||||
|
|
||||||
from .draw_help_card import draw_help_img
|
from .draw_help_card import draw_help_img
|
||||||
from ..genshinuid_meta import register_menu
|
from ..utils.draw_image_tools.send_image_tool import convert_img
|
||||||
from ..utils.exception.handle_exception import handle_exception
|
|
||||||
|
|
||||||
get_help = on_command('gs帮助')
|
|
||||||
|
|
||||||
HELP_IMG = Path(__file__).parent / 'help.png'
|
HELP_IMG = Path(__file__).parent / 'help.png'
|
||||||
|
|
||||||
|
|
||||||
@get_help.handle()
|
@sv.on_fullmatch(('gs帮助', 'genshin帮助', 'ys帮助', '原神帮助'))
|
||||||
@handle_exception('建议')
|
async def send_guide_pic(bot, ev):
|
||||||
@register_menu(
|
img = await convert_img(HELP_IMG)
|
||||||
'插件帮助',
|
|
||||||
'gs帮助',
|
|
||||||
'查看插件功能帮助图',
|
|
||||||
detail_des=(
|
|
||||||
'介绍:\n' '查看插件功能帮助图\n' ' \n' '指令:\n' '- <ft color=(238,120,0)>gs帮助</ft>'
|
|
||||||
),
|
|
||||||
)
|
|
||||||
async def send_guide_pic(matcher: Matcher):
|
|
||||||
logger.info('获得gs帮助图片成功!')
|
logger.info('获得gs帮助图片成功!')
|
||||||
if HELP_IMG.exists():
|
await bot.send(ev, img)
|
||||||
with open(HELP_IMG, 'rb') as f:
|
|
||||||
await matcher.finish(MessageSegment.image(f.read()))
|
|
||||||
else:
|
|
||||||
await matcher.finish('帮助图不存在!')
|
|
||||||
|
|
||||||
|
|
||||||
threading.Thread(
|
threading.Thread(
|
||||||
|
@ -1,29 +1,8 @@
|
|||||||
from typing import Any, Dict, Union
|
from hoshino.typing import CQEvent, HoshinoBot
|
||||||
|
|
||||||
from nonebot.log import logger
|
from ..base import sv, 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 ..config import priority
|
|
||||||
from ..genshinuid_meta import register_menu
|
|
||||||
from ..utils.nonebot2.rule import FullCommand
|
|
||||||
from .draw_genshinmap_card import MAP_DATA, draw_genshin_map
|
from .draw_genshinmap_card import MAP_DATA, draw_genshin_map
|
||||||
from ..utils.exception.handle_exception import handle_exception
|
from ..utils.draw_image_tools.send_image_tool import convert_img
|
||||||
|
|
||||||
change_map = on_command('切换地图', block=True, rule=FullCommand())
|
|
||||||
find_map = on_regex(
|
|
||||||
r'^(?P<name>.*)(在哪里|在哪|哪里有|哪儿有|哪有|在哪儿)$', priority=priority
|
|
||||||
)
|
|
||||||
find_map2 = on_regex(r'^(哪里有|哪儿有|哪有)(?P<name>.*)$', priority=priority)
|
|
||||||
|
|
||||||
|
|
||||||
MAP_ID_LIST = [
|
MAP_ID_LIST = [
|
||||||
'2', # 提瓦特
|
'2', # 提瓦特
|
||||||
@ -39,31 +18,13 @@ MAP_CHN_NAME = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@change_map.handle()
|
@sv.on_fullmatch('切换地图')
|
||||||
@handle_exception('切换地图')
|
async def send_change_map_msg(bot: HoshinoBot, ev: CQEvent):
|
||||||
@register_menu(
|
if ev.sender:
|
||||||
'切换地图',
|
qid = int(ev.sender['user_id'])
|
||||||
'切换地图',
|
else:
|
||||||
'切换查找资源点功能所使用的地图',
|
return
|
||||||
detail_des=(
|
if qid not in bot.config.SUPERUSERS:
|
||||||
'介绍:\n'
|
|
||||||
'切换查找资源点功能所使用的地图\n'
|
|
||||||
'指令按列表顺序轮流切换地图\n'
|
|
||||||
'目前可用地图:'
|
|
||||||
+ ";".join(
|
|
||||||
[f"<ft color=(238,120,0)>{x}</ft>" for x in MAP_CHN_NAME.values()]
|
|
||||||
)
|
|
||||||
+ ' \n\n'
|
|
||||||
'指令:\n'
|
|
||||||
'- <ft color=(238,120,0)>切换地图</ft>'
|
|
||||||
),
|
|
||||||
)
|
|
||||||
async def send_change_map_msg(
|
|
||||||
bot: Bot,
|
|
||||||
event: Union[GroupMessageEvent, PrivateMessageEvent],
|
|
||||||
matcher: Matcher,
|
|
||||||
):
|
|
||||||
if not await SUPERUSER(bot, event):
|
|
||||||
return
|
return
|
||||||
logger.info('[切换地图]正在执行...')
|
logger.info('[切换地图]正在执行...')
|
||||||
MAP_ID_LIST.append(MAP_ID_LIST[0])
|
MAP_ID_LIST.append(MAP_ID_LIST[0])
|
||||||
@ -71,67 +32,44 @@ async def send_change_map_msg(
|
|||||||
current = MAP_ID_LIST[0]
|
current = MAP_ID_LIST[0]
|
||||||
chn = MAP_CHN_NAME.get(current)
|
chn = MAP_CHN_NAME.get(current)
|
||||||
logger.info(f'[切换地图]当前地图为{chn}')
|
logger.info(f'[切换地图]当前地图为{chn}')
|
||||||
await matcher.finish(f'切换到{chn}地图')
|
await bot.send(ev, f'切换到{chn}地图')
|
||||||
|
|
||||||
|
|
||||||
@find_map.handle()
|
@sv.on_rex(r'^(?P<name>.*)(在哪里|在哪|哪里有|哪儿有|哪有|在哪儿)$')
|
||||||
@find_map2.handle()
|
@sv.on_rex(r'^(哪里有|哪儿有|哪有)(?P<name>.*)$')
|
||||||
@handle_exception('查找资源点')
|
async def send_find_map_msg(bot: HoshinoBot, ev: CQEvent):
|
||||||
@register_menu(
|
|
||||||
'查找资源点',
|
|
||||||
'xx在哪',
|
|
||||||
'查找指定资源在地图上的位置',
|
|
||||||
detail_des=(
|
|
||||||
'介绍:\n'
|
|
||||||
'在米游社大地图上查询某资源的位置\n'
|
|
||||||
'使用 <ft color=(238,120,0)>切换地图</ft> 指令来切换目标地图'
|
|
||||||
' \n'
|
|
||||||
'指令:\n'
|
|
||||||
'- <ft color=(0,148,200)>[资源名称]</ft>'
|
|
||||||
'<ft color=(238,120,0)>{在哪里|在哪|哪里有|哪儿有|哪有|在哪儿}</ft>\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>'
|
|
||||||
),
|
|
||||||
)
|
|
||||||
async def send_find_map_msg(
|
|
||||||
matcher: Matcher, args: Dict[str, Any] = RegexDict()
|
|
||||||
):
|
|
||||||
map_id = MAP_ID_LIST[0]
|
map_id = MAP_ID_LIST[0]
|
||||||
map_name = MAP_CHN_NAME[map_id]
|
map_name = MAP_CHN_NAME[map_id]
|
||||||
|
args = ev['match'].groupdict().get('name')
|
||||||
logger.info(f'[查找资源点]正在执行...当前地图为{map_name}')
|
logger.info(f'[查找资源点]正在执行...当前地图为{map_name}')
|
||||||
logger.info('[查找资源点]参数: {}'.format(args))
|
logger.info('[查找资源点]参数: {}'.format(args))
|
||||||
|
|
||||||
if not (args and (name := args.get('name'))):
|
if not args:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
im = ''
|
||||||
|
|
||||||
if not MAP_DATA.exists():
|
if not MAP_DATA.exists():
|
||||||
MAP_DATA.mkdir()
|
MAP_DATA.mkdir()
|
||||||
|
|
||||||
resource_temp_path = MAP_DATA / f'{map_name}_{name}.jpg'
|
resource_temp_path = MAP_DATA / f'{map_name}_{args}.jpg'
|
||||||
if resource_temp_path.exists():
|
if resource_temp_path.exists():
|
||||||
logger.info(f'本地已有{map_name}_{name}的资源点,直接发送...')
|
logger.info(f'本地已有{map_name}_{args}的资源点,直接发送...')
|
||||||
with open(resource_temp_path, 'rb') as f:
|
resource_temp = await convert_img(resource_temp_path)
|
||||||
await matcher.finish(MessageSegment.image(f.read()))
|
await bot.send(ev, resource_temp)
|
||||||
else:
|
else:
|
||||||
# 放弃安慰剂回复
|
# 放弃安慰剂回复
|
||||||
'''
|
'''
|
||||||
await matcher.send(
|
await bot.send(
|
||||||
(
|
ev,
|
||||||
f'正在查找{name},可能需要比较久的时间...\n'
|
f'正在查找{args},可能需要比较久的时间...\n当前地图:{map_name}',
|
||||||
f'当前地图:{MAP_CHN_NAME.get(MAP_ID_LIST[0])}'
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
'''
|
'''
|
||||||
logger.info('本地未缓存,正在渲染...')
|
logger.info('本地未缓存,正在渲染...')
|
||||||
im = await draw_genshin_map(name, map_id, map_name)
|
im = await draw_genshin_map(args, map_id, map_name)
|
||||||
if isinstance(im, str):
|
if isinstance(im, str):
|
||||||
# 如果无结果,直接不返回
|
return
|
||||||
await matcher.finish()
|
# await bot.send(ev, im)
|
||||||
elif isinstance(im, bytes):
|
elif isinstance(im, bytes):
|
||||||
await matcher.finish(MessageSegment.image(im))
|
im = await convert_img(im)
|
||||||
else:
|
await bot.send(ev, im)
|
||||||
await matcher.finish('查找失败!')
|
|
||||||
|
@ -1,54 +0,0 @@
|
|||||||
from typing import Optional
|
|
||||||
|
|
||||||
from nonebot.plugin import PluginMetadata
|
|
||||||
|
|
||||||
sub_menus = []
|
|
||||||
__plugin_meta__ = PluginMetadata(
|
|
||||||
name='GenshinUID',
|
|
||||||
description='基于NoneBot2的原神Uid查询/原神Wiki/米游社签到/树脂提醒插件',
|
|
||||||
usage=(
|
|
||||||
'发送 <ft color=(238,120,0)>gs帮助</ft> 可以获取帮助列表,也可以参考下面的表格\n'
|
|
||||||
'可以使用 <ft color=(238,120,0)>菜单 gsuid </ft>'
|
|
||||||
'<ft color=(0,148,200)>[序号]</ft> '
|
|
||||||
'指令获取某功能详细介绍\n'
|
|
||||||
' \n'
|
|
||||||
'菜单描述中的指令:\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'},
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def register_menu_func(
|
|
||||||
func: str,
|
|
||||||
trigger_condition: str,
|
|
||||||
brief_des: str,
|
|
||||||
trigger_method: str = '指令',
|
|
||||||
detail_des: Optional[str] = None,
|
|
||||||
):
|
|
||||||
sub_menus.append(
|
|
||||||
{
|
|
||||||
'func': func,
|
|
||||||
'trigger_method': trigger_method,
|
|
||||||
'trigger_condition': trigger_condition,
|
|
||||||
'brief_des': brief_des,
|
|
||||||
'detail_des': detail_des or brief_des,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def register_menu(*args, **kwargs):
|
|
||||||
def decorator(f):
|
|
||||||
register_menu_func(*args, **kwargs)
|
|
||||||
return f
|
|
||||||
|
|
||||||
return decorator
|
|
@ -1,75 +1,35 @@
|
|||||||
import random
|
import random
|
||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
from nonebot.log import logger
|
from nonebot import get_bot
|
||||||
from nonebot.matcher import Matcher
|
from hoshino.typing import CQEvent, HoshinoBot
|
||||||
from nonebot import get_bot, on_command
|
|
||||||
from nonebot.permission import SUPERUSER
|
|
||||||
from nonebot_plugin_apscheduler import scheduler
|
|
||||||
from nonebot.adapters.onebot.v11 import MessageEvent
|
|
||||||
|
|
||||||
from ..config import priority
|
from ..base import sv, logger
|
||||||
from ..genshinuid_meta import register_menu
|
|
||||||
from ..utils.nonebot2.rule import FullCommand
|
|
||||||
from ..utils.nonebot2.utils import get_superusers
|
|
||||||
from ..utils.db_operation.db_operation import config_check
|
from ..utils.db_operation.db_operation import config_check
|
||||||
from ..utils.exception.handle_exception import handle_exception
|
|
||||||
from .daily_mihoyo_bbs_coin import mihoyo_coin, all_daily_mihoyo_bbs_coin
|
from .daily_mihoyo_bbs_coin import mihoyo_coin, all_daily_mihoyo_bbs_coin
|
||||||
|
|
||||||
bbscoin_scheduler = scheduler
|
|
||||||
|
|
||||||
get_mihoyo_coin = on_command('开始获取米游币', priority=priority, rule=FullCommand())
|
|
||||||
all_bbscoin_recheck = on_command(
|
|
||||||
'全部重获取', permission=SUPERUSER, priority=priority, rule=FullCommand()
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
# 获取米游币
|
# 获取米游币
|
||||||
@get_mihoyo_coin.handle()
|
@sv.on_fullmatch('开始获取米游币')
|
||||||
@handle_exception('获取米游币')
|
async def send_mihoyo_coin(bot: HoshinoBot, ev: CQEvent):
|
||||||
@register_menu(
|
await bot.send(ev, '开始操作……', at_sender=True)
|
||||||
'手动获取米游币',
|
qid = int(ev.sender['user_id']) # type: ignore
|
||||||
'开始获取米游币',
|
|
||||||
'手动触发米游社米游币任务',
|
|
||||||
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 = event.user_id
|
|
||||||
im = await mihoyo_coin(qid)
|
im = await mihoyo_coin(qid)
|
||||||
await matcher.finish(im, at_sender=True)
|
await bot.send(ev, im, at_sender=True)
|
||||||
|
|
||||||
|
|
||||||
@all_bbscoin_recheck.handle()
|
@sv.on_fullmatch('全部重获取')
|
||||||
@handle_exception('米游币全部重获取')
|
async def bbs_recheck(bot: HoshinoBot, ev: CQEvent):
|
||||||
@register_menu(
|
qid = int(ev.sender['user_id']) # type: ignore
|
||||||
'重新获取米游币',
|
if qid not in bot.config.SUPERUSERS:
|
||||||
'全部重获取',
|
return
|
||||||
'重新运行所有自动获取米游币的任务',
|
await bot.send(ev, '已开始执行!可能需要较久时间!')
|
||||||
detail_des=(
|
|
||||||
'介绍:\n'
|
|
||||||
'重新运行所有自动获取米游币的任务\n'
|
|
||||||
' \n'
|
|
||||||
'指令:\n'
|
|
||||||
'- <ft color=(238,120,0)>全部重获取</ft>'
|
|
||||||
),
|
|
||||||
)
|
|
||||||
async def bbs_recheck(
|
|
||||||
matcher: Matcher,
|
|
||||||
):
|
|
||||||
await matcher.send('已开始执行!可能需要较久时间!')
|
|
||||||
await send_daily_mihoyo_bbs_sign()
|
await send_daily_mihoyo_bbs_sign()
|
||||||
await matcher.finish('执行完成!')
|
await bot.send(ev, '执行完成!')
|
||||||
|
|
||||||
|
|
||||||
# 每日一点十六分进行米游币获取
|
# 每日一点十六分进行米游币获取
|
||||||
@bbscoin_scheduler.scheduled_job('cron', hour='1', minute='16')
|
@sv.scheduled_job('cron', hour='1', minute='16')
|
||||||
async def sign_at_night():
|
async def sign_at_night():
|
||||||
if await config_check('SchedMhyBBSCoin'):
|
if await config_check('SchedMhyBBSCoin'):
|
||||||
await send_daily_mihoyo_bbs_sign()
|
await send_daily_mihoyo_bbs_sign()
|
||||||
@ -85,7 +45,7 @@ async def send_daily_mihoyo_bbs_sign():
|
|||||||
)
|
)
|
||||||
await asyncio.sleep(5 + random.randint(1, 3))
|
await asyncio.sleep(5 + random.randint(1, 3))
|
||||||
if await config_check('PrivateReport'):
|
if await config_check('PrivateReport'):
|
||||||
for qid in get_superusers():
|
for qid in bot.config.SUPERUSERS:
|
||||||
await bot.call_api(api='send_private_msg', user_id=qid, message=im)
|
await bot.send_private_msg(user_id=qid, message=im)
|
||||||
await asyncio.sleep(5 + random.randint(1, 3))
|
await asyncio.sleep(5 + random.randint(1, 3))
|
||||||
logger.info('米游币获取已结束。')
|
logger.info('米游币获取已结束。')
|
||||||
|
@ -1,104 +1,39 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
from typing import Any, Tuple
|
|
||||||
|
|
||||||
from nonebot.log import logger
|
from hoshino.typing import CQEvent, HoshinoBot
|
||||||
from nonebot.matcher import Matcher
|
|
||||||
from nonebot.params import RegexGroup
|
|
||||||
from nonebot import on_regex, on_command
|
|
||||||
from nonebot.adapters.onebot.v11 import (
|
|
||||||
Bot,
|
|
||||||
MessageEvent,
|
|
||||||
MessageSegment,
|
|
||||||
GroupMessageEvent,
|
|
||||||
)
|
|
||||||
|
|
||||||
from ..config import priority
|
from ..base import sv, logger
|
||||||
from .get_lots_data import get_lots_msg
|
from .get_lots_data import get_lots_msg
|
||||||
from .get_meme_card import get_meme_img
|
from .get_meme_card import get_meme_img
|
||||||
from ..genshinuid_meta import register_menu
|
|
||||||
from ..utils.nonebot2.rule import FullCommand
|
|
||||||
from .get_mys_data import get_region_task, get_task_detail
|
from .get_mys_data import get_region_task, get_task_detail
|
||||||
from ..utils.exception.handle_exception import handle_exception
|
from ..utils.draw_image_tools.send_image_tool import convert_img
|
||||||
|
|
||||||
get_task_adv = on_regex(
|
|
||||||
r'^(原神任务|任务|任务详情|任务攻略)( )?([\u4e00-\u9fa5]+)( )?$', priority=priority
|
|
||||||
)
|
|
||||||
get_meme = on_command('抽表情', priority=priority, rule=FullCommand())
|
|
||||||
get_lots = on_command('御神签', priority=priority, rule=FullCommand())
|
|
||||||
|
|
||||||
|
|
||||||
@get_task_adv.handle()
|
@sv.on_rex(r'^(原神任务|任务|任务详情|任务攻略)( )?([\u4e00-\u9fa5]+)( )?$')
|
||||||
@handle_exception('任务攻略')
|
async def send_task_adv(bot: HoshinoBot, ev: CQEvent):
|
||||||
@register_menu(
|
args = ev['match'].groups()
|
||||||
'任务攻略',
|
|
||||||
'任务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: GroupMessageEvent,
|
|
||||||
matcher: Matcher,
|
|
||||||
args: Tuple[Any, ...] = RegexGroup(),
|
|
||||||
):
|
|
||||||
if str(args[2]) in ['须弥', '层岩', '海岛']:
|
if str(args[2]) in ['须弥', '层岩', '海岛']:
|
||||||
im = await get_region_task(str(args[2]))
|
im = await get_region_task(str(args[2]))
|
||||||
for i in im:
|
for i in im:
|
||||||
await bot.call_api(
|
await bot.send_group_forward_msg(group_id=ev.group_id, messages=i)
|
||||||
'send_group_forward_msg', group_id=event.group_id, messages=i
|
|
||||||
)
|
|
||||||
await asyncio.sleep(1)
|
await asyncio.sleep(1)
|
||||||
await matcher.finish()
|
return
|
||||||
else:
|
else:
|
||||||
im = await get_task_detail(str(args[2]))
|
im = await get_task_detail(str(args[2]))
|
||||||
await matcher.finish(im)
|
await bot.send(ev, im)
|
||||||
|
|
||||||
|
|
||||||
@get_meme.handle()
|
@sv.on_fullmatch('抽表情')
|
||||||
@handle_exception('抽表情')
|
async def send_meme_card(bot: HoshinoBot, ev: CQEvent):
|
||||||
@register_menu(
|
|
||||||
'抽表情',
|
|
||||||
'抽表情',
|
|
||||||
'随机发送一张札记角色表情',
|
|
||||||
detail_des=(
|
|
||||||
'介绍:\n'
|
|
||||||
'随机发送一张札记角色表情\n'
|
|
||||||
' \n'
|
|
||||||
'指令:\n'
|
|
||||||
'- <ft color=(238,120,0)>抽表情</ft>'
|
|
||||||
),
|
|
||||||
)
|
|
||||||
async def send_meme_card(matcher: Matcher):
|
|
||||||
logger.info('开始执行[抽表情]')
|
logger.info('开始执行[抽表情]')
|
||||||
img = await get_meme_img()
|
img = await get_meme_img()
|
||||||
await matcher.finish(MessageSegment.image(img))
|
img = await convert_img(img)
|
||||||
|
await bot.send(ev, img)
|
||||||
|
|
||||||
|
|
||||||
@get_lots.handle()
|
@sv.on_fullmatch('御神签')
|
||||||
@handle_exception('御神签')
|
async def send_lots_data(bot: HoshinoBot, ev: CQEvent):
|
||||||
@register_menu(
|
qid = int(ev.sender['user_id'])
|
||||||
'御神签',
|
|
||||||
'御神签',
|
|
||||||
'鸣神大社御神签',
|
|
||||||
detail_des=(
|
|
||||||
'介绍:\n' '抽一签鸣神大社御神签\n' ' \n' '指令:\n' '- <ft color=(238,120,0)>御神签</ft>'
|
|
||||||
),
|
|
||||||
)
|
|
||||||
async def send_lots_data(matcher: Matcher, event: MessageEvent):
|
|
||||||
qid = event.user_id
|
|
||||||
logger.info('开始执行[御神签]')
|
logger.info('开始执行[御神签]')
|
||||||
im = await get_lots_msg(qid)
|
im = await get_lots_msg(qid)
|
||||||
await matcher.finish(im)
|
await bot.send(ev, im)
|
||||||
|
@ -1,82 +1,48 @@
|
|||||||
from nonebot import on_command
|
import re
|
||||||
from nonebot.log import logger
|
|
||||||
from nonebot.matcher import Matcher
|
from hoshino.typing import CQEvent, HoshinoBot
|
||||||
from nonebot.adapters.onebot.v11 import MessageEvent, MessageSegment
|
|
||||||
|
|
||||||
from .note_text import award
|
from .note_text import award
|
||||||
from ..config import priority
|
from ..base import sv, logger
|
||||||
from .draw_note_card import draw_note_img
|
from .draw_note_card import draw_note_img
|
||||||
from ..genshinuid_meta import register_menu
|
from ..utils.message.error_reply import UID_HINT
|
||||||
from ..utils.nonebot2.rule import FullCommand
|
|
||||||
from ..utils.db_operation.db_operation import select_db
|
from ..utils.db_operation.db_operation import select_db
|
||||||
from ..utils.message.error_reply import CK_HINT, UID_HINT
|
from ..utils.draw_image_tools.send_image_tool import convert_img
|
||||||
from ..utils.exception.handle_exception import handle_exception
|
|
||||||
|
|
||||||
monthly_data = on_command('每月统计', priority=priority, rule=FullCommand())
|
|
||||||
get_genshin_info = on_command(
|
|
||||||
'当前信息', aliases={'zj', '札记', '原石札记'}, priority=priority, rule=FullCommand()
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
# 群聊内 每月统计 功能
|
# 群聊内 每月统计 功能
|
||||||
@monthly_data.handle()
|
@sv.on_fullmatch('每月统计')
|
||||||
@handle_exception('每月统计', '获取/发送每月统计失败', '@未找到绑定信息\n' + CK_HINT)
|
async def send_monthly_data(bot: HoshinoBot, ev: CQEvent):
|
||||||
@register_menu(
|
qid = int(ev.sender['user_id']) # type: ignore
|
||||||
'文字札记',
|
|
||||||
'每月统计',
|
|
||||||
'文字形式米游社札记',
|
|
||||||
detail_des=(
|
|
||||||
'介绍:\n' '文字形式米游社札记\n' ' \n' '指令:\n' '- <ft color=(238,120,0)>每月统计</ft>'
|
|
||||||
),
|
|
||||||
)
|
|
||||||
async def send_monthly_data(
|
|
||||||
event: MessageEvent,
|
|
||||||
matcher: Matcher,
|
|
||||||
):
|
|
||||||
qid = event.user_id
|
|
||||||
uid = await select_db(qid, mode='uid')
|
uid = await select_db(qid, mode='uid')
|
||||||
if isinstance(uid, str):
|
if isinstance(uid, str):
|
||||||
if '未找到绑定的UID' in uid:
|
if '未找到绑定的UID' in uid:
|
||||||
await matcher.finish(UID_HINT)
|
await bot.send(ev, UID_HINT)
|
||||||
else:
|
else:
|
||||||
await matcher.finish('发生未知错误...')
|
await bot.send(ev, '发生未知错误...')
|
||||||
im = await award(uid)
|
im = await award(uid)
|
||||||
await matcher.finish(im, at_sender=True)
|
await bot.send(ev, im, at_sender=True)
|
||||||
|
|
||||||
|
|
||||||
# 群聊内 每月统计 功能
|
@sv.on_fullmatch(('当前信息', 'zj', '原石札记', '札记'))
|
||||||
@get_genshin_info.handle()
|
async def send_monthly_pic(bot: HoshinoBot, ev: CQEvent):
|
||||||
@handle_exception('每月统计', '获取/发送每月统计失败', '@未找到绑定信息\n' + CK_HINT)
|
logger.info('开始执行[每日信息]')
|
||||||
@register_menu(
|
at = re.search(r'\[CQ:at,qq=(\d*)]', str(ev.message))
|
||||||
'图片札记',
|
if at:
|
||||||
'当前信息',
|
qid = int(at.group(1))
|
||||||
'图片形式米游社札记',
|
else:
|
||||||
detail_des=(
|
if ev.sender:
|
||||||
'介绍:\n'
|
qid = int(ev.sender['user_id'])
|
||||||
'图片形式米游社札记\n'
|
else:
|
||||||
' \n'
|
return
|
||||||
'指令:\n'
|
logger.info('[每日信息]QQ号: {}'.format(qid))
|
||||||
'- <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 = event.user_id
|
|
||||||
uid = await select_db(qid, mode='uid')
|
uid = await select_db(qid, mode='uid')
|
||||||
if isinstance(uid, str):
|
logger.info('[每日信息]UID: {}'.format(uid))
|
||||||
if '未找到绑定的UID' in uid:
|
im = await draw_note_img(str(uid))
|
||||||
await matcher.finish(UID_HINT)
|
|
||||||
else:
|
|
||||||
await matcher.finish('发生未知错误...')
|
|
||||||
logger.info(f'[原石札记] 开始绘制,UID: {uid}')
|
|
||||||
im = await draw_note_img(uid)
|
|
||||||
if isinstance(im, str):
|
if isinstance(im, str):
|
||||||
await matcher.finish(im)
|
await bot.send(ev, im)
|
||||||
elif isinstance(im, bytes):
|
elif isinstance(im, bytes):
|
||||||
await matcher.finish(MessageSegment.image(im))
|
im = await convert_img(im)
|
||||||
|
await bot.send(ev, im)
|
||||||
else:
|
else:
|
||||||
await matcher.finish('发生了未知错误,请联系管理员检查后台输出!')
|
await bot.send(ev, '发生了未知错误,请联系管理员检查后台输出!')
|
||||||
|
@ -1,140 +1,118 @@
|
|||||||
|
import re
|
||||||
import asyncio
|
import asyncio
|
||||||
from typing import Union
|
|
||||||
|
|
||||||
from nonebot.log import logger
|
from nonebot import get_bot
|
||||||
from nonebot.params import Depends
|
from hoshino.typing import CQEvent, HoshinoBot
|
||||||
from nonebot.matcher import Matcher
|
|
||||||
from nonebot import get_bot, on_command
|
|
||||||
from nonebot_plugin_apscheduler import scheduler
|
|
||||||
from nonebot.adapters.onebot.v11 import (
|
|
||||||
MessageSegment,
|
|
||||||
GroupMessageEvent,
|
|
||||||
PrivateMessageEvent,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
from ..base import sv, logger
|
||||||
from .notice import get_notice_list
|
from .notice import get_notice_list
|
||||||
from .resin_text import get_resin_text
|
from .resin_text import get_resin_text
|
||||||
from .draw_resin_card import get_resin_img
|
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.error_reply import UID_HINT
|
||||||
from ..utils.db_operation.db_operation import select_db
|
from ..utils.db_operation.db_operation import select_db
|
||||||
from ..utils.message.get_image_and_at import ImageAndAt
|
from ..utils.draw_image_tools.send_image_tool import convert_img
|
||||||
from ..utils.exception.handle_exception import handle_exception
|
|
||||||
|
|
||||||
notice_scheduler = scheduler
|
|
||||||
get_resin_info = on_command(
|
|
||||||
'每日',
|
|
||||||
aliases={'mr', '状态', '实时便笺', '便笺', '便签'},
|
|
||||||
block=True,
|
|
||||||
rule=FullCommand(),
|
|
||||||
)
|
|
||||||
get_daily_info = on_command('当前状态', rule=FullCommand())
|
|
||||||
|
|
||||||
|
|
||||||
@get_daily_info.handle()
|
@sv.on_fullmatch('当前状态')
|
||||||
@handle_exception('每日信息文字版')
|
async def send_daily_info(bot: HoshinoBot, ev: CQEvent):
|
||||||
@register_menu(
|
|
||||||
'文字实时便笺',
|
|
||||||
'当前信息',
|
|
||||||
'米游社实时便笺文字版',
|
|
||||||
detail_des=(
|
|
||||||
'介绍:\n'
|
|
||||||
'米游社实时便笺文字版\n'
|
|
||||||
' \n'
|
|
||||||
'指令:\n'
|
|
||||||
'- <ft color=(238,120,0)>当前状态</ft>'
|
|
||||||
),
|
|
||||||
)
|
|
||||||
async def send_daily_info(
|
|
||||||
event: Union[GroupMessageEvent, PrivateMessageEvent],
|
|
||||||
matcher: Matcher,
|
|
||||||
custom: ImageAndAt = Depends(),
|
|
||||||
):
|
|
||||||
logger.info('开始执行[每日信息文字版]')
|
logger.info('开始执行[每日信息文字版]')
|
||||||
|
at = re.search(r'\[CQ:at,qq=(\d*)]', str(ev.message))
|
||||||
|
if ev.sender:
|
||||||
|
qid = ev.sender['user_id']
|
||||||
|
else:
|
||||||
|
return
|
||||||
|
|
||||||
at = custom.get_first_at()
|
|
||||||
qid = event.user_id
|
|
||||||
if at:
|
if at:
|
||||||
qid = at
|
qid = at.group(1)
|
||||||
|
|
||||||
logger.info('[每日信息文字版]QQ号: {}'.format(qid))
|
logger.info('[每日信息文字版]QQ号: {}'.format(qid))
|
||||||
|
|
||||||
uid: str = await select_db(qid, mode='uid') # type: ignore
|
uid: str = await select_db(qid, mode='uid') # type: ignore
|
||||||
logger.info('[每日信息文字版]UID: {}'.format(uid))
|
logger.info('[每日信息文字版]UID: {}'.format(uid))
|
||||||
|
|
||||||
if not uid:
|
if '未找到绑定的UID' in uid:
|
||||||
await matcher.finish(UID_HINT)
|
await bot.send(ev, UID_HINT)
|
||||||
|
|
||||||
im = await get_resin_text(uid)
|
im = await get_resin_text(uid)
|
||||||
await matcher.finish(im)
|
await bot.send(ev, im)
|
||||||
|
|
||||||
|
|
||||||
@notice_scheduler.scheduled_job('cron', minute='*/30')
|
@sv.scheduled_job('cron', minute='*/30')
|
||||||
async def notice_job():
|
async def notice_job():
|
||||||
bot = get_bot()
|
bot = get_bot()
|
||||||
result = await get_notice_list()
|
result = await get_notice_list()
|
||||||
logger.info('[推送检查]完成!等待消息推送中...')
|
logger.info('[推送检查]完成!等待消息推送中...')
|
||||||
# 执行私聊推送
|
# 执行私聊推送
|
||||||
|
bot_ids = bot._wsr_api_clients.keys()
|
||||||
for qid in result[0]:
|
for qid in result[0]:
|
||||||
try:
|
send_success = False
|
||||||
await bot.call_api(
|
for sid in bot_ids:
|
||||||
api='send_private_msg',
|
try:
|
||||||
user_id=qid,
|
await bot.send_private_msg(
|
||||||
message=result[0][qid],
|
self_id=sid,
|
||||||
)
|
user_id=qid,
|
||||||
except Exception:
|
message=result[0][qid],
|
||||||
|
)
|
||||||
|
send_success = True
|
||||||
|
break
|
||||||
|
except Exception:
|
||||||
|
logger.info(f'[推送检查(轮推)] BOT {sid} 没有 {qid} 好友,已跳过')
|
||||||
|
if not send_success:
|
||||||
logger.warning(f'[推送检查] QQ {qid} 私聊推送失败!')
|
logger.warning(f'[推送检查] QQ {qid} 私聊推送失败!')
|
||||||
await asyncio.sleep(0.5)
|
await asyncio.sleep(0.5)
|
||||||
logger.info('[推送检查]私聊推送完成')
|
logger.info('[推送检查] 私聊推送完成')
|
||||||
# 执行群聊推送
|
# 执行群聊推送
|
||||||
for group_id in result[1]:
|
for group_id in result[1]:
|
||||||
try:
|
send_success = False
|
||||||
await bot.call_api(
|
for sid in bot_ids:
|
||||||
api='send_group_msg',
|
try:
|
||||||
group_id=group_id,
|
await bot.send_group_msg(
|
||||||
message=result[1][group_id],
|
self_id=sid,
|
||||||
)
|
group_id=group_id,
|
||||||
except Exception:
|
message=result[1][group_id],
|
||||||
logger.warning(f'[推送检查] 群 {group_id} 群聊推送失败!')
|
)
|
||||||
|
send_success = True
|
||||||
|
break
|
||||||
|
except Exception:
|
||||||
|
logger.info(f'[推送检查(轮推)] BOT {sid} 没有 {group_id} 群,已跳过')
|
||||||
|
if not send_success:
|
||||||
|
logger.warning(f'[推送检查] 群 {group_id} 推送失败!')
|
||||||
await asyncio.sleep(0.5)
|
await asyncio.sleep(0.5)
|
||||||
logger.info('[推送检查]群聊推送完成')
|
logger.info('[推送检查] 群聊推送完成')
|
||||||
|
|
||||||
|
|
||||||
@get_resin_info.handle()
|
@sv.on_fullmatch(('执行推送检查任务'))
|
||||||
@handle_exception('每日信息')
|
async def manual_notice_job(bot: HoshinoBot, ev: CQEvent):
|
||||||
@register_menu(
|
if ev.sender:
|
||||||
'图片实时便笺',
|
qid = int(ev.sender['user_id'])
|
||||||
'每日',
|
else:
|
||||||
'图片形式米游社实时便笺',
|
return
|
||||||
detail_des=(
|
if qid not in bot.config.SUPERUSERS:
|
||||||
'介绍:\n'
|
return
|
||||||
'图片形式米游社实时便笺\n'
|
await notice_job()
|
||||||
' \n'
|
await bot.send(ev, '推送检查任务已执行')
|
||||||
'指令:\n'
|
|
||||||
'- <ft color=(238,120,0)>每日</ft>\n'
|
|
||||||
'- <ft color=(238,120,0)>mr</ft>\n'
|
@sv.on_fullmatch(('每日', 'mr', '实时便笺', '便笺', '便签'))
|
||||||
'- <ft color=(238,120,0)>状态</ft>\n'
|
async def send_daily_info_pic(bot: HoshinoBot, ev: CQEvent):
|
||||||
'- <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: Union[GroupMessageEvent, PrivateMessageEvent],
|
|
||||||
matcher: Matcher,
|
|
||||||
custom: ImageAndAt = Depends(),
|
|
||||||
):
|
|
||||||
logger.info('开始执行[每日信息]')
|
logger.info('开始执行[每日信息]')
|
||||||
|
at = re.search(r'\[CQ:at,qq=(\d*)]', str(ev.message))
|
||||||
|
|
||||||
at = custom.get_first_at()
|
|
||||||
qid = event.user_id
|
|
||||||
if at:
|
if at:
|
||||||
qid = at
|
qid = int(at.group(1))
|
||||||
|
else:
|
||||||
|
if ev.sender:
|
||||||
|
qid = int(ev.sender['user_id'])
|
||||||
|
else:
|
||||||
|
return
|
||||||
|
|
||||||
logger.info('[每日信息]QQ号: {}'.format(qid))
|
logger.info('[每日信息]QQ号: {}'.format(qid))
|
||||||
|
|
||||||
im = await get_resin_img(qid)
|
im = await get_resin_img(qid)
|
||||||
if isinstance(im, str):
|
if isinstance(im, str):
|
||||||
await matcher.finish(im)
|
await bot.send(ev, im)
|
||||||
elif isinstance(im, bytes):
|
elif isinstance(im, bytes):
|
||||||
await matcher.finish(MessageSegment.image(im))
|
im = await convert_img(im)
|
||||||
|
await bot.send(ev, im)
|
||||||
else:
|
else:
|
||||||
await matcher.finish('发生了未知错误,请联系管理员检查后台输出!')
|
await bot.send(ev, '发生了未知错误,请联系管理员检查后台输出!')
|
||||||
|
@ -1,52 +1,25 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
import threading
|
import threading
|
||||||
from typing import Union
|
|
||||||
|
|
||||||
from nonebot import on_command
|
from hoshino.typing import CQEvent, HoshinoBot
|
||||||
from nonebot.log import logger
|
|
||||||
from nonebot.matcher import Matcher
|
|
||||||
from nonebot.permission import SUPERUSER
|
|
||||||
from nonebot.adapters.onebot.v11 import (
|
|
||||||
Bot,
|
|
||||||
GroupMessageEvent,
|
|
||||||
PrivateMessageEvent,
|
|
||||||
)
|
|
||||||
|
|
||||||
from ..genshinuid_meta import register_menu
|
from ..base import sv, logger
|
||||||
from ..utils.nonebot2.rule import FullCommand
|
|
||||||
from ..utils.exception.handle_exception import handle_exception
|
|
||||||
from ..utils.download_resource.download_all_resource import (
|
from ..utils.download_resource.download_all_resource import (
|
||||||
download_all_resource,
|
download_all_resource,
|
||||||
)
|
)
|
||||||
|
|
||||||
download_resource = on_command('下载全部资源', rule=FullCommand())
|
|
||||||
|
|
||||||
|
@sv.on_fullmatch('下载全部资源')
|
||||||
@download_resource.handle()
|
async def send_download_resource_msg(bot: HoshinoBot, ev: CQEvent):
|
||||||
@handle_exception('下载全部资源', '资源下载错误')
|
if ev.sender:
|
||||||
@register_menu(
|
qid = ev.sender['user_id']
|
||||||
'下载全部资源',
|
else:
|
||||||
'下载全部资源',
|
|
||||||
'手动下载插件运行所需的资源',
|
|
||||||
trigger_method='管理员指令',
|
|
||||||
detail_des=(
|
|
||||||
'介绍:\n'
|
|
||||||
'手动下载插件正常运行所需的资源(一般每次启动会自动检查并下载)\n'
|
|
||||||
' \n'
|
|
||||||
'指令:\n'
|
|
||||||
'- <ft color=(238,120,0)>下载全部资源</ft>'
|
|
||||||
),
|
|
||||||
)
|
|
||||||
async def send_download_resource_msg(
|
|
||||||
bot: Bot,
|
|
||||||
event: Union[GroupMessageEvent, PrivateMessageEvent],
|
|
||||||
matcher: Matcher,
|
|
||||||
):
|
|
||||||
if not await SUPERUSER(bot, event):
|
|
||||||
return
|
return
|
||||||
await matcher.send('正在开始下载~可能需要较久的时间!')
|
if qid not in bot.config.SUPERUSERS:
|
||||||
|
return
|
||||||
|
await bot.send(ev, '正在开始下载~可能需要较久的时间!')
|
||||||
im = await download_all_resource()
|
im = await download_all_resource()
|
||||||
await matcher.finish(im)
|
await bot.send(ev, im)
|
||||||
|
|
||||||
|
|
||||||
async def startup():
|
async def startup():
|
||||||
|
@ -1,107 +1,27 @@
|
|||||||
import re
|
import re
|
||||||
from typing import Union
|
|
||||||
|
|
||||||
from nonebot import on_command
|
from hoshino.typing import CQEvent, HoshinoBot
|
||||||
from nonebot.log import logger
|
|
||||||
from nonebot.matcher import Matcher
|
|
||||||
from nonebot.params import Depends, CommandArg
|
|
||||||
from nonebot.adapters.onebot.v11 import (
|
|
||||||
Message,
|
|
||||||
MessageSegment,
|
|
||||||
GroupMessageEvent,
|
|
||||||
PrivateMessageEvent,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
from ..base import sv, logger
|
||||||
from .get_regtime import calc_reg_time
|
from .get_regtime import calc_reg_time
|
||||||
from .draw_roleinfo_card import draw_pic
|
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.error_reply import UID_HINT
|
||||||
from ..utils.db_operation.db_operation import select_db
|
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_role_info = on_command('uid', aliases={'查询'})
|
|
||||||
get_reg_time = on_command(
|
|
||||||
'原神注册时间', aliases={'注册时间', '查询注册时间'}, rule=FullCommand()
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@get_role_info.handle()
|
@sv.on_prefix(('原神注册时间', '注册时间'))
|
||||||
@handle_exception('查询角色信息')
|
async def regtime(bot, ev):
|
||||||
@register_menu(
|
at = re.search(r'\[CQ:at,qq=(\d*)]', str(ev.message))
|
||||||
'查询帐号信息',
|
|
||||||
'查询',
|
|
||||||
'帐号基础数据与角色信息总览',
|
|
||||||
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: Union[GroupMessageEvent, PrivateMessageEvent],
|
|
||||||
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
|
|
||||||
qid = event.user_id
|
|
||||||
at = custom.get_first_at()
|
|
||||||
if at:
|
if at:
|
||||||
qid = at
|
qid = int(at.group(1))
|
||||||
|
|
||||||
# 获取uid
|
|
||||||
uid = re.findall(r'\d+', raw_mes)
|
|
||||||
if uid:
|
|
||||||
uid = uid[0]
|
|
||||||
else:
|
else:
|
||||||
uid = await select_db(qid, mode='uid')
|
if ev.sender:
|
||||||
uid = str(uid)
|
qid = int(ev.sender['user_id'])
|
||||||
|
else:
|
||||||
logger.info('开始执行[查询角色信息]')
|
return
|
||||||
logger.info('[查询角色信息]参数: {}'.format(args))
|
|
||||||
logger.info('[查询角色信息]uid: {}'.format(uid))
|
|
||||||
|
|
||||||
if '未找到绑定的UID' in uid:
|
|
||||||
await matcher.finish(UID_HINT)
|
|
||||||
|
|
||||||
im = await draw_pic(uid)
|
|
||||||
|
|
||||||
if isinstance(im, str):
|
|
||||||
await matcher.finish(im)
|
|
||||||
elif isinstance(im, bytes):
|
|
||||||
await matcher.finish(MessageSegment.image(im))
|
|
||||||
else:
|
|
||||||
await matcher.finish('发生了未知错误,请联系管理员检查后台输出!')
|
|
||||||
|
|
||||||
|
|
||||||
@get_reg_time.handle()
|
|
||||||
async def regtime(
|
|
||||||
event: Union[GroupMessageEvent, PrivateMessageEvent],
|
|
||||||
matcher: Matcher,
|
|
||||||
custom: ImageAndAt = Depends(),
|
|
||||||
):
|
|
||||||
qid = event.user_id
|
|
||||||
at = custom.get_first_at()
|
|
||||||
if at:
|
|
||||||
qid = at
|
|
||||||
|
|
||||||
uid = await select_db(qid, mode='uid')
|
uid = await select_db(qid, mode='uid')
|
||||||
uid = str(uid)
|
uid = str(uid)
|
||||||
@ -110,11 +30,57 @@ async def regtime(
|
|||||||
logger.info('[查询注册时间]uid: {}'.format(uid))
|
logger.info('[查询注册时间]uid: {}'.format(uid))
|
||||||
|
|
||||||
if '未找到绑定的UID' in uid:
|
if '未找到绑定的UID' in uid:
|
||||||
await matcher.finish(UID_HINT)
|
await bot.send(ev, UID_HINT)
|
||||||
|
|
||||||
im = await calc_reg_time(uid)
|
im = await calc_reg_time(uid)
|
||||||
|
await bot.send(ev, im)
|
||||||
|
|
||||||
|
|
||||||
|
@sv.on_rex(r'^()?()?()?([1256][0-9]{8})()?()?$')
|
||||||
|
@sv.on_rex(
|
||||||
|
r'^(\[CQ:at,qq=[0-9]+\])?( )?'
|
||||||
|
r'(uid|查询|mys)([0-9]+)?'
|
||||||
|
r'(\[CQ:at,qq=[0-9]+\])?( )?$',
|
||||||
|
)
|
||||||
|
async def send_role_info(bot: HoshinoBot, ev: CQEvent):
|
||||||
|
args = ev['match'].groups()
|
||||||
|
at = re.search(r'\[CQ:at,qq=(\d*)]', str(ev.message))
|
||||||
|
|
||||||
|
if at:
|
||||||
|
qid = int(at.group(1))
|
||||||
|
else:
|
||||||
|
if ev.sender:
|
||||||
|
qid = int(ev.sender['user_id'])
|
||||||
|
else:
|
||||||
|
return
|
||||||
|
|
||||||
|
# 判断uid
|
||||||
|
if args[2] != 'mys':
|
||||||
|
if args[3] is None:
|
||||||
|
if args[2] is None:
|
||||||
|
return
|
||||||
|
uid = await select_db(qid, mode='uid')
|
||||||
|
uid = str(uid)
|
||||||
|
elif len(args[3]) != 9:
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
uid = args[3]
|
||||||
|
else:
|
||||||
|
uid = await convert_mysid(args[3])
|
||||||
|
|
||||||
|
logger.info('开始执行[查询角色信息]')
|
||||||
|
logger.info('[查询角色信息]参数: {}'.format(args))
|
||||||
|
logger.info('[查询角色信息]uid: {}'.format(uid))
|
||||||
|
|
||||||
|
if '未找到绑定的UID' in uid:
|
||||||
|
await bot.send(ev, UID_HINT)
|
||||||
|
|
||||||
|
im = await draw_pic(uid)
|
||||||
|
|
||||||
if isinstance(im, str):
|
if isinstance(im, str):
|
||||||
await matcher.finish(im)
|
await bot.send(ev, im)
|
||||||
|
elif isinstance(im, bytes):
|
||||||
|
im = await convert_img(im)
|
||||||
|
await bot.send(ev, im)
|
||||||
else:
|
else:
|
||||||
await matcher.finish('发生了未知错误,请联系管理员检查后台输出!')
|
await bot.send(ev, '发生了未知错误,请联系管理员检查后台输出!')
|
||||||
|
@ -1,88 +1,51 @@
|
|||||||
import random
|
import random
|
||||||
import asyncio
|
|
||||||
|
|
||||||
from nonebot.log import logger
|
|
||||||
from nonebot.matcher import Matcher
|
|
||||||
from nonebot import get_bot, on_command
|
|
||||||
from nonebot.permission import SUPERUSER
|
|
||||||
from nonebot.adapters.onebot.v11 import MessageEvent
|
|
||||||
|
|
||||||
from ..config import priority
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from sign import sign_in, daily_sign
|
from sign import sign_in, daily_sign
|
||||||
except ImportError:
|
except ImportError:
|
||||||
from .sign import sign_in, daily_sign
|
from .sign import sign_in, daily_sign
|
||||||
|
|
||||||
from nonebot_plugin_apscheduler import scheduler
|
import asyncio
|
||||||
|
|
||||||
from ..genshinuid_meta import register_menu
|
from nonebot import get_bot
|
||||||
from ..utils.nonebot2.rule import FullCommand
|
from hoshino.typing import CQEvent, HoshinoBot
|
||||||
from ..utils.exception.handle_exception import handle_exception
|
|
||||||
|
from ..base import sv, logger
|
||||||
from ..utils.db_operation.db_operation import select_db, config_check
|
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()
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
# 每日零点半执行米游社原神签到
|
# 每日零点半执行米游社原神签到
|
||||||
@sign_scheduler.scheduled_job('cron', hour='0', minute='30')
|
@sv.scheduled_job('cron', hour='0', minute='30')
|
||||||
async def sign_at_night():
|
async def sign_at_night():
|
||||||
if await config_check('SchedSignin'):
|
if await config_check('SchedSignin'):
|
||||||
await send_daily_sign()
|
await send_daily_sign()
|
||||||
|
|
||||||
|
|
||||||
# 群聊内 签到 功能
|
# 群聊内 签到 功能
|
||||||
@get_sign.handle()
|
@sv.on_rex(r'^(gs|米游社)(签到)$')
|
||||||
@handle_exception('签到')
|
async def get_sign_func(bot: HoshinoBot, ev: CQEvent):
|
||||||
@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('开始执行[签到]')
|
logger.info('开始执行[签到]')
|
||||||
qid = event.user_id
|
qid = int(ev.sender['user_id']) # type: ignore
|
||||||
logger.info('[签到]QQ号: {}'.format(qid))
|
logger.info('[签到]QQ号: {}'.format(qid))
|
||||||
uid = await select_db(qid, mode='uid')
|
uid = await select_db(qid, mode='uid')
|
||||||
logger.info('[签到]UID: {}'.format(uid))
|
logger.info('[签到]UID: {}'.format(uid))
|
||||||
im = await sign_in(uid)
|
im = await sign_in(uid)
|
||||||
await matcher.finish(im, at_sender=True)
|
await bot.send(ev, im, at_sender=True)
|
||||||
|
|
||||||
|
|
||||||
@all_recheck.handle()
|
@sv.on_fullmatch('全部重签')
|
||||||
@handle_exception('全部重签')
|
async def recheck(bot: HoshinoBot, ev: CQEvent):
|
||||||
@register_menu(
|
if ev.sender:
|
||||||
'米游社原神重签到',
|
qid = int(ev.sender['user_id'])
|
||||||
'全部重签',
|
else:
|
||||||
'重新运行所有自动米游社原神签到任务',
|
return
|
||||||
detail_des=(
|
if qid not in bot.config.SUPERUSERS:
|
||||||
'介绍:\n'
|
return
|
||||||
'重新运行所有自动米游社原神签到任务\n'
|
|
||||||
' \n'
|
|
||||||
'指令:\n'
|
|
||||||
'- <ft color=(238,120,0)>全部重签</ft>'
|
|
||||||
),
|
|
||||||
)
|
|
||||||
async def recheck(matcher: Matcher):
|
|
||||||
logger.info('开始执行[全部重签]')
|
logger.info('开始执行[全部重签]')
|
||||||
await matcher.send('已开始执行')
|
await bot.send(ev, '已开始执行')
|
||||||
await send_daily_sign()
|
await send_daily_sign()
|
||||||
await matcher.finish('执行完成')
|
await bot.send(ev, '执行完成')
|
||||||
|
|
||||||
|
|
||||||
async def send_daily_sign():
|
async def send_daily_sign():
|
||||||
@ -97,8 +60,7 @@ async def send_daily_sign():
|
|||||||
# 执行私聊推送
|
# 执行私聊推送
|
||||||
for qid in private_msg_list:
|
for qid in private_msg_list:
|
||||||
try:
|
try:
|
||||||
await bot.call_api(
|
await bot.send_private_msg(
|
||||||
api='send_private_msg',
|
|
||||||
user_id=qid,
|
user_id=qid,
|
||||||
message=private_msg_list[qid],
|
message=private_msg_list[qid],
|
||||||
)
|
)
|
||||||
@ -125,8 +87,7 @@ async def send_daily_sign():
|
|||||||
msg_title = group_msg_list[gid]['push_message']
|
msg_title = group_msg_list[gid]['push_message']
|
||||||
# 发送群消息
|
# 发送群消息
|
||||||
try:
|
try:
|
||||||
await bot.call_api(
|
await bot.send_group_msg(
|
||||||
api='send_group_msg',
|
|
||||||
group_id=gid,
|
group_id=gid,
|
||||||
message=msg_title,
|
message=msg_title,
|
||||||
)
|
)
|
||||||
|
@ -1,131 +1,78 @@
|
|||||||
from typing import Any, Tuple
|
from nonebot import get_bot, on_startup
|
||||||
|
from hoshino.typing import CQEvent, HoshinoBot
|
||||||
|
|
||||||
from nonebot.log import logger
|
from ..base import sv, 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, on_command
|
|
||||||
from nonebot.adapters.onebot.v11 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 .draw_update_log import draw_update_log_img
|
||||||
from .restart import restart_message, restart_genshinuid
|
from .restart import restart_message, restart_genshinuid
|
||||||
|
from ..utils.draw_image_tools.send_image_tool import convert_img
|
||||||
gs_restart = on_command('gs重启', rule=FullCommand())
|
|
||||||
get_update_log = on_command('更新记录', rule=FullCommand())
|
|
||||||
gs_update = on_regex(
|
|
||||||
r'^(gs)(强行)?(强制)?(更新)$',
|
|
||||||
block=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
driver = get_driver()
|
@on_startup
|
||||||
|
async def check_msg():
|
||||||
|
try:
|
||||||
|
logger.info('检查遗留信息...')
|
||||||
|
update_log = await restart_message()
|
||||||
|
if update_log == {}:
|
||||||
|
return
|
||||||
|
bot = get_bot()
|
||||||
|
if update_log['send_type'] == 'group':
|
||||||
|
await bot.send_group_msg(
|
||||||
|
group_id=update_log['send_to'],
|
||||||
|
message=update_log['msg'],
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
await bot.send_private_msg(
|
||||||
|
user_id=update_log['send_to'],
|
||||||
|
message=update_log['msg'],
|
||||||
|
)
|
||||||
|
logger.info('遗留信息检查完毕!')
|
||||||
|
except Exception:
|
||||||
|
logger.warning('遗留信息检查失败!')
|
||||||
|
|
||||||
|
|
||||||
@driver.on_bot_connect
|
@sv.on_fullmatch('gs重启')
|
||||||
async def _():
|
async def send_restart_msg(bot: HoshinoBot, ev: CQEvent):
|
||||||
logger.info('检查遗留信息...')
|
if ev.sender:
|
||||||
bot = get_bot()
|
qid = int(ev.sender['user_id'])
|
||||||
update_log = await restart_message()
|
else:
|
||||||
if update_log == {}:
|
|
||||||
return
|
return
|
||||||
if update_log['send_type'] == 'group':
|
if qid not in bot.config.SUPERUSERS:
|
||||||
await bot.call_api(
|
|
||||||
api='send_group_msg',
|
|
||||||
group_id=update_log['send_to'],
|
|
||||||
message=update_log['msg'],
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
await bot.call_api(
|
|
||||||
api='send_private_msg',
|
|
||||||
user_id=update_log['send_to'],
|
|
||||||
message=update_log['msg'],
|
|
||||||
)
|
|
||||||
logger.info('遗留信息检查完毕!')
|
|
||||||
|
|
||||||
|
|
||||||
@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,
|
|
||||||
):
|
|
||||||
im = await draw_update_log_img(is_update=False)
|
|
||||||
logger.info('正在执行[更新记录]...')
|
|
||||||
if isinstance(im, str):
|
|
||||||
await matcher.finish(im)
|
|
||||||
elif isinstance(im, bytes):
|
|
||||||
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
|
return
|
||||||
logger.warning('开始执行[重启]')
|
logger.warning('开始执行[重启]')
|
||||||
qid = event.user_id
|
|
||||||
if len(event.get_session_id().split('_')) == 3:
|
if ev.group_id:
|
||||||
send_id = event.get_session_id().split('_')[1]
|
send_id = str(ev.group_id)
|
||||||
send_type = 'group'
|
send_type = 'group'
|
||||||
else:
|
else:
|
||||||
send_id = qid
|
send_id = qid
|
||||||
send_type = 'private'
|
send_type = 'private'
|
||||||
await matcher.send('正在执行[gs重启]...')
|
await bot.send(ev, '正在执行[gs重启]...')
|
||||||
await restart_genshinuid(send_type, str(send_id))
|
await restart_genshinuid(send_type, str(send_id))
|
||||||
|
|
||||||
|
|
||||||
@gs_update.handle()
|
@sv.on_fullmatch('更新记录')
|
||||||
@register_menu(
|
async def send_updatelog_msg(bot: HoshinoBot, ev: CQEvent):
|
||||||
'更新插件',
|
im = await draw_update_log_img(is_update=False)
|
||||||
'gs更新',
|
logger.info('正在执行[更新记录]...')
|
||||||
'手动更新插件',
|
if isinstance(im, str):
|
||||||
detail_des=(
|
await bot.send(ev, im)
|
||||||
'介绍:\n'
|
elif isinstance(im, bytes):
|
||||||
'手动更新插件(执行 git pull)\n'
|
im = await convert_img(im)
|
||||||
'每加上一个可选参数,执行等级加1\n'
|
await bot.send(ev, im)
|
||||||
'当执行等级≥1时会还原上次更改,等级≥2时会清空暂存\n'
|
else:
|
||||||
' \n'
|
await bot.send(ev, '发生了未知错误,请联系管理员检查后台输出!')
|
||||||
'指令:\n'
|
|
||||||
'- <ft color=(238,120,0)>gs</ft>'
|
|
||||||
'<ft color=(125,125,125)>(强行)(强制)</ft>'
|
@sv.on_rex(r'^(gs)(强行)?(强制)?(更新)$')
|
||||||
'<ft color=(238,120,0)>更新</ft>'
|
async def send_update_msg(bot: HoshinoBot, ev: CQEvent):
|
||||||
),
|
if ev.sender:
|
||||||
)
|
qid = int(ev.sender['user_id'])
|
||||||
async def send_update_msg(
|
else:
|
||||||
bot: Bot,
|
return
|
||||||
event: MessageEvent,
|
if qid not in bot.config.SUPERUSERS:
|
||||||
matcher: Matcher,
|
|
||||||
args: Tuple[Any, ...] = RegexGroup(),
|
|
||||||
):
|
|
||||||
if not await SUPERUSER(bot, event):
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
args = ev['match'].groups()
|
||||||
logger.info('[gs更新] 正在执行 ...')
|
logger.info('[gs更新] 正在执行 ...')
|
||||||
level = 2
|
level = 2
|
||||||
if args[1] is None:
|
if args[1] is None:
|
||||||
@ -133,11 +80,12 @@ async def send_update_msg(
|
|||||||
if args[2] is None:
|
if args[2] is None:
|
||||||
level -= 1
|
level -= 1
|
||||||
logger.info(f'[gs更新] 更新等级为{level}')
|
logger.info(f'[gs更新] 更新等级为{level}')
|
||||||
await matcher.send(f'开始执行[gs更新], 执行等级为{level}')
|
await bot.send(ev, f'开始执行[gs更新], 执行等级为{level}')
|
||||||
im = await draw_update_log_img(level)
|
im = await draw_update_log_img(level)
|
||||||
if isinstance(im, str):
|
if isinstance(im, str):
|
||||||
await matcher.finish(im)
|
await bot.send(ev, im)
|
||||||
elif isinstance(im, bytes):
|
elif isinstance(im, bytes):
|
||||||
await matcher.finish(MessageSegment.image(im))
|
im = await convert_img(im)
|
||||||
|
await bot.send(ev, im)
|
||||||
else:
|
else:
|
||||||
await matcher.finish('发生了未知错误,请联系管理员检查后台输出!')
|
await bot.send(ev, '发生了未知错误,请联系管理员检查后台输出!')
|
||||||
|
@ -8,7 +8,7 @@ from pathlib import Path
|
|||||||
|
|
||||||
from ..utils.db_operation.db_operation import config_check
|
from ..utils.db_operation.db_operation import config_check
|
||||||
|
|
||||||
bot_start = Path().cwd() / 'bot.py'
|
bot_start = Path().cwd() / 'run.py'
|
||||||
restart_sh_path = Path().cwd() / 'gs_restart.sh'
|
restart_sh_path = Path().cwd() / 'gs_restart.sh'
|
||||||
update_log_path = Path(__file__).parent / 'update_log.json'
|
update_log_path = Path(__file__).parent / 'update_log.json'
|
||||||
|
|
||||||
@ -23,17 +23,17 @@ async def get_restart_sh(extra: str) -> str:
|
|||||||
|
|
||||||
|
|
||||||
async def restart_genshinuid(send_type: str, send_id: str) -> None:
|
async def restart_genshinuid(send_type: str, send_id: str) -> None:
|
||||||
|
pid = os.getpid()
|
||||||
extra = ''
|
extra = ''
|
||||||
if await config_check('UsePoetry'):
|
if await config_check('UsePoetry'):
|
||||||
extra = 'poetry run '
|
extra = 'poetry run '
|
||||||
extra += sys.executable
|
extra += sys.executable
|
||||||
restart_sh = await get_restart_sh(extra)
|
restart_sh = await get_restart_sh(extra)
|
||||||
if not restart_sh_path.exists():
|
with open(restart_sh_path, "w", encoding="utf8") as f:
|
||||||
with open(restart_sh_path, "w", encoding="utf8") as f:
|
f.write(restart_sh)
|
||||||
f.write(restart_sh)
|
if platform.system() == 'Linux':
|
||||||
if platform.system() == 'Linux':
|
os.system(f'chmod +x {str(restart_sh_path)}')
|
||||||
os.system(f'chmod +x {str(restart_sh_path)}')
|
os.system(f'chmod +x {str(bot_start)}')
|
||||||
os.system(f'chmod +x {str(bot_start)}')
|
|
||||||
now_time = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))
|
now_time = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))
|
||||||
update_log = {
|
update_log = {
|
||||||
'type': 'restart',
|
'type': 'restart',
|
||||||
@ -45,9 +45,11 @@ async def restart_genshinuid(send_type: str, send_id: str) -> None:
|
|||||||
with open(str(update_log_path), 'w', encoding='utf-8') as f:
|
with open(str(update_log_path), 'w', encoding='utf-8') as f:
|
||||||
json.dump(update_log, f)
|
json.dump(update_log, f)
|
||||||
if platform.system() == 'Linux':
|
if platform.system() == 'Linux':
|
||||||
os.execl(str(restart_sh_path), ' ')
|
subprocess.Popen(
|
||||||
|
f'kill -9 {pid} & {extra} {bot_start}',
|
||||||
|
shell=True,
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
pid = os.getpid()
|
|
||||||
subprocess.Popen(
|
subprocess.Popen(
|
||||||
f'taskkill /F /PID {pid} & {extra} {bot_start}',
|
f'taskkill /F /PID {pid} & {extra} {bot_start}',
|
||||||
shell=True,
|
shell=True,
|
||||||
|
@ -1,229 +1,103 @@
|
|||||||
from typing import Any, Tuple
|
import hoshino
|
||||||
|
from hoshino.typing import CQEvent, HoshinoBot
|
||||||
from nonebot.log import logger
|
|
||||||
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.onebot.v11 import (
|
|
||||||
PRIVATE_FRIEND,
|
|
||||||
Bot,
|
|
||||||
Message,
|
|
||||||
MessageEvent,
|
|
||||||
MessageSegment,
|
|
||||||
GroupMessageEvent,
|
|
||||||
)
|
|
||||||
|
|
||||||
from .topup import topup_
|
from .topup import topup_
|
||||||
from ..config import priority
|
from ..base import sv, logger
|
||||||
from .qrlogin import qrcode_login
|
from .qrlogin import qrcode_login
|
||||||
from .get_ck_help_msg import get_ck_help
|
from .get_ck_help_msg import get_ck_help
|
||||||
from .draw_user_card import get_user_card
|
from .draw_user_card import get_user_card
|
||||||
from ..genshinuid_meta import register_menu
|
from ..utils.draw_image_tools.send_image_tool import convert_img
|
||||||
from ..utils.nonebot2.rule import FullCommand
|
|
||||||
from ..utils.exception.handle_exception import handle_exception
|
|
||||||
from .add_ck import deal_ck, get_ck_by_stoken, get_ck_by_all_stoken
|
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
|
from ..utils.db_operation.db_operation import bind_db, delete_db, switch_db
|
||||||
|
|
||||||
add_cookie = on_command('添加', permission=PRIVATE_FRIEND)
|
hoshino_bot = hoshino.get_bot()
|
||||||
get_ck_msg = on_command(
|
|
||||||
'绑定ck说明',
|
|
||||||
aliases={'ck帮助', '绑定ck'},
|
|
||||||
block=True,
|
|
||||||
rule=FullCommand(),
|
|
||||||
)
|
|
||||||
bind_info = on_command(
|
|
||||||
'绑定信息', priority=priority, block=True, rule=FullCommand()
|
|
||||||
)
|
|
||||||
refresh_ck = on_command(
|
|
||||||
'刷新CK',
|
|
||||||
aliases={'刷新ck', '刷新Ck', '刷新Cookies'},
|
|
||||||
priority=priority,
|
|
||||||
block=True,
|
|
||||||
rule=FullCommand(),
|
|
||||||
)
|
|
||||||
refresh_all_ck = on_command(
|
|
||||||
'刷新全部CK',
|
|
||||||
aliases={'刷新全部ck', '刷新全部Ck', '刷新全部Cookies'},
|
|
||||||
priority=priority,
|
|
||||||
block=True,
|
|
||||||
rule=FullCommand(),
|
|
||||||
permission=SUPERUSER,
|
|
||||||
)
|
|
||||||
bind = on_regex(
|
|
||||||
r'^(绑定|切换|解绑|删除)(uid|UID|mys|MYS)([0-9]+)?$', priority=priority
|
|
||||||
)
|
|
||||||
get_qrcode_login = on_command(
|
|
||||||
'扫码登录',
|
|
||||||
aliases={'扫码登陆', '扫码登入'},
|
|
||||||
rule=FullCommand(),
|
|
||||||
)
|
|
||||||
get_topup = on_command('gsrc', priority=priority, block=True, aliases={'原神充值'})
|
|
||||||
|
|
||||||
|
|
||||||
@get_topup.handle()
|
@sv.on_fullmatch(('刷新全部CK', '刷新全部ck', '刷新全部Ck', '刷新全部Cookies'))
|
||||||
async def send_topup(bot: Bot, event: GroupMessageEvent):
|
async def send_refresh_allck_msg(bot: HoshinoBot, ev: CQEvent):
|
||||||
qid = event.user_id
|
if ev.sender:
|
||||||
goods_id = event.raw_message.replace('原神充值', '').replace('gsrc', '')
|
qid = int(ev.sender['user_id'])
|
||||||
if goods_id == "":
|
|
||||||
goods_id = 0
|
|
||||||
else:
|
else:
|
||||||
goods_id = int(goods_id)
|
return
|
||||||
group_id = event.group_id
|
if qid not in bot.config.SUPERUSERS:
|
||||||
await topup_(bot, qid, group_id, goods_id)
|
return
|
||||||
|
logger.info('开始执行[刷新全部ck]')
|
||||||
|
|
||||||
@refresh_all_ck.handle()
|
|
||||||
async def send_refresh_all_ck_msg(
|
|
||||||
matcher: Matcher,
|
|
||||||
):
|
|
||||||
logger.info('开始执行[刷新全部CK]')
|
|
||||||
im = await get_ck_by_all_stoken()
|
im = await get_ck_by_all_stoken()
|
||||||
if isinstance(im, str):
|
if isinstance(im, bytes):
|
||||||
await matcher.finish(im)
|
im = await convert_img(im)
|
||||||
await matcher.finish(MessageSegment.image(im))
|
await bot.send(ev, im)
|
||||||
|
|
||||||
|
|
||||||
@refresh_ck.handle()
|
@sv.on_fullmatch(('刷新CK', '刷新ck', '刷新Ck', '刷新Cookies'))
|
||||||
async def send_refresh_ck_msg(
|
async def send_refresh_ck_msg(bot: HoshinoBot, ev: CQEvent):
|
||||||
event: MessageEvent,
|
logger.info('开始执行[刷新ck]')
|
||||||
matcher: Matcher,
|
if ev.sender:
|
||||||
):
|
qid = ev.sender['user_id']
|
||||||
logger.info('开始执行[刷新CK]')
|
else:
|
||||||
qid = event.user_id
|
return
|
||||||
im = await get_ck_by_stoken(qid)
|
im = await get_ck_by_stoken(qid)
|
||||||
if isinstance(im, str):
|
if isinstance(im, bytes):
|
||||||
await matcher.finish(im)
|
im = await convert_img(im)
|
||||||
await matcher.finish(MessageSegment.image(im))
|
await bot.send(ev, im)
|
||||||
|
|
||||||
|
|
||||||
@get_qrcode_login.handle()
|
@sv.on_fullmatch('绑定信息')
|
||||||
async def send_qrcode_login(
|
async def send_bind_card(bot: HoshinoBot, ev: CQEvent):
|
||||||
bot: Bot,
|
logger.info('开始执行[查询用户绑定状态]')
|
||||||
event: GroupMessageEvent,
|
if ev.sender:
|
||||||
matcher: Matcher,
|
qid = ev.sender['user_id']
|
||||||
):
|
else:
|
||||||
logger.info('开始执行[扫码登陆]')
|
return
|
||||||
qid = event.user_id
|
im = await get_user_card(qid)
|
||||||
groupid = event.group_id
|
im = await convert_img(im)
|
||||||
im = await qrcode_login(bot, groupid, qid)
|
logger.info('[查询用户绑定状态]完成!等待图片发送中...')
|
||||||
|
await bot.send(ev, im)
|
||||||
|
|
||||||
|
|
||||||
|
@sv.on_fullmatch(('扫码登陆', '扫码登录', '扫码登入'))
|
||||||
|
async def send_qr_card(bot: HoshinoBot, ev: CQEvent):
|
||||||
|
im = await qrcode_login(hoshino_bot, ev.group_id, ev.user_id)
|
||||||
if not im:
|
if not im:
|
||||||
return
|
return
|
||||||
im = await deal_ck(im, qid)
|
im = await deal_ck(im, ev.user_id) # type: ignore
|
||||||
await matcher.finish(MessageSegment.image(im))
|
if isinstance(im, bytes):
|
||||||
|
im = await convert_img(im)
|
||||||
|
await bot.send(ev, im)
|
||||||
|
|
||||||
|
|
||||||
@bind_info.handle()
|
@hoshino_bot.on_message('private') # type: ignore
|
||||||
@register_menu(
|
async def send_add_ck_msg(ctx):
|
||||||
'绑定状态',
|
message = ctx['raw_message']
|
||||||
'绑定信息',
|
sid = int(ctx['self_id'])
|
||||||
'查询你绑定UID的绑定和推送状态',
|
userid = int(ctx['sender']['user_id'])
|
||||||
detail_des=(
|
gid = 0
|
||||||
'介绍:\n'
|
if message.startswith('添加'):
|
||||||
'查询你绑定的UID列表以及它们的CK、SK绑定状态和推送设置\n'
|
message = message.replace('添加', '').replace(' ', '')
|
||||||
' \n'
|
im = await deal_ck(message, userid) # type: ignore
|
||||||
'指令:\n'
|
else:
|
||||||
'- <ft color=(238,120,0)>绑定信息</ft>'
|
return
|
||||||
),
|
if isinstance(im, bytes):
|
||||||
)
|
im = await convert_img(im)
|
||||||
async def send_bind_card(
|
await hoshino_bot.send_msg(
|
||||||
event: MessageEvent,
|
self_id=sid, user_id=userid, group_id=gid, message=im
|
||||||
matcher: Matcher,
|
)
|
||||||
):
|
|
||||||
logger.info('开始执行[查询用户绑定状态]')
|
|
||||||
qid = event.user_id
|
|
||||||
im = await get_user_card(qid)
|
|
||||||
logger.info('[查询用户绑定状态]完成!等待图片发送中...')
|
|
||||||
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 = event.user_id
|
|
||||||
im = await deal_ck(mes, qid)
|
|
||||||
if isinstance(im, str):
|
|
||||||
await matcher.finish(im)
|
|
||||||
await matcher.finish(MessageSegment.image(im))
|
|
||||||
|
|
||||||
|
|
||||||
# 群聊内 绑定uid或者mysid 的命令,会绑定至当前qq号上
|
# 群聊内 绑定uid或者mysid 的命令,会绑定至当前qq号上
|
||||||
@bind.handle()
|
@sv.on_rex(r'^(绑定|切换|解绑|删除)(uid|UID|mys|MYS)([0-9]+)?$')
|
||||||
@handle_exception('绑定ID', '绑定ID异常')
|
async def send_link_uid_msg(bot: HoshinoBot, ev: CQEvent):
|
||||||
@register_menu(
|
args = ev['match'].groups()
|
||||||
'绑定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('开始执行[绑定/解绑用户信息]')
|
||||||
logger.info('[绑定/解绑]参数: {}'.format(args))
|
logger.info('[绑定/解绑]参数: {}'.format(str(args)))
|
||||||
qid = event.user_id
|
if ev.sender:
|
||||||
|
qid = ev.sender['user_id']
|
||||||
|
else:
|
||||||
|
return
|
||||||
logger.info('[绑定/解绑]UserID: {}'.format(qid))
|
logger.info('[绑定/解绑]UserID: {}'.format(qid))
|
||||||
|
|
||||||
if args[0] in ('绑定'):
|
if args[0] in ('绑定'):
|
||||||
if args[2] is None:
|
if args[2] is None:
|
||||||
await matcher.finish('请输入正确的uid或者mysid!')
|
await bot.send(ev, '请输入正确的uid或者mysid!')
|
||||||
|
|
||||||
if args[1] in ('uid', 'UID'):
|
if args[1] in ('uid', 'UID'):
|
||||||
im = await bind_db(qid, args[2])
|
im = await bind_db(qid, args[2])
|
||||||
@ -236,11 +110,11 @@ async def send_link_uid_msg(
|
|||||||
im = await delete_db(qid, {'UID': args[2]})
|
im = await delete_db(qid, {'UID': args[2]})
|
||||||
else:
|
else:
|
||||||
im = await delete_db(qid, {'MYSID': args[2]})
|
im = await delete_db(qid, {'MYSID': args[2]})
|
||||||
await matcher.finish(im, at_sender=True)
|
await bot.send(ev, im, at_sender=True)
|
||||||
|
|
||||||
|
|
||||||
@get_ck_msg.handle()
|
@sv.on_fullmatch(('绑定ck说明', 'ck帮助', '绑定ck'))
|
||||||
async def send_ck_help(bot: Bot, event: GroupMessageEvent):
|
async def send_ck_msg(bot: HoshinoBot, ev: CQEvent):
|
||||||
msg_list = await get_ck_help()
|
msg_list = await get_ck_help()
|
||||||
forward_msg = []
|
forward_msg = []
|
||||||
for msg in msg_list:
|
for msg in msg_list:
|
||||||
@ -250,6 +124,18 @@ async def send_ck_help(bot: Bot, event: GroupMessageEvent):
|
|||||||
"data": {"name": "小冰", "uin": "2854196306", "content": msg},
|
"data": {"name": "小冰", "uin": "2854196306", "content": msg},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
await bot.call_api(
|
await bot.send_group_forward_msg(
|
||||||
'send_group_forward_msg', group_id=event.group_id, messages=forward_msg
|
group_id=ev.group_id, messages=forward_msg
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@sv.on_prefix(("gsrc", "原神充值"))
|
||||||
|
async def topup(bot: HoshinoBot, ev: CQEvent):
|
||||||
|
qid = ev.user_id
|
||||||
|
goods_id = ev.message.extract_plain_text()
|
||||||
|
if goods_id == "":
|
||||||
|
goods_id = 0
|
||||||
|
else:
|
||||||
|
goods_id = int(goods_id)
|
||||||
|
group_id = ev.group_id
|
||||||
|
await topup_(bot, qid, group_id, goods_id)
|
||||||
|
@ -7,7 +7,6 @@ from typing import Any, Tuple, Union, Literal
|
|||||||
|
|
||||||
import qrcode
|
import qrcode
|
||||||
from nonebot.log import logger
|
from nonebot.log import logger
|
||||||
from qrcode.constants import ERROR_CORRECT_L
|
|
||||||
|
|
||||||
from ..utils.message.send_msg import send_forward_msg
|
from ..utils.message.send_msg import send_forward_msg
|
||||||
from ..utils.db_operation.db_operation import select_db
|
from ..utils.db_operation.db_operation import select_db
|
||||||
@ -31,15 +30,15 @@ disnote = '''免责声明:您将通过扫码完成获取米游社sk以及ck。
|
|||||||
def get_qrcode_base64(url):
|
def get_qrcode_base64(url):
|
||||||
qr = qrcode.QRCode(
|
qr = qrcode.QRCode(
|
||||||
version=1,
|
version=1,
|
||||||
error_correction=ERROR_CORRECT_L,
|
error_correction=qrcode.constants.ERROR_CORRECT_L,
|
||||||
box_size=10,
|
box_size=10,
|
||||||
border=4,
|
border=4,
|
||||||
)
|
)
|
||||||
qr.add_data(url)
|
qr.add_data(url)
|
||||||
qr.make(fit=True)
|
qr.make(fit=True)
|
||||||
img = qr.make_image(fill_color='black', back_color='white')
|
img = qr.make_image(fill_color="black", back_color="white")
|
||||||
img_byte = io.BytesIO()
|
img_byte = io.BytesIO()
|
||||||
img.save(img_byte, format='PNG') # type: ignore
|
img.save(img_byte, format="PNG")
|
||||||
img_byte = img_byte.getvalue()
|
img_byte = img_byte.getvalue()
|
||||||
return base64.b64encode(img_byte).decode()
|
return base64.b64encode(img_byte).decode()
|
||||||
|
|
||||||
@ -51,57 +50,50 @@ async def refresh(
|
|||||||
while True:
|
while True:
|
||||||
await asyncio.sleep(2)
|
await asyncio.sleep(2)
|
||||||
status_data = await check_qrcode(
|
status_data = await check_qrcode(
|
||||||
code_data['app_id'], code_data['ticket'], code_data['device']
|
code_data["app_id"], code_data["ticket"], code_data["device"]
|
||||||
)
|
)
|
||||||
if status_data['retcode'] != 0:
|
if status_data["retcode"] != 0:
|
||||||
logger.warning('二维码已过期')
|
logger.warn("二维码已过期")
|
||||||
return False, None
|
return False, None
|
||||||
if status_data['data']['stat'] == 'Scanned':
|
if status_data["data"]["stat"] == "Scanned":
|
||||||
if not scanned:
|
if not scanned:
|
||||||
logger.info('二维码已扫描')
|
logger.info("二维码已扫描")
|
||||||
scanned = True
|
scanned = True
|
||||||
continue
|
continue
|
||||||
if status_data['data']['stat'] == 'Confirmed':
|
if status_data["data"]["stat"] == "Confirmed":
|
||||||
logger.info('二维码已确认')
|
logger.info("二维码已确认")
|
||||||
# print(status_data['data']['payload']['raw'])
|
# print(status_data["data"]["payload"]["raw"])
|
||||||
break
|
break
|
||||||
return True, json.loads(status_data['data']['payload']['raw'])
|
return True, json.loads(status_data["data"]["payload"]["raw"])
|
||||||
|
|
||||||
|
|
||||||
async def qrcode_login(bot, group_id, user_id) -> str:
|
async def qrcode_login(bot, group_id, user_id) -> str:
|
||||||
async def send_group_msg(msg: str):
|
async def send_group_msg(msg: str):
|
||||||
await bot.call_api(
|
await bot.call_action(
|
||||||
api='send_group_msg',
|
action='send_group_msg',
|
||||||
group_id=group_id,
|
group_id=group_id,
|
||||||
message=msg,
|
message=msg,
|
||||||
)
|
)
|
||||||
return ''
|
return ""
|
||||||
|
|
||||||
code_data = await create_qrcode_url()
|
code_data = await create_qrcode_url()
|
||||||
try:
|
try:
|
||||||
im = []
|
im = []
|
||||||
|
qrc = f'[CQ:image,file=base64://{get_qrcode_base64(code_data["url"])}]'
|
||||||
im.append('请使用米游社扫描下方二维码登录:')
|
im.append('请使用米游社扫描下方二维码登录:')
|
||||||
im.append(
|
im.append(qrc)
|
||||||
f'[CQ:image,file=base64://{get_qrcode_base64(code_data["url"])}]'
|
im.append(disnote)
|
||||||
)
|
|
||||||
im.append(
|
|
||||||
'免责声明:您将通过扫码完成获取米游社sk以及ck。\n'
|
|
||||||
'本Bot将不会保存您的登录状态。\n'
|
|
||||||
'我方仅提供米游社查询及相关游戏内容服务,\n'
|
|
||||||
'若您的账号封禁、被盗等处罚与我方无关。\n'
|
|
||||||
'害怕风险请勿扫码~'
|
|
||||||
)
|
|
||||||
await send_forward_msg(bot, group_id, "扫码小助手", str(user_id), im)
|
await send_forward_msg(bot, group_id, "扫码小助手", str(user_id), im)
|
||||||
except Exception:
|
except Exception:
|
||||||
logger.warning(f'[扫码登录] {user_id} 图片发送失败')
|
logger.warn(f"[扫码登录] {group_id} 图片发送失败")
|
||||||
status, game_token_data = await refresh(code_data)
|
status, game_token_data = await refresh(code_data)
|
||||||
if status:
|
if status:
|
||||||
assert game_token_data is not None # 骗过 pyright
|
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)
|
cookie_token = await get_cookie_token(**game_token_data)
|
||||||
stoken_data = await get_stoken_by_game_token(
|
stoken_data = await get_stoken_by_game_token(
|
||||||
account_id=int(game_token_data['uid']),
|
account_id=int(game_token_data["uid"]),
|
||||||
game_token=game_token_data['token'],
|
game_token=game_token_data["token"],
|
||||||
)
|
)
|
||||||
account_id = game_token_data['uid']
|
account_id = game_token_data['uid']
|
||||||
stoken = stoken_data['data']['token']['token']
|
stoken = stoken_data['data']['token']['token']
|
||||||
@ -124,7 +116,6 @@ async def qrcode_login(bot, group_id, user_id) -> str:
|
|||||||
else:
|
else:
|
||||||
im = '请求失败, 请稍后再试...'
|
im = '请求失败, 请稍后再试...'
|
||||||
return await send_group_msg(im)
|
return await send_group_msg(im)
|
||||||
|
|
||||||
uid_bind = await select_db(user_id, mode='uid')
|
uid_bind = await select_db(user_id, mode='uid')
|
||||||
# 没有在gsuid绑定uid的情况
|
# 没有在gsuid绑定uid的情况
|
||||||
if uid_bind == "未找到绑定的UID~":
|
if uid_bind == "未找到绑定的UID~":
|
||||||
|
@ -5,7 +5,6 @@ import traceback
|
|||||||
|
|
||||||
import qrcode
|
import qrcode
|
||||||
from nonebot.log import logger
|
from nonebot.log import logger
|
||||||
from qrcode.constants import ERROR_CORRECT_L
|
|
||||||
|
|
||||||
from ..utils.message.send_msg import send_forward_msg
|
from ..utils.message.send_msg import send_forward_msg
|
||||||
from ..utils.db_operation.db_operation import select_db
|
from ..utils.db_operation.db_operation import select_db
|
||||||
@ -20,7 +19,7 @@ disnote = '''免责声明:
|
|||||||
def get_qrcode_base64(url):
|
def get_qrcode_base64(url):
|
||||||
qr = qrcode.QRCode(
|
qr = qrcode.QRCode(
|
||||||
version=1,
|
version=1,
|
||||||
error_correction=ERROR_CORRECT_L,
|
error_correction=qrcode.constants.ERROR_CORRECT_L,
|
||||||
box_size=10,
|
box_size=10,
|
||||||
border=4,
|
border=4,
|
||||||
)
|
)
|
||||||
@ -28,7 +27,7 @@ def get_qrcode_base64(url):
|
|||||||
qr.make(fit=True)
|
qr.make(fit=True)
|
||||||
img = qr.make_image(fill_color="black", back_color="white")
|
img = qr.make_image(fill_color="black", back_color="white")
|
||||||
img_byte = io.BytesIO()
|
img_byte = io.BytesIO()
|
||||||
img.save(img_byte, format="PNG") # type: ignore
|
img.save(img_byte, format="PNG")
|
||||||
img_byte = img_byte.getvalue()
|
img_byte = img_byte.getvalue()
|
||||||
return base64.b64encode(img_byte).decode()
|
return base64.b64encode(img_byte).decode()
|
||||||
|
|
||||||
@ -49,12 +48,12 @@ async def refresh(order, uid):
|
|||||||
|
|
||||||
async def topup_(bot, qid, group_id, goods_id):
|
async def topup_(bot, qid, group_id, goods_id):
|
||||||
async def send_group_msg(msg: str):
|
async def send_group_msg(msg: str):
|
||||||
await bot.call_api(
|
await bot.call_action(
|
||||||
api='send_group_msg',
|
action='send_group_msg',
|
||||||
group_id=group_id,
|
group_id=group_id,
|
||||||
message=msg,
|
message=msg,
|
||||||
)
|
)
|
||||||
return ''
|
return ""
|
||||||
|
|
||||||
uid = await select_db(qid, mode="uid")
|
uid = await select_db(qid, mode="uid")
|
||||||
if uid is None:
|
if uid is None:
|
||||||
@ -70,7 +69,7 @@ async def topup_(bot, qid, group_id, goods_id):
|
|||||||
order = await topup(uid, goods_data)
|
order = await topup(uid, goods_data)
|
||||||
except Exception:
|
except Exception:
|
||||||
await send_group_msg("出错了,可能是cookie过期或接口出错")
|
await send_group_msg("出错了,可能是cookie过期或接口出错")
|
||||||
logger.warning(f"[充值] {group_id} {qid}")
|
logger.warn(f"[充值] {group_id} {qid}")
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
im = []
|
im = []
|
||||||
@ -89,5 +88,5 @@ async def topup_(bot, qid, group_id, goods_id):
|
|||||||
await send_forward_msg(bot, group_id, "小助手", str(qid), im)
|
await send_forward_msg(bot, group_id, "小助手", str(qid), im)
|
||||||
except Exception:
|
except Exception:
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
logger.warning(f"[充值] {group_id} 图片发送失败")
|
logger.warn(f"[充值] {group_id} 图片发送失败")
|
||||||
await send_group_msg(await refresh(order, uid))
|
await send_group_msg(await refresh(order, uid))
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
from sqlmodel import SQLModel
|
from sqlmodel import SQLModel
|
||||||
from nonebot import get_driver
|
|
||||||
from nonebot.log import logger
|
from nonebot.log import logger
|
||||||
|
from nonebot import get_bot, on_startup
|
||||||
|
|
||||||
from ..utils.db_operation.db_operation import config_check
|
from ..utils.db_operation.db_operation import config_check
|
||||||
|
|
||||||
driver = get_driver()
|
config = get_bot().config
|
||||||
config = driver.config
|
|
||||||
|
|
||||||
|
|
||||||
async def run_webconsole():
|
async def run_webconsole():
|
||||||
@ -17,28 +16,22 @@ async def run_webconsole():
|
|||||||
user_auth_i18n.set_language('zh_CN')
|
user_auth_i18n.set_language('zh_CN')
|
||||||
|
|
||||||
# 导入app
|
# 导入app
|
||||||
try:
|
from .mount_app import auth, site
|
||||||
from .mount_app import auth, site
|
|
||||||
except RuntimeError:
|
|
||||||
logger.warning("当前 Driver 非 ReverseDriver,WebConsole 已禁用")
|
|
||||||
return
|
|
||||||
|
|
||||||
logger.info('尝试挂载WebConsole')
|
logger.info('尝试挂载WebConsole')
|
||||||
|
|
||||||
await site.db.async_run_sync(
|
await site.db.async_run_sync(
|
||||||
SQLModel.metadata.create_all, is_session=False # type: ignore
|
SQLModel.metadata.create_all, is_session=False # type: ignore
|
||||||
)
|
)
|
||||||
# 创建默认测试用户, 请及时修改密码!!!
|
# 创建默认测试用户, 请及时修改密码!!!
|
||||||
await auth.create_role_user()
|
await auth.create_role_user()
|
||||||
|
|
||||||
logger.opt(colors=True).info(
|
logger.info(
|
||||||
(
|
('WebConsole挂载成功:' f'http://{config.HOST}:{config.PORT}/genshinuid')
|
||||||
'WebConsole挂载成功:'
|
|
||||||
f'<blue>http://{config.host}:{config.port}/genshinuid</blue>'
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@driver.on_startup
|
@on_startup
|
||||||
async def start_check():
|
async def start_check():
|
||||||
if await config_check('OpenWeb'):
|
if await config_check('OpenWeb'):
|
||||||
await run_webconsole()
|
await run_webconsole()
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import fastapi_amis_admin
|
import fastapi_amis_admin
|
||||||
from fastapi import Request
|
from fastapi import Request
|
||||||
from nonebot.typing import overrides
|
|
||||||
from fastapi_user_auth import admin as user_auth_admin
|
from fastapi_user_auth import admin as user_auth_admin
|
||||||
from fastapi_amis_admin.admin import admin as amis_admin
|
from fastapi_amis_admin.admin import admin as amis_admin
|
||||||
from fastapi_amis_admin.utils.translation import i18n as _
|
from fastapi_amis_admin.utils.translation import i18n as _
|
||||||
@ -18,6 +17,7 @@ from fastapi_amis_admin.amis.components import (
|
|||||||
ButtonToolbar,
|
ButtonToolbar,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
from .nb2 import overrides
|
||||||
from ..version import GenshinUID_version
|
from ..version import GenshinUID_version
|
||||||
|
|
||||||
login_html = '''
|
login_html = '''
|
||||||
@ -109,7 +109,7 @@ def attach_page_head(page: Page) -> Page:
|
|||||||
Html(html=login_html),
|
Html(html=login_html),
|
||||||
Grid(
|
Grid(
|
||||||
columns=[
|
columns=[
|
||||||
{'body': [page.body], 'lg': 3, 'md': 4, 'valign': 'middle'}
|
{'body': [page.body], 'lg': 2, 'md': 4, 'valign': 'middle'}
|
||||||
],
|
],
|
||||||
align='center',
|
align='center',
|
||||||
valign='middle',
|
valign='middle',
|
||||||
|
@ -1,24 +1,15 @@
|
|||||||
# flake8: noqa
|
# flake8: noqa
|
||||||
import platform
|
import platform
|
||||||
import contextlib
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import (
|
from typing import Any, Set, Dict, List, Callable
|
||||||
TYPE_CHECKING,
|
|
||||||
Any,
|
|
||||||
Set,
|
|
||||||
List,
|
|
||||||
Union,
|
|
||||||
Callable,
|
|
||||||
Optional,
|
|
||||||
cast,
|
|
||||||
)
|
|
||||||
|
|
||||||
import fastapi_amis_admin
|
from quart import Quart
|
||||||
|
from nonebot import get_bot
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
from sqlmodel import Relationship
|
from sqlmodel import Relationship
|
||||||
from sqlalchemy.orm import backref
|
from sqlalchemy.orm import backref
|
||||||
from fastapi import FastAPI, Request
|
from fastapi import FastAPI, Request
|
||||||
from nonebot import get_app, get_driver
|
import fastapi_amis_admin # noqa: F401
|
||||||
from fastapi_amis_admin import amis, admin
|
from fastapi_amis_admin import amis, admin
|
||||||
from fastapi_amis_admin.crud import BaseApiOut
|
from fastapi_amis_admin.crud import BaseApiOut
|
||||||
from sqlalchemy.ext.asyncio import AsyncEngine
|
from sqlalchemy.ext.asyncio import AsyncEngine
|
||||||
@ -49,8 +40,8 @@ from fastapi_amis_admin.amis.components import (
|
|||||||
|
|
||||||
from ..version import GenshinUID_version
|
from ..version import GenshinUID_version
|
||||||
from ..genshinuid_user.add_ck import _deal_ck
|
from ..genshinuid_user.add_ck import _deal_ck
|
||||||
|
from .login_page import amis_admin, user_auth_admin # noqa
|
||||||
from ..utils.db_operation.database.db_config import DATABASE_URL
|
from ..utils.db_operation.database.db_config import DATABASE_URL
|
||||||
from .login_page import amis_admin, user_auth_admin # noqa # 不要删
|
|
||||||
from ..utils.db_operation.database.models import (
|
from ..utils.db_operation.database.models import (
|
||||||
Config,
|
Config,
|
||||||
UidData,
|
UidData,
|
||||||
@ -59,32 +50,21 @@ from ..utils.db_operation.database.models import (
|
|||||||
NewCookiesTable,
|
NewCookiesTable,
|
||||||
)
|
)
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
|
||||||
from quart import Quart
|
|
||||||
from asgiref.typing import Scope, HTTPScope, WebSocketScope
|
|
||||||
|
|
||||||
AppType = Union[FastAPI, 'Quart']
|
|
||||||
|
|
||||||
|
|
||||||
class FastApiMiddleware:
|
class FastApiMiddleware:
|
||||||
def __init__(
|
def __init__(self, app: Quart, fastapi: FastAPI, routes: Set[str]) -> None:
|
||||||
self, app: 'Quart', fastapi: FastAPI, routes: Set[str]
|
|
||||||
) -> None:
|
|
||||||
self.fastapi = fastapi
|
self.fastapi = fastapi
|
||||||
self.app = app.asgi_app
|
self.app = app.asgi_app
|
||||||
self.routes = routes
|
self.routes = routes
|
||||||
|
|
||||||
async def __call__(
|
async def __call__(
|
||||||
self, scope: 'Scope', receive: Callable, send: Callable
|
self, scope: Dict[str, Any], receive: Callable, send: Callable
|
||||||
) -> None:
|
) -> None:
|
||||||
if scope['type'] in ('http', 'websocket'):
|
if scope['type'] in ('http', 'websocket'):
|
||||||
scope = cast(Union['HTTPScope', 'WebSocketScope'], scope)
|
|
||||||
for path in self.routes:
|
for path in self.routes:
|
||||||
if scope['path'].startswith(path):
|
if scope['path'].startswith(path):
|
||||||
return await self.fastapi(
|
return await self.fastapi(scope, receive, send)
|
||||||
scope, receive, send # type: ignore
|
return await self.app(scope, receive, send)
|
||||||
)
|
|
||||||
return await self.app(scope, receive, send) # type: ignore
|
|
||||||
|
|
||||||
|
|
||||||
# 自定义后台管理站点
|
# 自定义后台管理站点
|
||||||
@ -109,28 +89,8 @@ class GenshinUIDAdminSite(AuthAdminSite):
|
|||||||
return app
|
return app
|
||||||
|
|
||||||
|
|
||||||
def get_asgi() -> Optional[AppType]:
|
# 创建FastAPI应用
|
||||||
try:
|
app = FastAPI()
|
||||||
return get_app()
|
|
||||||
except AssertionError:
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
# 从 nb 获取 FastAPI
|
|
||||||
app = get_asgi()
|
|
||||||
if app is None:
|
|
||||||
raise RuntimeError('App is not ReverseDriver')
|
|
||||||
|
|
||||||
with contextlib.suppress(ImportError):
|
|
||||||
from quart import Quart # noqa: F811
|
|
||||||
|
|
||||||
if isinstance(app, Quart):
|
|
||||||
fastapi = FastAPI()
|
|
||||||
app.asgi_app = FastApiMiddleware(app, fastapi, {'/genshinuid'}) # type: ignore
|
|
||||||
app = fastapi
|
|
||||||
|
|
||||||
|
|
||||||
app = cast(FastAPI, app)
|
|
||||||
settings = Settings(
|
settings = Settings(
|
||||||
database_url_async=DATABASE_URL,
|
database_url_async=DATABASE_URL,
|
||||||
database_url='',
|
database_url='',
|
||||||
@ -139,6 +99,8 @@ settings = Settings(
|
|||||||
site_title='GenshinUID网页控制台',
|
site_title='GenshinUID网页控制台',
|
||||||
language='zh_CN',
|
language='zh_CN',
|
||||||
)
|
)
|
||||||
|
quart = get_bot().server_app
|
||||||
|
quart.asgi_app = FastApiMiddleware(quart, app, {'/genshinuid'}) # type: ignore
|
||||||
|
|
||||||
|
|
||||||
# 显示主键
|
# 显示主键
|
||||||
@ -190,13 +152,16 @@ admin.BaseModelAdmin.get_create_form = patched_get_create_form
|
|||||||
# 创建AdminSite实例
|
# 创建AdminSite实例
|
||||||
site = GenshinUIDAdminSite(settings)
|
site = GenshinUIDAdminSite(settings)
|
||||||
auth = site.auth
|
auth = site.auth
|
||||||
|
config = get_bot().config
|
||||||
|
|
||||||
if float(fastapi_amis_admin.__version__[:3]) >= 0.3:
|
if float(fastapi_amis_admin.__version__[:3]) >= 0.3:
|
||||||
|
|
||||||
class MyUser(User, table=True):
|
class MyUser(User, table=True):
|
||||||
point: float = Field(default=0, title=_('Point')) # type: ignore
|
point: float = Field(default=0, title=_('Point')) # type: ignore
|
||||||
phone: str = Field(None, title=_('Tel'), max_length=15) # type: ignore
|
phone: str = Field(None, title=_('Tel'), max_length=15) # type: ignore
|
||||||
parent_id: int = Field(None, title=_('Parent'), foreign_key='auth_user.id') # type: ignore
|
parent_id: int = Field(
|
||||||
|
None, title=_('Parent'), foreign_key='auth_user.id' # type: ignore
|
||||||
|
)
|
||||||
children: List['User'] = Relationship(
|
children: List['User'] = Relationship(
|
||||||
sa_relationship_kwargs=dict(
|
sa_relationship_kwargs=dict(
|
||||||
backref=backref('parent', remote_side='User.id'),
|
backref=backref('parent', remote_side='User.id'),
|
||||||
@ -205,10 +170,9 @@ if float(fastapi_amis_admin.__version__[:3]) >= 0.3:
|
|||||||
|
|
||||||
auth.user_model = MyUser
|
auth.user_model = MyUser
|
||||||
|
|
||||||
config = get_driver().config
|
|
||||||
app.add_middleware(
|
app.add_middleware(
|
||||||
CORSMiddleware,
|
CORSMiddleware,
|
||||||
allow_origins=[f'http://{config.host}:{config.port}'],
|
allow_origins=[f'http://{config.HOST}:{config.PORT}/genshinuid'],
|
||||||
allow_credentials=True,
|
allow_credentials=True,
|
||||||
allow_methods=['*'],
|
allow_methods=['*'],
|
||||||
allow_headers=['*'],
|
allow_headers=['*'],
|
||||||
@ -216,17 +180,12 @@ app.add_middleware(
|
|||||||
|
|
||||||
gsuid_webconsole_help = '''
|
gsuid_webconsole_help = '''
|
||||||
## 初次使用
|
## 初次使用
|
||||||
|
|
||||||
欢迎进入网页控制台!
|
欢迎进入网页控制台!
|
||||||
|
|
||||||
Admin账户可以通过左侧的选项进入不同的数据库直接修改,**首次登陆的Admin账户别忘了修改你的密码!**
|
Admin账户可以通过左侧的选项进入不同的数据库直接修改,**首次登陆的Admin账户别忘了修改你的密码!**
|
||||||
|
|
||||||
普通账户可以通过左侧的选项进行绑定CK或者SK
|
普通账户可以通过左侧的选项进行绑定CK或者SK
|
||||||
|
|
||||||
未来还会加入更多功能!
|
未来还会加入更多功能!
|
||||||
|
|
||||||
## 丨我该如何获取Cookies?[#92](https://github.com/KimigaiiWuyi/GenshinUID/issues/92)([@RemKeeper](https://github.com/RemKeeper))
|
## 丨我该如何获取Cookies?[#92](https://github.com/KimigaiiWuyi/GenshinUID/issues/92)([@RemKeeper](https://github.com/RemKeeper))
|
||||||
|
|
||||||
```js
|
```js
|
||||||
var cookie = document.cookie;
|
var cookie = document.cookie;
|
||||||
var Str_Num = cookie.indexOf('_MHYUUID=');
|
var Str_Num = cookie.indexOf('_MHYUUID=');
|
||||||
@ -239,16 +198,12 @@ if (ask == true) {
|
|||||||
msg = 'Cancel'
|
msg = 'Cancel'
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
1. 复制上面全部代码,然后打开[米游社BBS](https://bbs.mihoyo.com/ys/)
|
1. 复制上面全部代码,然后打开[米游社BBS](https://bbs.mihoyo.com/ys/)
|
||||||
2. 在页面上右键检查或者Ctrl+Shift+i
|
2. 在页面上右键检查或者Ctrl+Shift+i
|
||||||
3. 选择控制台(Console),粘贴,回车,在弹出的窗口点确认(点完自动复制)
|
3. 选择控制台(Console),粘贴,回车,在弹出的窗口点确认(点完自动复制)
|
||||||
4. 然后在和机器人的私聊窗口,粘贴发送即可
|
4. 然后在和机器人的私聊窗口,粘贴发送即可
|
||||||
|
|
||||||
**警告:Cookies属于个人隐私,其效用相当于账号密码,请勿随意公开!**
|
**警告:Cookies属于个人隐私,其效用相当于账号密码,请勿随意公开!**
|
||||||
|
|
||||||
## 丨获取米游社Stoken([AutoMihoyoBBS](https://github.com/Womsxd/AutoMihoyoBBS#%E8%8E%B7%E5%8F%96%E7%B1%B3%E6%B8%B8%E7%A4%BECookie))
|
## 丨获取米游社Stoken([AutoMihoyoBBS](https://github.com/Womsxd/AutoMihoyoBBS#%E8%8E%B7%E5%8F%96%E7%B1%B3%E6%B8%B8%E7%A4%BECookie))
|
||||||
|
|
||||||
```js
|
```js
|
||||||
var cookie = document.cookie;
|
var cookie = document.cookie;
|
||||||
var ask = confirm('Cookie:' + cookie + '按确认,然后粘贴至Cookies或者Login_ticket选框内');
|
var ask = confirm('Cookie:' + cookie + '按确认,然后粘贴至Cookies或者Login_ticket选框内');
|
||||||
@ -259,12 +214,10 @@ if (ask == true) {
|
|||||||
msg = 'Cancel'
|
msg = 'Cancel'
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
1. 复制上面全部代码,然后打开[米游社账户登录界面](http://user.mihoyo.com/)
|
1. 复制上面全部代码,然后打开[米游社账户登录界面](http://user.mihoyo.com/)
|
||||||
2. 在页面上右键检查或者Ctrl+Shift+i
|
2. 在页面上右键检查或者Ctrl+Shift+i
|
||||||
3. 选择控制台(Console),粘贴,回车,在弹出的窗口点确认(点完自动复制)
|
3. 选择控制台(Console),粘贴,回车,在弹出的窗口点确认(点完自动复制)
|
||||||
4. 然后在和机器人的私聊窗口,粘贴发送即可
|
4. 然后在和机器人的私聊窗口,粘贴发送即可
|
||||||
|
|
||||||
**警告:Cookies属于个人隐私,其效用相当于账号密码,请勿随意公开!**
|
**警告:Cookies属于个人隐私,其效用相当于账号密码,请勿随意公开!**
|
||||||
|
|
||||||
## 获取CK通则
|
## 获取CK通则
|
||||||
|
15
GenshinUID/genshinuid_webconsole/nb2.py
Normal file
15
GenshinUID/genshinuid_webconsole/nb2.py
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
from typing import TypeVar, Callable
|
||||||
|
|
||||||
|
T_Wrapped = TypeVar("T_Wrapped", bound=Callable)
|
||||||
|
|
||||||
|
|
||||||
|
def overrides(InterfaceClass: object) -> Callable[[T_Wrapped], T_Wrapped]:
|
||||||
|
"""标记一个方法为父类 interface 的 implement"""
|
||||||
|
|
||||||
|
def overrider(func: T_Wrapped) -> T_Wrapped:
|
||||||
|
assert func.__name__ in dir(
|
||||||
|
InterfaceClass
|
||||||
|
), f"Error method: {func.__name__}"
|
||||||
|
return func
|
||||||
|
|
||||||
|
return overrider
|
@ -1,18 +1,9 @@
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
from nonebot import on_command
|
from nonebot import MessageSegment
|
||||||
from nonebot.matcher import Matcher
|
from hoshino.typing import CQEvent, HoshinoBot
|
||||||
from nonebot.params import CommandArg
|
|
||||||
from nonebot.adapters.onebot.v11 import (
|
|
||||||
Bot,
|
|
||||||
Message,
|
|
||||||
MessageSegment,
|
|
||||||
GroupMessageEvent,
|
|
||||||
)
|
|
||||||
|
|
||||||
from ..config import priority
|
from ..base import sv
|
||||||
from ..genshinuid_meta import register_menu
|
|
||||||
from ..utils.exception.handle_exception import handle_exception
|
|
||||||
from .get_wiki_text import (
|
from .get_wiki_text import (
|
||||||
char_wiki,
|
char_wiki,
|
||||||
audio_wiki,
|
audio_wiki,
|
||||||
@ -22,251 +13,149 @@ from .get_wiki_text import (
|
|||||||
artifacts_wiki,
|
artifacts_wiki,
|
||||||
)
|
)
|
||||||
|
|
||||||
get_weapon = on_command('武器', priority=priority)
|
|
||||||
get_char = on_command('角色', priority=priority)
|
|
||||||
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_artifacts = on_command('圣遗物', priority=priority)
|
|
||||||
get_food = on_command('食物', priority=priority)
|
|
||||||
|
|
||||||
|
@sv.on_prefix('语音')
|
||||||
|
async def send_audio(bot: HoshinoBot, ev: CQEvent):
|
||||||
|
if ev.message:
|
||||||
|
message = ev.message.extract_plain_text().replace(' ', '')
|
||||||
|
else:
|
||||||
|
return
|
||||||
|
if message == '':
|
||||||
|
return
|
||||||
|
|
||||||
@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))
|
name = ''.join(re.findall('[\u4e00-\u9fa5]', message))
|
||||||
im = await audio_wiki(name, message)
|
im = await audio_wiki(name, message)
|
||||||
if name == '列表':
|
if name == '列表':
|
||||||
await matcher.finish(MessageSegment.image(im))
|
await bot.send(ev, MessageSegment.image(im))
|
||||||
else:
|
else:
|
||||||
if isinstance(im, str):
|
if isinstance(im, str):
|
||||||
await matcher.finish(im)
|
await bot.send(ev, im)
|
||||||
else:
|
else:
|
||||||
await matcher.finish(MessageSegment.record(im))
|
await bot.send(ev, MessageSegment.record(im))
|
||||||
|
|
||||||
|
|
||||||
@get_enemies.handle()
|
@sv.on_prefix('原魔')
|
||||||
@handle_exception('怪物')
|
async def send_enemies(bot: HoshinoBot, ev: CQEvent):
|
||||||
@register_menu(
|
if ev.message:
|
||||||
'怪物图鉴',
|
message = ev.message.extract_plain_text().replace(' ', '')
|
||||||
'怪物xx',
|
else:
|
||||||
'获取怪物Wiki',
|
return
|
||||||
detail_des=(
|
if message == '':
|
||||||
'介绍:\n'
|
return
|
||||||
'获取怪物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)
|
im = await enemies_wiki(message)
|
||||||
await matcher.finish(im)
|
await bot.send(ev, im)
|
||||||
|
|
||||||
|
|
||||||
@get_food.handle()
|
@sv.on_prefix('食物')
|
||||||
@handle_exception('食物')
|
async def send_food(bot: HoshinoBot, ev: CQEvent):
|
||||||
@register_menu(
|
if ev.message:
|
||||||
'食物图鉴',
|
message = ev.message.extract_plain_text().replace(' ', '')
|
||||||
'食物xx',
|
else:
|
||||||
'获取食物Wiki',
|
return
|
||||||
detail_des=(
|
if message == '':
|
||||||
'介绍:\n'
|
return
|
||||||
'获取食物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)
|
im = await foods_wiki(message)
|
||||||
await matcher.finish(im)
|
await bot.send(ev, im)
|
||||||
|
|
||||||
|
|
||||||
@get_artifacts.handle()
|
@sv.on_prefix('圣遗物')
|
||||||
@handle_exception('圣遗物')
|
async def send_artifacts(bot: HoshinoBot, ev: CQEvent):
|
||||||
@register_menu(
|
if ev.message:
|
||||||
'圣遗物图鉴',
|
message = ev.message.extract_plain_text().replace(' ', '')
|
||||||
'圣遗物xx',
|
else:
|
||||||
'获取怪物Wiki',
|
return
|
||||||
detail_des=(
|
if message == '':
|
||||||
'介绍:\n'
|
return
|
||||||
'获取圣遗物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)
|
im = await artifacts_wiki(message)
|
||||||
await matcher.finish(im)
|
await bot.send(ev, im)
|
||||||
|
|
||||||
|
|
||||||
@get_weapon.handle()
|
@sv.on_prefix('武器')
|
||||||
@handle_exception('武器')
|
async def send_weapon(bot: HoshinoBot, ev: CQEvent):
|
||||||
@register_menu(
|
if ev.message:
|
||||||
'武器图鉴',
|
message = ev.message.extract_plain_text().replace(' ', '')
|
||||||
'武器xx',
|
else:
|
||||||
'获取武器Wiki',
|
return
|
||||||
detail_des=(
|
if message == '':
|
||||||
'介绍:\n'
|
return
|
||||||
'获取武器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))
|
name = ''.join(re.findall('[\u4e00-\u9fa5]', message))
|
||||||
level = re.findall(r'\d+', message)
|
level = re.findall(r'\d+', message)
|
||||||
if len(level) == 1:
|
if len(level) == 1:
|
||||||
im = await weapon_wiki(name, level=level[0])
|
im = await weapon_wiki(name, level=level[0])
|
||||||
else:
|
else:
|
||||||
im = await weapon_wiki(name)
|
im = await weapon_wiki(name)
|
||||||
await matcher.finish(im)
|
await bot.send(ev, im)
|
||||||
|
|
||||||
|
|
||||||
@get_talents.handle()
|
@sv.on_prefix('天赋')
|
||||||
@handle_exception('天赋')
|
async def send_talents(bot: HoshinoBot, ev: CQEvent):
|
||||||
@register_menu(
|
if ev.message:
|
||||||
'天赋效果',
|
message = ev.message.extract_plain_text().replace(' ', '')
|
||||||
'天赋[角色][天赋序号]',
|
else:
|
||||||
'查询角色天赋技能效果',
|
return
|
||||||
detail_des=(
|
if message == '':
|
||||||
'介绍:\n'
|
return
|
||||||
'查询角色天赋技能效果\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: GroupMessageEvent,
|
|
||||||
matcher: Matcher,
|
|
||||||
args: Message = CommandArg(),
|
|
||||||
):
|
|
||||||
message = args.extract_plain_text().strip().replace(' ', '')
|
|
||||||
name = ''.join(re.findall('[\u4e00-\u9fa5]', message))
|
name = ''.join(re.findall('[\u4e00-\u9fa5]', message))
|
||||||
num = re.findall(r'\d+', message)
|
num = re.findall(r'\d+', message)
|
||||||
if len(num) == 1:
|
if len(num) == 1:
|
||||||
im = await char_wiki(name, 'talents', num[0])
|
im = await char_wiki(name, 'talents', num[0])
|
||||||
if isinstance(im, list):
|
if isinstance(im, list):
|
||||||
await bot.call_api(
|
await bot.send_group_forward_msg(group_id=ev.group_id, messages=im)
|
||||||
'send_group_forward_msg', group_id=event.group_id, messages=im
|
|
||||||
)
|
|
||||||
await matcher.finish()
|
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
im = '参数不正确。'
|
im = '参数不正确。'
|
||||||
await matcher.finish(im)
|
await bot.send(ev, im)
|
||||||
|
|
||||||
|
|
||||||
@get_char.handle()
|
@sv.on_prefix('角色')
|
||||||
@handle_exception('角色')
|
async def send_char(bot: HoshinoBot, ev: CQEvent):
|
||||||
@register_menu(
|
if ev.message:
|
||||||
'角色图鉴',
|
message = ev.message.extract_plain_text().replace(' ', '')
|
||||||
'角色xx',
|
else:
|
||||||
'获取角色Wiki',
|
return
|
||||||
detail_des=(
|
if message == '':
|
||||||
'介绍:\n'
|
return
|
||||||
'获取角色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))
|
name = ''.join(re.findall('[\u4e00-\u9fa5]', message))
|
||||||
level = re.findall(r'\d+', message)
|
level = re.findall(r'\d+', message)
|
||||||
if len(level) == 1:
|
if len(level) == 1:
|
||||||
im = await char_wiki(name, 'char', level=level[0])
|
im = await char_wiki(name, 'char', level=level[0])
|
||||||
else:
|
else:
|
||||||
im = await char_wiki(name)
|
im = await char_wiki(name)
|
||||||
await matcher.finish(im)
|
await bot.send(ev, im)
|
||||||
|
|
||||||
|
|
||||||
@get_cost.handle()
|
@sv.on_prefix('材料')
|
||||||
@handle_exception('材料')
|
async def send_cost(bot: HoshinoBot, ev: CQEvent):
|
||||||
@register_menu(
|
if ev.message:
|
||||||
'材料图鉴',
|
message = ev.message.extract_plain_text().replace(' ', '')
|
||||||
'材料xx',
|
else:
|
||||||
'获取材料Wiki',
|
return
|
||||||
detail_des=(
|
if message == '':
|
||||||
'介绍:\n'
|
return
|
||||||
'获取材料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')
|
im = await char_wiki(message, 'costs')
|
||||||
await matcher.finish(im)
|
await bot.send(ev, im)
|
||||||
|
|
||||||
|
|
||||||
@get_polar.handle()
|
@sv.on_prefix('命座')
|
||||||
@handle_exception('命座')
|
async def send_polar(bot: HoshinoBot, ev: CQEvent):
|
||||||
@register_menu(
|
if ev.message:
|
||||||
'角色命座图鉴',
|
message = ev.message.extract_plain_text().replace(' ', '')
|
||||||
'命座[角色][等级]',
|
else:
|
||||||
'获取角色命座Wiki',
|
return
|
||||||
detail_des=(
|
if message == '':
|
||||||
'介绍:\n'
|
return
|
||||||
'获取角色命座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
|
num = int(re.findall(r'\d+', message)[0]) # str
|
||||||
m = ''.join(re.findall('[\u4e00-\u9fa5]', message))
|
m = ''.join(re.findall('[\u4e00-\u9fa5]', message))
|
||||||
if num <= 0 or num > 6:
|
if num <= 0 or num > 6:
|
||||||
await get_polar.finish('你家{}有{}命?'.format(m, num))
|
await bot.send(ev, '你家{}有{}命?'.format(m, num))
|
||||||
return
|
return
|
||||||
im = await char_wiki(m, 'constellations', num)
|
im = await char_wiki(m, 'constellations', num)
|
||||||
await matcher.finish(im)
|
await bot.send(ev, im)
|
||||||
|
@ -2,34 +2,22 @@ import random
|
|||||||
import asyncio
|
import asyncio
|
||||||
import threading
|
import threading
|
||||||
|
|
||||||
from nonebot import on_command
|
from ..base import sv, logger
|
||||||
from nonebot.log import logger
|
|
||||||
from nonebot.matcher import Matcher
|
|
||||||
from nonebot_plugin_apscheduler import scheduler
|
|
||||||
from nonebot.adapters.onebot.v11 import MessageSegment
|
|
||||||
|
|
||||||
from .draw_abyss_total import TOTAL_IMG, draw_xk_abyss_img
|
from .draw_abyss_total import TOTAL_IMG, draw_xk_abyss_img
|
||||||
from ..utils.exception.handle_exception import handle_exception
|
from ..utils.draw_image_tools.send_image_tool import convert_img
|
||||||
|
|
||||||
draw_total_scheduler = scheduler
|
|
||||||
get_abyss_total = on_command('深渊概览', aliases={'深渊统计', '深渊使用率'})
|
|
||||||
|
|
||||||
|
|
||||||
@draw_total_scheduler.scheduled_job('interval', hours=3)
|
@sv.scheduled_job('interval', hours=3)
|
||||||
async def scheduled_draw_abyss():
|
async def scheduled_draw_abyss():
|
||||||
await asyncio.sleep(random.randint(0, 60))
|
await asyncio.sleep(random.randint(0, 60))
|
||||||
await draw_xk_abyss_img()
|
await draw_xk_abyss_img()
|
||||||
|
|
||||||
|
|
||||||
@get_abyss_total.handle()
|
@sv.on_fullmatch(('深渊概览', '深渊统计', '深渊使用率'))
|
||||||
@handle_exception('深渊概览')
|
async def send_abyss_pic(bot, ev):
|
||||||
async def send_guide_pic(matcher: Matcher):
|
img = await convert_img(TOTAL_IMG)
|
||||||
if TOTAL_IMG.exists():
|
logger.info('获得gs帮助图片成功!')
|
||||||
logger.info('获得深渊概览成功!')
|
await bot.send(ev, img)
|
||||||
with open(TOTAL_IMG, 'rb') as f:
|
|
||||||
await matcher.finish(MessageSegment.image(f.read()))
|
|
||||||
else:
|
|
||||||
await matcher.finish('深渊概览图不存在!')
|
|
||||||
|
|
||||||
|
|
||||||
threading.Thread(
|
threading.Thread(
|
||||||
|
@ -27,9 +27,7 @@ async def check_db():
|
|||||||
try:
|
try:
|
||||||
if int(str(row[0])[0]) < 6:
|
if int(str(row[0])[0]) < 6:
|
||||||
aid = re.search(r'account_id=(\d*)', row[1])
|
aid = re.search(r'account_id=(\d*)', row[1])
|
||||||
if not aid:
|
mihoyo_id_data = aid.group(0).split('=') # type: ignore
|
||||||
raise Exception('cannot match account_id')
|
|
||||||
mihoyo_id_data = aid.group(0).split('=')
|
|
||||||
mihoyo_id = mihoyo_id_data[1]
|
mihoyo_id = mihoyo_id_data[1]
|
||||||
mys_data = await get_mihoyo_bbs_info(mihoyo_id, row[1])
|
mys_data = await get_mihoyo_bbs_info(mihoyo_id, row[1])
|
||||||
for i in mys_data['data']['list']:
|
for i in mys_data['data']['list']:
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
import sys
|
import sys
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
MAIN_PATH = Path() / 'data' / 'GenshinUID'
|
import hoshino
|
||||||
|
|
||||||
|
MAIN_PATH = Path(hoshino.config.RES_DIR) / 'GenshinUID'
|
||||||
sys.path.append(str(MAIN_PATH))
|
sys.path.append(str(MAIN_PATH))
|
||||||
CONFIG_PATH = MAIN_PATH / 'config.json'
|
CONFIG_PATH = MAIN_PATH / 'config.json'
|
||||||
RESOURCE_PATH = MAIN_PATH / 'resource'
|
RESOURCE_PATH = MAIN_PATH / 'resource'
|
||||||
|
@ -1,63 +1,53 @@
|
|||||||
from functools import wraps
|
# flake8: noqa
|
||||||
from typing import Optional
|
# from nonebot.log import logger
|
||||||
|
# from aiocqhttp.exceptions import ActionFailed
|
||||||
|
# from hoshino.typing import List, CQEvent, Iterable
|
||||||
|
|
||||||
from nonebot.log import logger
|
# FIXME: - 在 Hoshino 中可用
|
||||||
from nonebot.matcher import Matcher
|
# def handle_exception(name: str, log_msg: str = None, fail_msg: str = None): # type: ignore
|
||||||
from nonebot.exception import FinishedException
|
# """
|
||||||
from nonebot.adapters.onebot.v11 import ActionFailed
|
# :说明:
|
||||||
|
# 捕获命令执行过程中发生的异常并回报。
|
||||||
|
# :参数:
|
||||||
|
# * ``name: str``: 项目的名称。
|
||||||
|
# * ``log_msg: str = None``: 自定义捕获异常后在日志中留存的信息。留空则使用默认信息。
|
||||||
|
# * ``fail_msg: str = None``: 自定义捕获异常后向用户回报的信息,仅在提供自定义日志信息时有效。开头带@则艾特用户。留空则与日志信息相同。
|
||||||
|
# """
|
||||||
|
|
||||||
|
# def wrapper(func):
|
||||||
|
# @wraps(func)
|
||||||
|
# async def inner(
|
||||||
|
# log_msg: str = log_msg, fail_msg: str = fail_msg, **kwargs
|
||||||
|
# ):
|
||||||
|
# print(kwargs)
|
||||||
|
# matcher: CQEvent = kwargs['matcher']
|
||||||
|
# try:
|
||||||
|
# await func(**kwargs)
|
||||||
|
# except ActionFailed as e:
|
||||||
|
# # 此为bot本身由于风控或网络问题发不出消息,并非代码本身出问题
|
||||||
|
# await matcher.send(f'发送消息失败{e.result["wording"]}')
|
||||||
|
# logger.exception(f'发送{name}消息失败')
|
||||||
|
# except Exception as e:
|
||||||
|
# # 如果e内包含敏感信息,应在此处进行处理
|
||||||
|
# if 'SQL' in str(e):
|
||||||
|
# e = '数据库操作失败!可能正在[校验全部Cookies]\n敏感信息已抹去...请等待一段时间后重试!'
|
||||||
|
# # 代码本身出问题
|
||||||
|
# if log_msg:
|
||||||
|
# if not fail_msg:
|
||||||
|
# fail_msg = log_msg
|
||||||
|
# if fail_msg[0] == '@':
|
||||||
|
# await matcher.send(
|
||||||
|
# f'{fail_msg[1:]}\n错误信息为{e}', at_sender=True
|
||||||
|
# )
|
||||||
|
# else:
|
||||||
|
# await matcher.send(f'{fail_msg}\n错误信息为{e}')
|
||||||
|
# if log_msg[0] == '@':
|
||||||
|
# log_msg = log_msg[1:]
|
||||||
|
# logger.exception(log_msg)
|
||||||
|
# else:
|
||||||
|
# await matcher.send(f'发生错误 {e},请检查后台输出。')
|
||||||
|
# logger.exception(f'获取{name}信息错误')
|
||||||
|
|
||||||
def handle_exception(
|
# return inner
|
||||||
name: str, log_msg: Optional[str] = None, fail_msg: Optional[str] = None
|
|
||||||
):
|
|
||||||
"""
|
|
||||||
:说明:
|
|
||||||
捕获命令执行过程中发生的异常并回报。
|
|
||||||
:参数:
|
|
||||||
* ``name: str``: 项目的名称。
|
|
||||||
* ``log_msg: str = None``: 自定义捕获异常后在日志中留存的信息。留空则使用默认信息。
|
|
||||||
* ``fail_msg: str = None``: 自定义捕获异常后向用户回报的信息,仅在提供自定义日志信息时有效。
|
|
||||||
开头带@则艾特用户。留空则与日志信息相同。
|
|
||||||
"""
|
|
||||||
|
|
||||||
def wrapper(func):
|
# return wrapper
|
||||||
@wraps(func)
|
|
||||||
async def inner(
|
|
||||||
log_msg: Optional[str] = log_msg,
|
|
||||||
fail_msg: Optional[str] = fail_msg,
|
|
||||||
**kwargs,
|
|
||||||
):
|
|
||||||
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
|
|
||||||
except Exception as e:
|
|
||||||
# 如果e内包含敏感信息,应在此处进行处理
|
|
||||||
if 'SQL' in str(e):
|
|
||||||
e = '数据库操作失败!可能正在[校验全部Cookies]\n敏感信息已抹去...请等待一段时间后重试!'
|
|
||||||
# 代码本身出问题
|
|
||||||
if log_msg:
|
|
||||||
if not fail_msg:
|
|
||||||
fail_msg = log_msg
|
|
||||||
if fail_msg[0] == '@':
|
|
||||||
await matcher.send(
|
|
||||||
f'{fail_msg[1:]}\n错误信息为{e}', at_sender=True
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
await matcher.send(f'{fail_msg}\n错误信息为{e}')
|
|
||||||
if log_msg[0] == '@':
|
|
||||||
log_msg = log_msg[1:]
|
|
||||||
logger.exception(log_msg)
|
|
||||||
else:
|
|
||||||
await matcher.send(f'发生错误 {e},请检查后台输出。')
|
|
||||||
logger.exception(f'获取{name}信息错误')
|
|
||||||
|
|
||||||
return inner
|
|
||||||
|
|
||||||
return wrapper
|
|
||||||
|
@ -1,20 +1,18 @@
|
|||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
from nonebot.adapters.onebot.v11 import Bot
|
|
||||||
|
|
||||||
|
async def get_all_friend_list(bot) -> List[int]:
|
||||||
async def get_all_friend_list(bot: Bot) -> List[int]:
|
|
||||||
friend_list = []
|
friend_list = []
|
||||||
friend_dict_list = await bot.call_api('get_friend_list')
|
friend_dict_list = await bot.call_action(action='get_friend_list')
|
||||||
for friend in friend_dict_list:
|
for friend in friend_dict_list:
|
||||||
friend_list.append(friend['user_id'])
|
friend_list.append(friend['user_id'])
|
||||||
return friend_list
|
return friend_list
|
||||||
|
|
||||||
|
|
||||||
async def get_group_member_list(bot: Bot, group_id: int) -> List[int]:
|
async def get_group_member_list(bot, group_id: int) -> List[int]:
|
||||||
member_list = []
|
member_list = []
|
||||||
group_member_list = await bot.call_api(
|
group_member_list = await bot.call_api(
|
||||||
'get_group_member_list', group_id=group_id
|
action='get_group_member_list', group_id=group_id
|
||||||
)
|
)
|
||||||
for group_member in group_member_list:
|
for group_member in group_member_list:
|
||||||
member_list.append(group_member['user_id'])
|
member_list.append(group_member['user_id'])
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
from typing import Union
|
from typing import Union
|
||||||
|
|
||||||
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
|
# https://v2.nonebot.dev/docs/advanced/di/dependency-injection#class-%E4%BD%9C%E4%B8%BA%E4%BE%9D%E8%B5%96
|
||||||
class ImageAndAt:
|
class ImageAndAt:
|
||||||
def __init__(self, event: MessageEvent):
|
def __init__(self, event):
|
||||||
self.images = []
|
self.images = []
|
||||||
self.at = []
|
self.at = []
|
||||||
for i in event.message:
|
for i in event.message:
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
from nonebot.adapters.onebot.v11 import Bot
|
from ...base import hoshino_bot
|
||||||
|
|
||||||
|
|
||||||
# 发送聊天记录
|
# 发送聊天记录
|
||||||
async def send_forward_msg(
|
async def send_forward_msg(
|
||||||
bot: Bot,
|
bot: hoshino_bot,
|
||||||
groupid: int,
|
group_id: int,
|
||||||
name: str,
|
name: str,
|
||||||
uin: str,
|
uin: str,
|
||||||
msgs: List[str],
|
msgs: List[str],
|
||||||
@ -18,6 +18,6 @@ async def send_forward_msg(
|
|||||||
}
|
}
|
||||||
|
|
||||||
messages = [to_json(msg) for msg in msgs]
|
messages = [to_json(msg) for msg in msgs]
|
||||||
await bot.call_api(
|
await bot.call_action(
|
||||||
"send_group_forward_msg", group_id=groupid, messages=messages
|
action='send_group_forward_msg', group_id=group_id, messages=messages
|
||||||
)
|
)
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
from nonebot.rule import Rule
|
|
||||||
from nonebot.params import Depends, CommandArg
|
|
||||||
from nonebot.adapters.onebot.v11 import Message
|
|
||||||
|
|
||||||
|
|
||||||
async def full_command(arg: Message = CommandArg()) -> bool:
|
|
||||||
return not bool(str(arg))
|
|
||||||
|
|
||||||
|
|
||||||
def FullCommand() -> Rule:
|
|
||||||
return Rule(full_command)
|
|
||||||
|
|
||||||
|
|
||||||
def FullCommandDepend():
|
|
||||||
return Depends(full_command)
|
|
@ -1,15 +0,0 @@
|
|||||||
from typing import List
|
|
||||||
|
|
||||||
from nonebot import get_driver
|
|
||||||
|
|
||||||
|
|
||||||
def get_superusers() -> List[int]:
|
|
||||||
config = get_driver().config
|
|
||||||
superusers: List[int] = []
|
|
||||||
for su in config.superusers:
|
|
||||||
if "onebot:" in su:
|
|
||||||
# su[7:] == onebot:
|
|
||||||
su = su[7:]
|
|
||||||
if su.isdigit():
|
|
||||||
superusers.append(int(su))
|
|
||||||
return superusers
|
|
12
__init__.py
12
__init__.py
@ -3,11 +3,11 @@ import shutil
|
|||||||
from typing import List
|
from typing import List
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
import hoshino
|
||||||
from nonebot.log import logger
|
from nonebot.log import logger
|
||||||
from nonebot import require, load_plugins
|
from nonebot import load_plugins
|
||||||
|
|
||||||
dir_ = Path(__file__).parent
|
dir_ = Path(__file__).parent
|
||||||
require('nonebot_plugin_apscheduler')
|
|
||||||
|
|
||||||
|
|
||||||
def copy_and_delete_files():
|
def copy_and_delete_files():
|
||||||
@ -27,7 +27,7 @@ def copy_and_delete_files():
|
|||||||
elif path.name in {"resource", "player"}:
|
elif path.name in {"resource", "player"}:
|
||||||
dst = Path().joinpath(
|
dst = Path().joinpath(
|
||||||
(
|
(
|
||||||
"data/GenshinUID/"
|
hoshino.config.RES_DIR + "/GenshinUID/"
|
||||||
f"{'players' if path.name == 'player' else path.name}"
|
f"{'players' if path.name == 'player' else path.name}"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -37,7 +37,7 @@ def copy_and_delete_files():
|
|||||||
dst,
|
dst,
|
||||||
dirs_exist_ok=True,
|
dirs_exist_ok=True,
|
||||||
)
|
)
|
||||||
logger.success(f"复制文件夹 {path} -> {dst} 成功")
|
logger.info(f"复制文件夹 {path} -> {dst} 成功")
|
||||||
except shutil.Error as e:
|
except shutil.Error as e:
|
||||||
failed_src: List[Path] = []
|
failed_src: List[Path] = []
|
||||||
exc: str
|
exc: str
|
||||||
@ -56,10 +56,10 @@ def copy_and_delete_files():
|
|||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
shutil.rmtree(path)
|
shutil.rmtree(path)
|
||||||
logger.success(f"删除文件夹 {path} 成功")
|
logger.info(f"删除文件夹 {path} 成功")
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
logger.warning(f"删除文件夹 {path} 失败:{e.strerror}")
|
logger.warning(f"删除文件夹 {path} 失败:{e.strerror}")
|
||||||
|
|
||||||
|
|
||||||
copy_and_delete_files()
|
copy_and_delete_files()
|
||||||
load_plugins(str(dir_ / "GenshinUID"))
|
load_plugins(str(dir_ / 'GenshinUID'), 'hoshino.modules.GenshinUID.GenshinUID')
|
||||||
|
@ -1,14 +0,0 @@
|
|||||||
# 配置 NoneBot2 监听的 IP/主机名(不建议修改)
|
|
||||||
HOST=0.0.0.0
|
|
||||||
# 配置 NoneBot2 监听的端口(不建议修改)
|
|
||||||
PORT=8080
|
|
||||||
# 配置 NoneBot 超级用户(例如你的QQ号)
|
|
||||||
SUPERUSERS=["123456789"]
|
|
||||||
# 配置命令起始字符
|
|
||||||
COMMAND_START=["/", ""]
|
|
||||||
|
|
||||||
# 建议别删下面这行
|
|
||||||
FASTAPI_RELOAD=false
|
|
||||||
# 建议别删上面这行
|
|
||||||
|
|
||||||
更多配置参见:https://v2.nonebot.dev/docs/tutorial/configuration
|
|
@ -1,14 +0,0 @@
|
|||||||
default_context:
|
|
||||||
py: py
|
|
||||||
project_name: nb2
|
|
||||||
use_src: true
|
|
||||||
adapters:
|
|
||||||
- builtin:
|
|
||||||
- module_name: "nonebot.adapters.onebot.v11"
|
|
||||||
project_link: "nonebot-adapter-onebot"
|
|
||||||
name: "OneBot V11"
|
|
||||||
desc: "OneBot V11 协议"
|
|
||||||
author: "yanyongyu"
|
|
||||||
homepage: "https://onebot.adapters.nonebot.dev/"
|
|
||||||
tags: []
|
|
||||||
is_official: true
|
|
@ -1,21 +0,0 @@
|
|||||||
from typing import List
|
|
||||||
|
|
||||||
import tomlkit
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
with open("./nb2/pyproject.toml", "r", encoding="utf-8") as f:
|
|
||||||
data = tomlkit.load(f)
|
|
||||||
plugins: List[str] = data["tool"]["nonebot"]["plugins"] # type: ignore
|
|
||||||
if "GenshinUID" in plugins:
|
|
||||||
return
|
|
||||||
plugins.append("GenshinUID")
|
|
||||||
|
|
||||||
with open("./nb2/pyproject.toml", "w", encoding="utf-8") as f:
|
|
||||||
tomlkit.dump(data, f)
|
|
||||||
|
|
||||||
print("Update pyproject.toml done.")
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
1816
poetry.lock
generated
1816
poetry.lock
generated
File diff suppressed because it is too large
Load Diff
@ -1,3 +1,34 @@
|
|||||||
|
[tool.poetry]
|
||||||
|
name = "GenshinUID"
|
||||||
|
version = "0.1.0"
|
||||||
|
description = "基于HoshinoBot/NoneBot2/QQ官方频道Bot(PythonSDK)的原神Uid查询/原神Wiki/米社签到/树脂提醒插件"
|
||||||
|
authors = ["KimigaiiWuyi <444835641@qq.com>"]
|
||||||
|
license = "GPL-3.0-or-later"
|
||||||
|
|
||||||
|
[tool.poetry.dependencies]
|
||||||
|
python = "^3.8"
|
||||||
|
httpx = "^0.23.0"
|
||||||
|
beautifulsoup4 = "^4.11.1"
|
||||||
|
lxml = "^4.9.1"
|
||||||
|
openpyxl = "^3.0.10"
|
||||||
|
aiohttp = "^3.8.1"
|
||||||
|
SQLAlchemy = "^1.4.39"
|
||||||
|
Pillow = "^9.2.0"
|
||||||
|
aiosqlite = "^0.17.0"
|
||||||
|
sqlmodel = "^0.0.8"
|
||||||
|
GitPython = "^3.1.27"
|
||||||
|
fastapi_amis_admin = "^0.2.1"
|
||||||
|
fastapi_user_auth = "^0.2.1"
|
||||||
|
pydantic = "^1.10.2"
|
||||||
|
aiofiles = "^22.1.0"
|
||||||
|
qrcode = {extras = ["pil"], version = "^7.3.1"}
|
||||||
|
|
||||||
|
[tool.poetry.dev-dependencies]
|
||||||
|
flake8 = "^4.0.1"
|
||||||
|
black = "^22.6.0"
|
||||||
|
isort = "^5.11.5"
|
||||||
|
pre-commit = "^2.20.0"
|
||||||
|
|
||||||
[tool.black]
|
[tool.black]
|
||||||
line-length = 79
|
line-length = 79
|
||||||
target-version = ["py38", "py39", "py310"]
|
target-version = ["py38", "py39", "py310"]
|
||||||
@ -14,65 +45,10 @@ skip_gitignore = true
|
|||||||
force_sort_within_sections = true
|
force_sort_within_sections = true
|
||||||
extra_standard_library = ["typing_extensions"]
|
extra_standard_library = ["typing_extensions"]
|
||||||
|
|
||||||
[tool.pytest.ini_options]
|
|
||||||
asyncio_mode = "auto"
|
|
||||||
|
|
||||||
[build-system]
|
[build-system]
|
||||||
requires = ["poetry-core>=1.2.0"]
|
requires = ["poetry-core>=1.0.0"]
|
||||||
build-backend = "poetry.core.masonry.api"
|
build-backend = "poetry.core.masonry.api"
|
||||||
|
|
||||||
[tool.poetry]
|
|
||||||
name = "GenshinUID"
|
|
||||||
version = "3.1.0"
|
|
||||||
description = "基于HoshinoBot/NoneBot2/QQ官方频道/微信Bot的原神面板查询/原神Wiki/米社签到/树脂提醒插件"
|
|
||||||
authors = ["KimigaiiWuyi <444835641@qq.com>"]
|
|
||||||
license = "GPL-3.0-or-later"
|
|
||||||
readme = "README.md"
|
|
||||||
homepage = "https://github.com/KimigaiiWuyi/GenshinUID/tree/nonebot2-beta1"
|
|
||||||
repository = "https://github.com/KimigaiiWuyi/GenshinUID"
|
|
||||||
documentation = "https://github.com/KimigaiiWuyi/GenshinUID/wiki"
|
|
||||||
packages = [
|
|
||||||
{ include = "GenshinUID" }
|
|
||||||
]
|
|
||||||
exclude = ["tests", "deploy"]
|
|
||||||
|
|
||||||
[tool.poetry.urls]
|
|
||||||
"Bug Tracker" = "https://github.com/KimigaiiWuyi/GenshinUID/issues"
|
|
||||||
|
|
||||||
[tool.poetry.dependencies]
|
|
||||||
python = "^3.8.1"
|
|
||||||
nonebot2 = ">=2.0.0b4"
|
|
||||||
nonebot-adapter-onebot = ">=2.1.1"
|
|
||||||
httpx = ">=0.23.0"
|
|
||||||
beautifulsoup4 = ">=4.11.1"
|
|
||||||
lxml = ">=4.9.2"
|
|
||||||
openpyxl = ">=3.0.10"
|
|
||||||
aiohttp = ">=3.8.1"
|
|
||||||
sqlalchemy = ">=1.4.39"
|
|
||||||
pillow = ">=9.2.0"
|
|
||||||
aiosqlite = ">=0.17.0"
|
|
||||||
nonebot-plugin-apscheduler = ">=0.1.4"
|
|
||||||
aiofiles = ">=0.8.0"
|
|
||||||
sqlmodel = ">=0.0.8"
|
|
||||||
gitpython = ">=3.1.27"
|
|
||||||
fastapi-amis-admin = ">=0.2.1"
|
|
||||||
fastapi-user-auth = ">=0.2.1"
|
|
||||||
qrcode = {extras = ["pil"], version = "^7.3.1"}
|
|
||||||
|
|
||||||
[[tool.poetry.source]]
|
[[tool.poetry.source]]
|
||||||
name = "USTC"
|
name = 'aliyun.mirrors'
|
||||||
url = "https://pypi.mirrors.ustc.edu.cn/simple"
|
url = "http://mirrors.aliyun.com/pypi/simple/"
|
||||||
default = false
|
|
||||||
secondary = true
|
|
||||||
|
|
||||||
[tool.poetry.group.dev.dependencies]
|
|
||||||
flake8 = "^6.0.0"
|
|
||||||
black = "^22.12.0"
|
|
||||||
isort = "^5.11.5"
|
|
||||||
pre-commit = "^2.21.0"
|
|
||||||
pycln = "^2.1.2"
|
|
||||||
|
|
||||||
[tool.poetry.group.test.dependencies]
|
|
||||||
nonebug = "^0.3.0"
|
|
||||||
pytest = "^7.2.0"
|
|
||||||
pytest-asyncio = "^0.20.3"
|
|
115
requirements.txt
115
requirements.txt
@ -1,65 +1,50 @@
|
|||||||
aiofiles==23.1.0 ; python_full_version >= "3.8.1" and python_version < "4.0"
|
--trusted-host mirrors.aliyun.com
|
||||||
aiohttp==3.8.4 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
--extra-index-url http://mirrors.aliyun.com/pypi/simple
|
||||||
aiosignal==1.3.1 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
|
||||||
aiosqlite==0.18.0 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
aiofiles==22.1.0 ; python_version >= "3.8" and python_version < "4.0"
|
||||||
anyio==3.6.2 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
aiohttp==3.8.3 ; python_version >= "3.8" and python_version < "4.0"
|
||||||
apscheduler==3.10.1 ; python_full_version >= "3.8.1" and python_version < "4.0"
|
aiosignal==1.3.1 ; python_version >= "3.8" and python_version < "4.0"
|
||||||
async-timeout==4.0.2 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
aiosqlite==0.17.0 ; python_version >= "3.8" and python_version < "4.0"
|
||||||
attrs==22.2.0 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
anyio==3.6.2 ; python_version >= "3.8" and python_version < "4.0"
|
||||||
backports-zoneinfo==0.2.1 ; python_full_version >= "3.8.1" and python_version < "3.9"
|
async-timeout==4.0.2 ; python_version >= "3.8" and python_version < "4.0"
|
||||||
bcrypt==4.0.1 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
attrs==22.2.0 ; python_version >= "3.8" and python_version < "4.0"
|
||||||
beautifulsoup4==4.11.2 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
bcrypt==4.0.1 ; python_version >= "3.8" and python_version < "4.0"
|
||||||
certifi==2022.12.7 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
beautifulsoup4==4.11.1 ; python_version >= "3.8" and python_version < "4.0"
|
||||||
charset-normalizer==3.1.0 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
certifi==2022.12.7 ; python_version >= "3.8" and python_version < "4.0"
|
||||||
colorama==0.4.6 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0" and platform_system == "Windows" or python_full_version >= "3.8.1" and python_version < "4.0" and sys_platform == "win32"
|
charset-normalizer==2.1.1 ; python_version >= "3.8" and python_version < "4.0"
|
||||||
dnspython==2.3.0 ; python_full_version >= "3.8.1" and python_version < "4.0"
|
colorama==0.4.6 ; python_version >= "3.8" and python_version < "4.0" and platform_system == "Windows"
|
||||||
email-validator==1.3.1 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
dnspython==2.2.1 ; python_version >= "3.8" and python_version < "4.0"
|
||||||
et-xmlfile==1.1.0 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
email-validator==1.3.0 ; python_version >= "3.8" and python_version < "4.0"
|
||||||
fastapi-amis-admin==0.5.0 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
et-xmlfile==1.1.0 ; python_version >= "3.8" and python_version < "4.0"
|
||||||
fastapi-user-auth==0.5.0 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
fastapi-amis-admin==0.2.5 ; python_version >= "3.8" and python_version < "4.0"
|
||||||
fastapi==0.93.0 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
fastapi-user-auth==0.2.4 ; python_version >= "3.8" and python_version < "4.0"
|
||||||
frozenlist==1.3.3 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
fastapi==0.88.0 ; python_version >= "3.8" and python_version < "4.0"
|
||||||
gitdb==4.0.10 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
frozenlist==1.3.3 ; python_version >= "3.8" and python_version < "4.0"
|
||||||
gitpython==3.1.31 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
gitdb==4.0.10 ; python_version >= "3.8" and python_version < "4.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"
|
gitpython==3.1.30 ; python_version >= "3.8" and python_version < "4.0"
|
||||||
h11==0.14.0 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
greenlet==2.0.1 ; python_version >= "3.8" 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_version < "4.0"
|
||||||
httpcore==0.16.3 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
h11==0.14.0 ; python_version >= "3.8" and python_version < "4.0"
|
||||||
httpx==0.23.3 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
httpcore==0.16.3 ; python_version >= "3.8" and python_version < "4.0"
|
||||||
idna==3.4 ; python_full_version >= "3.8.1" and python_version < "4.0"
|
httpx==0.23.1 ; python_version >= "3.8" and python_version < "4.0"
|
||||||
loguru==0.6.0 ; python_full_version >= "3.8.1" and python_version < "4.0"
|
idna==3.4 ; python_version >= "3.8" and python_version < "4.0"
|
||||||
lxml==4.9.2 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
lxml==4.9.2 ; python_version >= "3.8" and python_version < "4.0"
|
||||||
msgpack==1.0.5 ; python_full_version >= "3.8.1" and python_version < "4.0"
|
multidict==6.0.4 ; python_version >= "3.8" and python_version < "4.0"
|
||||||
multidict==6.0.4 ; python_full_version >= "3.8.1" and python_version < "4.0"
|
openpyxl==3.0.10 ; python_version >= "3.8" and python_version < "4.0"
|
||||||
nonebot-adapter-onebot==2.2.1 ; python_full_version >= "3.8.1" and python_version < "4.0"
|
passlib==1.7.4 ; python_version >= "3.8" and python_version < "4.0"
|
||||||
nonebot-plugin-apscheduler==0.2.0 ; python_full_version >= "3.8.1" and python_version < "4.0"
|
pillow==9.3.0 ; python_version >= "3.8" and python_version < "4.0"
|
||||||
nonebot2==2.0.0rc3 ; python_full_version >= "3.8.1" and python_version < "4.0"
|
pydantic==1.10.4 ; python_version >= "3.8" and python_version < "4.0"
|
||||||
openpyxl==3.1.1 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
python-multipart==0.0.5 ; python_version >= "3.8" and python_version < "4.0"
|
||||||
passlib==1.7.4 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
qrcode[pil]==7.3.1 ; python_version >= "3.8" and python_version < "4.0"
|
||||||
pillow==9.4.0 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
rfc3986[idna2008]==1.5.0 ; python_version >= "3.8" and python_version < "4.0"
|
||||||
pydantic==1.10.6 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
six==1.16.0 ; python_version >= "3.8" and python_version < "4.0"
|
||||||
pydantic[dotenv]==1.10.6 ; python_full_version >= "3.8.1" and python_version < "4.0"
|
smmap==5.0.0 ; python_version >= "3.8" and python_version < "4.0"
|
||||||
pygtrie==2.5.0 ; python_full_version >= "3.8.1" and python_version < "4.0"
|
sniffio==1.3.0 ; python_version >= "3.8" and python_version < "4.0"
|
||||||
pypng==0.20220715.0 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
soupsieve==2.3.2.post1 ; python_version >= "3.8" and python_version < "4.0"
|
||||||
python-dotenv==1.0.0 ; python_full_version >= "3.8.1" and python_version < "4.0"
|
sqlalchemy-database==0.0.11 ; python_version >= "3.8" and python_version < "4.0"
|
||||||
python-multipart==0.0.6 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
sqlalchemy2-stubs==0.0.2a31 ; python_version >= "3.8" and python_version < "4.0"
|
||||||
pytz-deprecation-shim==0.1.0.post0 ; python_full_version >= "3.8.1" and python_version < "4.0"
|
sqlalchemy==1.4.41 ; python_version >= "3.8" and python_version < "4.0"
|
||||||
pytz==2022.7.1 ; python_full_version >= "3.8.1" and python_version < "4.0"
|
sqlmodel==0.0.8 ; python_version >= "3.8" and python_version < "4.0"
|
||||||
qrcode[pil]==7.4.2 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
sqlmodelx==0.0.4 ; python_version >= "3.8" and python_version < "4.0"
|
||||||
rfc3986[idna2008]==1.5.0 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
starlette==0.22.0 ; python_version >= "3.8" and python_version < "4.0"
|
||||||
setuptools==67.6.0 ; python_full_version >= "3.8.1" and python_version < "4.0"
|
typing-extensions==4.4.0 ; python_version >= "3.8" and python_version < "4.0"
|
||||||
six==1.16.0 ; python_full_version >= "3.8.1" and python_version < "4.0"
|
yarl==1.8.2 ; python_version >= "3.8" and python_version < "4.0"
|
||||||
smmap==5.0.0 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
|
||||||
sniffio==1.3.0 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
|
||||||
soupsieve==2.4 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
|
||||||
sqlalchemy-database==0.1.0 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
|
||||||
sqlalchemy2-stubs==0.0.2a32 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
|
||||||
sqlalchemy==1.4.41 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
|
||||||
sqlmodel==0.0.8 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
|
||||||
sqlmodelx==0.0.4 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
|
||||||
starlette==0.25.0 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
|
||||||
tomlkit==0.11.6 ; python_full_version >= "3.8.1" and python_version < "4.0"
|
|
||||||
typing-extensions==4.5.0 ; python_full_version >= "3.8.1" and python_version < "4.0"
|
|
||||||
tzdata==2022.7 ; python_full_version >= "3.8.1" and python_version < "4.0"
|
|
||||||
tzlocal==4.2 ; python_full_version >= "3.8.1" and python_version < "4.0"
|
|
||||||
win32-setctime==1.1.0 ; python_full_version >= "3.8.1" and python_version < "4.0" and sys_platform == "win32"
|
|
||||||
yarl==1.8.2 ; python_full_version >= "3.8.1" and python_version < "4.0"
|
|
||||||
|
@ -1 +0,0 @@
|
|||||||
ENVIRONMENT=test
|
|
@ -1,5 +0,0 @@
|
|||||||
LOG_LEVEL=TRACE
|
|
||||||
NICKNAME=["test"]
|
|
||||||
SUPERUSERS=["onebot:10000","10001","other:10002","abcdef"]
|
|
||||||
COMMAND_START=["", "/"]
|
|
||||||
DRIVER="~none"
|
|
@ -1,23 +0,0 @@
|
|||||||
import pytest
|
|
||||||
import nonebot
|
|
||||||
from nonebug import NONEBOT_INIT_KWARGS
|
|
||||||
from nonebot.adapters.onebot.v11 import Adapter
|
|
||||||
|
|
||||||
PLUGINS = ["meta", "adv", "etcimg", "guide"]
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope="session", autouse=True)
|
|
||||||
def load_bot():
|
|
||||||
driver = nonebot.get_driver()
|
|
||||||
driver.register_adapter(Adapter)
|
|
||||||
|
|
||||||
nonebot.load_all_plugins(
|
|
||||||
[f"GenshinUID.genshinuid_{name}" for name in PLUGINS], []
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def pytest_configure(config: pytest.Config):
|
|
||||||
config.stash[NONEBOT_INIT_KWARGS] = {
|
|
||||||
"genshinuid_disabled_plugins": {"xkdata", "abyss", "adv"},
|
|
||||||
"genshinuid_priority": 5,
|
|
||||||
}
|
|
@ -1,31 +0,0 @@
|
|||||||
import pytest
|
|
||||||
from nonebug import App
|
|
||||||
|
|
||||||
MESSAGE = """「安柏」
|
|
||||||
-=-=-=-=-=-=-=-=-=-
|
|
||||||
推荐5★武器:阿莫斯之弓、天空之翼、终末嗟叹之诗
|
|
||||||
推荐4★武器:绝弦
|
|
||||||
推荐圣遗物搭配:
|
|
||||||
[昔日宗室之仪]四件套
|
|
||||||
-=-=-=-=-=-=-=-=-=-
|
|
||||||
备注:
|
|
||||||
原神御三家之一,必胜客联动看板角色之一;
|
|
||||||
身份西风骑士团侦查骑士,蒙德飞行冠军,柏菈图的拼图(误);
|
|
||||||
人送外号解谜点火真君/打火姬
|
|
||||||
通常情况下,安柏的大世界解谜意义大于其深渊实战意义,建议根据实际需求选择投入资源培养"""
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
|
||||||
@pytest.mark.parametrize(argnames="alias", argvalues=["安柏用什么", "安柏怎么养"])
|
|
||||||
async def test_adv_char_chat(app: App, alias):
|
|
||||||
from utils import make_event
|
|
||||||
from nonebot.adapters.onebot.v11 import Bot, Message
|
|
||||||
|
|
||||||
from GenshinUID.genshinuid_adv import get_char_adv
|
|
||||||
|
|
||||||
async with app.test_matcher(get_char_adv) as ctx:
|
|
||||||
bot = ctx.create_bot(base=Bot)
|
|
||||||
event = make_event(message=Message(alias))
|
|
||||||
ctx.receive_event(bot, event)
|
|
||||||
ctx.should_call_send(event, MESSAGE, True)
|
|
||||||
ctx.should_finished()
|
|
@ -1,8 +0,0 @@
|
|||||||
from nonebug import App
|
|
||||||
|
|
||||||
|
|
||||||
def test_config(app: App):
|
|
||||||
from GenshinUID import config
|
|
||||||
|
|
||||||
assert config.config.disabled_plugins == {"xkdata", "abyss", "adv"}
|
|
||||||
assert config.priority == 5
|
|
@ -1,121 +0,0 @@
|
|||||||
from pathlib import Path
|
|
||||||
|
|
||||||
import pytest
|
|
||||||
from nonebug import App
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
|
||||||
@pytest.mark.parametrize(argnames="alias", argvalues=["版本规划", "原石预估"])
|
|
||||||
async def test_get_primogems_data(app: App, alias):
|
|
||||||
from utils import make_event
|
|
||||||
from nonebot.adapters.onebot.v11 import Bot, Message, MessageSegment
|
|
||||||
|
|
||||||
from GenshinUID.version import Genshin_version
|
|
||||||
from GenshinUID.genshinuid_etcimg import get_primogems_data
|
|
||||||
|
|
||||||
with open(
|
|
||||||
Path(
|
|
||||||
(
|
|
||||||
"../GenshinUID/genshinuid_etcimg"
|
|
||||||
f"/primogems_data/{Genshin_version[:3]}.png"
|
|
||||||
)
|
|
||||||
),
|
|
||||||
"rb",
|
|
||||||
) as f:
|
|
||||||
data = f.read()
|
|
||||||
|
|
||||||
async with app.test_matcher(get_primogems_data) 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(data),
|
|
||||||
True,
|
|
||||||
)
|
|
||||||
ctx.should_finished()
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
|
||||||
async def test_primogems_version(app: App):
|
|
||||||
from utils import make_event
|
|
||||||
from nonebot.adapters.onebot.v11 import Bot, Message, MessageSegment
|
|
||||||
|
|
||||||
from GenshinUID.version import Genshin_version
|
|
||||||
from GenshinUID.genshinuid_etcimg import get_primogems_data
|
|
||||||
|
|
||||||
with open(
|
|
||||||
Path(
|
|
||||||
(
|
|
||||||
"../GenshinUID/genshinuid_etcimg"
|
|
||||||
f"/primogems_data/{Genshin_version[:3]}.png"
|
|
||||||
)
|
|
||||||
),
|
|
||||||
"rb",
|
|
||||||
) as f:
|
|
||||||
data = f.read()
|
|
||||||
|
|
||||||
async with app.test_matcher(get_primogems_data) as ctx:
|
|
||||||
bot = ctx.create_bot(base=Bot)
|
|
||||||
event = make_event(message=Message(f"版本规划{Genshin_version[:3]}"))
|
|
||||||
ctx.receive_event(bot, event)
|
|
||||||
ctx.should_call_send(
|
|
||||||
event,
|
|
||||||
MessageSegment.image(data),
|
|
||||||
True,
|
|
||||||
)
|
|
||||||
ctx.should_finished()
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
|
||||||
async def test_primogems_failed(app: App):
|
|
||||||
from utils import make_event
|
|
||||||
from nonebot.adapters.onebot.v11 import Bot, Message
|
|
||||||
|
|
||||||
from GenshinUID.genshinuid_etcimg import get_primogems_data
|
|
||||||
|
|
||||||
# primogems_img.exists() is False
|
|
||||||
async with app.test_matcher(get_primogems_data) as ctx:
|
|
||||||
bot = ctx.create_bot(base=Bot)
|
|
||||||
|
|
||||||
event = make_event(message=Message("版本规划1.0"))
|
|
||||||
ctx.receive_event(bot, event)
|
|
||||||
ctx.should_finished()
|
|
||||||
|
|
||||||
# str(args) in version is False
|
|
||||||
async with app.test_matcher(get_primogems_data) as ctx:
|
|
||||||
event = make_event(message=Message("版本规划abc"))
|
|
||||||
ctx.receive_event(bot, event)
|
|
||||||
ctx.should_finished()
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
|
||||||
@pytest.mark.parametrize(
|
|
||||||
argnames="alias",
|
|
||||||
argvalues=[
|
|
||||||
"伤害乘区",
|
|
||||||
"血量表",
|
|
||||||
"抗性表",
|
|
||||||
"血量排行",
|
|
||||||
"伤害乘区",
|
|
||||||
],
|
|
||||||
)
|
|
||||||
async def test_get_img_data(app: App, alias):
|
|
||||||
from utils import make_event
|
|
||||||
from nonebot.adapters.onebot.v11 import Bot, Message, MessageSegment
|
|
||||||
|
|
||||||
from GenshinUID.genshinuid_etcimg import get_img_data
|
|
||||||
|
|
||||||
with open(
|
|
||||||
Path(f"../GenshinUID/genshinuid_etcimg/img_data/{alias}.jpg"),
|
|
||||||
"rb",
|
|
||||||
) as f:
|
|
||||||
data = f.read()
|
|
||||||
|
|
||||||
async with app.test_matcher(get_img_data) as ctx:
|
|
||||||
bot = ctx.create_bot(base=Bot)
|
|
||||||
|
|
||||||
event = make_event(message=Message(f"查询{alias}"))
|
|
||||||
ctx.receive_event(bot, event)
|
|
||||||
ctx.should_call_send(event, MessageSegment.image(data), True)
|
|
||||||
ctx.should_finished()
|
|
@ -1,123 +0,0 @@
|
|||||||
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 ):
|
|
||||||
# from utils import make_event
|
|
||||||
# from nonebot.adapters.onebot.v11 import Bot, Message, MessageSegment
|
|
||||||
|
|
||||||
# from GenshinUID.genshinuid_guide import get_guide_pic
|
|
||||||
|
|
||||||
# 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 ):
|
|
||||||
# from utils import make_event
|
|
||||||
# from nonebot.adapters.onebot.v11 import Bot, Message, MessageSegment
|
|
||||||
|
|
||||||
# from GenshinUID.genshinuid_guide import get_guide_pic
|
|
||||||
|
|
||||||
# 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()
|
|
||||||
|
|
||||||
|
|
||||||
# @pytest.mark.asyncio
|
|
||||||
# async def test_get_guide_pic_failed(app: App ):
|
|
||||||
# from utils import make_event
|
|
||||||
# from nonebot.adapters.onebot.v11 import Bot, Message
|
|
||||||
|
|
||||||
# from GenshinUID.genshinuid_guide import get_guide_pic
|
|
||||||
|
|
||||||
# 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()
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
|
||||||
@pytest.mark.parametrize(
|
|
||||||
argnames="alias",
|
|
||||||
argvalues=[
|
|
||||||
"参考面板钟离",
|
|
||||||
"参考面板岩王爷", # alias
|
|
||||||
],
|
|
||||||
)
|
|
||||||
async def test_get_bluekun_pic(app: App, alias):
|
|
||||||
from utils import make_event
|
|
||||||
from nonebot.adapters.onebot.v11 import Bot, Message, MessageSegment
|
|
||||||
|
|
||||||
from GenshinUID.genshinuid_guide import get_bluekun_pic
|
|
||||||
|
|
||||||
with open(Path("../GenshinUID/genshinuid_guide/img/钟离.jpg"), "rb") as f:
|
|
||||||
data = f.read()
|
|
||||||
async with app.test_matcher(get_bluekun_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(data), True)
|
|
||||||
ctx.should_finished()
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
|
||||||
@pytest.mark.parametrize(
|
|
||||||
argnames="alias",
|
|
||||||
argvalues=[
|
|
||||||
"岩",
|
|
||||||
"冰",
|
|
||||||
],
|
|
||||||
)
|
|
||||||
async def test_get_bluekun_pic_element(app: App, alias):
|
|
||||||
from utils import make_event
|
|
||||||
from nonebot.adapters.onebot.v11 import Bot, Message, MessageSegment
|
|
||||||
|
|
||||||
from GenshinUID.genshinuid_guide import get_bluekun_pic
|
|
||||||
|
|
||||||
with open(
|
|
||||||
Path(f"../GenshinUID/genshinuid_guide/img/{alias}.jpg"), "rb"
|
|
||||||
) as f:
|
|
||||||
data = f.read()
|
|
||||||
async with app.test_matcher(get_bluekun_pic) as ctx:
|
|
||||||
bot = ctx.create_bot(base=Bot)
|
|
||||||
|
|
||||||
event = make_event(message=Message(f"参考面板{alias}"))
|
|
||||||
ctx.receive_event(bot, event)
|
|
||||||
ctx.should_call_send(event, MessageSegment.image(data), True)
|
|
||||||
ctx.should_finished()
|
|
@ -1,36 +0,0 @@
|
|||||||
import pytest
|
|
||||||
from nonebug import App
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
|
||||||
async def test_metadata(app: App):
|
|
||||||
from GenshinUID.genshinuid_meta import __plugin_meta__
|
|
||||||
|
|
||||||
assert __plugin_meta__.name == 'GenshinUID'
|
|
||||||
assert (
|
|
||||||
__plugin_meta__.description == '基于NoneBot2的原神Uid查询/原神Wiki/米游社签到/树脂提醒插件'
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
|
||||||
async def test_register_menu(app: App):
|
|
||||||
from GenshinUID.genshinuid_meta import sub_menus, register_menu
|
|
||||||
|
|
||||||
@register_menu(
|
|
||||||
'test',
|
|
||||||
'trigger',
|
|
||||||
'test register_menu',
|
|
||||||
trigger_method='114514',
|
|
||||||
detail_des='test register_menu',
|
|
||||||
)
|
|
||||||
async def _example() -> None:
|
|
||||||
pass
|
|
||||||
|
|
||||||
menu = {
|
|
||||||
"func": "test",
|
|
||||||
"trigger_condition": "trigger",
|
|
||||||
"trigger_method": "114514",
|
|
||||||
"brief_des": "test register_menu",
|
|
||||||
"detail_des": "test register_menu",
|
|
||||||
}
|
|
||||||
assert menu in sub_menus
|
|
@ -1,9 +0,0 @@
|
|||||||
from nonebug import App
|
|
||||||
|
|
||||||
|
|
||||||
def test_get_superusers(app: App):
|
|
||||||
from GenshinUID.utils.nonebot2.utils import get_superusers
|
|
||||||
|
|
||||||
superusers = get_superusers()
|
|
||||||
assert len(superusers) == 2
|
|
||||||
assert set(superusers) == {10000, 10001}
|
|
108
tests/utils.py
108
tests/utils.py
@ -1,108 +0,0 @@
|
|||||||
# https://gist.github.com/38e4df0f6f7879d9324b15ac910229ac
|
|
||||||
from typing import Any, Dict, Optional, cast
|
|
||||||
|
|
||||||
from nonebot.adapters.onebot.v11 import Adapter, Message
|
|
||||||
from nonebot.adapters.onebot.v11.event import Event, Sender
|
|
||||||
|
|
||||||
|
|
||||||
def make_sender(
|
|
||||||
user_id: int = 10001,
|
|
||||||
nickname: str = "test",
|
|
||||||
sex: str = "unknown",
|
|
||||||
age: int = 1,
|
|
||||||
card: str = "test",
|
|
||||||
area: str = "北京",
|
|
||||||
level: str = "1",
|
|
||||||
role: str = "owner",
|
|
||||||
title: str = "test",
|
|
||||||
):
|
|
||||||
"""
|
|
||||||
:说明:
|
|
||||||
生成发送人信息类型。
|
|
||||||
https://github.com/botuniverse/onebot-11/blob/master/event/message.md
|
|
||||||
|
|
||||||
|
|
||||||
:参数:
|
|
||||||
|
|
||||||
* ``user_id: int = 10001``: 发送者 QQ 号。
|
|
||||||
* ``nickname: str = "test"``: 昵称。
|
|
||||||
* ``sex: str = "unknown"``: 性别,`male` 或 `female` 或 `unknown`。
|
|
||||||
* ``age: int = 1``: 年龄。
|
|
||||||
* ``card: str = "test"``: 群名片/备注。
|
|
||||||
* ``area: str = "北京"``: 地区。
|
|
||||||
* ``level: str = "1"``: 成员等级。
|
|
||||||
* ``role: str = "owner"``: 角色,`owner` 或 `admin` 或 `member`。
|
|
||||||
* ``title: str = "test"``: 专属头衔。
|
|
||||||
"""
|
|
||||||
|
|
||||||
return Sender(
|
|
||||||
user_id=user_id,
|
|
||||||
nickname=nickname,
|
|
||||||
sex=sex,
|
|
||||||
age=age,
|
|
||||||
card=card,
|
|
||||||
area=area,
|
|
||||||
level=level,
|
|
||||||
role=role,
|
|
||||||
title=title,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def make_event(
|
|
||||||
sender: Sender = make_sender(),
|
|
||||||
message: Optional[Message] = None,
|
|
||||||
time: int = 0,
|
|
||||||
self_id: int = 10000,
|
|
||||||
post_type: str = "message",
|
|
||||||
message_type: str = "private",
|
|
||||||
sub_type: str = "friend",
|
|
||||||
group_id: int = 10002,
|
|
||||||
anonymous: Optional[Dict[str, Any]] = None,
|
|
||||||
message_id: int = 1,
|
|
||||||
user_id: int = 10001,
|
|
||||||
font: int = 0,
|
|
||||||
**kwargs,
|
|
||||||
) -> Event:
|
|
||||||
"""
|
|
||||||
:说明:
|
|
||||||
|
|
||||||
根据消息类型自动生成事件。
|
|
||||||
https://github.com/botuniverse/onebot-11/blob/master/event/message.md
|
|
||||||
|
|
||||||
:参数:
|
|
||||||
|
|
||||||
* ``time: int = 0``: 事件发生的时间戳。
|
|
||||||
* ``self_id: int = 10000``: 收到事件的机器人 QQ 号。
|
|
||||||
* ``post_type: str = "message"``: 上报类型。
|
|
||||||
* ``message_type: str = "private"``: 消息类型,`friend` 是私聊消息,`group是群消息`。
|
|
||||||
* ``sub_type: str = "friend"``: 消息子类型:
|
|
||||||
* 私聊消息:如果是好友则是 `friend`,如果是群临时会话则是 `group`。
|
|
||||||
* 群消息:正常消息是 normal,匿名消息是 anonymous,系统提示(如「管理员已禁止群内匿名聊天」)是 notice
|
|
||||||
* ``message_id: int = 1``: 消息 ID。
|
|
||||||
* ``user_id: int = 10001``: 发送者 QQ 号。
|
|
||||||
* ``message: Message = None``: 消息内容。
|
|
||||||
* ``font: int = 0``: 字体。
|
|
||||||
* ``sender: Sender = None``: 发送人信息。
|
|
||||||
"""
|
|
||||||
raw_message = message.extract_plain_text() if message else ''
|
|
||||||
return cast(
|
|
||||||
Event,
|
|
||||||
Adapter.json_to_event(
|
|
||||||
{
|
|
||||||
"time": time,
|
|
||||||
"self_id": self_id,
|
|
||||||
"post_type": post_type,
|
|
||||||
"message_type": message_type,
|
|
||||||
"sub_type": sub_type,
|
|
||||||
"message_id": message_id,
|
|
||||||
"user_id": user_id,
|
|
||||||
"message": message,
|
|
||||||
"raw_message": raw_message,
|
|
||||||
"font": font,
|
|
||||||
"sender": sender,
|
|
||||||
"group_id": group_id,
|
|
||||||
"anonymous": anonymous,
|
|
||||||
**kwargs,
|
|
||||||
},
|
|
||||||
),
|
|
||||||
)
|
|
Reference in New Issue
Block a user