mirror of
https://github.com/KimigaiiWuyi/GenshinUID.git
synced 2025-07-04 14:03:31 +00:00
Compare commits
763 Commits
main
...
nonebot2-b
Author | SHA1 | Date | |
---|---|---|---|
acd5408552 | |||
31b6bc7de4 | |||
4db59f2b1d | |||
99496abd40 | |||
d372757f72 | |||
689efe6595 | |||
7ec5618d56 | |||
b4817ef539 | |||
739a14237c | |||
c7f7130db3 | |||
15671c5204 | |||
a9644b6af2 | |||
ca793d9b50 | |||
b2564f3303 | |||
bf530c7c49 | |||
d3214bd468 | |||
04e05d708a | |||
986dc750de | |||
e0f6e68fb8 | |||
94aaa52fd6 | |||
f684f0e833 | |||
772d54ef99 | |||
b6c855c1ae | |||
558f280996 | |||
d75a023d10 | |||
cd2eb1d217 | |||
1a69c787b2 | |||
e77b8b74b4 | |||
5da43afd78 | |||
fa3319a48d | |||
4f349cd253 | |||
955ff47542 | |||
ae38504e7e | |||
03e31d6416 | |||
4f0a3202ea | |||
32e15df3cd | |||
3a202afd19 | |||
28227236da | |||
ed68e42385 | |||
b850f099d1 | |||
768619e0c1 | |||
137c83471e | |||
20319c02ac | |||
79d90deae0 | |||
9fee49e090 | |||
cc145d9a5c | |||
1fbecaee53 | |||
f7ff22ad4c | |||
416cc371fc | |||
e73cd9e6eb | |||
ec622d1388 | |||
bdfc63a6c7 | |||
0c7d737ab7 | |||
e0ae84ac89 | |||
b9519acf89 | |||
6f22752b07 | |||
e13b3e5a52 | |||
8b3771a3a0 | |||
4ec467e154 | |||
5b6384764a | |||
7838611f14 | |||
24257cdf90 | |||
7692e9799a | |||
bdff2b31c1 | |||
052d3c1c73 | |||
e5824e407e | |||
5540fab06a | |||
6240d020eb | |||
59c93fd6ef | |||
668ad813c8 | |||
5eb4675628 | |||
261437f466 | |||
b24708f913 | |||
3ff5b4f2fa | |||
698d310684 | |||
18ed57b93a | |||
ea486f7ff5 | |||
cd4ecb462c | |||
3c3785cd48 | |||
37a6d2f7a8 | |||
29c46a93d6 | |||
5ba1ba09e6 | |||
21c7049fdd | |||
76469c56a7 | |||
b30bd4fa9c | |||
eb6e822b6f | |||
80f8a12789 | |||
278cbcaa63 | |||
ac98c9f896 | |||
c02d1f2f07 | |||
0f1a0b02c2 | |||
f4d1d47554 | |||
fb4c6b569c | |||
5e52c9abd4 | |||
c413e7d65c | |||
9e6cd2a2a8 | |||
38910e9a2b | |||
933e97ff97 | |||
09aa9af93a | |||
f1ff90c423 | |||
897399b77e | |||
0099d16072 | |||
519aef0ca1 | |||
a6f66c5231 | |||
63488e7bbf | |||
c7ceb7a14c | |||
49612280fa | |||
e18e69aeed | |||
1b402defbc | |||
245446e329 | |||
0832d9d79e | |||
376f537701 | |||
a5933222c5 | |||
455e9207ff | |||
fee7e8a936 | |||
ba2b4aa86f | |||
76f18d9c7c | |||
95dbe36cf9 | |||
d0d56f1a6d | |||
b3a64c8aec | |||
9d34e463ec | |||
0cb727784b | |||
1b743e9096 | |||
1ec87752a4 | |||
94050454e6 | |||
2886cbfebf | |||
fddc85c91e | |||
63f5d0686b | |||
21a6a3eafc | |||
a7eb2a33cb | |||
aaf7431c92 | |||
49a77f7fb9 | |||
ef923c5ba9 | |||
68c42305e5 | |||
7fb4a4d572 | |||
ecdb232beb | |||
8cd9570e2d | |||
e42ef039d1 | |||
28dce2f15c | |||
5ee22c89bf | |||
9ddba001be | |||
58cabae6ee | |||
b59b406027 | |||
e6d4d452a5 | |||
8d82fba7af | |||
0a81e2b9fa | |||
98e0174348 | |||
9596199a3a | |||
b9406eb634 | |||
30f164b2a1 | |||
66224ece5b | |||
db9860531b | |||
d8d2ede988 | |||
044701e730 | |||
2d1f766d7c | |||
b01117c224 | |||
8ca7237075 | |||
41f047a96f | |||
ad3859ed71 | |||
e62f9ba574 | |||
93bcf9fbbc | |||
3ac2267cee | |||
c46f14e59f | |||
99be740d11 | |||
21ddfa3cd6 | |||
00bdc5fccb | |||
918632ad71 | |||
b4f8371e5d | |||
59cc1e35c4 | |||
798069565a | |||
0b3dddb870 | |||
58a0df17b8 | |||
bdd4f26fe3 | |||
c3ae3ed0db | |||
ecd7a57ef3 | |||
c231cb4267 | |||
26eb980e5b | |||
ffb2558fec | |||
a9f26bb102 | |||
2c1ad1466b | |||
25ffbfc4bc | |||
34eb5093d9 | |||
9ac01864c5 | |||
db3ba78639 | |||
7617c29b6d | |||
62d8ee5cd3 | |||
bec03e8acc | |||
396015763b | |||
4a1c402c38 | |||
5fc6df94f6 | |||
c39ddf30c2 | |||
124de5aff3 | |||
3e61f3411a | |||
1488e3eebb | |||
f32e40d362 | |||
60af532185 | |||
ff317b8f7c | |||
a703593836 | |||
5f801276f5 | |||
a2a6228b66 | |||
712380c24b | |||
27db2e14c4 | |||
3005b435d2 | |||
46a6e846e6 | |||
954e1dd965 | |||
f40730e510 | |||
a60baf7975 | |||
7b9aec2761 | |||
a40a0ea74d | |||
711fe2ad1c | |||
391bf0aa0b | |||
56a609226b | |||
bc17763617 | |||
a5a418f51c | |||
aeec83f982 | |||
85171c0172 | |||
1c363b7ff3 | |||
19dd446219 | |||
6c778f1fcb | |||
7dad667064 | |||
c0532c06dd | |||
245121b318 | |||
501e8398b0 | |||
bac4d7061c | |||
2cddf1c481 | |||
973c64a2dc | |||
d4fd84da9b | |||
fd1f366db3 | |||
86cc55cf78 | |||
70bc3b5143 | |||
6838ce7d5a | |||
75269479be | |||
5d426aa4b4 | |||
34af5a7c27 | |||
dbd60d4ac4 | |||
ad4af70e21 | |||
06fa1a71fa | |||
8cffc3f070 | |||
670cf730e7 | |||
76a350a834 | |||
830a246d96 | |||
5f7dfb93fc | |||
113613bc94 | |||
bb6a2666ff | |||
0e90dd9613 | |||
2a5144b1d6 | |||
1591cc6052 | |||
d8ec80bcd2 | |||
a50f26ecdc | |||
e59d42e168 | |||
0941cd1196 | |||
3e22dae35f | |||
ca40fad6d3 | |||
11bee5a2fc | |||
9cd5fbd0dc | |||
5443ef8ae2 | |||
6e90802e30 | |||
79f9aa9237 | |||
81da9e5735 | |||
fe439f7fb8 | |||
2608259a14 | |||
ca49ee0682 | |||
c0ab255b32 | |||
99146c70ac | |||
8b7a1f5da7 | |||
d1312c5ecc | |||
f2e3687f17 | |||
fbc76e5f8c | |||
4511f6c6c2 | |||
7d98e374ee | |||
c917459e79 | |||
63710928f4 | |||
5d21214a65 | |||
ab83a6689f | |||
c8238e83cf | |||
79bb8c2595 | |||
2ba6701304 | |||
29a5a1a8b5 | |||
0faeef3544 | |||
efb31d55af | |||
997e024681 | |||
1445e0decb | |||
2a55819cd5 | |||
cbf8d26005 | |||
4dc93cb7c2 | |||
43e1202499 | |||
47fbf74e29 | |||
27b343a95e | |||
e8642ac7d8 | |||
ffd27fe2db | |||
b8395ab3fe | |||
e95f1ce4e3 | |||
cf67c7f1ea | |||
5bd4890add | |||
38471d4f11 | |||
d3e1b24fdb | |||
3cefc786ff | |||
d2f9c95e95 | |||
bdfd5714d2 | |||
244e4ae414 | |||
0f225418be | |||
82f7b05a69 | |||
78daf6a934 | |||
843166211b | |||
9fffc3be60 | |||
0643b7d888 | |||
0dff2bf76a | |||
ee88d072a1 | |||
89181be54a | |||
bc522c2259 | |||
6f8c5b60e0 | |||
b5992535c8 | |||
1354400e27 | |||
a96cb5b92f | |||
2682b0c807 | |||
7788067def | |||
7ba36afa97 | |||
3c6f46bf7b | |||
3c8a706d2d | |||
fe1dad35ab | |||
7c6d123bff | |||
45e3781020 | |||
40af1c28db | |||
f325cc136b | |||
31d3f6f783 | |||
e8ca7f7853 | |||
ff4ee1929d | |||
1b8e05d02b | |||
5dbea107ab | |||
09b47a5f2d | |||
03cc73696a | |||
6cbb92423b | |||
79dff3fe7c | |||
0c4719dc07 | |||
f9e1c3f7dd | |||
b67eed8089 | |||
f604d7a007 | |||
d222368ba8 | |||
2e361247c8 | |||
46f389e5eb | |||
cbb7947dd0 | |||
c52c2192e7 | |||
5402f034fe | |||
7d50cc134b | |||
71bcb82082 | |||
7061832664 | |||
bb119bfd6f | |||
ee987c11ed | |||
d80706beaf | |||
09f1f39d62 | |||
d95c1a0c2d | |||
10a0199fdb | |||
edc86d456d | |||
445d190d34 | |||
b84c00c6a1 | |||
de78a3b13c | |||
68baa744b2 | |||
0aaf186615 | |||
22febab01c | |||
47929f764c | |||
72ebb26b12 | |||
8333d61eae | |||
9efaf75c0a | |||
9bd0085982 | |||
21150c7514 | |||
2a337ce8e9 | |||
51866deb99 | |||
331198fa5a | |||
017fbf6683 | |||
6c68ba3657 | |||
a05fdfb9b8 | |||
4a211dd32f | |||
96628af1c8 | |||
d53f920bb3 | |||
4c84a729d0 | |||
3548477289 | |||
b836263039 | |||
7ddf72ea17 | |||
e960a19060 | |||
44934543ea | |||
f9fc8539eb | |||
4002f8597a | |||
fa490d744a | |||
a6dfb9489c | |||
5f074c645c | |||
3b1e03a8ac | |||
10fb6c23f8 | |||
6071903db4 | |||
97eafe0c4f | |||
4f7ee1b8fc | |||
790c6c363a | |||
a680fd40c0 | |||
e7d6b90950 | |||
8dc4bf8b38 | |||
372a03baaa | |||
9a22c2f0a0 | |||
e7f934342e | |||
b385d78655 | |||
d853a3bffe | |||
2331e54519 | |||
84111f11b9 | |||
2120c5387c | |||
0c1d0c8dd3 | |||
ca81bbf131 | |||
418399abf2 | |||
1fca111eef | |||
02627e9743 | |||
e0f19e144f | |||
2f88ca9f96 | |||
55296b8ca7 | |||
a1ad2a2ab5 | |||
d7cd6b0955 | |||
5e706cc04d | |||
18ae78863c | |||
ab8cfe3290 | |||
91c4224b01 | |||
f60716f3fe | |||
8e4c3aa3e7 | |||
0aa94deaae | |||
2eafb87fe5 | |||
3205499096 | |||
9e13b43d8d | |||
efbfea22e1 | |||
3f55b031b2 | |||
df7245d9c7 | |||
3191714394 | |||
1bf87585cf | |||
e6be183259 | |||
ba1da7f328 | |||
32fd9c66e1 | |||
e42fe4d745 | |||
88395108dc | |||
6b01b98f1f | |||
300f907985 | |||
9c196a7341 | |||
8dc2494bed | |||
0da4c273e7 | |||
c371f64449 | |||
0f4f02c687 | |||
9bf5c26b22 | |||
641d4a5ad9 | |||
816feb22e6 | |||
64c145c68d | |||
a8b2ad5fbc | |||
8a57b016cd | |||
e76eff24fe | |||
1105ff1ac7 | |||
cf6ea4bc6a | |||
a70061b158 | |||
5fa9ef4b84 | |||
bc02c23cee | |||
beb9a566a3 | |||
3480677c52 | |||
ea86619795 | |||
e2d75b3752 | |||
6269277b96 | |||
31941d31b2 | |||
55bfd25f64 | |||
6706fd1312 | |||
35d0596f17 | |||
5ab0693f7b | |||
4277a40450 | |||
cfa3f91379 | |||
4b1ad04662 | |||
c854194fcc | |||
451e871d1b | |||
4bc1533063 | |||
62649caa31 | |||
0c9b291ee9 | |||
29df398de6 | |||
0694443bca | |||
75b078810a | |||
7aa07579db | |||
a50a6167e2 | |||
382068070e | |||
782307e4bb | |||
94f3c3a7cb | |||
d441c25c51 | |||
675e8e4f65 | |||
3a02a8f496 | |||
387f618c59 | |||
0bacc8c674 | |||
ee74e054d8 | |||
83681c8e15 | |||
27572a3af4 | |||
2ad9b6242e | |||
01de70c1af | |||
00c5280ec6 | |||
cca8c34bba | |||
bf259f805d | |||
ebdbec5fcd | |||
d96c7b0e06 | |||
a6130424d5 | |||
b8ce462636 | |||
7c1508fd23 | |||
5581b85332 | |||
5dc5110ee3 | |||
fe31910a09 | |||
04a486a256 | |||
d1ca4da918 | |||
75d6083419 | |||
c2e87458a1 | |||
202e86ee77 | |||
27eef2e13e | |||
9c9bae7cc6 | |||
6c41b75e42 | |||
bfbf3140ac | |||
a2305773a9 | |||
ec250a3cbb | |||
f7d62129cb | |||
d24a3109f0 | |||
e2b52b0987 | |||
8fb71cb0be | |||
a974b7b1b7 | |||
a475fd8811 | |||
74e471380a | |||
6f9d251fd1 | |||
8e87716175 | |||
daffc0e39f | |||
ac2346def6 | |||
e7c9071a2a | |||
07ac6fc212 | |||
6bb12944b8 | |||
46d94cebe3 | |||
94838c0a0a | |||
4e2f6d8ee0 | |||
47bc645b68 | |||
60d1c59f2c | |||
96d4ba3211 | |||
26fbb1b38c | |||
d201c33278 | |||
97fee4c824 | |||
12bd7ba921 | |||
29a98bab97 | |||
e4c4e66e58 | |||
f74d04f53a | |||
ead44f46f6 | |||
894da9c2a6 | |||
ae25d5c6b1 | |||
4f605e8654 | |||
ca8ecb677b | |||
89db8d35ca | |||
65c3496e37 | |||
eccfe329a3 | |||
86e22f7374 | |||
62fccbedef | |||
4ef0be08e8 | |||
1fd5b6c564 | |||
1a88b93efd | |||
1b3706a46b | |||
ecad374c03 | |||
fa4ca0be51 | |||
240a01fb18 | |||
7103e7d8ca | |||
728ea9abc2 | |||
2f90e0ee3b | |||
42d28f2fed | |||
1893edf8a7 | |||
92b9e1737f | |||
d4c5d515c8 | |||
1198c71160 | |||
6d4704da56 | |||
4234cc2d2e | |||
c07e864aa0 | |||
de97644fd0 | |||
3b862cb54f | |||
192682ea2a | |||
3593c2d163 | |||
9ae88a11d5 | |||
7efc532f3e | |||
c2e62045fd | |||
5de79b499f | |||
dffdbcc4c6 | |||
90e5b9d3e7 | |||
6b6d9ee479 | |||
3ae3611d36 | |||
7c75145a50 | |||
ad88bc5011 | |||
18a16db8db | |||
bb385e3f9f | |||
d600d4ff9a | |||
71620ce015 | |||
19d9781107 | |||
f42788c008 | |||
6c95472351 | |||
1a92f35fcc | |||
f800581446 | |||
b63c5b9ba3 | |||
22204b115d | |||
35b884a2d3 | |||
7440ef2805 | |||
c54facc919 | |||
4390193184 | |||
23ec1dce8d | |||
d3853a6eb4 | |||
dfe71c99f0 | |||
6ef6005112 | |||
e39094f54a | |||
435e4a2d9a | |||
746cb89bf3 | |||
83a8c53449 | |||
0907e10271 | |||
e07183beae | |||
8daec54d15 | |||
0fc4d899b6 | |||
53b9026d0a | |||
0ec2685d37 | |||
656fbb4749 | |||
2a4da7699d | |||
b5ff2b3613 | |||
c121c95a4c | |||
cbcaa41640 | |||
2e37a0ff9a | |||
4389d23bcc | |||
a2b2f2f3d3 | |||
0ddad55580 | |||
1cc1d4e765 | |||
72bd7be66e | |||
b1ff73ef0d | |||
72d9fa0828 | |||
82e33b153b | |||
06c67c85f8 | |||
fdeafed874 | |||
e3fb49c791 | |||
71db7d8f0f | |||
223f519ee1 | |||
8d6b3c5c77 | |||
a60b64181c | |||
5260abac14 | |||
7838150f35 | |||
cd0c38700c | |||
70c23164c5 | |||
f3c5cb80a1 | |||
f28d7ae0a0 | |||
017c561008 | |||
35dcd29d74 | |||
3c4c7a83c8 | |||
5f20fbd347 | |||
d0f334c9aa | |||
0333757b92 | |||
89fe126579 | |||
b9991ac7d2 | |||
ef0913e6dd | |||
564f3b2783 | |||
d49c3297ed | |||
3df56c1249 | |||
e43392253c | |||
2d1339f8c1 | |||
9597a6d1ba | |||
8f3bc1f9ee | |||
b8279048c1 | |||
d2a8c048a1 | |||
b785adf105 | |||
414e384f1c | |||
0ca23df74f | |||
e6b629d9e1 | |||
c37e008261 | |||
f3eb0b0aa1 | |||
563933f78f | |||
89a8883f07 | |||
adc0a86ce0 | |||
0fb37e41ab | |||
ce110cba99 | |||
bf51b8a2a6 | |||
a3e9a00568 | |||
5adf659ac5 | |||
7500be4078 | |||
c933d5d9ef | |||
157ad92eda | |||
82d2fbcda1 | |||
2afaa437b7 | |||
b7c896e18a | |||
16dc1fe974 | |||
586481062c | |||
fd0e60796e | |||
e91564ac08 | |||
e9042d42fd | |||
b92ff01ddb | |||
5d736dbda1 | |||
a5006183ae | |||
3b919f54fb | |||
9c3e260d1a | |||
0054148196 | |||
0be58c1f43 | |||
02d4809d2c | |||
cea56eb3ea | |||
e53a1d2299 | |||
2f0f8ccbd6 | |||
c120bf65a3 | |||
dd0720a32c | |||
ed8d169134 | |||
e59d4ed1e5 | |||
7955f52ba9 | |||
fc9e35ed05 | |||
c7cc86ca2d | |||
199c2f3a78 | |||
5c9960b5af | |||
81d5e52528 | |||
8f70742528 | |||
d00b7bcbd9 | |||
c47d091c40 | |||
7ff2609f2d | |||
1e2f605776 | |||
05f53275f6 | |||
5728d4ecad | |||
91758947ac | |||
a6e06dce57 | |||
bc49efa759 | |||
ad88859ca6 | |||
3dce0539c6 | |||
fcc038abc1 | |||
247709b06a | |||
a4fbaccee8 | |||
0fce1cbe92 | |||
823e998114 | |||
66e76c71ba | |||
926b48a890 | |||
22b7a53e58 | |||
f09547ba04 | |||
6f54c0c99a | |||
5bc89880fe | |||
aab3d148c4 | |||
c23e577c45 | |||
69250a8700 | |||
5a9e63c54a | |||
336c3f2aaf | |||
9ba855fa17 | |||
bd47c1dce8 | |||
d04dd57aef | |||
18a054ae66 | |||
1b6dc2a194 | |||
421291929d | |||
ecf9419186 | |||
b5362fe575 | |||
ac223d02b3 | |||
babac2d270 | |||
7ea57c069e | |||
68a0fc6073 | |||
cedd47a453 | |||
b72594f20e | |||
61cf1ce79e | |||
997688fa67 | |||
6aa62f2451 | |||
96a2bf6a46 | |||
53a58d458c | |||
4452e35f6a | |||
608c505d7a | |||
da36b1ae0d | |||
d72bdf87ad | |||
dd19fc6bd2 | |||
a51d03c6ee | |||
d73a6d57e4 | |||
84b46699ba | |||
9bdb8dfc3f | |||
286a74d004 | |||
3cd332d8f5 | |||
2a3db3784f | |||
1cea32424d | |||
207c82dfab | |||
dff8992adc | |||
8a7fdb1709 | |||
94682d43fe | |||
2e34937700 |
16
.dockerignore
Normal file
16
.dockerignore
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
# .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
Normal file
42
.github/workflows/unittest.yml
vendored
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
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,5 +668,6 @@ 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
|
|
||||||
.vscode/settings.json
|
### Debug ###
|
||||||
|
testnb2/
|
||||||
|
@ -1,15 +1,12 @@
|
|||||||
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:
|
||||||
@ -25,17 +22,16 @@ 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:
|
args: ["-f", "requirements.txt", "--without-hashes", "-o", "requirements.txt"]
|
||||||
[
|
|
||||||
"-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": "off",
|
"python.analysis.typeCheckingMode": "basic",
|
||||||
"cSpell.words": [
|
"cSpell.words": [
|
||||||
"audioid",
|
"audioid",
|
||||||
"enka",
|
"enka",
|
||||||
|
43
Dockerfile
Normal file
43
Dockerfile
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
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
|
@ -0,0 +1,25 @@
|
|||||||
|
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_
|
||||||
|
],
|
||||||
|
[],
|
||||||
|
)
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
import hoshino
|
|
||||||
from hoshino import Service
|
|
||||||
|
|
||||||
sv = Service('genshinuid', bundle='genshin', help_='发送"原神帮助"查看详情')
|
|
||||||
hoshino_bot = hoshino.get_bot()
|
|
||||||
logger = sv.logger
|
|
15
GenshinUID/config.py
Normal file
15
GenshinUID/config.py
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
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,59 +1,84 @@
|
|||||||
import re
|
from typing import Any, Tuple, Union
|
||||||
|
|
||||||
from hoshino.typing import CQEvent, HoshinoBot
|
from nonebot import on_regex
|
||||||
|
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 ..base import sv, logger
|
from ..genshinuid_meta import register_menu
|
||||||
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.draw_image_tools.send_image_tool import convert_img
|
from ..utils.exception.handle_exception import handle_exception
|
||||||
|
|
||||||
|
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('[查询深渊信息]参数: {}'.format(args))
|
logger.info(f'[查询深渊信息]参数: {args}')
|
||||||
at = re.search(r'\[CQ:at,qq=(\d*)]', str(ev.message))
|
at = custom.get_first_at()
|
||||||
|
qid = at or event.user_id
|
||||||
if at:
|
if args[2] == 'mys':
|
||||||
qid = int(at.group(1))
|
uid = await convert_mysid(args[3])
|
||||||
else:
|
elif args[3] is None:
|
||||||
if ev.sender:
|
|
||||||
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 = await select_db(qid, mode='uid')
|
||||||
uid = str(uid)
|
uid = str(uid)
|
||||||
elif len(args[3]) != 9:
|
elif len(args[3]) != 9:
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
uid = args[3]
|
uid = args[3]
|
||||||
else:
|
logger.info(f'[查询深渊信息]uid: {uid}')
|
||||||
uid = await convert_mysid(args[3])
|
|
||||||
|
|
||||||
logger.info('[查询深渊信息]uid: {}'.format(uid))
|
|
||||||
|
|
||||||
if '未找到绑定的UID' in uid:
|
if '未找到绑定的UID' in uid:
|
||||||
await bot.send(ev, UID_HINT)
|
await matcher.finish(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]
|
||||||
@ -62,17 +87,16 @@ async def send_abyss_info(bot: HoshinoBot, ev: CQEvent):
|
|||||||
.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('[查询深渊信息]深渊层数: {}'.format(floor))
|
logger.info(f'[查询深渊信息]深渊层数: {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 bot.send(ev, im)
|
await matcher.finish(im)
|
||||||
elif isinstance(im, bytes):
|
elif isinstance(im, bytes):
|
||||||
im = await convert_img(im)
|
await matcher.finish(MessageSegment.image(im))
|
||||||
await bot.send(ev, im)
|
|
||||||
else:
|
else:
|
||||||
await bot.send(ev, '发生了未知错误,请联系管理员检查后台输出!')
|
await matcher.finish('发生了未知错误,请联系管理员检查后台输出!')
|
||||||
|
@ -1,36 +1,34 @@
|
|||||||
from hoshino.typing import CQEvent, HoshinoBot
|
from nonebot import on_command
|
||||||
|
from nonebot.log import logger
|
||||||
|
from nonebot.matcher import Matcher
|
||||||
|
from nonebot.params import CommandArg
|
||||||
|
from nonebot.adapters.onebot.v11 import Message
|
||||||
|
|
||||||
from ..base import sv, logger
|
from ..config import priority
|
||||||
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)
|
||||||
|
|
||||||
|
|
||||||
@sv.on_prefix('查委托')
|
@get_task_info.handle()
|
||||||
async def send_task_info(bot: HoshinoBot, ev: CQEvent):
|
@handle_exception('查委托')
|
||||||
if ev.message:
|
async def send_task_info(matcher: Matcher, args: Message = CommandArg()):
|
||||||
message = ev.message.extract_plain_text().replace(' ', '')
|
if not args:
|
||||||
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 bot.send(ev, im)
|
await matcher.finish(im)
|
||||||
|
|
||||||
|
|
||||||
@sv.on_prefix('查成就')
|
@get_achi_info.handle()
|
||||||
async def send_achi_info(bot: HoshinoBot, ev: CQEvent):
|
@handle_exception('查成就')
|
||||||
if ev.message:
|
async def send_achi_info(matcher: Matcher, args: Message = CommandArg()):
|
||||||
message = ev.message.extract_plain_text().replace(' ', '')
|
if not args:
|
||||||
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 bot.send(ev, im)
|
await matcher.finish(im)
|
||||||
|
@ -1,19 +1,72 @@
|
|||||||
from hoshino.typing import CQEvent, HoshinoBot
|
from typing import Any, Tuple
|
||||||
|
|
||||||
from ..base import sv
|
from nonebot import on_regex
|
||||||
|
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
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@sv.on_rex(r'([\u4e00-\u9fa5]+)(用什么|能用啥|怎么养)')
|
@get_char_adv.handle()
|
||||||
async def send_char_adv(bot: HoshinoBot, ev: CQEvent):
|
@handle_exception('建议')
|
||||||
name = await alias_to_char_name(str(ev['match'].group(1)))
|
@register_menu(
|
||||||
|
'角色配置推荐',
|
||||||
|
'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 bot.send(ev, im)
|
await matcher.finish(im)
|
||||||
|
|
||||||
|
|
||||||
@sv.on_rex(r'([\u4e00-\u9fa5]+)(能给谁|给谁用|要给谁|谁能用)')
|
@get_weapon_adv.handle()
|
||||||
async def send_weapon_adv(bot: HoshinoBot, ev: CQEvent):
|
@handle_exception('建议')
|
||||||
name = await alias_to_char_name(str(ev['match'].group(1)))
|
@register_menu(
|
||||||
|
'装备适用角色',
|
||||||
|
'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 bot.send(ev, im)
|
await matcher.finish(im)
|
||||||
|
@ -1,90 +1,96 @@
|
|||||||
import random
|
import random
|
||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
from nonebot import get_bot
|
from nonebot.log import logger
|
||||||
from hoshino import Service, priv
|
from nonebot.matcher import Matcher
|
||||||
|
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.draw_image_tools.send_image_tool import convert_img
|
from ..utils.exception.handle_exception import handle_exception
|
||||||
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
|
||||||
|
|
||||||
sv_help = '''
|
update_ann_scheduler = scheduler
|
||||||
原神公告
|
get_ann_info = on_command('原神公告', priority=priority)
|
||||||
原神公告#ID
|
reg_ann = on_command(
|
||||||
'''.strip()
|
'订阅原神公告', priority=priority, rule=FullCommand(), permission=SUPERUSER
|
||||||
|
|
||||||
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())
|
||||||
|
|
||||||
|
|
||||||
@sv.on_prefix((f'{prefix}公告#', f'{prefix}公告'))
|
@get_ann_info.handle()
|
||||||
async def ann_(bot, ev):
|
@handle_exception('原神公告', '获取/发送原神公告失败')
|
||||||
ann_id = ev.message.extract_plain_text().strip()
|
async def send_ann_pic(
|
||||||
|
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()
|
||||||
img = await convert_img(img)
|
await matcher.finish(MessageSegment.image(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))
|
||||||
img = await convert_img(img)
|
await matcher.finish(MessageSegment.image(img))
|
||||||
await bot.send(ev, img, at_sender=True)
|
|
||||||
except Exception as e:
|
|
||||||
await bot.finish(ev, str(e))
|
|
||||||
|
|
||||||
|
|
||||||
@sv.on_fullmatch(f'订阅{prefix}公告')
|
@reg_ann.handle()
|
||||||
async def sub_ann_(bot, ev):
|
@handle_exception('设置原神公告', '设置原神公告失败')
|
||||||
if not priv.check_priv(ev, priv.ADMIN):
|
async def send_reg_ann(
|
||||||
raise Exception("你没有权限开启原神公告推送")
|
event: GroupMessageEvent,
|
||||||
try:
|
matcher: Matcher,
|
||||||
await bot.send(ev, sub_ann(ev.group_id))
|
):
|
||||||
except Exception as e:
|
await matcher.finish(sub_ann(event.group_id))
|
||||||
await bot.finish(ev, str(e))
|
|
||||||
|
|
||||||
|
|
||||||
@sv.on_fullmatch((f'取消订阅{prefix}公告', f'取消{prefix}公告', f'退订{prefix}公告'))
|
@unreg_ann.handle()
|
||||||
async def unsub_ann_(bot, ev):
|
@handle_exception('取消原神公告', '取消设置原神公告失败')
|
||||||
if not priv.check_priv(ev, priv.ADMIN):
|
async def send_unreg_ann(
|
||||||
raise Exception("你没有权限取消原神公告推送")
|
event: GroupMessageEvent,
|
||||||
try:
|
matcher: Matcher,
|
||||||
await bot.send(ev, unsub_ann(ev.group_id))
|
):
|
||||||
except Exception as e:
|
await matcher.finish(unsub_ann(event.group_id))
|
||||||
await bot.finish(ev, str(e))
|
|
||||||
|
|
||||||
|
|
||||||
@sv.on_fullmatch(f'取消{prefix}公告红点')
|
@consume_ann.handle()
|
||||||
async def consume_remind_(bot, ev):
|
@handle_exception('取消原神公告红点', '取消红点失败')
|
||||||
try:
|
async def send_consume_ann(
|
||||||
qid = int(ev.sender['user_id'])
|
event: MessageEvent,
|
||||||
|
matcher: Matcher,
|
||||||
|
):
|
||||||
|
qid = event.user_id
|
||||||
uid = await select_db(qid, mode='uid')
|
uid = await select_db(qid, mode='uid')
|
||||||
uid = str(uid)
|
uid = str(uid)
|
||||||
if '未找到绑定的UID' in uid:
|
if '未找到绑定的UID' in uid:
|
||||||
await bot.send(ev, UID_HINT)
|
await matcher.finish(UID_HINT)
|
||||||
return
|
await matcher.finish(await consume_remind(uid))
|
||||||
await bot.send(ev, await consume_remind(uid), at_sender=True)
|
|
||||||
except Exception as e:
|
|
||||||
await bot.finish(ev, str(e))
|
|
||||||
|
|
||||||
|
|
||||||
@sv.scheduled_job('cron', minute=10)
|
@update_ann_scheduler.scheduled_job('cron', minute=10)
|
||||||
async def check_ann():
|
async def check_ann():
|
||||||
await check_ann_state()
|
await check_ann_state()
|
||||||
|
|
||||||
@ -117,12 +123,15 @@ 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.send_group_msg(group_id=group, message=img)
|
await bot.call_api(
|
||||||
|
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,10 +1,23 @@
|
|||||||
import random
|
import random
|
||||||
import asyncio
|
import asyncio
|
||||||
|
from typing import Union
|
||||||
|
|
||||||
from hoshino.typing import CQEvent, HoshinoBot
|
from nonebot import on_command
|
||||||
|
from nonebot.log import logger
|
||||||
|
from nonebot.matcher import Matcher
|
||||||
|
from nonebot.permission import SUPERUSER
|
||||||
|
from nonebot_plugin_apscheduler import scheduler
|
||||||
|
from nonebot.adapters.onebot.v11 import (
|
||||||
|
Bot,
|
||||||
|
GroupMessageEvent,
|
||||||
|
PrivateMessageEvent,
|
||||||
|
)
|
||||||
|
|
||||||
from ..base import sv, logger
|
from ..config import priority
|
||||||
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 (
|
||||||
@ -12,35 +25,69 @@ 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
|
||||||
|
)
|
||||||
|
|
||||||
@sv.scheduled_job('cron', hour=0)
|
backup_scheduler = scheduler
|
||||||
|
|
||||||
|
|
||||||
|
@backup_scheduler.scheduled_job('cron', hour=0)
|
||||||
async def daily_refresh_charData():
|
async def daily_refresh_charData():
|
||||||
await data_backup()
|
await data_backup()
|
||||||
|
|
||||||
|
|
||||||
@sv.on_fullmatch('gs清除缓存')
|
@backup.handle()
|
||||||
|
@handle_exception('清除缓存', '清除缓存错误')
|
||||||
|
@register_menu(
|
||||||
|
'清除缓存',
|
||||||
|
'清除缓存',
|
||||||
|
'清除插件产生的缓存数据',
|
||||||
|
trigger_method='超级用户指令',
|
||||||
|
detail_des=(
|
||||||
|
'介绍:\n'
|
||||||
|
'备份一份插件数据库后清除插件产生的文件与数据库缓存\n'
|
||||||
|
' \n'
|
||||||
|
'指令:\n'
|
||||||
|
'- <ft color=(238,120,0)>清除缓存</ft>'
|
||||||
|
),
|
||||||
|
)
|
||||||
async def send_backup_msg(
|
async def send_backup_msg(
|
||||||
bot: HoshinoBot,
|
bot: Bot,
|
||||||
ev: CQEvent,
|
event: Union[GroupMessageEvent, PrivateMessageEvent],
|
||||||
|
matcher: Matcher,
|
||||||
):
|
):
|
||||||
if ev.sender:
|
if not await SUPERUSER(bot, event):
|
||||||
qid = int(ev.sender['user_id'])
|
|
||||||
else:
|
|
||||||
return
|
return
|
||||||
if qid not in bot.config.SUPERUSERS:
|
|
||||||
return
|
|
||||||
|
|
||||||
await data_backup()
|
await data_backup()
|
||||||
await bot.send(ev, '操作成功完成!')
|
await matcher.finish('操作成功完成!')
|
||||||
|
|
||||||
|
|
||||||
@sv.on_fullmatch('清除无效用户')
|
@remove_invalid_user.handle()
|
||||||
async def send_remove_invalid_user_msg(bot: HoshinoBot, ev: CQEvent):
|
@handle_exception('清除无效用户', '清除无效用户错误')
|
||||||
if ev.sender:
|
@register_menu(
|
||||||
qid = int(ev.sender['user_id'])
|
'清除无效用户',
|
||||||
else:
|
'清除无效用户',
|
||||||
return
|
'清除非好友或非推送群成员的数据',
|
||||||
if qid not in bot.config.SUPERUSERS:
|
trigger_method='超级用户指令',
|
||||||
|
detail_des=(
|
||||||
|
'介绍:\n'
|
||||||
|
'从数据库中删除掉 开启了私聊推送但不是Bot好友的用户 '
|
||||||
|
'以及 开启了群聊推送但不在推送目标群的用户 的数据\n'
|
||||||
|
' \n'
|
||||||
|
'指令:\n'
|
||||||
|
'- <ft color=(238,120,0)>清除无效用户</ft>'
|
||||||
|
),
|
||||||
|
)
|
||||||
|
async def send_remove_invalid_user_msg(
|
||||||
|
bot: Bot,
|
||||||
|
event: Union[GroupMessageEvent, PrivateMessageEvent],
|
||||||
|
matcher: Matcher,
|
||||||
|
):
|
||||||
|
if not await SUPERUSER(bot, event):
|
||||||
return
|
return
|
||||||
im_list = []
|
im_list = []
|
||||||
invalid_user = {}
|
invalid_user = {}
|
||||||
@ -62,40 +109,78 @@ async def send_remove_invalid_user_msg(bot: HoshinoBot, ev: CQEvent):
|
|||||||
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 bot.send(ev, f'已清理失效用户{len(im_list)}个!')
|
await matcher.finish(f'已清理失效用户{len(im_list)}个!')
|
||||||
|
|
||||||
|
|
||||||
# 群聊内 校验Cookies 是否正常的功能,不正常自动删掉
|
# 群聊内 校验Cookies 是否正常的功能,不正常自动删掉
|
||||||
@sv.on_fullmatch('校验全部Cookies')
|
@check.handle()
|
||||||
async def send_check_cookies(bot: HoshinoBot, ev: CQEvent):
|
@handle_exception('Cookie校验', 'Cookie校验错误')
|
||||||
|
@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 bot.send(ev, im)
|
await matcher.send(im)
|
||||||
for i in raw_mes[1]:
|
for i in raw_mes[1]:
|
||||||
await bot.send_private_msg(
|
await bot.call_api(
|
||||||
user_id=i[0],
|
api='send_private_msg',
|
||||||
message=(
|
**{
|
||||||
|
'user_id': i[0],
|
||||||
|
'message': (
|
||||||
'您绑定的Cookies(uid{})已失效,以下功能将会受到影响:\n'
|
'您绑定的Cookies(uid{})已失效,以下功能将会受到影响:\n'
|
||||||
'查看完整信息列表\n查看深渊配队\n自动签到/当前状态/每月统计\n'
|
'查看完整信息列表\n查看深渊配队\n自动签到/当前状态/每月统计\n'
|
||||||
'请及时重新绑定Cookies并重新开关相应功能。'
|
'请及时重新绑定Cookies并重新开关相应功能。'
|
||||||
).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()
|
||||||
|
|
||||||
|
|
||||||
# 群聊内 校验Stoken 是否正常的功能,不正常自动删掉
|
# 群聊内 校验Stoken 是否正常的功能,不正常自动删掉
|
||||||
@sv.on_fullmatch('校验全部Stoken')
|
@check_stoken.handle()
|
||||||
async def send_check_stoken(bot: HoshinoBot, ev: CQEvent):
|
@handle_exception('Stoken校验', 'Stoken校验错误')
|
||||||
|
@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 bot.send(ev, im)
|
await matcher.send(im)
|
||||||
for i in raw_mes[1]:
|
for i in raw_mes[1]:
|
||||||
await bot.send_private_msg(
|
await bot.call_api(
|
||||||
user_id=i[0],
|
api='send_private_msg',
|
||||||
message=(
|
**{
|
||||||
|
'user_id': i[0],
|
||||||
|
'message': (
|
||||||
'您绑定的Stoken(uid{})已失效,以下功能将会受到影响:\n'
|
'您绑定的Stoken(uid{})已失效,以下功能将会受到影响:\n'
|
||||||
'gs开启自动米游币,开始获取米游币。\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,70 +1,112 @@
|
|||||||
import re
|
from typing import Union
|
||||||
|
|
||||||
from hoshino.typing import CQEvent, HoshinoBot
|
from nonebot import on_command
|
||||||
|
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 ..genshinuid_meta import register_menu
|
||||||
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.error_reply import * # noqa: F403,F401
|
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
|
||||||
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'))
|
|
||||||
async def send_collection_info(bot: HoshinoBot, ev: CQEvent):
|
@get_collection_info.handle()
|
||||||
raw_mes = ev.message.extract_plain_text().replace(' ', '')
|
@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=(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('开始执行[查询收集信息]')
|
||||||
at = re.search(r'\[CQ:at,qq=(\d*)]', raw_mes)
|
logger.info('[查询收集信息]参数: {}'.format(args))
|
||||||
|
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 bot.send(ev, UID_HINT)
|
await matcher.finish(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 bot.send(ev, im)
|
await matcher.finish(im)
|
||||||
elif isinstance(im, bytes):
|
elif isinstance(im, bytes):
|
||||||
im = await convert_img(im)
|
await matcher.finish(MessageSegment.image(im))
|
||||||
await bot.send(ev, im)
|
|
||||||
else:
|
else:
|
||||||
await bot.send(ev, '发生了未知错误,请联系管理员检查后台输出!')
|
await matcher.finish('发生了未知错误,请联系管理员检查后台输出!')
|
||||||
|
|
||||||
|
|
||||||
@sv.on_prefix(('查询探索', '探索', 'ts'))
|
@get_explora_info.handle()
|
||||||
async def send_explora_info(bot: HoshinoBot, ev: CQEvent):
|
@handle_exception('查询探索信息')
|
||||||
raw_mes = ev.message.extract_plain_text().replace(' ', '')
|
async def send_explora_info(
|
||||||
|
event: Union[GroupMessageEvent, PrivateMessageEvent],
|
||||||
|
matcher: Matcher,
|
||||||
|
args: Message = CommandArg(),
|
||||||
|
custom: ImageAndAt = Depends(),
|
||||||
|
):
|
||||||
logger.info('开始执行[查询探索信息]')
|
logger.info('开始执行[查询探索信息]')
|
||||||
at = re.search(r'\[CQ:at,qq=(\d*)]', raw_mes)
|
logger.info('[查询探索信息]参数: {}'.format(args))
|
||||||
|
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 bot.send(ev, UID_HINT)
|
await matcher.finish(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 bot.send(ev, im)
|
await matcher.finish(im)
|
||||||
elif isinstance(im, bytes):
|
elif isinstance(im, bytes):
|
||||||
im = await convert_img(im)
|
await matcher.finish(MessageSegment.image(im))
|
||||||
await bot.send(ev, im)
|
|
||||||
else:
|
else:
|
||||||
await bot.send(ev, '发生了未知错误,请联系管理员检查后台输出!')
|
await matcher.finish('发生了未知错误,请联系管理员检查后台输出!')
|
||||||
|
@ -1,98 +1,153 @@
|
|||||||
import re
|
from typing import Any, Tuple, Union
|
||||||
|
|
||||||
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 Depends, CommandArg, RegexGroup
|
||||||
|
from nonebot.adapters.onebot.v11 import (
|
||||||
|
Bot,
|
||||||
|
Message,
|
||||||
|
MessageSegment,
|
||||||
|
GroupMessageEvent,
|
||||||
|
PrivateMessageEvent,
|
||||||
|
)
|
||||||
|
|
||||||
from ..base import sv, logger
|
from ..genshinuid_meta import register_menu
|
||||||
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.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
|
|
||||||
|
|
||||||
|
open_and_close_switch = on_regex(
|
||||||
|
r'^(\[CQ:at,qq=[0-9]+\])?( )?'
|
||||||
|
r'(gs)(开启|关闭)(.*)'
|
||||||
|
r'(\[CQ:at,qq=[0-9]+\])?( )?$'
|
||||||
|
)
|
||||||
|
|
||||||
@sv.on_fullmatch('gs配置')
|
push_config = on_regex(
|
||||||
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):
|
|
||||||
args = ev['match'].groups()
|
config_card = on_command('gs配置')
|
||||||
|
|
||||||
|
|
||||||
|
@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()
|
||||||
|
|
||||||
at = re.search(r'\[CQ:at,qq=(\d*)]', str(ev.message))
|
if at and await SUPERUSER(bot, event):
|
||||||
|
|
||||||
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 bot.send(ev, '你没有权限操作别人的状态噢~', at_sender=True)
|
await matcher.finish('你没有权限操作别人的状态噢~', 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 bot.send(ev, UID_HINT)
|
await matcher.finish(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 bot.send(ev, '请输入数字哦~', at_sender=True)
|
await matcher.finish('请输入数字哦~', at_sender=True)
|
||||||
return
|
|
||||||
else:
|
else:
|
||||||
await bot.send(ev, '请输入正确的阈值数字!', at_sender=True)
|
await matcher.finish('请输入正确的阈值数字!', 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 bot.send(ev, im, at_sender=True)
|
await matcher.finish(im, at_sender=True)
|
||||||
|
|
||||||
|
|
||||||
# 开启 自动签到 和 推送树脂提醒 功能
|
# 开启 自动签到 和 推送树脂提醒 功能
|
||||||
@sv.on_rex(
|
@open_and_close_switch.handle()
|
||||||
r'^(\[CQ:at,qq=[0-9]+\])?( )?'
|
@register_menu(
|
||||||
r'(gs)(开启|关闭)(.*)'
|
'开关推送服务',
|
||||||
r'(\[CQ:at,qq=[0-9]+\])?( )?$'
|
'gs{开启|关闭}xx(@某人)',
|
||||||
|
'开关自己或指定人的推送服务状态',
|
||||||
|
detail_des=(
|
||||||
|
'介绍:\n'
|
||||||
|
'设置某人的推送服务开关状态\n'
|
||||||
|
'超级用户可以设置他人的推送服务状态\n'
|
||||||
|
' \n'
|
||||||
|
'指令:\n'
|
||||||
|
'- <ft color=(238,120,0)>gs{开启|关闭}</ft>'
|
||||||
|
'<ft color=(0,148,200)>[服务名称]</ft>'
|
||||||
|
'<ft color=(125,125,125)>(@某人)</ft>\n'
|
||||||
|
' \n'
|
||||||
|
'示例:\n'
|
||||||
|
'- <ft color=(238,120,0)>gs开启推送</ft>'
|
||||||
|
),
|
||||||
)
|
)
|
||||||
async def open_switch_func(bot: HoshinoBot, ev: CQEvent):
|
async def open_switch_func(
|
||||||
args = ev['match'].groups()
|
bot: Bot,
|
||||||
at = re.search(r'\[CQ:at,qq=(\d*)]', str(ev.message))
|
event: Union[GroupMessageEvent, PrivateMessageEvent],
|
||||||
|
matcher: Matcher,
|
||||||
if at:
|
args: Tuple[Any, ...] = RegexGroup(),
|
||||||
qid = int(at.group(1))
|
at: ImageAndAt = Depends(),
|
||||||
else:
|
):
|
||||||
if ev.sender:
|
qid = event.user_id
|
||||||
qid = int(ev.sender['user_id'])
|
atqq = at.get_first_at() if at else None
|
||||||
else:
|
|
||||||
return
|
|
||||||
|
|
||||||
config_name = args[4]
|
config_name = args[4]
|
||||||
|
|
||||||
@ -100,34 +155,31 @@ async def open_switch_func(bot: HoshinoBot, ev: CQEvent):
|
|||||||
|
|
||||||
if args[3] == '开启':
|
if args[3] == '开启':
|
||||||
query = 'OPEN'
|
query = 'OPEN'
|
||||||
gid = str(ev.group_id) if ev.group_id else 'on'
|
gid = (
|
||||||
|
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)
|
||||||
|
|
||||||
if qid in bot.config.SUPERUSERS:
|
|
||||||
is_admin = True
|
|
||||||
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')
|
uid = await select_db(qid, mode='uid')
|
||||||
except TypeError:
|
if uid is None or not isinstance(uid, str) or not uid.isdecimal():
|
||||||
await bot.send(ev, UID_HINT)
|
await matcher.finish(UID_HINT)
|
||||||
return
|
|
||||||
|
|
||||||
im = await set_config_func(
|
im = await set_config_func(
|
||||||
config_name=config_name,
|
config_name=config_name,
|
||||||
uid=uid, # type: ignore
|
uid=uid,
|
||||||
qid=qid, # type: ignore
|
qid=str(qid),
|
||||||
option=gid,
|
option=gid,
|
||||||
query=query,
|
query=query,
|
||||||
is_admin=is_admin,
|
is_admin=is_admin,
|
||||||
)
|
)
|
||||||
await bot.send(ev, im, at_sender=True)
|
await matcher.finish(im, at_sender=True)
|
||||||
|
@ -1,17 +1,15 @@
|
|||||||
from hoshino.typing import CQEvent, HoshinoBot
|
from nonebot import on_command
|
||||||
|
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())
|
||||||
|
|
||||||
|
|
||||||
@sv.on_prefix(('导出v3数据'))
|
@export_v3_data.handle()
|
||||||
async def send_export_msg(bot: HoshinoBot, ev: CQEvent):
|
async def send_export_msg(matcher: Matcher):
|
||||||
if ev.sender:
|
await matcher.send('开始导出数据..可能需要一定时间!')
|
||||||
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 bot.send(ev, '导出数据成功!')
|
await matcher.send('导出数据成功!')
|
||||||
|
@ -1,106 +1,196 @@
|
|||||||
import re
|
import re
|
||||||
import random
|
import random
|
||||||
import asyncio
|
import asyncio
|
||||||
from typing import Tuple
|
from typing import Tuple, Union
|
||||||
|
|
||||||
from hoshino.typing import CQEvent, HoshinoBot
|
from nonebot import on_command
|
||||||
|
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 ..base import sv, logger
|
from ..config import priority
|
||||||
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.draw_image_tools.send_image_tool import convert_img
|
from ..utils.exception.handle_exception import handle_exception
|
||||||
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
|
||||||
|
|
||||||
|
|
||||||
@sv.on_fullmatch('切换api')
|
@change_api.handle()
|
||||||
async def send_change_api_info(bot: HoshinoBot, ev: CQEvent):
|
@handle_exception('切换api')
|
||||||
print(ev)
|
@register_menu(
|
||||||
if ev.sender:
|
'切换API',
|
||||||
qid = int(ev.sender['user_id'])
|
'切换api',
|
||||||
else:
|
'切换获取角色面板时使用的API',
|
||||||
return
|
detail_des=(
|
||||||
|
'介绍:\n'
|
||||||
if qid not in bot.config.SUPERUSERS:
|
'切换获取角色面板时使用的Enka Network API\n'
|
||||||
|
' \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 bot.send(ev, im)
|
await matcher.finish(im)
|
||||||
|
|
||||||
|
|
||||||
@sv.on_rex(r'^(\[CQ:reply,id=[0-9]+\])?( )?(\[CQ:at,qq=[0-9]+\])?( )?原图')
|
@original_pic.handle()
|
||||||
async def send_original_pic(bot: HoshinoBot, ev: CQEvent):
|
@handle_exception('原图')
|
||||||
for msg in ev.message:
|
@register_menu(
|
||||||
if msg['type'] == 'reply':
|
'查看面板原图',
|
||||||
msg_id = msg['data']['id']
|
'原图',
|
||||||
|
'查看角色面板中原随机图',
|
||||||
|
trigger_method='回复+指令',
|
||||||
|
detail_des=(
|
||||||
|
'介绍:\n'
|
||||||
|
'查看开启随机图功能时角色面板中角色位置的原图,需要回复要查看原图的面板图片消息\n'
|
||||||
|
' \n'
|
||||||
|
'指令:\n'
|
||||||
|
'- <ft color=(238,120,0)>原图</ft>'
|
||||||
|
),
|
||||||
|
)
|
||||||
|
async def send_original_pic(
|
||||||
|
event: Union[GroupMessageEvent, PrivateMessageEvent],
|
||||||
|
matcher: Matcher,
|
||||||
|
):
|
||||||
|
if event.reply:
|
||||||
|
msg_id = event.reply.message_id
|
||||||
path = TEMP_PATH / f'{msg_id}.jpg'
|
path = TEMP_PATH / f'{msg_id}.jpg'
|
||||||
if path.exists():
|
if path.exists():
|
||||||
logger.info('[原图]访问图片: {}'.format(path))
|
logger.info('[原图]访问图片: {}'.format(path))
|
||||||
with open(path, 'rb') as f:
|
with open(path, 'rb') as f:
|
||||||
im = await convert_img(f.read())
|
await matcher.finish(MessageSegment.image(f.read()))
|
||||||
await bot.send(ev, im)
|
|
||||||
|
|
||||||
|
|
||||||
@sv.on_rex(
|
@get_char_info.handle()
|
||||||
r'^(\[CQ:at,qq=[0-9]+\])?( )?'
|
@handle_exception('查询角色面板')
|
||||||
r'(uid|查询|mys)([0-9]+)?'
|
@register_menu(
|
||||||
r'([\u4e00-\u9fa5]+)'
|
'查询角色面板',
|
||||||
r'(\[CQ:at,qq=[0-9]+\])?( )?',
|
'查询(@某人)角色名',
|
||||||
|
'查询你的或者指定人的已缓存展柜角色的面板',
|
||||||
|
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>'
|
||||||
|
),
|
||||||
)
|
)
|
||||||
async def send_char_info(bot: HoshinoBot, ev: CQEvent):
|
@register_menu(
|
||||||
args = ev['match'].groups()
|
'查询展柜角色',
|
||||||
if args[4] is None:
|
'查询展柜角色',
|
||||||
|
'查询插件已缓存的展柜角色列表',
|
||||||
|
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('[查询角色面板]参数: {}'.format(args))
|
|
||||||
# 获取角色名
|
|
||||||
at = re.search(r'\[CQ:at,qq=(\d*)]', str(ev.message))
|
|
||||||
image = re.search(r'\[CQ:image,file=(.*),url=(.*)]', str(ev.message))
|
|
||||||
|
|
||||||
img = None
|
logger.info('开始执行[查询角色面板]')
|
||||||
if image:
|
at = custom.get_first_at()
|
||||||
img = image.group(2)
|
img = custom.get_first_image()
|
||||||
|
|
||||||
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
|
|
||||||
logger.info('[查询角色面板]QQ: {}'.format(qid))
|
logger.info('[查询角色面板]QQ: {}'.format(qid))
|
||||||
|
|
||||||
# 获取uid
|
# 获取uid
|
||||||
if args[3] is None:
|
uid = re.findall(r'\d+', raw_mes)
|
||||||
|
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 bot.send(ev, UID_HINT)
|
await matcher.finish(UID_HINT)
|
||||||
|
|
||||||
im = await draw_enka_img(msg, uid, img)
|
im = await draw_enka_img(raw_mes, uid, img)
|
||||||
|
|
||||||
if isinstance(im, str):
|
if isinstance(im, str):
|
||||||
await bot.send(ev, im)
|
await matcher.finish(im)
|
||||||
elif isinstance(im, Tuple):
|
elif isinstance(im, Tuple):
|
||||||
img = await convert_img(im[0])
|
req = await matcher.send(MessageSegment.image(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 bot.send(ev, '发生了未知错误,请联系管理员检查后台输出!')
|
await matcher.finish('发生了未知错误,请联系管理员检查后台输出!')
|
||||||
|
|
||||||
|
|
||||||
async def refresh_char_data():
|
async def refresh_char_data():
|
||||||
@ -125,92 +215,115 @@ async def refresh_char_data():
|
|||||||
return f'执行成功!共刷新{str(t)}个角色!'
|
return f'执行成功!共刷新{str(t)}个角色!'
|
||||||
|
|
||||||
|
|
||||||
@sv.scheduled_job('cron', hour='4')
|
@refresh_scheduler.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()
|
||||||
|
|
||||||
|
|
||||||
@sv.on_prefix('强制刷新')
|
@refresh.handle()
|
||||||
async def send_card_info(bot: HoshinoBot, ev: CQEvent):
|
@handle_exception('强制刷新')
|
||||||
if ev.message:
|
@register_menu(
|
||||||
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>'
|
||||||
if at:
|
'<ft color=(125,125,125)>(uid/全部数据)</ft>\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'])
|
'示例:\n'
|
||||||
else:
|
'<ft color=(238,120,0)>强制刷新</ft>;\n'
|
||||||
return
|
'<ft color=(238,120,0)>强制刷新123456789</ft>;\n'
|
||||||
|
'<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 qid in bot.config.SUPERUSERS:
|
if await SUPERUSER(bot, event):
|
||||||
await bot.send(ev, '开始刷新全部数据,这可能需要相当长的一段时间!!')
|
await matcher.send('开始刷新全部数据,这可能需要相当长的一段时间!!')
|
||||||
im = await refresh_char_data()
|
im = await refresh_char_data()
|
||||||
await bot.send(ev, str(im))
|
await matcher.finish(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 '未找到绑定的UID' in uid:
|
if not uid:
|
||||||
await bot.send(ev, UID_HINT)
|
await matcher.finish(UID_HINT)
|
||||||
return
|
|
||||||
im = await enka_to_card(uid)
|
im = await enka_to_card(uid)
|
||||||
|
|
||||||
if isinstance(im, str):
|
if isinstance(im, str):
|
||||||
await bot.send(ev, im)
|
await matcher.finish(im)
|
||||||
elif isinstance(im, bytes):
|
elif isinstance(im, bytes):
|
||||||
im = await convert_img(im)
|
await matcher.finish(MessageSegment.image(im))
|
||||||
await bot.send(ev, im)
|
|
||||||
else:
|
else:
|
||||||
await bot.send(ev, '发生了未知错误,请联系管理员检查后台输出!')
|
await matcher.finish('发生了未知错误,请联系管理员检查后台输出!')
|
||||||
|
|
||||||
|
|
||||||
@sv.on_prefix('毕业度统计')
|
@get_charcard_list.handle()
|
||||||
async def send_charcard_list(bot: HoshinoBot, ev: CQEvent):
|
@handle_exception('毕业度统计')
|
||||||
if ev.message:
|
@register_menu(
|
||||||
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 = int(at.group(1))
|
qid = at
|
||||||
message = message.replace(str(at), '')
|
|
||||||
else:
|
|
||||||
if ev.sender:
|
|
||||||
qid = int(ev.sender['user_id'])
|
|
||||||
else:
|
|
||||||
return
|
|
||||||
|
|
||||||
# 获取uid
|
# 获取uid
|
||||||
uid = re.findall(r'\d+', message)
|
uid = re.findall(r'\d+', raw_mes)
|
||||||
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):
|
||||||
im = await convert_img(im)
|
await matcher.finish(MessageSegment.image(im))
|
||||||
await bot.send(ev, im)
|
|
||||||
else:
|
else:
|
||||||
await bot.send(ev, str(im))
|
await matcher.finish(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,8 +614,12 @@ class Character:
|
|||||||
'type': '攻击力',
|
'type': '攻击力',
|
||||||
'plus': 1,
|
'plus': 1,
|
||||||
'value': [
|
'value': [
|
||||||
f'''{int(i[:-1]) +
|
f'''{
|
||||||
int(self.power_list["A霜华矢·霜华绽发伤害"]["value"][index][:-1])
|
int(i[:-1]) + int(
|
||||||
|
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'''elementalMastery+
|
effect = f'''
|
||||||
{0.25 * em if 0.25 * em <= 250 else 250}
|
elementalMastery+{0.25 * em if 0.25 * em <= 250 else 250}
|
||||||
'''.strip()
|
'''.strip()
|
||||||
effect_list.append(effect)
|
effect_list.append(effect)
|
||||||
|
|
||||||
|
@ -1,42 +1,118 @@
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from typing import Any, Tuple
|
||||||
|
|
||||||
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.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 ..utils.draw_image_tools.send_image_tool import convert_img
|
from ..genshinuid_meta import register_menu
|
||||||
|
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'
|
||||||
|
|
||||||
|
|
||||||
@sv.on_rex(r'^(版本规划|原石预估)(\S+)?$')
|
@get_primogems_data.handle()
|
||||||
async def send_primogems_data(bot: HoshinoBot, ev: CQEvent):
|
@handle_exception('版本规划')
|
||||||
args = ev['match'].groups()
|
@register_menu(
|
||||||
|
'版本原石规划',
|
||||||
|
'版本规划(版本号)',
|
||||||
|
'发送一张指定版本的原石规划图',
|
||||||
|
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[1]:
|
if args:
|
||||||
path = PRIMOGEMS_DATA_PATH / f'{str(args[1])}.png'
|
path = PRIMOGEMS_DATA_PATH / f'{str(args)}.png'
|
||||||
if path.exists():
|
if path.exists():
|
||||||
img = f'{str(args[1])}.png'
|
img = f'{str(args)}.png'
|
||||||
else:
|
else:
|
||||||
return
|
await matcher.finish()
|
||||||
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()
|
||||||
|
|
||||||
|
|
||||||
@sv.on_rex(r'^(查询)?(伤害乘区|血量表|抗性表|血量排行)$')
|
@get_img_data.handle()
|
||||||
async def send_img_data(bot: HoshinoBot, ev: CQEvent):
|
@handle_exception('杂图')
|
||||||
args = ev['match'].groups()
|
@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>'
|
||||||
|
),
|
||||||
|
)
|
||||||
|
@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():
|
||||||
img = await convert_img(img)
|
with open(img, 'rb') as f:
|
||||||
await bot.send(ev, img)
|
await matcher.finish(MessageSegment.image(f.read()))
|
||||||
else:
|
|
||||||
return
|
|
||||||
|
@ -1,24 +1,56 @@
|
|||||||
from hoshino.typing import CQEvent, HoshinoBot
|
from nonebot import on_command
|
||||||
|
from nonebot.matcher import Matcher
|
||||||
|
from nonebot_plugin_apscheduler import scheduler
|
||||||
|
from nonebot.adapters.onebot.v11 import MessageSegment
|
||||||
|
|
||||||
from ..base import sv
|
from ..config import priority
|
||||||
|
from ..genshinuid_meta import register_menu
|
||||||
|
from ..utils.nonebot2.rule import FullCommand
|
||||||
from .draw_event_img import get_event_img, get_all_event_img
|
from .draw_event_img import get_event_img, get_all_event_img
|
||||||
from ..utils.draw_image_tools.send_image_tool import convert_img
|
from ..utils.exception.handle_exception import handle_exception
|
||||||
|
|
||||||
|
get_event = on_command('活动列表', priority=priority, rule=FullCommand())
|
||||||
|
get_gacha = on_command('卡池列表', priority=priority, rule=FullCommand())
|
||||||
|
|
||||||
|
|
||||||
@sv.scheduled_job('cron', hour='2')
|
@scheduler.scheduled_job('cron', hour='2')
|
||||||
async def draw_event():
|
async def draw_event():
|
||||||
await get_all_event_img()
|
await get_all_event_img()
|
||||||
|
|
||||||
|
|
||||||
@sv.on_fullmatch('活动列表')
|
@get_event.handle()
|
||||||
async def send_events(bot: HoshinoBot, ev: CQEvent):
|
@handle_exception('活动')
|
||||||
|
@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')
|
||||||
im = await convert_img(img)
|
await matcher.finish(MessageSegment.image(img))
|
||||||
await bot.send(ev, im)
|
|
||||||
|
|
||||||
|
|
||||||
@sv.on_fullmatch('卡池列表')
|
@get_gacha.handle()
|
||||||
async def send_gachas(bot: HoshinoBot, ev: CQEvent):
|
@handle_exception('活动')
|
||||||
|
@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')
|
||||||
im = await convert_img(img)
|
await matcher.finish(MessageSegment.image(img))
|
||||||
await bot.send(ev, im)
|
|
||||||
|
@ -1,93 +1,161 @@
|
|||||||
from nonebot import get_bot
|
from typing import Union
|
||||||
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.draw_image_tools.send_image_tool import convert_img
|
from ..utils.exception.handle_exception import handle_exception
|
||||||
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())
|
||||||
@sv.on_notice()
|
get_gacha_log_card = on_command('抽卡记录', rule=FullCommand())
|
||||||
async def import_gacha_log_info(session: NoticeSession):
|
import_gacha_log = on_notice()
|
||||||
ev = session.event
|
export_gacha_log = on_command('导出抽卡记录', rule=FullCommand())
|
||||||
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)
|
|
||||||
|
|
||||||
|
|
||||||
@sv.on_fullmatch('导出抽卡记录')
|
@export_gacha_log.handle()
|
||||||
async def export_gacha_log_info(bot: HoshinoBot, ev: CQEvent):
|
@handle_exception('导出抽卡记录')
|
||||||
|
@register_menu(
|
||||||
|
'导出抽卡记录',
|
||||||
|
'导出抽卡记录',
|
||||||
|
'导出符合UIGF规范的抽卡记录',
|
||||||
|
trigger_method='群聊指令',
|
||||||
|
detail_des=(
|
||||||
|
'介绍:\n'
|
||||||
|
'导出UIGF格式规范的json格式抽卡记录上传到群文件\n'
|
||||||
|
' \n'
|
||||||
|
'指令:\n'
|
||||||
|
'- <ft color=(238,120,0)>导出抽卡记录</ft>'
|
||||||
|
),
|
||||||
|
)
|
||||||
|
async def export_gacha_log_info(
|
||||||
|
event: GroupMessageEvent,
|
||||||
|
matcher: Matcher,
|
||||||
|
):
|
||||||
logger.info('开始执行[导出抽卡记录]')
|
logger.info('开始执行[导出抽卡记录]')
|
||||||
qid = int(ev.sender['user_id'])
|
qid = event.user_id
|
||||||
gid = int(ev.group_id)
|
gid = event.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 bot.send(ev, UID_HINT)
|
await matcher.finish(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_action(
|
await bot.call_api(
|
||||||
action='upload_group_file',
|
'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 bot.send(ev, '上传成功!')
|
await matcher.finish('上传成功!')
|
||||||
else:
|
else:
|
||||||
logger.warning(f'[导出抽卡记录] UID{uid}失败!')
|
logger.warning(f'[导出抽卡记录] UID{uid}失败!')
|
||||||
await bot.send(ev, '导出抽卡记录失败!')
|
await matcher.finish('导出抽卡记录失败!')
|
||||||
|
|
||||||
|
|
||||||
@sv.on_fullmatch('抽卡记录')
|
@import_gacha_log.handle()
|
||||||
async def send_gacha_log_card_info(bot: HoshinoBot, ev: CQEvent):
|
@handle_exception('导入抽卡记录')
|
||||||
|
@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:
|
|
||||||
qid = int(ev.sender['user_id'])
|
|
||||||
else:
|
|
||||||
return
|
|
||||||
uid = await select_db(qid, mode='uid')
|
|
||||||
|
|
||||||
|
uid = await select_db(event.user_id, mode='uid')
|
||||||
if isinstance(uid, str):
|
if isinstance(uid, str):
|
||||||
im = await draw_gachalogs_img(uid, qid)
|
im = await draw_gachalogs_img(uid, event.user_id)
|
||||||
if isinstance(im, bytes):
|
if isinstance(im, bytes):
|
||||||
im = await convert_img(im)
|
await matcher.finish(MessageSegment.image(im))
|
||||||
await bot.send(ev, im)
|
|
||||||
else:
|
else:
|
||||||
await bot.send(ev, im)
|
await matcher.finish(im)
|
||||||
else:
|
else:
|
||||||
await bot.send(ev, UID_HINT)
|
await matcher.finish(UID_HINT)
|
||||||
|
|
||||||
|
|
||||||
@sv.on_fullmatch(('刷新抽卡记录', '强制刷新抽卡记录'))
|
@get_gacha_log.handle()
|
||||||
async def send_daily_info(bot: HoshinoBot, ev: CQEvent):
|
@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_daily_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'])
|
|
||||||
else:
|
|
||||||
return
|
|
||||||
uid = await select_db(qid, mode='uid')
|
|
||||||
if isinstance(uid, str):
|
if isinstance(uid, str):
|
||||||
is_force = False
|
is_force = False
|
||||||
if ev.raw_message and str(ev.raw_message).startswith('强制'):
|
if event.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 bot.send(ev, im)
|
await matcher.finish(im)
|
||||||
else:
|
else:
|
||||||
await bot.send(ev, UID_HINT)
|
await matcher.finish(UID_HINT)
|
||||||
|
43
GenshinUID/genshinuid_gachaurl/__init__.py
Normal file
43
GenshinUID/genshinuid_gachaurl/__init__.py
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
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))
|
53
GenshinUID/genshinuid_gachaurl/gacha_url.py
Normal file
53
GenshinUID/genshinuid_gachaurl/gacha_url.py
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
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,28 +1,41 @@
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
from hoshino.typing import CQEvent, HoshinoBot
|
from nonebot import on_command
|
||||||
|
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 ..base import sv, logger
|
from ..config import priority
|
||||||
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.draw_image_tools.send_image_tool import convert_img
|
from ..utils.message.get_image_and_at import ImageAndAt
|
||||||
|
from ..utils.message.error_reply import CK_HINT, UID_HINT
|
||||||
|
from ..utils.exception.handle_exception import handle_exception
|
||||||
|
|
||||||
|
get_gcg_info = on_command('七圣召唤', aliases={'七圣', '召唤'}, priority=priority)
|
||||||
|
|
||||||
|
|
||||||
@sv.on_prefix(('七圣召唤', '七圣', '召唤'))
|
# 群聊内 每月统计 功能
|
||||||
async def send_gcg_pic(bot: HoshinoBot, ev: CQEvent):
|
@get_gcg_info.handle()
|
||||||
if ev.message:
|
@handle_exception('七圣召唤', '获取/发送七圣召唤失败', '@未找到绑定信息\n' + CK_HINT)
|
||||||
raw_mes = ev.message.extract_plain_text().replace(' ', '')
|
async def send_gcg_pic(
|
||||||
else:
|
event: MessageEvent,
|
||||||
|
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 = int(at.group(1))
|
qid = at
|
||||||
else:
|
else:
|
||||||
qid = int(ev.sender['user_id'])
|
qid = event.user_id
|
||||||
logger.info('[七圣召唤]QQ: {}'.format(qid))
|
logger.info('[七圣召唤]QQ: {}'.format(qid))
|
||||||
|
|
||||||
# 获取uid
|
# 获取uid
|
||||||
@ -32,18 +45,16 @@ async def send_gcg_pic(bot: HoshinoBot, ev: CQEvent):
|
|||||||
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 bot.send(ev, UID_HINT)
|
await matcher.finish(UID_HINT)
|
||||||
|
|
||||||
im = await draw_gcg_info(uid)
|
im = await draw_gcg_info(uid)
|
||||||
|
|
||||||
if isinstance(im, str):
|
if isinstance(im, str):
|
||||||
await bot.send(ev, im)
|
await matcher.finish(im)
|
||||||
elif isinstance(im, bytes):
|
elif isinstance(im, bytes):
|
||||||
im = await convert_img(im)
|
await matcher.finish(MessageSegment.image(im))
|
||||||
await bot.send(ev, im)
|
|
||||||
else:
|
else:
|
||||||
await bot.send(ev, '发生了未知错误,请联系管理员检查后台输出!')
|
await matcher.finish('发生了未知错误,请联系管理员检查后台输出!')
|
||||||
|
@ -1,96 +1,132 @@
|
|||||||
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 hoshino.typing import CQEvent, HoshinoBot
|
from nonebot.log import logger
|
||||||
|
from nonebot.matcher import Matcher
|
||||||
|
from nonebot import on_regex, on_command
|
||||||
|
from nonebot.params import CommandArg, RegexGroup
|
||||||
|
from nonebot.adapters.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.draw_image_tools.send_image_tool import convert_img
|
from ..utils.exception.handle_exception import handle_exception
|
||||||
|
|
||||||
|
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'
|
||||||
|
|
||||||
|
|
||||||
@sv.on_rex('([\u4e00-\u9fa5]+)(推荐|攻略)')
|
@get_guide_pic.handle()
|
||||||
async def send_guide_pic(bot: HoshinoBot, ev: CQEvent):
|
@handle_exception('建议')
|
||||||
if ev.message:
|
@register_menu(
|
||||||
name = name = str(ev['match'].group(1))
|
'角色攻略',
|
||||||
else:
|
'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_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))
|
||||||
im = await convert_img(im)
|
await matcher.finish(MessageSegment.image(im))
|
||||||
await bot.send(ev, im)
|
|
||||||
else:
|
else:
|
||||||
logger.warning('未找到{}攻略图片'.format(name))
|
logger.warning('未找到{}攻略图片'.format(name))
|
||||||
|
|
||||||
|
|
||||||
@sv.on_prefix('参考面板')
|
@get_bluekun_pic.handle()
|
||||||
async def send_bluekun_pic(bot: HoshinoBot, ev: CQEvent):
|
@handle_exception('参考面板')
|
||||||
if ev.message:
|
@register_menu(
|
||||||
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:
|
||||||
return
|
name = await alias_to_char_name(str(args[0]))
|
||||||
|
|
||||||
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():
|
||||||
img = await convert_img(img)
|
with open(img, 'rb') as f:
|
||||||
|
im = MessageSegment.image(f.read())
|
||||||
logger.info('获得{}参考面板图片成功!'.format(name))
|
logger.info('获得{}参考面板图片成功!'.format(name))
|
||||||
await bot.send(ev, img)
|
await matcher.finish(im)
|
||||||
else:
|
else:
|
||||||
logger.warning('未找到{}参考面板图片'.format(name))
|
logger.warning('未找到{}参考面板图片'.format(name))
|
||||||
|
|
||||||
|
|
||||||
@sv.on_prefix('原牌')
|
@get_card.handle()
|
||||||
async def send_gscard_pic(bot: HoshinoBot, ev: CQEvent):
|
@handle_exception('原牌')
|
||||||
if ev.message:
|
async def send_gscard_pic(matcher: Matcher, args: Message = CommandArg()):
|
||||||
name = ev.message.extract_plain_text().replace(' ', '')
|
if not args:
|
||||||
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))
|
||||||
im = await convert_img(im)
|
await matcher.finish(MessageSegment.image(im))
|
||||||
await bot.send(ev, im)
|
|
||||||
else:
|
else:
|
||||||
logger.warning('未找到{}原牌图片'.format(name))
|
logger.warning('未找到{}原牌图片'.format(name))
|
||||||
|
|
||||||
|
|
||||||
@sv.on_prefix('版本深渊')
|
@get_abyss.handle()
|
||||||
async def send_abyss_review(bot: HoshinoBot, ev: CQEvent):
|
@handle_exception('原牌')
|
||||||
if ev.message:
|
async def send_abyss_review(
|
||||||
version = ev.message.extract_plain_text().replace(' ', '')
|
bot: Bot,
|
||||||
else:
|
event: GroupMessageEvent,
|
||||||
return
|
matcher: Matcher,
|
||||||
|
args: Message = CommandArg(),
|
||||||
if version == '':
|
):
|
||||||
|
if not args:
|
||||||
version = Genshin_version[:-2]
|
version = Genshin_version[:-2]
|
||||||
|
else:
|
||||||
|
version = str(args[0])
|
||||||
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:
|
||||||
@ -104,14 +140,16 @@ async def send_abyss_review(bot: HoshinoBot, ev: CQEvent):
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
await bot.send_group_forward_msg(group_id=ev.group_id, messages=mes)
|
await bot.call_api(
|
||||||
|
'send_group_forward_msg', group_id=event.group_id, messages=mes
|
||||||
|
)
|
||||||
|
await matcher.finish()
|
||||||
elif isinstance(im, str):
|
elif isinstance(im, str):
|
||||||
await bot.send(ev, im)
|
await matcher.finish(im)
|
||||||
elif isinstance(im, bytes):
|
elif isinstance(im, bytes):
|
||||||
im = await convert_img(im)
|
await matcher.finish(MessageSegment.image(im))
|
||||||
await bot.send(ev, im)
|
|
||||||
else:
|
else:
|
||||||
await bot.send(ev, '发生了未知错误,请联系管理员检查后台输出!')
|
await matcher.finish('发生了未知错误,请联系管理员检查后台输出!')
|
||||||
|
|
||||||
|
|
||||||
threading.Thread(
|
threading.Thread(
|
||||||
|
@ -2,18 +2,37 @@ import asyncio
|
|||||||
import threading
|
import threading
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from ..base import sv, logger
|
from nonebot import on_command
|
||||||
|
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 ..utils.draw_image_tools.send_image_tool import convert_img
|
from ..genshinuid_meta import register_menu
|
||||||
|
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'
|
||||||
|
|
||||||
|
|
||||||
@sv.on_fullmatch(('gs帮助', 'genshin帮助', 'ys帮助', '原神帮助'))
|
@get_help.handle()
|
||||||
async def send_guide_pic(bot, ev):
|
@handle_exception('建议')
|
||||||
img = await convert_img(HELP_IMG)
|
@register_menu(
|
||||||
|
'插件帮助',
|
||||||
|
'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帮助图片成功!')
|
||||||
await bot.send(ev, img)
|
if HELP_IMG.exists():
|
||||||
|
with open(HELP_IMG, 'rb') as f:
|
||||||
|
await matcher.finish(MessageSegment.image(f.read()))
|
||||||
|
else:
|
||||||
|
await matcher.finish('帮助图不存在!')
|
||||||
|
|
||||||
|
|
||||||
threading.Thread(
|
threading.Thread(
|
||||||
|
@ -1,8 +1,29 @@
|
|||||||
from hoshino.typing import CQEvent, HoshinoBot
|
from typing import Any, Dict, Union
|
||||||
|
|
||||||
from ..base import sv, logger
|
from nonebot.log import logger
|
||||||
|
from nonebot.matcher import Matcher
|
||||||
|
from nonebot.params import RegexDict
|
||||||
|
from nonebot import on_regex, on_command
|
||||||
|
from nonebot.permission import SUPERUSER
|
||||||
|
from nonebot.adapters.onebot.v11 import (
|
||||||
|
Bot,
|
||||||
|
MessageSegment,
|
||||||
|
GroupMessageEvent,
|
||||||
|
PrivateMessageEvent,
|
||||||
|
)
|
||||||
|
|
||||||
|
from ..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.draw_image_tools.send_image_tool import convert_img
|
from ..utils.exception.handle_exception import handle_exception
|
||||||
|
|
||||||
|
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', # 提瓦特
|
||||||
@ -18,13 +39,31 @@ MAP_CHN_NAME = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@sv.on_fullmatch('切换地图')
|
@change_map.handle()
|
||||||
async def send_change_map_msg(bot: HoshinoBot, ev: CQEvent):
|
@handle_exception('切换地图')
|
||||||
if ev.sender:
|
@register_menu(
|
||||||
qid = int(ev.sender['user_id'])
|
'切换地图',
|
||||||
else:
|
'切换地图',
|
||||||
return
|
'切换查找资源点功能所使用的地图',
|
||||||
if qid not in bot.config.SUPERUSERS:
|
detail_des=(
|
||||||
|
'介绍:\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])
|
||||||
@ -32,44 +71,67 @@ async def send_change_map_msg(bot: HoshinoBot, ev: CQEvent):
|
|||||||
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 bot.send(ev, f'切换到{chn}地图')
|
await matcher.finish(f'切换到{chn}地图')
|
||||||
|
|
||||||
|
|
||||||
@sv.on_rex(r'^(?P<name>.*)(在哪里|在哪|哪里有|哪儿有|哪有|在哪儿)$')
|
@find_map.handle()
|
||||||
@sv.on_rex(r'^(哪里有|哪儿有|哪有)(?P<name>.*)$')
|
@find_map2.handle()
|
||||||
async def send_find_map_msg(bot: HoshinoBot, ev: CQEvent):
|
@handle_exception('查找资源点')
|
||||||
|
@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:
|
if not (args and (name := args.get('name'))):
|
||||||
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}_{args}.jpg'
|
resource_temp_path = MAP_DATA / f'{map_name}_{name}.jpg'
|
||||||
if resource_temp_path.exists():
|
if resource_temp_path.exists():
|
||||||
logger.info(f'本地已有{map_name}_{args}的资源点,直接发送...')
|
logger.info(f'本地已有{map_name}_{name}的资源点,直接发送...')
|
||||||
resource_temp = await convert_img(resource_temp_path)
|
with open(resource_temp_path, 'rb') as f:
|
||||||
await bot.send(ev, resource_temp)
|
await matcher.finish(MessageSegment.image(f.read()))
|
||||||
else:
|
else:
|
||||||
# 放弃安慰剂回复
|
# 放弃安慰剂回复
|
||||||
'''
|
'''
|
||||||
await bot.send(
|
await matcher.send(
|
||||||
ev,
|
(
|
||||||
f'正在查找{args},可能需要比较久的时间...\n当前地图:{map_name}',
|
f'正在查找{name},可能需要比较久的时间...\n'
|
||||||
|
f'当前地图:{MAP_CHN_NAME.get(MAP_ID_LIST[0])}'
|
||||||
|
)
|
||||||
)
|
)
|
||||||
'''
|
'''
|
||||||
logger.info('本地未缓存,正在渲染...')
|
logger.info('本地未缓存,正在渲染...')
|
||||||
im = await draw_genshin_map(args, map_id, map_name)
|
im = await draw_genshin_map(name, map_id, map_name)
|
||||||
if isinstance(im, str):
|
if isinstance(im, str):
|
||||||
return
|
# 如果无结果,直接不返回
|
||||||
# await bot.send(ev, im)
|
await matcher.finish()
|
||||||
elif isinstance(im, bytes):
|
elif isinstance(im, bytes):
|
||||||
im = await convert_img(im)
|
await matcher.finish(MessageSegment.image(im))
|
||||||
await bot.send(ev, im)
|
else:
|
||||||
|
await matcher.finish('查找失败!')
|
||||||
|
54
GenshinUID/genshinuid_meta/__init__.py
Normal file
54
GenshinUID/genshinuid_meta/__init__.py
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
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,35 +1,75 @@
|
|||||||
import random
|
import random
|
||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
from nonebot import get_bot
|
from nonebot.log import logger
|
||||||
from hoshino.typing import CQEvent, HoshinoBot
|
from nonebot.matcher import Matcher
|
||||||
|
from nonebot import get_bot, on_command
|
||||||
|
from nonebot.permission import SUPERUSER
|
||||||
|
from nonebot_plugin_apscheduler import scheduler
|
||||||
|
from nonebot.adapters.onebot.v11 import MessageEvent
|
||||||
|
|
||||||
from ..base import sv, logger
|
from ..config import priority
|
||||||
|
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()
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
# 获取米游币
|
# 获取米游币
|
||||||
@sv.on_fullmatch('开始获取米游币')
|
@get_mihoyo_coin.handle()
|
||||||
async def send_mihoyo_coin(bot: HoshinoBot, ev: CQEvent):
|
@handle_exception('获取米游币')
|
||||||
await bot.send(ev, '开始操作……', at_sender=True)
|
@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_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 bot.send(ev, im, at_sender=True)
|
await matcher.finish(im, at_sender=True)
|
||||||
|
|
||||||
|
|
||||||
@sv.on_fullmatch('全部重获取')
|
@all_bbscoin_recheck.handle()
|
||||||
async def bbs_recheck(bot: HoshinoBot, ev: CQEvent):
|
@handle_exception('米游币全部重获取')
|
||||||
qid = int(ev.sender['user_id']) # type: ignore
|
@register_menu(
|
||||||
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 bot.send(ev, '执行完成!')
|
await matcher.finish('执行完成!')
|
||||||
|
|
||||||
|
|
||||||
# 每日一点十六分进行米游币获取
|
# 每日一点十六分进行米游币获取
|
||||||
@sv.scheduled_job('cron', hour='1', minute='16')
|
@bbscoin_scheduler.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()
|
||||||
@ -45,7 +85,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 bot.config.SUPERUSERS:
|
for qid in get_superusers():
|
||||||
await bot.send_private_msg(user_id=qid, message=im)
|
await bot.call_api(api='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,39 +1,104 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
|
from typing import Any, Tuple
|
||||||
|
|
||||||
from hoshino.typing import CQEvent, HoshinoBot
|
from nonebot.log import logger
|
||||||
|
from nonebot.matcher import Matcher
|
||||||
|
from nonebot.params import RegexGroup
|
||||||
|
from nonebot import on_regex, on_command
|
||||||
|
from nonebot.adapters.onebot.v11 import (
|
||||||
|
Bot,
|
||||||
|
MessageEvent,
|
||||||
|
MessageSegment,
|
||||||
|
GroupMessageEvent,
|
||||||
|
)
|
||||||
|
|
||||||
from ..base import sv, logger
|
from ..config import priority
|
||||||
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.draw_image_tools.send_image_tool import convert_img
|
from ..utils.exception.handle_exception import handle_exception
|
||||||
|
|
||||||
|
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())
|
||||||
|
|
||||||
|
|
||||||
@sv.on_rex(r'^(原神任务|任务|任务详情|任务攻略)( )?([\u4e00-\u9fa5]+)( )?$')
|
@get_task_adv.handle()
|
||||||
async def send_task_adv(bot: HoshinoBot, ev: CQEvent):
|
@handle_exception('任务攻略')
|
||||||
args = ev['match'].groups()
|
@register_menu(
|
||||||
|
'任务攻略',
|
||||||
|
'任务xx',
|
||||||
|
'查询某任务的攻略',
|
||||||
|
detail_des=(
|
||||||
|
'介绍:\n'
|
||||||
|
'查询指定任务或指定地区的攻略\n'
|
||||||
|
' \n'
|
||||||
|
'指令:\n'
|
||||||
|
'- <ft color=(238,120,0)>{原神任务|任务|任务详情|任务攻略}</ft>'
|
||||||
|
'<ft color=(238,120,0)>{</ft>'
|
||||||
|
'<ft color=(0,148,200)>[任务名]</ft>'
|
||||||
|
'<ft color=(238,120,0)>|须弥|层岩|海岛}</ft>\n'
|
||||||
|
' \n'
|
||||||
|
'示例:\n'
|
||||||
|
'- <ft color=(238,120,0)>任务神樱大祓</ft>\n'
|
||||||
|
'- <ft color=(238,120,0)>任务须弥</ft>'
|
||||||
|
),
|
||||||
|
)
|
||||||
|
async def send_task_adv(
|
||||||
|
bot: Bot,
|
||||||
|
event: 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.send_group_forward_msg(group_id=ev.group_id, messages=i)
|
await bot.call_api(
|
||||||
|
'send_group_forward_msg', group_id=event.group_id, messages=i
|
||||||
|
)
|
||||||
await asyncio.sleep(1)
|
await asyncio.sleep(1)
|
||||||
return
|
await matcher.finish()
|
||||||
else:
|
else:
|
||||||
im = await get_task_detail(str(args[2]))
|
im = await get_task_detail(str(args[2]))
|
||||||
await bot.send(ev, im)
|
await matcher.finish(im)
|
||||||
|
|
||||||
|
|
||||||
@sv.on_fullmatch('抽表情')
|
@get_meme.handle()
|
||||||
async def send_meme_card(bot: HoshinoBot, ev: CQEvent):
|
@handle_exception('抽表情')
|
||||||
|
@register_menu(
|
||||||
|
'抽表情',
|
||||||
|
'抽表情',
|
||||||
|
'随机发送一张札记角色表情',
|
||||||
|
detail_des=(
|
||||||
|
'介绍:\n'
|
||||||
|
'随机发送一张札记角色表情\n'
|
||||||
|
' \n'
|
||||||
|
'指令:\n'
|
||||||
|
'- <ft color=(238,120,0)>抽表情</ft>'
|
||||||
|
),
|
||||||
|
)
|
||||||
|
async def send_meme_card(matcher: Matcher):
|
||||||
logger.info('开始执行[抽表情]')
|
logger.info('开始执行[抽表情]')
|
||||||
img = await get_meme_img()
|
img = await get_meme_img()
|
||||||
img = await convert_img(img)
|
await matcher.finish(MessageSegment.image(img))
|
||||||
await bot.send(ev, img)
|
|
||||||
|
|
||||||
|
|
||||||
@sv.on_fullmatch('御神签')
|
@get_lots.handle()
|
||||||
async def send_lots_data(bot: HoshinoBot, ev: CQEvent):
|
@handle_exception('御神签')
|
||||||
qid = int(ev.sender['user_id'])
|
@register_menu(
|
||||||
|
'御神签',
|
||||||
|
'御神签',
|
||||||
|
'鸣神大社御神签',
|
||||||
|
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 bot.send(ev, im)
|
await matcher.finish(im)
|
||||||
|
@ -1,48 +1,82 @@
|
|||||||
import re
|
from nonebot import on_command
|
||||||
|
from nonebot.log import logger
|
||||||
from hoshino.typing import CQEvent, HoshinoBot
|
from nonebot.matcher import Matcher
|
||||||
|
from nonebot.adapters.onebot.v11 import MessageEvent, MessageSegment
|
||||||
|
|
||||||
from .note_text import award
|
from .note_text import award
|
||||||
from ..base import sv, logger
|
from ..config import priority
|
||||||
from .draw_note_card import draw_note_img
|
from .draw_note_card import draw_note_img
|
||||||
from ..utils.message.error_reply import UID_HINT
|
from ..genshinuid_meta import register_menu
|
||||||
|
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.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
|
||||||
|
|
||||||
|
monthly_data = on_command('每月统计', priority=priority, rule=FullCommand())
|
||||||
|
get_genshin_info = on_command(
|
||||||
|
'当前信息', aliases={'zj', '札记', '原石札记'}, priority=priority, rule=FullCommand()
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
# 群聊内 每月统计 功能
|
# 群聊内 每月统计 功能
|
||||||
@sv.on_fullmatch('每月统计')
|
@monthly_data.handle()
|
||||||
async def send_monthly_data(bot: HoshinoBot, ev: CQEvent):
|
@handle_exception('每月统计', '获取/发送每月统计失败', '@未找到绑定信息\n' + CK_HINT)
|
||||||
qid = int(ev.sender['user_id']) # type: ignore
|
@register_menu(
|
||||||
|
'文字札记',
|
||||||
|
'每月统计',
|
||||||
|
'文字形式米游社札记',
|
||||||
|
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 bot.send(ev, UID_HINT)
|
await matcher.finish(UID_HINT)
|
||||||
else:
|
else:
|
||||||
await bot.send(ev, '发生未知错误...')
|
await matcher.finish('发生未知错误...')
|
||||||
im = await award(uid)
|
im = await award(uid)
|
||||||
await bot.send(ev, im, at_sender=True)
|
await matcher.finish(im, at_sender=True)
|
||||||
|
|
||||||
|
|
||||||
@sv.on_fullmatch(('当前信息', 'zj', '原石札记', '札记'))
|
# 群聊内 每月统计 功能
|
||||||
async def send_monthly_pic(bot: HoshinoBot, ev: CQEvent):
|
@get_genshin_info.handle()
|
||||||
logger.info('开始执行[每日信息]')
|
@handle_exception('每月统计', '获取/发送每月统计失败', '@未找到绑定信息\n' + CK_HINT)
|
||||||
at = re.search(r'\[CQ:at,qq=(\d*)]', str(ev.message))
|
@register_menu(
|
||||||
if at:
|
'图片札记',
|
||||||
qid = int(at.group(1))
|
'当前信息',
|
||||||
else:
|
'图片形式米游社札记',
|
||||||
if ev.sender:
|
detail_des=(
|
||||||
qid = int(ev.sender['user_id'])
|
'介绍:\n'
|
||||||
else:
|
'图片形式米游社札记\n'
|
||||||
return
|
' \n'
|
||||||
logger.info('[每日信息]QQ号: {}'.format(qid))
|
'指令:\n'
|
||||||
|
'- <ft color=(238,120,0)>当前信息</ft>\n'
|
||||||
|
'- <ft color=(125,125,125)>(原石)</ft><ft color=(238,120,0)>札记</ft>\n'
|
||||||
|
'- <ft color=(238,120,0)>zj</ft>'
|
||||||
|
),
|
||||||
|
)
|
||||||
|
async def send_monthly_pic(
|
||||||
|
event: MessageEvent,
|
||||||
|
matcher: Matcher,
|
||||||
|
):
|
||||||
|
qid = event.user_id
|
||||||
uid = await select_db(qid, mode='uid')
|
uid = await select_db(qid, mode='uid')
|
||||||
logger.info('[每日信息]UID: {}'.format(uid))
|
if isinstance(uid, str):
|
||||||
im = await draw_note_img(str(uid))
|
if '未找到绑定的UID' in uid:
|
||||||
if isinstance(im, str):
|
await matcher.finish(UID_HINT)
|
||||||
await bot.send(ev, im)
|
|
||||||
elif isinstance(im, bytes):
|
|
||||||
im = await convert_img(im)
|
|
||||||
await bot.send(ev, im)
|
|
||||||
else:
|
else:
|
||||||
await bot.send(ev, '发生了未知错误,请联系管理员检查后台输出!')
|
await matcher.finish('发生未知错误...')
|
||||||
|
logger.info(f'[原石札记] 开始绘制,UID: {uid}')
|
||||||
|
im = await draw_note_img(uid)
|
||||||
|
if isinstance(im, str):
|
||||||
|
await matcher.finish(im)
|
||||||
|
elif isinstance(im, bytes):
|
||||||
|
await matcher.finish(MessageSegment.image(im))
|
||||||
|
else:
|
||||||
|
await matcher.finish('发生了未知错误,请联系管理员检查后台输出!')
|
||||||
|
@ -1,118 +1,140 @@
|
|||||||
import re
|
|
||||||
import asyncio
|
import asyncio
|
||||||
|
from typing import Union
|
||||||
|
|
||||||
from nonebot import get_bot
|
from nonebot.log import logger
|
||||||
from hoshino.typing import CQEvent, HoshinoBot
|
from nonebot.params import Depends
|
||||||
|
from nonebot.matcher import Matcher
|
||||||
|
from nonebot import get_bot, on_command
|
||||||
|
from nonebot_plugin_apscheduler import scheduler
|
||||||
|
from nonebot.adapters.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.draw_image_tools.send_image_tool import convert_img
|
from ..utils.message.get_image_and_at import ImageAndAt
|
||||||
|
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())
|
||||||
|
|
||||||
|
|
||||||
@sv.on_fullmatch('当前状态')
|
@get_daily_info.handle()
|
||||||
async def send_daily_info(bot: HoshinoBot, ev: CQEvent):
|
@handle_exception('每日信息文字版')
|
||||||
|
@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.group(1)
|
qid = at
|
||||||
|
|
||||||
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 '未找到绑定的UID' in uid:
|
if not uid:
|
||||||
await bot.send(ev, UID_HINT)
|
await matcher.finish(UID_HINT)
|
||||||
|
|
||||||
im = await get_resin_text(uid)
|
im = await get_resin_text(uid)
|
||||||
await bot.send(ev, im)
|
await matcher.finish(im)
|
||||||
|
|
||||||
|
|
||||||
@sv.scheduled_job('cron', minute='*/30')
|
@notice_scheduler.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]:
|
||||||
send_success = False
|
|
||||||
for sid in bot_ids:
|
|
||||||
try:
|
try:
|
||||||
await bot.send_private_msg(
|
await bot.call_api(
|
||||||
self_id=sid,
|
api='send_private_msg',
|
||||||
user_id=qid,
|
user_id=qid,
|
||||||
message=result[0][qid],
|
message=result[0][qid],
|
||||||
)
|
)
|
||||||
send_success = True
|
|
||||||
break
|
|
||||||
except Exception:
|
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]:
|
||||||
send_success = False
|
|
||||||
for sid in bot_ids:
|
|
||||||
try:
|
try:
|
||||||
await bot.send_group_msg(
|
await bot.call_api(
|
||||||
self_id=sid,
|
api='send_group_msg',
|
||||||
group_id=group_id,
|
group_id=group_id,
|
||||||
message=result[1][group_id],
|
message=result[1][group_id],
|
||||||
)
|
)
|
||||||
send_success = True
|
|
||||||
break
|
|
||||||
except Exception:
|
except Exception:
|
||||||
logger.info(f'[推送检查(轮推)] BOT {sid} 没有 {group_id} 群,已跳过')
|
logger.warning(f'[推送检查] 群 {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('[推送检查]群聊推送完成')
|
||||||
|
|
||||||
|
|
||||||
@sv.on_fullmatch(('执行推送检查任务'))
|
@get_resin_info.handle()
|
||||||
async def manual_notice_job(bot: HoshinoBot, ev: CQEvent):
|
@handle_exception('每日信息')
|
||||||
if ev.sender:
|
@register_menu(
|
||||||
qid = int(ev.sender['user_id'])
|
'图片实时便笺',
|
||||||
else:
|
'每日',
|
||||||
return
|
'图片形式米游社实时便笺',
|
||||||
if qid not in bot.config.SUPERUSERS:
|
detail_des=(
|
||||||
return
|
'介绍:\n'
|
||||||
await notice_job()
|
'图片形式米游社实时便笺\n'
|
||||||
await bot.send(ev, '推送检查任务已执行')
|
' \n'
|
||||||
|
'指令:\n'
|
||||||
|
'- <ft color=(238,120,0)>每日</ft>\n'
|
||||||
@sv.on_fullmatch(('每日', 'mr', '实时便笺', '便笺', '便签'))
|
'- <ft color=(238,120,0)>mr</ft>\n'
|
||||||
async def send_daily_info_pic(bot: HoshinoBot, ev: CQEvent):
|
'- <ft color=(238,120,0)>状态</ft>\n'
|
||||||
|
'- <ft color=(125,125,125)>(实时)</ft><ft color=(238,120,0)>便笺</ft>\n'
|
||||||
|
'- <ft color=(238,120,0)>便签</ft>'
|
||||||
|
),
|
||||||
|
)
|
||||||
|
async def send_uid_info(
|
||||||
|
event: 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 = int(at.group(1))
|
qid = at
|
||||||
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 bot.send(ev, im)
|
await matcher.finish(im)
|
||||||
elif isinstance(im, bytes):
|
elif isinstance(im, bytes):
|
||||||
im = await convert_img(im)
|
await matcher.finish(MessageSegment.image(im))
|
||||||
await bot.send(ev, im)
|
|
||||||
else:
|
else:
|
||||||
await bot.send(ev, '发生了未知错误,请联系管理员检查后台输出!')
|
await matcher.finish('发生了未知错误,请联系管理员检查后台输出!')
|
||||||
|
@ -1,25 +1,52 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
import threading
|
import threading
|
||||||
|
from typing import Union
|
||||||
|
|
||||||
from hoshino.typing import CQEvent, HoshinoBot
|
from nonebot import on_command
|
||||||
|
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 ..base import sv, logger
|
from ..genshinuid_meta import register_menu
|
||||||
|
from ..utils.nonebot2.rule import FullCommand
|
||||||
|
from ..utils.exception.handle_exception import handle_exception
|
||||||
from ..utils.download_resource.download_all_resource import (
|
from ..utils.download_resource.download_all_resource import (
|
||||||
download_all_resource,
|
download_all_resource,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
download_resource = on_command('下载全部资源', rule=FullCommand())
|
||||||
|
|
||||||
@sv.on_fullmatch('下载全部资源')
|
|
||||||
async def send_download_resource_msg(bot: HoshinoBot, ev: CQEvent):
|
@download_resource.handle()
|
||||||
if ev.sender:
|
@handle_exception('下载全部资源', '资源下载错误')
|
||||||
qid = ev.sender['user_id']
|
@register_menu(
|
||||||
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
|
||||||
if qid not in bot.config.SUPERUSERS:
|
await matcher.send('正在开始下载~可能需要较久的时间!')
|
||||||
return
|
|
||||||
await bot.send(ev, '正在开始下载~可能需要较久的时间!')
|
|
||||||
im = await download_all_resource()
|
im = await download_all_resource()
|
||||||
await bot.send(ev, im)
|
await matcher.finish(im)
|
||||||
|
|
||||||
|
|
||||||
async def startup():
|
async def startup():
|
||||||
|
@ -1,27 +1,107 @@
|
|||||||
import re
|
import re
|
||||||
|
from typing import Union
|
||||||
|
|
||||||
from hoshino.typing import CQEvent, HoshinoBot
|
from nonebot import on_command
|
||||||
|
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.mhy_api.convert_mysid_to_uid import convert_mysid
|
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
|
||||||
|
|
||||||
|
get_role_info = on_command('uid', aliases={'查询'})
|
||||||
|
get_reg_time = on_command(
|
||||||
|
'原神注册时间', aliases={'注册时间', '查询注册时间'}, rule=FullCommand()
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@sv.on_prefix(('原神注册时间', '注册时间'))
|
@get_role_info.handle()
|
||||||
async def regtime(bot, ev):
|
@handle_exception('查询角色信息')
|
||||||
at = re.search(r'\[CQ:at,qq=(\d*)]', str(ev.message))
|
@register_menu(
|
||||||
|
'查询帐号信息',
|
||||||
if at:
|
'查询',
|
||||||
qid = int(at.group(1))
|
'帐号基础数据与角色信息总览',
|
||||||
else:
|
detail_des=(
|
||||||
if ev.sender:
|
'介绍:\n'
|
||||||
qid = int(ev.sender['user_id'])
|
'查询帐号探索度、声望、宝箱收集、角色总览等等基础数据\n'
|
||||||
else:
|
'未绑定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
|
return
|
||||||
|
qid = event.user_id
|
||||||
|
at = custom.get_first_at()
|
||||||
|
if at:
|
||||||
|
qid = at
|
||||||
|
|
||||||
|
# 获取uid
|
||||||
|
uid = re.findall(r'\d+', raw_mes)
|
||||||
|
if uid:
|
||||||
|
uid = uid[0]
|
||||||
|
else:
|
||||||
|
uid = await select_db(qid, mode='uid')
|
||||||
|
uid = str(uid)
|
||||||
|
|
||||||
|
logger.info('开始执行[查询角色信息]')
|
||||||
|
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)
|
||||||
@ -30,57 +110,11 @@ async def regtime(bot, ev):
|
|||||||
logger.info('[查询注册时间]uid: {}'.format(uid))
|
logger.info('[查询注册时间]uid: {}'.format(uid))
|
||||||
|
|
||||||
if '未找到绑定的UID' in uid:
|
if '未找到绑定的UID' in uid:
|
||||||
await bot.send(ev, UID_HINT)
|
await matcher.finish(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 bot.send(ev, im)
|
await matcher.finish(im)
|
||||||
elif isinstance(im, bytes):
|
|
||||||
im = await convert_img(im)
|
|
||||||
await bot.send(ev, im)
|
|
||||||
else:
|
else:
|
||||||
await bot.send(ev, '发生了未知错误,请联系管理员检查后台输出!')
|
await matcher.finish('发生了未知错误,请联系管理员检查后台输出!')
|
||||||
|
@ -1,51 +1,88 @@
|
|||||||
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
|
||||||
|
|
||||||
import asyncio
|
from nonebot_plugin_apscheduler import scheduler
|
||||||
|
|
||||||
from nonebot import get_bot
|
from ..genshinuid_meta import register_menu
|
||||||
from hoshino.typing import CQEvent, HoshinoBot
|
from ..utils.nonebot2.rule import FullCommand
|
||||||
|
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()
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
# 每日零点半执行米游社原神签到
|
# 每日零点半执行米游社原神签到
|
||||||
@sv.scheduled_job('cron', hour='0', minute='30')
|
@sign_scheduler.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()
|
||||||
|
|
||||||
|
|
||||||
# 群聊内 签到 功能
|
# 群聊内 签到 功能
|
||||||
@sv.on_rex(r'^(gs|米游社)(签到)$')
|
@get_sign.handle()
|
||||||
async def get_sign_func(bot: HoshinoBot, ev: CQEvent):
|
@handle_exception('签到')
|
||||||
|
@register_menu(
|
||||||
|
'手动米游社原神签到',
|
||||||
|
'签到',
|
||||||
|
'手动触发米游社原神签到任务',
|
||||||
|
detail_des=(
|
||||||
|
'介绍:\n'
|
||||||
|
'手动触发米游社原神签到任务\n'
|
||||||
|
' \n'
|
||||||
|
'指令:\n'
|
||||||
|
'- <ft color=(238,120,0)>签到</ft>'
|
||||||
|
),
|
||||||
|
)
|
||||||
|
async def get_sign_func(
|
||||||
|
event: MessageEvent,
|
||||||
|
matcher: Matcher,
|
||||||
|
):
|
||||||
logger.info('开始执行[签到]')
|
logger.info('开始执行[签到]')
|
||||||
qid = int(ev.sender['user_id']) # type: ignore
|
qid = event.user_id
|
||||||
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 bot.send(ev, im, at_sender=True)
|
await matcher.finish(im, at_sender=True)
|
||||||
|
|
||||||
|
|
||||||
@sv.on_fullmatch('全部重签')
|
@all_recheck.handle()
|
||||||
async def recheck(bot: HoshinoBot, ev: CQEvent):
|
@handle_exception('全部重签')
|
||||||
if ev.sender:
|
@register_menu(
|
||||||
qid = int(ev.sender['user_id'])
|
'米游社原神重签到',
|
||||||
else:
|
'全部重签',
|
||||||
return
|
'重新运行所有自动米游社原神签到任务',
|
||||||
if qid not in bot.config.SUPERUSERS:
|
detail_des=(
|
||||||
return
|
'介绍:\n'
|
||||||
|
'重新运行所有自动米游社原神签到任务\n'
|
||||||
|
' \n'
|
||||||
|
'指令:\n'
|
||||||
|
'- <ft color=(238,120,0)>全部重签</ft>'
|
||||||
|
),
|
||||||
|
)
|
||||||
|
async def recheck(matcher: Matcher):
|
||||||
logger.info('开始执行[全部重签]')
|
logger.info('开始执行[全部重签]')
|
||||||
await bot.send(ev, '已开始执行')
|
await matcher.send('已开始执行')
|
||||||
await send_daily_sign()
|
await send_daily_sign()
|
||||||
await bot.send(ev, '执行完成')
|
await matcher.finish('执行完成')
|
||||||
|
|
||||||
|
|
||||||
async def send_daily_sign():
|
async def send_daily_sign():
|
||||||
@ -60,7 +97,8 @@ async def send_daily_sign():
|
|||||||
# 执行私聊推送
|
# 执行私聊推送
|
||||||
for qid in private_msg_list:
|
for qid in private_msg_list:
|
||||||
try:
|
try:
|
||||||
await bot.send_private_msg(
|
await bot.call_api(
|
||||||
|
api='send_private_msg',
|
||||||
user_id=qid,
|
user_id=qid,
|
||||||
message=private_msg_list[qid],
|
message=private_msg_list[qid],
|
||||||
)
|
)
|
||||||
@ -87,7 +125,8 @@ 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.send_group_msg(
|
await bot.call_api(
|
||||||
|
api='send_group_msg',
|
||||||
group_id=gid,
|
group_id=gid,
|
||||||
message=msg_title,
|
message=msg_title,
|
||||||
)
|
)
|
||||||
|
@ -1,78 +1,131 @@
|
|||||||
from nonebot import get_bot, on_startup
|
from typing import Any, Tuple
|
||||||
from hoshino.typing import CQEvent, HoshinoBot
|
|
||||||
|
|
||||||
from ..base import sv, logger
|
from nonebot.log import logger
|
||||||
|
from nonebot.matcher import Matcher
|
||||||
|
from nonebot.params import RegexGroup
|
||||||
|
from nonebot.permission import SUPERUSER
|
||||||
|
from nonebot import get_bot, on_regex, get_driver, 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,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@on_startup
|
driver = get_driver()
|
||||||
async def check_msg():
|
|
||||||
try:
|
|
||||||
|
@driver.on_bot_connect
|
||||||
|
async def _():
|
||||||
logger.info('检查遗留信息...')
|
logger.info('检查遗留信息...')
|
||||||
|
bot = get_bot()
|
||||||
update_log = await restart_message()
|
update_log = await restart_message()
|
||||||
if update_log == {}:
|
if update_log == {}:
|
||||||
return
|
return
|
||||||
bot = get_bot()
|
|
||||||
if update_log['send_type'] == 'group':
|
if update_log['send_type'] == 'group':
|
||||||
await bot.send_group_msg(
|
await bot.call_api(
|
||||||
|
api='send_group_msg',
|
||||||
group_id=update_log['send_to'],
|
group_id=update_log['send_to'],
|
||||||
message=update_log['msg'],
|
message=update_log['msg'],
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
await bot.send_private_msg(
|
await bot.call_api(
|
||||||
|
api='send_private_msg',
|
||||||
user_id=update_log['send_to'],
|
user_id=update_log['send_to'],
|
||||||
message=update_log['msg'],
|
message=update_log['msg'],
|
||||||
)
|
)
|
||||||
logger.info('遗留信息检查完毕!')
|
logger.info('遗留信息检查完毕!')
|
||||||
except Exception:
|
|
||||||
logger.warning('遗留信息检查失败!')
|
|
||||||
|
|
||||||
|
|
||||||
@sv.on_fullmatch('gs重启')
|
@get_update_log.handle()
|
||||||
async def send_restart_msg(bot: HoshinoBot, ev: CQEvent):
|
@register_menu(
|
||||||
if ev.sender:
|
'更新记录',
|
||||||
qid = int(ev.sender['user_id'])
|
'更新记录',
|
||||||
|
'查看插件最近的更新记录',
|
||||||
|
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:
|
else:
|
||||||
return
|
await matcher.finish('发生了未知错误,请联系管理员检查后台输出!')
|
||||||
if qid not in bot.config.SUPERUSERS:
|
|
||||||
|
|
||||||
|
@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 ev.group_id:
|
if len(event.get_session_id().split('_')) == 3:
|
||||||
send_id = str(ev.group_id)
|
send_id = event.get_session_id().split('_')[1]
|
||||||
send_type = 'group'
|
send_type = 'group'
|
||||||
else:
|
else:
|
||||||
send_id = qid
|
send_id = qid
|
||||||
send_type = 'private'
|
send_type = 'private'
|
||||||
await bot.send(ev, '正在执行[gs重启]...')
|
await matcher.send('正在执行[gs重启]...')
|
||||||
await restart_genshinuid(send_type, str(send_id))
|
await restart_genshinuid(send_type, str(send_id))
|
||||||
|
|
||||||
|
|
||||||
@sv.on_fullmatch('更新记录')
|
@gs_update.handle()
|
||||||
async def send_updatelog_msg(bot: HoshinoBot, ev: CQEvent):
|
@register_menu(
|
||||||
im = await draw_update_log_img(is_update=False)
|
'更新插件',
|
||||||
logger.info('正在执行[更新记录]...')
|
'gs更新',
|
||||||
if isinstance(im, str):
|
'手动更新插件',
|
||||||
await bot.send(ev, im)
|
detail_des=(
|
||||||
elif isinstance(im, bytes):
|
'介绍:\n'
|
||||||
im = await convert_img(im)
|
'手动更新插件(执行 git pull)\n'
|
||||||
await bot.send(ev, im)
|
'每加上一个可选参数,执行等级加1\n'
|
||||||
else:
|
'当执行等级≥1时会还原上次更改,等级≥2时会清空暂存\n'
|
||||||
await bot.send(ev, '发生了未知错误,请联系管理员检查后台输出!')
|
' \n'
|
||||||
|
'指令:\n'
|
||||||
|
'- <ft color=(238,120,0)>gs</ft>'
|
||||||
@sv.on_rex(r'^(gs)(强行)?(强制)?(更新)$')
|
'<ft color=(125,125,125)>(强行)(强制)</ft>'
|
||||||
async def send_update_msg(bot: HoshinoBot, ev: CQEvent):
|
'<ft color=(238,120,0)>更新</ft>'
|
||||||
if ev.sender:
|
),
|
||||||
qid = int(ev.sender['user_id'])
|
)
|
||||||
else:
|
async def send_update_msg(
|
||||||
return
|
bot: Bot,
|
||||||
if qid not in bot.config.SUPERUSERS:
|
event: MessageEvent,
|
||||||
|
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:
|
||||||
@ -80,12 +133,11 @@ async def send_update_msg(bot: HoshinoBot, ev: CQEvent):
|
|||||||
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 bot.send(ev, f'开始执行[gs更新], 执行等级为{level}')
|
await matcher.send(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 bot.send(ev, im)
|
await matcher.finish(im)
|
||||||
elif isinstance(im, bytes):
|
elif isinstance(im, bytes):
|
||||||
im = await convert_img(im)
|
await matcher.finish(MessageSegment.image(im))
|
||||||
await bot.send(ev, im)
|
|
||||||
else:
|
else:
|
||||||
await bot.send(ev, '发生了未知错误,请联系管理员检查后台输出!')
|
await matcher.finish('发生了未知错误,请联系管理员检查后台输出!')
|
||||||
|
@ -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() / 'run.py'
|
bot_start = Path().cwd() / 'bot.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,12 +23,12 @@ 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':
|
||||||
@ -45,11 +45,9 @@ 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':
|
||||||
subprocess.Popen(
|
os.execl(str(restart_sh_path), ' ')
|
||||||
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,103 +1,229 @@
|
|||||||
import hoshino
|
from typing import Any, Tuple
|
||||||
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 ..base import sv, logger
|
from ..config import priority
|
||||||
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 ..utils.draw_image_tools.send_image_tool import convert_img
|
from ..genshinuid_meta import register_menu
|
||||||
|
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
|
||||||
|
|
||||||
hoshino_bot = hoshino.get_bot()
|
add_cookie = on_command('添加', permission=PRIVATE_FRIEND)
|
||||||
|
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={'原神充值'})
|
||||||
|
|
||||||
|
|
||||||
@sv.on_fullmatch(('刷新全部CK', '刷新全部ck', '刷新全部Ck', '刷新全部Cookies'))
|
@get_topup.handle()
|
||||||
async def send_refresh_allck_msg(bot: HoshinoBot, ev: CQEvent):
|
async def send_topup(bot: Bot, event: GroupMessageEvent):
|
||||||
if ev.sender:
|
qid = event.user_id
|
||||||
qid = int(ev.sender['user_id'])
|
goods_id = event.raw_message.replace('原神充值', '').replace('gsrc', '')
|
||||||
|
if goods_id == "":
|
||||||
|
goods_id = 0
|
||||||
else:
|
else:
|
||||||
return
|
goods_id = int(goods_id)
|
||||||
if qid not in bot.config.SUPERUSERS:
|
group_id = event.group_id
|
||||||
return
|
await topup_(bot, qid, group_id, goods_id)
|
||||||
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, bytes):
|
if isinstance(im, str):
|
||||||
im = await convert_img(im)
|
await matcher.finish(im)
|
||||||
await bot.send(ev, im)
|
await matcher.finish(MessageSegment.image(im))
|
||||||
|
|
||||||
|
|
||||||
@sv.on_fullmatch(('刷新CK', '刷新ck', '刷新Ck', '刷新Cookies'))
|
@refresh_ck.handle()
|
||||||
async def send_refresh_ck_msg(bot: HoshinoBot, ev: CQEvent):
|
async def send_refresh_ck_msg(
|
||||||
logger.info('开始执行[刷新ck]')
|
event: MessageEvent,
|
||||||
if ev.sender:
|
matcher: Matcher,
|
||||||
qid = ev.sender['user_id']
|
):
|
||||||
else:
|
logger.info('开始执行[刷新CK]')
|
||||||
return
|
qid = event.user_id
|
||||||
im = await get_ck_by_stoken(qid)
|
im = await get_ck_by_stoken(qid)
|
||||||
if isinstance(im, bytes):
|
if isinstance(im, str):
|
||||||
im = await convert_img(im)
|
await matcher.finish(im)
|
||||||
await bot.send(ev, im)
|
await matcher.finish(MessageSegment.image(im))
|
||||||
|
|
||||||
|
|
||||||
@sv.on_fullmatch('绑定信息')
|
@get_qrcode_login.handle()
|
||||||
async def send_bind_card(bot: HoshinoBot, ev: CQEvent):
|
async def send_qrcode_login(
|
||||||
logger.info('开始执行[查询用户绑定状态]')
|
bot: Bot,
|
||||||
if ev.sender:
|
event: GroupMessageEvent,
|
||||||
qid = ev.sender['user_id']
|
matcher: Matcher,
|
||||||
else:
|
):
|
||||||
return
|
logger.info('开始执行[扫码登陆]')
|
||||||
im = await get_user_card(qid)
|
qid = event.user_id
|
||||||
im = await convert_img(im)
|
groupid = event.group_id
|
||||||
logger.info('[查询用户绑定状态]完成!等待图片发送中...')
|
im = await qrcode_login(bot, groupid, qid)
|
||||||
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, ev.user_id) # type: ignore
|
im = await deal_ck(im, qid)
|
||||||
if isinstance(im, bytes):
|
await matcher.finish(MessageSegment.image(im))
|
||||||
im = await convert_img(im)
|
|
||||||
await bot.send(ev, im)
|
|
||||||
|
|
||||||
|
|
||||||
@hoshino_bot.on_message('private') # type: ignore
|
@bind_info.handle()
|
||||||
async def send_add_ck_msg(ctx):
|
@register_menu(
|
||||||
message = ctx['raw_message']
|
'绑定状态',
|
||||||
sid = int(ctx['self_id'])
|
'绑定信息',
|
||||||
userid = int(ctx['sender']['user_id'])
|
'查询你绑定UID的绑定和推送状态',
|
||||||
gid = 0
|
detail_des=(
|
||||||
if message.startswith('添加'):
|
'介绍:\n'
|
||||||
message = message.replace('添加', '').replace(' ', '')
|
'查询你绑定的UID列表以及它们的CK、SK绑定状态和推送设置\n'
|
||||||
im = await deal_ck(message, userid) # type: ignore
|
' \n'
|
||||||
else:
|
'指令:\n'
|
||||||
return
|
'- <ft color=(238,120,0)>绑定信息</ft>'
|
||||||
if isinstance(im, bytes):
|
),
|
||||||
im = await convert_img(im)
|
)
|
||||||
await hoshino_bot.send_msg(
|
async def send_bind_card(
|
||||||
self_id=sid, user_id=userid, group_id=gid, message=im
|
event: MessageEvent,
|
||||||
)
|
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号上
|
||||||
@sv.on_rex(r'^(绑定|切换|解绑|删除)(uid|UID|mys|MYS)([0-9]+)?$')
|
@bind.handle()
|
||||||
async def send_link_uid_msg(bot: HoshinoBot, ev: CQEvent):
|
@handle_exception('绑定ID', '绑定ID异常')
|
||||||
args = ev['match'].groups()
|
@register_menu(
|
||||||
|
'绑定UID',
|
||||||
|
'绑定xx',
|
||||||
|
'绑定原神UID或米游社UID',
|
||||||
|
detail_des=(
|
||||||
|
'介绍:\n'
|
||||||
|
'绑定原神UID或米游社UID\n'
|
||||||
|
' \n'
|
||||||
|
'指令:\n'
|
||||||
|
'- <ft color=(238,120,0)>绑定'
|
||||||
|
'{uid</ft><ft color=(0,148,200)>[原神UID]</ft>'
|
||||||
|
'<ft color=(238,120,0)>|mys</ft><ft color=(0,148,200)>[米游社UID]</ft>'
|
||||||
|
'<ft color=(238,120,0)>}</ft>'
|
||||||
|
),
|
||||||
|
)
|
||||||
|
@register_menu(
|
||||||
|
'解绑UID',
|
||||||
|
'解绑xx',
|
||||||
|
'解绑原神UID或米游社UID',
|
||||||
|
detail_des=(
|
||||||
|
'介绍:\n'
|
||||||
|
'解绑原神UID或米游社UID\n'
|
||||||
|
' \n'
|
||||||
|
'指令:\n'
|
||||||
|
'- <ft color=(238,120,0)>{解绑|删除}'
|
||||||
|
'{uid</ft><ft color=(0,148,200)>[原神UID]</ft>'
|
||||||
|
'<ft color=(238,120,0)>|mys</ft><ft color=(0,148,200)>[米游社UID]</ft>'
|
||||||
|
'<ft color=(238,120,0)>}</ft>'
|
||||||
|
),
|
||||||
|
)
|
||||||
|
@register_menu(
|
||||||
|
'切换UID',
|
||||||
|
'切换xx',
|
||||||
|
'切换当前原神UID或米游社UID',
|
||||||
|
detail_des=(
|
||||||
|
'介绍:\n'
|
||||||
|
'切换当前原神UID或米游社UID\n'
|
||||||
|
'绑定一个UID的情况下无法切换\n'
|
||||||
|
' \n'
|
||||||
|
'指令:\n'
|
||||||
|
'- <ft color=(238,120,0)>切换'
|
||||||
|
'{uid</ft><ft color=(0,148,200)>[原神UID]</ft>'
|
||||||
|
'<ft color=(238,120,0)>|mys</ft><ft color=(0,148,200)>[米游社UID]</ft>'
|
||||||
|
'<ft color=(238,120,0)>}</ft>'
|
||||||
|
),
|
||||||
|
)
|
||||||
|
async def send_link_uid_msg(
|
||||||
|
event: MessageEvent, matcher: Matcher, args: Tuple[Any, ...] = RegexGroup()
|
||||||
|
):
|
||||||
logger.info('开始执行[绑定/解绑用户信息]')
|
logger.info('开始执行[绑定/解绑用户信息]')
|
||||||
logger.info('[绑定/解绑]参数: {}'.format(str(args)))
|
logger.info('[绑定/解绑]参数: {}'.format(args))
|
||||||
if ev.sender:
|
qid = event.user_id
|
||||||
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 bot.send(ev, '请输入正确的uid或者mysid!')
|
await matcher.finish('请输入正确的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])
|
||||||
@ -110,11 +236,11 @@ async def send_link_uid_msg(bot: HoshinoBot, ev: CQEvent):
|
|||||||
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 bot.send(ev, im, at_sender=True)
|
await matcher.finish(im, at_sender=True)
|
||||||
|
|
||||||
|
|
||||||
@sv.on_fullmatch(('绑定ck说明', 'ck帮助', '绑定ck'))
|
@get_ck_msg.handle()
|
||||||
async def send_ck_msg(bot: HoshinoBot, ev: CQEvent):
|
async def send_ck_help(bot: Bot, event: GroupMessageEvent):
|
||||||
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:
|
||||||
@ -124,18 +250,6 @@ async def send_ck_msg(bot: HoshinoBot, ev: CQEvent):
|
|||||||
"data": {"name": "小冰", "uin": "2854196306", "content": msg},
|
"data": {"name": "小冰", "uin": "2854196306", "content": msg},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
await bot.send_group_forward_msg(
|
await bot.call_api(
|
||||||
group_id=ev.group_id, messages=forward_msg
|
'send_group_forward_msg', group_id=event.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,6 +7,7 @@ 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
|
||||||
@ -30,15 +31,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=qrcode.constants.ERROR_CORRECT_L,
|
error_correction=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")
|
img.save(img_byte, format='PNG') # type: ignore
|
||||||
img_byte = img_byte.getvalue()
|
img_byte = img_byte.getvalue()
|
||||||
return base64.b64encode(img_byte).decode()
|
return base64.b64encode(img_byte).decode()
|
||||||
|
|
||||||
@ -50,50 +51,57 @@ 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.warn("二维码已过期")
|
logger.warning('二维码已过期')
|
||||||
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_action(
|
await bot.call_api(
|
||||||
action='send_group_msg',
|
api='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(qrc)
|
im.append(
|
||||||
im.append(disnote)
|
f'[CQ:image,file=base64://{get_qrcode_base64(code_data["url"])}]'
|
||||||
|
)
|
||||||
|
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.warn(f"[扫码登录] {group_id} 图片发送失败")
|
logger.warning(f'[扫码登录] {user_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']
|
||||||
@ -116,6 +124,7 @@ 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,6 +5,7 @@ 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
|
||||||
@ -19,7 +20,7 @@ disnote = '''免责声明:
|
|||||||
def get_qrcode_base64(url):
|
def get_qrcode_base64(url):
|
||||||
qr = qrcode.QRCode(
|
qr = qrcode.QRCode(
|
||||||
version=1,
|
version=1,
|
||||||
error_correction=qrcode.constants.ERROR_CORRECT_L,
|
error_correction=ERROR_CORRECT_L,
|
||||||
box_size=10,
|
box_size=10,
|
||||||
border=4,
|
border=4,
|
||||||
)
|
)
|
||||||
@ -27,7 +28,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")
|
img.save(img_byte, format="PNG") # type: ignore
|
||||||
img_byte = img_byte.getvalue()
|
img_byte = img_byte.getvalue()
|
||||||
return base64.b64encode(img_byte).decode()
|
return base64.b64encode(img_byte).decode()
|
||||||
|
|
||||||
@ -48,12 +49,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_action(
|
await bot.call_api(
|
||||||
action='send_group_msg',
|
api='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:
|
||||||
@ -69,7 +70,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.warn(f"[充值] {group_id} {qid}")
|
logger.warning(f"[充值] {group_id} {qid}")
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
im = []
|
im = []
|
||||||
@ -88,5 +89,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.warn(f"[充值] {group_id} 图片发送失败")
|
logger.warning(f"[充值] {group_id} 图片发送失败")
|
||||||
await send_group_msg(await refresh(order, uid))
|
await send_group_msg(await refresh(order, uid))
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
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
|
||||||
|
|
||||||
config = get_bot().config
|
driver = get_driver()
|
||||||
|
config = driver.config
|
||||||
|
|
||||||
|
|
||||||
async def run_webconsole():
|
async def run_webconsole():
|
||||||
@ -16,22 +17,28 @@ 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.info(
|
logger.opt(colors=True).info(
|
||||||
('WebConsole挂载成功:' f'http://{config.HOST}:{config.PORT}/genshinuid')
|
(
|
||||||
|
'WebConsole挂载成功:'
|
||||||
|
f'<blue>http://{config.host}:{config.port}/genshinuid</blue>'
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@on_startup
|
@driver.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,5 +1,6 @@
|
|||||||
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 _
|
||||||
@ -17,7 +18,6 @@ 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': 2, 'md': 4, 'valign': 'middle'}
|
{'body': [page.body], 'lg': 3, 'md': 4, 'valign': 'middle'}
|
||||||
],
|
],
|
||||||
align='center',
|
align='center',
|
||||||
valign='middle',
|
valign='middle',
|
||||||
|
@ -1,15 +1,24 @@
|
|||||||
# flake8: noqa
|
# flake8: noqa
|
||||||
import platform
|
import platform
|
||||||
|
import contextlib
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any, Set, Dict, List, Callable
|
from typing import (
|
||||||
|
TYPE_CHECKING,
|
||||||
|
Any,
|
||||||
|
Set,
|
||||||
|
List,
|
||||||
|
Union,
|
||||||
|
Callable,
|
||||||
|
Optional,
|
||||||
|
cast,
|
||||||
|
)
|
||||||
|
|
||||||
from quart import Quart
|
import fastapi_amis_admin
|
||||||
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
|
||||||
import fastapi_amis_admin # noqa: F401
|
from nonebot import get_app, get_driver
|
||||||
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
|
||||||
@ -40,8 +49,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,
|
||||||
@ -50,21 +59,32 @@ 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__(self, app: Quart, fastapi: FastAPI, routes: Set[str]) -> None:
|
def __init__(
|
||||||
|
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: Dict[str, Any], receive: Callable, send: Callable
|
self, scope: 'Scope', 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(scope, receive, send)
|
return await self.fastapi(
|
||||||
return await self.app(scope, receive, send)
|
scope, receive, send # type: ignore
|
||||||
|
)
|
||||||
|
return await self.app(scope, receive, send) # type: ignore
|
||||||
|
|
||||||
|
|
||||||
# 自定义后台管理站点
|
# 自定义后台管理站点
|
||||||
@ -89,8 +109,28 @@ class GenshinUIDAdminSite(AuthAdminSite):
|
|||||||
return app
|
return app
|
||||||
|
|
||||||
|
|
||||||
# 创建FastAPI应用
|
def get_asgi() -> Optional[AppType]:
|
||||||
app = FastAPI()
|
try:
|
||||||
|
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='',
|
||||||
@ -99,8 +139,6 @@ 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
|
|
||||||
|
|
||||||
|
|
||||||
# 显示主键
|
# 显示主键
|
||||||
@ -152,16 +190,13 @@ 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(
|
parent_id: int = Field(None, title=_('Parent'), foreign_key='auth_user.id') # type: ignore
|
||||||
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'),
|
||||||
@ -170,9 +205,10 @@ 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}/genshinuid'],
|
allow_origins=[f'http://{config.host}:{config.port}'],
|
||||||
allow_credentials=True,
|
allow_credentials=True,
|
||||||
allow_methods=['*'],
|
allow_methods=['*'],
|
||||||
allow_headers=['*'],
|
allow_headers=['*'],
|
||||||
@ -180,12 +216,17 @@ 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=');
|
||||||
@ -198,12 +239,16 @@ 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选框内');
|
||||||
@ -214,10 +259,12 @@ 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通则
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
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,9 +1,18 @@
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
from nonebot import MessageSegment
|
from nonebot import on_command
|
||||||
from hoshino.typing import CQEvent, HoshinoBot
|
from nonebot.matcher import Matcher
|
||||||
|
from nonebot.params import CommandArg
|
||||||
|
from nonebot.adapters.onebot.v11 import (
|
||||||
|
Bot,
|
||||||
|
Message,
|
||||||
|
MessageSegment,
|
||||||
|
GroupMessageEvent,
|
||||||
|
)
|
||||||
|
|
||||||
from ..base import sv
|
from ..config import priority
|
||||||
|
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,
|
||||||
@ -13,149 +22,251 @@ 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 bot.send(ev, MessageSegment.image(im))
|
await matcher.finish(MessageSegment.image(im))
|
||||||
else:
|
else:
|
||||||
if isinstance(im, str):
|
if isinstance(im, str):
|
||||||
await bot.send(ev, im)
|
await matcher.finish(im)
|
||||||
else:
|
else:
|
||||||
await bot.send(ev, MessageSegment.record(im))
|
await matcher.finish(MessageSegment.record(im))
|
||||||
|
|
||||||
|
|
||||||
@sv.on_prefix('原魔')
|
@get_enemies.handle()
|
||||||
async def send_enemies(bot: HoshinoBot, ev: CQEvent):
|
@handle_exception('怪物')
|
||||||
if ev.message:
|
@register_menu(
|
||||||
message = ev.message.extract_plain_text().replace(' ', '')
|
'怪物图鉴',
|
||||||
else:
|
'怪物xx',
|
||||||
return
|
'获取怪物Wiki',
|
||||||
if message == '':
|
detail_des=(
|
||||||
return
|
'介绍:\n'
|
||||||
|
'获取怪物Wiki\n'
|
||||||
|
' \n'
|
||||||
|
'指令:\n'
|
||||||
|
'- <ft color=(238,120,0)>怪物</ft><ft color=(0,148,200)>[怪物名称]</ft>'
|
||||||
|
),
|
||||||
|
)
|
||||||
|
async def send_enemies(matcher: Matcher, args: Message = CommandArg()):
|
||||||
|
message = args.extract_plain_text().strip().replace(' ', '')
|
||||||
im = await enemies_wiki(message)
|
im = await enemies_wiki(message)
|
||||||
await bot.send(ev, im)
|
await matcher.finish(im)
|
||||||
|
|
||||||
|
|
||||||
@sv.on_prefix('食物')
|
@get_food.handle()
|
||||||
async def send_food(bot: HoshinoBot, ev: CQEvent):
|
@handle_exception('食物')
|
||||||
if ev.message:
|
@register_menu(
|
||||||
message = ev.message.extract_plain_text().replace(' ', '')
|
'食物图鉴',
|
||||||
else:
|
'食物xx',
|
||||||
return
|
'获取食物Wiki',
|
||||||
if message == '':
|
detail_des=(
|
||||||
return
|
'介绍:\n'
|
||||||
|
'获取食物Wiki\n'
|
||||||
|
' \n'
|
||||||
|
'指令:\n'
|
||||||
|
'- <ft color=(238,120,0)>食物</ft><ft color=(0,148,200)>[食物名称]</ft>'
|
||||||
|
),
|
||||||
|
)
|
||||||
|
async def send_food(matcher: Matcher, args: Message = CommandArg()):
|
||||||
|
message = args.extract_plain_text().strip().replace(' ', '')
|
||||||
im = await foods_wiki(message)
|
im = await foods_wiki(message)
|
||||||
await bot.send(ev, im)
|
await matcher.finish(im)
|
||||||
|
|
||||||
|
|
||||||
@sv.on_prefix('圣遗物')
|
@get_artifacts.handle()
|
||||||
async def send_artifacts(bot: HoshinoBot, ev: CQEvent):
|
@handle_exception('圣遗物')
|
||||||
if ev.message:
|
@register_menu(
|
||||||
message = ev.message.extract_plain_text().replace(' ', '')
|
'圣遗物图鉴',
|
||||||
else:
|
'圣遗物xx',
|
||||||
return
|
'获取怪物Wiki',
|
||||||
if message == '':
|
detail_des=(
|
||||||
return
|
'介绍:\n'
|
||||||
|
'获取圣遗物Wiki\n'
|
||||||
|
' \n'
|
||||||
|
'指令:\n'
|
||||||
|
'- <ft color=(238,120,0)>圣遗物</ft><ft color=(0,148,200)>[圣遗物名称]</ft>'
|
||||||
|
),
|
||||||
|
)
|
||||||
|
async def send_artifacts(matcher: Matcher, args: Message = CommandArg()):
|
||||||
|
message = args.extract_plain_text().strip().replace(' ', '')
|
||||||
im = await artifacts_wiki(message)
|
im = await artifacts_wiki(message)
|
||||||
await bot.send(ev, im)
|
await matcher.finish(im)
|
||||||
|
|
||||||
|
|
||||||
@sv.on_prefix('武器')
|
@get_weapon.handle()
|
||||||
async def send_weapon(bot: HoshinoBot, ev: CQEvent):
|
@handle_exception('武器')
|
||||||
if ev.message:
|
@register_menu(
|
||||||
message = ev.message.extract_plain_text().replace(' ', '')
|
'武器图鉴',
|
||||||
else:
|
'武器xx',
|
||||||
return
|
'获取武器Wiki',
|
||||||
if message == '':
|
detail_des=(
|
||||||
return
|
'介绍:\n'
|
||||||
|
'获取武器Wiki\n'
|
||||||
|
' \n'
|
||||||
|
'指令:\n'
|
||||||
|
'- <ft color=(238,120,0)>武器</ft><ft color=(0,148,200)>[武器名称]</ft>'
|
||||||
|
'<ft color=(125,125,125)>(级数)</ft>\n'
|
||||||
|
' \n'
|
||||||
|
'示例:\n'
|
||||||
|
'- <ft color=(238,120,0)>武器雾切</ft>\n'
|
||||||
|
'- <ft color=(238,120,0)>武器无工之剑90</ft>'
|
||||||
|
),
|
||||||
|
)
|
||||||
|
async def send_weapon(matcher: Matcher, args: Message = CommandArg()):
|
||||||
|
message = args.extract_plain_text().strip().replace(' ', '')
|
||||||
name = ''.join(re.findall('[\u4e00-\u9fa5]', message))
|
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 bot.send(ev, im)
|
await matcher.finish(im)
|
||||||
|
|
||||||
|
|
||||||
@sv.on_prefix('天赋')
|
@get_talents.handle()
|
||||||
async def send_talents(bot: HoshinoBot, ev: CQEvent):
|
@handle_exception('天赋')
|
||||||
if ev.message:
|
@register_menu(
|
||||||
message = ev.message.extract_plain_text().replace(' ', '')
|
'天赋效果',
|
||||||
else:
|
'天赋[角色][天赋序号]',
|
||||||
return
|
'查询角色天赋技能效果',
|
||||||
if message == '':
|
detail_des=(
|
||||||
return
|
'介绍:\n'
|
||||||
|
'查询角色天赋技能效果\n'
|
||||||
|
' \n'
|
||||||
|
'指令:\n'
|
||||||
|
'- <ft color=(238,120,0)>天赋</ft>'
|
||||||
|
'<ft color=(0,148,200)>[角色名称][天赋序号]</ft>\n'
|
||||||
|
' \n'
|
||||||
|
'示例:\n'
|
||||||
|
'- <ft color=(238,120,0)>天赋绫华2</ft>'
|
||||||
|
),
|
||||||
|
)
|
||||||
|
async def send_talents(
|
||||||
|
bot: Bot,
|
||||||
|
event: 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.send_group_forward_msg(group_id=ev.group_id, messages=im)
|
await bot.call_api(
|
||||||
|
'send_group_forward_msg', group_id=event.group_id, messages=im
|
||||||
|
)
|
||||||
|
await matcher.finish()
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
im = '参数不正确。'
|
im = '参数不正确。'
|
||||||
await bot.send(ev, im)
|
await matcher.finish(im)
|
||||||
|
|
||||||
|
|
||||||
@sv.on_prefix('角色')
|
@get_char.handle()
|
||||||
async def send_char(bot: HoshinoBot, ev: CQEvent):
|
@handle_exception('角色')
|
||||||
if ev.message:
|
@register_menu(
|
||||||
message = ev.message.extract_plain_text().replace(' ', '')
|
'角色图鉴',
|
||||||
else:
|
'角色xx',
|
||||||
return
|
'获取角色Wiki',
|
||||||
if message == '':
|
detail_des=(
|
||||||
return
|
'介绍:\n'
|
||||||
|
'获取角色Wiki\n'
|
||||||
|
' \n'
|
||||||
|
'指令:\n'
|
||||||
|
'- <ft color=(238,120,0)>角色</ft><ft color=(0,148,200)>[角色名称]</ft>'
|
||||||
|
'<ft color=(125,125,125)>(等级)</ft>\n'
|
||||||
|
' \n'
|
||||||
|
'示例:\n'
|
||||||
|
'- <ft color=(238,120,0)>角色可莉</ft>\n'
|
||||||
|
'- <ft color=(238,120,0)>角色可莉90</ft>'
|
||||||
|
),
|
||||||
|
)
|
||||||
|
async def send_char(matcher: Matcher, args: Message = CommandArg()):
|
||||||
|
message = args.extract_plain_text().strip().replace(' ', '')
|
||||||
name = ''.join(re.findall('[\u4e00-\u9fa5]', message))
|
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 bot.send(ev, im)
|
await matcher.finish(im)
|
||||||
|
|
||||||
|
|
||||||
@sv.on_prefix('材料')
|
@get_cost.handle()
|
||||||
async def send_cost(bot: HoshinoBot, ev: CQEvent):
|
@handle_exception('材料')
|
||||||
if ev.message:
|
@register_menu(
|
||||||
message = ev.message.extract_plain_text().replace(' ', '')
|
'材料图鉴',
|
||||||
else:
|
'材料xx',
|
||||||
return
|
'获取材料Wiki',
|
||||||
if message == '':
|
detail_des=(
|
||||||
return
|
'介绍:\n'
|
||||||
|
'获取材料Wiki\n'
|
||||||
|
' \n'
|
||||||
|
'指令:\n'
|
||||||
|
'- <ft color=(238,120,0)>材料</ft><ft color=(0,148,200)>[材料名称]</ft>'
|
||||||
|
),
|
||||||
|
)
|
||||||
|
async def send_cost(matcher: Matcher, args: Message = CommandArg()):
|
||||||
|
message = args.extract_plain_text().strip().replace(' ', '')
|
||||||
im = await char_wiki(message, 'costs')
|
im = await char_wiki(message, 'costs')
|
||||||
await bot.send(ev, im)
|
await matcher.finish(im)
|
||||||
|
|
||||||
|
|
||||||
@sv.on_prefix('命座')
|
@get_polar.handle()
|
||||||
async def send_polar(bot: HoshinoBot, ev: CQEvent):
|
@handle_exception('命座')
|
||||||
if ev.message:
|
@register_menu(
|
||||||
message = ev.message.extract_plain_text().replace(' ', '')
|
'角色命座图鉴',
|
||||||
else:
|
'命座[角色][等级]',
|
||||||
return
|
'获取角色命座Wiki',
|
||||||
if message == '':
|
detail_des=(
|
||||||
return
|
'介绍:\n'
|
||||||
|
'获取角色命座Wiki\n'
|
||||||
|
' \n'
|
||||||
|
'指令:\n'
|
||||||
|
'- <ft color=(238,120,0)>命座</ft>'
|
||||||
|
'<ft color=(0,148,200)>[角色名称][命座等级]</ft>\n'
|
||||||
|
' \n'
|
||||||
|
'示例:\n'
|
||||||
|
'- <ft color=(238,120,0)>命座胡桃1</ft>'
|
||||||
|
),
|
||||||
|
)
|
||||||
|
async def send_polar(matcher: Matcher, args: Message = CommandArg()):
|
||||||
|
message = args.extract_plain_text().strip().replace(' ', '')
|
||||||
num = int(re.findall(r'\d+', message)[0]) # str
|
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 bot.send(ev, '你家{}有{}命?'.format(m, num))
|
await get_polar.finish('你家{}有{}命?'.format(m, num))
|
||||||
return
|
return
|
||||||
im = await char_wiki(m, 'constellations', num)
|
im = await char_wiki(m, 'constellations', num)
|
||||||
await bot.send(ev, im)
|
await matcher.finish(im)
|
||||||
|
@ -2,22 +2,34 @@ import random
|
|||||||
import asyncio
|
import asyncio
|
||||||
import threading
|
import threading
|
||||||
|
|
||||||
from ..base import sv, logger
|
from nonebot import on_command
|
||||||
|
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.draw_image_tools.send_image_tool import convert_img
|
from ..utils.exception.handle_exception import handle_exception
|
||||||
|
|
||||||
|
draw_total_scheduler = scheduler
|
||||||
|
get_abyss_total = on_command('深渊概览', aliases={'深渊统计', '深渊使用率'})
|
||||||
|
|
||||||
|
|
||||||
@sv.scheduled_job('interval', hours=3)
|
@draw_total_scheduler.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()
|
||||||
|
|
||||||
|
|
||||||
@sv.on_fullmatch(('深渊概览', '深渊统计', '深渊使用率'))
|
@get_abyss_total.handle()
|
||||||
async def send_abyss_pic(bot, ev):
|
@handle_exception('深渊概览')
|
||||||
img = await convert_img(TOTAL_IMG)
|
async def send_guide_pic(matcher: Matcher):
|
||||||
logger.info('获得gs帮助图片成功!')
|
if TOTAL_IMG.exists():
|
||||||
await bot.send(ev, img)
|
logger.info('获得深渊概览成功!')
|
||||||
|
with open(TOTAL_IMG, 'rb') as f:
|
||||||
|
await matcher.finish(MessageSegment.image(f.read()))
|
||||||
|
else:
|
||||||
|
await matcher.finish('深渊概览图不存在!')
|
||||||
|
|
||||||
|
|
||||||
threading.Thread(
|
threading.Thread(
|
||||||
|
@ -27,7 +27,9 @@ 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])
|
||||||
mihoyo_id_data = aid.group(0).split('=') # type: ignore
|
if not aid:
|
||||||
|
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,9 +1,7 @@
|
|||||||
import sys
|
import sys
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
import hoshino
|
MAIN_PATH = Path() / 'data' / 'GenshinUID'
|
||||||
|
|
||||||
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,53 +1,63 @@
|
|||||||
# flake8: noqa
|
from functools import wraps
|
||||||
# from nonebot.log import logger
|
from typing import Optional
|
||||||
# from aiocqhttp.exceptions import ActionFailed
|
|
||||||
# from hoshino.typing import List, CQEvent, Iterable
|
|
||||||
|
|
||||||
# FIXME: - 在 Hoshino 中可用
|
from nonebot.log import logger
|
||||||
# def handle_exception(name: str, log_msg: str = None, fail_msg: str = None): # type: ignore
|
from nonebot.matcher import Matcher
|
||||||
# """
|
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}信息错误')
|
|
||||||
|
|
||||||
# return inner
|
def handle_exception(
|
||||||
|
name: str, log_msg: Optional[str] = None, fail_msg: Optional[str] = None
|
||||||
|
):
|
||||||
|
"""
|
||||||
|
:说明:
|
||||||
|
捕获命令执行过程中发生的异常并回报。
|
||||||
|
:参数:
|
||||||
|
* ``name: str``: 项目的名称。
|
||||||
|
* ``log_msg: str = None``: 自定义捕获异常后在日志中留存的信息。留空则使用默认信息。
|
||||||
|
* ``fail_msg: str = None``: 自定义捕获异常后向用户回报的信息,仅在提供自定义日志信息时有效。
|
||||||
|
开头带@则艾特用户。留空则与日志信息相同。
|
||||||
|
"""
|
||||||
|
|
||||||
# return wrapper
|
def wrapper(func):
|
||||||
|
@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,18 +1,20 @@
|
|||||||
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_action(action='get_friend_list')
|
friend_dict_list = await bot.call_api('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, group_id: int) -> List[int]:
|
async def get_group_member_list(bot: Bot, group_id: int) -> List[int]:
|
||||||
member_list = []
|
member_list = []
|
||||||
group_member_list = await bot.call_api(
|
group_member_list = await bot.call_api(
|
||||||
action='get_group_member_list', group_id=group_id
|
'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,9 +1,11 @@
|
|||||||
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):
|
def __init__(self, event: MessageEvent):
|
||||||
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 ...base import hoshino_bot
|
from nonebot.adapters.onebot.v11 import Bot
|
||||||
|
|
||||||
|
|
||||||
# 发送聊天记录
|
# 发送聊天记录
|
||||||
async def send_forward_msg(
|
async def send_forward_msg(
|
||||||
bot: hoshino_bot,
|
bot: Bot,
|
||||||
group_id: int,
|
groupid: 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_action(
|
await bot.call_api(
|
||||||
action='send_group_forward_msg', group_id=group_id, messages=messages
|
"send_group_forward_msg", group_id=groupid, messages=messages
|
||||||
)
|
)
|
||||||
|
15
GenshinUID/utils/nonebot2/rule.py
Normal file
15
GenshinUID/utils/nonebot2/rule.py
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
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)
|
15
GenshinUID/utils/nonebot2/utils.py
Normal file
15
GenshinUID/utils/nonebot2/utils.py
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
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 load_plugins
|
from nonebot import require, 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(
|
||||||
(
|
(
|
||||||
hoshino.config.RES_DIR + "/GenshinUID/"
|
"data/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.info(f"复制文件夹 {path} -> {dst} 成功")
|
logger.success(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.info(f"删除文件夹 {path} 成功")
|
logger.success(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'), 'hoshino.modules.GenshinUID.GenshinUID')
|
load_plugins(str(dir_ / "GenshinUID"))
|
||||||
|
14
deploy/.env.dev
Normal file
14
deploy/.env.dev
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
# 配置 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
|
14
deploy/cookiecutter.yml
Normal file
14
deploy/cookiecutter.yml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
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
|
21
deploy/update_pyproject.py
Normal file
21
deploy/update_pyproject.py
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
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()
|
1824
poetry.lock
generated
1824
poetry.lock
generated
File diff suppressed because it is too large
Load Diff
@ -1,34 +1,3 @@
|
|||||||
[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"]
|
||||||
@ -45,10 +14,65 @@ 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.0.0"]
|
requires = ["poetry-core>=1.2.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 = 'aliyun.mirrors'
|
name = "USTC"
|
||||||
url = "http://mirrors.aliyun.com/pypi/simple/"
|
url = "https://pypi.mirrors.ustc.edu.cn/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,50 +1,65 @@
|
|||||||
--trusted-host mirrors.aliyun.com
|
aiofiles==23.1.0 ; python_full_version >= "3.8.1" and python_version < "4.0"
|
||||||
--extra-index-url http://mirrors.aliyun.com/pypi/simple
|
aiohttp==3.8.4 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
||||||
|
aiosignal==1.3.1 ; 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"
|
aiosqlite==0.18.0 ; 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"
|
anyio==3.6.2 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
||||||
aiosignal==1.3.1 ; python_version >= "3.8" and python_version < "4.0"
|
apscheduler==3.10.1 ; python_full_version >= "3.8.1" and python_version < "4.0"
|
||||||
aiosqlite==0.17.0 ; 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"
|
||||||
anyio==3.6.2 ; 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"
|
||||||
async-timeout==4.0.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"
|
||||||
attrs==22.2.0 ; 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"
|
||||||
bcrypt==4.0.1 ; 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"
|
||||||
beautifulsoup4==4.11.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"
|
||||||
certifi==2022.12.7 ; 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"
|
||||||
charset-normalizer==2.1.1 ; 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"
|
||||||
colorama==0.4.6 ; python_version >= "3.8" and python_version < "4.0" and platform_system == "Windows"
|
dnspython==2.3.0 ; python_full_version >= "3.8.1" and python_version < "4.0"
|
||||||
dnspython==2.2.1 ; python_version >= "3.8" and python_version < "4.0"
|
email-validator==1.3.1 ; 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"
|
et-xmlfile==1.1.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-amis-admin==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-user-auth==0.5.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"
|
fastapi==0.93.0 ; 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"
|
frozenlist==1.3.3 ; 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"
|
gitdb==4.0.10 ; 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"
|
gitpython==3.1.31 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
||||||
gitpython==3.1.30 ; 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"
|
||||||
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"
|
h11==0.14.0 ; 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"
|
httpcore==0.16.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"
|
httpx==0.23.3 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
||||||
httpx==0.23.1 ; python_version >= "3.8" and python_version < "4.0"
|
idna==3.4 ; python_full_version >= "3.8.1" and python_version < "4.0"
|
||||||
idna==3.4 ; python_version >= "3.8" and python_version < "4.0"
|
loguru==0.6.0 ; python_full_version >= "3.8.1" and python_version < "4.0"
|
||||||
lxml==4.9.2 ; python_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"
|
||||||
multidict==6.0.4 ; python_version >= "3.8" and python_version < "4.0"
|
msgpack==1.0.5 ; python_full_version >= "3.8.1" and python_version < "4.0"
|
||||||
openpyxl==3.0.10 ; python_version >= "3.8" and python_version < "4.0"
|
multidict==6.0.4 ; 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-adapter-onebot==2.2.1 ; python_full_version >= "3.8.1" and python_version < "4.0"
|
||||||
pillow==9.3.0 ; 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"
|
||||||
pydantic==1.10.4 ; python_version >= "3.8" and python_version < "4.0"
|
nonebot2==2.0.0rc3 ; python_full_version >= "3.8.1" and python_version < "4.0"
|
||||||
python-multipart==0.0.5 ; 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"
|
||||||
qrcode[pil]==7.3.1 ; 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"
|
||||||
rfc3986[idna2008]==1.5.0 ; 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"
|
||||||
six==1.16.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"
|
||||||
smmap==5.0.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"
|
||||||
sniffio==1.3.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"
|
||||||
soupsieve==2.3.2.post1 ; 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"
|
||||||
sqlalchemy-database==0.0.11 ; 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"
|
||||||
sqlalchemy2-stubs==0.0.2a31 ; 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"
|
||||||
sqlalchemy==1.4.41 ; 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"
|
||||||
sqlmodel==0.0.8 ; python_version >= "3.8" and python_version < "4.0"
|
pytz==2022.7.1 ; python_full_version >= "3.8.1" and python_version < "4.0"
|
||||||
sqlmodelx==0.0.4 ; 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"
|
||||||
starlette==0.22.0 ; 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"
|
||||||
typing-extensions==4.4.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"
|
||||||
yarl==1.8.2 ; python_version >= "3.8" and python_version < "4.0"
|
six==1.16.0 ; python_full_version >= "3.8.1" 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
tests/.env
Normal file
1
tests/.env
Normal file
@ -0,0 +1 @@
|
|||||||
|
ENVIRONMENT=test
|
5
tests/.env.test
Normal file
5
tests/.env.test
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
LOG_LEVEL=TRACE
|
||||||
|
NICKNAME=["test"]
|
||||||
|
SUPERUSERS=["onebot:10000","10001","other:10002","abcdef"]
|
||||||
|
COMMAND_START=["", "/"]
|
||||||
|
DRIVER="~none"
|
23
tests/conftest.py
Normal file
23
tests/conftest.py
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
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,
|
||||||
|
}
|
31
tests/test_adv.py
Normal file
31
tests/test_adv.py
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
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()
|
8
tests/test_base.py
Normal file
8
tests/test_base.py
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
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
|
121
tests/test_etc.py
Normal file
121
tests/test_etc.py
Normal file
@ -0,0 +1,121 @@
|
|||||||
|
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()
|
123
tests/test_guide.py
Normal file
123
tests/test_guide.py
Normal file
@ -0,0 +1,123 @@
|
|||||||
|
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()
|
36
tests/test_metadata.py
Normal file
36
tests/test_metadata.py
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
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
|
9
tests/test_utils/test_nonebot2.py
Normal file
9
tests/test_utils/test_nonebot2.py
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
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
Normal file
108
tests/utils.py
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
# 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