mirror of
https://github.com/KimigaiiWuyi/GenshinUID.git
synced 2025-07-04 05:53:29 +00:00
Compare commits
763 Commits
QQGuildBot
...
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 |
54
.github/workflows/pre-commit.yml
vendored
54
.github/workflows/pre-commit.yml
vendored
@ -1,54 +0,0 @@
|
|||||||
name: Pre Commit
|
|
||||||
on:
|
|
||||||
- pull_request
|
|
||||||
jobs:
|
|
||||||
Pre-Commit:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
with:
|
|
||||||
ref: ${{ github.event.pull_request.head.ref }}
|
|
||||||
|
|
||||||
- name: Setup Python
|
|
||||||
uses: actions/setup-python@v2
|
|
||||||
with:
|
|
||||||
python-version: "3.10"
|
|
||||||
architecture: "x64"
|
|
||||||
|
|
||||||
- name: Setup pre-commit and actions-toolkit
|
|
||||||
run: "python3 -m pip install pre-commit actions-toolkit"
|
|
||||||
|
|
||||||
- name: Run pre-commit
|
|
||||||
run: python3 -c "import os;os.system('python3 -m pre_commit run --color never -a > result.txt')"
|
|
||||||
|
|
||||||
- name: Commit and push
|
|
||||||
run: |
|
|
||||||
git config user.name github-actions[bot]
|
|
||||||
git config user.email github-actions[bot]@users.noreply.github.com
|
|
||||||
git add .
|
|
||||||
git diff-index --quiet HEAD || git commit -m ":rotating_light: auto fix by pre-commit"
|
|
||||||
git push
|
|
||||||
|
|
||||||
- name: Read result
|
|
||||||
id: rr
|
|
||||||
run: python3 -c "from pathlib import Path;from actions_toolkit.core import set_output;comment=Path('./result.txt').read_text();set_output('comment', comment)"
|
|
||||||
|
|
||||||
- name: Find Comment
|
|
||||||
uses: peter-evans/find-comment@v2
|
|
||||||
id: fc
|
|
||||||
with:
|
|
||||||
issue-number: ${{ github.event.pull_request.number }}
|
|
||||||
comment-author: "github-actions[bot]"
|
|
||||||
body-includes: "pre-commit"
|
|
||||||
|
|
||||||
- name: Create or update comment
|
|
||||||
uses: peter-evans/create-or-update-comment@v2
|
|
||||||
with:
|
|
||||||
comment-id: ${{ steps.fc.outputs.comment-id }}
|
|
||||||
issue-number: ${{ github.event.pull_request.number }}
|
|
||||||
body: |
|
|
||||||
pre-commit output:
|
|
||||||
```
|
|
||||||
${{ steps.rr.outputs.COMMENT }}
|
|
||||||
```
|
|
||||||
edit-mode: replace
|
|
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
|
@ -1,5 +1,7 @@
|
|||||||
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
|
||||||
|
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
@ -7,6 +7,8 @@
|
|||||||
"genshin",
|
"genshin",
|
||||||
"genshinuid",
|
"genshinuid",
|
||||||
"minigg",
|
"minigg",
|
||||||
|
"nonebot",
|
||||||
|
"nonebug",
|
||||||
"weapontype"
|
"weapontype"
|
||||||
],
|
],
|
||||||
"[python]": {
|
"[python]": {
|
||||||
|
@ -1,42 +1,25 @@
|
|||||||
|
from pathlib import Path
|
||||||
|
from pkgutil import iter_modules
|
||||||
|
|
||||||
from nonebot.log import logger
|
from nonebot.log import logger
|
||||||
from nonebot import require, load_all_plugins, get_plugin_by_module_name
|
from nonebot import require, load_all_plugins, get_plugin_by_module_name
|
||||||
|
|
||||||
|
from .config import config as _config
|
||||||
|
|
||||||
require('nonebot_plugin_apscheduler')
|
require('nonebot_plugin_apscheduler')
|
||||||
|
|
||||||
# from .utils.nonebot2.send import patch_send
|
|
||||||
|
|
||||||
# patch_send()
|
|
||||||
if get_plugin_by_module_name("GenshinUID"):
|
if get_plugin_by_module_name("GenshinUID"):
|
||||||
logger.info("推荐直接加载 GenshinUID 仓库文件夹")
|
logger.info("推荐直接加载 GenshinUID 仓库文件夹")
|
||||||
load_all_plugins(
|
load_all_plugins(
|
||||||
[
|
[
|
||||||
'GenshinUID.genshinuid_abyss',
|
f"GenshinUID.{module.name}"
|
||||||
'GenshinUID.genshinuid_adv',
|
for module in iter_modules([str(Path(__file__).parent)])
|
||||||
'GenshinUID.genshinuid_ann',
|
if module.ispkg
|
||||||
'GenshinUID.genshinuid_gcg',
|
and (
|
||||||
'GenshinUID.genshinuid_xkdata',
|
(name := module.name[11:]) == "meta"
|
||||||
'GenshinUID.genshinuid_check',
|
or name not in _config.disabled_plugins
|
||||||
'GenshinUID.genshinuid_collection',
|
)
|
||||||
'GenshinUID.genshinuid_config',
|
# module.name[:11] == genshinuid_
|
||||||
'GenshinUID.genshinuid_enka',
|
|
||||||
'GenshinUID.genshinuid_etcimg',
|
|
||||||
'GenshinUID.genshinuid_eventlist',
|
|
||||||
'GenshinUID.genshinuid_gachalog',
|
|
||||||
'GenshinUID.genshinuid_guide',
|
|
||||||
'GenshinUID.genshinuid_help',
|
|
||||||
'GenshinUID.genshinuid_map',
|
|
||||||
'GenshinUID.genshinuid_meta',
|
|
||||||
'GenshinUID.genshinuid_mhybbscoin',
|
|
||||||
'GenshinUID.genshinuid_mys',
|
|
||||||
'GenshinUID.genshinuid_note',
|
|
||||||
'GenshinUID.genshinuid_resin',
|
|
||||||
'GenshinUID.genshinuid_resource',
|
|
||||||
'GenshinUID.genshinuid_roleinfo',
|
|
||||||
'GenshinUID.genshinuid_signin',
|
|
||||||
'GenshinUID.genshinuid_user',
|
|
||||||
'GenshinUID.genshinuid_wikitext',
|
|
||||||
'GenshinUID.genshinuid_webconsole',
|
|
||||||
'GenshinUID.genshinuid_update',
|
|
||||||
],
|
],
|
||||||
[],
|
[],
|
||||||
)
|
)
|
||||||
|
@ -1,5 +1,15 @@
|
|||||||
from nonebot import get_driver
|
from typing import Set
|
||||||
|
|
||||||
config = get_driver().config
|
from nonebot import get_driver
|
||||||
SUPERUSERS = {int(x) for x in config.superusers}
|
from pydantic import Field, BaseModel
|
||||||
priority = 2
|
|
||||||
|
|
||||||
|
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,15 +1,18 @@
|
|||||||
from typing import Any, Tuple
|
from typing import Any, Tuple, Union
|
||||||
|
|
||||||
from nonebot import on_regex
|
from nonebot import on_regex
|
||||||
from nonebot.log import logger
|
from nonebot.log import logger
|
||||||
from nonebot.matcher import Matcher
|
from nonebot.matcher import Matcher
|
||||||
from nonebot.params import Depends, RegexGroup
|
from nonebot.params import Depends, RegexGroup
|
||||||
from nonebot.adapters.qqguild import MessageEvent, MessageSegment
|
from nonebot.adapters.onebot.v11 import (
|
||||||
|
MessageSegment,
|
||||||
|
GroupMessageEvent,
|
||||||
|
PrivateMessageEvent,
|
||||||
|
)
|
||||||
|
|
||||||
from ..genshinuid_meta import register_menu
|
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.message.cast_type import cast_to_int
|
|
||||||
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.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
|
||||||
@ -31,26 +34,29 @@ get_abyss_info = on_regex(
|
|||||||
'查询(@某人)(上期)深渊(xx层)',
|
'查询(@某人)(上期)深渊(xx层)',
|
||||||
'查询你的或者指定人的深渊战绩',
|
'查询你的或者指定人的深渊战绩',
|
||||||
detail_des=(
|
detail_des=(
|
||||||
'指令:'
|
'介绍:\n'
|
||||||
'<ft color=(238,120,0)>[查询</ft>'
|
'可以用来查看你的或者指定人的深渊战绩,可以指定层数,默认为最高层数\n'
|
||||||
|
'可以在命令文本后带一张图以自定义背景图\n'
|
||||||
|
' \n' # 如果想要空行,请在换行符前面打个空格,不然会忽略换行符
|
||||||
|
'指令:\n'
|
||||||
|
'- <ft color=(238,120,0)>{查询</ft>'
|
||||||
'<ft color=(125,125,125)>(@某人)</ft>'
|
'<ft color=(125,125,125)>(@某人)</ft>'
|
||||||
'<ft color=(238,120,0)>/uidxxx/mysxxx]</ft>'
|
'<ft color=(238,120,0)>|uid</ft><ft color=(0,148,200)>xx</ft>'
|
||||||
|
'<ft color=(238,120,0)>|mys</ft><ft color=(0,148,200)>xx</ft>'
|
||||||
|
'<ft color=(238,120,0)>}</ft>'
|
||||||
'<ft color=(125,125,125)>(上期)</ft>'
|
'<ft color=(125,125,125)>(上期)</ft>'
|
||||||
'<ft color=(238,120,0)>深渊</ft>'
|
'<ft color=(238,120,0)>深渊</ft>'
|
||||||
'<ft color=(125,125,125)>(xx层)</ft>\n'
|
'<ft color=(125,125,125)>(xx层)</ft>\n'
|
||||||
' \n' # 如果想要空行,请在换行符前面打个空格,不然会忽略换行符
|
|
||||||
'可以用来查看你的或者指定人的深渊战绩,可以指定层数,默认为最高层数\n'
|
|
||||||
'可以在命令文本后带一张图以自定义背景图\n'
|
|
||||||
' \n'
|
' \n'
|
||||||
'示例:\n'
|
'示例:\n'
|
||||||
'<ft color=(238,120,0)>查询深渊</ft>;\n'
|
'- <ft color=(238,120,0)>查询深渊</ft>\n'
|
||||||
'<ft color=(238,120,0)>uid123456789上期深渊</ft>;\n'
|
'- <ft color=(238,120,0)>uid123456789上期深渊</ft>\n'
|
||||||
'<ft color=(238,120,0)>查询</ft><ft color=(0,148,200)>@无疑Wuyi</ft> '
|
'- <ft color=(238,120,0)>查询</ft><ft color=(0,123,67)>@无疑Wuyi</ft> '
|
||||||
'<ft color=(238,120,0)>上期深渊12层</ft>'
|
'<ft color=(238,120,0)>上期深渊12层</ft>'
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
async def send_abyss_info(
|
async def send_abyss_info(
|
||||||
event: MessageEvent,
|
event: Union[GroupMessageEvent, PrivateMessageEvent],
|
||||||
matcher: Matcher,
|
matcher: Matcher,
|
||||||
args: Tuple[Any, ...] = RegexGroup(),
|
args: Tuple[Any, ...] = RegexGroup(),
|
||||||
custom: ImageAndAt = Depends(),
|
custom: ImageAndAt = Depends(),
|
||||||
@ -58,11 +64,11 @@ async def send_abyss_info(
|
|||||||
logger.info('开始执行[查询深渊信息]')
|
logger.info('开始执行[查询深渊信息]')
|
||||||
logger.info(f'[查询深渊信息]参数: {args}')
|
logger.info(f'[查询深渊信息]参数: {args}')
|
||||||
at = custom.get_first_at()
|
at = custom.get_first_at()
|
||||||
qid = at or cast_to_int(event.author)
|
qid = at or event.user_id
|
||||||
if args[2] == 'mys':
|
if args[2] == 'mys':
|
||||||
uid = await convert_mysid(args[3])
|
uid = await convert_mysid(args[3])
|
||||||
elif args[3] is None:
|
elif args[3] is None:
|
||||||
uid = await select_db(str(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
|
||||||
@ -91,6 +97,6 @@ async def send_abyss_info(
|
|||||||
if isinstance(im, str):
|
if isinstance(im, str):
|
||||||
await matcher.finish(im)
|
await matcher.finish(im)
|
||||||
elif isinstance(im, bytes):
|
elif isinstance(im, bytes):
|
||||||
await matcher.finish(MessageSegment.file_image(im))
|
await matcher.finish(MessageSegment.image(im))
|
||||||
else:
|
else:
|
||||||
await matcher.finish('发生了未知错误,请联系管理员检查后台输出!')
|
await matcher.finish('发生了未知错误,请联系管理员检查后台输出!')
|
||||||
|
@ -2,7 +2,7 @@ from nonebot import on_command
|
|||||||
from nonebot.log import logger
|
from nonebot.log import logger
|
||||||
from nonebot.matcher import Matcher
|
from nonebot.matcher import Matcher
|
||||||
from nonebot.params import CommandArg
|
from nonebot.params import CommandArg
|
||||||
from nonebot.adapters.qqguild import Message
|
from nonebot.adapters.onebot.v11 import Message
|
||||||
|
|
||||||
from ..config import priority
|
from ..config import priority
|
||||||
from .get_achi_desc import get_achi, get_daily_achi
|
from .get_achi_desc import get_achi, get_daily_achi
|
||||||
|
@ -23,15 +23,17 @@ get_weapon_adv = on_regex(
|
|||||||
'xx用什么',
|
'xx用什么',
|
||||||
'查询角色武器/圣遗物推荐配置',
|
'查询角色武器/圣遗物推荐配置',
|
||||||
detail_des=(
|
detail_des=(
|
||||||
'指令:'
|
'介绍:\n'
|
||||||
'<ft color=(238,120,0)>[角色名][用什么/能用啥/怎么养]</ft>\n'
|
|
||||||
' \n'
|
|
||||||
'可以查询某角色的武器/圣遗物推荐配置\n'
|
'可以查询某角色的武器/圣遗物推荐配置\n'
|
||||||
'支持部分角色别名\n'
|
'支持部分角色别名\n'
|
||||||
' \n'
|
' \n'
|
||||||
|
'指令:\n'
|
||||||
|
'- <ft color=(0,148,200)>[角色名]</ft>'
|
||||||
|
'<ft color=(238,120,0)>{用什么|能用啥|怎么养}</ft>\n'
|
||||||
|
' \n'
|
||||||
'示例:\n'
|
'示例:\n'
|
||||||
'<ft color=(238,120,0)>钟离用什么</ft>;\n'
|
'- <ft color=(238,120,0)>钟离用什么</ft>\n'
|
||||||
'<ft color=(238,120,0)>公子怎么养</ft>'
|
'- <ft color=(238,120,0)>公子怎么养</ft>'
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
async def send_char_adv(
|
async def send_char_adv(
|
||||||
@ -49,15 +51,17 @@ async def send_char_adv(
|
|||||||
'xx能给谁',
|
'xx能给谁',
|
||||||
'查询某武器/圣遗物能给谁用',
|
'查询某武器/圣遗物能给谁用',
|
||||||
detail_des=(
|
detail_des=(
|
||||||
'指令:'
|
'介绍:\n'
|
||||||
'<ft color=(238,120,0)>[角色名][能给谁/给谁用/要给谁/谁能用]</ft>\n'
|
|
||||||
' \n'
|
|
||||||
'可以通过武器/圣遗物名反查适用的角色\n'
|
'可以通过武器/圣遗物名反查适用的角色\n'
|
||||||
'支持部分别名\n'
|
'支持部分别名\n'
|
||||||
' \n'
|
' \n'
|
||||||
|
'指令:\n'
|
||||||
|
'- <ft color=(0,148,200)>[武器名]</ft>'
|
||||||
|
'<ft color=(238,120,0)>{能给谁|给谁用|要给谁|谁能用}</ft>\n'
|
||||||
|
' \n'
|
||||||
'示例:\n'
|
'示例:\n'
|
||||||
'<ft color=(238,120,0)>四风原典能给谁</ft>;\n'
|
'- <ft color=(238,120,0)>四风原典能给谁</ft>\n'
|
||||||
'<ft color=(238,120,0)>千岩给谁用</ft>'
|
'- <ft color=(238,120,0)>千岩给谁用</ft>'
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
async def send_weapon_adv(
|
async def send_weapon_adv(
|
||||||
|
@ -7,14 +7,18 @@ from nonebot.params import CommandArg
|
|||||||
from nonebot import get_bot, on_command
|
from nonebot import get_bot, on_command
|
||||||
from nonebot.permission import SUPERUSER
|
from nonebot.permission import SUPERUSER
|
||||||
from nonebot_plugin_apscheduler import scheduler
|
from nonebot_plugin_apscheduler import scheduler
|
||||||
from nonebot.adapters.qqguild import Message, MessageEvent, MessageSegment
|
from nonebot.adapters.onebot.v11 import (
|
||||||
|
Message,
|
||||||
|
MessageEvent,
|
||||||
|
MessageSegment,
|
||||||
|
GroupMessageEvent,
|
||||||
|
)
|
||||||
|
|
||||||
from .util import black_ids
|
from .util import black_ids
|
||||||
from ..config import priority
|
from ..config import priority
|
||||||
from .main import ann, consume_remind
|
from .main import ann, consume_remind
|
||||||
from ..utils.nonebot2.rule import FullCommand
|
from ..utils.nonebot2.rule import FullCommand
|
||||||
from ..utils.message.error_reply import UID_HINT
|
from ..utils.message.error_reply import UID_HINT
|
||||||
from ..utils.message.cast_type import cast_to_int
|
|
||||||
from ..utils.db_operation.db_operation import select_db
|
from ..utils.db_operation.db_operation import select_db
|
||||||
from ..genshinuid_config.default_config import string_config
|
from ..genshinuid_config.default_config import string_config
|
||||||
from ..utils.exception.handle_exception import handle_exception
|
from ..utils.exception.handle_exception import handle_exception
|
||||||
@ -45,31 +49,31 @@ async def send_ann_pic(
|
|||||||
|
|
||||||
if not ann_id:
|
if not ann_id:
|
||||||
img = await ann_list_card()
|
img = await ann_list_card()
|
||||||
await matcher.finish(MessageSegment.file_image(img))
|
await matcher.finish(MessageSegment.image(img))
|
||||||
|
|
||||||
if not ann_id.isdigit():
|
if not ann_id.isdigit():
|
||||||
raise Exception("公告ID不正确")
|
raise Exception("公告ID不正确")
|
||||||
|
|
||||||
img = await ann_detail_card(int(ann_id))
|
img = await ann_detail_card(int(ann_id))
|
||||||
await matcher.finish(MessageSegment.file_image(img))
|
await matcher.finish(MessageSegment.image(img))
|
||||||
|
|
||||||
|
|
||||||
@reg_ann.handle()
|
@reg_ann.handle()
|
||||||
@handle_exception('设置原神公告', '设置原神公告失败')
|
@handle_exception('设置原神公告', '设置原神公告失败')
|
||||||
async def send_reg_ann(
|
async def send_reg_ann(
|
||||||
event: MessageEvent,
|
event: GroupMessageEvent,
|
||||||
matcher: Matcher,
|
matcher: Matcher,
|
||||||
):
|
):
|
||||||
await matcher.finish(sub_ann(event.channel_id))
|
await matcher.finish(sub_ann(event.group_id))
|
||||||
|
|
||||||
|
|
||||||
@unreg_ann.handle()
|
@unreg_ann.handle()
|
||||||
@handle_exception('取消原神公告', '取消设置原神公告失败')
|
@handle_exception('取消原神公告', '取消设置原神公告失败')
|
||||||
async def send_unreg_ann(
|
async def send_unreg_ann(
|
||||||
event: MessageEvent,
|
event: GroupMessageEvent,
|
||||||
matcher: Matcher,
|
matcher: Matcher,
|
||||||
):
|
):
|
||||||
await matcher.finish(unsub_ann(event.channel_id))
|
await matcher.finish(unsub_ann(event.group_id))
|
||||||
|
|
||||||
|
|
||||||
@consume_ann.handle()
|
@consume_ann.handle()
|
||||||
@ -78,7 +82,7 @@ async def send_consume_ann(
|
|||||||
event: MessageEvent,
|
event: MessageEvent,
|
||||||
matcher: Matcher,
|
matcher: Matcher,
|
||||||
):
|
):
|
||||||
qid = str(cast_to_int(event.author))
|
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:
|
||||||
@ -124,9 +128,9 @@ async def check_ann_state():
|
|||||||
for group in sub_list:
|
for group in sub_list:
|
||||||
try:
|
try:
|
||||||
await bot.call_api(
|
await bot.call_api(
|
||||||
api='_post_messages',
|
api='send_group_msg',
|
||||||
channel_id=group,
|
group_id=group,
|
||||||
content=img,
|
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:
|
||||||
|
@ -1,11 +1,17 @@
|
|||||||
import random
|
import random
|
||||||
import asyncio
|
import asyncio
|
||||||
|
from typing import Union
|
||||||
|
|
||||||
from nonebot import on_command
|
from nonebot import on_command
|
||||||
|
from nonebot.log import logger
|
||||||
from nonebot.matcher import Matcher
|
from nonebot.matcher import Matcher
|
||||||
from nonebot.permission import SUPERUSER
|
from nonebot.permission import SUPERUSER
|
||||||
from nonebot_plugin_apscheduler import scheduler
|
from nonebot_plugin_apscheduler import scheduler
|
||||||
from nonebot.adapters.qqguild import Bot, MessageEvent
|
from nonebot.adapters.onebot.v11 import (
|
||||||
|
Bot,
|
||||||
|
GroupMessageEvent,
|
||||||
|
PrivateMessageEvent,
|
||||||
|
)
|
||||||
|
|
||||||
from ..config import priority
|
from ..config import priority
|
||||||
from .backup_data import data_backup
|
from .backup_data import data_backup
|
||||||
@ -13,6 +19,11 @@ from ..genshinuid_meta import register_menu
|
|||||||
from ..utils.nonebot2.rule import FullCommand
|
from ..utils.nonebot2.rule import FullCommand
|
||||||
from ..utils.exception.handle_exception import handle_exception
|
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.message.get_cqhttp_data import (
|
||||||
|
get_all_friend_list,
|
||||||
|
get_group_member_list,
|
||||||
|
)
|
||||||
|
|
||||||
backup = on_command('gs清除缓存', rule=FullCommand(), priority=priority)
|
backup = on_command('gs清除缓存', rule=FullCommand(), priority=priority)
|
||||||
check = on_command('校验全部Cookies', rule=FullCommand(), priority=priority)
|
check = on_command('校验全部Cookies', rule=FullCommand(), priority=priority)
|
||||||
@ -31,9 +42,22 @@ async def daily_refresh_charData():
|
|||||||
|
|
||||||
@backup.handle()
|
@backup.handle()
|
||||||
@handle_exception('清除缓存', '清除缓存错误')
|
@handle_exception('清除缓存', '清除缓存错误')
|
||||||
|
@register_menu(
|
||||||
|
'清除缓存',
|
||||||
|
'清除缓存',
|
||||||
|
'清除插件产生的缓存数据',
|
||||||
|
trigger_method='超级用户指令',
|
||||||
|
detail_des=(
|
||||||
|
'介绍:\n'
|
||||||
|
'备份一份插件数据库后清除插件产生的文件与数据库缓存\n'
|
||||||
|
' \n'
|
||||||
|
'指令:\n'
|
||||||
|
'- <ft color=(238,120,0)>清除缓存</ft>'
|
||||||
|
),
|
||||||
|
)
|
||||||
async def send_backup_msg(
|
async def send_backup_msg(
|
||||||
bot: Bot,
|
bot: Bot,
|
||||||
event: MessageEvent,
|
event: Union[GroupMessageEvent, PrivateMessageEvent],
|
||||||
matcher: Matcher,
|
matcher: Matcher,
|
||||||
):
|
):
|
||||||
if not await SUPERUSER(bot, event):
|
if not await SUPERUSER(bot, event):
|
||||||
@ -42,6 +66,52 @@ async def send_backup_msg(
|
|||||||
await matcher.finish('操作成功完成!')
|
await matcher.finish('操作成功完成!')
|
||||||
|
|
||||||
|
|
||||||
|
@remove_invalid_user.handle()
|
||||||
|
@handle_exception('清除无效用户', '清除无效用户错误')
|
||||||
|
@register_menu(
|
||||||
|
'清除无效用户',
|
||||||
|
'清除无效用户',
|
||||||
|
'清除非好友或非推送群成员的数据',
|
||||||
|
trigger_method='超级用户指令',
|
||||||
|
detail_des=(
|
||||||
|
'介绍:\n'
|
||||||
|
'从数据库中删除掉 开启了私聊推送但不是Bot好友的用户 '
|
||||||
|
'以及 开启了群聊推送但不在推送目标群的用户 的数据\n'
|
||||||
|
' \n'
|
||||||
|
'指令:\n'
|
||||||
|
'- <ft color=(238,120,0)>清除无效用户</ft>'
|
||||||
|
),
|
||||||
|
)
|
||||||
|
async def send_remove_invalid_user_msg(
|
||||||
|
bot: Bot,
|
||||||
|
event: Union[GroupMessageEvent, PrivateMessageEvent],
|
||||||
|
matcher: Matcher,
|
||||||
|
):
|
||||||
|
if not await SUPERUSER(bot, event):
|
||||||
|
return
|
||||||
|
im_list = []
|
||||||
|
invalid_user = {}
|
||||||
|
invalid_uid_list = []
|
||||||
|
user_list = await get_all_push_list()
|
||||||
|
friend_list = await get_all_friend_list(bot)
|
||||||
|
for user in user_list:
|
||||||
|
if user['StatusA'] == 'on':
|
||||||
|
if user['QID'] not in friend_list:
|
||||||
|
invalid_user['qid'] = user['UID']
|
||||||
|
invalid_uid_list.append(user['UID'])
|
||||||
|
else:
|
||||||
|
group_member_list = await get_group_member_list(
|
||||||
|
bot, int(user['StatusA'])
|
||||||
|
)
|
||||||
|
if user['QID'] not in group_member_list:
|
||||||
|
invalid_user['qid'] = user['UID']
|
||||||
|
invalid_uid_list.append(user['UID'])
|
||||||
|
for uid in invalid_uid_list:
|
||||||
|
im_list.append(await delete_cookies(str(uid)))
|
||||||
|
logger.warning(f'无效UID已被删除: {uid}')
|
||||||
|
await matcher.finish(f'已清理失效用户{len(im_list)}个!')
|
||||||
|
|
||||||
|
|
||||||
# 群聊内 校验Cookies 是否正常的功能,不正常自动删掉
|
# 群聊内 校验Cookies 是否正常的功能,不正常自动删掉
|
||||||
@check.handle()
|
@check.handle()
|
||||||
@handle_exception('Cookie校验', 'Cookie校验错误')
|
@handle_exception('Cookie校验', 'Cookie校验错误')
|
||||||
@ -49,14 +119,14 @@ async def send_backup_msg(
|
|||||||
'校验全部Cookies',
|
'校验全部Cookies',
|
||||||
'校验全部Cookies',
|
'校验全部Cookies',
|
||||||
'校验数据库内所有Cookies是否正常',
|
'校验数据库内所有Cookies是否正常',
|
||||||
trigger_method='管理员指令',
|
|
||||||
detail_des=(
|
detail_des=(
|
||||||
'指令:'
|
'介绍:\n'
|
||||||
'<ft color=(238,120,0)>校验全部Cookies</ft>\n'
|
'校验数据库内所有Cookies是否正常,不正常的会自动删除\n'
|
||||||
'注意<ft color=(238,120,0)>Cookies</ft>的'
|
|
||||||
'<ft color=(238,120,0)>C</ft>为大写\n'
|
|
||||||
' \n'
|
' \n'
|
||||||
'校验数据库内所有Cookies是否正常,不正常的会自动删除'
|
'指令:\n'
|
||||||
|
'- <ft color=(238,120,0)>校验全部Cookies</ft>\n'
|
||||||
|
'注意<ft color=(238,120,0)>Cookies</ft>的'
|
||||||
|
'<ft color=(238,120,0)>C</ft>为大写'
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
async def send_check_cookie(bot: Bot, matcher: Matcher):
|
async def send_check_cookie(bot: Bot, matcher: Matcher):
|
||||||
@ -86,13 +156,13 @@ async def send_check_cookie(bot: Bot, matcher: Matcher):
|
|||||||
'校验全部Stoken',
|
'校验全部Stoken',
|
||||||
'校验全部Stoken',
|
'校验全部Stoken',
|
||||||
'校验数据库内所有Stoken是否正常',
|
'校验数据库内所有Stoken是否正常',
|
||||||
trigger_method='管理员指令',
|
|
||||||
detail_des=(
|
detail_des=(
|
||||||
'指令:'
|
'介绍:\n'
|
||||||
'<ft color=(238,120,0)>校验全部Stoken</ft>\n'
|
'校验数据库内所有Stoken是否正常,不正常的会自动删除\n'
|
||||||
'注意<ft color=(238,120,0)>Stoken</ft>的<ft color=(238,120,0)>S</ft>为大写\n'
|
|
||||||
' \n'
|
' \n'
|
||||||
'校验数据库内所有Stoken是否正常,不正常的会自动删除'
|
'指令:\n'
|
||||||
|
'- <ft color=(238,120,0)>校验全部Stoken</ft>\n'
|
||||||
|
'注意<ft color=(238,120,0)>Stoken</ft>的<ft color=(238,120,0)>S</ft>为大写'
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
async def send_check_stoken(bot: Bot, matcher: Matcher):
|
async def send_check_stoken(bot: Bot, matcher: Matcher):
|
||||||
|
@ -1,13 +1,19 @@
|
|||||||
|
from typing import Union
|
||||||
|
|
||||||
from nonebot import on_command
|
from nonebot import on_command
|
||||||
from nonebot.log import logger
|
from nonebot.log import logger
|
||||||
from nonebot.matcher import Matcher
|
from nonebot.matcher import Matcher
|
||||||
from nonebot.params import Depends, CommandArg
|
from nonebot.params import Depends, CommandArg
|
||||||
from nonebot.adapters.qqguild import Message, MessageEvent, MessageSegment
|
from nonebot.adapters.onebot.v11 import (
|
||||||
|
Message,
|
||||||
|
MessageSegment,
|
||||||
|
GroupMessageEvent,
|
||||||
|
PrivateMessageEvent,
|
||||||
|
)
|
||||||
|
|
||||||
from ..genshinuid_meta import register_menu
|
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.cast_type import cast_to_int
|
|
||||||
from ..utils.message.get_image_and_at import ImageAndAt
|
from ..utils.message.get_image_and_at import ImageAndAt
|
||||||
from ..utils.exception.handle_exception import handle_exception
|
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
|
||||||
@ -23,24 +29,27 @@ get_explora_info = on_command('查询探索', aliases={'探索', 'ts'}, block=Tr
|
|||||||
'查询(@某人)收集',
|
'查询(@某人)收集',
|
||||||
'查询你的或者指定人的宝箱收集度',
|
'查询你的或者指定人的宝箱收集度',
|
||||||
detail_des=(
|
detail_des=(
|
||||||
'指令:'
|
'介绍:\n'
|
||||||
'<ft color=(238,120,0)>[查询</ft>'
|
|
||||||
'<ft color=(125,125,125)>(@某人)</ft>'
|
|
||||||
'<ft color=(238,120,0)>/uidxxx/mysxxx]</ft>'
|
|
||||||
'<ft color=(238,120,0)>[收集/宝箱/sj/bx]</ft>\n'
|
|
||||||
' \n'
|
|
||||||
'可以用来查看你的或者指定人的宝箱收集度\n'
|
'可以用来查看你的或者指定人的宝箱收集度\n'
|
||||||
'可以在命令文本后带一张图以自定义背景图\n'
|
'可以在命令文本后带一张图以自定义背景图\n'
|
||||||
' \n'
|
' \n'
|
||||||
|
'指令:\n'
|
||||||
|
'- <ft color=(238,120,0)>{查询</ft>'
|
||||||
|
'<ft color=(125,125,125)>(@某人)</ft>'
|
||||||
|
'<ft color=(238,120,0)>|uid</ft><ft color=(0,148,200)>xx</ft>'
|
||||||
|
'<ft color=(238,120,0)>|mys</ft><ft color=(0,148,200)>xx</ft>'
|
||||||
|
'<ft color=(238,120,0)>}</ft>'
|
||||||
|
'<ft color=(238,120,0)>{收集|宝箱|sj|bx}</ft>\n'
|
||||||
|
' \n'
|
||||||
'示例:\n'
|
'示例:\n'
|
||||||
'<ft color=(238,120,0)>查询收集</ft>;\n'
|
'- <ft color=(238,120,0)>查询收集</ft>\n'
|
||||||
'<ft color=(238,120,0)>uid123456789宝箱</ft>;\n'
|
'- <ft color=(238,120,0)>uid123456789宝箱</ft>\n'
|
||||||
'<ft color=(238,120,0)>查询</ft><ft color=(0,148,200)>@无疑Wuyi'
|
'- <ft color=(238,120,0)>查询</ft><ft color=(0,123,67)>@无疑Wuyi'
|
||||||
'</ft> <ft color=(238,120,0)>bx</ft>'
|
'</ft> <ft color=(238,120,0)>bx</ft>'
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
async def send_collection_info(
|
async def send_collection_info(
|
||||||
event: MessageEvent,
|
event: Union[GroupMessageEvent, PrivateMessageEvent],
|
||||||
matcher: Matcher,
|
matcher: Matcher,
|
||||||
args: Message = CommandArg(),
|
args: Message = CommandArg(),
|
||||||
custom: ImageAndAt = Depends(),
|
custom: ImageAndAt = Depends(),
|
||||||
@ -49,11 +58,14 @@ async def send_collection_info(
|
|||||||
logger.info('[查询收集信息]参数: {}'.format(args))
|
logger.info('[查询收集信息]参数: {}'.format(args))
|
||||||
raw_mes = args.extract_plain_text().strip()
|
raw_mes = args.extract_plain_text().strip()
|
||||||
at = custom.get_first_at()
|
at = custom.get_first_at()
|
||||||
qid = at or cast_to_int(event.author)
|
if at:
|
||||||
qid = str(qid)
|
qid = at
|
||||||
|
else:
|
||||||
|
qid = event.user_id
|
||||||
|
|
||||||
|
# 获取uid
|
||||||
uid = await get_uid(qid, raw_mes)
|
uid = await get_uid(qid, raw_mes)
|
||||||
logger.info('[查询收集信息]uid: {}'.format(uid))
|
logger.info('[查询角色面板]uid: {}'.format(uid))
|
||||||
|
|
||||||
if '未找到绑定的UID' in uid:
|
if '未找到绑定的UID' in uid:
|
||||||
await matcher.finish(UID_HINT)
|
await matcher.finish(UID_HINT)
|
||||||
@ -62,7 +74,7 @@ async def send_collection_info(
|
|||||||
if isinstance(im, str):
|
if isinstance(im, str):
|
||||||
await matcher.finish(im)
|
await matcher.finish(im)
|
||||||
elif isinstance(im, bytes):
|
elif isinstance(im, bytes):
|
||||||
await matcher.finish(MessageSegment.file_image(im))
|
await matcher.finish(MessageSegment.image(im))
|
||||||
else:
|
else:
|
||||||
await matcher.finish('发生了未知错误,请联系管理员检查后台输出!')
|
await matcher.finish('发生了未知错误,请联系管理员检查后台输出!')
|
||||||
|
|
||||||
@ -70,7 +82,7 @@ async def send_collection_info(
|
|||||||
@get_explora_info.handle()
|
@get_explora_info.handle()
|
||||||
@handle_exception('查询探索信息')
|
@handle_exception('查询探索信息')
|
||||||
async def send_explora_info(
|
async def send_explora_info(
|
||||||
event: MessageEvent,
|
event: Union[GroupMessageEvent, PrivateMessageEvent],
|
||||||
matcher: Matcher,
|
matcher: Matcher,
|
||||||
args: Message = CommandArg(),
|
args: Message = CommandArg(),
|
||||||
custom: ImageAndAt = Depends(),
|
custom: ImageAndAt = Depends(),
|
||||||
@ -79,11 +91,14 @@ async def send_explora_info(
|
|||||||
logger.info('[查询探索信息]参数: {}'.format(args))
|
logger.info('[查询探索信息]参数: {}'.format(args))
|
||||||
raw_mes = args.extract_plain_text().strip()
|
raw_mes = args.extract_plain_text().strip()
|
||||||
at = custom.get_first_at()
|
at = custom.get_first_at()
|
||||||
qid = at or cast_to_int(event.author)
|
if at:
|
||||||
qid = str(qid)
|
qid = at
|
||||||
|
else:
|
||||||
|
qid = event.user_id
|
||||||
|
|
||||||
|
# 获取uid
|
||||||
uid = await get_uid(qid, raw_mes)
|
uid = await get_uid(qid, raw_mes)
|
||||||
logger.info('[查询探索信息]uid: {}'.format(uid))
|
logger.info('[查询角色面板]uid: {}'.format(uid))
|
||||||
|
|
||||||
if '未找到绑定的UID' in uid:
|
if '未找到绑定的UID' in uid:
|
||||||
await matcher.finish(UID_HINT)
|
await matcher.finish(UID_HINT)
|
||||||
@ -92,6 +107,6 @@ async def send_explora_info(
|
|||||||
if isinstance(im, str):
|
if isinstance(im, str):
|
||||||
await matcher.finish(im)
|
await matcher.finish(im)
|
||||||
elif isinstance(im, bytes):
|
elif isinstance(im, bytes):
|
||||||
await matcher.finish(MessageSegment.file_image(im))
|
await matcher.finish(MessageSegment.image(im))
|
||||||
else:
|
else:
|
||||||
await matcher.finish('发生了未知错误,请联系管理员检查后台输出!')
|
await matcher.finish('发生了未知错误,请联系管理员检查后台输出!')
|
||||||
|
@ -1,15 +1,21 @@
|
|||||||
from typing import Any, Tuple
|
from typing import Any, Tuple, Union
|
||||||
|
|
||||||
from nonebot.log import logger
|
from nonebot.log import logger
|
||||||
from nonebot.matcher import Matcher
|
from nonebot.matcher import Matcher
|
||||||
from nonebot import on_regex, on_command
|
from nonebot import on_regex, on_command
|
||||||
from nonebot.permission import SUPERUSER
|
from nonebot.permission import SUPERUSER
|
||||||
from nonebot.params import Depends, CommandArg, RegexGroup
|
from nonebot.params import Depends, CommandArg, RegexGroup
|
||||||
from nonebot.adapters.qqguild import Bot, Message, MessageEvent, MessageSegment
|
from nonebot.adapters.onebot.v11 import (
|
||||||
|
Bot,
|
||||||
|
Message,
|
||||||
|
MessageSegment,
|
||||||
|
GroupMessageEvent,
|
||||||
|
PrivateMessageEvent,
|
||||||
|
)
|
||||||
|
|
||||||
|
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.message.cast_type import cast_to_int
|
|
||||||
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.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
|
||||||
@ -32,6 +38,18 @@ config_card = on_command('gs配置')
|
|||||||
|
|
||||||
@config_card.handle()
|
@config_card.handle()
|
||||||
@handle_exception('发送配置表')
|
@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()):
|
async def send_config_card(matcher: Matcher, args: Message = CommandArg()):
|
||||||
if args:
|
if args:
|
||||||
await matcher.finish()
|
await matcher.finish()
|
||||||
@ -40,23 +58,41 @@ async def send_config_card(matcher: Matcher, args: Message = CommandArg()):
|
|||||||
if isinstance(im, str):
|
if isinstance(im, str):
|
||||||
await matcher.finish(im)
|
await matcher.finish(im)
|
||||||
elif isinstance(im, bytes):
|
elif isinstance(im, bytes):
|
||||||
await matcher.finish(MessageSegment.file_image(im))
|
await matcher.finish(MessageSegment.image(im))
|
||||||
else:
|
else:
|
||||||
await matcher.finish('发生了未知错误,请联系管理员检查后台输出!')
|
await matcher.finish('发生了未知错误,请联系管理员检查后台输出!')
|
||||||
|
|
||||||
|
|
||||||
@push_config.handle()
|
@push_config.handle()
|
||||||
@handle_exception('设置推送服务')
|
@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(
|
async def send_config_msg(
|
||||||
bot: Bot,
|
bot: Bot,
|
||||||
event: MessageEvent,
|
event: Union[GroupMessageEvent, PrivateMessageEvent],
|
||||||
matcher: Matcher,
|
matcher: Matcher,
|
||||||
args: Tuple[Any, ...] = RegexGroup(),
|
args: Tuple[Any, ...] = RegexGroup(),
|
||||||
custom: ImageAndAt = Depends(),
|
custom: ImageAndAt = Depends(),
|
||||||
):
|
):
|
||||||
logger.info('开始执行[设置阈值信息]')
|
logger.info('开始执行[设置阈值信息]')
|
||||||
logger.info('[设置阈值信息]参数: {}'.format(args))
|
logger.info('[设置阈值信息]参数: {}'.format(args))
|
||||||
qid = cast_to_int(event.author)
|
qid = event.user_id
|
||||||
at = custom.get_first_at()
|
at = custom.get_first_at()
|
||||||
|
|
||||||
if at and await SUPERUSER(bot, event):
|
if at and await SUPERUSER(bot, event):
|
||||||
@ -66,7 +102,7 @@ async def send_config_msg(
|
|||||||
logger.info('[设置阈值信息]qid: {}'.format(qid))
|
logger.info('[设置阈值信息]qid: {}'.format(qid))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
uid = await select_db(str(qid), mode='uid')
|
uid = await select_db(qid, mode='uid')
|
||||||
except TypeError:
|
except TypeError:
|
||||||
await matcher.finish(UID_HINT)
|
await matcher.finish(UID_HINT)
|
||||||
|
|
||||||
@ -85,16 +121,34 @@ async def send_config_msg(
|
|||||||
|
|
||||||
# 开启 自动签到 和 推送树脂提醒 功能
|
# 开启 自动签到 和 推送树脂提醒 功能
|
||||||
@open_and_close_switch.handle()
|
@open_and_close_switch.handle()
|
||||||
|
@register_menu(
|
||||||
|
'开关推送服务',
|
||||||
|
'gs{开启|关闭}xx(@某人)',
|
||||||
|
'开关自己或指定人的推送服务状态',
|
||||||
|
detail_des=(
|
||||||
|
'介绍:\n'
|
||||||
|
'设置某人的推送服务开关状态\n'
|
||||||
|
'超级用户可以设置他人的推送服务状态\n'
|
||||||
|
' \n'
|
||||||
|
'指令:\n'
|
||||||
|
'- <ft color=(238,120,0)>gs{开启|关闭}</ft>'
|
||||||
|
'<ft color=(0,148,200)>[服务名称]</ft>'
|
||||||
|
'<ft color=(125,125,125)>(@某人)</ft>\n'
|
||||||
|
' \n'
|
||||||
|
'示例:\n'
|
||||||
|
'- <ft color=(238,120,0)>gs开启推送</ft>'
|
||||||
|
),
|
||||||
|
)
|
||||||
async def open_switch_func(
|
async def open_switch_func(
|
||||||
bot: Bot,
|
bot: Bot,
|
||||||
event: MessageEvent,
|
event: Union[GroupMessageEvent, PrivateMessageEvent],
|
||||||
matcher: Matcher,
|
matcher: Matcher,
|
||||||
args: Tuple[Any, ...] = RegexGroup(),
|
args: Tuple[Any, ...] = RegexGroup(),
|
||||||
at: ImageAndAt = Depends(),
|
at: ImageAndAt = Depends(),
|
||||||
):
|
):
|
||||||
qid = cast_to_int(event.author)
|
qid = event.user_id
|
||||||
if at:
|
atqq = at.get_first_at() if at else None
|
||||||
at = at.get_first_at() # type: ignore
|
|
||||||
config_name = args[4]
|
config_name = args[4]
|
||||||
|
|
||||||
logger.info(f'[{qid}]尝试[{args[3]}]了[{config_name}]功能')
|
logger.info(f'[{qid}]尝试[{args[3]}]了[{config_name}]功能')
|
||||||
@ -110,20 +164,20 @@ async def open_switch_func(
|
|||||||
query = 'CLOSED'
|
query = 'CLOSED'
|
||||||
gid = 'off'
|
gid = 'off'
|
||||||
is_admin = await SUPERUSER(bot, event)
|
is_admin = await SUPERUSER(bot, event)
|
||||||
if at and is_admin:
|
if atqq:
|
||||||
qid = at
|
if is_admin:
|
||||||
elif at and at != qid:
|
qid = atqq
|
||||||
|
elif atqq != qid:
|
||||||
await matcher.finish('你没有权限操作别人的状态噢~', at_sender=True)
|
await matcher.finish('你没有权限操作别人的状态噢~', at_sender=True)
|
||||||
|
|
||||||
try:
|
uid = await select_db(qid, mode='uid')
|
||||||
uid = await select_db(str(qid), mode='uid')
|
if uid is None or not isinstance(uid, str) or not uid.isdecimal():
|
||||||
except TypeError:
|
|
||||||
await matcher.finish(UID_HINT)
|
await matcher.finish(UID_HINT)
|
||||||
|
|
||||||
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,
|
||||||
|
@ -5,7 +5,7 @@ from ..utils.download_resource.RESOURCE_PATH import MAIN_PATH
|
|||||||
from ..utils.db_operation.db_operation import get_all_bind, get_user_bind_data
|
from ..utils.db_operation.db_operation import get_all_bind, get_user_bind_data
|
||||||
|
|
||||||
DATA_PATH = MAIN_PATH / 'v3_data.json'
|
DATA_PATH = MAIN_PATH / 'v3_data.json'
|
||||||
BOT_ID = 'qqguild'
|
BOT_ID = 'onebot'
|
||||||
RECOGNIZE_SERVER = {
|
RECOGNIZE_SERVER = {
|
||||||
'1': 'cn_gf01',
|
'1': 'cn_gf01',
|
||||||
'2': 'cn_gf01',
|
'2': 'cn_gf01',
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import re
|
import re
|
||||||
import random
|
import random
|
||||||
import asyncio
|
import asyncio
|
||||||
from typing import Tuple
|
from typing import Tuple, Union
|
||||||
|
|
||||||
from nonebot import on_command
|
from nonebot import on_command
|
||||||
from nonebot.log import logger
|
from nonebot.log import logger
|
||||||
@ -9,14 +9,20 @@ from nonebot.matcher import Matcher
|
|||||||
from nonebot.permission import SUPERUSER
|
from nonebot.permission import SUPERUSER
|
||||||
from nonebot.params import Depends, CommandArg
|
from nonebot.params import Depends, CommandArg
|
||||||
from nonebot_plugin_apscheduler import scheduler
|
from nonebot_plugin_apscheduler import scheduler
|
||||||
from nonebot.adapters.qqguild import Bot, Message, MessageEvent, MessageSegment
|
from nonebot.adapters.onebot.v11 import (
|
||||||
|
Bot,
|
||||||
|
Message,
|
||||||
|
MessageSegment,
|
||||||
|
GroupMessageEvent,
|
||||||
|
PrivateMessageEvent,
|
||||||
|
)
|
||||||
|
|
||||||
from ..config import priority
|
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 ..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.message.cast_type import cast_to_int
|
|
||||||
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
|
||||||
@ -26,7 +32,7 @@ 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('强制刷新')
|
refresh = on_command('强制刷新')
|
||||||
original_pic = on_command('原图')
|
original_pic = on_command('原图', rule=FullCommand())
|
||||||
change_api = on_command('切换api')
|
change_api = on_command('切换api')
|
||||||
get_charcard_list = on_command('毕业度统计')
|
get_charcard_list = on_command('毕业度统计')
|
||||||
get_char_info = on_command(
|
get_char_info = on_command(
|
||||||
@ -40,9 +46,21 @@ refresh_scheduler = scheduler
|
|||||||
|
|
||||||
@change_api.handle()
|
@change_api.handle()
|
||||||
@handle_exception('切换api')
|
@handle_exception('切换api')
|
||||||
|
@register_menu(
|
||||||
|
'切换API',
|
||||||
|
'切换api',
|
||||||
|
'切换获取角色面板时使用的API',
|
||||||
|
detail_des=(
|
||||||
|
'介绍:\n'
|
||||||
|
'切换获取角色面板时使用的Enka Network API\n'
|
||||||
|
' \n'
|
||||||
|
'指令:\n'
|
||||||
|
'- <ft color=(238,120,0)>切换api</ft>'
|
||||||
|
),
|
||||||
|
)
|
||||||
async def send_change_api_info(
|
async def send_change_api_info(
|
||||||
bot: Bot,
|
bot: Bot,
|
||||||
event: MessageEvent,
|
event: Union[GroupMessageEvent, PrivateMessageEvent],
|
||||||
matcher: Matcher,
|
matcher: Matcher,
|
||||||
args: Message = CommandArg(),
|
args: Message = CommandArg(),
|
||||||
):
|
):
|
||||||
@ -55,18 +73,30 @@ async def send_change_api_info(
|
|||||||
|
|
||||||
@original_pic.handle()
|
@original_pic.handle()
|
||||||
@handle_exception('原图')
|
@handle_exception('原图')
|
||||||
|
@register_menu(
|
||||||
|
'查看面板原图',
|
||||||
|
'原图',
|
||||||
|
'查看角色面板中原随机图',
|
||||||
|
trigger_method='回复+指令',
|
||||||
|
detail_des=(
|
||||||
|
'介绍:\n'
|
||||||
|
'查看开启随机图功能时角色面板中角色位置的原图,需要回复要查看原图的面板图片消息\n'
|
||||||
|
' \n'
|
||||||
|
'指令:\n'
|
||||||
|
'- <ft color=(238,120,0)>原图</ft>'
|
||||||
|
),
|
||||||
|
)
|
||||||
async def send_original_pic(
|
async def send_original_pic(
|
||||||
event: MessageEvent,
|
event: Union[GroupMessageEvent, PrivateMessageEvent],
|
||||||
matcher: Matcher,
|
matcher: Matcher,
|
||||||
):
|
):
|
||||||
ev = event.__dict__
|
if event.reply:
|
||||||
if 'message_reference' in ev:
|
msg_id = event.reply.message_id
|
||||||
msg_id = ev['message_reference'].__dict__['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:
|
||||||
await matcher.finish(MessageSegment.file_image(f.read()))
|
await matcher.finish(MessageSegment.image(f.read()))
|
||||||
|
|
||||||
|
|
||||||
@get_char_info.handle()
|
@get_char_info.handle()
|
||||||
@ -76,23 +106,48 @@ async def send_original_pic(
|
|||||||
'查询(@某人)角色名',
|
'查询(@某人)角色名',
|
||||||
'查询你的或者指定人的已缓存展柜角色的面板',
|
'查询你的或者指定人的已缓存展柜角色的面板',
|
||||||
detail_des=(
|
detail_des=(
|
||||||
'指令:'
|
'介绍:\n'
|
||||||
'<ft color=(238,120,0)>[查询</ft>'
|
|
||||||
'<ft color=(125,125,125)>(@某人)</ft>'
|
|
||||||
'<ft color=(238,120,0)>/uidxxx/mysxxx]</ft>'
|
|
||||||
'<ft color=(238,120,0)>角色名</ft>\n'
|
|
||||||
' \n'
|
|
||||||
'可以用来查看你的或者指定人的已缓存展柜角色的面板\n'
|
'可以用来查看你的或者指定人的已缓存展柜角色的面板\n'
|
||||||
'支持部分角色别名\n'
|
'支持部分角色别名\n'
|
||||||
' \n'
|
' \n'
|
||||||
|
'指令:\n'
|
||||||
|
'- <ft color=(238,120,0)>{查询</ft>'
|
||||||
|
'<ft color=(125,125,125)>(@某人)</ft>'
|
||||||
|
'<ft color=(238,120,0)>|uid</ft><ft color=(0,148,200)>xx</ft>'
|
||||||
|
'<ft color=(238,120,0)>|mys</ft><ft color=(0,148,200)>xx</ft>'
|
||||||
|
'<ft color=(238,120,0)>}</ft>'
|
||||||
|
'<ft color=(0,148,200)>[角色名]</ft>\n'
|
||||||
|
'后面可以跟 '
|
||||||
|
'<ft color=(238,120,0)>换</ft>'
|
||||||
|
'<ft color=(125,125,125)>(精{一|二|三|四|五})</ft>'
|
||||||
|
'<ft color=(0,148,200)>[武器名]</ft> '
|
||||||
|
'来更换展示的武器\n'
|
||||||
|
'可以跟 '
|
||||||
|
'<ft color=(125,125,125)>(成长)</ft><ft color=(238,120,0)>曲线</ft> '
|
||||||
|
'来查询该角色成长曲线\n'
|
||||||
|
' \n'
|
||||||
'示例:\n'
|
'示例:\n'
|
||||||
'<ft color=(238,120,0)>查询宵宫</ft>;\n'
|
'- <ft color=(238,120,0)>查询宵宫</ft>\n'
|
||||||
'<ft color=(238,120,0)>查询</ft><ft color=(0,148,200)>@无疑Wuyi</ft>'
|
'- <ft color=(238,120,0)>查询绫华换精五雾切</ft>\n'
|
||||||
|
'- <ft color=(238,120,0)>查询一斗成长曲线</ft>\n'
|
||||||
|
'- <ft color=(238,120,0)>查询</ft><ft color=(0,123,67)>@无疑Wuyi</ft>'
|
||||||
' <ft color=(238,120,0)>公子</ft>'
|
' <ft color=(238,120,0)>公子</ft>'
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
@register_menu(
|
||||||
|
'查询展柜角色',
|
||||||
|
'查询展柜角色',
|
||||||
|
'查询插件已缓存的展柜角色列表',
|
||||||
|
detail_des=(
|
||||||
|
'介绍:\n'
|
||||||
|
'查询插件当前已缓存的展柜角色列表\n'
|
||||||
|
' \n'
|
||||||
|
'指令:\n'
|
||||||
|
'- <ft color=(238,120,0)>查询展柜角色</ft>'
|
||||||
|
),
|
||||||
|
)
|
||||||
async def send_char_info(
|
async def send_char_info(
|
||||||
event: MessageEvent,
|
event: Union[GroupMessageEvent, PrivateMessageEvent],
|
||||||
matcher: Matcher,
|
matcher: Matcher,
|
||||||
args: Message = CommandArg(),
|
args: Message = CommandArg(),
|
||||||
custom: ImageAndAt = Depends(),
|
custom: ImageAndAt = Depends(),
|
||||||
@ -101,13 +156,15 @@ async def send_char_info(
|
|||||||
name = ''.join(re.findall('[\u4e00-\u9fa5]', raw_mes))
|
name = ''.join(re.findall('[\u4e00-\u9fa5]', raw_mes))
|
||||||
if not name:
|
if not name:
|
||||||
return
|
return
|
||||||
|
|
||||||
logger.info('开始执行[查询角色面板]')
|
logger.info('开始执行[查询角色面板]')
|
||||||
at = custom.get_first_at()
|
at = custom.get_first_at()
|
||||||
img = custom.get_first_image()
|
img = custom.get_first_image()
|
||||||
|
|
||||||
qid = at or cast_to_int(event.author)
|
if at:
|
||||||
qid = str(qid)
|
qid = at
|
||||||
|
else:
|
||||||
|
qid = event.user_id
|
||||||
logger.info('[查询角色面板]QQ: {}'.format(qid))
|
logger.info('[查询角色面板]QQ: {}'.format(qid))
|
||||||
|
|
||||||
# 获取uid
|
# 获取uid
|
||||||
@ -122,17 +179,13 @@ async def send_char_info(
|
|||||||
if '未找到绑定的UID' in uid:
|
if '未找到绑定的UID' in uid:
|
||||||
await matcher.finish(UID_HINT)
|
await matcher.finish(UID_HINT)
|
||||||
|
|
||||||
# 获取角色名
|
im = await draw_enka_img(raw_mes, uid, img)
|
||||||
msg = ''.join(re.findall('[\u4e00-\u9fa5]', raw_mes))
|
|
||||||
im = await draw_enka_img(msg, uid, img)
|
|
||||||
|
|
||||||
if isinstance(im, str):
|
if isinstance(im, str):
|
||||||
await matcher.finish(im)
|
await matcher.finish(im)
|
||||||
elif isinstance(im, Tuple):
|
elif isinstance(im, Tuple):
|
||||||
if isinstance(im[0], str):
|
req = await matcher.send(MessageSegment.image(im[0]))
|
||||||
await matcher.finish(im[0])
|
msg_id = req['message_id']
|
||||||
req = await matcher.send(MessageSegment.file_image(im[0]))
|
|
||||||
msg_id = req.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])
|
||||||
@ -192,14 +245,14 @@ async def daily_refresh_charData():
|
|||||||
async def send_card_info(
|
async def send_card_info(
|
||||||
bot: Bot,
|
bot: Bot,
|
||||||
matcher: Matcher,
|
matcher: Matcher,
|
||||||
event: MessageEvent,
|
event: Union[GroupMessageEvent, PrivateMessageEvent],
|
||||||
custom: ImageAndAt = Depends(),
|
|
||||||
args: Message = CommandArg(),
|
args: Message = CommandArg(),
|
||||||
|
custom: ImageAndAt = Depends(),
|
||||||
):
|
):
|
||||||
message = args.extract_plain_text().strip().replace(' ', '')
|
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 = str(cast_to_int(event.author))
|
qid = event.user_id
|
||||||
at = custom.get_first_at()
|
at = custom.get_first_at()
|
||||||
if at:
|
if at:
|
||||||
qid = at
|
qid = at
|
||||||
@ -220,10 +273,13 @@ async def send_card_info(
|
|||||||
if not uid:
|
if not uid:
|
||||||
await matcher.finish(UID_HINT)
|
await matcher.finish(UID_HINT)
|
||||||
im = await enka_to_card(uid)
|
im = await enka_to_card(uid)
|
||||||
logger.info(f'UID{uid}获取角色数据成功!')
|
|
||||||
if isinstance(im, str):
|
if isinstance(im, str):
|
||||||
await matcher.finish(im)
|
await matcher.finish(im)
|
||||||
await matcher.finish(MessageSegment.file_image(im))
|
elif isinstance(im, bytes):
|
||||||
|
await matcher.finish(MessageSegment.image(im))
|
||||||
|
else:
|
||||||
|
await matcher.finish('发生了未知错误,请联系管理员检查后台输出!')
|
||||||
|
|
||||||
|
|
||||||
@get_charcard_list.handle()
|
@get_charcard_list.handle()
|
||||||
@ -245,13 +301,13 @@ async def send_card_info(
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
async def send_charcard_list(
|
async def send_charcard_list(
|
||||||
event: MessageEvent,
|
event: Union[GroupMessageEvent, PrivateMessageEvent],
|
||||||
matcher: Matcher,
|
matcher: Matcher,
|
||||||
args: Message = CommandArg(),
|
args: Message = CommandArg(),
|
||||||
custom: ImageAndAt = Depends(),
|
custom: ImageAndAt = Depends(),
|
||||||
):
|
):
|
||||||
raw_mes = args.extract_plain_text().strip()
|
raw_mes = args.extract_plain_text().strip()
|
||||||
qid = str(cast_to_int(event.author))
|
qid = event.user_id
|
||||||
at = custom.get_first_at()
|
at = custom.get_first_at()
|
||||||
if at:
|
if at:
|
||||||
qid = at
|
qid = at
|
||||||
@ -264,14 +320,10 @@ async def send_charcard_list(
|
|||||||
uid = await select_db(qid, mode='uid')
|
uid = await select_db(qid, mode='uid')
|
||||||
uid = str(uid)
|
uid = str(uid)
|
||||||
|
|
||||||
if event.author and event.author.avatar:
|
im = await draw_cahrcard_list(str(uid), qid)
|
||||||
avatar = event.author.avatar
|
|
||||||
else:
|
|
||||||
avatar = '3399214199'
|
|
||||||
|
|
||||||
im = await draw_cahrcard_list(str(uid), avatar)
|
|
||||||
|
|
||||||
|
logger.info(f'UID{uid}获取角色数据成功!')
|
||||||
if isinstance(im, bytes):
|
if isinstance(im, bytes):
|
||||||
await matcher.finish(MessageSegment.file_image(im))
|
await matcher.finish(MessageSegment.image(im))
|
||||||
else:
|
else:
|
||||||
await matcher.finish(str(im))
|
await matcher.finish(str(im))
|
||||||
|
@ -5,7 +5,7 @@ from nonebot.log import logger
|
|||||||
from nonebot.matcher import Matcher
|
from nonebot.matcher import Matcher
|
||||||
from nonebot import on_regex, on_command
|
from nonebot import on_regex, on_command
|
||||||
from nonebot.params import CommandArg, RegexGroup
|
from nonebot.params import CommandArg, RegexGroup
|
||||||
from nonebot.adapters.qqguild import Message, MessageSegment
|
from nonebot.adapters.onebot.v11 import Message, MessageSegment
|
||||||
|
|
||||||
from ..version import Genshin_version
|
from ..version import Genshin_version
|
||||||
from ..genshinuid_meta import register_menu
|
from ..genshinuid_meta import register_menu
|
||||||
@ -25,15 +25,16 @@ IMG_PATH = Path(__file__).parent / 'img_data'
|
|||||||
'版本规划(版本号)',
|
'版本规划(版本号)',
|
||||||
'发送一张指定版本的原石规划图',
|
'发送一张指定版本的原石规划图',
|
||||||
detail_des=(
|
detail_des=(
|
||||||
'指令:'
|
'介绍:\n'
|
||||||
'<ft color=(238,120,0)>版本规划</ft>'
|
|
||||||
'<ft color=(125,125,125)>(版本号)</ft>\n'
|
|
||||||
' \n'
|
|
||||||
'发送一张指定版本的原石规划图\n'
|
'发送一张指定版本的原石规划图\n'
|
||||||
' \n'
|
' \n'
|
||||||
|
'指令:\n'
|
||||||
|
'- <ft color=(238,120,0)>版本规划</ft><ft color=(125,125,125)>(版本号)</ft>\n'
|
||||||
|
'- <ft color=(238,120,0)>原石预估</ft><ft color=(125,125,125)>(版本号)</ft>\n'
|
||||||
|
' \n'
|
||||||
'示例:\n'
|
'示例:\n'
|
||||||
'<ft color=(238,120,0)>版本规划</ft>;\n'
|
'- <ft color=(238,120,0)>版本规划</ft>\n'
|
||||||
'<ft color=(238,120,0)>版本规划3.0</ft>'
|
'- <ft color=(238,120,0)>版本规划3.0</ft>'
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
async def send_primogems_data(matcher: Matcher, args: Message = CommandArg()):
|
async def send_primogems_data(matcher: Matcher, args: Message = CommandArg()):
|
||||||
@ -48,38 +49,62 @@ async def send_primogems_data(matcher: Matcher, args: Message = CommandArg()):
|
|||||||
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))
|
||||||
await matcher.finish(MessageSegment.file_image(primogems_img))
|
with open(primogems_img, 'rb') as f:
|
||||||
|
await matcher.finish(MessageSegment.image(f.read()))
|
||||||
|
else:
|
||||||
|
await matcher.finish()
|
||||||
|
|
||||||
|
|
||||||
@get_img_data.handle()
|
@get_img_data.handle()
|
||||||
@handle_exception('杂图')
|
@handle_exception('杂图')
|
||||||
@register_menu(
|
@register_menu(
|
||||||
'伤害乘区图',
|
'伤害乘区图',
|
||||||
'伤害乘区',
|
'(查询)伤害乘区',
|
||||||
'发送一张理论伤害计算公式图',
|
'发送一张理论伤害计算公式图',
|
||||||
detail_des=(
|
detail_des=(
|
||||||
'指令:' '<ft color=(238,120,0)>伤害乘区</ft>\n' ' \n' '发送一张理论伤害计算公式图'
|
'介绍:\n'
|
||||||
|
'发送一张理论伤害计算公式图\n'
|
||||||
|
' \n'
|
||||||
|
'指令:\n'
|
||||||
|
'- <ft color=(125,125,125)>(查询)</ft><ft color=(238,120,0)>伤害乘区</ft>'
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@register_menu(
|
@register_menu(
|
||||||
'怪物血量表',
|
'怪物血量表',
|
||||||
'血量表',
|
'(查询)血量表',
|
||||||
'发送一张原神怪物血量表图',
|
'发送一张原神怪物血量表图',
|
||||||
detail_des=('指令:' '<ft color=(238,120,0)>血量表</ft>\n' ' \n' '发送一张原神怪物血量表图'),
|
detail_des=(
|
||||||
|
'介绍:\n'
|
||||||
|
'发送一张原神怪物血量表图\n'
|
||||||
|
' \n'
|
||||||
|
'指令:\n'
|
||||||
|
'- <ft color=(125,125,125)>(查询)</ft><ft color=(238,120,0)>血量表</ft>'
|
||||||
|
),
|
||||||
)
|
)
|
||||||
@register_menu(
|
@register_menu(
|
||||||
'怪物抗性表',
|
'怪物抗性表',
|
||||||
'抗性表',
|
'(查询)抗性表',
|
||||||
'发送一张原神怪物抗性表图',
|
'发送一张原神怪物抗性表图',
|
||||||
detail_des=('指令:' '<ft color=(238,120,0)>抗性表</ft>\n' ' \n' '发送一张原神怪物抗性表图'),
|
detail_des=(
|
||||||
|
'介绍:\n'
|
||||||
|
'发送一张原神怪物抗性表图\n'
|
||||||
|
' \n'
|
||||||
|
'指令:\n'
|
||||||
|
'- <ft color=(125,125,125)>(查询)</ft><ft color=(238,120,0)>抗性表</ft>'
|
||||||
|
),
|
||||||
)
|
)
|
||||||
@register_menu(
|
@register_menu(
|
||||||
'怪物血量排行',
|
'怪物血量排行',
|
||||||
'血量排行',
|
'(查询)血量排行',
|
||||||
'发送一张原神怪物血量排行图',
|
'发送一张原神怪物血量排行图',
|
||||||
detail_des=(
|
detail_des=(
|
||||||
'指令:' '<ft color=(238,120,0)>血量排行</ft>\n' ' \n' '发送一张原神怪物血量排行图'
|
'介绍:\n'
|
||||||
|
'发送一张原神怪物血量排行图\n'
|
||||||
|
' \n'
|
||||||
|
'指令:\n'
|
||||||
|
'- <ft color=(125,125,125)>(查询)</ft><ft color=(238,120,0)>血量排行</ft>'
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
async def send_img_data(
|
async def send_img_data(
|
||||||
@ -89,4 +114,5 @@ async def send_img_data(
|
|||||||
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():
|
||||||
await matcher.finish(MessageSegment.file_image(img))
|
with open(img, 'rb') as f:
|
||||||
|
await matcher.finish(MessageSegment.image(f.read()))
|
||||||
|
@ -1,14 +1,16 @@
|
|||||||
from nonebot import on_regex
|
from nonebot import on_command
|
||||||
from nonebot.matcher import Matcher
|
from nonebot.matcher import Matcher
|
||||||
from nonebot_plugin_apscheduler import scheduler
|
from nonebot_plugin_apscheduler import scheduler
|
||||||
from nonebot.adapters.qqguild import MessageSegment
|
from nonebot.adapters.onebot.v11 import MessageSegment
|
||||||
|
|
||||||
|
from ..config import priority
|
||||||
from ..genshinuid_meta import register_menu
|
from ..genshinuid_meta import register_menu
|
||||||
|
from ..utils.nonebot2.rule import FullCommand
|
||||||
from .draw_event_img import get_event_img, get_all_event_img
|
from .draw_event_img import get_event_img, get_all_event_img
|
||||||
from ..utils.exception.handle_exception import handle_exception
|
from ..utils.exception.handle_exception import handle_exception
|
||||||
|
|
||||||
get_event = on_regex(r'^活动列表$')
|
get_event = on_command('活动列表', priority=priority, rule=FullCommand())
|
||||||
get_gacha = on_regex(r'^卡池列表$')
|
get_gacha = on_command('卡池列表', priority=priority, rule=FullCommand())
|
||||||
|
|
||||||
|
|
||||||
@scheduler.scheduled_job('cron', hour='2')
|
@scheduler.scheduled_job('cron', hour='2')
|
||||||
@ -22,21 +24,33 @@ async def draw_event():
|
|||||||
'活动列表',
|
'活动列表',
|
||||||
'活动列表',
|
'活动列表',
|
||||||
'查询当前版本活动日程表',
|
'查询当前版本活动日程表',
|
||||||
detail_des=('指令:' '<ft color=(238,120,0)>活动列表</ft>\n' ' \n' '查询当前版本活动日程表'),
|
detail_des=(
|
||||||
|
'介绍:\n'
|
||||||
|
'查询当前版本活动日程表\n'
|
||||||
|
' \n'
|
||||||
|
'指令:\n'
|
||||||
|
'- <ft color=(238,120,0)>活动列表</ft>'
|
||||||
|
),
|
||||||
)
|
)
|
||||||
async def send_events(matcher: Matcher):
|
async def send_events(matcher: Matcher):
|
||||||
img = await get_event_img('EVENT')
|
img = await get_event_img('EVENT')
|
||||||
await matcher.finish(MessageSegment.file_image(img))
|
await matcher.finish(MessageSegment.image(img))
|
||||||
|
|
||||||
|
|
||||||
@get_gacha.handle()
|
@get_gacha.handle()
|
||||||
@handle_exception('卡池')
|
@handle_exception('活动')
|
||||||
@register_menu(
|
@register_menu(
|
||||||
'卡池列表',
|
'卡池列表',
|
||||||
'卡池列表',
|
'卡池列表',
|
||||||
'查询当前版本卡池列表',
|
'查询当前版本卡池列表',
|
||||||
detail_des=('指令:' '<ft color=(238,120,0)>卡池列表</ft>\n' ' \n' '查询当前版本卡池列表'),
|
detail_des=(
|
||||||
|
'介绍:\n'
|
||||||
|
'查询当前版本卡池列表\n'
|
||||||
|
' \n'
|
||||||
|
'指令:\n'
|
||||||
|
'- <ft color=(238,120,0)>卡池列表</ft>'
|
||||||
|
),
|
||||||
)
|
)
|
||||||
async def send_gachas(matcher: Matcher):
|
async def send_gachas(matcher: Matcher):
|
||||||
img = await get_event_img('GACHA')
|
img = await get_event_img('GACHA')
|
||||||
await matcher.finish(MessageSegment.file_image(img))
|
await matcher.finish(MessageSegment.image(img))
|
||||||
|
@ -1,14 +1,20 @@
|
|||||||
|
from typing import Union
|
||||||
|
|
||||||
from nonebot.log import logger
|
from nonebot.log import logger
|
||||||
from nonebot.matcher import Matcher
|
from nonebot.matcher import Matcher
|
||||||
from nonebot import get_bot, on_notice, on_command
|
from nonebot import get_bot, on_notice, on_command
|
||||||
from nonebot.adapters.qqguild import MessageEvent, MessageSegment
|
from nonebot.adapters.onebot.v11 import (
|
||||||
|
NoticeEvent,
|
||||||
|
MessageSegment,
|
||||||
|
GroupMessageEvent,
|
||||||
|
PrivateMessageEvent,
|
||||||
|
)
|
||||||
|
|
||||||
from .get_gachalogs import save_gachalogs
|
from .get_gachalogs import save_gachalogs
|
||||||
from ..genshinuid_meta import register_menu
|
from ..genshinuid_meta import register_menu
|
||||||
from ..utils.nonebot2.rule import FullCommand
|
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.message.cast_type import cast_to_int
|
|
||||||
from ..utils.db_operation.db_operation import select_db
|
from ..utils.db_operation.db_operation import select_db
|
||||||
from ..utils.exception.handle_exception import handle_exception
|
from ..utils.exception.handle_exception import handle_exception
|
||||||
from .export_and_import import export_gachalogs, import_gachalogs
|
from .export_and_import import export_gachalogs, import_gachalogs
|
||||||
@ -21,14 +27,26 @@ export_gacha_log = on_command('导出抽卡记录', rule=FullCommand())
|
|||||||
|
|
||||||
@export_gacha_log.handle()
|
@export_gacha_log.handle()
|
||||||
@handle_exception('导出抽卡记录')
|
@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(
|
async def export_gacha_log_info(
|
||||||
event: MessageEvent,
|
event: GroupMessageEvent,
|
||||||
matcher: Matcher,
|
matcher: Matcher,
|
||||||
):
|
):
|
||||||
|
|
||||||
logger.info('开始执行[导出抽卡记录]')
|
logger.info('开始执行[导出抽卡记录]')
|
||||||
qid = str(str(cast_to_int(event.author)))
|
qid = event.user_id
|
||||||
gid = event.channel_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:
|
||||||
@ -50,7 +68,20 @@ async def export_gacha_log_info(
|
|||||||
|
|
||||||
@import_gacha_log.handle()
|
@import_gacha_log.handle()
|
||||||
@handle_exception('导入抽卡记录')
|
@handle_exception('导入抽卡记录')
|
||||||
async def import_gacha_log_info(event: MessageEvent, matcher: Matcher):
|
@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()
|
args = event.dict()
|
||||||
if args['notice_type'] != 'offline_file':
|
if args['notice_type'] != 'offline_file':
|
||||||
await matcher.finish()
|
await matcher.finish()
|
||||||
@ -74,28 +105,25 @@ async def import_gacha_log_info(event: MessageEvent, matcher: Matcher):
|
|||||||
'抽卡记录',
|
'抽卡记录',
|
||||||
'查询你的原神抽卡记录',
|
'查询你的原神抽卡记录',
|
||||||
detail_des=(
|
detail_des=(
|
||||||
'指令:'
|
'介绍:\n'
|
||||||
'<ft color=(238,120,0)>抽卡记录</ft>\n'
|
|
||||||
' \n'
|
|
||||||
'查询你的原神抽卡记录\n'
|
'查询你的原神抽卡记录\n'
|
||||||
'需要<ft color=(238,120,0)>绑定Stoken</ft>'
|
'需要<ft color=(238,120,0)>绑定Stoken</ft>\n'
|
||||||
|
' \n'
|
||||||
|
'指令:\n'
|
||||||
|
'<ft color=(238,120,0)>抽卡记录</ft>'
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
async def send_gacha_log_card_info(
|
async def send_gacha_log_card_info(
|
||||||
event: MessageEvent,
|
event: Union[GroupMessageEvent, PrivateMessageEvent],
|
||||||
matcher: Matcher,
|
matcher: Matcher,
|
||||||
):
|
):
|
||||||
logger.info('开始执行[抽卡记录]')
|
logger.info('开始执行[抽卡记录]')
|
||||||
|
|
||||||
uid = await select_db(str(cast_to_int(event.author)), mode='uid')
|
uid = await select_db(event.user_id, mode='uid')
|
||||||
if event.author and event.author.avatar:
|
|
||||||
avatar = event.author.avatar
|
|
||||||
else:
|
|
||||||
avatar = '3399214199'
|
|
||||||
if isinstance(uid, str):
|
if isinstance(uid, str):
|
||||||
im = await draw_gachalogs_img(uid, avatar) # type: ignore
|
im = await draw_gachalogs_img(uid, event.user_id)
|
||||||
if isinstance(im, bytes):
|
if isinstance(im, bytes):
|
||||||
await matcher.finish(MessageSegment.file_image(im))
|
await matcher.finish(MessageSegment.image(im))
|
||||||
else:
|
else:
|
||||||
await matcher.finish(im)
|
await matcher.finish(im)
|
||||||
else:
|
else:
|
||||||
@ -109,22 +137,23 @@ async def send_gacha_log_card_info(
|
|||||||
'刷新抽卡记录',
|
'刷新抽卡记录',
|
||||||
'刷新你的原神抽卡记录本地缓存',
|
'刷新你的原神抽卡记录本地缓存',
|
||||||
detail_des=(
|
detail_des=(
|
||||||
'指令:'
|
'介绍:\n'
|
||||||
'<ft color=(238,120,0)>刷新抽卡记录</ft>\n'
|
|
||||||
' \n'
|
|
||||||
'刷新你的原神抽卡记录本地缓存\n'
|
'刷新你的原神抽卡记录本地缓存\n'
|
||||||
'需要<ft color=(238,120,0)>绑定Stoken</ft>'
|
'需要<ft color=(238,120,0)>绑定Stoken</ft>\n'
|
||||||
|
' \n'
|
||||||
|
'指令:\n'
|
||||||
|
'- <ft color=(238,120,0)>刷新抽卡记录</ft>'
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
async def send_daily_info(
|
async def send_daily_info(
|
||||||
event: MessageEvent,
|
event: Union[GroupMessageEvent, PrivateMessageEvent],
|
||||||
matcher: Matcher,
|
matcher: Matcher,
|
||||||
):
|
):
|
||||||
logger.info('开始执行[刷新抽卡记录]')
|
logger.info('开始执行[刷新抽卡记录]')
|
||||||
uid = await select_db(str(cast_to_int(event.author)), mode='uid')
|
uid = await select_db(event.user_id, mode='uid')
|
||||||
if isinstance(uid, str):
|
if isinstance(uid, str):
|
||||||
is_force = False
|
is_force = False
|
||||||
if event.content and event.content.startswith('强制'):
|
if event.raw_message.startswith('强制'):
|
||||||
is_force = True
|
is_force = True
|
||||||
im = await save_gachalogs(uid, None, is_force)
|
im = await save_gachalogs(uid, None, is_force)
|
||||||
await matcher.finish(im)
|
await matcher.finish(im)
|
||||||
|
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 "成功执行"
|
@ -4,11 +4,10 @@ from nonebot import on_command
|
|||||||
from nonebot.log import logger
|
from nonebot.log import logger
|
||||||
from nonebot.matcher import Matcher
|
from nonebot.matcher import Matcher
|
||||||
from nonebot.params import Depends, CommandArg
|
from nonebot.params import Depends, CommandArg
|
||||||
from nonebot.adapters.qqguild import Message, MessageEvent, MessageSegment
|
from nonebot.adapters.onebot.v11 import Message, MessageEvent, MessageSegment
|
||||||
|
|
||||||
from ..config import priority
|
from ..config import priority
|
||||||
from .draw_gcginfo import draw_gcg_info
|
from .draw_gcginfo import draw_gcg_info
|
||||||
from ..utils.message.cast_type import cast_to_int
|
|
||||||
from ..utils.db_operation.db_operation import select_db
|
from ..utils.db_operation.db_operation import select_db
|
||||||
from ..utils.message.get_image_and_at import ImageAndAt
|
from ..utils.message.get_image_and_at import ImageAndAt
|
||||||
from ..utils.message.error_reply import CK_HINT, UID_HINT
|
from ..utils.message.error_reply import CK_HINT, UID_HINT
|
||||||
@ -33,9 +32,10 @@ async def send_gcg_pic(
|
|||||||
at = custom.get_first_at()
|
at = custom.get_first_at()
|
||||||
logger.info('开始执行[七圣召唤]')
|
logger.info('开始执行[七圣召唤]')
|
||||||
|
|
||||||
qid = at or cast_to_int(event.author)
|
if at:
|
||||||
qid = str(qid)
|
qid = at
|
||||||
|
else:
|
||||||
|
qid = event.user_id
|
||||||
logger.info('[七圣召唤]QQ: {}'.format(qid))
|
logger.info('[七圣召唤]QQ: {}'.format(qid))
|
||||||
|
|
||||||
# 获取uid
|
# 获取uid
|
||||||
@ -55,6 +55,6 @@ async def send_gcg_pic(
|
|||||||
if isinstance(im, str):
|
if isinstance(im, str):
|
||||||
await matcher.finish(im)
|
await matcher.finish(im)
|
||||||
elif isinstance(im, bytes):
|
elif isinstance(im, bytes):
|
||||||
await matcher.finish(MessageSegment.file_image(im))
|
await matcher.finish(MessageSegment.image(im))
|
||||||
else:
|
else:
|
||||||
await matcher.finish('发生了未知错误,请联系管理员检查后台输出!')
|
await matcher.finish('发生了未知错误,请联系管理员检查后台输出!')
|
||||||
|
@ -7,7 +7,12 @@ from nonebot.log import logger
|
|||||||
from nonebot.matcher import Matcher
|
from nonebot.matcher import Matcher
|
||||||
from nonebot import on_regex, on_command
|
from nonebot import on_regex, on_command
|
||||||
from nonebot.params import CommandArg, RegexGroup
|
from nonebot.params import CommandArg, RegexGroup
|
||||||
from nonebot.adapters.qqguild import Message, MessageSegment
|
from nonebot.adapters.onebot.v11 import (
|
||||||
|
Bot,
|
||||||
|
Message,
|
||||||
|
MessageSegment,
|
||||||
|
GroupMessageEvent,
|
||||||
|
)
|
||||||
|
|
||||||
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
|
||||||
@ -22,6 +27,7 @@ get_bluekun_pic = on_command('参考面板')
|
|||||||
get_card = on_command('原牌')
|
get_card = on_command('原牌')
|
||||||
get_abyss = on_command('版本深渊')
|
get_abyss = on_command('版本深渊')
|
||||||
|
|
||||||
|
|
||||||
IMG_PATH = Path(__file__).parent / 'img'
|
IMG_PATH = Path(__file__).parent / 'img'
|
||||||
|
|
||||||
|
|
||||||
@ -32,15 +38,17 @@ IMG_PATH = Path(__file__).parent / 'img'
|
|||||||
'xx攻略',
|
'xx攻略',
|
||||||
'发送一张对应角色的西风驿站攻略图',
|
'发送一张对应角色的西风驿站攻略图',
|
||||||
detail_des=(
|
detail_des=(
|
||||||
'指令:'
|
'介绍:\n'
|
||||||
'<ft color=(238,120,0)>角色名[推荐/攻略]</ft>\n'
|
|
||||||
' \n'
|
|
||||||
'发送一张对应角色的米游社西风驿站攻略图\n'
|
'发送一张对应角色的米游社西风驿站攻略图\n'
|
||||||
'支持部分角色别名\n'
|
'支持部分角色别名\n'
|
||||||
' \n'
|
' \n'
|
||||||
|
'指令:\n'
|
||||||
|
'- <ft color=(0,148,200)>[角色名]</ft>'
|
||||||
|
'<ft color=(238,120,0)>{推荐|攻略}</ft>\n'
|
||||||
|
' \n'
|
||||||
'示例:\n'
|
'示例:\n'
|
||||||
'<ft color=(238,120,0)>钟离推荐</ft>;\n'
|
'- <ft color=(238,120,0)>钟离推荐</ft>\n'
|
||||||
'<ft color=(238,120,0)>公子攻略</ft>'
|
'- <ft color=(238,120,0)>公子攻略</ft>'
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
async def send_guide_pic(
|
async def send_guide_pic(
|
||||||
@ -52,8 +60,7 @@ async def send_guide_pic(
|
|||||||
im = await get_gs_guide(name)
|
im = await get_gs_guide(name)
|
||||||
if im:
|
if im:
|
||||||
logger.info('获得{}攻略成功!'.format(name))
|
logger.info('获得{}攻略成功!'.format(name))
|
||||||
print('gg')
|
await matcher.finish(MessageSegment.image(im))
|
||||||
await matcher.finish(MessageSegment.file_image(im))
|
|
||||||
else:
|
else:
|
||||||
logger.warning('未找到{}攻略图片'.format(name))
|
logger.warning('未找到{}攻略图片'.format(name))
|
||||||
|
|
||||||
@ -65,15 +72,17 @@ async def send_guide_pic(
|
|||||||
'参考面板[角色名/元素名]',
|
'参考面板[角色名/元素名]',
|
||||||
'发送一张对应角色/元素的参考面板图',
|
'发送一张对应角色/元素的参考面板图',
|
||||||
detail_des=(
|
detail_des=(
|
||||||
'指令:'
|
'介绍:\n'
|
||||||
'<ft color=(238,120,0)>参考面板[角色名/元素名]</ft>\n'
|
|
||||||
' \n'
|
|
||||||
'发送一张对应角色/元素的参考面板图\n'
|
'发送一张对应角色/元素的参考面板图\n'
|
||||||
'支持部分角色别名\n'
|
'支持部分角色别名\n'
|
||||||
' \n'
|
' \n'
|
||||||
|
'指令:\n'
|
||||||
|
'- <ft color=(238,120,0)>参考面板</ft>'
|
||||||
|
'<ft color=(0,148,200)>[角色名/元素名]</ft>\n'
|
||||||
|
' \n'
|
||||||
'示例:\n'
|
'示例:\n'
|
||||||
'<ft color=(238,120,0)>参考面板火</ft>;\n'
|
'- <ft color=(238,120,0)>参考面板火</ft>\n'
|
||||||
'<ft color=(238,120,0)>参考面板公子</ft>'
|
'- <ft color=(238,120,0)>参考面板公子</ft>'
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
async def send_bluekun_pic(matcher: Matcher, args: Message = CommandArg()):
|
async def send_bluekun_pic(matcher: Matcher, args: Message = CommandArg()):
|
||||||
@ -83,8 +92,10 @@ async def send_bluekun_pic(matcher: Matcher, args: Message = CommandArg()):
|
|||||||
name = await alias_to_char_name(str(args[0]))
|
name = await alias_to_char_name(str(args[0]))
|
||||||
img = IMG_PATH / '{}.jpg'.format(name)
|
img = IMG_PATH / '{}.jpg'.format(name)
|
||||||
if img.exists():
|
if img.exists():
|
||||||
|
with open(img, 'rb') as f:
|
||||||
|
im = MessageSegment.image(f.read())
|
||||||
logger.info('获得{}参考面板图片成功!'.format(name))
|
logger.info('获得{}参考面板图片成功!'.format(name))
|
||||||
await matcher.finish(MessageSegment.file_image(img))
|
await matcher.finish(im)
|
||||||
else:
|
else:
|
||||||
logger.warning('未找到{}参考面板图片'.format(name))
|
logger.warning('未找到{}参考面板图片'.format(name))
|
||||||
|
|
||||||
@ -98,14 +109,16 @@ async def send_gscard_pic(matcher: Matcher, args: Message = CommandArg()):
|
|||||||
im = await get_gs_card(name)
|
im = await get_gs_card(name)
|
||||||
if im:
|
if im:
|
||||||
logger.info('获得{}原牌成功!'.format(name))
|
logger.info('获得{}原牌成功!'.format(name))
|
||||||
await matcher.finish(MessageSegment.file_image(im))
|
await matcher.finish(MessageSegment.image(im))
|
||||||
else:
|
else:
|
||||||
logger.warning('未找到{}原牌图片'.format(name))
|
logger.warning('未找到{}原牌图片'.format(name))
|
||||||
|
|
||||||
|
|
||||||
@get_abyss.handle()
|
@get_abyss.handle()
|
||||||
@handle_exception('版本深渊')
|
@handle_exception('原牌')
|
||||||
async def send_abyss_review(
|
async def send_abyss_review(
|
||||||
|
bot: Bot,
|
||||||
|
event: GroupMessageEvent,
|
||||||
matcher: Matcher,
|
matcher: Matcher,
|
||||||
args: Message = CommandArg(),
|
args: Message = CommandArg(),
|
||||||
):
|
):
|
||||||
@ -115,12 +128,26 @@ async def send_abyss_review(
|
|||||||
version = str(args[0])
|
version = str(args[0])
|
||||||
im = await get_review(version)
|
im = await get_review(version)
|
||||||
if isinstance(im, List):
|
if isinstance(im, List):
|
||||||
im = '\n'.join(im)
|
mes = []
|
||||||
await matcher.finish(im)
|
for msg in im:
|
||||||
|
mes.append(
|
||||||
|
{
|
||||||
|
'type': 'node',
|
||||||
|
'data': {
|
||||||
|
'name': '小仙',
|
||||||
|
'uin': '3399214199',
|
||||||
|
'content': msg,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
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 matcher.finish(im)
|
await matcher.finish(im)
|
||||||
elif isinstance(im, bytes):
|
elif isinstance(im, bytes):
|
||||||
await matcher.finish(MessageSegment.file_image(im))
|
await matcher.finish(MessageSegment.image(im))
|
||||||
else:
|
else:
|
||||||
await matcher.finish('发生了未知错误,请联系管理员检查后台输出!')
|
await matcher.finish('发生了未知错误,请联系管理员检查后台输出!')
|
||||||
|
|
||||||
|
@ -1,139 +0,0 @@
|
|||||||
import asyncio
|
|
||||||
from typing import List
|
|
||||||
|
|
||||||
from nonebot import on_command
|
|
||||||
from nonebot.log import logger
|
|
||||||
from nonebot.matcher import Matcher
|
|
||||||
from nonebot.permission import SUPERUSER
|
|
||||||
from nonebot.message import event_preprocessor
|
|
||||||
from nonebot.adapters.qqguild.message import Text
|
|
||||||
from nonebot.adapters.qqguild import Bot, MessageEvent
|
|
||||||
from nonebot.adapters.qqguild.api.model import DMS, Guild, MessageMarkdown
|
|
||||||
|
|
||||||
from ..utils.nonebot2.rule import FullCommand
|
|
||||||
from ..utils.exception.handle_exception import handle_exception
|
|
||||||
|
|
||||||
_md = '''## 这是一个自定义MD文本
|
|
||||||
'''
|
|
||||||
|
|
||||||
guild_detail = on_command('频道统计', block=True, rule=FullCommand())
|
|
||||||
get_dirct_msg = on_command(
|
|
||||||
'给我发消息',
|
|
||||||
aliases={'给我发私信', '给我发短信', '给我发信息'},
|
|
||||||
block=True,
|
|
||||||
rule=FullCommand(),
|
|
||||||
)
|
|
||||||
get_markdown_msg = on_command(
|
|
||||||
'给我发md',
|
|
||||||
aliases={'给我发markdown'},
|
|
||||||
block=True,
|
|
||||||
rule=FullCommand(),
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@get_markdown_msg.handle()
|
|
||||||
@handle_exception('发md')
|
|
||||||
async def send_markdown_msg(bot: Bot, event: MessageEvent, matcher: Matcher):
|
|
||||||
if not event.author:
|
|
||||||
return
|
|
||||||
|
|
||||||
await bot.call_api(
|
|
||||||
'post_markdown_message',
|
|
||||||
channel_id=str(event.channel_id),
|
|
||||||
content=_md,
|
|
||||||
)
|
|
||||||
|
|
||||||
await matcher.finish('已发送消息!')
|
|
||||||
|
|
||||||
|
|
||||||
@get_dirct_msg.handle()
|
|
||||||
@handle_exception('发私信')
|
|
||||||
async def send_dirct_msg(
|
|
||||||
bot: Bot,
|
|
||||||
event: MessageEvent,
|
|
||||||
matcher: Matcher,
|
|
||||||
):
|
|
||||||
if not event.author:
|
|
||||||
return
|
|
||||||
|
|
||||||
dms: DMS = await bot.call_api(
|
|
||||||
'post_dms',
|
|
||||||
recipient_id=str(event.author.id),
|
|
||||||
source_guild_id=str(event.guild_id),
|
|
||||||
)
|
|
||||||
|
|
||||||
await bot.call_api(
|
|
||||||
'post_dms_messages',
|
|
||||||
guild_id=dms.guild_id,
|
|
||||||
content='一条消息!',
|
|
||||||
)
|
|
||||||
|
|
||||||
await matcher.finish('已发送消息!')
|
|
||||||
|
|
||||||
|
|
||||||
@event_preprocessor
|
|
||||||
async def _(event: MessageEvent):
|
|
||||||
msg = event.get_message().extract_content()
|
|
||||||
msg = msg.replace(' ', '').replace('/', '')
|
|
||||||
r_msg = None
|
|
||||||
new_msg = []
|
|
||||||
for i in event._message: # type: ignore
|
|
||||||
if isinstance(i, Text):
|
|
||||||
i.data['text'] = msg
|
|
||||||
if '毕业都统计' in i.data['text']:
|
|
||||||
i.data['text'].replace('都', '度')
|
|
||||||
|
|
||||||
if r_msg:
|
|
||||||
new_msg.insert(0, r_msg)
|
|
||||||
event._message = new_msg
|
|
||||||
|
|
||||||
if event.content:
|
|
||||||
event.content = event.content.replace(' ', '').replace('/', '')
|
|
||||||
|
|
||||||
|
|
||||||
@guild_detail.handle()
|
|
||||||
@handle_exception('频道统计')
|
|
||||||
async def send_create_map_msg(
|
|
||||||
bot: Bot,
|
|
||||||
event: MessageEvent,
|
|
||||||
matcher: Matcher,
|
|
||||||
):
|
|
||||||
if not await SUPERUSER(bot, event):
|
|
||||||
return
|
|
||||||
logger.info('[频道统计]正在执行...')
|
|
||||||
await matcher.send('频道统计正在执行...可能需要较长时间!')
|
|
||||||
|
|
||||||
# 初始化最后的计数
|
|
||||||
ALL_MEMBER = 0
|
|
||||||
HIDE = 0
|
|
||||||
|
|
||||||
# 开始分页
|
|
||||||
after = None
|
|
||||||
# 初始化频道列表
|
|
||||||
guild_list = []
|
|
||||||
# 开始循环
|
|
||||||
while True:
|
|
||||||
# 本次获取的频道列表
|
|
||||||
new_guild_list: List[Guild] = await bot.call_api(
|
|
||||||
'guilds', before=None, after=after, limit=None
|
|
||||||
)
|
|
||||||
# 遍历频道列表
|
|
||||||
for guild in new_guild_list:
|
|
||||||
# 如果该频道人数展示
|
|
||||||
if guild.member_count:
|
|
||||||
# 总人数加上该频道的人数
|
|
||||||
ALL_MEMBER += guild.member_count
|
|
||||||
else:
|
|
||||||
HIDE += 1
|
|
||||||
logger.info(f'频道{guild.id}隐藏频道人数信息,已跳过计算...')
|
|
||||||
# 重新设定拉取值
|
|
||||||
after = guild.id
|
|
||||||
# 把本次拉取的频道列表 合并到总频道列表
|
|
||||||
guild_list.extend(new_guild_list)
|
|
||||||
logger.info(f'当前页gid={after}')
|
|
||||||
# 如果已经拉取不到频道了,就退出循环
|
|
||||||
if new_guild_list == []:
|
|
||||||
break
|
|
||||||
await asyncio.sleep(0.5)
|
|
||||||
im = f'当前Bot加入频道数{len(guild_list)}\n总人数为{ALL_MEMBER}\n隐藏人数频道数量{HIDE}!'
|
|
||||||
await matcher.finish(im)
|
|
@ -5,7 +5,7 @@ from pathlib import Path
|
|||||||
from nonebot import on_command
|
from nonebot import on_command
|
||||||
from nonebot.log import logger
|
from nonebot.log import logger
|
||||||
from nonebot.matcher import Matcher
|
from nonebot.matcher import Matcher
|
||||||
from nonebot.adapters.qqguild import MessageSegment
|
from nonebot.adapters.onebot.v11 import MessageSegment
|
||||||
|
|
||||||
from .draw_help_card import draw_help_img
|
from .draw_help_card import draw_help_img
|
||||||
from ..genshinuid_meta import register_menu
|
from ..genshinuid_meta import register_menu
|
||||||
@ -22,12 +22,15 @@ HELP_IMG = Path(__file__).parent / 'help.png'
|
|||||||
'插件帮助',
|
'插件帮助',
|
||||||
'gs帮助',
|
'gs帮助',
|
||||||
'查看插件功能帮助图',
|
'查看插件功能帮助图',
|
||||||
detail_des=('指令:' '<ft color=(238,120,0)>gs帮助</ft>\n' ' \n' '查看插件功能帮助图'),
|
detail_des=(
|
||||||
|
'介绍:\n' '查看插件功能帮助图\n' ' \n' '指令:\n' '- <ft color=(238,120,0)>gs帮助</ft>'
|
||||||
|
),
|
||||||
)
|
)
|
||||||
async def send_guide_pic(matcher: Matcher):
|
async def send_guide_pic(matcher: Matcher):
|
||||||
logger.info('获得gs帮助图片成功!')
|
logger.info('获得gs帮助图片成功!')
|
||||||
if HELP_IMG.exists():
|
if HELP_IMG.exists():
|
||||||
await matcher.finish(MessageSegment.file_image(HELP_IMG))
|
with open(HELP_IMG, 'rb') as f:
|
||||||
|
await matcher.finish(MessageSegment.image(f.read()))
|
||||||
else:
|
else:
|
||||||
await matcher.finish('帮助图不存在!')
|
await matcher.finish('帮助图不存在!')
|
||||||
|
|
||||||
|
@ -129,6 +129,7 @@ async def send_find_map_msg(
|
|||||||
logger.info('本地未缓存,正在渲染...')
|
logger.info('本地未缓存,正在渲染...')
|
||||||
im = await draw_genshin_map(name, map_id, map_name)
|
im = await draw_genshin_map(name, map_id, map_name)
|
||||||
if isinstance(im, str):
|
if isinstance(im, str):
|
||||||
|
# 如果无结果,直接不返回
|
||||||
await matcher.finish()
|
await matcher.finish()
|
||||||
elif isinstance(im, bytes):
|
elif isinstance(im, bytes):
|
||||||
await matcher.finish(MessageSegment.image(im))
|
await matcher.finish(MessageSegment.image(im))
|
||||||
|
@ -12,8 +12,17 @@ __plugin_meta__ = PluginMetadata(
|
|||||||
'<ft color=(0,148,200)>[序号]</ft> '
|
'<ft color=(0,148,200)>[序号]</ft> '
|
||||||
'指令获取某功能详细介绍\n'
|
'指令获取某功能详细介绍\n'
|
||||||
' \n'
|
' \n'
|
||||||
'示例指令小括号中的内容为可选参数,可以省略;\n'
|
'菜单描述中的指令:\n'
|
||||||
'中括号中的内容或者用“xx”代表的内容为必选参数,请将它们替换为对应的参数'
|
'<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'},
|
extra={'menu_data': sub_menus, 'menu_template': 'default'},
|
||||||
)
|
)
|
||||||
|
@ -6,10 +6,12 @@ from nonebot.matcher import Matcher
|
|||||||
from nonebot import get_bot, on_command
|
from nonebot import get_bot, on_command
|
||||||
from nonebot.permission import SUPERUSER
|
from nonebot.permission import SUPERUSER
|
||||||
from nonebot_plugin_apscheduler import scheduler
|
from nonebot_plugin_apscheduler import scheduler
|
||||||
from nonebot.adapters.qqguild import MessageEvent
|
from nonebot.adapters.onebot.v11 import MessageEvent
|
||||||
|
|
||||||
from ..config import SUPERUSERS, priority
|
from ..config import priority
|
||||||
|
from ..genshinuid_meta import register_menu
|
||||||
from ..utils.nonebot2.rule import FullCommand
|
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 ..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
|
||||||
@ -25,15 +27,39 @@ all_bbscoin_recheck = on_command(
|
|||||||
# 获取米游币
|
# 获取米游币
|
||||||
@get_mihoyo_coin.handle()
|
@get_mihoyo_coin.handle()
|
||||||
@handle_exception('获取米游币')
|
@handle_exception('获取米游币')
|
||||||
|
@register_menu(
|
||||||
|
'手动获取米游币',
|
||||||
|
'开始获取米游币',
|
||||||
|
'手动触发米游社米游币任务',
|
||||||
|
detail_des=(
|
||||||
|
'介绍:\n'
|
||||||
|
'手动触发米游社获取米游币的任务\n'
|
||||||
|
' \n'
|
||||||
|
'指令:\n'
|
||||||
|
'- <ft color=(238,120,0)>开始获取米游币</ft>'
|
||||||
|
),
|
||||||
|
)
|
||||||
async def send_mihoyo_coin(event: MessageEvent, matcher: Matcher):
|
async def send_mihoyo_coin(event: MessageEvent, matcher: Matcher):
|
||||||
await matcher.send('开始操作……', at_sender=True)
|
await matcher.send('开始操作……', at_sender=True)
|
||||||
qid = int(event.sender.user_id) # type: ignore
|
qid = event.user_id
|
||||||
im = await mihoyo_coin(qid)
|
im = await mihoyo_coin(qid)
|
||||||
await matcher.finish(im, at_sender=True)
|
await matcher.finish(im, at_sender=True)
|
||||||
|
|
||||||
|
|
||||||
@all_bbscoin_recheck.handle()
|
@all_bbscoin_recheck.handle()
|
||||||
@handle_exception('米游币全部重获取')
|
@handle_exception('米游币全部重获取')
|
||||||
|
@register_menu(
|
||||||
|
'重新获取米游币',
|
||||||
|
'全部重获取',
|
||||||
|
'重新运行所有自动获取米游币的任务',
|
||||||
|
detail_des=(
|
||||||
|
'介绍:\n'
|
||||||
|
'重新运行所有自动获取米游币的任务\n'
|
||||||
|
' \n'
|
||||||
|
'指令:\n'
|
||||||
|
'- <ft color=(238,120,0)>全部重获取</ft>'
|
||||||
|
),
|
||||||
|
)
|
||||||
async def bbs_recheck(
|
async def bbs_recheck(
|
||||||
matcher: Matcher,
|
matcher: Matcher,
|
||||||
):
|
):
|
||||||
@ -59,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 SUPERUSERS:
|
for qid in get_superusers():
|
||||||
await bot.call_api(api='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('米游币获取已结束。')
|
||||||
|
@ -5,14 +5,19 @@ from nonebot.log import logger
|
|||||||
from nonebot.matcher import Matcher
|
from nonebot.matcher import Matcher
|
||||||
from nonebot.params import RegexGroup
|
from nonebot.params import RegexGroup
|
||||||
from nonebot import on_regex, on_command
|
from nonebot import on_regex, on_command
|
||||||
from nonebot.adapters.qqguild import Bot, MessageEvent, MessageSegment
|
from nonebot.adapters.onebot.v11 import (
|
||||||
|
Bot,
|
||||||
|
MessageEvent,
|
||||||
|
MessageSegment,
|
||||||
|
GroupMessageEvent,
|
||||||
|
)
|
||||||
|
|
||||||
from ..config import priority
|
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 .get_mys_data import get_task_detail
|
from ..genshinuid_meta import register_menu
|
||||||
from ..utils.nonebot2.rule import FullCommand
|
from ..utils.nonebot2.rule import FullCommand
|
||||||
from ..utils.message.cast_type import cast_to_int
|
from .get_mys_data import get_region_task, get_task_detail
|
||||||
from ..utils.exception.handle_exception import handle_exception
|
from ..utils.exception.handle_exception import handle_exception
|
||||||
|
|
||||||
get_task_adv = on_regex(
|
get_task_adv = on_regex(
|
||||||
@ -24,15 +29,32 @@ get_lots = on_command('御神签', priority=priority, rule=FullCommand())
|
|||||||
|
|
||||||
@get_task_adv.handle()
|
@get_task_adv.handle()
|
||||||
@handle_exception('任务攻略')
|
@handle_exception('任务攻略')
|
||||||
|
@register_menu(
|
||||||
|
'任务攻略',
|
||||||
|
'任务xx',
|
||||||
|
'查询某任务的攻略',
|
||||||
|
detail_des=(
|
||||||
|
'介绍:\n'
|
||||||
|
'查询指定任务或指定地区的攻略\n'
|
||||||
|
' \n'
|
||||||
|
'指令:\n'
|
||||||
|
'- <ft color=(238,120,0)>{原神任务|任务|任务详情|任务攻略}</ft>'
|
||||||
|
'<ft color=(238,120,0)>{</ft>'
|
||||||
|
'<ft color=(0,148,200)>[任务名]</ft>'
|
||||||
|
'<ft color=(238,120,0)>|须弥|层岩|海岛}</ft>\n'
|
||||||
|
' \n'
|
||||||
|
'示例:\n'
|
||||||
|
'- <ft color=(238,120,0)>任务神樱大祓</ft>\n'
|
||||||
|
'- <ft color=(238,120,0)>任务须弥</ft>'
|
||||||
|
),
|
||||||
|
)
|
||||||
async def send_task_adv(
|
async def send_task_adv(
|
||||||
bot: Bot,
|
bot: Bot,
|
||||||
event: MessageEvent,
|
event: GroupMessageEvent,
|
||||||
matcher: Matcher,
|
matcher: Matcher,
|
||||||
args: Tuple[Any, ...] = RegexGroup(),
|
args: Tuple[Any, ...] = RegexGroup(),
|
||||||
):
|
):
|
||||||
if str(args[2]) in ['须弥', '层岩', '海岛']:
|
if str(args[2]) in ['须弥', '层岩', '海岛']:
|
||||||
pass
|
|
||||||
'''
|
|
||||||
im = await get_region_task(str(args[2]))
|
im = await get_region_task(str(args[2]))
|
||||||
for i in im:
|
for i in im:
|
||||||
await bot.call_api(
|
await bot.call_api(
|
||||||
@ -40,7 +62,6 @@ async def send_task_adv(
|
|||||||
)
|
)
|
||||||
await asyncio.sleep(1)
|
await asyncio.sleep(1)
|
||||||
await matcher.finish()
|
await matcher.finish()
|
||||||
'''
|
|
||||||
else:
|
else:
|
||||||
im = await get_task_detail(str(args[2]))
|
im = await get_task_detail(str(args[2]))
|
||||||
await matcher.finish(im)
|
await matcher.finish(im)
|
||||||
@ -48,16 +69,36 @@ async def send_task_adv(
|
|||||||
|
|
||||||
@get_meme.handle()
|
@get_meme.handle()
|
||||||
@handle_exception('抽表情')
|
@handle_exception('抽表情')
|
||||||
|
@register_menu(
|
||||||
|
'抽表情',
|
||||||
|
'抽表情',
|
||||||
|
'随机发送一张札记角色表情',
|
||||||
|
detail_des=(
|
||||||
|
'介绍:\n'
|
||||||
|
'随机发送一张札记角色表情\n'
|
||||||
|
' \n'
|
||||||
|
'指令:\n'
|
||||||
|
'- <ft color=(238,120,0)>抽表情</ft>'
|
||||||
|
),
|
||||||
|
)
|
||||||
async def send_meme_card(matcher: Matcher):
|
async def send_meme_card(matcher: Matcher):
|
||||||
logger.info('开始执行[抽表情]')
|
logger.info('开始执行[抽表情]')
|
||||||
img = await get_meme_img()
|
img = await get_meme_img()
|
||||||
await matcher.finish(MessageSegment.file_image(img))
|
await matcher.finish(MessageSegment.image(img))
|
||||||
|
|
||||||
|
|
||||||
@get_lots.handle()
|
@get_lots.handle()
|
||||||
@handle_exception('御神签')
|
@handle_exception('御神签')
|
||||||
|
@register_menu(
|
||||||
|
'御神签',
|
||||||
|
'御神签',
|
||||||
|
'鸣神大社御神签',
|
||||||
|
detail_des=(
|
||||||
|
'介绍:\n' '抽一签鸣神大社御神签\n' ' \n' '指令:\n' '- <ft color=(238,120,0)>御神签</ft>'
|
||||||
|
),
|
||||||
|
)
|
||||||
async def send_lots_data(matcher: Matcher, event: MessageEvent):
|
async def send_lots_data(matcher: Matcher, event: MessageEvent):
|
||||||
qid = cast_to_int(event.author)
|
qid = event.user_id
|
||||||
logger.info('开始执行[御神签]')
|
logger.info('开始执行[御神签]')
|
||||||
im = await get_lots_msg(qid)
|
im = await get_lots_msg(qid)
|
||||||
await matcher.finish(im)
|
await matcher.finish(im)
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
from nonebot import on_command
|
from nonebot import on_command
|
||||||
from nonebot.log import logger
|
from nonebot.log import logger
|
||||||
from nonebot.matcher import Matcher
|
from nonebot.matcher import Matcher
|
||||||
from nonebot.adapters.qqguild import MessageEvent, MessageSegment
|
from nonebot.adapters.onebot.v11 import MessageEvent, MessageSegment
|
||||||
|
|
||||||
from .note_text import award
|
from .note_text import award
|
||||||
from ..config import priority
|
from ..config import priority
|
||||||
from .draw_note_card import draw_note_img
|
from .draw_note_card import draw_note_img
|
||||||
|
from ..genshinuid_meta import register_menu
|
||||||
from ..utils.nonebot2.rule import FullCommand
|
from ..utils.nonebot2.rule import FullCommand
|
||||||
from ..utils.message.cast_type import cast_to_int
|
|
||||||
from ..utils.db_operation.db_operation import select_db
|
from ..utils.db_operation.db_operation import select_db
|
||||||
from ..utils.message.error_reply import CK_HINT, UID_HINT
|
from ..utils.message.error_reply import CK_HINT, UID_HINT
|
||||||
from ..utils.exception.handle_exception import handle_exception
|
from ..utils.exception.handle_exception import handle_exception
|
||||||
@ -21,13 +21,20 @@ get_genshin_info = on_command(
|
|||||||
# 群聊内 每月统计 功能
|
# 群聊内 每月统计 功能
|
||||||
@monthly_data.handle()
|
@monthly_data.handle()
|
||||||
@handle_exception('每月统计', '获取/发送每月统计失败', '@未找到绑定信息\n' + CK_HINT)
|
@handle_exception('每月统计', '获取/发送每月统计失败', '@未找到绑定信息\n' + CK_HINT)
|
||||||
|
@register_menu(
|
||||||
|
'文字札记',
|
||||||
|
'每月统计',
|
||||||
|
'文字形式米游社札记',
|
||||||
|
detail_des=(
|
||||||
|
'介绍:\n' '文字形式米游社札记\n' ' \n' '指令:\n' '- <ft color=(238,120,0)>每月统计</ft>'
|
||||||
|
),
|
||||||
|
)
|
||||||
async def send_monthly_data(
|
async def send_monthly_data(
|
||||||
event: MessageEvent,
|
event: MessageEvent,
|
||||||
matcher: Matcher,
|
matcher: Matcher,
|
||||||
):
|
):
|
||||||
qid = cast_to_int(event.author)
|
qid = event.user_id
|
||||||
logger.info('[每月统计]QQ号: {}'.format(qid))
|
uid = await select_db(qid, mode='uid')
|
||||||
uid = await select_db(str(qid), mode='uid')
|
|
||||||
if isinstance(uid, str):
|
if isinstance(uid, str):
|
||||||
if '未找到绑定的UID' in uid:
|
if '未找到绑定的UID' in uid:
|
||||||
await matcher.finish(UID_HINT)
|
await matcher.finish(UID_HINT)
|
||||||
@ -40,13 +47,26 @@ async def send_monthly_data(
|
|||||||
# 群聊内 每月统计 功能
|
# 群聊内 每月统计 功能
|
||||||
@get_genshin_info.handle()
|
@get_genshin_info.handle()
|
||||||
@handle_exception('每月统计', '获取/发送每月统计失败', '@未找到绑定信息\n' + CK_HINT)
|
@handle_exception('每月统计', '获取/发送每月统计失败', '@未找到绑定信息\n' + CK_HINT)
|
||||||
|
@register_menu(
|
||||||
|
'图片札记',
|
||||||
|
'当前信息',
|
||||||
|
'图片形式米游社札记',
|
||||||
|
detail_des=(
|
||||||
|
'介绍:\n'
|
||||||
|
'图片形式米游社札记\n'
|
||||||
|
' \n'
|
||||||
|
'指令:\n'
|
||||||
|
'- <ft color=(238,120,0)>当前信息</ft>\n'
|
||||||
|
'- <ft color=(125,125,125)>(原石)</ft><ft color=(238,120,0)>札记</ft>\n'
|
||||||
|
'- <ft color=(238,120,0)>zj</ft>'
|
||||||
|
),
|
||||||
|
)
|
||||||
async def send_monthly_pic(
|
async def send_monthly_pic(
|
||||||
event: MessageEvent,
|
event: MessageEvent,
|
||||||
matcher: Matcher,
|
matcher: Matcher,
|
||||||
):
|
):
|
||||||
qid = cast_to_int(event.author)
|
qid = event.user_id
|
||||||
logger.info('[原石札记]QQ号: {}'.format(qid))
|
uid = await select_db(qid, mode='uid')
|
||||||
uid = await select_db(str(qid), mode='uid')
|
|
||||||
if isinstance(uid, str):
|
if isinstance(uid, str):
|
||||||
if '未找到绑定的UID' in uid:
|
if '未找到绑定的UID' in uid:
|
||||||
await matcher.finish(UID_HINT)
|
await matcher.finish(UID_HINT)
|
||||||
@ -57,6 +77,6 @@ async def send_monthly_pic(
|
|||||||
if isinstance(im, str):
|
if isinstance(im, str):
|
||||||
await matcher.finish(im)
|
await matcher.finish(im)
|
||||||
elif isinstance(im, bytes):
|
elif isinstance(im, bytes):
|
||||||
await matcher.finish(MessageSegment.file_image(im))
|
await matcher.finish(MessageSegment.image(im))
|
||||||
else:
|
else:
|
||||||
await matcher.finish('发生了未知错误,请联系管理员检查后台输出!')
|
await matcher.finish('发生了未知错误,请联系管理员检查后台输出!')
|
||||||
|
@ -1,18 +1,23 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
|
from typing import Union
|
||||||
|
|
||||||
from nonebot.log import logger
|
from nonebot.log import logger
|
||||||
from nonebot.params import Depends
|
from nonebot.params import Depends
|
||||||
from nonebot.matcher import Matcher
|
from nonebot.matcher import Matcher
|
||||||
from nonebot import get_bot, on_command
|
from nonebot import get_bot, on_command
|
||||||
from nonebot_plugin_apscheduler import scheduler
|
from nonebot_plugin_apscheduler import scheduler
|
||||||
from nonebot.adapters.qqguild import MessageEvent, MessageSegment
|
from nonebot.adapters.onebot.v11 import (
|
||||||
|
MessageSegment,
|
||||||
|
GroupMessageEvent,
|
||||||
|
PrivateMessageEvent,
|
||||||
|
)
|
||||||
|
|
||||||
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.nonebot2.rule import FullCommand
|
||||||
from ..utils.message.error_reply import UID_HINT
|
from ..utils.message.error_reply import UID_HINT
|
||||||
from ..utils.message.cast_type import cast_to_int
|
|
||||||
from ..utils.db_operation.db_operation import select_db
|
from ..utils.db_operation.db_operation import select_db
|
||||||
from ..utils.message.get_image_and_at import ImageAndAt
|
from ..utils.message.get_image_and_at import ImageAndAt
|
||||||
from ..utils.exception.handle_exception import handle_exception
|
from ..utils.exception.handle_exception import handle_exception
|
||||||
@ -29,15 +34,27 @@ get_daily_info = on_command('当前状态', rule=FullCommand())
|
|||||||
|
|
||||||
@get_daily_info.handle()
|
@get_daily_info.handle()
|
||||||
@handle_exception('每日信息文字版')
|
@handle_exception('每日信息文字版')
|
||||||
|
@register_menu(
|
||||||
|
'文字实时便笺',
|
||||||
|
'当前信息',
|
||||||
|
'米游社实时便笺文字版',
|
||||||
|
detail_des=(
|
||||||
|
'介绍:\n'
|
||||||
|
'米游社实时便笺文字版\n'
|
||||||
|
' \n'
|
||||||
|
'指令:\n'
|
||||||
|
'- <ft color=(238,120,0)>当前状态</ft>'
|
||||||
|
),
|
||||||
|
)
|
||||||
async def send_daily_info(
|
async def send_daily_info(
|
||||||
event: MessageEvent,
|
event: Union[GroupMessageEvent, PrivateMessageEvent],
|
||||||
matcher: Matcher,
|
matcher: Matcher,
|
||||||
custom: ImageAndAt = Depends(),
|
custom: ImageAndAt = Depends(),
|
||||||
):
|
):
|
||||||
logger.info('开始执行[每日信息文字版]')
|
logger.info('开始执行[每日信息文字版]')
|
||||||
|
|
||||||
at = custom.get_first_at()
|
at = custom.get_first_at()
|
||||||
qid = at or cast_to_int(event.author)
|
qid = event.user_id
|
||||||
if at:
|
if at:
|
||||||
qid = at
|
qid = at
|
||||||
logger.info('[每日信息文字版]QQ号: {}'.format(qid))
|
logger.info('[每日信息文字版]QQ号: {}'.format(qid))
|
||||||
@ -85,23 +102,39 @@ async def notice_job():
|
|||||||
|
|
||||||
@get_resin_info.handle()
|
@get_resin_info.handle()
|
||||||
@handle_exception('每日信息')
|
@handle_exception('每日信息')
|
||||||
|
@register_menu(
|
||||||
|
'图片实时便笺',
|
||||||
|
'每日',
|
||||||
|
'图片形式米游社实时便笺',
|
||||||
|
detail_des=(
|
||||||
|
'介绍:\n'
|
||||||
|
'图片形式米游社实时便笺\n'
|
||||||
|
' \n'
|
||||||
|
'指令:\n'
|
||||||
|
'- <ft color=(238,120,0)>每日</ft>\n'
|
||||||
|
'- <ft color=(238,120,0)>mr</ft>\n'
|
||||||
|
'- <ft color=(238,120,0)>状态</ft>\n'
|
||||||
|
'- <ft color=(125,125,125)>(实时)</ft><ft color=(238,120,0)>便笺</ft>\n'
|
||||||
|
'- <ft color=(238,120,0)>便签</ft>'
|
||||||
|
),
|
||||||
|
)
|
||||||
async def send_uid_info(
|
async def send_uid_info(
|
||||||
event: MessageEvent,
|
event: Union[GroupMessageEvent, PrivateMessageEvent],
|
||||||
matcher: Matcher,
|
matcher: Matcher,
|
||||||
custom: ImageAndAt = Depends(),
|
custom: ImageAndAt = Depends(),
|
||||||
):
|
):
|
||||||
logger.info('开始执行[每日信息]')
|
logger.info('开始执行[每日信息]')
|
||||||
|
|
||||||
at = custom.get_first_at()
|
at = custom.get_first_at()
|
||||||
qid = at or cast_to_int(event.author)
|
qid = event.user_id
|
||||||
if at:
|
if at:
|
||||||
qid = at
|
qid = at
|
||||||
logger.info('[每日信息]QQ号: {}'.format(qid))
|
logger.info('[每日信息]QQ号: {}'.format(qid))
|
||||||
qid = int(qid)
|
|
||||||
im = await get_resin_img(qid)
|
im = await get_resin_img(qid)
|
||||||
if isinstance(im, str):
|
if isinstance(im, str):
|
||||||
await matcher.finish(im)
|
await matcher.finish(im)
|
||||||
elif isinstance(im, bytes):
|
elif isinstance(im, bytes):
|
||||||
await matcher.finish(MessageSegment.file_image(im))
|
await matcher.finish(MessageSegment.image(im))
|
||||||
else:
|
else:
|
||||||
await matcher.finish('发生了未知错误,请联系管理员检查后台输出!')
|
await matcher.finish('发生了未知错误,请联系管理员检查后台输出!')
|
||||||
|
@ -1,12 +1,18 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
import threading
|
import threading
|
||||||
|
from typing import Union
|
||||||
|
|
||||||
from nonebot import on_command
|
from nonebot import on_command
|
||||||
from nonebot.log import logger
|
from nonebot.log import logger
|
||||||
from nonebot.matcher import Matcher
|
from nonebot.matcher import Matcher
|
||||||
from nonebot.permission import SUPERUSER
|
from nonebot.permission import SUPERUSER
|
||||||
from nonebot.adapters.qqguild import Bot, MessageEvent
|
from nonebot.adapters.onebot.v11 import (
|
||||||
|
Bot,
|
||||||
|
GroupMessageEvent,
|
||||||
|
PrivateMessageEvent,
|
||||||
|
)
|
||||||
|
|
||||||
|
from ..genshinuid_meta import register_menu
|
||||||
from ..utils.nonebot2.rule import FullCommand
|
from ..utils.nonebot2.rule import FullCommand
|
||||||
from ..utils.exception.handle_exception import handle_exception
|
from ..utils.exception.handle_exception import handle_exception
|
||||||
from ..utils.download_resource.download_all_resource import (
|
from ..utils.download_resource.download_all_resource import (
|
||||||
@ -18,9 +24,22 @@ download_resource = on_command('下载全部资源', rule=FullCommand())
|
|||||||
|
|
||||||
@download_resource.handle()
|
@download_resource.handle()
|
||||||
@handle_exception('下载全部资源', '资源下载错误')
|
@handle_exception('下载全部资源', '资源下载错误')
|
||||||
|
@register_menu(
|
||||||
|
'下载全部资源',
|
||||||
|
'下载全部资源',
|
||||||
|
'手动下载插件运行所需的资源',
|
||||||
|
trigger_method='管理员指令',
|
||||||
|
detail_des=(
|
||||||
|
'介绍:\n'
|
||||||
|
'手动下载插件正常运行所需的资源(一般每次启动会自动检查并下载)\n'
|
||||||
|
' \n'
|
||||||
|
'指令:\n'
|
||||||
|
'- <ft color=(238,120,0)>下载全部资源</ft>'
|
||||||
|
),
|
||||||
|
)
|
||||||
async def send_download_resource_msg(
|
async def send_download_resource_msg(
|
||||||
bot: Bot,
|
bot: Bot,
|
||||||
event: MessageEvent,
|
event: Union[GroupMessageEvent, PrivateMessageEvent],
|
||||||
matcher: Matcher,
|
matcher: Matcher,
|
||||||
):
|
):
|
||||||
if not await SUPERUSER(bot, event):
|
if not await SUPERUSER(bot, event):
|
||||||
|
@ -1,16 +1,22 @@
|
|||||||
import re
|
import re
|
||||||
|
from typing import Union
|
||||||
|
|
||||||
from nonebot import on_command
|
from nonebot import on_command
|
||||||
from nonebot.log import logger
|
from nonebot.log import logger
|
||||||
from nonebot.matcher import Matcher
|
from nonebot.matcher import Matcher
|
||||||
from nonebot.params import Depends, CommandArg
|
from nonebot.params import Depends, CommandArg
|
||||||
from nonebot.adapters.qqguild import Message, MessageEvent, MessageSegment
|
from nonebot.adapters.onebot.v11 import (
|
||||||
|
Message,
|
||||||
|
MessageSegment,
|
||||||
|
GroupMessageEvent,
|
||||||
|
PrivateMessageEvent,
|
||||||
|
)
|
||||||
|
|
||||||
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.nonebot2.rule import FullCommand
|
||||||
from ..utils.message.error_reply import UID_HINT
|
from ..utils.message.error_reply import UID_HINT
|
||||||
from ..utils.message.cast_type import cast_to_int
|
|
||||||
from ..utils.db_operation.db_operation import select_db
|
from ..utils.db_operation.db_operation import select_db
|
||||||
from ..utils.message.get_image_and_at import ImageAndAt
|
from ..utils.message.get_image_and_at import ImageAndAt
|
||||||
from ..utils.exception.handle_exception import handle_exception
|
from ..utils.exception.handle_exception import handle_exception
|
||||||
@ -23,8 +29,31 @@ get_reg_time = on_command(
|
|||||||
|
|
||||||
@get_role_info.handle()
|
@get_role_info.handle()
|
||||||
@handle_exception('查询角色信息')
|
@handle_exception('查询角色信息')
|
||||||
|
@register_menu(
|
||||||
|
'查询帐号信息',
|
||||||
|
'查询',
|
||||||
|
'帐号基础数据与角色信息总览',
|
||||||
|
detail_des=(
|
||||||
|
'介绍:\n'
|
||||||
|
'查询帐号探索度、声望、宝箱收集、角色总览等等基础数据\n'
|
||||||
|
'未绑定CK时最多只能查询8个角色信息\n'
|
||||||
|
' \n'
|
||||||
|
'指令:\n'
|
||||||
|
'- <ft color=(238,120,0)>{查询|uid}</ft>'
|
||||||
|
'<ft color=(125,125,125)>({@某人|[UID]})</ft>\n'
|
||||||
|
'- <ft color=(238,120,0)>mys</ft>'
|
||||||
|
'<ft color=(125,125,125)>({@某人|[米游社ID]})</ft>\n'
|
||||||
|
'- <ft color=(238,120,0)>直接发送九位数UID</ft>\n'
|
||||||
|
' \n'
|
||||||
|
'示例:\n'
|
||||||
|
'- <ft color=(238,120,0)>查询</ft>\n'
|
||||||
|
'- <ft color=(238,120,0)>查询</ft><ft color=(0,123,67)>@无疑Wuyi</ft>\n'
|
||||||
|
'- <ft color=(238,120,0)>uid123456789</ft>\n'
|
||||||
|
'- <ft color=(238,120,0)>123456789</ft>'
|
||||||
|
),
|
||||||
|
)
|
||||||
async def send_role_info(
|
async def send_role_info(
|
||||||
event: MessageEvent,
|
event: Union[GroupMessageEvent, PrivateMessageEvent],
|
||||||
matcher: Matcher,
|
matcher: Matcher,
|
||||||
args: Message = CommandArg(),
|
args: Message = CommandArg(),
|
||||||
custom: ImageAndAt = Depends(),
|
custom: ImageAndAt = Depends(),
|
||||||
@ -33,12 +62,10 @@ async def send_role_info(
|
|||||||
name = ''.join(re.findall('[\u4e00-\u9fa5]', raw_mes))
|
name = ''.join(re.findall('[\u4e00-\u9fa5]', raw_mes))
|
||||||
if name:
|
if name:
|
||||||
return
|
return
|
||||||
|
qid = event.user_id
|
||||||
at = custom.get_first_at()
|
at = custom.get_first_at()
|
||||||
qid = at or cast_to_int(event.author)
|
|
||||||
if at:
|
if at:
|
||||||
qid = at
|
qid = at
|
||||||
qid = str(qid)
|
|
||||||
|
|
||||||
# 获取uid
|
# 获取uid
|
||||||
uid = re.findall(r'\d+', raw_mes)
|
uid = re.findall(r'\d+', raw_mes)
|
||||||
@ -47,8 +74,8 @@ async def send_role_info(
|
|||||||
else:
|
else:
|
||||||
uid = await select_db(qid, mode='uid')
|
uid = await select_db(qid, mode='uid')
|
||||||
uid = str(uid)
|
uid = str(uid)
|
||||||
logger.info('开始执行[查询角色信息]')
|
|
||||||
|
|
||||||
|
logger.info('开始执行[查询角色信息]')
|
||||||
logger.info('[查询角色信息]参数: {}'.format(args))
|
logger.info('[查询角色信息]参数: {}'.format(args))
|
||||||
logger.info('[查询角色信息]uid: {}'.format(uid))
|
logger.info('[查询角色信息]uid: {}'.format(uid))
|
||||||
|
|
||||||
@ -60,22 +87,21 @@ async def send_role_info(
|
|||||||
if isinstance(im, str):
|
if isinstance(im, str):
|
||||||
await matcher.finish(im)
|
await matcher.finish(im)
|
||||||
elif isinstance(im, bytes):
|
elif isinstance(im, bytes):
|
||||||
await matcher.finish(MessageSegment.file_image(im))
|
await matcher.finish(MessageSegment.image(im))
|
||||||
else:
|
else:
|
||||||
await matcher.finish('发生了未知错误,请联系管理员检查后台输出!')
|
await matcher.finish('发生了未知错误,请联系管理员检查后台输出!')
|
||||||
|
|
||||||
|
|
||||||
@get_reg_time.handle()
|
@get_reg_time.handle()
|
||||||
async def regtime(
|
async def regtime(
|
||||||
event: MessageEvent,
|
event: Union[GroupMessageEvent, PrivateMessageEvent],
|
||||||
matcher: Matcher,
|
matcher: Matcher,
|
||||||
custom: ImageAndAt = Depends(),
|
custom: ImageAndAt = Depends(),
|
||||||
):
|
):
|
||||||
|
qid = event.user_id
|
||||||
at = custom.get_first_at()
|
at = custom.get_first_at()
|
||||||
qid = at or cast_to_int(event.author)
|
|
||||||
if at:
|
if at:
|
||||||
qid = at
|
qid = at
|
||||||
qid = str(qid)
|
|
||||||
|
|
||||||
uid = await select_db(qid, mode='uid')
|
uid = await select_db(qid, mode='uid')
|
||||||
uid = str(uid)
|
uid = str(uid)
|
||||||
|
@ -5,8 +5,7 @@ from nonebot.log import logger
|
|||||||
from nonebot.matcher import Matcher
|
from nonebot.matcher import Matcher
|
||||||
from nonebot import get_bot, on_command
|
from nonebot import get_bot, on_command
|
||||||
from nonebot.permission import SUPERUSER
|
from nonebot.permission import SUPERUSER
|
||||||
from nonebot_plugin_apscheduler import scheduler
|
from nonebot.adapters.onebot.v11 import MessageEvent
|
||||||
from nonebot.adapters.qqguild import MessageEvent
|
|
||||||
|
|
||||||
from ..config import priority
|
from ..config import priority
|
||||||
|
|
||||||
@ -15,8 +14,10 @@ try:
|
|||||||
except ImportError:
|
except ImportError:
|
||||||
from .sign import sign_in, daily_sign
|
from .sign import sign_in, daily_sign
|
||||||
|
|
||||||
|
from nonebot_plugin_apscheduler import scheduler
|
||||||
|
|
||||||
|
from ..genshinuid_meta import register_menu
|
||||||
from ..utils.nonebot2.rule import FullCommand
|
from ..utils.nonebot2.rule import FullCommand
|
||||||
from ..utils.message.cast_type import cast_to_int
|
|
||||||
from ..utils.exception.handle_exception import handle_exception
|
from ..utils.exception.handle_exception import handle_exception
|
||||||
from ..utils.db_operation.db_operation import select_db, config_check
|
from ..utils.db_operation.db_operation import select_db, config_check
|
||||||
|
|
||||||
@ -38,14 +39,26 @@ async def sign_at_night():
|
|||||||
# 群聊内 签到 功能
|
# 群聊内 签到 功能
|
||||||
@get_sign.handle()
|
@get_sign.handle()
|
||||||
@handle_exception('签到')
|
@handle_exception('签到')
|
||||||
|
@register_menu(
|
||||||
|
'手动米游社原神签到',
|
||||||
|
'签到',
|
||||||
|
'手动触发米游社原神签到任务',
|
||||||
|
detail_des=(
|
||||||
|
'介绍:\n'
|
||||||
|
'手动触发米游社原神签到任务\n'
|
||||||
|
' \n'
|
||||||
|
'指令:\n'
|
||||||
|
'- <ft color=(238,120,0)>签到</ft>'
|
||||||
|
),
|
||||||
|
)
|
||||||
async def get_sign_func(
|
async def get_sign_func(
|
||||||
event: MessageEvent,
|
event: MessageEvent,
|
||||||
matcher: Matcher,
|
matcher: Matcher,
|
||||||
):
|
):
|
||||||
logger.info('开始执行[签到]')
|
logger.info('开始执行[签到]')
|
||||||
qid = cast_to_int(event.author)
|
qid = event.user_id
|
||||||
logger.info('[签到]QQ号: {}'.format(qid))
|
logger.info('[签到]QQ号: {}'.format(qid))
|
||||||
uid = await select_db(str(qid), mode='uid')
|
uid = await select_db(qid, mode='uid')
|
||||||
logger.info('[签到]UID: {}'.format(uid))
|
logger.info('[签到]UID: {}'.format(uid))
|
||||||
im = await sign_in(uid)
|
im = await sign_in(uid)
|
||||||
await matcher.finish(im, at_sender=True)
|
await matcher.finish(im, at_sender=True)
|
||||||
@ -53,6 +66,18 @@ async def get_sign_func(
|
|||||||
|
|
||||||
@all_recheck.handle()
|
@all_recheck.handle()
|
||||||
@handle_exception('全部重签')
|
@handle_exception('全部重签')
|
||||||
|
@register_menu(
|
||||||
|
'米游社原神重签到',
|
||||||
|
'全部重签',
|
||||||
|
'重新运行所有自动米游社原神签到任务',
|
||||||
|
detail_des=(
|
||||||
|
'介绍:\n'
|
||||||
|
'重新运行所有自动米游社原神签到任务\n'
|
||||||
|
' \n'
|
||||||
|
'指令:\n'
|
||||||
|
'- <ft color=(238,120,0)>全部重签</ft>'
|
||||||
|
),
|
||||||
|
)
|
||||||
async def recheck(matcher: Matcher):
|
async def recheck(matcher: Matcher):
|
||||||
logger.info('开始执行[全部重签]')
|
logger.info('开始执行[全部重签]')
|
||||||
await matcher.send('已开始执行')
|
await matcher.send('已开始执行')
|
||||||
|
@ -4,22 +4,26 @@ from nonebot.log import logger
|
|||||||
from nonebot.matcher import Matcher
|
from nonebot.matcher import Matcher
|
||||||
from nonebot.params import RegexGroup
|
from nonebot.params import RegexGroup
|
||||||
from nonebot.permission import SUPERUSER
|
from nonebot.permission import SUPERUSER
|
||||||
from nonebot import get_bot, on_regex, get_driver
|
from nonebot import get_bot, on_regex, get_driver, on_command
|
||||||
from nonebot.adapters.qqguild import Bot, MessageEvent, MessageSegment
|
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 ..utils.message.cast_type import cast_to_int
|
|
||||||
from .restart import restart_message, restart_genshinuid
|
from .restart import restart_message, restart_genshinuid
|
||||||
|
|
||||||
gs_restart = on_regex(r'^(gs)(重启)$')
|
gs_restart = on_command('gs重启', rule=FullCommand())
|
||||||
get_update_log = on_regex(r'更新记录')
|
get_update_log = on_command('更新记录', rule=FullCommand())
|
||||||
gs_update = on_regex(
|
gs_update = on_regex(
|
||||||
r'^(gs)(强行)?(强制)?(更新)$',
|
r'^(gs)(强行)?(强制)?(更新)$',
|
||||||
block=True,
|
block=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@get_driver().on_bot_connect
|
driver = get_driver()
|
||||||
|
|
||||||
|
|
||||||
|
@driver.on_bot_connect
|
||||||
async def _():
|
async def _():
|
||||||
logger.info('检查遗留信息...')
|
logger.info('检查遗留信息...')
|
||||||
bot = get_bot()
|
bot = get_bot()
|
||||||
@ -41,22 +45,19 @@ async def _():
|
|||||||
logger.info('遗留信息检查完毕!')
|
logger.info('遗留信息检查完毕!')
|
||||||
|
|
||||||
|
|
||||||
@gs_restart.handle()
|
|
||||||
async def send_restart_msg(
|
|
||||||
bot: Bot,
|
|
||||||
event: MessageEvent,
|
|
||||||
matcher: Matcher,
|
|
||||||
):
|
|
||||||
if not await SUPERUSER(bot, event):
|
|
||||||
return
|
|
||||||
logger.warning('开始执行[重启]')
|
|
||||||
send_id = cast_to_int(event.author)
|
|
||||||
send_type = 'group'
|
|
||||||
await matcher.send('正在执行[gs重启]...')
|
|
||||||
await restart_genshinuid(send_type, str(send_id))
|
|
||||||
|
|
||||||
|
|
||||||
@get_update_log.handle()
|
@get_update_log.handle()
|
||||||
|
@register_menu(
|
||||||
|
'更新记录',
|
||||||
|
'更新记录',
|
||||||
|
'查看插件最近的更新记录',
|
||||||
|
detail_des=(
|
||||||
|
'介绍:\n'
|
||||||
|
'查看插件最近的有效Git更新记录\n'
|
||||||
|
' \n'
|
||||||
|
'指令:\n'
|
||||||
|
'- <ft color=(238,120,0)>更新记录</ft>'
|
||||||
|
),
|
||||||
|
)
|
||||||
async def send_updatelog_msg(
|
async def send_updatelog_msg(
|
||||||
matcher: Matcher,
|
matcher: Matcher,
|
||||||
):
|
):
|
||||||
@ -65,12 +66,57 @@ async def send_updatelog_msg(
|
|||||||
if isinstance(im, str):
|
if isinstance(im, str):
|
||||||
await matcher.finish(im)
|
await matcher.finish(im)
|
||||||
elif isinstance(im, bytes):
|
elif isinstance(im, bytes):
|
||||||
await matcher.finish(MessageSegment.file_image(im))
|
await matcher.finish(MessageSegment.image(im))
|
||||||
else:
|
else:
|
||||||
await matcher.finish('发生了未知错误,请联系管理员检查后台输出!')
|
await matcher.finish('发生了未知错误,请联系管理员检查后台输出!')
|
||||||
|
|
||||||
|
|
||||||
|
@gs_restart.handle()
|
||||||
|
@register_menu(
|
||||||
|
'重启Bot',
|
||||||
|
'gs重启',
|
||||||
|
'重启Bot框架',
|
||||||
|
trigger_method='超级用户指令',
|
||||||
|
detail_des=(
|
||||||
|
'介绍:\n' '重启Bot框架\n' ' \n' '指令:\n' '- <ft color=(238,120,0)>gs重启</ft>'
|
||||||
|
),
|
||||||
|
)
|
||||||
|
async def send_restart_msg(
|
||||||
|
bot: Bot,
|
||||||
|
event: MessageEvent,
|
||||||
|
matcher: Matcher,
|
||||||
|
):
|
||||||
|
if not await SUPERUSER(bot, event):
|
||||||
|
return
|
||||||
|
logger.warning('开始执行[重启]')
|
||||||
|
qid = event.user_id
|
||||||
|
if len(event.get_session_id().split('_')) == 3:
|
||||||
|
send_id = event.get_session_id().split('_')[1]
|
||||||
|
send_type = 'group'
|
||||||
|
else:
|
||||||
|
send_id = qid
|
||||||
|
send_type = 'private'
|
||||||
|
await matcher.send('正在执行[gs重启]...')
|
||||||
|
await restart_genshinuid(send_type, str(send_id))
|
||||||
|
|
||||||
|
|
||||||
@gs_update.handle()
|
@gs_update.handle()
|
||||||
|
@register_menu(
|
||||||
|
'更新插件',
|
||||||
|
'gs更新',
|
||||||
|
'手动更新插件',
|
||||||
|
detail_des=(
|
||||||
|
'介绍:\n'
|
||||||
|
'手动更新插件(执行 git pull)\n'
|
||||||
|
'每加上一个可选参数,执行等级加1\n'
|
||||||
|
'当执行等级≥1时会还原上次更改,等级≥2时会清空暂存\n'
|
||||||
|
' \n'
|
||||||
|
'指令:\n'
|
||||||
|
'- <ft color=(238,120,0)>gs</ft>'
|
||||||
|
'<ft color=(125,125,125)>(强行)(强制)</ft>'
|
||||||
|
'<ft color=(238,120,0)>更新</ft>'
|
||||||
|
),
|
||||||
|
)
|
||||||
async def send_update_msg(
|
async def send_update_msg(
|
||||||
bot: Bot,
|
bot: Bot,
|
||||||
event: MessageEvent,
|
event: MessageEvent,
|
||||||
@ -92,6 +138,6 @@ async def send_update_msg(
|
|||||||
if isinstance(im, str):
|
if isinstance(im, str):
|
||||||
await matcher.finish(im)
|
await matcher.finish(im)
|
||||||
elif isinstance(im, bytes):
|
elif isinstance(im, bytes):
|
||||||
await matcher.finish(MessageSegment.file_image(im))
|
await matcher.finish(MessageSegment.image(im))
|
||||||
else:
|
else:
|
||||||
await matcher.finish('发生了未知错误,请联系管理员检查后台输出!')
|
await matcher.finish('发生了未知错误,请联系管理员检查后台输出!')
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import asyncio
|
|
||||||
from typing import Any, Tuple
|
from typing import Any, Tuple
|
||||||
|
|
||||||
from nonebot.log import logger
|
from nonebot.log import logger
|
||||||
@ -6,20 +5,27 @@ from nonebot.matcher import Matcher
|
|||||||
from nonebot import on_regex, on_command
|
from nonebot import on_regex, on_command
|
||||||
from nonebot.permission import SUPERUSER
|
from nonebot.permission import SUPERUSER
|
||||||
from nonebot.params import CommandArg, RegexGroup
|
from nonebot.params import CommandArg, RegexGroup
|
||||||
from nonebot.adapters.qqguild import Message, MessageEvent, MessageSegment
|
from nonebot.adapters.onebot.v11 import (
|
||||||
|
PRIVATE_FRIEND,
|
||||||
|
Bot,
|
||||||
|
Message,
|
||||||
|
MessageEvent,
|
||||||
|
MessageSegment,
|
||||||
|
GroupMessageEvent,
|
||||||
|
)
|
||||||
|
|
||||||
|
from .topup import topup_
|
||||||
from ..config import priority
|
from ..config import priority
|
||||||
from .qrlogin import qrcode_login
|
from .qrlogin import qrcode_login
|
||||||
from ..utils.nonebot2.perm import DIRECT
|
|
||||||
from .get_ck_help_msg import get_ck_help
|
from .get_ck_help_msg import get_ck_help
|
||||||
from .draw_user_card import get_user_card
|
from .draw_user_card import get_user_card
|
||||||
|
from ..genshinuid_meta import register_menu
|
||||||
from ..utils.nonebot2.rule import FullCommand
|
from ..utils.nonebot2.rule import FullCommand
|
||||||
from ..utils.message.cast_type import cast_to_int
|
|
||||||
from ..utils.exception.handle_exception import handle_exception
|
from ..utils.exception.handle_exception import handle_exception
|
||||||
from .add_ck import deal_ck, get_ck_by_stoken, get_ck_by_all_stoken
|
from .add_ck import deal_ck, get_ck_by_stoken, get_ck_by_all_stoken
|
||||||
from ..utils.db_operation.db_operation import bind_db, delete_db, switch_db
|
from ..utils.db_operation.db_operation import bind_db, delete_db, switch_db
|
||||||
|
|
||||||
add_cookie = on_command('添加', permission=DIRECT)
|
add_cookie = on_command('添加', permission=PRIVATE_FRIEND)
|
||||||
get_ck_msg = on_command(
|
get_ck_msg = on_command(
|
||||||
'绑定ck说明',
|
'绑定ck说明',
|
||||||
aliases={'ck帮助', '绑定ck'},
|
aliases={'ck帮助', '绑定ck'},
|
||||||
@ -50,9 +56,21 @@ bind = on_regex(
|
|||||||
get_qrcode_login = on_command(
|
get_qrcode_login = on_command(
|
||||||
'扫码登录',
|
'扫码登录',
|
||||||
aliases={'扫码登陆', '扫码登入'},
|
aliases={'扫码登陆', '扫码登入'},
|
||||||
permission=DIRECT,
|
|
||||||
rule=FullCommand(),
|
rule=FullCommand(),
|
||||||
)
|
)
|
||||||
|
get_topup = on_command('gsrc', priority=priority, block=True, aliases={'原神充值'})
|
||||||
|
|
||||||
|
|
||||||
|
@get_topup.handle()
|
||||||
|
async def send_topup(bot: Bot, event: GroupMessageEvent):
|
||||||
|
qid = event.user_id
|
||||||
|
goods_id = event.raw_message.replace('原神充值', '').replace('gsrc', '')
|
||||||
|
if goods_id == "":
|
||||||
|
goods_id = 0
|
||||||
|
else:
|
||||||
|
goods_id = int(goods_id)
|
||||||
|
group_id = event.group_id
|
||||||
|
await topup_(bot, qid, group_id, goods_id)
|
||||||
|
|
||||||
|
|
||||||
@refresh_all_ck.handle()
|
@refresh_all_ck.handle()
|
||||||
@ -72,70 +90,135 @@ async def send_refresh_ck_msg(
|
|||||||
matcher: Matcher,
|
matcher: Matcher,
|
||||||
):
|
):
|
||||||
logger.info('开始执行[刷新CK]')
|
logger.info('开始执行[刷新CK]')
|
||||||
qid = cast_to_int(event.author)
|
qid = event.user_id
|
||||||
im = await get_ck_by_stoken(qid)
|
im = await get_ck_by_stoken(qid)
|
||||||
if isinstance(im, str):
|
if isinstance(im, str):
|
||||||
await matcher.finish(im)
|
await matcher.finish(im)
|
||||||
await matcher.finish(MessageSegment.file_image(im))
|
await matcher.finish(MessageSegment.image(im))
|
||||||
|
|
||||||
|
|
||||||
@get_qrcode_login.handle()
|
@get_qrcode_login.handle()
|
||||||
async def send_qrcode_login(
|
async def send_qrcode_login(
|
||||||
event: MessageEvent,
|
bot: Bot,
|
||||||
|
event: GroupMessageEvent,
|
||||||
matcher: Matcher,
|
matcher: Matcher,
|
||||||
):
|
):
|
||||||
logger.info('开始执行[扫码登陆]')
|
logger.info('开始执行[扫码登陆]')
|
||||||
qid = cast_to_int(event.author)
|
qid = event.user_id
|
||||||
im = await qrcode_login(matcher, qid)
|
groupid = event.group_id
|
||||||
|
im = await qrcode_login(bot, groupid, qid)
|
||||||
if not im:
|
if not im:
|
||||||
return
|
return
|
||||||
im = await deal_ck(im, qid)
|
im = await deal_ck(im, qid)
|
||||||
if isinstance(im, str):
|
await matcher.finish(MessageSegment.image(im))
|
||||||
await matcher.finish(im)
|
|
||||||
await matcher.finish(MessageSegment.file_image(im))
|
|
||||||
|
|
||||||
|
|
||||||
@bind_info.handle()
|
@bind_info.handle()
|
||||||
|
@register_menu(
|
||||||
|
'绑定状态',
|
||||||
|
'绑定信息',
|
||||||
|
'查询你绑定UID的绑定和推送状态',
|
||||||
|
detail_des=(
|
||||||
|
'介绍:\n'
|
||||||
|
'查询你绑定的UID列表以及它们的CK、SK绑定状态和推送设置\n'
|
||||||
|
' \n'
|
||||||
|
'指令:\n'
|
||||||
|
'- <ft color=(238,120,0)>绑定信息</ft>'
|
||||||
|
),
|
||||||
|
)
|
||||||
async def send_bind_card(
|
async def send_bind_card(
|
||||||
event: MessageEvent,
|
event: MessageEvent,
|
||||||
matcher: Matcher,
|
matcher: Matcher,
|
||||||
):
|
):
|
||||||
logger.info('开始执行[查询用户绑定状态]')
|
logger.info('开始执行[查询用户绑定状态]')
|
||||||
qid = cast_to_int(event.author)
|
qid = event.user_id
|
||||||
if qid is None:
|
im = await get_user_card(qid)
|
||||||
await matcher.finish('QID为空,请重试!')
|
|
||||||
im = await get_user_card(str(qid))
|
|
||||||
logger.info('[查询用户绑定状态]完成!等待图片发送中...')
|
logger.info('[查询用户绑定状态]完成!等待图片发送中...')
|
||||||
await matcher.finish(MessageSegment.file_image(im))
|
await matcher.finish(MessageSegment.image(im))
|
||||||
|
|
||||||
|
|
||||||
@add_cookie.handle()
|
@add_cookie.handle()
|
||||||
@handle_exception('Cookie', '校验失败!请输入正确的Cookies!')
|
@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(
|
async def send_add_ck_msg(
|
||||||
event: MessageEvent, matcher: Matcher, args: Message = CommandArg()
|
event: MessageEvent, matcher: Matcher, args: Message = CommandArg()
|
||||||
):
|
):
|
||||||
mes = args.extract_plain_text().strip().replace(' ', '')
|
mes = args.extract_plain_text().strip().replace(' ', '')
|
||||||
qid = cast_to_int(event.author)
|
qid = event.user_id
|
||||||
if qid is None:
|
|
||||||
await matcher.finish('QID为空,请重试!')
|
|
||||||
qid = str(qid)
|
|
||||||
im = await deal_ck(mes, qid)
|
im = await deal_ck(mes, qid)
|
||||||
if isinstance(im, str):
|
if isinstance(im, str):
|
||||||
await matcher.finish(im)
|
await matcher.finish(im)
|
||||||
await matcher.finish(MessageSegment.file_image(im))
|
await matcher.finish(MessageSegment.image(im))
|
||||||
|
|
||||||
|
|
||||||
# 群聊内 绑定uid或者mysid 的命令,会绑定至当前qq号上
|
# 群聊内 绑定uid或者mysid 的命令,会绑定至当前qq号上
|
||||||
@bind.handle()
|
@bind.handle()
|
||||||
@handle_exception('绑定ID', '绑定ID异常')
|
@handle_exception('绑定ID', '绑定ID异常')
|
||||||
|
@register_menu(
|
||||||
|
'绑定UID',
|
||||||
|
'绑定xx',
|
||||||
|
'绑定原神UID或米游社UID',
|
||||||
|
detail_des=(
|
||||||
|
'介绍:\n'
|
||||||
|
'绑定原神UID或米游社UID\n'
|
||||||
|
' \n'
|
||||||
|
'指令:\n'
|
||||||
|
'- <ft color=(238,120,0)>绑定'
|
||||||
|
'{uid</ft><ft color=(0,148,200)>[原神UID]</ft>'
|
||||||
|
'<ft color=(238,120,0)>|mys</ft><ft color=(0,148,200)>[米游社UID]</ft>'
|
||||||
|
'<ft color=(238,120,0)>}</ft>'
|
||||||
|
),
|
||||||
|
)
|
||||||
|
@register_menu(
|
||||||
|
'解绑UID',
|
||||||
|
'解绑xx',
|
||||||
|
'解绑原神UID或米游社UID',
|
||||||
|
detail_des=(
|
||||||
|
'介绍:\n'
|
||||||
|
'解绑原神UID或米游社UID\n'
|
||||||
|
' \n'
|
||||||
|
'指令:\n'
|
||||||
|
'- <ft color=(238,120,0)>{解绑|删除}'
|
||||||
|
'{uid</ft><ft color=(0,148,200)>[原神UID]</ft>'
|
||||||
|
'<ft color=(238,120,0)>|mys</ft><ft color=(0,148,200)>[米游社UID]</ft>'
|
||||||
|
'<ft color=(238,120,0)>}</ft>'
|
||||||
|
),
|
||||||
|
)
|
||||||
|
@register_menu(
|
||||||
|
'切换UID',
|
||||||
|
'切换xx',
|
||||||
|
'切换当前原神UID或米游社UID',
|
||||||
|
detail_des=(
|
||||||
|
'介绍:\n'
|
||||||
|
'切换当前原神UID或米游社UID\n'
|
||||||
|
'绑定一个UID的情况下无法切换\n'
|
||||||
|
' \n'
|
||||||
|
'指令:\n'
|
||||||
|
'- <ft color=(238,120,0)>切换'
|
||||||
|
'{uid</ft><ft color=(0,148,200)>[原神UID]</ft>'
|
||||||
|
'<ft color=(238,120,0)>|mys</ft><ft color=(0,148,200)>[米游社UID]</ft>'
|
||||||
|
'<ft color=(238,120,0)>}</ft>'
|
||||||
|
),
|
||||||
|
)
|
||||||
async def send_link_uid_msg(
|
async def send_link_uid_msg(
|
||||||
event: MessageEvent, matcher: Matcher, args: Tuple[Any, ...] = RegexGroup()
|
event: MessageEvent, matcher: Matcher, args: Tuple[Any, ...] = RegexGroup()
|
||||||
):
|
):
|
||||||
logger.info('开始执行[绑定/解绑用户信息]')
|
logger.info('开始执行[绑定/解绑用户信息]')
|
||||||
logger.info('[绑定/解绑]参数: {}'.format(args))
|
logger.info('[绑定/解绑]参数: {}'.format(args))
|
||||||
qid = cast_to_int(event.author)
|
qid = event.user_id
|
||||||
if qid is None:
|
|
||||||
await matcher.finish('QID为空,请重试!')
|
|
||||||
logger.info('[绑定/解绑]UserID: {}'.format(qid))
|
logger.info('[绑定/解绑]UserID: {}'.format(qid))
|
||||||
|
|
||||||
if args[0] in ('绑定'):
|
if args[0] in ('绑定'):
|
||||||
@ -143,22 +226,30 @@ async def send_link_uid_msg(
|
|||||||
await matcher.finish('请输入正确的uid或者mysid!')
|
await matcher.finish('请输入正确的uid或者mysid!')
|
||||||
|
|
||||||
if args[1] in ('uid', 'UID'):
|
if args[1] in ('uid', 'UID'):
|
||||||
im = await bind_db(str(qid), args[2])
|
im = await bind_db(qid, args[2])
|
||||||
else:
|
else:
|
||||||
im = await bind_db(str(qid), None, args[2])
|
im = await bind_db(qid, None, args[2])
|
||||||
elif args[0] in ('切换'):
|
elif args[0] in ('切换'):
|
||||||
im = await switch_db(str(qid), args[2])
|
im = await switch_db(qid, args[2])
|
||||||
else:
|
else:
|
||||||
if args[1] in ('uid', 'UID'):
|
if args[1] in ('uid', 'UID'):
|
||||||
im = await delete_db(str(qid), {'UID': args[2]})
|
im = await delete_db(qid, {'UID': args[2]})
|
||||||
else:
|
else:
|
||||||
im = await delete_db(str(qid), {'MYSID': args[2]})
|
im = await delete_db(qid, {'MYSID': args[2]})
|
||||||
await matcher.finish(im, at_sender=True)
|
await matcher.finish(im, at_sender=True)
|
||||||
|
|
||||||
|
|
||||||
@get_ck_msg.handle()
|
@get_ck_msg.handle()
|
||||||
async def send_ck_help(matcher: Matcher):
|
async def send_ck_help(bot: Bot, event: GroupMessageEvent):
|
||||||
msg_list = await get_ck_help()
|
msg_list = await get_ck_help()
|
||||||
|
forward_msg = []
|
||||||
for msg in msg_list:
|
for msg in msg_list:
|
||||||
await matcher.send(msg)
|
forward_msg.append(
|
||||||
await asyncio.sleep(0.5)
|
{
|
||||||
|
"type": "node",
|
||||||
|
"data": {"name": "小冰", "uin": "2854196306", "content": msg},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
await bot.call_api(
|
||||||
|
'send_group_forward_msg', group_id=event.group_id, messages=forward_msg
|
||||||
|
)
|
||||||
|
@ -29,7 +29,7 @@ gs_font_15 = genshin_font_origin(15)
|
|||||||
gs_font_26 = genshin_font_origin(26)
|
gs_font_26 = genshin_font_origin(26)
|
||||||
|
|
||||||
|
|
||||||
async def get_user_card(qid: str) -> bytes:
|
async def get_user_card(qid: int) -> bytes:
|
||||||
uid_list: List = await select_db(qid, 'list') # type: ignore
|
uid_list: List = await select_db(qid, 'list') # type: ignore
|
||||||
w, h = 500, len(uid_list) * 210 + 330
|
w, h = 500, len(uid_list) * 210 + 330
|
||||||
img = await get_simple_bg(w, h)
|
img = await get_simple_bg(w, h)
|
||||||
@ -38,7 +38,7 @@ async def get_user_card(qid: str) -> bytes:
|
|||||||
uid_title = Image.open(TEXT_PATH / 'uid_title.png')
|
uid_title = Image.open(TEXT_PATH / 'uid_title.png')
|
||||||
uid_title_draw = ImageDraw.Draw(uid_title)
|
uid_title_draw = ImageDraw.Draw(uid_title)
|
||||||
uid_title_draw.text(
|
uid_title_draw.text(
|
||||||
(47, 70), f'频道ID {str(qid)}', (106, 100, 89), font=gs_font_26
|
(47, 70), f'QQ号{str(qid)}', (106, 100, 89), font=gs_font_26
|
||||||
)
|
)
|
||||||
img.paste(uid_title, (0, 50), uid_title)
|
img.paste(uid_title, (0, 50), uid_title)
|
||||||
img.paste(uid_hint, (0, 145 + len(uid_list) * 210), uid_hint)
|
img.paste(uid_hint, (0, 145 + len(uid_list) * 210), uid_hint)
|
||||||
|
@ -7,15 +7,17 @@ from typing import Any, Tuple, Union, Literal
|
|||||||
|
|
||||||
import qrcode
|
import qrcode
|
||||||
from nonebot.log import logger
|
from nonebot.log import logger
|
||||||
from nonebot.matcher import Matcher
|
|
||||||
from qrcode.constants import ERROR_CORRECT_L
|
from qrcode.constants import ERROR_CORRECT_L
|
||||||
from nonebot.adapters.qqguild import MessageSegment
|
|
||||||
|
|
||||||
|
from ..utils.message.send_msg import send_forward_msg
|
||||||
|
from ..utils.db_operation.db_operation import select_db
|
||||||
from ..utils.mhy_api.get_mhy_data import (
|
from ..utils.mhy_api.get_mhy_data import (
|
||||||
check_qrcode,
|
check_qrcode,
|
||||||
get_cookie_token,
|
get_cookie_token,
|
||||||
create_qrcode_url,
|
create_qrcode_url,
|
||||||
|
get_mihoyo_bbs_info,
|
||||||
get_stoken_by_game_token,
|
get_stoken_by_game_token,
|
||||||
|
get_cookie_token_by_stoken,
|
||||||
)
|
)
|
||||||
|
|
||||||
disnote = '''免责声明:您将通过扫码完成获取米游社sk以及ck。
|
disnote = '''免责声明:您将通过扫码完成获取米游社sk以及ck。
|
||||||
@ -66,17 +68,32 @@ async def refresh(
|
|||||||
return True, json.loads(status_data['data']['payload']['raw'])
|
return True, json.loads(status_data['data']['payload']['raw'])
|
||||||
|
|
||||||
|
|
||||||
async def qrcode_login(matcher: Matcher, user_id) -> str:
|
async def qrcode_login(bot, group_id, user_id) -> str:
|
||||||
|
async def send_group_msg(msg: str):
|
||||||
|
await bot.call_api(
|
||||||
|
api='send_group_msg',
|
||||||
|
group_id=group_id,
|
||||||
|
message=msg,
|
||||||
|
)
|
||||||
|
return ''
|
||||||
|
|
||||||
code_data = await create_qrcode_url()
|
code_data = await create_qrcode_url()
|
||||||
try:
|
try:
|
||||||
await matcher.send(
|
im = []
|
||||||
MessageSegment.file_image(get_qrcode_base64(code_data["url"])) # type: ignore
|
im.append('请使用米游社扫描下方二维码登录:')
|
||||||
|
im.append(
|
||||||
|
f'[CQ:image,file=base64://{get_qrcode_base64(code_data["url"])}]'
|
||||||
)
|
)
|
||||||
await matcher.send('请绑定UID之后使用米游社扫描上方二维码登录')
|
im.append(
|
||||||
await matcher.send(disnote)
|
'免责声明:您将通过扫码完成获取米游社sk以及ck。\n'
|
||||||
except Exception as e:
|
'本Bot将不会保存您的登录状态。\n'
|
||||||
logger.debug(e)
|
'我方仅提供米游社查询及相关游戏内容服务,\n'
|
||||||
logger.warning('[扫码登录] {user_id} 图片发送失败')
|
'若您的账号封禁、被盗等处罚与我方无关。\n'
|
||||||
|
'害怕风险请勿扫码~'
|
||||||
|
)
|
||||||
|
await send_forward_msg(bot, group_id, "扫码小助手", str(user_id), im)
|
||||||
|
except Exception:
|
||||||
|
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
|
||||||
@ -86,6 +103,36 @@ async def qrcode_login(matcher: Matcher, user_id) -> str:
|
|||||||
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']
|
||||||
|
stoken = stoken_data['data']['token']['token']
|
||||||
|
mid = stoken_data['data']['user_info']['mid']
|
||||||
|
app_cookie = f'stuid={account_id};stoken={stoken};mid={mid}'
|
||||||
|
ck = await get_cookie_token_by_stoken(stoken, account_id, app_cookie)
|
||||||
|
ck = ck['data']['cookie_token']
|
||||||
|
cookie_check = f'account_id={account_id};cookie_token={ck}'
|
||||||
|
get_uid = await get_mihoyo_bbs_info(account_id, cookie_check)
|
||||||
|
# 剔除除了原神之外的其他游戏
|
||||||
|
im = None
|
||||||
|
if get_uid:
|
||||||
|
for i in get_uid['data']['list']:
|
||||||
|
if i['game_id'] == 2:
|
||||||
|
uid_check = i['game_role_id']
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
im = f'你的米游社账号{account_id}尚未绑定原神账号,请前往米游社操作!'
|
||||||
|
return await send_group_msg(im)
|
||||||
|
else:
|
||||||
|
im = '请求失败, 请稍后再试...'
|
||||||
|
return await send_group_msg(im)
|
||||||
|
|
||||||
|
uid_bind = await select_db(user_id, mode='uid')
|
||||||
|
# 没有在gsuid绑定uid的情况
|
||||||
|
if uid_bind == "未找到绑定的UID~":
|
||||||
|
logger.warning('game_token获取失败')
|
||||||
|
im = '你还没有绑定uid,请输入[绑定uid123456]绑定你的uid,再发送[扫码登录]进行绑定'
|
||||||
|
return await send_group_msg(im)
|
||||||
|
# 比对gsuid数据库和扫码登陆获取到的uid
|
||||||
|
if str(uid_bind) == uid_check or str(uid_bind) == account_id:
|
||||||
return SimpleCookie(
|
return SimpleCookie(
|
||||||
{
|
{
|
||||||
'stoken_v2': stoken_data['data']['token']['token'],
|
'stoken_v2': stoken_data['data']['token']['token'],
|
||||||
@ -96,5 +143,8 @@ async def qrcode_login(matcher: Matcher, user_id) -> str:
|
|||||||
).output(header='', sep=';')
|
).output(header='', sep=';')
|
||||||
else:
|
else:
|
||||||
logger.warning('game_token获取失败')
|
logger.warning('game_token获取失败')
|
||||||
await matcher.send('game_token获取失败:二维码已过期')
|
im = 'game_token获取失败:被非绑定指定uid用户扫取,取消绑定,请重新发送[扫码登录]登录账号'
|
||||||
return ''
|
else:
|
||||||
|
logger.warning('game_token获取失败')
|
||||||
|
im = 'game_token获取失败:二维码已过期'
|
||||||
|
return await send_group_msg(im)
|
||||||
|
93
GenshinUID/genshinuid_user/topup.py
Normal file
93
GenshinUID/genshinuid_user/topup.py
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
import io
|
||||||
|
import base64
|
||||||
|
import asyncio
|
||||||
|
import traceback
|
||||||
|
|
||||||
|
import qrcode
|
||||||
|
from nonebot.log import logger
|
||||||
|
from qrcode.constants import ERROR_CORRECT_L
|
||||||
|
|
||||||
|
from ..utils.message.send_msg import send_forward_msg
|
||||||
|
from ..utils.db_operation.db_operation import select_db
|
||||||
|
from ..utils.mhy_api.get_mhy_data import topup, checkorder, fetchgoods
|
||||||
|
|
||||||
|
disnote = '''免责声明:
|
||||||
|
该充值接口由米游社提供,不对充值结果负责。
|
||||||
|
请在充值前仔细阅读米哈游的充值条款。
|
||||||
|
'''
|
||||||
|
|
||||||
|
|
||||||
|
def get_qrcode_base64(url):
|
||||||
|
qr = qrcode.QRCode(
|
||||||
|
version=1,
|
||||||
|
error_correction=ERROR_CORRECT_L,
|
||||||
|
box_size=10,
|
||||||
|
border=4,
|
||||||
|
)
|
||||||
|
qr.add_data(url)
|
||||||
|
qr.make(fit=True)
|
||||||
|
img = qr.make_image(fill_color="black", back_color="white")
|
||||||
|
img_byte = io.BytesIO()
|
||||||
|
img.save(img_byte, format="PNG") # type: ignore
|
||||||
|
img_byte = img_byte.getvalue()
|
||||||
|
return base64.b64encode(img_byte).decode()
|
||||||
|
|
||||||
|
|
||||||
|
async def refresh(order, uid):
|
||||||
|
times = 0
|
||||||
|
while True:
|
||||||
|
await asyncio.sleep(5)
|
||||||
|
order_status = await checkorder(order, uid)
|
||||||
|
if order_status != 900:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
return "支付成功"
|
||||||
|
times += 1
|
||||||
|
if times > 60:
|
||||||
|
return "支付超时"
|
||||||
|
|
||||||
|
|
||||||
|
async def topup_(bot, qid, group_id, goods_id):
|
||||||
|
async def send_group_msg(msg: str):
|
||||||
|
await bot.call_api(
|
||||||
|
api='send_group_msg',
|
||||||
|
group_id=group_id,
|
||||||
|
message=msg,
|
||||||
|
)
|
||||||
|
return ''
|
||||||
|
|
||||||
|
uid = await select_db(qid, mode="uid")
|
||||||
|
if uid is None:
|
||||||
|
await send_group_msg("未绑定米游社账号")
|
||||||
|
return
|
||||||
|
fetchgoods_data = await fetchgoods()
|
||||||
|
try:
|
||||||
|
goods_data = fetchgoods_data[goods_id]
|
||||||
|
except Exception:
|
||||||
|
await send_group_msg("商品不存在,最大为" + str(len(fetchgoods_data) - 1))
|
||||||
|
return
|
||||||
|
try:
|
||||||
|
order = await topup(uid, goods_data)
|
||||||
|
except Exception:
|
||||||
|
await send_group_msg("出错了,可能是cookie过期或接口出错")
|
||||||
|
logger.warning(f"[充值] {group_id} {qid}")
|
||||||
|
return
|
||||||
|
try:
|
||||||
|
im = []
|
||||||
|
b64_data = get_qrcode_base64(order["encode_order"])
|
||||||
|
qrc = f'[CQ:image,file=base64://{b64_data}]'
|
||||||
|
im.append(f"充值uid:{uid}")
|
||||||
|
im.append(
|
||||||
|
f"商品名称:{goods_data['goods_name']}×{str(goods_data['goods_unit'])}"
|
||||||
|
if int(goods_data['goods_unit']) > 0
|
||||||
|
else goods_data["goods_name"],
|
||||||
|
)
|
||||||
|
im.append(f'商品价格:{int(order["amount"])/100}')
|
||||||
|
im.append(f"订单号:{order['order_no']}")
|
||||||
|
im.append(disnote)
|
||||||
|
im.append(qrc)
|
||||||
|
await send_forward_msg(bot, group_id, "小助手", str(qid), im)
|
||||||
|
except Exception:
|
||||||
|
traceback.print_exc()
|
||||||
|
logger.warning(f"[充值] {group_id} 图片发送失败")
|
||||||
|
await send_group_msg(await refresh(order, uid))
|
@ -64,6 +64,7 @@ footer_html = f'''
|
|||||||
</p>
|
</p>
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
|
||||||
# 还原高版本的注册按钮丢失
|
# 还原高版本的注册按钮丢失
|
||||||
@overrides(user_auth_admin.UserLoginFormAdmin)
|
@overrides(user_auth_admin.UserLoginFormAdmin)
|
||||||
async def get_form(self, request: Request) -> Form:
|
async def get_form(self, request: Request) -> Form:
|
||||||
|
@ -3,9 +3,15 @@ import re
|
|||||||
from nonebot import on_command
|
from nonebot import on_command
|
||||||
from nonebot.matcher import Matcher
|
from nonebot.matcher import Matcher
|
||||||
from nonebot.params import CommandArg
|
from nonebot.params import CommandArg
|
||||||
from nonebot.adapters.qqguild import Bot, Message, MessageEvent
|
from nonebot.adapters.onebot.v11 import (
|
||||||
|
Bot,
|
||||||
|
Message,
|
||||||
|
MessageSegment,
|
||||||
|
GroupMessageEvent,
|
||||||
|
)
|
||||||
|
|
||||||
from ..config import priority
|
from ..config import priority
|
||||||
|
from ..genshinuid_meta import register_menu
|
||||||
from ..utils.exception.handle_exception import handle_exception
|
from ..utils.exception.handle_exception import handle_exception
|
||||||
from .get_wiki_text import (
|
from .get_wiki_text import (
|
||||||
char_wiki,
|
char_wiki,
|
||||||
@ -22,14 +28,28 @@ get_cost = on_command('材料', priority=priority)
|
|||||||
get_polar = on_command('命座', priority=priority)
|
get_polar = on_command('命座', priority=priority)
|
||||||
get_talents = on_command('天赋', priority=priority)
|
get_talents = on_command('天赋', priority=priority)
|
||||||
get_enemies = on_command('原魔', priority=priority)
|
get_enemies = on_command('原魔', priority=priority)
|
||||||
# get_audio = on_command('语音', priority=priority)
|
get_audio = on_command('语音', priority=priority)
|
||||||
get_artifacts = on_command('圣遗物', priority=priority)
|
get_artifacts = on_command('圣遗物', priority=priority)
|
||||||
get_food = on_command('食物', priority=priority)
|
get_food = on_command('食物', priority=priority)
|
||||||
|
|
||||||
|
|
||||||
'''频道无法使用语音相关
|
|
||||||
@get_audio.handle()
|
@get_audio.handle()
|
||||||
@handle_exception('语音', '语音发送失败,可能是FFmpeg环境未配置。')
|
@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()):
|
async def send_audio(matcher: Matcher, args: Message = CommandArg()):
|
||||||
message = args.extract_plain_text().strip().replace(' ', '')
|
message = args.extract_plain_text().strip().replace(' ', '')
|
||||||
name = ''.join(re.findall('[\u4e00-\u9fa5]', message))
|
name = ''.join(re.findall('[\u4e00-\u9fa5]', message))
|
||||||
@ -41,11 +61,22 @@ async def send_audio(matcher: Matcher, args: Message = CommandArg()):
|
|||||||
await matcher.finish(im)
|
await matcher.finish(im)
|
||||||
else:
|
else:
|
||||||
await matcher.finish(MessageSegment.record(im))
|
await matcher.finish(MessageSegment.record(im))
|
||||||
'''
|
|
||||||
|
|
||||||
|
|
||||||
@get_enemies.handle()
|
@get_enemies.handle()
|
||||||
@handle_exception('怪物')
|
@handle_exception('怪物')
|
||||||
|
@register_menu(
|
||||||
|
'怪物图鉴',
|
||||||
|
'怪物xx',
|
||||||
|
'获取怪物Wiki',
|
||||||
|
detail_des=(
|
||||||
|
'介绍:\n'
|
||||||
|
'获取怪物Wiki\n'
|
||||||
|
' \n'
|
||||||
|
'指令:\n'
|
||||||
|
'- <ft color=(238,120,0)>怪物</ft><ft color=(0,148,200)>[怪物名称]</ft>'
|
||||||
|
),
|
||||||
|
)
|
||||||
async def send_enemies(matcher: Matcher, args: Message = CommandArg()):
|
async def send_enemies(matcher: Matcher, args: Message = CommandArg()):
|
||||||
message = args.extract_plain_text().strip().replace(' ', '')
|
message = args.extract_plain_text().strip().replace(' ', '')
|
||||||
im = await enemies_wiki(message)
|
im = await enemies_wiki(message)
|
||||||
@ -54,6 +85,18 @@ async def send_enemies(matcher: Matcher, args: Message = CommandArg()):
|
|||||||
|
|
||||||
@get_food.handle()
|
@get_food.handle()
|
||||||
@handle_exception('食物')
|
@handle_exception('食物')
|
||||||
|
@register_menu(
|
||||||
|
'食物图鉴',
|
||||||
|
'食物xx',
|
||||||
|
'获取食物Wiki',
|
||||||
|
detail_des=(
|
||||||
|
'介绍:\n'
|
||||||
|
'获取食物Wiki\n'
|
||||||
|
' \n'
|
||||||
|
'指令:\n'
|
||||||
|
'- <ft color=(238,120,0)>食物</ft><ft color=(0,148,200)>[食物名称]</ft>'
|
||||||
|
),
|
||||||
|
)
|
||||||
async def send_food(matcher: Matcher, args: Message = CommandArg()):
|
async def send_food(matcher: Matcher, args: Message = CommandArg()):
|
||||||
message = args.extract_plain_text().strip().replace(' ', '')
|
message = args.extract_plain_text().strip().replace(' ', '')
|
||||||
im = await foods_wiki(message)
|
im = await foods_wiki(message)
|
||||||
@ -62,6 +105,18 @@ async def send_food(matcher: Matcher, args: Message = CommandArg()):
|
|||||||
|
|
||||||
@get_artifacts.handle()
|
@get_artifacts.handle()
|
||||||
@handle_exception('圣遗物')
|
@handle_exception('圣遗物')
|
||||||
|
@register_menu(
|
||||||
|
'圣遗物图鉴',
|
||||||
|
'圣遗物xx',
|
||||||
|
'获取怪物Wiki',
|
||||||
|
detail_des=(
|
||||||
|
'介绍:\n'
|
||||||
|
'获取圣遗物Wiki\n'
|
||||||
|
' \n'
|
||||||
|
'指令:\n'
|
||||||
|
'- <ft color=(238,120,0)>圣遗物</ft><ft color=(0,148,200)>[圣遗物名称]</ft>'
|
||||||
|
),
|
||||||
|
)
|
||||||
async def send_artifacts(matcher: Matcher, args: Message = CommandArg()):
|
async def send_artifacts(matcher: Matcher, args: Message = CommandArg()):
|
||||||
message = args.extract_plain_text().strip().replace(' ', '')
|
message = args.extract_plain_text().strip().replace(' ', '')
|
||||||
im = await artifacts_wiki(message)
|
im = await artifacts_wiki(message)
|
||||||
@ -70,6 +125,23 @@ async def send_artifacts(matcher: Matcher, args: Message = CommandArg()):
|
|||||||
|
|
||||||
@get_weapon.handle()
|
@get_weapon.handle()
|
||||||
@handle_exception('武器')
|
@handle_exception('武器')
|
||||||
|
@register_menu(
|
||||||
|
'武器图鉴',
|
||||||
|
'武器xx',
|
||||||
|
'获取武器Wiki',
|
||||||
|
detail_des=(
|
||||||
|
'介绍:\n'
|
||||||
|
'获取武器Wiki\n'
|
||||||
|
' \n'
|
||||||
|
'指令:\n'
|
||||||
|
'- <ft color=(238,120,0)>武器</ft><ft color=(0,148,200)>[武器名称]</ft>'
|
||||||
|
'<ft color=(125,125,125)>(级数)</ft>\n'
|
||||||
|
' \n'
|
||||||
|
'示例:\n'
|
||||||
|
'- <ft color=(238,120,0)>武器雾切</ft>\n'
|
||||||
|
'- <ft color=(238,120,0)>武器无工之剑90</ft>'
|
||||||
|
),
|
||||||
|
)
|
||||||
async def send_weapon(matcher: Matcher, args: Message = CommandArg()):
|
async def send_weapon(matcher: Matcher, args: Message = CommandArg()):
|
||||||
message = args.extract_plain_text().strip().replace(' ', '')
|
message = args.extract_plain_text().strip().replace(' ', '')
|
||||||
name = ''.join(re.findall('[\u4e00-\u9fa5]', message))
|
name = ''.join(re.findall('[\u4e00-\u9fa5]', message))
|
||||||
@ -81,12 +153,27 @@ async def send_weapon(matcher: Matcher, args: Message = CommandArg()):
|
|||||||
await matcher.finish(im)
|
await matcher.finish(im)
|
||||||
|
|
||||||
|
|
||||||
'''频道无法发送合并转发消息
|
|
||||||
@get_talents.handle()
|
@get_talents.handle()
|
||||||
@handle_exception('天赋')
|
@handle_exception('天赋')
|
||||||
|
@register_menu(
|
||||||
|
'天赋效果',
|
||||||
|
'天赋[角色][天赋序号]',
|
||||||
|
'查询角色天赋技能效果',
|
||||||
|
detail_des=(
|
||||||
|
'介绍:\n'
|
||||||
|
'查询角色天赋技能效果\n'
|
||||||
|
' \n'
|
||||||
|
'指令:\n'
|
||||||
|
'- <ft color=(238,120,0)>天赋</ft>'
|
||||||
|
'<ft color=(0,148,200)>[角色名称][天赋序号]</ft>\n'
|
||||||
|
' \n'
|
||||||
|
'示例:\n'
|
||||||
|
'- <ft color=(238,120,0)>天赋绫华2</ft>'
|
||||||
|
),
|
||||||
|
)
|
||||||
async def send_talents(
|
async def send_talents(
|
||||||
bot: Bot,
|
bot: Bot,
|
||||||
event: MessageEvent,
|
event: GroupMessageEvent,
|
||||||
matcher: Matcher,
|
matcher: Matcher,
|
||||||
args: Message = CommandArg(),
|
args: Message = CommandArg(),
|
||||||
):
|
):
|
||||||
@ -104,11 +191,27 @@ async def send_talents(
|
|||||||
else:
|
else:
|
||||||
im = '参数不正确。'
|
im = '参数不正确。'
|
||||||
await matcher.finish(im)
|
await matcher.finish(im)
|
||||||
'''
|
|
||||||
|
|
||||||
|
|
||||||
@get_char.handle()
|
@get_char.handle()
|
||||||
@handle_exception('角色')
|
@handle_exception('角色')
|
||||||
|
@register_menu(
|
||||||
|
'角色图鉴',
|
||||||
|
'角色xx',
|
||||||
|
'获取角色Wiki',
|
||||||
|
detail_des=(
|
||||||
|
'介绍:\n'
|
||||||
|
'获取角色Wiki\n'
|
||||||
|
' \n'
|
||||||
|
'指令:\n'
|
||||||
|
'- <ft color=(238,120,0)>角色</ft><ft color=(0,148,200)>[角色名称]</ft>'
|
||||||
|
'<ft color=(125,125,125)>(等级)</ft>\n'
|
||||||
|
' \n'
|
||||||
|
'示例:\n'
|
||||||
|
'- <ft color=(238,120,0)>角色可莉</ft>\n'
|
||||||
|
'- <ft color=(238,120,0)>角色可莉90</ft>'
|
||||||
|
),
|
||||||
|
)
|
||||||
async def send_char(matcher: Matcher, args: Message = CommandArg()):
|
async def send_char(matcher: Matcher, args: Message = CommandArg()):
|
||||||
message = args.extract_plain_text().strip().replace(' ', '')
|
message = args.extract_plain_text().strip().replace(' ', '')
|
||||||
name = ''.join(re.findall('[\u4e00-\u9fa5]', message))
|
name = ''.join(re.findall('[\u4e00-\u9fa5]', message))
|
||||||
@ -122,6 +225,18 @@ async def send_char(matcher: Matcher, args: Message = CommandArg()):
|
|||||||
|
|
||||||
@get_cost.handle()
|
@get_cost.handle()
|
||||||
@handle_exception('材料')
|
@handle_exception('材料')
|
||||||
|
@register_menu(
|
||||||
|
'材料图鉴',
|
||||||
|
'材料xx',
|
||||||
|
'获取材料Wiki',
|
||||||
|
detail_des=(
|
||||||
|
'介绍:\n'
|
||||||
|
'获取材料Wiki\n'
|
||||||
|
' \n'
|
||||||
|
'指令:\n'
|
||||||
|
'- <ft color=(238,120,0)>材料</ft><ft color=(0,148,200)>[材料名称]</ft>'
|
||||||
|
),
|
||||||
|
)
|
||||||
async def send_cost(matcher: Matcher, args: Message = CommandArg()):
|
async def send_cost(matcher: Matcher, args: Message = CommandArg()):
|
||||||
message = args.extract_plain_text().strip().replace(' ', '')
|
message = args.extract_plain_text().strip().replace(' ', '')
|
||||||
im = await char_wiki(message, 'costs')
|
im = await char_wiki(message, 'costs')
|
||||||
@ -130,6 +245,22 @@ async def send_cost(matcher: Matcher, args: Message = CommandArg()):
|
|||||||
|
|
||||||
@get_polar.handle()
|
@get_polar.handle()
|
||||||
@handle_exception('命座')
|
@handle_exception('命座')
|
||||||
|
@register_menu(
|
||||||
|
'角色命座图鉴',
|
||||||
|
'命座[角色][等级]',
|
||||||
|
'获取角色命座Wiki',
|
||||||
|
detail_des=(
|
||||||
|
'介绍:\n'
|
||||||
|
'获取角色命座Wiki\n'
|
||||||
|
' \n'
|
||||||
|
'指令:\n'
|
||||||
|
'- <ft color=(238,120,0)>命座</ft>'
|
||||||
|
'<ft color=(0,148,200)>[角色名称][命座等级]</ft>\n'
|
||||||
|
' \n'
|
||||||
|
'示例:\n'
|
||||||
|
'- <ft color=(238,120,0)>命座胡桃1</ft>'
|
||||||
|
),
|
||||||
|
)
|
||||||
async def send_polar(matcher: Matcher, args: Message = CommandArg()):
|
async def send_polar(matcher: Matcher, args: Message = CommandArg()):
|
||||||
message = args.extract_plain_text().strip().replace(' ', '')
|
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
|
||||||
|
@ -6,7 +6,7 @@ from nonebot import on_command
|
|||||||
from nonebot.log import logger
|
from nonebot.log import logger
|
||||||
from nonebot.matcher import Matcher
|
from nonebot.matcher import Matcher
|
||||||
from nonebot_plugin_apscheduler import scheduler
|
from nonebot_plugin_apscheduler import scheduler
|
||||||
from nonebot.adapters.qqguild import MessageSegment
|
from nonebot.adapters.onebot.v11 import MessageSegment
|
||||||
|
|
||||||
from .draw_abyss_total import TOTAL_IMG, draw_xk_abyss_img
|
from .draw_abyss_total import TOTAL_IMG, draw_xk_abyss_img
|
||||||
from ..utils.exception.handle_exception import handle_exception
|
from ..utils.exception.handle_exception import handle_exception
|
||||||
@ -26,7 +26,8 @@ async def scheduled_draw_abyss():
|
|||||||
async def send_guide_pic(matcher: Matcher):
|
async def send_guide_pic(matcher: Matcher):
|
||||||
if TOTAL_IMG.exists():
|
if TOTAL_IMG.exists():
|
||||||
logger.info('获得深渊概览成功!')
|
logger.info('获得深渊概览成功!')
|
||||||
await matcher.finish(MessageSegment.file_image(TOTAL_IMG))
|
with open(TOTAL_IMG, 'rb') as f:
|
||||||
|
await matcher.finish(MessageSegment.image(f.read()))
|
||||||
else:
|
else:
|
||||||
await matcher.finish('深渊概览图不存在!')
|
await matcher.finish('深渊概览图不存在!')
|
||||||
|
|
||||||
|
@ -17,7 +17,10 @@ path = Path(__file__).parents[1] / 'genshinuid_adv'
|
|||||||
wb = load_workbook(str(path / 'Genshin All Char.xlsx'))
|
wb = load_workbook(str(path / 'Genshin All Char.xlsx'))
|
||||||
ws = wb.active
|
ws = wb.active
|
||||||
for char_i in range(2, 336, 5): # 角色行
|
for char_i in range(2, 336, 5): # 角色行
|
||||||
char_name = ws.cell(char_i, 1).value.replace('\n', '') # type: ignore
|
char = ws.cell(char_i, 1).value
|
||||||
|
if not isinstance(char, str):
|
||||||
|
continue
|
||||||
|
char_name = char.replace('\n', '')
|
||||||
char_sample = copy.deepcopy(sample)
|
char_sample = copy.deepcopy(sample)
|
||||||
for i in range(5):
|
for i in range(5):
|
||||||
row = i + char_i
|
row = i + char_i
|
||||||
|
@ -251,7 +251,7 @@ class CookiesDAL:
|
|||||||
await self.db_session.flush()
|
await self.db_session.flush()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
async def add_cookie_db(self, userid: str, uid: str, cookies: str) -> bool:
|
async def add_cookie_db(self, userid: int, uid: str, cookies: str) -> bool:
|
||||||
"""
|
"""
|
||||||
:说明:
|
:说明:
|
||||||
绑定Cookies
|
绑定Cookies
|
||||||
|
@ -11,7 +11,7 @@ class UidDataDAL:
|
|||||||
def __init__(self, db_session: Session):
|
def __init__(self, db_session: Session):
|
||||||
self.db_session = db_session
|
self.db_session = db_session
|
||||||
|
|
||||||
async def get_user_data(self, userid: str) -> Optional[UidData]:
|
async def get_user_data(self, userid: int) -> Optional[UidData]:
|
||||||
"""
|
"""
|
||||||
:说明:
|
:说明:
|
||||||
获取用户的绑定信息
|
获取用户的绑定信息
|
||||||
@ -37,7 +37,7 @@ class UidDataDAL:
|
|||||||
bind_list.append(item.__dict__)
|
bind_list.append(item.__dict__)
|
||||||
return bind_list
|
return bind_list
|
||||||
|
|
||||||
async def user_exists(self, userid: str) -> bool:
|
async def user_exists(self, userid: int) -> bool:
|
||||||
"""
|
"""
|
||||||
:说明:
|
:说明:
|
||||||
是否存在用户的绑定信息
|
是否存在用户的绑定信息
|
||||||
@ -67,7 +67,7 @@ class UidDataDAL:
|
|||||||
uid_list.extend(item.UID.split("_"))
|
uid_list.extend(item.UID.split("_"))
|
||||||
return uid_list
|
return uid_list
|
||||||
|
|
||||||
async def get_uid_list(self, userid: str) -> List[str]:
|
async def get_uid_list(self, userid: int) -> List[str]:
|
||||||
"""
|
"""
|
||||||
:说明:
|
:说明:
|
||||||
获得用户的绑定UID列表
|
获得用户的绑定UID列表
|
||||||
@ -83,7 +83,7 @@ class UidDataDAL:
|
|||||||
return uid_list
|
return uid_list
|
||||||
return []
|
return []
|
||||||
|
|
||||||
async def get_uid(self, userid: str) -> str:
|
async def get_uid(self, userid: int) -> str:
|
||||||
"""
|
"""
|
||||||
:说明:
|
:说明:
|
||||||
获得用户绑定的UID
|
获得用户绑定的UID
|
||||||
@ -98,7 +98,7 @@ class UidDataDAL:
|
|||||||
else:
|
else:
|
||||||
return '未找到绑定的UID~'
|
return '未找到绑定的UID~'
|
||||||
|
|
||||||
async def switch_uid(self, userid: str, uid: Optional[str] = None) -> str:
|
async def switch_uid(self, userid: int, uid: Optional[str] = None) -> str:
|
||||||
"""
|
"""
|
||||||
:说明:
|
:说明:
|
||||||
切换绑定的UID列表,绑定一个UID的情况下返回无法切换
|
切换绑定的UID列表,绑定一个UID的情况下返回无法切换
|
||||||
@ -126,7 +126,7 @@ class UidDataDAL:
|
|||||||
else:
|
else:
|
||||||
return '你还没有绑定过UID噢~'
|
return '你还没有绑定过UID噢~'
|
||||||
|
|
||||||
async def get_mysid_list(self, userid: str) -> List[str]:
|
async def get_mysid_list(self, userid: int) -> List[str]:
|
||||||
"""
|
"""
|
||||||
:说明:
|
:说明:
|
||||||
获得用户的绑定MYSID列表
|
获得用户的绑定MYSID列表
|
||||||
@ -142,7 +142,7 @@ class UidDataDAL:
|
|||||||
return mys_list
|
return mys_list
|
||||||
return []
|
return []
|
||||||
|
|
||||||
async def get_mysid(self, userid: str) -> str:
|
async def get_mysid(self, userid: int) -> str:
|
||||||
"""
|
"""
|
||||||
:说明:
|
:说明:
|
||||||
获得用户绑定的MYSID
|
获得用户绑定的MYSID
|
||||||
@ -157,7 +157,7 @@ class UidDataDAL:
|
|||||||
else:
|
else:
|
||||||
return "未找到绑定的MYSID~"
|
return "未找到绑定的MYSID~"
|
||||||
|
|
||||||
async def get_anyid(self, userid: str) -> str:
|
async def get_anyid(self, userid: int) -> str:
|
||||||
"""
|
"""
|
||||||
:说明:
|
:说明:
|
||||||
获得用户绑定的ID信息
|
获得用户绑定的ID信息
|
||||||
@ -176,12 +176,12 @@ class UidDataDAL:
|
|||||||
else:
|
else:
|
||||||
return '未找到绑定的ID信息~'
|
return '未找到绑定的ID信息~'
|
||||||
|
|
||||||
async def bind_db(self, userid: str, data: dict) -> str:
|
async def bind_db(self, userid: int, data: dict) -> str:
|
||||||
"""
|
"""
|
||||||
:说明:
|
:说明:
|
||||||
绑定UID或者MYSID
|
绑定UID或者MYSID
|
||||||
:参数:
|
:参数:
|
||||||
* userid (str): 频道用户 ID。
|
* userid (int): QQ号。
|
||||||
* data (dict): 绑定的UID或者MYSID, 至少填写一项。
|
* data (dict): 绑定的UID或者MYSID, 至少填写一项。
|
||||||
data = {'UID': UID, 'MYSID': MYSID}
|
data = {'UID': UID, 'MYSID': MYSID}
|
||||||
:返回:
|
:返回:
|
||||||
@ -229,7 +229,7 @@ class UidDataDAL:
|
|||||||
await self.db_session.flush() # type: ignore
|
await self.db_session.flush() # type: ignore
|
||||||
return _bind
|
return _bind
|
||||||
|
|
||||||
async def delete_db(self, userid: str, data: Optional[dict]) -> str:
|
async def delete_db(self, userid: int, data: Optional[dict]) -> str:
|
||||||
"""
|
"""
|
||||||
:说明:
|
:说明:
|
||||||
删除用户的绑定UID或者MYSID
|
删除用户的绑定UID或者MYSID
|
||||||
@ -284,7 +284,7 @@ class UidDataDAL:
|
|||||||
|
|
||||||
async def update_db(
|
async def update_db(
|
||||||
self,
|
self,
|
||||||
userid: str,
|
userid: int,
|
||||||
data: Optional[dict],
|
data: Optional[dict],
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
|
@ -33,10 +33,7 @@ class PushData(SQLModel, table=True):
|
|||||||
|
|
||||||
class UidData(SQLModel, table=True):
|
class UidData(SQLModel, table=True):
|
||||||
__table_args__ = {'keep_existing': True}
|
__table_args__ = {'keep_existing': True}
|
||||||
ID: int = Field(
|
USERID: int = Field(default=100000000, primary_key=True, title='QQ号')
|
||||||
default=1, primary_key=True, sa_column_kwargs={"autoincrement": 1}
|
|
||||||
)
|
|
||||||
USERID: str = Field(default="100000000", primary_key=True, title='QQ号')
|
|
||||||
UID: Optional[str] = Field(title='UID')
|
UID: Optional[str] = Field(title='UID')
|
||||||
MYSID: Optional[str] = Field(title='米游社通行证(废弃)')
|
MYSID: Optional[str] = Field(title='米游社通行证(废弃)')
|
||||||
|
|
||||||
@ -45,7 +42,7 @@ class NewCookiesTable(SQLModel, table=True):
|
|||||||
__table_args__ = {'keep_existing': True}
|
__table_args__ = {'keep_existing': True}
|
||||||
UID: int = Field(default=100000000, primary_key=True, title='UID')
|
UID: int = Field(default=100000000, primary_key=True, title='UID')
|
||||||
Cookies: str = Field(title='CK')
|
Cookies: str = Field(title='CK')
|
||||||
QID: str = Field(title='QQ号')
|
QID: int = Field(title='QQ号')
|
||||||
StatusA: str = Field(title='全局推送开关')
|
StatusA: str = Field(title='全局推送开关')
|
||||||
StatusB: str = Field(title='自动签到')
|
StatusB: str = Field(title='自动签到')
|
||||||
StatusC: str = Field(title='自动米游币')
|
StatusC: str = Field(title='自动米游币')
|
||||||
|
@ -9,7 +9,7 @@ from .database.db_config import async_session
|
|||||||
|
|
||||||
|
|
||||||
async def get_push_status(uid, func) -> List:
|
async def get_push_status(uid, func) -> List:
|
||||||
async with async_session() as session: # type: ignore
|
async with async_session() as session:
|
||||||
async with session.begin():
|
async with session.begin():
|
||||||
PushData = PushDataDAL(session)
|
PushData = PushDataDAL(session)
|
||||||
push_dict = await PushData.get_user_data(uid)
|
push_dict = await PushData.get_user_data(uid)
|
||||||
@ -23,7 +23,7 @@ async def get_push_status(uid, func) -> List:
|
|||||||
|
|
||||||
|
|
||||||
async def update_push_status(uid: int, func: str, status: str) -> bool:
|
async def update_push_status(uid: int, func: str, status: str) -> bool:
|
||||||
async with async_session() as session: # type: ignore
|
async with async_session() as session:
|
||||||
async with session.begin():
|
async with session.begin():
|
||||||
PushData = PushDataDAL(session)
|
PushData = PushDataDAL(session)
|
||||||
return await PushData.update_user_data(
|
return await PushData.update_user_data(
|
||||||
@ -32,7 +32,7 @@ async def update_push_status(uid: int, func: str, status: str) -> bool:
|
|||||||
|
|
||||||
|
|
||||||
async def update_push_value(uid: int, func: str, value: int) -> bool:
|
async def update_push_value(uid: int, func: str, value: int) -> bool:
|
||||||
async with async_session() as session: # type: ignore
|
async with async_session() as session:
|
||||||
async with session.begin():
|
async with session.begin():
|
||||||
PushData = PushDataDAL(session)
|
PushData = PushDataDAL(session)
|
||||||
return await PushData.update_user_data(
|
return await PushData.update_user_data(
|
||||||
@ -43,7 +43,7 @@ async def update_push_value(uid: int, func: str, value: int) -> bool:
|
|||||||
async def update_is_pushed(
|
async def update_is_pushed(
|
||||||
uid: int, func: str, is_pushed: str = 'off'
|
uid: int, func: str, is_pushed: str = 'off'
|
||||||
) -> bool:
|
) -> bool:
|
||||||
async with async_session() as session: # type: ignore
|
async with async_session() as session:
|
||||||
async with session.begin():
|
async with session.begin():
|
||||||
PushData = PushDataDAL(session)
|
PushData = PushDataDAL(session)
|
||||||
return await PushData.update_user_data(
|
return await PushData.update_user_data(
|
||||||
@ -52,7 +52,7 @@ async def update_is_pushed(
|
|||||||
|
|
||||||
|
|
||||||
async def bind_db(userid, uid=None, mys=None):
|
async def bind_db(userid, uid=None, mys=None):
|
||||||
async with async_session() as session: # type: ignore
|
async with async_session() as session:
|
||||||
async with session.begin():
|
async with session.begin():
|
||||||
UidData = UidDataDAL(session)
|
UidData = UidDataDAL(session)
|
||||||
im = await UidData.bind_db(userid, {'UID': uid, 'MYSID': mys})
|
im = await UidData.bind_db(userid, {'UID': uid, 'MYSID': mys})
|
||||||
@ -68,7 +68,7 @@ async def get_all_bind() -> List[Dict]:
|
|||||||
|
|
||||||
|
|
||||||
async def get_all_uid() -> List:
|
async def get_all_uid() -> List:
|
||||||
async with async_session() as session: # type: ignore
|
async with async_session() as session:
|
||||||
async with session.begin():
|
async with session.begin():
|
||||||
UidData = UidDataDAL(session)
|
UidData = UidDataDAL(session)
|
||||||
lst = await UidData.get_all_uid_list()
|
lst = await UidData.get_all_uid_list()
|
||||||
@ -76,7 +76,7 @@ async def get_all_uid() -> List:
|
|||||||
|
|
||||||
|
|
||||||
async def get_all_cookie() -> List:
|
async def get_all_cookie() -> List:
|
||||||
async with async_session() as session: # type: ignore
|
async with async_session() as session:
|
||||||
async with session.begin():
|
async with session.begin():
|
||||||
Cookies = CookiesDAL(session)
|
Cookies = CookiesDAL(session)
|
||||||
lst = await Cookies.get_all_cookie_list()
|
lst = await Cookies.get_all_cookie_list()
|
||||||
@ -84,14 +84,16 @@ async def get_all_cookie() -> List:
|
|||||||
|
|
||||||
|
|
||||||
async def get_all_stoken() -> List:
|
async def get_all_stoken() -> List:
|
||||||
async with async_session() as session: # type: ignore
|
async with async_session() as session:
|
||||||
async with session.begin():
|
async with session.begin():
|
||||||
Cookies = CookiesDAL(session)
|
Cookies = CookiesDAL(session)
|
||||||
lst = await Cookies.get_all_stoken_list()
|
lst = await Cookies.get_all_stoken_list()
|
||||||
return lst
|
return lst
|
||||||
|
|
||||||
|
|
||||||
async def select_db(userid: str, mode='auto') -> Union[List, str, None]:
|
async def select_db(
|
||||||
|
userid: int, mode: str = 'auto'
|
||||||
|
) -> Union[List[str], str, None]:
|
||||||
"""
|
"""
|
||||||
:说明:
|
:说明:
|
||||||
选择绑定uid/mys库
|
选择绑定uid/mys库
|
||||||
@ -108,7 +110,7 @@ async def select_db(userid: str, mode='auto') -> Union[List, str, None]:
|
|||||||
其他情况下data[0]为需要的uid/mysid
|
其他情况下data[0]为需要的uid/mysid
|
||||||
data[1]表示data[0]是`uid` or `mysid`
|
data[1]表示data[0]是`uid` or `mysid`
|
||||||
"""
|
"""
|
||||||
async with async_session() as session: # type: ignore
|
async with async_session() as session:
|
||||||
async with session.begin():
|
async with session.begin():
|
||||||
UidData = UidDataDAL(session)
|
UidData = UidDataDAL(session)
|
||||||
if mode == 'auto':
|
if mode == 'auto':
|
||||||
@ -124,7 +126,7 @@ async def select_db(userid: str, mode='auto') -> Union[List, str, None]:
|
|||||||
return im
|
return im
|
||||||
|
|
||||||
|
|
||||||
async def switch_db(userid: str, uid: Optional[str] = None) -> str:
|
async def switch_db(userid: int, uid: Optional[str] = None) -> str:
|
||||||
"""
|
"""
|
||||||
:说明:
|
:说明:
|
||||||
切换绑定的UID列表,绑定一个UID的情况下返回无法切换
|
切换绑定的UID列表,绑定一个UID的情况下返回无法切换
|
||||||
@ -135,14 +137,14 @@ async def switch_db(userid: str, uid: Optional[str] = None) -> str:
|
|||||||
:返回:
|
:返回:
|
||||||
* im (str): 回调信息。
|
* im (str): 回调信息。
|
||||||
"""
|
"""
|
||||||
async with async_session() as session: # type: ignore
|
async with async_session() as session:
|
||||||
async with session.begin():
|
async with session.begin():
|
||||||
UidData = UidDataDAL(session)
|
UidData = UidDataDAL(session)
|
||||||
im = await UidData.switch_uid(userid, uid)
|
im = await UidData.switch_uid(userid, uid)
|
||||||
return im
|
return im
|
||||||
|
|
||||||
|
|
||||||
async def delete_db(userid: str, data: dict) -> str:
|
async def delete_db(userid: int, data: dict) -> str:
|
||||||
"""
|
"""
|
||||||
:说明:
|
:说明:
|
||||||
删除当前绑定的UID信息
|
删除当前绑定的UID信息
|
||||||
@ -153,15 +155,15 @@ async def delete_db(userid: str, data: dict) -> str:
|
|||||||
:返回:
|
:返回:
|
||||||
* im (str): 回调信息。
|
* im (str): 回调信息。
|
||||||
"""
|
"""
|
||||||
async with async_session() as session: # type: ignore
|
async with async_session() as session:
|
||||||
async with session.begin():
|
async with session.begin():
|
||||||
UidData = UidDataDAL(session)
|
UidData = UidDataDAL(session)
|
||||||
im = await UidData.delete_db(userid, data)
|
im = await UidData.delete_db(userid, data)
|
||||||
return im
|
return im
|
||||||
|
|
||||||
|
|
||||||
async def cookies_db(uid: str, cookies: str, qid: str):
|
async def cookies_db(uid: str, cookies: str, qid: int):
|
||||||
async with async_session() as session: # type: ignore
|
async with async_session() as session:
|
||||||
async with session.begin():
|
async with session.begin():
|
||||||
Cookies = CookiesDAL(session)
|
Cookies = CookiesDAL(session)
|
||||||
im = await Cookies.add_cookie_db(qid, uid, cookies)
|
im = await Cookies.add_cookie_db(qid, uid, cookies)
|
||||||
@ -169,7 +171,7 @@ async def cookies_db(uid: str, cookies: str, qid: str):
|
|||||||
|
|
||||||
|
|
||||||
async def error_db(cookies: str, error: str):
|
async def error_db(cookies: str, error: str):
|
||||||
async with async_session() as session: # type: ignore
|
async with async_session() as session:
|
||||||
async with session.begin():
|
async with session.begin():
|
||||||
Cookies = CookiesDAL(session)
|
Cookies = CookiesDAL(session)
|
||||||
im = await Cookies.add_error_db(cookies, error)
|
im = await Cookies.add_error_db(cookies, error)
|
||||||
@ -177,7 +179,7 @@ async def error_db(cookies: str, error: str):
|
|||||||
|
|
||||||
|
|
||||||
async def owner_cookies(uid: str) -> str:
|
async def owner_cookies(uid: str) -> str:
|
||||||
async with async_session() as session: # type: ignore
|
async with async_session() as session:
|
||||||
async with session.begin():
|
async with session.begin():
|
||||||
Cookies = CookiesDAL(session)
|
Cookies = CookiesDAL(session)
|
||||||
owner_ck = await Cookies.get_user_ck(uid)
|
owner_ck = await Cookies.get_user_ck(uid)
|
||||||
@ -189,7 +191,7 @@ async def owner_cookies(uid: str) -> str:
|
|||||||
|
|
||||||
|
|
||||||
async def delete_cookies(uid: str) -> str:
|
async def delete_cookies(uid: str) -> str:
|
||||||
async with async_session() as session: # type: ignore
|
async with async_session() as session:
|
||||||
async with session.begin():
|
async with session.begin():
|
||||||
Cookies = CookiesDAL(session)
|
Cookies = CookiesDAL(session)
|
||||||
result = await Cookies.delete_user(uid)
|
result = await Cookies.delete_user(uid)
|
||||||
@ -200,7 +202,7 @@ async def delete_cookies(uid: str) -> str:
|
|||||||
|
|
||||||
|
|
||||||
async def get_stoken(uid: str) -> str:
|
async def get_stoken(uid: str) -> str:
|
||||||
async with async_session() as session: # type: ignore
|
async with async_session() as session:
|
||||||
async with session.begin():
|
async with session.begin():
|
||||||
Cookies = CookiesDAL(session)
|
Cookies = CookiesDAL(session)
|
||||||
stoken = await Cookies.get_user_stoken(uid)
|
stoken = await Cookies.get_user_stoken(uid)
|
||||||
@ -208,7 +210,7 @@ async def get_stoken(uid: str) -> str:
|
|||||||
|
|
||||||
|
|
||||||
async def get_user_bind_data(uid: str) -> dict:
|
async def get_user_bind_data(uid: str) -> dict:
|
||||||
async with async_session() as session: # type: ignore
|
async with async_session() as session:
|
||||||
async with session.begin():
|
async with session.begin():
|
||||||
Cookies = CookiesDAL(session)
|
Cookies = CookiesDAL(session)
|
||||||
lst = await Cookies.get_user_data_dict(uid)
|
lst = await Cookies.get_user_data_dict(uid)
|
||||||
@ -216,7 +218,7 @@ async def get_user_bind_data(uid: str) -> dict:
|
|||||||
|
|
||||||
|
|
||||||
async def stoken_db(s_cookies: str, uid: str) -> str:
|
async def stoken_db(s_cookies: str, uid: str) -> str:
|
||||||
async with async_session() as session: # type: ignore
|
async with async_session() as session:
|
||||||
async with session.begin():
|
async with session.begin():
|
||||||
Cookies = CookiesDAL(session)
|
Cookies = CookiesDAL(session)
|
||||||
im = await Cookies.add_stoken_db(uid, s_cookies)
|
im = await Cookies.add_stoken_db(uid, s_cookies)
|
||||||
@ -224,7 +226,7 @@ async def stoken_db(s_cookies: str, uid: str) -> str:
|
|||||||
|
|
||||||
|
|
||||||
async def open_push(uid, qid, status, func):
|
async def open_push(uid, qid, status, func):
|
||||||
async with async_session() as session: # type: ignore
|
async with async_session() as session:
|
||||||
async with session.begin():
|
async with session.begin():
|
||||||
Cookies = CookiesDAL(session)
|
Cookies = CookiesDAL(session)
|
||||||
im = await Cookies.update_user_status(
|
im = await Cookies.update_user_status(
|
||||||
@ -241,7 +243,7 @@ async def empty_cache():
|
|||||||
|
|
||||||
|
|
||||||
async def config_check(func, mode='CHECK') -> bool:
|
async def config_check(func, mode='CHECK') -> bool:
|
||||||
async with async_session() as session: # type: ignore
|
async with async_session() as session:
|
||||||
async with session.begin():
|
async with session.begin():
|
||||||
Config = ConfigDAL(session)
|
Config = ConfigDAL(session)
|
||||||
im = False
|
im = False
|
||||||
@ -255,7 +257,7 @@ async def config_check(func, mode='CHECK') -> bool:
|
|||||||
|
|
||||||
|
|
||||||
async def get_all_signin_list() -> List:
|
async def get_all_signin_list() -> List:
|
||||||
async with async_session() as session: # type: ignore
|
async with async_session() as session:
|
||||||
async with session.begin():
|
async with session.begin():
|
||||||
Cookies = CookiesDAL(session)
|
Cookies = CookiesDAL(session)
|
||||||
im = await Cookies.get_status_list('StatusB')
|
im = await Cookies.get_status_list('StatusB')
|
||||||
@ -263,7 +265,7 @@ async def get_all_signin_list() -> List:
|
|||||||
|
|
||||||
|
|
||||||
async def get_all_push_list() -> List:
|
async def get_all_push_list() -> List:
|
||||||
async with async_session() as session: # type: ignore
|
async with async_session() as session:
|
||||||
async with session.begin():
|
async with session.begin():
|
||||||
Cookies = CookiesDAL(session)
|
Cookies = CookiesDAL(session)
|
||||||
im = await Cookies.get_status_list('StatusA')
|
im = await Cookies.get_status_list('StatusA')
|
||||||
@ -271,7 +273,7 @@ async def get_all_push_list() -> List:
|
|||||||
|
|
||||||
|
|
||||||
async def get_push_data(uid: int) -> dict:
|
async def get_push_data(uid: int) -> dict:
|
||||||
async with async_session() as session: # type: ignore
|
async with async_session() as session:
|
||||||
async with session.begin():
|
async with session.begin():
|
||||||
PushData = PushDataDAL(session)
|
PushData = PushDataDAL(session)
|
||||||
push_data = await PushData.get_user_data(uid)
|
push_data = await PushData.get_user_data(uid)
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
from typing import Optional, cast
|
|
||||||
|
|
||||||
from nonebot.adapters.qqguild.api.model import User
|
|
||||||
|
|
||||||
|
|
||||||
def cast_to_int(user: Optional[User]) -> int:
|
|
||||||
return cast(int, cast(User, user).id)
|
|
21
GenshinUID/utils/message/get_cqhttp_data.py
Normal file
21
GenshinUID/utils/message/get_cqhttp_data.py
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
from typing import List
|
||||||
|
|
||||||
|
from nonebot.adapters.onebot.v11 import Bot
|
||||||
|
|
||||||
|
|
||||||
|
async def get_all_friend_list(bot: Bot) -> List[int]:
|
||||||
|
friend_list = []
|
||||||
|
friend_dict_list = await bot.call_api('get_friend_list')
|
||||||
|
for friend in friend_dict_list:
|
||||||
|
friend_list.append(friend['user_id'])
|
||||||
|
return friend_list
|
||||||
|
|
||||||
|
|
||||||
|
async def get_group_member_list(bot: Bot, group_id: int) -> List[int]:
|
||||||
|
member_list = []
|
||||||
|
group_member_list = await bot.call_api(
|
||||||
|
'get_group_member_list', group_id=group_id
|
||||||
|
)
|
||||||
|
for group_member in group_member_list:
|
||||||
|
member_list.append(group_member['user_id'])
|
||||||
|
return member_list
|
@ -1,6 +1,6 @@
|
|||||||
from typing import Optional
|
from typing import Union
|
||||||
|
|
||||||
from nonebot.adapters.qqguild import MessageEvent
|
from nonebot.adapters.onebot.v11 import MessageEvent
|
||||||
|
|
||||||
|
|
||||||
# https://v2.nonebot.dev/docs/advanced/di/dependency-injection#class-%E4%BD%9C%E4%B8%BA%E4%BE%9D%E8%B5%96
|
# https://v2.nonebot.dev/docs/advanced/di/dependency-injection#class-%E4%BD%9C%E4%B8%BA%E4%BE%9D%E8%B5%96
|
||||||
@ -8,11 +8,15 @@ class ImageAndAt:
|
|||||||
def __init__(self, event: MessageEvent):
|
def __init__(self, event: MessageEvent):
|
||||||
self.images = []
|
self.images = []
|
||||||
self.at = []
|
self.at = []
|
||||||
for i in event.get_message():
|
for i in event.message:
|
||||||
if i.type == "attachment":
|
if i.type == "image":
|
||||||
self.images.append(i.data["url"])
|
data = i.data
|
||||||
elif i.type == "mention_user":
|
if url := data.get("url"):
|
||||||
self.at.append(i.data["user_id"])
|
self.images.append(url)
|
||||||
|
else:
|
||||||
|
continue
|
||||||
|
elif i.type == "at":
|
||||||
|
self.at.append(i.data["qq"])
|
||||||
|
|
||||||
def get_at(self):
|
def get_at(self):
|
||||||
return self.at
|
return self.at
|
||||||
@ -20,8 +24,14 @@ class ImageAndAt:
|
|||||||
def get_image(self):
|
def get_image(self):
|
||||||
return self.images
|
return self.images
|
||||||
|
|
||||||
def get_first_image(self) -> Optional[str]:
|
def get_first_image(self) -> Union[str, None]:
|
||||||
return self.images[0] if len(self.images) else None
|
try:
|
||||||
|
return self.images[0]
|
||||||
|
except IndexError:
|
||||||
|
return None
|
||||||
|
|
||||||
def get_first_at(self) -> Optional[str]:
|
def get_first_at(self) -> Union[int, None]:
|
||||||
return self.at[0] if len(self.at) else None
|
try:
|
||||||
|
return self.at[0]
|
||||||
|
except IndexError:
|
||||||
|
return None
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
from nonebot.adapters.qqguild import Bot
|
from nonebot.adapters.onebot.v11 import Bot
|
||||||
|
|
||||||
|
|
||||||
# 发送聊天记录
|
# 发送聊天记录
|
||||||
async def send_forward_msg(
|
async def send_forward_msg(
|
||||||
bot: Bot,
|
bot: Bot,
|
||||||
userid: int,
|
groupid: int,
|
||||||
name: str,
|
name: str,
|
||||||
uin: str,
|
uin: str,
|
||||||
msgs: List[str],
|
msgs: List[str],
|
||||||
@ -19,5 +19,5 @@ async def send_forward_msg(
|
|||||||
|
|
||||||
messages = [to_json(msg) for msg in msgs]
|
messages = [to_json(msg) for msg in msgs]
|
||||||
await bot.call_api(
|
await bot.call_api(
|
||||||
"send_private_forward_msg", user_id=userid, messages=messages
|
"send_group_forward_msg", group_id=groupid, messages=messages
|
||||||
)
|
)
|
||||||
|
@ -17,6 +17,7 @@ from ..mhy_api.mhy_api_tools import (
|
|||||||
random_hex,
|
random_hex,
|
||||||
random_text,
|
random_text,
|
||||||
get_ds_token,
|
get_ds_token,
|
||||||
|
gen_payment_sign,
|
||||||
generate_passport_ds,
|
generate_passport_ds,
|
||||||
generate_dynamic_secret,
|
generate_dynamic_secret,
|
||||||
old_version_get_ds_token,
|
old_version_get_ds_token,
|
||||||
@ -56,6 +57,9 @@ from ..mhy_api.mhy_api import ( # noqa
|
|||||||
MIHOYO_BBS_PLAYER_INFO_URL,
|
MIHOYO_BBS_PLAYER_INFO_URL,
|
||||||
MIHOYO_BBS_PLAYER_INFO_URL_OS,
|
MIHOYO_BBS_PLAYER_INFO_URL_OS,
|
||||||
GET_COOKIE_TOKEN_BY_GAME_TOKEN,
|
GET_COOKIE_TOKEN_BY_GAME_TOKEN,
|
||||||
|
CheckOrderurl,
|
||||||
|
CreateOrderurl,
|
||||||
|
fetchGoodsurl,
|
||||||
)
|
)
|
||||||
|
|
||||||
PROXY_URL = string_config.get_config('proxy')
|
PROXY_URL = string_config.get_config('proxy')
|
||||||
@ -545,7 +549,7 @@ async def get_gcg_info(uid: str):
|
|||||||
|
|
||||||
async def create_qrcode_url():
|
async def create_qrcode_url():
|
||||||
device_id: str = ''.join(random.choices(ascii_letters + digits, k=64))
|
device_id: str = ''.join(random.choices(ascii_letters + digits, k=64))
|
||||||
app_id: str = '4'
|
app_id: str = '8'
|
||||||
data = await _mhy_request(
|
data = await _mhy_request(
|
||||||
CREATE_QRCODE,
|
CREATE_QRCODE,
|
||||||
'POST',
|
'POST',
|
||||||
@ -854,3 +858,77 @@ async def get_regtime_data(uid: str) -> Any:
|
|||||||
use_proxy=True,
|
use_proxy=True,
|
||||||
)
|
)
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
|
async def fetchgoods():
|
||||||
|
data = {
|
||||||
|
"released_flag": True,
|
||||||
|
"game": "hk4e_cn",
|
||||||
|
"region": "cn_gf01",
|
||||||
|
"uid": "1",
|
||||||
|
"account": "1",
|
||||||
|
}
|
||||||
|
goodslist = await _mhy_request(
|
||||||
|
url=fetchGoodsurl,
|
||||||
|
method='POST',
|
||||||
|
data=data,
|
||||||
|
)
|
||||||
|
# print(json.dumps(goodslist.json(),indent=4,ensure_ascii=False))
|
||||||
|
return goodslist["data"]["goods_list"]
|
||||||
|
|
||||||
|
|
||||||
|
async def topup(uid, goods):
|
||||||
|
device_id = str(uuid.uuid4())
|
||||||
|
HEADER = copy.deepcopy(_HEADER)
|
||||||
|
HEADER["Cookie"] = await owner_cookies(uid)
|
||||||
|
account = HEADER["Cookie"].split("account_id=")[1].split(";")[0]
|
||||||
|
order = {
|
||||||
|
"account": str(account),
|
||||||
|
"region": "cn_gf01",
|
||||||
|
"uid": uid,
|
||||||
|
"delivery_url": "",
|
||||||
|
"device": device_id,
|
||||||
|
"channel_id": 1,
|
||||||
|
"client_ip": "",
|
||||||
|
"client_type": 4,
|
||||||
|
"game": "hk4e_cn",
|
||||||
|
"amount": goods["price"],
|
||||||
|
# "amount": 600,
|
||||||
|
"goods_num": 1,
|
||||||
|
"goods_id": goods["goods_id"],
|
||||||
|
"goods_title": f"{goods['goods_name']}×{str(goods['goods_unit'])}"
|
||||||
|
if int(goods['goods_unit']) > 0
|
||||||
|
else goods["goods_name"],
|
||||||
|
"price_tier": goods["tier_id"],
|
||||||
|
# "price_tier": "Tier_1",
|
||||||
|
"currency": "CNY",
|
||||||
|
"pay_plat": "alipay",
|
||||||
|
}
|
||||||
|
data = {"order": order, "sign": gen_payment_sign(order)}
|
||||||
|
HEADER["x-rpc-device_id"] = device_id
|
||||||
|
HEADER["x-rpc-client_type"] = "4"
|
||||||
|
order = await _mhy_request(
|
||||||
|
url=CreateOrderurl,
|
||||||
|
method='POST',
|
||||||
|
header=HEADER,
|
||||||
|
data=data,
|
||||||
|
)
|
||||||
|
return order["data"]
|
||||||
|
|
||||||
|
|
||||||
|
async def checkorder(order, uid):
|
||||||
|
HEADER = copy.deepcopy(_HEADER)
|
||||||
|
HEADER["Cookie"] = await owner_cookies(uid)
|
||||||
|
data = {
|
||||||
|
"order_no": order["order_no"],
|
||||||
|
"game": "hk4e_cn",
|
||||||
|
"region": "cn_gf01",
|
||||||
|
"uid": uid,
|
||||||
|
}
|
||||||
|
order = await _mhy_request(
|
||||||
|
url=CheckOrderurl,
|
||||||
|
method='GET',
|
||||||
|
header=HEADER,
|
||||||
|
params=data,
|
||||||
|
)
|
||||||
|
return order["data"]["status"]
|
||||||
|
@ -115,3 +115,9 @@ bbs_Listurl = (
|
|||||||
bbs_Detailurl = BBS_URL + '/post/api/getPostFull?post_id={}'
|
bbs_Detailurl = BBS_URL + '/post/api/getPostFull?post_id={}'
|
||||||
bbs_Shareurl = BBS_URL + '/apihub/api/getShareConf?entity_id={}&entity_type=1'
|
bbs_Shareurl = BBS_URL + '/apihub/api/getShareConf?entity_id={}&entity_type=1'
|
||||||
bbs_Likeurl = f'{BBS_URL}/apihub/sapi/upvotePost'
|
bbs_Likeurl = f'{BBS_URL}/apihub/sapi/upvotePost'
|
||||||
|
|
||||||
|
# 原神充值中心
|
||||||
|
fetchGoodsurl = f"{HK4_SDK_URL}/hk4e_cn/mdk/shopwindow/shopwindow/fetchGoods"
|
||||||
|
CreateOrderurl = f"{HK4_SDK_URL}/hk4e_cn/mdk/atropos/api/createOrder"
|
||||||
|
CheckOrderurl = f"{HK4_SDK_URL}/hk4e_cn/mdk/atropos/api/checkOrder"
|
||||||
|
PriceTierurl = f"{HK4_SDK_URL}/hk4e_cn/mdk/shopwindow/shopwindow/listPriceTier"
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import hmac
|
||||||
import json
|
import json
|
||||||
import time
|
import time
|
||||||
import random
|
import random
|
||||||
@ -75,3 +76,17 @@ def generate_passport_ds(q: str = '', b: Optional[Dict[str, Any]] = None):
|
|||||||
return _random_str_ds(
|
return _random_str_ds(
|
||||||
"JwYDpKvLj6MrMqqYU6jTKF17KNO2PXoS", string.ascii_letters, True, q, b
|
"JwYDpKvLj6MrMqqYU6jTKF17KNO2PXoS", string.ascii_letters, True, q, b
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def HMCASHA256(data, key):
|
||||||
|
key = key.encode('utf-8')
|
||||||
|
message = data.encode('utf-8')
|
||||||
|
sign = hmac.new(key, message, digestmod=hashlib.sha256).digest()
|
||||||
|
return sign.hex()
|
||||||
|
|
||||||
|
|
||||||
|
def gen_payment_sign(data):
|
||||||
|
data = dict(sorted(data.items(), key=lambda x: x[0]))
|
||||||
|
value = "".join([str(i) for i in data.values()])
|
||||||
|
sign = HMCASHA256(value, "6bdc3982c25f3f3c38668a32d287d16b")
|
||||||
|
return sign
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
from nonebot.permission import Permission
|
|
||||||
from nonebot.adapters.qqguild.event import DirectMessageCreateEvent
|
|
||||||
|
|
||||||
|
|
||||||
async def is_direct(_: DirectMessageCreateEvent) -> bool:
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
DIRECT = Permission(is_direct)
|
|
@ -1,6 +1,6 @@
|
|||||||
from nonebot.rule import Rule
|
from nonebot.rule import Rule
|
||||||
from nonebot.adapters.qqguild import Message
|
|
||||||
from nonebot.params import Depends, CommandArg
|
from nonebot.params import Depends, CommandArg
|
||||||
|
from nonebot.adapters.onebot.v11 import Message
|
||||||
|
|
||||||
|
|
||||||
async def full_command(arg: Message = CommandArg()) -> bool:
|
async def full_command(arg: Message = CommandArg()) -> bool:
|
||||||
|
@ -1,154 +0,0 @@
|
|||||||
import json
|
|
||||||
from io import BytesIO
|
|
||||||
from pathlib import Path
|
|
||||||
from typing import Any, Dict, List, Union, Optional
|
|
||||||
|
|
||||||
from nonebot.log import logger
|
|
||||||
from aiohttp import ClientSession
|
|
||||||
from nonebot.drivers import Request
|
|
||||||
from nonebot.typing import overrides
|
|
||||||
from nonebot.adapters.qqguild.bot import Bot
|
|
||||||
from pydantic import BaseModel, parse_obj_as
|
|
||||||
from nonebot.adapters.qqguild.adapter import Adapter
|
|
||||||
from nonebot.adapters.qqguild.api.request import _request
|
|
||||||
from nonebot.adapters.qqguild.api.handle import API_HANDLERS
|
|
||||||
from nonebot.adapters.qqguild.api.model import Message as APIMessage
|
|
||||||
from nonebot.adapters.qqguild.message import Message, MessageSegment
|
|
||||||
from nonebot.adapters.qqguild.event import (
|
|
||||||
Event,
|
|
||||||
MessageEvent,
|
|
||||||
DirectMessageCreateEvent,
|
|
||||||
)
|
|
||||||
from nonebot.adapters.qqguild.api.model import (
|
|
||||||
MessageArk,
|
|
||||||
MessageEmbed,
|
|
||||||
MessageMarkdown,
|
|
||||||
MessageReference,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class LocalImage(MessageSegment):
|
|
||||||
@overrides(MessageSegment)
|
|
||||||
def __str__(self) -> str:
|
|
||||||
return "<local_image>"
|
|
||||||
|
|
||||||
|
|
||||||
def local_image(data: Union[str, Path, bytes, BytesIO]) -> LocalImage:
|
|
||||||
if isinstance(data, (str, Path)):
|
|
||||||
with open(data, "rb") as f:
|
|
||||||
b = f.read()
|
|
||||||
elif isinstance(data, BytesIO):
|
|
||||||
b = data.getvalue()
|
|
||||||
else:
|
|
||||||
b = data
|
|
||||||
return LocalImage("local_image", data={"content": b})
|
|
||||||
|
|
||||||
|
|
||||||
class MessageSend(BaseModel):
|
|
||||||
content: Optional[str] = None
|
|
||||||
embed: Optional[MessageEmbed] = None
|
|
||||||
ark: Optional[MessageArk] = None
|
|
||||||
markdown: Optional[MessageMarkdown] = None
|
|
||||||
message_reference: Optional[MessageReference] = None
|
|
||||||
image: Optional[str] = None
|
|
||||||
msg_id: Optional[str] = None
|
|
||||||
|
|
||||||
|
|
||||||
def patch_send():
|
|
||||||
logger.info("注入本地图片发送猴子补丁")
|
|
||||||
|
|
||||||
@overrides(Bot)
|
|
||||||
async def send(
|
|
||||||
self,
|
|
||||||
event: Event,
|
|
||||||
message: Union[str, Message, MessageSegment],
|
|
||||||
**kwargs,
|
|
||||||
) -> Any:
|
|
||||||
if (
|
|
||||||
not isinstance(event, MessageEvent)
|
|
||||||
or not event.channel_id
|
|
||||||
or not event.id
|
|
||||||
):
|
|
||||||
raise RuntimeError("Event cannot be replied to!")
|
|
||||||
message = (
|
|
||||||
MessageSegment.text(message)
|
|
||||||
if isinstance(message, str)
|
|
||||||
else message
|
|
||||||
)
|
|
||||||
|
|
||||||
message = message if isinstance(message, Message) else Message(message)
|
|
||||||
content = message.extract_content() or None
|
|
||||||
guild_id = None
|
|
||||||
if isinstance(event, DirectMessageCreateEvent):
|
|
||||||
event_dict = event.__dict__
|
|
||||||
guild_id = event_dict['guild_id']
|
|
||||||
if embed := (message["embed"] or None):
|
|
||||||
embed = embed[-1].data["embed"]
|
|
||||||
if ark := (message["ark"] or None):
|
|
||||||
ark = ark[-1].data["ark"]
|
|
||||||
if image := (message["attachment"] or None):
|
|
||||||
image = image[-1].data["url"]
|
|
||||||
if local_image := (message["local_image"] or None):
|
|
||||||
local_image = local_image[-1].data["content"]
|
|
||||||
if markdown := (message["markdown"] or None):
|
|
||||||
markdown = markdown[-1].data["markdown"]
|
|
||||||
return await self.post_messages(
|
|
||||||
channel_id=event.channel_id,
|
|
||||||
guild_id=guild_id,
|
|
||||||
msg_id=event.id,
|
|
||||||
content=content,
|
|
||||||
embed=embed,
|
|
||||||
ark=ark,
|
|
||||||
markdown=markdown,
|
|
||||||
image=image,
|
|
||||||
file_image=local_image,
|
|
||||||
**kwargs,
|
|
||||||
)
|
|
||||||
|
|
||||||
Bot.send = send
|
|
||||||
|
|
||||||
async def post_messages(
|
|
||||||
adapter: Adapter, bot: Bot, channel_id: int, guild_id: int, **data
|
|
||||||
) -> Union[APIMessage, List[APIMessage]]:
|
|
||||||
headers = {"Authorization": adapter.get_authorization(bot.bot_info)}
|
|
||||||
model_data = MessageSend(**data).dict(exclude_none=True)
|
|
||||||
d_api = adapter.get_api_base() / f"channels/{channel_id}/messages"
|
|
||||||
if guild_id:
|
|
||||||
d_api = adapter.get_api_base() / f"dms/{guild_id}/messages"
|
|
||||||
if "file_image" in model_data.keys() and (
|
|
||||||
file_image := model_data.pop("file_image")
|
|
||||||
):
|
|
||||||
new_data: Dict[str, Union[BytesIO, str]] = {
|
|
||||||
"file_image": BytesIO(file_image)
|
|
||||||
}
|
|
||||||
for k, v in model_data.items():
|
|
||||||
# 当字段类型为对象或数组时需要将字段序列化为 JSON 字符串后进行调用
|
|
||||||
# https://bot.q.qq.com/wiki/develop/api/openapi/message/post_messages.html#form-data-%E6%A0%BC%E5%BC%8F%E7%A4%BA%E4%BE%8B
|
|
||||||
if isinstance(v, BaseModel):
|
|
||||||
new_data[k] = v.json()
|
|
||||||
elif isinstance(v, (list, dict)):
|
|
||||||
new_data[k] = json.dumps(v)
|
|
||||||
|
|
||||||
else:
|
|
||||||
new_data[k] = v
|
|
||||||
async with ClientSession(headers=headers) as session:
|
|
||||||
req = await session.post(
|
|
||||||
d_api,
|
|
||||||
data=new_data,
|
|
||||||
)
|
|
||||||
data = await req.json()
|
|
||||||
else:
|
|
||||||
request = Request(
|
|
||||||
"POST",
|
|
||||||
d_api,
|
|
||||||
json=model_data,
|
|
||||||
headers=headers,
|
|
||||||
)
|
|
||||||
data = await _request(adapter, bot, request)
|
|
||||||
if guild_id:
|
|
||||||
return parse_obj_as(List[APIMessage], data)
|
|
||||||
else:
|
|
||||||
return parse_obj_as(APIMessage, data)
|
|
||||||
|
|
||||||
API_HANDLERS["post_messages"] = post_messages
|
|
||||||
logger.success("本地图片发送猴子补丁已注入")
|
|
97
poetry.lock
generated
97
poetry.lock
generated
@ -1174,6 +1174,79 @@ files = [
|
|||||||
{file = "mccabe-0.7.0.tar.gz", hash = "sha256:348e0240c33b60bbdf4e523192ef919f28cb2c3d7d5c7794f74009290f236325"},
|
{file = "mccabe-0.7.0.tar.gz", hash = "sha256:348e0240c33b60bbdf4e523192ef919f28cb2c3d7d5c7794f74009290f236325"},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "msgpack"
|
||||||
|
version = "1.0.5"
|
||||||
|
description = "MessagePack serializer"
|
||||||
|
category = "main"
|
||||||
|
optional = false
|
||||||
|
python-versions = "*"
|
||||||
|
files = [
|
||||||
|
{file = "msgpack-1.0.5-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:525228efd79bb831cf6830a732e2e80bc1b05436b086d4264814b4b2955b2fa9"},
|
||||||
|
{file = "msgpack-1.0.5-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:4f8d8b3bf1ff2672567d6b5c725a1b347fe838b912772aa8ae2bf70338d5a198"},
|
||||||
|
{file = "msgpack-1.0.5-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:cdc793c50be3f01106245a61b739328f7dccc2c648b501e237f0699fe1395b81"},
|
||||||
|
{file = "msgpack-1.0.5-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5cb47c21a8a65b165ce29f2bec852790cbc04936f502966768e4aae9fa763cb7"},
|
||||||
|
{file = "msgpack-1.0.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e42b9594cc3bf4d838d67d6ed62b9e59e201862a25e9a157019e171fbe672dd3"},
|
||||||
|
{file = "msgpack-1.0.5-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:55b56a24893105dc52c1253649b60f475f36b3aa0fc66115bffafb624d7cb30b"},
|
||||||
|
{file = "msgpack-1.0.5-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:1967f6129fc50a43bfe0951c35acbb729be89a55d849fab7686004da85103f1c"},
|
||||||
|
{file = "msgpack-1.0.5-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:20a97bf595a232c3ee6d57ddaadd5453d174a52594bf9c21d10407e2a2d9b3bd"},
|
||||||
|
{file = "msgpack-1.0.5-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:d25dd59bbbbb996eacf7be6b4ad082ed7eacc4e8f3d2df1ba43822da9bfa122a"},
|
||||||
|
{file = "msgpack-1.0.5-cp310-cp310-win32.whl", hash = "sha256:382b2c77589331f2cb80b67cc058c00f225e19827dbc818d700f61513ab47bea"},
|
||||||
|
{file = "msgpack-1.0.5-cp310-cp310-win_amd64.whl", hash = "sha256:4867aa2df9e2a5fa5f76d7d5565d25ec76e84c106b55509e78c1ede0f152659a"},
|
||||||
|
{file = "msgpack-1.0.5-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:9f5ae84c5c8a857ec44dc180a8b0cc08238e021f57abdf51a8182e915e6299f0"},
|
||||||
|
{file = "msgpack-1.0.5-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:9e6ca5d5699bcd89ae605c150aee83b5321f2115695e741b99618f4856c50898"},
|
||||||
|
{file = "msgpack-1.0.5-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:5494ea30d517a3576749cad32fa27f7585c65f5f38309c88c6d137877fa28a5a"},
|
||||||
|
{file = "msgpack-1.0.5-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1ab2f3331cb1b54165976a9d976cb251a83183631c88076613c6c780f0d6e45a"},
|
||||||
|
{file = "msgpack-1.0.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:28592e20bbb1620848256ebc105fc420436af59515793ed27d5c77a217477705"},
|
||||||
|
{file = "msgpack-1.0.5-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:fe5c63197c55bce6385d9aee16c4d0641684628f63ace85f73571e65ad1c1e8d"},
|
||||||
|
{file = "msgpack-1.0.5-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:ed40e926fa2f297e8a653c954b732f125ef97bdd4c889f243182299de27e2aa9"},
|
||||||
|
{file = "msgpack-1.0.5-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:b2de4c1c0538dcb7010902a2b97f4e00fc4ddf2c8cda9749af0e594d3b7fa3d7"},
|
||||||
|
{file = "msgpack-1.0.5-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:bf22a83f973b50f9d38e55c6aade04c41ddda19b00c4ebc558930d78eecc64ed"},
|
||||||
|
{file = "msgpack-1.0.5-cp311-cp311-win32.whl", hash = "sha256:c396e2cc213d12ce017b686e0f53497f94f8ba2b24799c25d913d46c08ec422c"},
|
||||||
|
{file = "msgpack-1.0.5-cp311-cp311-win_amd64.whl", hash = "sha256:6c4c68d87497f66f96d50142a2b73b97972130d93677ce930718f68828b382e2"},
|
||||||
|
{file = "msgpack-1.0.5-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:a2b031c2e9b9af485d5e3c4520f4220d74f4d222a5b8dc8c1a3ab9448ca79c57"},
|
||||||
|
{file = "msgpack-1.0.5-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4f837b93669ce4336e24d08286c38761132bc7ab29782727f8557e1eb21b2080"},
|
||||||
|
{file = "msgpack-1.0.5-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b1d46dfe3832660f53b13b925d4e0fa1432b00f5f7210eb3ad3bb9a13c6204a6"},
|
||||||
|
{file = "msgpack-1.0.5-cp36-cp36m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:366c9a7b9057e1547f4ad51d8facad8b406bab69c7d72c0eb6f529cf76d4b85f"},
|
||||||
|
{file = "msgpack-1.0.5-cp36-cp36m-musllinux_1_1_aarch64.whl", hash = "sha256:4c075728a1095efd0634a7dccb06204919a2f67d1893b6aa8e00497258bf926c"},
|
||||||
|
{file = "msgpack-1.0.5-cp36-cp36m-musllinux_1_1_i686.whl", hash = "sha256:f933bbda5a3ee63b8834179096923b094b76f0c7a73c1cfe8f07ad608c58844b"},
|
||||||
|
{file = "msgpack-1.0.5-cp36-cp36m-musllinux_1_1_x86_64.whl", hash = "sha256:36961b0568c36027c76e2ae3ca1132e35123dcec0706c4b7992683cc26c1320c"},
|
||||||
|
{file = "msgpack-1.0.5-cp36-cp36m-win32.whl", hash = "sha256:b5ef2f015b95f912c2fcab19c36814963b5463f1fb9049846994b007962743e9"},
|
||||||
|
{file = "msgpack-1.0.5-cp36-cp36m-win_amd64.whl", hash = "sha256:288e32b47e67f7b171f86b030e527e302c91bd3f40fd9033483f2cacc37f327a"},
|
||||||
|
{file = "msgpack-1.0.5-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:137850656634abddfb88236008339fdaba3178f4751b28f270d2ebe77a563b6c"},
|
||||||
|
{file = "msgpack-1.0.5-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0c05a4a96585525916b109bb85f8cb6511db1c6f5b9d9cbcbc940dc6b4be944b"},
|
||||||
|
{file = "msgpack-1.0.5-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:56a62ec00b636583e5cb6ad313bbed36bb7ead5fa3a3e38938503142c72cba4f"},
|
||||||
|
{file = "msgpack-1.0.5-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:ef8108f8dedf204bb7b42994abf93882da1159728a2d4c5e82012edd92c9da9f"},
|
||||||
|
{file = "msgpack-1.0.5-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:1835c84d65f46900920b3708f5ba829fb19b1096c1800ad60bae8418652a951d"},
|
||||||
|
{file = "msgpack-1.0.5-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:e57916ef1bd0fee4f21c4600e9d1da352d8816b52a599c46460e93a6e9f17086"},
|
||||||
|
{file = "msgpack-1.0.5-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:17358523b85973e5f242ad74aa4712b7ee560715562554aa2134d96e7aa4cbbf"},
|
||||||
|
{file = "msgpack-1.0.5-cp37-cp37m-win32.whl", hash = "sha256:cb5aaa8c17760909ec6cb15e744c3ebc2ca8918e727216e79607b7bbce9c8f77"},
|
||||||
|
{file = "msgpack-1.0.5-cp37-cp37m-win_amd64.whl", hash = "sha256:ab31e908d8424d55601ad7075e471b7d0140d4d3dd3272daf39c5c19d936bd82"},
|
||||||
|
{file = "msgpack-1.0.5-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:b72d0698f86e8d9ddf9442bdedec15b71df3598199ba33322d9711a19f08145c"},
|
||||||
|
{file = "msgpack-1.0.5-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:379026812e49258016dd84ad79ac8446922234d498058ae1d415f04b522d5b2d"},
|
||||||
|
{file = "msgpack-1.0.5-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:332360ff25469c346a1c5e47cbe2a725517919892eda5cfaffe6046656f0b7bb"},
|
||||||
|
{file = "msgpack-1.0.5-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:476a8fe8fae289fdf273d6d2a6cb6e35b5a58541693e8f9f019bfe990a51e4ba"},
|
||||||
|
{file = "msgpack-1.0.5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a9985b214f33311df47e274eb788a5893a761d025e2b92c723ba4c63936b69b1"},
|
||||||
|
{file = "msgpack-1.0.5-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:48296af57cdb1d885843afd73c4656be5c76c0c6328db3440c9601a98f303d87"},
|
||||||
|
{file = "msgpack-1.0.5-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:addab7e2e1fcc04bd08e4eb631c2a90960c340e40dfc4a5e24d2ff0d5a3b3edb"},
|
||||||
|
{file = "msgpack-1.0.5-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:916723458c25dfb77ff07f4c66aed34e47503b2eb3188b3adbec8d8aa6e00f48"},
|
||||||
|
{file = "msgpack-1.0.5-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:821c7e677cc6acf0fd3f7ac664c98803827ae6de594a9f99563e48c5a2f27eb0"},
|
||||||
|
{file = "msgpack-1.0.5-cp38-cp38-win32.whl", hash = "sha256:1c0f7c47f0087ffda62961d425e4407961a7ffd2aa004c81b9c07d9269512f6e"},
|
||||||
|
{file = "msgpack-1.0.5-cp38-cp38-win_amd64.whl", hash = "sha256:bae7de2026cbfe3782c8b78b0db9cbfc5455e079f1937cb0ab8d133496ac55e1"},
|
||||||
|
{file = "msgpack-1.0.5-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:20c784e66b613c7f16f632e7b5e8a1651aa5702463d61394671ba07b2fc9e025"},
|
||||||
|
{file = "msgpack-1.0.5-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:266fa4202c0eb94d26822d9bfd7af25d1e2c088927fe8de9033d929dd5ba24c5"},
|
||||||
|
{file = "msgpack-1.0.5-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:18334484eafc2b1aa47a6d42427da7fa8f2ab3d60b674120bce7a895a0a85bdd"},
|
||||||
|
{file = "msgpack-1.0.5-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:57e1f3528bd95cc44684beda696f74d3aaa8a5e58c816214b9046512240ef437"},
|
||||||
|
{file = "msgpack-1.0.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:586d0d636f9a628ddc6a17bfd45aa5b5efaf1606d2b60fa5d87b8986326e933f"},
|
||||||
|
{file = "msgpack-1.0.5-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:a740fa0e4087a734455f0fc3abf5e746004c9da72fbd541e9b113013c8dc3282"},
|
||||||
|
{file = "msgpack-1.0.5-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:3055b0455e45810820db1f29d900bf39466df96ddca11dfa6d074fa47054376d"},
|
||||||
|
{file = "msgpack-1.0.5-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:a61215eac016f391129a013c9e46f3ab308db5f5ec9f25811e811f96962599a8"},
|
||||||
|
{file = "msgpack-1.0.5-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:362d9655cd369b08fda06b6657a303eb7172d5279997abe094512e919cf74b11"},
|
||||||
|
{file = "msgpack-1.0.5-cp39-cp39-win32.whl", hash = "sha256:ac9dd47af78cae935901a9a500104e2dea2e253207c924cc95de149606dc43cc"},
|
||||||
|
{file = "msgpack-1.0.5-cp39-cp39-win_amd64.whl", hash = "sha256:06f5174b5f8ed0ed919da0e62cbd4ffde676a374aba4020034da05fab67b9164"},
|
||||||
|
{file = "msgpack-1.0.5.tar.gz", hash = "sha256:c075544284eadc5cddc70f4757331d99dcbc16b2bbd4849d15f8aae4cf36d31c"},
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "multidict"
|
name = "multidict"
|
||||||
version = "6.0.4"
|
version = "6.0.4"
|
||||||
@ -1286,20 +1359,20 @@ files = [
|
|||||||
setuptools = "*"
|
setuptools = "*"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nonebot-adapter-qqguild"
|
name = "nonebot-adapter-onebot"
|
||||||
version = "0.2.1"
|
version = "2.2.1"
|
||||||
description = "QQ Guild adapter for nonebot2"
|
description = "OneBot(CQHTTP) adapter for nonebot2"
|
||||||
category = "main"
|
category = "main"
|
||||||
optional = false
|
optional = false
|
||||||
python-versions = ">=3.8,<4.0"
|
python-versions = ">=3.8,<4.0"
|
||||||
files = [
|
files = [
|
||||||
{file = "nonebot_adapter_qqguild-0.2.1-py3-none-any.whl", hash = "sha256:0f0d195ef6f27b99727a0d5cedb007833ac31d483f200bb0defc704bbb54616b"},
|
{file = "nonebot_adapter_onebot-2.2.1-py3-none-any.whl", hash = "sha256:db22c92a541f243ef427a7080096fb28751fec213bc75b111e2c9ed89e121d94"},
|
||||||
{file = "nonebot_adapter_qqguild-0.2.1.tar.gz", hash = "sha256:bbde4260206663a67bfdccf76c7e062432af1d344ee80652c1d439eecca93bba"},
|
{file = "nonebot_adapter_onebot-2.2.1.tar.gz", hash = "sha256:2f77ff2345cc98e493c3bf00a5fd7112cf20e66ebeac062bbb8de56b4d07040e"},
|
||||||
]
|
]
|
||||||
|
|
||||||
[package.dependencies]
|
[package.dependencies]
|
||||||
nonebot2 = ">=2.0.0-beta.1,<3.0.0"
|
msgpack = ">=1.0.3,<2.0.0"
|
||||||
pydantic = ">=1.9.0,<2.0.0"
|
nonebot2 = ">=2.0.0-beta.3,<3.0.0"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nonebot-plugin-apscheduler"
|
name = "nonebot-plugin-apscheduler"
|
||||||
@ -1347,20 +1420,20 @@ websockets = ["websockets (>=10.0,<11.0)"]
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nonebug"
|
name = "nonebug"
|
||||||
version = "0.2.3"
|
version = "0.3.1"
|
||||||
description = "nonebot2 test framework"
|
description = "nonebot2 test framework"
|
||||||
category = "dev"
|
category = "dev"
|
||||||
optional = false
|
optional = false
|
||||||
python-versions = ">=3.8,<4.0"
|
python-versions = ">=3.8,<4.0"
|
||||||
files = [
|
files = [
|
||||||
{file = "nonebug-0.2.3-py3-none-any.whl", hash = "sha256:5c83bd885899b2857323fa19eff6bbc3f160729453b2f289d8305a99b7b95fc9"},
|
{file = "nonebug-0.3.1-py3-none-any.whl", hash = "sha256:b33e93d486e3f187e890a516ad8d9432ea736e50b0270341ddc78fecfe080d5f"},
|
||||||
{file = "nonebug-0.2.3.tar.gz", hash = "sha256:3e59757b32b6b96cd8c36c4c9fd6050e611b1ffad058ec5fa82cba3f86495c61"},
|
{file = "nonebug-0.3.1.tar.gz", hash = "sha256:96637bbdc406e7673e625492fbe928a9db467cd630d6fd04cfde0999f58f9a7a"},
|
||||||
]
|
]
|
||||||
|
|
||||||
[package.dependencies]
|
[package.dependencies]
|
||||||
asgiref = ">=3.4.0,<4.0.0"
|
asgiref = ">=3.4.0,<4.0.0"
|
||||||
async-asgi-testclient = ">=1.4.8,<2.0.0"
|
async-asgi-testclient = ">=1.4.8,<2.0.0"
|
||||||
nonebot2 = ">=2.0.0-beta.1,<3.0.0"
|
nonebot2 = ">=2.0.0-rc.2,<3.0.0"
|
||||||
pytest = ">=7.0.0,<8.0.0"
|
pytest = ">=7.0.0,<8.0.0"
|
||||||
typing-extensions = ">=4.0.0,<5.0.0"
|
typing-extensions = ">=4.0.0,<5.0.0"
|
||||||
|
|
||||||
@ -2379,4 +2452,4 @@ multidict = ">=4.0"
|
|||||||
[metadata]
|
[metadata]
|
||||||
lock-version = "2.0"
|
lock-version = "2.0"
|
||||||
python-versions = "^3.8.1"
|
python-versions = "^3.8.1"
|
||||||
content-hash = "20a3950358ff0c7df2fc8dde966cb5e2fcad0ec695ca605c9d23c84d6a2567ce"
|
content-hash = "5de28f6fa03c9bf7e2207a3d3688e379c2c4aa7ed672718583c99f7f0907bc1c"
|
||||||
|
@ -18,7 +18,7 @@ extra_standard_library = ["typing_extensions"]
|
|||||||
asyncio_mode = "auto"
|
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]
|
[tool.poetry]
|
||||||
@ -42,7 +42,7 @@ exclude = ["tests", "deploy"]
|
|||||||
[tool.poetry.dependencies]
|
[tool.poetry.dependencies]
|
||||||
python = "^3.8.1"
|
python = "^3.8.1"
|
||||||
nonebot2 = ">=2.0.0b4"
|
nonebot2 = ">=2.0.0b4"
|
||||||
nonebot-adapter-qqguild = ">=0.1.2"
|
nonebot-adapter-onebot = ">=2.1.1"
|
||||||
httpx = ">=0.23.0"
|
httpx = ">=0.23.0"
|
||||||
beautifulsoup4 = ">=4.11.1"
|
beautifulsoup4 = ">=4.11.1"
|
||||||
lxml = ">=4.9.2"
|
lxml = ">=4.9.2"
|
||||||
@ -70,7 +70,9 @@ flake8 = "^6.0.0"
|
|||||||
black = "^22.12.0"
|
black = "^22.12.0"
|
||||||
isort = "^5.11.5"
|
isort = "^5.11.5"
|
||||||
pre-commit = "^2.21.0"
|
pre-commit = "^2.21.0"
|
||||||
nonebug = "^0.2.2"
|
pycln = "^2.1.2"
|
||||||
|
|
||||||
|
[tool.poetry.group.test.dependencies]
|
||||||
|
nonebug = "^0.3.0"
|
||||||
pytest = "^7.2.0"
|
pytest = "^7.2.0"
|
||||||
pytest-asyncio = "^0.20.3"
|
pytest-asyncio = "^0.20.3"
|
||||||
pycln = "^2.1.2"
|
|
||||||
|
@ -28,14 +28,15 @@ httpx==0.23.3 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
|||||||
idna==3.4 ; python_full_version >= "3.8.1" and python_version < "4.0"
|
idna==3.4 ; python_full_version >= "3.8.1" and python_version < "4.0"
|
||||||
loguru==0.6.0 ; python_full_version >= "3.8.1" and python_version < "4.0"
|
loguru==0.6.0 ; python_full_version >= "3.8.1" and python_version < "4.0"
|
||||||
lxml==4.9.2 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
lxml==4.9.2 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
||||||
|
msgpack==1.0.5 ; python_full_version >= "3.8.1" and python_version < "4.0"
|
||||||
multidict==6.0.4 ; python_full_version >= "3.8.1" and python_version < "4.0"
|
multidict==6.0.4 ; python_full_version >= "3.8.1" and python_version < "4.0"
|
||||||
nonebot-adapter-qqguild==0.2.1 ; python_full_version >= "3.8.1" and python_version < "4.0"
|
nonebot-adapter-onebot==2.2.1 ; python_full_version >= "3.8.1" and python_version < "4.0"
|
||||||
nonebot-plugin-apscheduler==0.2.0 ; python_full_version >= "3.8.1" and python_version < "4.0"
|
nonebot-plugin-apscheduler==0.2.0 ; python_full_version >= "3.8.1" and python_version < "4.0"
|
||||||
nonebot2==2.0.0rc3 ; python_full_version >= "3.8.1" and python_version < "4.0"
|
nonebot2==2.0.0rc3 ; python_full_version >= "3.8.1" and python_version < "4.0"
|
||||||
openpyxl==3.1.1 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
openpyxl==3.1.1 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
||||||
passlib==1.7.4 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
passlib==1.7.4 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
||||||
pillow==9.4.0 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
pillow==9.4.0 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
||||||
pydantic==1.10.6 ; python_full_version >= "3.8.1" and python_version < "4.0"
|
pydantic==1.10.6 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
||||||
pydantic[dotenv]==1.10.6 ; python_full_version >= "3.8.1" and python_version < "4.0"
|
pydantic[dotenv]==1.10.6 ; python_full_version >= "3.8.1" and python_version < "4.0"
|
||||||
pygtrie==2.5.0 ; python_full_version >= "3.8.1" and python_version < "4.0"
|
pygtrie==2.5.0 ; python_full_version >= "3.8.1" and python_version < "4.0"
|
||||||
pypng==0.20220715.0 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
pypng==0.20220715.0 ; python_full_version >= "3.8.1" and python_full_version < "4.0.0"
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
LOG_LEVEL=TRACE
|
LOG_LEVEL=TRACE
|
||||||
NICKNAME=["test"]
|
NICKNAME=["test"]
|
||||||
SUPERUSERS=["10000"]
|
SUPERUSERS=["onebot:10000","10001","other:10002","abcdef"]
|
||||||
COMMAND_START=["", "/"]
|
COMMAND_START=["", "/"]
|
||||||
|
DRIVER="~none"
|
||||||
|
@ -1,34 +1,23 @@
|
|||||||
from typing import TYPE_CHECKING, Optional
|
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
import nonebot
|
||||||
|
from nonebug import NONEBOT_INIT_KWARGS
|
||||||
|
from nonebot.adapters.onebot.v11 import Adapter
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
PLUGINS = ["meta", "adv", "etcimg", "guide"]
|
||||||
from nonebot.plugin import Plugin
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture(scope="session", autouse=True)
|
||||||
def load_metadata(nonebug_init: None) -> Optional["Plugin"]:
|
def load_bot():
|
||||||
import nonebot
|
driver = nonebot.get_driver()
|
||||||
|
driver.register_adapter(Adapter)
|
||||||
|
|
||||||
return nonebot.load_plugin("GenshinUID.genshinuid_meta")
|
nonebot.load_all_plugins(
|
||||||
|
[f"GenshinUID.genshinuid_{name}" for name in PLUGINS], []
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
def pytest_configure(config: pytest.Config):
|
||||||
def load_adv(nonebug_init: None) -> Optional["Plugin"]:
|
config.stash[NONEBOT_INIT_KWARGS] = {
|
||||||
import nonebot
|
"genshinuid_disabled_plugins": {"xkdata", "abyss", "adv"},
|
||||||
|
"genshinuid_priority": 5,
|
||||||
return nonebot.load_plugin("GenshinUID.genshinuid_adv")
|
}
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
|
||||||
def load_etc(nonebug_init: None) -> Optional["Plugin"]:
|
|
||||||
import nonebot
|
|
||||||
|
|
||||||
return nonebot.load_plugin("GenshinUID.genshinuid_etcimg")
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
|
||||||
def load_guide(nonebug_init: None) -> Optional["Plugin"]:
|
|
||||||
import nonebot
|
|
||||||
|
|
||||||
return nonebot.load_plugin("GenshinUID.genshinuid_guide")
|
|
||||||
|
@ -6,12 +6,18 @@ MESSAGE = """「安柏」
|
|||||||
推荐5★武器:阿莫斯之弓、天空之翼、终末嗟叹之诗
|
推荐5★武器:阿莫斯之弓、天空之翼、终末嗟叹之诗
|
||||||
推荐4★武器:绝弦
|
推荐4★武器:绝弦
|
||||||
推荐圣遗物搭配:
|
推荐圣遗物搭配:
|
||||||
[昔日宗室之仪]四件套"""
|
[昔日宗室之仪]四件套
|
||||||
|
-=-=-=-=-=-=-=-=-=-
|
||||||
|
备注:
|
||||||
|
原神御三家之一,必胜客联动看板角色之一;
|
||||||
|
身份西风骑士团侦查骑士,蒙德飞行冠军,柏菈图的拼图(误);
|
||||||
|
人送外号解谜点火真君/打火姬
|
||||||
|
通常情况下,安柏的大世界解谜意义大于其深渊实战意义,建议根据实际需求选择投入资源培养"""
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
@pytest.mark.parametrize(argnames="alias", argvalues=["安柏用什么", "安柏怎么养"])
|
@pytest.mark.parametrize(argnames="alias", argvalues=["安柏用什么", "安柏怎么养"])
|
||||||
async def test_adv_char_chat(app: App, alias, load_adv: None):
|
async def test_adv_char_chat(app: App, alias):
|
||||||
from utils import make_event
|
from utils import make_event
|
||||||
from nonebot.adapters.onebot.v11 import Bot, Message
|
from nonebot.adapters.onebot.v11 import Bot, Message
|
||||||
|
|
||||||
|
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
|
@ -6,7 +6,7 @@ from nonebug import App
|
|||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
@pytest.mark.parametrize(argnames="alias", argvalues=["版本规划", "原石预估"])
|
@pytest.mark.parametrize(argnames="alias", argvalues=["版本规划", "原石预估"])
|
||||||
async def test_get_primogems_data(app: App, alias, load_etc: None):
|
async def test_get_primogems_data(app: App, alias):
|
||||||
from utils import make_event
|
from utils import make_event
|
||||||
from nonebot.adapters.onebot.v11 import Bot, Message, MessageSegment
|
from nonebot.adapters.onebot.v11 import Bot, Message, MessageSegment
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ async def test_get_primogems_data(app: App, alias, load_etc: None):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_primogems_version(app: App, load_etc: None):
|
async def test_primogems_version(app: App):
|
||||||
from utils import make_event
|
from utils import make_event
|
||||||
from nonebot.adapters.onebot.v11 import Bot, Message, MessageSegment
|
from nonebot.adapters.onebot.v11 import Bot, Message, MessageSegment
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ async def test_primogems_version(app: App, load_etc: None):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_primogems_failed(app: App, load_etc: None):
|
async def test_primogems_failed(app: App):
|
||||||
from utils import make_event
|
from utils import make_event
|
||||||
from nonebot.adapters.onebot.v11 import Bot, Message
|
from nonebot.adapters.onebot.v11 import Bot, Message
|
||||||
|
|
||||||
@ -100,7 +100,7 @@ async def test_primogems_failed(app: App, load_etc: None):
|
|||||||
"伤害乘区",
|
"伤害乘区",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
async def test_get_img_data(app: App, alias, load_etc: None):
|
async def test_get_img_data(app: App, alias):
|
||||||
from utils import make_event
|
from utils import make_event
|
||||||
from nonebot.adapters.onebot.v11 import Bot, Message, MessageSegment
|
from nonebot.adapters.onebot.v11 import Bot, Message, MessageSegment
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ from nonebug import App
|
|||||||
# "岩王爷攻略", # alias
|
# "岩王爷攻略", # alias
|
||||||
# ],
|
# ],
|
||||||
# )
|
# )
|
||||||
# async def test_get_guide_pic(app: App, alias, load_guide: None):
|
# async def test_get_guide_pic(app: App, alias ):
|
||||||
# from utils import make_event
|
# from utils import make_event
|
||||||
# from nonebot.adapters.onebot.v11 import Bot, Message, MessageSegment
|
# from nonebot.adapters.onebot.v11 import Bot, Message, MessageSegment
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ from nonebug import App
|
|||||||
|
|
||||||
|
|
||||||
# @pytest.mark.asyncio
|
# @pytest.mark.asyncio
|
||||||
# async def test_get_guide_pic_traveler(app: App, load_guide: None):
|
# async def test_get_guide_pic_traveler(app: App ):
|
||||||
# from utils import make_event
|
# from utils import make_event
|
||||||
# from nonebot.adapters.onebot.v11 import Bot, Message, MessageSegment
|
# from nonebot.adapters.onebot.v11 import Bot, Message, MessageSegment
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ from nonebug import App
|
|||||||
|
|
||||||
|
|
||||||
# @pytest.mark.asyncio
|
# @pytest.mark.asyncio
|
||||||
# async def test_get_guide_pic_failed(app: App, load_guide: None):
|
# async def test_get_guide_pic_failed(app: App ):
|
||||||
# from utils import make_event
|
# from utils import make_event
|
||||||
# from nonebot.adapters.onebot.v11 import Bot, Message
|
# from nonebot.adapters.onebot.v11 import Bot, Message
|
||||||
|
|
||||||
@ -79,7 +79,7 @@ from nonebug import App
|
|||||||
"参考面板岩王爷", # alias
|
"参考面板岩王爷", # alias
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
async def test_get_bluekun_pic(app: App, alias, load_guide: None):
|
async def test_get_bluekun_pic(app: App, alias):
|
||||||
from utils import make_event
|
from utils import make_event
|
||||||
from nonebot.adapters.onebot.v11 import Bot, Message, MessageSegment
|
from nonebot.adapters.onebot.v11 import Bot, Message, MessageSegment
|
||||||
|
|
||||||
@ -104,7 +104,7 @@ async def test_get_bluekun_pic(app: App, alias, load_guide: None):
|
|||||||
"冰",
|
"冰",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
async def test_get_bluekun_pic_element(app: App, alias, load_guide: None):
|
async def test_get_bluekun_pic_element(app: App, alias):
|
||||||
from utils import make_event
|
from utils import make_event
|
||||||
from nonebot.adapters.onebot.v11 import Bot, Message, MessageSegment
|
from nonebot.adapters.onebot.v11 import Bot, Message, MessageSegment
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ from nonebug import App
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_metadata(app: App, load_metadata: None):
|
async def test_metadata(app: App):
|
||||||
from GenshinUID.genshinuid_meta import __plugin_meta__
|
from GenshinUID.genshinuid_meta import __plugin_meta__
|
||||||
|
|
||||||
assert __plugin_meta__.name == 'GenshinUID'
|
assert __plugin_meta__.name == 'GenshinUID'
|
||||||
@ -13,7 +13,7 @@ async def test_metadata(app: App, load_metadata: None):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_register_menu(app: App, load_metadata: None):
|
async def test_register_menu(app: App):
|
||||||
from GenshinUID.genshinuid_meta import sub_menus, register_menu
|
from GenshinUID.genshinuid_meta import sub_menus, register_menu
|
||||||
|
|
||||||
@register_menu(
|
@register_menu(
|
||||||
@ -26,10 +26,11 @@ async def test_register_menu(app: App, load_metadata: None):
|
|||||||
async def _example() -> None:
|
async def _example() -> None:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
assert len(sub_menus) == 1
|
menu = {
|
||||||
menu = sub_menus[0]
|
"func": "test",
|
||||||
assert menu['func'] == 'test'
|
"trigger_condition": "trigger",
|
||||||
assert menu['trigger_condition'] == 'trigger'
|
"trigger_method": "114514",
|
||||||
assert menu['trigger_method'] == '114514'
|
"brief_des": "test register_menu",
|
||||||
assert menu['brief_des'] == 'test register_menu'
|
"detail_des": "test register_menu",
|
||||||
assert 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}
|
Reference in New Issue
Block a user