mirror of
https://github.com/nonebot/nonebot2.git
synced 2025-10-07 03:07:07 +00:00
Compare commits
1516 Commits
v2.0.0a9
...
v2.0.0-bet
Author | SHA1 | Date | |
---|---|---|---|
|
9b45b77894 | ||
|
e890453870 | ||
|
abcea78fcc | ||
|
80594cffb6 | ||
|
6d4c5cbc2d | ||
|
d295e9ef6b | ||
|
2ad46bf97a | ||
|
70ddc634f6 | ||
|
540629aa7c | ||
|
4f4369c712 | ||
|
c6633bc9af | ||
|
1c099b4d13 | ||
|
abe1e29fd9 | ||
|
e8b9963ef3 | ||
|
90f7c153cb | ||
|
983a5930c6 | ||
|
ff65f10da9 | ||
|
1710d009bb | ||
|
049d988574 | ||
|
97fa0b4fe9 | ||
|
cd42385a43 | ||
|
56f99b7f0b | ||
|
91c5056c97 | ||
|
5e970a291f | ||
|
42a49a20aa | ||
|
a4a329cf87 | ||
|
dc074f35d5 | ||
|
591107870e | ||
|
94b19b4833 | ||
|
1a91371410 | ||
|
a77664297d | ||
|
b889d2352e | ||
|
17e09267e0 | ||
|
bbf734b2d1 | ||
|
7ab9e85dc0 | ||
|
71bfb42fe0 | ||
|
aeaea54ac1 | ||
|
49437daf10 | ||
|
a93401e3b4 | ||
|
e87861983b | ||
|
2d81d54d93 | ||
|
e145d99335 | ||
|
7e3a58a0e8 | ||
|
11b6e1ba98 | ||
|
34186830ab | ||
|
b98be416e4 | ||
|
aaae928026 | ||
|
1e43b4df10 | ||
|
505b4d46d0 | ||
|
95331bbb22 | ||
|
f028575f2f | ||
|
252e3de459 | ||
|
6449b1e9fd | ||
|
5334f11902 | ||
|
76ffcf14e8 | ||
|
c8f25db6f6 | ||
|
4845ca10a4 | ||
|
eec27a267a | ||
|
3870f0084d | ||
|
06b36ec278 | ||
|
dcfa25c486 | ||
|
14953f5161 | ||
|
16f69b045b | ||
|
533e99418c | ||
|
f989710cd6 | ||
|
e1534f2205 | ||
|
532aee5e71 | ||
|
fb047a4987 | ||
|
af799aa846 | ||
|
91f4daa722 | ||
|
42fa47263a | ||
|
39fd544651 | ||
|
e5bb30e2b5 | ||
|
a6d8f18cf0 | ||
|
47d843ddca | ||
|
74542d30e0 | ||
|
e12445be2f | ||
|
d8eb7d311b | ||
|
7ac14bab03 | ||
|
e2621b4448 | ||
|
2f3324ce0c | ||
|
494b9c625d | ||
|
f20cf785ce | ||
|
82803ff90f | ||
|
d38b5602a6 | ||
|
adb5fd8ca0 | ||
|
977e1de077 | ||
|
537866db95 | ||
|
9ffd78dda3 | ||
|
599da5158e | ||
|
2b64e8266c | ||
|
8ccf10954a | ||
|
09b9a626e6 | ||
|
1d221fddab | ||
|
524ed419c2 | ||
|
536e75f994 | ||
|
130c2ed5c0 | ||
|
3c8e705bb0 | ||
|
87e5e15b52 | ||
|
a2abc5a714 | ||
|
de434b3072 | ||
|
614f005373 | ||
|
36efa3f441 | ||
|
78a90ef7aa | ||
|
2e5df56d38 | ||
|
a230e98052 | ||
|
45e2e6c280 | ||
|
fcdb05a7e2 | ||
|
8c6d5a2d1f | ||
|
8735b61a8d | ||
|
02de6fd266 | ||
|
06f8dde33c | ||
|
0fe3e4fb16 | ||
|
56c6f6a471 | ||
|
58e69f7884 | ||
|
4ebbf7638c | ||
|
8d7507c8f2 | ||
|
c1c720756b | ||
|
a1be18f7f4 | ||
|
e2fcfa902e | ||
|
b54f4c8d4c | ||
|
4cf07ca2e0 | ||
|
5b3dd8f020 | ||
|
9bb291e95b | ||
|
492c0947c3 | ||
|
547d50ad76 | ||
|
f7600a8a62 | ||
|
9bd380a3bb | ||
|
8600687f7d | ||
|
1d98ea1961 | ||
|
998db949da | ||
|
dea1b8c6fa | ||
|
d348f544b1 | ||
|
b1559eee42 | ||
|
edc7183c22 | ||
|
ea539345cc | ||
|
03d60dd0be | ||
|
48003a779f | ||
|
2203b82b09 | ||
|
9fc2f7c02e | ||
|
6ee295bfd7 | ||
|
6b067f0865 | ||
|
339c25638b | ||
|
e6cd3e57f5 | ||
|
69fcda5658 | ||
|
88f8614cfc | ||
|
273b302ef2 | ||
|
e86bab74d3 | ||
|
b1df360900 | ||
|
2c271da965 | ||
|
5db9c1e232 | ||
|
b05ce41b1d | ||
|
bda27c78b9 | ||
|
6f0e27ee6d | ||
|
2c89409667 | ||
|
5adc5ce1cd | ||
|
cad2f90b8a | ||
|
b3d246cfb1 | ||
|
a8a6eb8c93 | ||
|
86a73011b1 | ||
|
9fb089bf08 | ||
|
72d993921f | ||
|
db764f7e9e | ||
|
1767f7a388 | ||
|
fc45c67d97 | ||
|
87885bd878 | ||
|
d75a04b31a | ||
|
12313204e1 | ||
|
4573235583 | ||
|
4293bdf21f | ||
|
baae3e48de | ||
|
24df95ae4a | ||
|
6b50a57348 | ||
|
6920ec3a11 | ||
|
6586f28f6a | ||
|
192c8da09c | ||
|
1fba27d9b8 | ||
|
0f0dc0a818 | ||
|
3c3a250180 | ||
|
03d33f3bdc | ||
|
1147d67f1a | ||
|
98e5956d44 | ||
|
999a6a0e10 | ||
|
ff2675b527 | ||
|
daa026cfd7 | ||
|
d4d3962177 | ||
|
1d6a333b49 | ||
|
9c0e05c615 | ||
|
258bdbe403 | ||
|
c48ddaf0a2 | ||
|
9dd989c627 | ||
|
3d84844a58 | ||
|
d63d434e0f | ||
|
5216a5b8f2 | ||
|
4107affb9b | ||
|
b898303e4d | ||
|
43aebd9c93 | ||
|
fcda5c37d7 | ||
|
1412385e51 | ||
|
00fab9143e | ||
|
5e17d4c2f9 | ||
|
d7de928f22 | ||
|
83ff7a3a6c | ||
|
6f9c9eb740 | ||
|
6272dfd46a | ||
|
ab78769822 | ||
|
004a308765 | ||
|
98e0ec27ee | ||
|
a491d842db | ||
|
722fc6c6e1 | ||
|
a5fffe2a4f | ||
|
5f1f84327d | ||
|
3d8ac3e789 | ||
|
c05eea2b67 | ||
|
a6299bec8f | ||
|
513c14ee78 | ||
|
987e44e1d0 | ||
|
e7937e5a06 | ||
|
962c71ea4e | ||
|
04e9a50bc1 | ||
|
4bd1b92e9f | ||
|
f737bb899c | ||
|
9f12404338 | ||
|
cee96d8ab6 | ||
|
14703fce8d | ||
|
6d0c782fcc | ||
|
0cceeaec0b | ||
|
803223f31c | ||
|
6ceaf51af7 | ||
|
8f38fc5795 | ||
|
257c49466f | ||
|
85d86dfa96 | ||
|
925886534c | ||
|
9a53b415d9 | ||
|
a884869ae2 | ||
|
04fe654d74 | ||
|
ff887481ee | ||
|
0bfe1ce433 | ||
|
80bf73e0e9 | ||
|
a8694aee23 | ||
|
943de58826 | ||
|
c0af89a6ad | ||
|
b076497823 | ||
|
a416b4315a | ||
|
4f91e63759 | ||
|
dc982fe5eb | ||
|
1b17039fe1 | ||
|
b4fc9f9539 | ||
|
b7762b9176 | ||
|
455c599b06 | ||
|
e9908bcbc4 | ||
|
fba9471fe6 | ||
|
58bceff175 | ||
|
c45843e32d | ||
|
aefe16f2c7 | ||
|
460efe436d | ||
|
aacfc9b90c | ||
|
7d190213b7 | ||
|
ae37f31e38 | ||
|
6f90dcb12f | ||
|
5ce72655e2 | ||
|
9ed5d915d5 | ||
|
c4d82aa21b | ||
|
319b3ff20e | ||
|
5e19ad672e | ||
|
2d276a6b7a | ||
|
e98e784fe7 | ||
|
f4120d91e0 | ||
|
2f51afc007 | ||
|
b9fd4b1ac8 | ||
|
f4395d77d7 | ||
|
28cfa45d95 | ||
|
b90054e61b | ||
|
1ee7f73d59 | ||
|
118519e15d | ||
|
65dc9a908b | ||
|
924d9b6536 | ||
|
fd11e2696b | ||
|
b8456b12ad | ||
|
dcaf5cedcf | ||
|
2cd2ea6ca4 | ||
|
6e8978710a | ||
|
7e5c179641 | ||
|
86aa3ef2e8 | ||
|
994b99e462 | ||
|
b0b2b1f681 | ||
|
4e1e0e98b4 | ||
|
a68a6e2659 | ||
|
e8bb66ca48 | ||
|
e720584044 | ||
|
ec9e8511b7 | ||
|
3a314fc7ae | ||
|
fe5e5428dd | ||
|
e37e6d0714 | ||
|
7cdcfd02ab | ||
|
578f0fb619 | ||
|
3408f27a77 | ||
|
0fd7c77640 | ||
|
613fc09382 | ||
|
4d5cc03454 | ||
|
09b438485a | ||
|
c7883863c7 | ||
|
60ccdf8a7a | ||
|
ea188cb948 | ||
|
244c7266b3 | ||
|
1eaacde745 | ||
|
c33e7eca46 | ||
|
bdf2f4771b | ||
|
2cd6867bd1 | ||
|
f3cc93c699 | ||
|
244b3c02a8 | ||
|
2ec5917709 | ||
|
a0d9c4e1a0 | ||
|
5abf55d095 | ||
|
34e2535390 | ||
|
5fa7806a2f | ||
|
1b674496ed | ||
|
b43dfb983d | ||
|
e887c39998 | ||
|
4c2269f789 | ||
|
ac0dd63ca4 | ||
|
a8a68d89a2 | ||
|
942bb8761e | ||
|
ad712c59b3 | ||
|
1271a757c9 | ||
|
ea8a700f86 | ||
|
fd8fd233b6 | ||
|
d06e06eba2 | ||
|
392def7936 | ||
|
c4d08d13cb | ||
|
ffab125f02 | ||
|
0b150d35f7 | ||
|
15d68706b3 | ||
|
2924c74333 | ||
|
afea004421 | ||
|
1b08e0d822 | ||
|
1da7da9fc1 | ||
|
1b6b9d61fe | ||
|
b222863f63 | ||
|
e1dffa99a0 | ||
|
0885474b94 | ||
|
482fba234b | ||
|
770e808f1d | ||
|
fdf05173be | ||
|
5c73c80c65 | ||
|
bda2991c30 | ||
|
efbfea3d94 | ||
|
956ee7e321 | ||
|
ba8dfb6d94 | ||
|
1a202e918d | ||
|
2e78de3d5d | ||
|
f53e374521 | ||
|
b773083b4e | ||
|
ebd45dc5c1 | ||
|
2f61c6a6f9 | ||
|
22597959cf | ||
|
6b930cd7be | ||
|
c8369f599f | ||
|
c09ecb4a88 | ||
|
74c3961998 | ||
|
e7b2dde44a | ||
|
77faa027bd | ||
|
40f7c4013b | ||
|
ba6a440bbd | ||
|
d0d6e0fc25 | ||
|
26934124a1 | ||
|
05f4a8b363 | ||
|
cb92bb7007 | ||
|
bc2abc9c51 | ||
|
ebd7e4df19 | ||
|
48b507e272 | ||
|
6a17ce5fda | ||
|
44ca11cceb | ||
|
12d28eb77d | ||
|
0513b5884d | ||
|
97563a0090 | ||
|
596f763c46 | ||
|
5f3902fe61 | ||
|
ceb7589b27 | ||
|
fa8a3987e7 | ||
|
8f51aff483 | ||
|
c1084cc437 | ||
|
46757a315b | ||
|
4316990aab | ||
|
7d81e079de | ||
|
12d9a68351 | ||
|
c4e204001e | ||
|
f9674da6ea | ||
|
794a640681 | ||
|
1bdb27d109 | ||
|
aef585c60c | ||
|
215cfc90f4 | ||
|
b671a9658b | ||
|
017049f321 | ||
|
10733e7520 | ||
|
b343fb8e6f | ||
|
f6308916ad | ||
|
b3d0e7c548 | ||
|
67f5b87492 | ||
|
30a14eb99c | ||
|
92714de522 | ||
|
98ef09585a | ||
|
13e021fa1e | ||
|
82224da9ab | ||
|
2877c39288 | ||
|
af0b0ae823 | ||
|
4701537a48 | ||
|
608cf859c8 | ||
|
27b1ded9a1 | ||
|
60800b1d9e | ||
|
c675addeef | ||
|
a07919ad5c | ||
|
ce0e230887 | ||
|
b037be4485 | ||
|
3b4c4d3081 | ||
|
1221baaa94 | ||
|
39822378a7 | ||
|
3041650b4b | ||
|
3a9a5a9ce9 | ||
|
34c086a046 | ||
|
cf819af179 | ||
|
9b6d8b6efa | ||
|
478dff512f | ||
|
cc1dc10b5d | ||
|
b7a0ba11d5 | ||
|
93aec6d3f6 | ||
|
9c729d194b | ||
|
dcfba4e94a | ||
|
55b1f962ac | ||
|
6c0ab74956 | ||
|
9cbac0b4ca | ||
|
8d0951a816 | ||
|
8a896b42a3 | ||
|
d26fda7320 | ||
|
9af7079fdd | ||
|
1d49defdfa | ||
|
0e31a5fbf4 | ||
|
ad5a011b45 | ||
|
341ee94848 | ||
|
a47b8c68c0 | ||
|
cc343c981f | ||
|
10395d6bce | ||
|
6713f4d9b0 | ||
|
8494768a89 | ||
|
88bd49de45 | ||
|
b52ccc3690 | ||
|
a8a1b4d65d | ||
|
98deadb4d6 | ||
|
ec06010298 | ||
|
cd69b22d43 | ||
|
f298930f9d | ||
|
0e97022d3b | ||
|
6d21cbed55 | ||
|
edb20a4786 | ||
|
187532930b | ||
|
456d333568 | ||
|
a5f32febbd | ||
|
4ba1a09fb7 | ||
|
0099364838 | ||
|
0e11959347 | ||
|
705a6f7fbf | ||
|
eeb54c8f8a | ||
|
c9056c6fd0 | ||
|
e29db806cc | ||
|
f837e5f3fa | ||
|
d82f0c6310 | ||
|
18082d0dc7 | ||
|
6ca54574ce | ||
|
85fc2422d1 | ||
|
bb7313f12c | ||
|
742d1f1f02 | ||
|
1b035ed19b | ||
|
ea65ee5b4f | ||
|
6572622e8a | ||
|
00de3bcc54 | ||
|
2ccdc218e0 | ||
|
c11c62f622 | ||
|
59c77d312a | ||
|
a14cfc8d77 | ||
|
d6f5216d29 | ||
|
d549087db2 | ||
|
3fa8bd2cd0 | ||
|
8674d18543 | ||
|
096f0d72f1 | ||
|
f0e935d4ff | ||
|
490a8146bc | ||
|
a74c6e220b | ||
|
0e8ef3def2 | ||
|
ba4e90b14f | ||
|
d02d8f06b2 | ||
|
95415659ce | ||
|
304118c98e | ||
|
3fe3c1351f | ||
|
b0536edab3 | ||
|
ff330e1536 | ||
|
6c00432c10 | ||
|
1c37024699 | ||
|
ad2ebc3818 | ||
|
92fd6fb669 | ||
|
a904becfe0 | ||
|
7a8b38bd07 | ||
|
cd94672999 | ||
|
3e66bc73a6 | ||
|
f01694dfe7 | ||
|
d13ca9aee6 | ||
|
0a10a3c18b | ||
|
6b2d8d2674 | ||
|
cf1333f8a8 | ||
|
0cbcc04396 | ||
|
f396f76425 | ||
|
89ae275793 | ||
|
381e5e4a76 | ||
|
ac6eed9217 | ||
|
abf4d57987 | ||
|
1393318bce | ||
|
1ee1ed80c0 | ||
|
20751e8ee5 | ||
|
1030b73555 | ||
|
e39539a3be | ||
|
159fc12fb9 | ||
|
93b76894bb | ||
|
2b5f3268c8 | ||
|
87f9ccd058 | ||
|
402de4bb8a | ||
|
1af67b4431 | ||
|
493a4e5880 | ||
|
ef386af2bc | ||
|
896f1d6596 | ||
|
69b4c29dcb | ||
|
dd5112ff99 | ||
|
3bede1581f | ||
|
e54b80f739 | ||
|
bd7ee0a1ba | ||
|
aaed95cae1 | ||
|
7f54468868 | ||
|
07cb96864c | ||
|
96749bde83 | ||
|
bbbb5bbecd | ||
|
7053f0ee72 | ||
|
6950e5b34d | ||
|
5fe5273f8f | ||
|
479952777b | ||
|
0541008fb5 | ||
|
be1915381e | ||
|
43938a004e | ||
|
983e5aefdb | ||
|
620938c26c | ||
|
338c41abd5 | ||
|
2bb365c70e | ||
|
574d4366a6 | ||
|
feadffebcd | ||
|
78d0ec847e | ||
|
ec35f292bd | ||
|
c48231454e | ||
|
56677616b4 | ||
|
ab2c73856d | ||
|
21a958ffd9 | ||
|
e4691f0525 | ||
|
2beed6bf16 | ||
|
d1706e438b | ||
|
23d0b2509e | ||
|
80c0ac5456 | ||
|
af03188f88 | ||
|
4bd2156929 | ||
|
c7f428795b | ||
|
39fd8b2dcd | ||
|
0aea7f13e3 | ||
|
f06b78054c | ||
|
3323393261 | ||
|
5cfeb4e79d | ||
|
86c859fec2 | ||
|
9379182f04 | ||
|
db826caff4 | ||
|
0f5a4473ab | ||
|
7690f0e640 | ||
|
3b1dd6d5db | ||
|
7e9dabfd5f | ||
|
c815ac7ca3 | ||
|
91262d68bc | ||
|
717fbd1b95 | ||
|
2ec04e5a4c | ||
|
c1e06c2ec0 | ||
|
fd9ec5e6fa | ||
|
8093c5d154 | ||
|
e64f399370 | ||
|
7b204d72e6 | ||
|
00c2ee8490 | ||
|
d773fea709 | ||
|
7ebae277d1 | ||
|
9b9941e6c5 | ||
|
188eb110c5 | ||
|
e62ce93011 | ||
|
2f5e523b5a | ||
|
495053f83b | ||
|
5c67290f00 | ||
|
80258fe2d4 | ||
|
75e2ca77df | ||
|
6ed87f1910 | ||
|
6643f951ef | ||
|
e968b71239 | ||
|
a51158cfc0 | ||
|
17f3c8fd09 | ||
|
76104d3237 | ||
|
e3aba26080 | ||
|
8fb394e4c3 | ||
|
b9f1890d80 | ||
|
0839d6d062 | ||
|
e870fcceab | ||
|
ee7f4daef7 | ||
|
cda49551a8 | ||
|
b984f99643 | ||
|
71caa4a0ae | ||
|
fecdb5367a | ||
|
9e316bff77 | ||
|
9b2fa46921 | ||
|
b900133ab4 | ||
|
cf8670c167 | ||
|
e9b8515cf1 | ||
|
d549cdf26a | ||
|
1a602b68e3 | ||
|
883ea18224 | ||
|
e5fdb1e07a | ||
|
ea8f7717b9 | ||
|
c49059f9d3 | ||
|
0d24a79840 | ||
|
6968d34fc2 | ||
|
008c6fd036 | ||
|
44e5182322 | ||
|
c2c3d5ef4b | ||
|
ca045b2f73 | ||
|
ec9e159ef6 | ||
|
c0f321116a | ||
|
3d762fcbab | ||
|
fe69735ca0 | ||
|
acbb886942 | ||
|
3dac49f271 | ||
|
14f88d4062 | ||
|
de7c51a518 | ||
|
329a1fd226 | ||
|
9613e47682 | ||
|
ec1249f5fb | ||
|
0316033a57 | ||
|
baabf2a83a | ||
|
85ee0ce420 | ||
|
27f8d6aa28 | ||
|
e942f4076c | ||
|
8f3978f2b2 | ||
|
3b8ba6ee3a | ||
|
60461c767e | ||
|
66ba25494a | ||
|
6b5a5e53eb | ||
|
344c3576b1 | ||
|
5efdc71d9f | ||
|
f160310aea | ||
|
5aedc52537 | ||
|
a0d13822c0 | ||
|
6963047af2 | ||
|
4de01d7d4f | ||
|
61e17d0de7 | ||
|
b64b02bb45 | ||
|
47d4909b31 | ||
|
d80c02ae46 | ||
|
180aaadda9 | ||
|
a85ee6555f | ||
|
bbaf156826 | ||
|
5b75b72720 | ||
|
ca4d7397f8 | ||
|
02ef337bc4 | ||
|
d82ab12948 | ||
|
c25ee1cb56 | ||
|
59e139724b | ||
|
b52954a240 | ||
|
aea961b346 | ||
|
a148ef7bfe | ||
|
3c428d98c4 | ||
|
2ce305da2a | ||
|
226fc0feb3 | ||
|
534119eaf0 | ||
|
c037c7a196 | ||
|
b4e49d8b8d | ||
|
b47869198d | ||
|
dcb6f69f21 | ||
|
7d8a60b033 | ||
|
0236746e65 | ||
|
2dc5a7e1b1 | ||
|
a414406039 | ||
|
5a7af6d6e2 | ||
|
f2b15d4efa | ||
|
4570baa57b | ||
|
b92c1a0b33 | ||
|
319b03acd8 | ||
|
44356154fa | ||
|
a6112fdf64 | ||
|
d0821cd12f | ||
|
ebdc8c7004 | ||
|
37f55652d9 | ||
|
bd55cd19e3 | ||
|
a369d7dcbc | ||
|
030237fe22 | ||
|
6cf7f1f1fc | ||
|
f9b244b0d6 | ||
|
29f14a20ce | ||
|
286729f703 | ||
|
db5d4d7acf | ||
|
a98d98cd12 | ||
|
602185a34e | ||
|
3120abacb3 | ||
|
225e48d420 | ||
|
91bd5aa708 | ||
|
23c237cb2a | ||
|
9a29966e2d | ||
|
760ac693c0 | ||
|
a864b36e9f | ||
|
75d4cd9565 | ||
|
d22630e768 | ||
|
b4d12d905d | ||
|
d1c03208e4 | ||
|
8ee9697cc0 | ||
|
a5948fb5e3 | ||
|
471d306e13 | ||
|
81e1cf23c7 | ||
|
203e1c1897 | ||
|
646eedb2ad | ||
|
4150e4d771 | ||
|
c1163bed8d | ||
|
1b9a6cb2ca | ||
|
ee619a33a9 | ||
|
36d93b8a3a | ||
|
dc31afbd18 | ||
|
4cbdd726e5 | ||
|
ea502c1fff | ||
|
d1c6eeb6c2 | ||
|
cafe5c9af0 | ||
|
0a1ae75b70 | ||
|
7495fee2a2 | ||
|
9d708a6723 | ||
|
f7eadb48b5 | ||
|
c454cf0874 | ||
|
57e826a835 | ||
|
ecb9d6bc28 | ||
|
512d77de0d | ||
|
618753bd3a | ||
|
fdffaf4e85 | ||
|
7c27fbe1d5 | ||
|
554ad156c0 | ||
|
8be2de4cfc | ||
|
2ccbc93e48 | ||
|
b796f3cabc | ||
|
4e482685ae | ||
|
08f56db385 | ||
|
72f5aeea54 | ||
|
1236abe507 | ||
|
06c1978260 | ||
|
f1b204f421 | ||
|
2b26f519af | ||
|
069e7024ec | ||
|
2d7d5f73c2 | ||
|
75774d34bc | ||
|
0c2c2717ac | ||
|
d10f557212 | ||
|
32e3c17552 | ||
|
e632e99feb | ||
|
e38772435d | ||
|
d9093a20e0 | ||
|
130f11ac68 | ||
|
9a44a2ff2f | ||
|
c81c0578e3 | ||
|
b01db74e0b | ||
|
4c40acb09d | ||
|
3722547f1c | ||
|
e12e18022b | ||
|
9a84bd175c | ||
|
ac87107556 | ||
|
33f605a947 | ||
|
2a08f6bdf6 | ||
|
b9c91dc5c3 | ||
|
6b79106cd1 | ||
|
0fa85be0e4 | ||
|
69f8821acb | ||
|
ff96a11dc5 | ||
|
042f7faa71 | ||
|
0d5849759f | ||
|
391a899045 | ||
|
b72583b8c8 | ||
|
cbb3ec1fb8 | ||
|
9f70daca59 | ||
|
cfd992b6b1 | ||
|
6ec1159f95 | ||
|
38ac45f687 | ||
|
1331cbf8a3 | ||
|
a6fc0e408c | ||
|
66b2153493 | ||
|
94b98b74b9 | ||
|
f3abd2f1a3 | ||
|
1280cf9ba3 | ||
|
bac56635c0 | ||
|
6d9caadffc | ||
|
4a7c07a7ac | ||
|
910d18e79f | ||
|
5cff80812e | ||
|
c8a8ff28ec | ||
|
292b8e6366 | ||
|
9e9608abd8 | ||
|
3452880b16 | ||
|
ef2c98c6af | ||
|
246b8ccbe7 | ||
|
2355c6385d | ||
|
75811c0b64 | ||
|
3a510e3888 | ||
|
161cfbe1b8 | ||
|
0b08d23e34 | ||
|
2ebf7fc096 | ||
|
041b59011b | ||
|
92a411e3b4 | ||
|
81cbf84dca | ||
|
4364685b30 | ||
|
cfdebb30b7 | ||
|
049d14295e | ||
|
3dc93f7997 | ||
|
b19c2e4191 | ||
|
d121a2080b | ||
|
919e3ebf8c | ||
|
b0f4b8ffa1 | ||
|
b3bf9470cf | ||
|
16029a33e8 | ||
|
b31d04dc5d | ||
|
e0f73ba193 | ||
|
0b35d5e724 | ||
|
c747342709 | ||
|
244df12069 | ||
|
368afe6d63 | ||
|
5cd61c09a8 | ||
|
1e55fbf6b1 | ||
|
463ff260c4 | ||
|
89e32a3241 | ||
|
4f8771acbd | ||
|
a212baf90b | ||
|
5db8b124ab | ||
|
a273d75b07 | ||
|
55a402203e | ||
|
64967e8807 | ||
|
43917b5aad | ||
|
b97133fb59 | ||
|
855f61d837 | ||
|
e2003e27df | ||
|
d82749c48e | ||
|
0a802f9b13 | ||
|
e0610fdcc0 | ||
|
20d0ecfc7f | ||
|
fa15e5b0ee | ||
|
d9cc912ccb | ||
|
09d9f414ce | ||
|
ca09fb8372 | ||
|
b25a0387ba | ||
|
9931563d80 | ||
|
53a576dae5 | ||
|
44d13acc81 | ||
|
59f567004f | ||
|
956e581d72 | ||
|
b635d01519 | ||
|
12c1f6d764 | ||
|
b66a4df4c5 | ||
|
46c61df081 | ||
|
b6ec81c21d | ||
|
f9f2f1b0bd | ||
|
45396e3163 | ||
|
7ced508f9d | ||
|
ed1f1c27e2 | ||
|
3fa75b1c78 | ||
|
258ef670e2 | ||
|
5cf665fa21 | ||
|
116f16b470 | ||
|
9518e3c568 | ||
|
57827ea4bb | ||
|
8e41422055 | ||
|
fcd168fd3e | ||
|
fe1bd87ff8 | ||
|
efe1615d16 | ||
|
ca26609308 | ||
|
01e818f6a4 | ||
|
1c73a9adfa | ||
|
a739b93561 | ||
|
7cfdc2dd37 | ||
|
a6ff3711bb | ||
|
58d10abd32 | ||
|
f0bc47ec5e | ||
|
b5f2b1a76d | ||
|
4f4a072dd7 | ||
|
fff7d3bff6 | ||
|
474fd10613 | ||
|
9bea710e45 | ||
|
3c76c6ff8b | ||
|
a8a61623d2 | ||
|
24ce531598 | ||
|
a6be0c370f | ||
|
22c7371f2e | ||
|
bfb77e9cdf | ||
|
9aa346fb1f | ||
|
1dfe5d49fc | ||
|
e48788e41f | ||
|
802c39da32 | ||
|
0d23a9ab8d | ||
|
109cae6dac | ||
|
f63ef8d23b | ||
|
3d4d3b0f24 | ||
|
a3fa1a36c9 | ||
|
45cec05bbc | ||
|
e4d1462585 | ||
|
18c6bea451 | ||
|
c4e3309026 | ||
|
57a60ae45b | ||
|
e7f5097e17 | ||
|
e437c13bb3 | ||
|
edd7f3ccc8 | ||
|
26f0d66017 | ||
|
5791018af1 | ||
|
2c6b41f62c | ||
|
f2b23f1b44 | ||
|
a534f7b58c | ||
|
81398bb803 | ||
|
3a0265b0f6 | ||
|
59db66ef27 | ||
|
a04957a354 | ||
|
371cfd4a0e | ||
|
037a5ccce0 | ||
|
879767df01 | ||
|
31b18e36e7 | ||
|
eb3e20abfb | ||
|
b96823b5bd | ||
|
b098c8477b | ||
|
02b2589eeb | ||
|
05ea21becd | ||
|
2836f50e74 | ||
|
7b3d66cd2a | ||
|
ceebe0e95d | ||
|
2fe01f33e0 | ||
|
410266acb1 | ||
|
02924d56cd | ||
|
0bd8d4fbbc | ||
|
547bebebd9 | ||
|
f8703557a0 | ||
|
8e97a84ad8 | ||
|
3564228183 | ||
|
bb93757f51 | ||
|
e18b3d04fb | ||
|
458085b317 | ||
|
832875e7cf | ||
|
73762e65bb | ||
|
26e627c36c | ||
|
8b93dc7769 | ||
|
6cfd44224d | ||
|
dc8b7887d7 | ||
|
18f98e4cbc | ||
|
db73d2b621 | ||
|
7a3cd8c395 | ||
|
358528b495 | ||
|
cda1ad093f | ||
|
f48c61c2e0 | ||
|
571cdef826 | ||
|
0ce3ee6c20 | ||
|
600fc4fffd | ||
|
c1b10a0e48 | ||
|
904f285f62 | ||
|
8680695586 | ||
|
a1803553fb | ||
|
9c647682e7 | ||
|
fb6e5a69f2 | ||
|
cf85cbecb3 | ||
|
948ea93599 | ||
|
de48ed99a7 | ||
|
8a6c26440c | ||
|
cf747f954c | ||
|
54a7e4808c | ||
|
03f5683d52 | ||
|
58c922f042 | ||
|
98e65ebdec | ||
|
e4a4a8127e | ||
|
72b0ee0130 | ||
|
679ec94020 | ||
|
1f0be1e1e3 | ||
|
bcc55a9143 | ||
|
749d33478a | ||
|
cb68e0ee1b | ||
|
ecc613f6c5 | ||
|
04b3fda40c | ||
|
32787fdc1e | ||
|
637c48aea7 | ||
|
5768b5bdd6 | ||
|
96d05cb521 | ||
|
92e5b8ea88 | ||
|
59ed869ed0 | ||
|
a14d475de2 | ||
|
8ea4561f1c | ||
|
5ac43eb459 | ||
|
c22d97fe47 | ||
|
bb964213f1 | ||
|
ef1547cbfe | ||
|
f2295318a9 | ||
|
66b54de869 | ||
|
d802fad111 | ||
|
8acd561de6 | ||
|
b4e20e00e4 | ||
|
3230dfc14a | ||
|
607f338934 | ||
|
758108229a | ||
|
aac4571d43 | ||
|
0436c1b7b8 | ||
|
a740a9cfea | ||
|
57ff73269b | ||
|
625c12fc12 | ||
|
4fc655323d | ||
|
f0482bb636 | ||
|
df6486f926 | ||
|
141cd10651 | ||
|
711fffe3b0 | ||
|
2c056364c1 | ||
|
c6921c731c | ||
|
8c7498eeb5 | ||
|
30cb6be104 | ||
|
fbd60e30fc | ||
|
2908cb3ce2 | ||
|
b1c5013088 | ||
|
70e424b58f | ||
|
730186cfd4 | ||
|
d2ae2e2982 | ||
|
67770ffa6f | ||
|
15ab958a70 | ||
|
af6f63dc44 | ||
|
7c7994e2e2 | ||
|
f597303698 | ||
|
1222972b73 | ||
|
7df407056b | ||
|
79b6601d12 | ||
|
53d98f3d2e | ||
|
fe43c8d69a | ||
|
e490be9eb0 | ||
|
3af8b55985 | ||
|
aaed345a20 | ||
|
f42d578765 | ||
|
f5843dd3ad | ||
|
840580334f | ||
|
5a8b5b5696 | ||
|
dc5aa3d4bf | ||
|
b9befc8350 | ||
|
e3c3e370cb | ||
|
603a63a629 | ||
|
276d09bb54 | ||
|
5635c83bfb | ||
|
0ec7cdc3aa | ||
|
932963e71c | ||
|
322ac98c50 | ||
|
811e94e186 | ||
|
0c39300f4b | ||
|
33bd7582be | ||
|
b6979594a7 | ||
|
150ef30b73 | ||
|
1042759d60 | ||
|
866149902c | ||
|
136b13b4cc | ||
|
cc11e2e885 | ||
|
f9f1e33262 | ||
|
7a8f881b04 | ||
|
20c3c24a6d | ||
|
f80ba8451f | ||
|
b1fa2bbb80 | ||
|
406511496d | ||
|
24144a9474 | ||
|
3571a5fdc0 | ||
|
4afd681ca9 | ||
|
48816308f8 | ||
|
3e66eb2fdb | ||
|
d669fed5e9 | ||
|
8e915f808b | ||
|
46ace83106 | ||
|
da16bdbb96 | ||
|
c1b7b78929 | ||
|
b9de8baac4 | ||
|
b3718c3042 | ||
|
69cee3844e | ||
|
1db462e4ad | ||
|
23cfa5564a | ||
|
7879346ca1 | ||
|
ef5a49933f | ||
|
e0bd7e11d5 | ||
|
0c5bbdaabe | ||
|
d8e29a81aa | ||
|
9f15b69724 | ||
|
cd12718dcb | ||
|
94c3c47523 | ||
|
fde6181d3c | ||
|
a4c6d834ff | ||
|
c8e494ca83 | ||
|
f87c23c9a7 | ||
|
b2f21ab974 | ||
|
6749afe75e | ||
|
8849cb73bb | ||
|
ad2060e651 | ||
|
c76dae584e | ||
|
edb7c79acf | ||
|
76c830739c | ||
|
8e6f8fada8 | ||
|
ddd96271b0 | ||
|
e9bc98e74d | ||
|
af6e9217c7 | ||
|
c0d78449be | ||
|
d7f2837efe | ||
|
cf9b5fd980 | ||
|
b42cafafd6 | ||
|
136c9a2687 | ||
|
cf45572211 | ||
|
c9d80255ae | ||
|
393be3baa4 | ||
|
fd01213697 | ||
|
2f5eb1a0f9 | ||
|
ca31ec5fe3 | ||
|
2003dfd703 | ||
|
f3342722f5 | ||
|
b2f5f93603 | ||
|
830276d110 | ||
|
9342d03f4d | ||
|
fe588caebb | ||
|
b0026831d0 | ||
|
46d7804c98 | ||
|
accbf57776 | ||
|
62c0dd6e74 | ||
|
916bb5b0e6 | ||
|
45e1126f37 | ||
|
57cf8e9bd8 | ||
|
f609a9fe0e | ||
|
4795f01583 | ||
|
06f9f795aa | ||
|
2d7d8992c0 | ||
|
15007feea7 | ||
|
8095be9ab9 | ||
|
ea48b86310 | ||
|
6402d8a4de | ||
|
5ec30c5122 | ||
|
c4b83a60f1 | ||
|
0fec4c8592 | ||
|
a09e09b942 | ||
|
7e8296b36e | ||
|
322477638a | ||
|
e659b4b2b6 | ||
|
27fe6e4fcb | ||
|
7d8b0843a0 | ||
|
e44b427b7a | ||
|
2ff6f87842 | ||
|
84dfe18f39 | ||
|
918b375ece | ||
|
c82a4820f7 | ||
|
c6e62957ab | ||
|
8a14177219 | ||
|
24268072fc | ||
|
3c65f2dd19 | ||
|
3f14a92a3e | ||
|
adf2016f4e | ||
|
81bb8be7f3 | ||
|
744f9e9f5d | ||
|
e2de13e122 | ||
|
3939dfa024 | ||
|
8680a954f8 | ||
|
20001764bf | ||
|
61512ff01f | ||
|
2488c6295e | ||
|
100f560558 | ||
|
01678005f0 | ||
|
00dc72b6c4 | ||
|
ca21fb8202 | ||
|
5989c3fecd | ||
|
7376933c31 | ||
|
a573266cab | ||
|
8374f86fde | ||
|
4a18772d2c | ||
|
5d0ac94bfe | ||
|
a636ddfab4 | ||
|
5c2840ca27 | ||
|
44850a279d | ||
|
17f3258207 | ||
|
b95fed69b0 | ||
|
059935aedb | ||
|
c99e1880d3 | ||
|
faf7a3b500 | ||
|
41c5ac0ac7 | ||
|
f8ad9ef278 | ||
|
5146a30836 | ||
|
db59cd9578 | ||
|
4b38afdcd7 | ||
|
b87971247a | ||
|
dcf4838fda | ||
|
6f40365407 | ||
|
315fdb97d3 | ||
|
9a3e974063 | ||
|
6b3183cdfa | ||
|
5189a182b5 | ||
|
884a7b966f | ||
|
fa73c13800 | ||
|
593d593a62 | ||
|
c2c8906b7d | ||
|
71f68fc1ce | ||
|
add2bda2c1 | ||
|
beef2ad8cf | ||
|
554865f97f | ||
|
d3e7ed4a71 | ||
|
56e489b458 | ||
|
5f3bd91321 | ||
|
4655bf1df8 | ||
|
9052214e6d | ||
|
59405bbe7a | ||
|
260d119711 | ||
|
5abc0d9614 | ||
|
4ba6ff106c | ||
|
9e51df9116 | ||
|
64d51448b8 | ||
|
79d3bbcdfe | ||
|
c24d0def09 | ||
|
e08843dd5c | ||
|
ec35ef041a | ||
|
efe8dd98b5 | ||
|
3fb9b25284 | ||
|
06deb13826 | ||
|
7d189392d2 | ||
|
2a07b49cb7 | ||
|
0be145491d | ||
|
58dd4a2183 | ||
|
810477749b | ||
|
92b035bea8 | ||
|
9801a8cebd | ||
|
f5a22b3d4b | ||
|
abbcb36131 | ||
|
d4860af85f | ||
|
50a4cbdb80 | ||
|
dff9a74f35 | ||
|
a5c2b06493 | ||
|
7bb49f0b3c | ||
|
00b4b880e9 | ||
|
87d93def62 | ||
|
0315aa7d8f | ||
|
b9812ea11b | ||
|
207750774d | ||
|
176dbd5830 | ||
|
1c6711355e | ||
|
20e1bf9624 | ||
|
d1a438a287 | ||
|
0d467d9275 | ||
|
c402b7599f | ||
|
916d620012 | ||
|
0fd82d4f54 | ||
|
e425571b08 | ||
|
85f0023350 | ||
|
0eadf5f4e9 | ||
|
b09a7518f5 | ||
|
0235af770f | ||
|
e03e3f6130 | ||
|
f0a6ff4627 | ||
|
6b763e20d0 | ||
|
fcb1c5d316 | ||
|
953328903c | ||
|
afba90838f | ||
|
f1ed783776 | ||
|
59ec5bacde | ||
|
ca08c56df7 | ||
|
d1e8925fe0 | ||
|
68ba1c1af2 | ||
|
03ac119313 | ||
|
8f99b01fb5 | ||
|
4e7592de98 | ||
|
5db819738e | ||
|
ade5d923ab | ||
|
43b185a3b8 | ||
|
65ec4828a9 | ||
|
1f585d8bcb | ||
|
b861149e0b | ||
|
534b51bc73 | ||
|
430b3467cc | ||
|
2dc7107990 | ||
|
81edb535a4 | ||
|
f00ce8b4f6 | ||
|
696ae2da6b | ||
|
b7e5ce88ea | ||
|
8fc8cb6112 | ||
|
48fae782d7 | ||
|
f3e78cc82e | ||
|
45199a247b | ||
|
f0a8b47c06 | ||
|
6371cd6bfe | ||
|
d738f8674d | ||
|
abfda3113b | ||
|
a941b32dd5 | ||
|
1527fb55f5 | ||
|
ffc1cd7d8d | ||
|
7f27957164 | ||
|
f8c057b135 | ||
|
2166595e50 | ||
|
22033e1cfb | ||
|
fc334ec7b9 | ||
|
e7dc4e1eec | ||
|
6bd12b7f2c | ||
|
5d48a92d1d | ||
|
4bc87ca747 | ||
|
62135dc117 | ||
|
1e294b8fbe | ||
|
9258bb09b4 | ||
|
b31317720b | ||
|
211c571508 | ||
|
785eac1345 | ||
|
bb64c6fb71 | ||
|
782232fb1a | ||
|
0fec9915de | ||
|
efacff698d | ||
|
36d0628e4f | ||
|
46c65b919f | ||
|
0b9aad09cf | ||
|
717e74f01d | ||
|
ef4f8df5a7 | ||
|
dce1187750 | ||
|
5ee6beb4b8 | ||
|
3af8cc45ea | ||
|
89ff2dd3c5 | ||
|
e7101a1f39 | ||
|
2af7f2bedb | ||
|
ad70fac377 | ||
|
2885e6053c | ||
|
4661adc564 | ||
|
edc6da9e61 | ||
|
d49749e5a1 | ||
|
8544fb2f69 | ||
|
80e41d26e2 | ||
|
8d6bb3768b | ||
|
c54007d7a4 | ||
|
35bf3ef772 | ||
|
06e1459667 | ||
|
da97a18497 | ||
|
61e33e24e9 | ||
|
f49a581193 | ||
|
f30b9e4fb9 | ||
|
c3a8dc709f | ||
|
63d6f173d6 | ||
|
8d80b610d1 | ||
|
80a54914e2 | ||
|
ac613b5839 | ||
|
33412f9bd2 | ||
|
51304fdd8e | ||
|
e139c883a3 | ||
|
662c5c09a6 | ||
|
a99d33198f | ||
|
e6ac07e608 | ||
|
d476c7e999 | ||
|
22655005f9 | ||
|
f7dd898379 | ||
|
d568a31684 | ||
|
46795ecd4b | ||
|
f1f510604e | ||
|
611049681a | ||
|
15c6f30fc3 | ||
|
59a855f2ed | ||
|
db61a93de8 | ||
|
4ed5b06db0 | ||
|
9e04e497b7 | ||
|
464f0d4a89 | ||
|
1df24a683e | ||
|
873aa62825 | ||
|
cb6c1cccca | ||
|
f6289ff1b3 | ||
|
7b61cd370e | ||
|
7f4ee24f87 | ||
|
3c8dca67fa | ||
|
b962bc43e6 | ||
|
e70b29bb9e | ||
|
94a55fead5 | ||
|
b23e845726 | ||
|
dc17d514b4 | ||
|
5e24300619 | ||
|
dc38a98180 | ||
|
af27e8f3f5 | ||
|
01af05742c | ||
|
11052dbcd1 | ||
|
f9e4d077d4 | ||
|
3477c0d8b4 | ||
|
8c9e096a84 | ||
|
19a780eabb | ||
|
3c312d9759 | ||
|
bb37d757da | ||
|
9ea80abf8c | ||
|
117758658e | ||
|
da290dad07 | ||
|
00daaed074 | ||
|
6f2b9a1d13 | ||
|
04e11c3b3e | ||
|
eb8e5aa39d | ||
|
93ffc93a80 | ||
|
d3091cdb3e | ||
|
869df38238 | ||
|
507000b63b | ||
|
6ab18f2d14 | ||
|
80714c9b61 | ||
|
42157f3dd1 | ||
|
854c2ae499 | ||
|
f397789516 | ||
|
fe8d711108 | ||
|
f31318b7f4 | ||
|
74ce56817c | ||
|
31682f5f28 | ||
|
7d3b397ff4 | ||
|
352f9f85c1 | ||
|
f9d4bcba3d | ||
|
2c85b2aa19 | ||
|
9bbadddfa9 | ||
|
247456df56 | ||
|
be674c0efc | ||
|
f26fb9d6fb | ||
|
6cd6750729 | ||
|
19c4602354 | ||
|
60ef01b66f | ||
|
f40f1788df | ||
|
c855ebcfb1 | ||
|
24f3900c69 | ||
|
70581abcef | ||
|
f2c732722f | ||
|
e76430a43b | ||
|
20e19d34b8 | ||
|
f58eb61f2d | ||
|
35e9321feb | ||
|
631743171f | ||
|
fc2694497e | ||
|
31b8a5ff77 | ||
|
6ce034ca20 | ||
|
3cc738c205 | ||
|
7b2af1b2f3 | ||
|
eeec690e71 | ||
|
aba18a2f68 | ||
|
17c7903bee | ||
|
ad47c24b60 | ||
|
6eab05d57f | ||
|
f4d623be25 | ||
|
4a961d8584 | ||
|
36e6f5b5c1 | ||
|
332a3a4f93 | ||
|
145caee37a | ||
|
2fa7b7ca00 | ||
|
d60fca90f6 | ||
|
4abfa2cf2b | ||
|
ada964e5aa | ||
|
16cf694a77 | ||
|
362b8724fc | ||
|
d06a927085 | ||
|
031faa5923 | ||
|
a2c1e5fd26 | ||
|
ac35c13727 | ||
|
f7b8c7ab8d | ||
|
802250eb71 | ||
|
3fb002c977 | ||
|
98d1d407c3 | ||
|
8821218bfd | ||
|
27b9b413df | ||
|
2b67b0f12e | ||
|
d26d7bba55 | ||
|
0761a60443 | ||
|
217b1a5fac | ||
|
ef98a6f23c | ||
|
c6a6dc6e21 | ||
|
f3b77a7f60 | ||
|
f625c34269 | ||
|
ac5c4acf09 | ||
|
9a3464744f | ||
|
91bdfc4704 | ||
|
6f8aa49d0e | ||
|
be57798eac | ||
|
4855e65b1a | ||
|
a3fe3a1ad8 | ||
|
382a9b6e12 | ||
|
24349953e3 | ||
|
85aba9e36f | ||
|
49010bf5b7 | ||
|
b1c7f309f8 | ||
|
458ddaa167 | ||
|
ab97334cf8 | ||
|
112fdf7ed3 | ||
|
b59ff03abf | ||
|
bdd9f5ae30 | ||
|
abcdbc4de9 | ||
|
1715139494 | ||
|
b862c506e4 | ||
|
4fd4fbfb08 | ||
|
6cb9fda53a | ||
|
4f7a033b9c | ||
|
c537841bc1 | ||
|
7d9a8eaf19 | ||
|
86965ee06d | ||
|
496f64f103 | ||
|
9e0862bc97 | ||
|
6b43ad5575 | ||
|
bf7b2a8cbe | ||
|
7232c89292 | ||
|
bc164ca2f2 | ||
|
ad8429e7fa | ||
|
c268e0105d | ||
|
050137fb3f | ||
|
f2d04c598c | ||
|
49307a3df2 | ||
|
ff9f0bc74a | ||
|
f929f25abd | ||
|
6af0a2574d | ||
|
c61a159eff | ||
|
59bdd03b1e | ||
|
35ea1e78ec | ||
|
7db386b752 | ||
|
e6a68feb0c | ||
|
78b0450d66 | ||
|
bd5fb46e0a | ||
|
cc3ed735f1 | ||
|
3f0c3f1f37 | ||
|
e1ff0a7221 | ||
|
2bf8b4d313 | ||
|
188aa8a50a | ||
|
1538d2094a | ||
|
16eb74e88b |
20
.devcontainer/Dockerfile
Normal file
20
.devcontainer/Dockerfile
Normal file
@@ -0,0 +1,20 @@
|
||||
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.233.0/containers/codespaces-linux/.devcontainer/base.Dockerfile
|
||||
|
||||
FROM mcr.microsoft.com/vscode/devcontainers/universal:linux
|
||||
|
||||
# ** [Optional] Uncomment this section to install additional packages. **
|
||||
# USER root
|
||||
#
|
||||
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
|
||||
# && apt-get -y install --no-install-recommends <your-package-list-here>
|
||||
|
||||
USER codespace
|
||||
|
||||
# [Required] Poetry
|
||||
RUN curl -sSL https://install.python-poetry.org | python - -y
|
||||
RUN poetry config virtualenvs.in-project true
|
||||
|
||||
# [Required] Gitmoji CLI
|
||||
# Deprecated: Maybe removed once nonemoji is done
|
||||
RUN yarn global add gitmoji-cli
|
||||
ENV PATH="$PATH:/home/codespace/.yarn/bin"
|
83
.devcontainer/devcontainer.json
Normal file
83
.devcontainer/devcontainer.json
Normal file
@@ -0,0 +1,83 @@
|
||||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
|
||||
// https://github.com/microsoft/vscode-dev-containers/tree/v0.233.0/containers/codespaces-linux
|
||||
{
|
||||
"name": "NoneBot",
|
||||
"build": {
|
||||
"dockerfile": "Dockerfile",
|
||||
"context": ".."
|
||||
},
|
||||
"settings": {
|
||||
"go.toolsManagement.checkForUpdates": "local",
|
||||
"go.useLanguageServer": true,
|
||||
"go.gopath": "/go",
|
||||
"python.defaultInterpreterPath": "/opt/python/latest/bin/python",
|
||||
"python.formatting.autopep8Path": "/usr/local/py-utils/bin/autopep8",
|
||||
"python.formatting.blackPath": "/usr/local/py-utils/bin/black",
|
||||
"python.formatting.yapfPath": "/usr/local/py-utils/bin/yapf",
|
||||
"python.linting.banditPath": "/usr/local/py-utils/bin/bandit",
|
||||
"python.linting.flake8Path": "/usr/local/py-utils/bin/flake8",
|
||||
"python.linting.mypyPath": "/usr/local/py-utils/bin/mypy",
|
||||
"python.linting.pycodestylePath": "/usr/local/py-utils/bin/pycodestyle",
|
||||
"python.linting.pydocstylePath": "/usr/local/py-utils/bin/pydocstyle",
|
||||
"python.linting.pylintPath": "/usr/local/py-utils/bin/pylint",
|
||||
"python.analysis.diagnosticMode": "workspace",
|
||||
"python.analysis.typeCheckingMode": "basic",
|
||||
"[python]":{
|
||||
"editor.defaultFormatter": "ms-python.black-formatter",
|
||||
"editor.codeActionsOnSave": {
|
||||
"source.organizeImports": true
|
||||
}
|
||||
},
|
||||
"[javascript]": {
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||
},
|
||||
"[html]": {
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||
},
|
||||
"[typescript]": {
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||
},
|
||||
"[javascriptreact]": {
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||
},
|
||||
"[typescriptreact]": {
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||
},
|
||||
"lldb.executable": "/usr/bin/lldb",
|
||||
"files.exclude": {
|
||||
"**/__pycache__": true
|
||||
},
|
||||
"files.watcherExclude": {
|
||||
"**/target/**": true,
|
||||
"**/__pycache__": true
|
||||
}
|
||||
},
|
||||
"remoteUser": "codespace",
|
||||
"overrideCommand": false,
|
||||
"mounts": ["source=codespaces-linux-var-lib-docker,target=/var/lib/docker,type=volume"],
|
||||
"runArgs": [
|
||||
"--cap-add=SYS_PTRACE",
|
||||
"--security-opt",
|
||||
"seccomp=unconfined",
|
||||
"--privileged",
|
||||
"--init"
|
||||
],
|
||||
|
||||
// Add the IDs of extensions you want installed when the container is created.
|
||||
"extensions": [
|
||||
"GitHub.vscode-pull-request-github",
|
||||
"ms-python.python",
|
||||
"ms-python.vscode-pylance",
|
||||
"ms-python.isort",
|
||||
"ms-python.black-formatter",
|
||||
"EditorConfig.EditorConfig",
|
||||
"esbenp.prettier-vscode",
|
||||
"bradlc.vscode-tailwindcss"
|
||||
],
|
||||
|
||||
// Use 'forwardPorts' to make a list of ports inside the container available locally.
|
||||
// "forwardPorts": [],
|
||||
|
||||
// "oryx build" will automatically install your dependencies and attempt to build your project
|
||||
"postCreateCommand": "poetry install -E all && poetry run pre-commit install && yarn install"
|
||||
}
|
7
.github/ISSUE_TEMPLATE/bug-report.md
vendored
7
.github/ISSUE_TEMPLATE/bug-report.md
vendored
@@ -28,6 +28,11 @@ A clear and concise description of what you expected to happen.
|
||||
- Python Version: [e.g. 3.8]
|
||||
- Nonebot Version: [e.g. 2.0.0]
|
||||
|
||||
**截图**
|
||||
**协议端信息:**
|
||||
|
||||
- 协议端: [e.g. go-cqhttp]
|
||||
- 协议端版本: [e.g. 1.0.0]
|
||||
|
||||
**截图或日志**
|
||||
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
|
14
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
14
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
blank_issues_enabled: false
|
||||
contact_links:
|
||||
- name: Question
|
||||
url: https://discussions.nonebot.dev/
|
||||
about: Ask questions about nonebot
|
||||
- name: Plugin Publish
|
||||
url: https://v2.nonebot.dev/store
|
||||
about: Publish your plugin to nonebot homepage and nb-cli
|
||||
- name: Adapter Publish
|
||||
url: https://v2.nonebot.dev/store
|
||||
about: Publish your adapter to nonebot homepage and nb-cli
|
||||
- name: Bot Publish
|
||||
url: https://v2.nonebot.dev/store
|
||||
about: Publish your bot to nonebot homepage and nb-cli
|
17
.github/ISSUE_TEMPLATE/document.md
vendored
Normal file
17
.github/ISSUE_TEMPLATE/document.md
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
---
|
||||
name: Document improvement
|
||||
about: Feedback on documentation, including errors and ideas
|
||||
title: 'Docs: some description'
|
||||
labels: documentation
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**描述问题或主题:**
|
||||
|
||||
|
||||
**需做出的修改:**
|
||||
|
||||
* [ ] 一些修改
|
||||
* [ ] 一些修改
|
||||
* [ ] 一些修改
|
36
.github/ISSUE_TEMPLATE/plugin-publish.md
vendored
36
.github/ISSUE_TEMPLATE/plugin-publish.md
vendored
@@ -1,36 +0,0 @@
|
||||
---
|
||||
name: Plugin Publish
|
||||
about: Publish your plugin to nonebot homepage and nb-cli
|
||||
title: "Plugin: blabla 的插件"
|
||||
labels: Plugin
|
||||
assignees: ""
|
||||
|
||||
---
|
||||
|
||||
**你的插件名称:**
|
||||
|
||||
例:复读机
|
||||
|
||||
**简短描述插件功能:**
|
||||
|
||||
例:复读群友的消息
|
||||
|
||||
**插件 import 使用的名称**
|
||||
|
||||
例:nonebot_plugin_example
|
||||
|
||||
**插件 install 使用的名称**
|
||||
|
||||
例 1:nonebot-plugin-example
|
||||
|
||||
通过 pypi 安装
|
||||
|
||||
> 请事先发布插件到[pypi](https://pypi.org/)
|
||||
|
||||
例 2:git+https://github.com/nonebot/nonebot-plugin-example
|
||||
|
||||
从 github 仓库安装
|
||||
|
||||
**插件项目仓库/主页链接**
|
||||
|
||||
例:nonebot/nonebot2(默认 github )或其他链接
|
11
.github/actions/build-api-doc/action.yml
vendored
Normal file
11
.github/actions/build-api-doc/action.yml
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
name: Build API Doc
|
||||
description: Build API Doc
|
||||
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- run: |
|
||||
poetry run nb-autodoc nonebot
|
||||
cp -r ./build/nonebot/* ./website/docs/api/
|
||||
yarn prettier
|
||||
shell: bash
|
21
.github/actions/setup-node/action.yml
vendored
Normal file
21
.github/actions/setup-node/action.yml
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
name: Setup Node
|
||||
description: Setup Node
|
||||
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: "16"
|
||||
|
||||
- id: yarn-cache-dir-path
|
||||
run: echo "::set-output name=dir::$(yarn cache dir)"
|
||||
shell: bash
|
||||
|
||||
- uses: actions/cache@v2
|
||||
with:
|
||||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
||||
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
||||
|
||||
- run: yarn install
|
||||
shell: bash
|
26
.github/actions/setup-python/action.yml
vendored
Normal file
26
.github/actions/setup-python/action.yml
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
name: Setup Python
|
||||
description: Setup Python
|
||||
|
||||
inputs:
|
||||
python-version:
|
||||
description: Python version
|
||||
required: false
|
||||
default: "3.9"
|
||||
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: ${{ inputs.python-version }}
|
||||
architecture: "x64"
|
||||
|
||||
- uses: Gr1N/setup-poetry@v7
|
||||
|
||||
- uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/.cache/pypoetry/virtualenvs
|
||||
key: ${{ runner.os }}-poetry-${{ inputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
|
||||
|
||||
- run: poetry install -E all
|
||||
shell: bash
|
6
.github/dependabot.yml
vendored
Normal file
6
.github/dependabot.yml
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: github-actions
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: daily
|
57
.github/release-drafter.yml
vendored
57
.github/release-drafter.yml
vendored
@@ -1,38 +1,43 @@
|
||||
name-template: 'v$RESOLVED_VERSION 🌈'
|
||||
tag-template: 'v$RESOLVED_VERSION'
|
||||
template: $CHANGES
|
||||
category-template: "### $TITLE"
|
||||
name-template: "Release v$RESOLVED_VERSION 🌈"
|
||||
tag-template: "v$RESOLVED_VERSION"
|
||||
change-template: "- $TITLE [@$AUTHOR](https://github.com/$AUTHOR) ([#$NUMBER]($URL))"
|
||||
change-title-escapes: '\<&'
|
||||
exclude-labels:
|
||||
- "dependencies"
|
||||
- "skip-changelog"
|
||||
categories:
|
||||
- title: '💥 Breaking Changes'
|
||||
- title: "💥 破坏性变更"
|
||||
labels:
|
||||
- 'Breaking'
|
||||
- title: '🚀 Features'
|
||||
- "Breaking"
|
||||
- title: "🚀 新功能"
|
||||
labels:
|
||||
- 'feature'
|
||||
- 'enhancement'
|
||||
- title: '🐛 Bug Fixes'
|
||||
- "feature"
|
||||
- "enhancement"
|
||||
- title: "🐛 Bug 修复"
|
||||
labels:
|
||||
- 'fix'
|
||||
- 'bugfix'
|
||||
- 'bug'
|
||||
- title: '🍻 Plugin Publish'
|
||||
label: 'Plugin'
|
||||
change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
|
||||
change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks.
|
||||
- "fix"
|
||||
- "bugfix"
|
||||
- "bug"
|
||||
- title: "📝 文档"
|
||||
labels:
|
||||
- "documentation"
|
||||
- title: "💫 杂项"
|
||||
- title: "🍻 插件发布"
|
||||
label: "Plugin"
|
||||
- title: "🍻 机器人发布"
|
||||
label: "Bot"
|
||||
- title: "🍻 适配器发布"
|
||||
label: "Adapter"
|
||||
version-resolver:
|
||||
major:
|
||||
labels:
|
||||
- 'major'
|
||||
- "major"
|
||||
minor:
|
||||
labels:
|
||||
- 'minor'
|
||||
- "minor"
|
||||
patch:
|
||||
labels:
|
||||
- 'patch'
|
||||
- "patch"
|
||||
default: patch
|
||||
template: |
|
||||
## Documentation
|
||||
|
||||
See: https://v2.nonebot.dev
|
||||
|
||||
## 💫 Changes
|
||||
|
||||
$CHANGES
|
||||
|
44
.github/workflows/build_docs.yml
vendored
44
.github/workflows/build_docs.yml
vendored
@@ -1,44 +0,0 @@
|
||||
name: Build API Doc
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [ opened, synchronize, reopened ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: 3.8
|
||||
architecture: "x64"
|
||||
|
||||
- uses: Gr1N/setup-poetry@v4
|
||||
|
||||
- uses: actions/cache@v1
|
||||
with:
|
||||
path: ~/.cache/pypoetry/virtualenvs
|
||||
key: ${{ runner.os }}-poetry-${{ hashFiles('poetry.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-poetry-
|
||||
|
||||
- name: Set up dependencies
|
||||
run: |
|
||||
poetry install
|
||||
|
||||
- name: Build Doc
|
||||
run: poetry run sphinx-build -M markdown ./docs_build ./build
|
||||
|
||||
- name: Copy Files
|
||||
run: cp -r ./build/markdown/* ./docs/api/
|
||||
|
||||
- uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: docs
|
||||
path: docs/
|
43
.github/workflows/codecov.yml
vendored
Normal file
43
.github/workflows/codecov.yml
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
name: Code Coverage
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
name: Test Coverage
|
||||
runs-on: ${{ matrix.os }}
|
||||
concurrency:
|
||||
group: test-coverage-${{ github.ref }}-${{ matrix.os }}-${{ matrix.python-version }}
|
||||
cancel-in-progress: true
|
||||
strategy:
|
||||
matrix:
|
||||
python-version: ["3.7", "3.8", "3.9", "3.10"]
|
||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
||||
fail-fast: false
|
||||
env:
|
||||
OS: ${{ matrix.os }}
|
||||
PYTHON_VERSION: ${{ matrix.python-version }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Setup Python environment
|
||||
uses: ./.github/actions/setup-python
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
|
||||
- name: Run Pytest
|
||||
run: |
|
||||
cd tests/
|
||||
poetry run pytest -n auto --cov-report xml
|
||||
|
||||
- name: Upload coverage report
|
||||
uses: codecov/codecov-action@v3
|
||||
with:
|
||||
env_vars: OS,PYTHON_VERSION
|
||||
files: ./tests/coverage.xml
|
||||
flags: unittests
|
40
.github/workflows/nonebot_plugin_docs.yml
vendored
40
.github/workflows/nonebot_plugin_docs.yml
vendored
@@ -1,40 +0,0 @@
|
||||
name: Release Nonebot Plugin Docs
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [ published ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: '12'
|
||||
- run: npm ci
|
||||
- name: Build Docs
|
||||
env:
|
||||
VUEPRESS_BASE: '/docs/'
|
||||
run: npx vuepress build docs --dest packages/nonebot-plugin-docs/nonebot_plugin_docs/dist
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: 3.8
|
||||
architecture: "x64"
|
||||
- name: Install Poetry
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install poetry
|
||||
|
||||
- name: Publish Package
|
||||
run: |
|
||||
export NONEBOT_VERSION=`poetry version -s`
|
||||
cd packages/nonebot-plugin-docs/
|
||||
poetry version $NONEBOT_VERSION
|
||||
poetry build
|
||||
poetry publish -u ${{secrets.PYPI_USERNAME}} -p ${{secrets.PYPI_PASSWORD}}
|
25
.github/workflows/plugin_issue.yml
vendored
25
.github/workflows/plugin_issue.yml
vendored
@@ -1,25 +0,0 @@
|
||||
name: 'Plugin Issue Bot'
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
issues:
|
||||
types: [opened, reopened, edited]
|
||||
pull_request:
|
||||
types: [closed]
|
||||
|
||||
jobs:
|
||||
issue_bot:
|
||||
runs-on: ubuntu-latest
|
||||
name: plugin issue bot
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: NoneBot2 Plugin Issue Bot
|
||||
uses: he0119/nonebot2-plugin-issue-bot@v0.2
|
||||
with:
|
||||
token: ${{ secrets.GH_TOKEN }}
|
||||
base: master
|
||||
path: docs/.vuepress/public/plugins.json
|
29
.github/workflows/publish-bot.yml
vendored
Normal file
29
.github/workflows/publish-bot.yml
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
name: NoneBot2 Publish Bot
|
||||
|
||||
on:
|
||||
issues:
|
||||
types: [opened, reopened, edited]
|
||||
pull_request_target:
|
||||
types: [closed]
|
||||
|
||||
jobs:
|
||||
publish_bot:
|
||||
runs-on: ubuntu-latest
|
||||
name: nonebot2 publish bot
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
token: ${{ secrets.GH_TOKEN }}
|
||||
|
||||
- name: NoneBot2 Publish Bot
|
||||
uses: docker://ghcr.io/nonebot/nonebot2-publish-bot:main
|
||||
with:
|
||||
token: ${{ secrets.GH_TOKEN }}
|
||||
config: >
|
||||
{
|
||||
"base": "master",
|
||||
"plugin_path": "website/static/plugins.json",
|
||||
"bot_path": "website/static/bots.json",
|
||||
"adapter_path": "website/static/adapters.json"
|
||||
}
|
14
.github/workflows/release-draft.yml
vendored
14
.github/workflows/release-draft.yml
vendored
@@ -1,14 +0,0 @@
|
||||
name: Release Drafter
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
update_release_draft:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: release-drafter/release-drafter@v5
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
97
.github/workflows/release-drafter.yml
vendored
Normal file
97
.github/workflows/release-drafter.yml
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
name: Release Drafter
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- v*
|
||||
pull_request_target:
|
||||
branches:
|
||||
- master
|
||||
types:
|
||||
- closed
|
||||
|
||||
jobs:
|
||||
update-release-draft:
|
||||
if: github.event_name == 'pull_request_target'
|
||||
runs-on: ubuntu-latest
|
||||
concurrency:
|
||||
group: pull-request-changelog
|
||||
cancel-in-progress: true
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
token: ${{ secrets.GH_TOKEN }}
|
||||
|
||||
- name: Setup Node Environment
|
||||
uses: ./.github/actions/setup-node
|
||||
|
||||
- uses: release-drafter/release-drafter@v5
|
||||
id: release-drafter
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Update Changelog
|
||||
uses: docker://ghcr.io/nonebot/auto-changelog:master
|
||||
with:
|
||||
changelog_file: website/src/pages/changelog.md
|
||||
latest_changes_position: '# 更新日志\n\n'
|
||||
latest_changes_title: '## 最近更新'
|
||||
replace_regex: '(?<=## 最近更新\n)[\s\S]*?(?=\n## )'
|
||||
changelog_body: ${{ steps.release-drafter.outputs.body }}
|
||||
commit_and_push: false
|
||||
|
||||
- name: Commit and Push
|
||||
run: |
|
||||
yarn prettier
|
||||
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 ":memo: Update changelog"
|
||||
git push
|
||||
|
||||
|
||||
release:
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Setup Python Environment
|
||||
uses: ./.github/actions/setup-python
|
||||
|
||||
- name: Setup Node Environment
|
||||
uses: ./.github/actions/setup-node
|
||||
|
||||
- name: Build API Doc
|
||||
uses: ./.github/actions/build-api-doc
|
||||
|
||||
- run: |
|
||||
echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
|
||||
|
||||
- uses: release-drafter/release-drafter@v5
|
||||
with:
|
||||
name: Release ${{ env.TAG_NAME }} 🌈
|
||||
tag: ${{ env.TAG_NAME }}
|
||||
publish: true
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Build and Publish Package
|
||||
run: |
|
||||
poetry build
|
||||
poetry publish -u ${{secrets.PYPI_USERNAME}} -p ${{secrets.PYPI_PASSWORD}}
|
||||
gh release upload --clobber ${{ env.TAG_NAME }} dist/*.tar.gz dist/*.whl
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Build and Publish Doc Package
|
||||
run: |
|
||||
yarn build:plugin --out-dir ../packages/nonebot-plugin-docs/nonebot_plugin_docs/dist
|
||||
export NONEBOT_VERSION=`poetry version -s`
|
||||
cd packages/nonebot-plugin-docs/
|
||||
poetry version $NONEBOT_VERSION
|
||||
poetry build
|
||||
poetry publish -u ${{secrets.PYPI_USERNAME}} -p ${{secrets.PYPI_PASSWORD}}
|
||||
gh release upload --clobber ${{ env.TAG_NAME }} dist/*.tar.gz dist/*.whl
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
47
.github/workflows/release.yml
vendored
Normal file
47
.github/workflows/release.yml
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
name: Release
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
ref: master
|
||||
token: ${{ secrets.GH_TOKEN }}
|
||||
|
||||
- name: Setup Python Environment
|
||||
uses: ./.github/actions/setup-python
|
||||
|
||||
- name: Setup Node Environment
|
||||
uses: ./.github/actions/setup-node
|
||||
|
||||
- name: Build API Doc
|
||||
uses: ./.github/actions/build-api-doc
|
||||
|
||||
- run: echo "TAG_NAME=v$(poetry version -s)" >> $GITHUB_ENV
|
||||
|
||||
- name: Archive Changelog
|
||||
uses: docker://ghcr.io/nonebot/auto-changelog:master
|
||||
with:
|
||||
changelog_file: website/src/pages/changelog.md
|
||||
archive_regex: '(?<=## )最近更新(?=\n)'
|
||||
archive_title: ${{ env.TAG_NAME }}
|
||||
commit_and_push: false
|
||||
|
||||
- name: Archive Files
|
||||
run: |
|
||||
yarn archive $(poetry version -s)
|
||||
yarn prettier
|
||||
|
||||
- name: Push Tag
|
||||
run: |
|
||||
git config user.name github-actions[bot]
|
||||
git config user.email github-actions[bot]@users.noreply.github.com
|
||||
git add .
|
||||
git commit -m ":bookmark: Release $(poetry version -s)"
|
||||
git tag ${{ env.TAG_NAME }}
|
||||
git push && git push --tags
|
35
.github/workflows/upload_docs.yml
vendored
35
.github/workflows/upload_docs.yml
vendored
@@ -1,35 +0,0 @@
|
||||
name: Upload API Doc
|
||||
|
||||
on:
|
||||
workflow_run:
|
||||
workflows: ["Build API Doc"]
|
||||
types:
|
||||
- completed
|
||||
|
||||
jobs:
|
||||
upload:
|
||||
runs-on: ubuntu-latest
|
||||
if: ${{ github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' }}
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
ref: ${{ github.event.workflow_run.head_sha }}
|
||||
token: ${{ secrets.GH_TOKEN }}
|
||||
|
||||
- uses: dawidd6/action-download-artifact@v2
|
||||
with:
|
||||
workflow: ${{ github.event.workflow_run.workflow_id }}
|
||||
name: docs
|
||||
path: docs/
|
||||
|
||||
- env:
|
||||
REF: ${{ github.event.workflow_run.head_branch }}
|
||||
PR_REPO: ${{ github.event.workflow_run.head_repository.full_name }}
|
||||
PR_USER: ${{ github.event.workflow_run.head_repository.owner.login }}
|
||||
run: |
|
||||
git config user.name $PR_USER
|
||||
git config user.email $PR_USER@users.noreply.github.com
|
||||
git add .
|
||||
git diff-index --quiet HEAD || git commit -m ":memo: update api docs"
|
||||
git remote add target https://github.com/$PR_REPO.git
|
||||
git push target HEAD:$REF
|
44
.github/workflows/website-deploy.yml
vendored
Normal file
44
.github/workflows/website-deploy.yml
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
name: Site Deploy
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
runs-on: ubuntu-latest
|
||||
concurrency:
|
||||
group: website-deploy-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Setup Python Environment
|
||||
uses: ./.github/actions/setup-python
|
||||
|
||||
- name: Setup Node Environment
|
||||
uses: ./.github/actions/setup-node
|
||||
|
||||
- name: Build API Doc
|
||||
uses: ./.github/actions/build-api-doc
|
||||
|
||||
- name: Build Doc
|
||||
run: yarn build
|
||||
|
||||
- name: Get Branch Name
|
||||
run: echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_ENV
|
||||
|
||||
- name: Deploy to Netlify
|
||||
uses: nwtgck/actions-netlify@v1
|
||||
with:
|
||||
publish-dir: "./website/build"
|
||||
production-deploy: true
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
deploy-message: "Deploy ${{ env.BRANCH_NAME }}@${{ github.sha }}"
|
||||
enable-commit-comment: false
|
||||
alias: ${{ env.BRANCH_NAME }}
|
||||
env:
|
||||
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
|
||||
NETLIFY_SITE_ID: ${{ secrets.SITE_ID }}
|
45
.github/workflows/website-preview.yml
vendored
Normal file
45
.github/workflows/website-preview.yml
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
name: Site Deploy(Preview)
|
||||
|
||||
on:
|
||||
pull_request_target:
|
||||
|
||||
jobs:
|
||||
preview:
|
||||
runs-on: ubuntu-latest
|
||||
concurrency:
|
||||
group: pull-request-preview-${{ github.event.number }}
|
||||
cancel-in-progress: true
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
|
||||
- name: Setup Python Environment
|
||||
uses: ./.github/actions/setup-python
|
||||
|
||||
- name: Setup Node Environment
|
||||
uses: ./.github/actions/setup-node
|
||||
|
||||
- name: Build API Doc
|
||||
uses: ./.github/actions/build-api-doc
|
||||
|
||||
- name: Build Doc
|
||||
run: yarn build
|
||||
|
||||
- name: Get Deploy Name
|
||||
run: |
|
||||
echo "DEPLOY_NAME=deploy-preview-${{ github.event.number }}" >> $GITHUB_ENV
|
||||
|
||||
- name: Deploy to Netlify
|
||||
uses: nwtgck/actions-netlify@v1
|
||||
with:
|
||||
publish-dir: "./website/build"
|
||||
production-deploy: false
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
deploy-message: "Deploy ${{ env.DEPLOY_NAME }}@${{ github.sha }}"
|
||||
enable-commit-comment: false
|
||||
alias: ${{ env.DEPLOY_NAME }}
|
||||
env:
|
||||
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
|
||||
NETLIFY_SITE_ID: ${{ secrets.SITE_ID }}
|
439
.gitignore
vendored
439
.gitignore
vendored
@@ -1,5 +1,296 @@
|
||||
# ----- Python -----
|
||||
# ----- Project -----
|
||||
|
||||
.idea
|
||||
.vscode
|
||||
dev
|
||||
docs_build/_build
|
||||
!tests/.env
|
||||
.docusaurus
|
||||
website/docs/api/**/*.md
|
||||
|
||||
# Created by https://www.toptal.com/developers/gitignore/api/python,node,visualstudiocode,jetbrains,macos,windows,linux
|
||||
# Edit at https://www.toptal.com/developers/gitignore?templates=python,node,visualstudiocode,jetbrains,macos,windows,linux
|
||||
|
||||
### JetBrains ###
|
||||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
|
||||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||
|
||||
# User-specific stuff
|
||||
.idea/**/workspace.xml
|
||||
.idea/**/tasks.xml
|
||||
.idea/**/usage.statistics.xml
|
||||
.idea/**/dictionaries
|
||||
.idea/**/shelf
|
||||
|
||||
# AWS User-specific
|
||||
.idea/**/aws.xml
|
||||
|
||||
# Generated files
|
||||
.idea/**/contentModel.xml
|
||||
|
||||
# Sensitive or high-churn files
|
||||
.idea/**/dataSources/
|
||||
.idea/**/dataSources.ids
|
||||
.idea/**/dataSources.local.xml
|
||||
.idea/**/sqlDataSources.xml
|
||||
.idea/**/dynamic.xml
|
||||
.idea/**/uiDesigner.xml
|
||||
.idea/**/dbnavigator.xml
|
||||
|
||||
# Gradle
|
||||
.idea/**/gradle.xml
|
||||
.idea/**/libraries
|
||||
|
||||
# Gradle and Maven with auto-import
|
||||
# When using Gradle or Maven with auto-import, you should exclude module files,
|
||||
# since they will be recreated, and may cause churn. Uncomment if using
|
||||
# auto-import.
|
||||
# .idea/artifacts
|
||||
# .idea/compiler.xml
|
||||
# .idea/jarRepositories.xml
|
||||
# .idea/modules.xml
|
||||
# .idea/*.iml
|
||||
# .idea/modules
|
||||
# *.iml
|
||||
# *.ipr
|
||||
|
||||
# CMake
|
||||
cmake-build-*/
|
||||
|
||||
# Mongo Explorer plugin
|
||||
.idea/**/mongoSettings.xml
|
||||
|
||||
# File-based project format
|
||||
*.iws
|
||||
|
||||
# IntelliJ
|
||||
out/
|
||||
|
||||
# mpeltonen/sbt-idea plugin
|
||||
.idea_modules/
|
||||
|
||||
# JIRA plugin
|
||||
atlassian-ide-plugin.xml
|
||||
|
||||
# Cursive Clojure plugin
|
||||
.idea/replstate.xml
|
||||
|
||||
# Crashlytics plugin (for Android Studio and IntelliJ)
|
||||
com_crashlytics_export_strings.xml
|
||||
crashlytics.properties
|
||||
crashlytics-build.properties
|
||||
fabric.properties
|
||||
|
||||
# Editor-based Rest Client
|
||||
.idea/httpRequests
|
||||
|
||||
# Android studio 3.1+ serialized cache file
|
||||
.idea/caches/build_file_checksums.ser
|
||||
|
||||
### JetBrains Patch ###
|
||||
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
|
||||
|
||||
# *.iml
|
||||
# modules.xml
|
||||
# .idea/misc.xml
|
||||
# *.ipr
|
||||
|
||||
# Sonarlint plugin
|
||||
# https://plugins.jetbrains.com/plugin/7973-sonarlint
|
||||
.idea/**/sonarlint/
|
||||
|
||||
# SonarQube Plugin
|
||||
# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin
|
||||
.idea/**/sonarIssues.xml
|
||||
|
||||
# Markdown Navigator plugin
|
||||
# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced
|
||||
.idea/**/markdown-navigator.xml
|
||||
.idea/**/markdown-navigator-enh.xml
|
||||
.idea/**/markdown-navigator/
|
||||
|
||||
# Cache file creation bug
|
||||
# See https://youtrack.jetbrains.com/issue/JBR-2257
|
||||
.idea/$CACHE_FILE$
|
||||
|
||||
# CodeStream plugin
|
||||
# https://plugins.jetbrains.com/plugin/12206-codestream
|
||||
.idea/codestream.xml
|
||||
|
||||
### Linux ###
|
||||
*~
|
||||
|
||||
# temporary files which can be created if a process still has a handle open of a deleted file
|
||||
.fuse_hidden*
|
||||
|
||||
# KDE directory preferences
|
||||
.directory
|
||||
|
||||
# Linux trash folder which might appear on any partition or disk
|
||||
.Trash-*
|
||||
|
||||
# .nfs files are created when an open file is removed but is still being accessed
|
||||
.nfs*
|
||||
|
||||
### macOS ###
|
||||
# General
|
||||
.DS_Store
|
||||
.AppleDouble
|
||||
.LSOverride
|
||||
|
||||
# Icon must end with two \r
|
||||
Icon
|
||||
|
||||
# Thumbnails
|
||||
._*
|
||||
|
||||
# Files that might appear in the root of a volume
|
||||
.DocumentRevisions-V100
|
||||
.fseventsd
|
||||
.Spotlight-V100
|
||||
.TemporaryItems
|
||||
.Trashes
|
||||
.VolumeIcon.icns
|
||||
.com.apple.timemachine.donotpresent
|
||||
|
||||
# Directories potentially created on remote AFP share
|
||||
.AppleDB
|
||||
.AppleDesktop
|
||||
Network Trash Folder
|
||||
Temporary Items
|
||||
.apdisk
|
||||
|
||||
### Node ###
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
lerna-debug.log*
|
||||
.pnpm-debug.log*
|
||||
|
||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
*.pid.lock
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
*.lcov
|
||||
|
||||
# nyc test coverage
|
||||
.nyc_output
|
||||
|
||||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# Bower dependency directory (https://bower.io/)
|
||||
bower_components
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Dependency directories
|
||||
node_modules/
|
||||
jspm_packages/
|
||||
|
||||
# Snowpack dependency directory (https://snowpack.dev/)
|
||||
web_modules/
|
||||
|
||||
# TypeScript cache
|
||||
*.tsbuildinfo
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
|
||||
# Optional eslint cache
|
||||
.eslintcache
|
||||
|
||||
# Microbundle cache
|
||||
.rpt2_cache/
|
||||
.rts2_cache_cjs/
|
||||
.rts2_cache_es/
|
||||
.rts2_cache_umd/
|
||||
|
||||
# Optional REPL history
|
||||
.node_repl_history
|
||||
|
||||
# Output of 'npm pack'
|
||||
*.tgz
|
||||
|
||||
# Yarn Integrity file
|
||||
.yarn-integrity
|
||||
|
||||
# dotenv environment variables file
|
||||
.env
|
||||
.env.test
|
||||
.env.production
|
||||
|
||||
# parcel-bundler cache (https://parceljs.org/)
|
||||
.cache
|
||||
.parcel-cache
|
||||
|
||||
# Next.js build output
|
||||
.next
|
||||
out
|
||||
|
||||
# Nuxt.js build / generate output
|
||||
.nuxt
|
||||
dist
|
||||
|
||||
# Gatsby files
|
||||
.cache/
|
||||
# Comment in the public line in if your project uses Gatsby and not Next.js
|
||||
# https://nextjs.org/blog/next-9-1#public-directory-support
|
||||
# public
|
||||
|
||||
# vuepress build output
|
||||
.vuepress/dist
|
||||
|
||||
# Serverless directories
|
||||
.serverless/
|
||||
|
||||
# FuseBox cache
|
||||
.fusebox/
|
||||
|
||||
# DynamoDB Local files
|
||||
.dynamodb/
|
||||
|
||||
# TernJS port file
|
||||
.tern-port
|
||||
|
||||
# Stores VSCode versions used for testing VSCode extensions
|
||||
.vscode-test
|
||||
|
||||
# yarn v2
|
||||
.yarn/cache
|
||||
.yarn/unplugged
|
||||
.yarn/build-state.yml
|
||||
.yarn/install-state.gz
|
||||
.pnp.*
|
||||
|
||||
### Node Patch ###
|
||||
# Serverless Webpack directories
|
||||
.webpack/
|
||||
|
||||
# Optional stylelint cache
|
||||
.stylelintcache
|
||||
|
||||
# SvelteKit build / generate output
|
||||
.svelte-kit
|
||||
|
||||
### Python ###
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
@@ -22,6 +313,7 @@ parts/
|
||||
sdist/
|
||||
var/
|
||||
wheels/
|
||||
share/python-wheels/
|
||||
*.egg-info/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
@@ -40,23 +332,25 @@ pip-delete-this-directory.txt
|
||||
# Unit test / coverage reports
|
||||
htmlcov/
|
||||
.tox/
|
||||
.nox/
|
||||
.coverage
|
||||
.coverage.*
|
||||
.cache
|
||||
nosetests.xml
|
||||
coverage.xml
|
||||
*.cover
|
||||
*.py,cover
|
||||
.hypothesis/
|
||||
.pytest_cache/
|
||||
cover/
|
||||
|
||||
# Translations
|
||||
*.mo
|
||||
*.pot
|
||||
|
||||
# Django stuff:
|
||||
*.log
|
||||
local_settings.py
|
||||
db.sqlite3
|
||||
db.sqlite3-journal
|
||||
|
||||
# Flask stuff:
|
||||
instance/
|
||||
@@ -69,22 +363,39 @@ instance/
|
||||
docs/_build/
|
||||
|
||||
# PyBuilder
|
||||
.pybuilder/
|
||||
target/
|
||||
|
||||
# Jupyter Notebook
|
||||
.ipynb_checkpoints
|
||||
|
||||
# pyenv
|
||||
.python-version
|
||||
# IPython
|
||||
profile_default/
|
||||
ipython_config.py
|
||||
|
||||
# celery beat schedule file
|
||||
# pyenv
|
||||
# For a library or package, you might want to ignore these files since the code is
|
||||
# intended to run in multiple environments; otherwise, check them in:
|
||||
# .python-version
|
||||
|
||||
# pipenv
|
||||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
||||
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
||||
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
||||
# install all needed dependencies.
|
||||
#Pipfile.lock
|
||||
|
||||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
|
||||
__pypackages__/
|
||||
|
||||
# Celery stuff
|
||||
celerybeat-schedule
|
||||
celerybeat.pid
|
||||
|
||||
# SageMath parsed files
|
||||
*.sage.py
|
||||
|
||||
# Environments
|
||||
.env
|
||||
.venv
|
||||
env/
|
||||
venv/
|
||||
@@ -104,87 +415,61 @@ venv.bak/
|
||||
|
||||
# mypy
|
||||
.mypy_cache/
|
||||
.dmypy.json
|
||||
dmypy.json
|
||||
|
||||
# ----- Node -----
|
||||
# Pyre type checker
|
||||
.pyre/
|
||||
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
# pytype static type analyzer
|
||||
.pytype/
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
*.pid.lock
|
||||
# Cython debug symbols
|
||||
cython_debug/
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
### VisualStudioCode ###
|
||||
.vscode/*
|
||||
!.vscode/settings.json
|
||||
!.vscode/tasks.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/extensions.json
|
||||
*.code-workspace
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
# Local History for Visual Studio Code
|
||||
.history/
|
||||
|
||||
# nyc test coverage
|
||||
.nyc_output
|
||||
### VisualStudioCode Patch ###
|
||||
# Ignore all local history of files
|
||||
.history
|
||||
.ionide
|
||||
|
||||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
# Support for Project snippet scope
|
||||
!.vscode/*.code-snippets
|
||||
|
||||
# Bower dependency directory (https://bower.io/)
|
||||
bower_components
|
||||
### Windows ###
|
||||
# Windows thumbnail cache files
|
||||
Thumbs.db
|
||||
Thumbs.db:encryptable
|
||||
ehthumbs.db
|
||||
ehthumbs_vista.db
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
# Dump file
|
||||
*.stackdump
|
||||
|
||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
# Folder config file
|
||||
[Dd]esktop.ini
|
||||
|
||||
# Dependency directories
|
||||
node_modules/
|
||||
jspm_packages/
|
||||
# Recycle Bin used on file shares
|
||||
$RECYCLE.BIN/
|
||||
|
||||
# TypeScript v1 declaration files
|
||||
typings/
|
||||
# Windows Installer files
|
||||
*.cab
|
||||
*.msi
|
||||
*.msix
|
||||
*.msm
|
||||
*.msp
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
# Windows shortcuts
|
||||
*.lnk
|
||||
|
||||
# Optional eslint cache
|
||||
.eslintcache
|
||||
|
||||
# Optional REPL history
|
||||
.node_repl_history
|
||||
|
||||
# Output of 'npm pack'
|
||||
*.tgz
|
||||
|
||||
# Yarn Integrity file
|
||||
.yarn-integrity
|
||||
|
||||
# dotenv environment variables file
|
||||
.env
|
||||
|
||||
# parcel-bundler cache (https://parceljs.org/)
|
||||
.cache
|
||||
|
||||
# next.js build output
|
||||
.next
|
||||
|
||||
# nuxt.js build output
|
||||
.nuxt
|
||||
|
||||
# vuepress build output
|
||||
.vuepress/dist
|
||||
|
||||
# Serverless directories
|
||||
.serverless
|
||||
|
||||
# ----- Project -----
|
||||
|
||||
.idea
|
||||
.vscode
|
||||
dev
|
||||
docs_build/_build
|
||||
!tests/.env
|
||||
# End of https://www.toptal.com/developers/gitignore/api/python,node,visualstudiocode,jetbrains,macos,windows,linux
|
||||
|
22
.pre-commit-config.yaml
Normal file
22
.pre-commit-config.yaml
Normal file
@@ -0,0 +1,22 @@
|
||||
ci:
|
||||
autofix_commit_msg: ":rotating_light: auto fix by pre-commit hooks"
|
||||
autofix_prs: true
|
||||
autoupdate_branch: master
|
||||
autoupdate_schedule: monthly
|
||||
autoupdate_commit_msg: ":arrow_up: auto update by pre-commit hooks"
|
||||
repos:
|
||||
- repo: https://github.com/pycqa/isort
|
||||
rev: 5.10.1
|
||||
hooks:
|
||||
- id: isort
|
||||
|
||||
- repo: https://github.com/psf/black
|
||||
rev: 22.3.0
|
||||
hooks:
|
||||
- id: black
|
||||
|
||||
- repo: https://github.com/pre-commit/mirrors-prettier
|
||||
rev: v2.6.2
|
||||
hooks:
|
||||
- id: prettier
|
||||
types_or: [javascript, jsx, ts, tsx, markdown]
|
9
.prettierrc
Normal file
9
.prettierrc
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"tabWidth": 2,
|
||||
"useTabs": false,
|
||||
"endOfLine": "lf",
|
||||
"arrowParens": "always",
|
||||
"singleQuote": false,
|
||||
"trailingComma": "es5",
|
||||
"semi": true
|
||||
}
|
@@ -1,2 +0,0 @@
|
||||
[style]
|
||||
based_on_style = google
|
3
CHANGELOG.md
Normal file
3
CHANGELOG.md
Normal file
@@ -0,0 +1,3 @@
|
||||
# Changelog
|
||||
|
||||
See [changelog.md](./website/src/pages/changelog.md) or <https://v2.nonebot.dev/changelog>
|
86
CODE_OF_CONDUCT.md
Normal file
86
CODE_OF_CONDUCT.md
Normal file
@@ -0,0 +1,86 @@
|
||||
# NoneBot2 贡献者公约
|
||||
|
||||
## 我们的承诺
|
||||
|
||||
身为项目成员、贡献者、负责人,我们保证参与此社区的每个人都不受骚扰,不论其年龄、体型、身体条件、民族、性征、性别认同与表现、经验水平、教育程度、社会地位、国籍、相貌、种族、宗教信仰及性取向如何。
|
||||
|
||||
我们承诺致力于建设开放、友善、多元、包容、健康的社区环境。
|
||||
|
||||
## 我们的准则
|
||||
|
||||
有助于促进本社区积极环境的行为包括但不限于:
|
||||
|
||||
- 与人为善、推己及人
|
||||
- 尊重不同的主张、观点和经历
|
||||
- 积极提出、耐心接受有益批评
|
||||
- 面对过失,承担责任、认真道歉、从中学习
|
||||
- 关注社区共同诉求,而非一己私利
|
||||
|
||||
不当行为包括但不限于:
|
||||
|
||||
- 发布与性有关的言论或图像,以及任何形式的献殷勤或勾引
|
||||
- 挑衅行为、侮辱或贬损的言论、人身及政治攻击
|
||||
- 公开或私下骚扰
|
||||
- 未获明确授权擅自发布他人的资料,如地址、电子邮箱等
|
||||
- 其他有理由认定为违反职业操守的不当行为
|
||||
|
||||
## 落实之义务
|
||||
|
||||
社区负责人有责任诠释什么是“妥当行为”,并据此准则,妥善公正地认定与处置不当、威胁、冒犯及有害的行为。
|
||||
|
||||
社区负责人有权利和义务删除、编辑、拒绝违背本公约的评论(comment)、提交(commit)、代码、维基(wiki)编辑、问题(issue)等贡献。如有必要,需告知采取措施的理由。
|
||||
|
||||
## 适用范围
|
||||
|
||||
此行为标准适用于本社区全部场合,以及在其他场合代表本社区的个人。
|
||||
|
||||
代表本社区的情形包括但不限于:使用官方电子邮件与社交平台、作为指定代表参与在线或线下活动。
|
||||
|
||||
## 贯彻落实
|
||||
|
||||
如遇滥用、骚扰等不当行为,请通过 contact@nonebot.dev 向我们举报。我们将迅速审议并调查全部投诉。
|
||||
|
||||
社区全体负责人有义务保密举报者信息。
|
||||
|
||||
## 指导方针
|
||||
|
||||
社区负责人将依据下列方案判断并处置违纪行为:
|
||||
|
||||
### 一、督促
|
||||
|
||||
**社区影响**:用语不当、举止不符合道德或不受社区欢迎。
|
||||
|
||||
**处理意见**:由社区负责人予以非公开的书面警告,阐明违纪事由、解释举止如何不妥。或要求公开道歉。
|
||||
|
||||
### 二、警告
|
||||
|
||||
**社区影响**:一起或多起事件中的违纪行为。
|
||||
|
||||
**处理意见**:警告继续违纪的后果、违纪者在特定时间内禁止与当事人往来、不得擅自与社区执法者往来,禁令涵盖社区内外、社交网络在内的一切联络。如有违反,可致封禁乃至开除。
|
||||
|
||||
### 三、封禁
|
||||
|
||||
**社区影响**:严重违纪行为,包括屡教不改。
|
||||
|
||||
**处理意见**:违纪者在特定时间内禁止与社区的任何往来或公开联络,禁止任何与当事人公开或私下往来,不得擅自与社区管理者往来。如有违反,可导致开除。
|
||||
|
||||
### 四、开除
|
||||
|
||||
**社区影响**:典型违纪行为,例如屡教不改、骚扰某个人、敌对或贬低某个群体。
|
||||
|
||||
**处理意见**:无限期禁止违纪者与项目社区的一切公开往来。
|
||||
|
||||
## 来源
|
||||
|
||||
本行为标准改编自[参与者公约][homepage]2.0 版,可在此查阅:[https://www.contributor-covenant.org/zh-cn/version/2/0/code_of_conduct.html][v2.0]
|
||||
|
||||
指导方针借鉴自[Mozilla 纪检分级][mozilla coc]。
|
||||
|
||||
此行为标准常见问题请洽:[https://www.contributor-covenant.org/faq][faq]。
|
||||
另有诸译本:[https://www.contributor-covenant.org/translations][translations]。
|
||||
|
||||
[homepage]: https://www.contributor-covenant.org
|
||||
[v2.0]: https://www.contributor-covenant.org/version/2/0/code_of_conduct.html
|
||||
[mozilla coc]: https://github.com/mozilla/diversity
|
||||
[faq]: https://www.contributor-covenant.org/faq
|
||||
[translations]: https://www.contributor-covenant.org/translations
|
78
CONTRIBUTING.md
Normal file
78
CONTRIBUTING.md
Normal file
@@ -0,0 +1,78 @@
|
||||
# NoneBot2 贡献指南
|
||||
|
||||
首先,感谢你愿意为 NoneBot2 贡献自己的一份力量!
|
||||
|
||||
本指南旨在引导你更规范地向 NoneBot2 提交贡献,请务必认真阅读。
|
||||
|
||||
## 提交 Issue
|
||||
|
||||
在提交 Issue 前,我们建议你先查看 [FAQ](https://github.com/nonebot/discussions/discussions/13) 与 [已有的 Issues](https://github.com/nonebot/nonebot2/issues),以防重复提交。
|
||||
|
||||
### 报告问题、故障与漏洞
|
||||
|
||||
NoneBot2 仍然是一个不够稳定的开发中项目,如果你在使用过程中发现问题并确信是由 NoneBot2 引起的,欢迎提交 Issue。
|
||||
|
||||
### 建议功能
|
||||
|
||||
NoneBot2 还未进入正式版,欢迎在 Issue 中提议要加入哪些新功能。
|
||||
|
||||
为了让开发者更好地理解你的意图,请认真描述你所需要的特性,可能的话可以提出你认为可行的解决方案。
|
||||
|
||||
## Pull Request
|
||||
|
||||
NoneBot 使用 [poetry](https://python-poetry.org/) 管理项目依赖,由于 pre-commit 也经其管理,所以在此一并说明。
|
||||
|
||||
下面的命令能在已安装 poetry 和 yarn 的情况下帮你快速配置开发环境。
|
||||
|
||||
```bash
|
||||
# 安装 python 依赖
|
||||
poetry install
|
||||
# 安装 pre-commit git hook
|
||||
pre-commit install
|
||||
# 安装 gitmoji git hook
|
||||
yarn global add gitmoji-cli
|
||||
gitmoji -i
|
||||
```
|
||||
|
||||
### 使用 GitHub Codespaces (Dev Container)
|
||||
|
||||
使用 GitHub Codespaces 选择 `NoneBot2` 项目,然后选择 `.devcontainer/devcontainer.json` 配置即可。
|
||||
|
||||
### Commit 规范
|
||||
|
||||
请确保你的每一个 commit 都能清晰地描述其意图,一个 commit 尽量只有一个意图。
|
||||
|
||||
NoneBot 的 commit message 格式遵循 [gitmoji](https://gitmoji.dev/) 规范,在创建 commit 时请牢记这一点。
|
||||
|
||||
### 撰写文档
|
||||
|
||||
NoneBot2 的文档使用 [docusaurus](https://docusaurus.io/),它有一些 [Markdown 特性](https://docusaurus.io/zh-CN/docs/markdown-features) 可能会帮助到你。
|
||||
|
||||
NoneBot2 文档并没有具体的行文风格规范,但我们建议你尽量写得简单易懂。
|
||||
|
||||
如果你需要在本地预览修改后的文档,可以使用 yarn 安装文档依赖后启动 dev server,如下所示:
|
||||
|
||||
```bash
|
||||
yarn install
|
||||
yarn start
|
||||
```
|
||||
|
||||
### 参与开发
|
||||
|
||||
NoneBot2 的代码风格遵循 [PEP 8](https://www.python.org/dev/peps/pep-0008/) 与 [PEP 484](https://www.python.org/dev/peps/pep-0484/) 规范,请确保你的代码风格和项目已有的代码保持一致,变量命名清晰,有适当的注释与测试代码。
|
||||
|
||||
## 为社区做贡献
|
||||
|
||||
你可以在 NoneBot 商店上架自己的适配器、插件、机器人,具体步骤可参考 [发布插件](https://v2.nonebot.dev/docs/advanced/publish-plugin) 一节。
|
||||
|
||||
我们仅对插件的兼容性进行简单测试,并会在下一个版本发布前对与该版本不兼容的插件作出处理。
|
||||
|
||||
虽然对插件的内容没有严格限制,但我们还是建议在上架插件之前先查看商店有无功能一致的插件。如果你想要上架商店的插件功能与现有插件不完全重合,请在插件说明中补充其与现有插件的区别。
|
||||
|
||||
同时,如果你参考或基于他人发行的代码进行开发,请注意遵守各代码所使用的开源许可协议。
|
||||
|
||||
## Git 工作流
|
||||
|
||||
`master` 分支为 NoneBot 的开发分支,请在任何情况下都不要直接修改 `master` 分支,而是创建一个目标分支为 `nonebot:master` 的 Pull Request 来提交修改。
|
||||
|
||||
如果你不是 NoneBot 团队的成员,可在 fork 本仓库后,向本仓库的 `master` 分支发起 Pull Request,注意遵循先前提到的 commit message 规范创建 commit。我们将在 code review 通过后通过 squash merge 方式将您的贡献合并到主分支。
|
145
README.md
145
README.md
@@ -1,12 +1,16 @@
|
||||
<!-- markdownlint-disable MD033 MD041 -->
|
||||
<p align="center">
|
||||
<a href="https://v2.nonebot.dev/"><img src="https://raw.githubusercontent.com/nonebot/nonebot2/master/docs/.vuepress/public/logo.png" width="200" height="200" alt="nonebot"></a>
|
||||
<a href="https://v2.nonebot.dev/"><img src="https://v2.nonebot.dev/logo.png" width="200" height="200" alt="nonebot"></a>
|
||||
</p>
|
||||
|
||||
<div align="center">
|
||||
|
||||
# NoneBot
|
||||
|
||||
_✨ Python 异步机器人框架 ✨_
|
||||
<!-- prettier-ignore-start -->
|
||||
<!-- markdownlint-disable-next-line MD036 -->
|
||||
_✨ 跨平台 Python 异步机器人框架 ✨_
|
||||
<!-- prettier-ignore-end -->
|
||||
|
||||
</div>
|
||||
|
||||
@@ -17,12 +21,19 @@ _✨ Python 异步机器人框架 ✨_
|
||||
<a href="https://pypi.python.org/pypi/nonebot2">
|
||||
<img src="https://img.shields.io/pypi/v/nonebot2" alt="pypi">
|
||||
</a>
|
||||
<img src="https://img.shields.io/badge/python-3.7+-blue" alt="python"><br />
|
||||
<a href="https://github.com/howmanybots/onebot/blob/master/README.md">
|
||||
<img src="https://img.shields.io/badge/OneBot-v11-black?style=social&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABABAMAAABYR2ztAAAAIVBMVEUAAAAAAAADAwMHBwceHh4UFBQNDQ0ZGRkoKCgvLy8iIiLWSdWYAAAAAXRSTlMAQObYZgAAAQVJREFUSMftlM0RgjAQhV+0ATYK6i1Xb+iMd0qgBEqgBEuwBOxU2QDKsjvojQPvkJ/ZL5sXkgWrFirK4MibYUdE3OR2nEpuKz1/q8CdNxNQgthZCXYVLjyoDQftaKuniHHWRnPh2GCUetR2/9HsMAXyUT4/3UHwtQT2AggSCGKeSAsFnxBIOuAggdh3AKTL7pDuCyABcMb0aQP7aM4AnAbc/wHwA5D2wDHTTe56gIIOUA/4YYV2e1sg713PXdZJAuncdZMAGkAukU9OAn40O849+0ornPwT93rphWF0mgAbauUrEOthlX8Zu7P5A6kZyKCJy75hhw1Mgr9RAUvX7A3csGqZegEdniCx30c3agAAAABJRU5ErkJggg==" alt="cqhttp">
|
||||
<img src="https://img.shields.io/badge/python-3.7.3+-blue" alt="python">
|
||||
<a href="https://codecov.io/gh/nonebot/nonebot2">
|
||||
<img src="https://codecov.io/gh/nonebot/nonebot2/branch/master/graph/badge.svg?token=2P0G0VS7N4" alt="codecov"/>
|
||||
</a>
|
||||
<a href="http://github.com/mamoe/mirai">
|
||||
<img src="https://img.shields.io/badge/mirai-HTTP-lightgrey?style=social">
|
||||
<a href="https://github.com/nonebot/nonebot2/actions/workflows/website-deploy.yml">
|
||||
<img src="https://github.com/nonebot/nonebot2/actions/workflows/website-deploy.yml/badge.svg?branch=master&event=push" alt="site"/>
|
||||
</a>
|
||||
<a href="https://results.pre-commit.ci/latest/github/nonebot/nonebot2/master">
|
||||
<img src="https://results.pre-commit.ci/badge/github/nonebot/nonebot2/master.svg" />
|
||||
</a>
|
||||
<br />
|
||||
<a href="https://onebot.dev/">
|
||||
<img src="https://img.shields.io/badge/OneBot-v11-black?style=social&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABABAMAAABYR2ztAAAAIVBMVEUAAAAAAAADAwMHBwceHh4UFBQNDQ0ZGRkoKCgvLy8iIiLWSdWYAAAAAXRSTlMAQObYZgAAAQVJREFUSMftlM0RgjAQhV+0ATYK6i1Xb+iMd0qgBEqgBEuwBOxU2QDKsjvojQPvkJ/ZL5sXkgWrFirK4MibYUdE3OR2nEpuKz1/q8CdNxNQgthZCXYVLjyoDQftaKuniHHWRnPh2GCUetR2/9HsMAXyUT4/3UHwtQT2AggSCGKeSAsFnxBIOuAggdh3AKTL7pDuCyABcMb0aQP7aM4AnAbc/wHwA5D2wDHTTe56gIIOUA/4YYV2e1sg713PXdZJAuncdZMAGkAukU9OAn40O849+0ornPwT93rphWF0mgAbauUrEOthlX8Zu7P5A6kZyKCJy75hhw1Mgr9RAUvX7A3csGqZegEdniCx30c3agAAAABJRU5ErkJggg==" alt="cqhttp">
|
||||
</a>
|
||||
<a href="https://ding-doc.dingtalk.com/document#/org-dev-guide/elzz1p">
|
||||
<img src="https://img.shields.io/badge/%E9%92%89%E9%92%89-Bot-lightgrey?style=social&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAAAnFBMVEUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD4jUzeAAAAM3RSTlMAQKSRaA+/f0YyFevh29R3cyklIfrlyrGsn41tVUs48c/HqJm9uZdhX1otGwkF9IN8V1CX0Q+IAAABY0lEQVRYw+3V2W7CMBAF0JuNQAhhX9OEfYdu9///rUVWpagE27Ef2gfO+0zGozsKnv6bMGzAhkNytIe5gDdzrwtTCwrbI8x4/NF668NAxgI3Q3UtFi3TyPwNQtPLUUmDd8YfqGLNe4v22XwEYb5zoOuF5baHq2UHtsKe5ivWfGAwrWu2mC34QM0PoCAuqZdOmiwV+5BLyMRtZ7dTSEcs48rzWfzwptMLyzpApka1SJ5FtR4kfCqNIBPEVDmqoqgwUYY5plQOlf6UEjNoOPnuKB6wzDyCrks///TDza8+PnR109WQdxLo8RKWq0PPnuXG0OXKQ6wWLFnCg75uYYbhmMIVVdQ709q33aHbGIj6Duz+2k1HQFX9VwqmY8xYsEJll2ahvhWgsjYLHFRXvIi2Qb0jzMQCzC3FAoydxCma88UCzE3JCWwkjCNYyMUCzHX4DiuTMawEwwhW6hnshPhjZzzJfAH0YacpbmRd7QAAAABJRU5ErkJggg==" alt="ding">
|
||||
@@ -30,61 +41,84 @@ _✨ Python 异步机器人框架 ✨_
|
||||
<a href="https://core.telegram.org/bots/api">
|
||||
<img src="https://img.shields.io/badge/telegram-Bot-lightgrey?style=social&logo=telegram">
|
||||
</a>
|
||||
<a href="https://open.feishu.cn/document/home/index">
|
||||
<img src="https://img.shields.io/badge/%E9%A3%9E%E4%B9%A6-Bot-lightgrey?style=social&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAMAAACahl6sAAAAk1BMVEX///8zMzNJSUlSUlJcXFxtbW0zMzNLS0szMzMzMzNBQUGVlZUzMzM1NTU0NDQzMzMzMzM0NDQ0NDQ0NDQ3NzdDQ0M0NDQ2NjY4ODg9PT0zMzM0NDQ5OTk7OzszMzM0NDQ3NzczMzM0NDQ0NDQ0NDQ0NDQ3Nzc2NjY4ODg2NjY7Ozs0NDQ6Ojo6Ojo3Nzc4ODgzMzNGdMWJAAAAMHRSTlMD6h0TDgr8GNf0KQbvhLT45KKTmm4jwHVJLdLFQzbcjFTgzsq7rl58T2kyqD46Y1riMDRhAAAFr0lEQVR42uzZWXKiUACF4YMyqKAQhyjOc7STmLP/1bVlLukESIJ3sLGKbwFU/Q8HuIBKpVKpVCqVSqVSqVQqlUqlUvmNM10Mcfda/U6TPdw3e9lb8ayLO+bPniYu+amjNcPd8U7PFhML0RE5uCvnaY/5SVt0WFvckcu0vxjiYmDxbu5cl2mn9UVHRMa4B2LaP3RYKD1vL6adccRFLSLL/izxxbRz7UXHimdLlFdq2mlvnztYRznZh96cP3G/dkxQRrOnR5c/c5eiQ+S2UTbe/sHir9zD1w6+okz8aXvMItyRqE46ApSHmHYRYdLRoPCMcrAP3TkLC6fpDp5QAn/EtItqij3UG/zgQZH5aWc7ZqJjzA9jKFGf9ppXC3I6uMB/Mzh2mpQQ/Mnp4BSy1Kctx4pFx5qfhA4kqE87pCyrldfBDm6sLqat2mGnttXHDfkvYtryooHo2PCrFm5lcNw1qWr1XUeEm7BH3QYVRJNGcOmoietNmNKDWeKFnCo6b3Wc1drW/NsOLpFRqmmT4xgfPFw42Q7XhkFi2kq2DtKcR2Y8wpTacRdQ3aZYB59ggiOmrS6sFevgDNr9GW6pzRAZdsQsC3rV3x4i6uQha8+sB2h9am9c6rVBDj9ixr5k007rIs+CGV65pl3wXjRi2hrKYjFtM/rI02JaW3XaPYtGtZHHY9qL0lN7QuO2yBMzpenLTvtkZNos+AY1ZcpObtoLtWmrj6TNlCOuJqZ9M3PkaDBlIBHCmwpHyHpjSgMS2ryhcIqsmsWULmR0eTPhK7LsMdMOKHdJM+nw8E+8ZoYDOT3eRDDDuz6HNt7VeszaQtYDJch+38WRZ51TDO+0Y54hylzy0XHib2JI83c0zIoLd1hAeUus1jenQe2HQ79Dg6wB3i1d/uoNpS2JrulgHWqcRxqySjoObrFjfUlLVrVrOtiGMmdCA+ZJx8hlEa9QZ2+oXcNLOkIWEUAHe22sYxqykGdoUV//5w6eoKlkTI3Gdbx7CVmQB10lDWqzSTpemyyoAW28ubYO++oOLqBPbUUtJknHrMnCRihdyaOTdAQsLHSgtSTS2BEHLK4DvQYWFW2lOtiHZi3Fko6fXCjgNVooV0nHl7tMBP1aAaXtJDvYgwGxdMmzLzu1JUyYNSU7IAwiiZ8OJrxKlTzI38QnMORFoqSn8Fh9gikvIa/UVejgDMZMQ9mOOa8WwKCRyysslF6hn2HSwZX4+ew1KGEPCSZKhoqHMw9mLd1rO8aUMYZpexbRV/2AsYBxy7/t3NtuglAQheFR6wEPVEQtaq1WxQNqnfd/urY08QJFYHZS15D9vcHckMzOz/QWA9/3jqHrbmbr1bT10a90ncQcoiclgKY/Vq81q6P2JJqfI+NHPqdDSMRzsEtIXmYGcQcQk2fwKgHxTCIVJGMWwTu6sWGxPSFx+QpkOfz3QcYEJWQhtGsbR5aKCIrHInjXNsSDeITFZ6ELYZEMAnltY8AyawKz4KJAr21IBzkRmB6LOIRGOEhIaHYsciA0uxIshwa/DLQIzrAEy2HswBIBwck9yNOvbWT4YgHEU4zbEiyHsQsXhnmKccmxp2cbxvb8CyDbMBXwD4hsw1BQguUw9s4Mk20YOTFQtmHiDJVtGJhjZRtyEVi2ITbhnLBOMd5qOvqXwz9RFy3bkJpU0LINeTCsJdvIztHVZhsJo77SbOPG6FNltpFQqMxsE7hmS+9ymJxE7XKYUGupyzZS1Kbaso00tbWybONBTadyObyjPlaVbTycRFO28Uh9oyjbEJ/E2JImnVDXy1y6zpHvW5E2npJsI5unI9vIwVe3HKYZaMg2clkoyDby6Wl5mcv0Bp9t5DVEzzZyG4JnG/kdsLONArbQ2UYRlwZwtlHIsoGbbRSdRNtymGbf0LYcpgleQbMNwdUCbcthmrP2j++VjqdSy7Isy7Isy4LxDTcBnqEPd5jdAAAAAElFTkSuQmCC" alt="feishu">
|
||||
</a>
|
||||
<a href="https://bot.q.qq.com/wiki/">
|
||||
<img src="https://img.shields.io/badge/QQ%E9%A2%91%E9%81%93-Bot-lightgrey?style=social&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAAC+lBMVEUAAAApRHRAbvYyVI4dMlsNGjcvTH5anN0/a5xdo+Vdpvpms/dMfvdcoPZjr/hJfu5krvA9Z+8/a+M9adxQjNdYmdVAbdU4XtRRjcxFd8wyVbM+aZowUJwpRJlZneRIevU5YORWl+1fqOZVle9ZnOpEdOk/aelepus/a+NQiuVKgeQ6YeRQi905X91EdtxAbthZnNlRjdk5YdpQjuhLgehhquc7Y+c6Y8k3XctWlcs0V8tJfMMzVsM9aMJVksdHebVKgLQyVJknP5REdKD///9irv9Ccf5EdP9GfP9jsf7+/f5SkP9mtf9GeP/+/vxJfv5Ukv9Ng/9boP9Gef1ls/9Ulf9Wl//+//5KgP9Nhv9dpP9Oiv9Tk/5Abv9Lg/9Fdv9NiP7///5Qj/7+/fxfpv9Nh/xhq/9QjP9Wm/79//1co/9ir/5fqf5bov9Qi//8/f1XmP1Wl/1ksv/7/v38/vv9/vlgqv9Znf9IfPzZ5fdeqP9nt/5anv5Xmf9Uk/1anvxpuf73/P34+/tot/9hrf1anvpMhvpSjv1pt/9ZnP1aofxTkfxNivza5/dOhPf+//1Ri/z+//vz+fvw9/tIf/v6/fpdofrI2PlYmfnF3Pe0y/Pm7/jW4/e0zvRapPxXlfpTkvpGevri7ffS3vVMiP5XnvxXnPtQivn3/Ph0r/dgpPZ1qfXi6/S9z/NYmf/z+v5Yn/7L2vlfmflUk/hXi/dRgvSw0fGnu+1dqP3t9Pthq/vA1vjc6vfU4vd4sfdepPdsn/dam/fU5fawzfRjjfRhi/NJhP0/a/y80fhTjfhrrfeXvvZuk/WyyPR9rvSqz/OcwfOmv/OSuPO0yfKguPCWr/BPi+9MheRKgv1gsPzq9PpgpvpVjvrN2/jG1vdonvbA0PSrx/OtxPCkxPDp8PvN4ftnuPuCufloqPiex/a3z/WPuvWQqvR2mfRplvReivSOqvOKufKGufKCrPKBoPJzlfFjr+88Ze6ftux8nOxxq/SGr/CFr/Cvx+3R19+QAAAARHRSTlMAEP4ZEwUEvC3S/v7+/Pv08PDXvJqampqSgEtJLS3f/Pz4+O/n5+bl4tTU1Lq6ure2trGdnZ2dlI6Afl5eXldMS0lJLRAR2gcAAAewSURBVFjDlZcFfBJRHMdvdnd3d3cn1qk3h4Et7EQ965h3KKgTQUGdOgYMHII6a5vO2d3d3d3d3X4+/t974A51xvfDu7vfP348HsdxR6VAulaN6lUu8SHVgQOpPpSoXK9Rq3TUf5CmSdWcB/oFcCBn1SZp/rG9aP6c/X5LzvxF/6W9Vqq2KZKq1t8sgvKT9pQt8gf9qb9QOVLWjux+K8oVSrE9bYNU7f6BVA3SpjD93O3+kdy//Ripcw34QefOnaViwM8iV+rf9Ffo7Kdr166du87vSgQGZGcIJocq/OIQlAv1EbAHDL/0hXzOhFxBP61f7vbJdJ0PFfN1RBB0MIPAUO7Alazvz+l0WY4+Pbthw4az66QG63Do6dEsuh+W9QO+//moVRet071L8phomUzBGPcGBwe3hxdmn5FVyGS0yZP0TodpHzy/kGQBygYjonUvbtpFraDwGUjYZ2JRVNSKK26+0EXjWNnkZciH26OjPy3gOZ5nVVCq+p0BzfK8wC/4FB2MLfL5+4sU7wkER7/dhN6aYxia0zKmvT0l7DUxHE1zHMcoVLJNb6ODUbB4EYpQHddcPHpXK5OpWNHp8CxbtmzmPqnBvpnLAIeTQdPT3j16EUer+yaQpT8i8pqAVi9h4cu1kZGR69bt7y9h/7p1EFz7cmEC+iTiwkgczUKmkC8ECkIs54wiI4j2j5EXQwj9QyCBNgCRIZbIj3ZRYET+nCVkP4TwKqTJHoJTXlbFscZzlv6WXr1CkpGKXhb0PozVynoj1SiTHV3lmvYC1JZnCQzNOG9a1BY1aAlKqbBYLEm8jWYSnpGypmBQTQ0sUp9iVCqr/bl60SK1UqlchIIzYCABB/BCIRR/breqVMwp9SIlUA2u39mVCPUWBlZQHz8DiT591t5euPD2WiUR6rXfiAKhnBHvhXVkrs9AGWX2dFTLGX0AZfxCTiaTHYwChTjl1LL8HZ+YccvJa52nfCL+IHyT3Lb4kVi1pAqOBPqMjPfSYHBmZBQSI6Nm0TTDXicCFCsy9HWfiDqGDPTxIzEFqTqDMVF6BTIYHEXUKhDMrMGEKddstIr2qajQYzT6sIeIrENVCsVc1VuRQeiU0FAYU4gBEkhfY5CBT4TCDJABkZWoCx0xxGB26BSspqyiFSowwAKUSNvoWUQQA1p/NRTLC9R5El+jZ5BBR9Qzffr0VbTICrNiQSC9yskKrN9g+hkoVOljp2N5njrUBdExlhj07UI4qGVZ7ePpREw/KLJa5xxfqu9sBRjMjCXJQ5SvaI3ehg0mELlz94oVu3ei3IQJE2J3eu0rdt/AAvAZoEMwp2L7Iias0aOlAYO+hHmrV89De5KVqAndicEaUhlLremOCJuHDeZ0D+v+V4jBPFK5hjrfA+E3CAvr8RfCwvwGWJ6nLmgQYTF6Gr4cZACCELN6Z+Kbr1/eJO5cHaOBBAyNpkeYZg86kWbGgAAuUBXDw8OXh4fH6BlkoNGgY43mxumkbR6HySiIomBKcHi2JZ2+odHELIdSzR5YbevMmHBMRar2EEyMXgXxOcvD4Viza88mnuNYhmNpDMMwIr9pzy4NJMOXIwMGDHBfbaog3k+LQzNgHscNmTZkSNwut0mgaQH6OK0NtmDG8yb3rrghY8YMiZuD5jozbhoSQwpShaeNAaYt3obWYIt58TQkzKe3JYisKCoUNKegwUFI8J7257agSi8SIAtT6UqPRxjc+De2axocLzYbzObjSVtX8Dyj1TICv2Jr0nEzsHLMmPFxZvS75d2GMSDGl4bbxypyuXy8wXBLUMloe6JBvtJgGB8BjitdiUfmuO/dc885kuhaaRg/fiVUwUi00zKVcAuqoLEKRVGN5UCE4bhJRdPiFrPZJZcQESEPwOUybxFpWmU6bsCZxuiyXnKEfIQ8wjWTZxSs6WRExNwRfiCByn4IOSRPwr+kit/qikChkvjmNc/Qob2HznWd5G1WgXbc2TF36A9GkI0fqLrj4AWrjT/pmju0d++heShEhqy9EUt3CwKso9F75OHSHTuWLp3bW8LcpSj28IjXCCsoCLuv4GjWDBSm5sCBSG6/zMNJDldjh2fBggVbEwdicOXAz1sh5HHwrBbON3bTdpKoCc1kCrg00xMHzICzwanD0VrTkoESlpi06L/dZuMUMoXjSaaNKIgmQMgzFti48corj1aEk88KJwpjXDJWwhIjSysUVi0HJ4bn1ZWNG1EwT/ItTpnhhCVuO8sKCjDgjNuHSwAD9M8lsJzdvcQXKyO502ueaTQwaNDmza/dl50+g9EStsMMwMB52f168+bho4dDKFNzSkKBQX4mH37w6MT69etPHCaacBiHHj04PHnQoNGkrkDgjWb6NslMJrSRhjZPHhQYSp+WCiCoWHJu2LBhl2BIDSASGMoY9MvNdjFfKUA2RCRHpQbFfne7nrHDqA4dOozCG/Qie6mAQURG6P+VoPS4DED7wONAkT4ohUeeAtm6/QPZCqSlUqJF+U6dOnVDA23Q/ldRvsUfH/vyZuv0R7LlDaL+TOsamSdNmjTuBwEic43W1N/JkDfH1EmIqT78xznyZvjXh+9m6XNM/Ikc6Zulof6DdIUb1s1Y6n3m+/czvy+VsW7Dwik9/n8HzjZEy9x05tIAAAAASUVORK5CYII=" alt="QQ频道">
|
||||
</a>
|
||||
<br />
|
||||
<a href="https://jq.qq.com/?_wv=1027&k=5OFifDh">
|
||||
<img src="https://img.shields.io/badge/qq%E7%BE%A4-768887710-orange?style=flat-square" alt="QQ Chat">
|
||||
<img src="https://img.shields.io/badge/QQ%E7%BE%A4-768887710-orange?style=flat-square" alt="QQ Chat Group">
|
||||
</a>
|
||||
<a href="https://t.me/cqhttp">
|
||||
<img src="https://img.shields.io/badge/telegram-chat-blue?style=flat-square" alt="Telegram Chat">
|
||||
<a href="https://qun.qq.com/qqweb/qunpro/share?_wv=3&_wwv=128&appChannel=share&inviteCode=7b4a3&appChannel=share&businessType=9&from=246610&biz=ka">
|
||||
<img src="https://img.shields.io/badge/QQ%E9%A2%91%E9%81%93-NoneBot-5492ff?style=flat-square" alt="QQ Channel">
|
||||
</a>
|
||||
<a href="https://jq.qq.com/?_wv=1027&k=5Nl0zhE">
|
||||
<img src="https://img.shields.io/badge/%E7%89%88%E6%9C%AC%E5%8F%91%E5%B8%83%E7%BE%A4-218529254-green?style=flat-square" alt="QQ Release">
|
||||
<a href="https://t.me/botuniverse">
|
||||
<img src="https://img.shields.io/badge/telegram-botuniverse-blue?style=flat-square" alt="Telegram Channel">
|
||||
</a>
|
||||
<a href="https://t.me/cqhttp_release">
|
||||
<img src="https://img.shields.io/badge/%E7%89%88%E6%9C%AC%E5%8F%91%E5%B8%83%E9%A2%91%E9%81%93-join-green?style=flat-square" alt="Telegram Release">
|
||||
<a href="https://discord.gg/VKtE6Gdc4h">
|
||||
<img src="https://discordapp.com/api/guilds/847819937858584596/widget.png?style=shield" alt="Discord Server">
|
||||
</a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://v2.nonebot.dev/">文档</a>
|
||||
·
|
||||
<a href="https://v2.nonebot.dev/guide/installation.html">安装</a>
|
||||
<a href="https://v2.nonebot.dev/docs/start/installation">安装</a>
|
||||
·
|
||||
<a href="https://v2.nonebot.dev/guide/getting-started.html">开始使用</a>
|
||||
<a href="https://v2.nonebot.dev/docs/tutorial/create-project">开始使用</a>
|
||||
·
|
||||
<a href="#插件">文档打不开?</a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://asciinema.org/a/464654">
|
||||
<img src="https://v2.nonebot.dev/img/setup.svg">
|
||||
</a>
|
||||
</p>
|
||||
|
||||
## 简介
|
||||
|
||||
NoneBot2 是一个可扩展的 Python 异步机器人框架,它会对机器人收到的事件进行解析和处理,并以插件化的形式,按优先级分发给事件所对应的事件响应器,来完成具体的功能。
|
||||
|
||||
除了起到解析事件的作用,NoneBot 还为插件提供了大量实用的预设操作和权限控制机制。对于命令处理,它更是提供了完善且易用的会话机制和内部调用机制,以分别适应命令的连续交互和插件内部功能复用等需求。
|
||||
|
||||
得益于 Python 的 [asyncio](https://docs.python.org/3/library/asyncio.html) 机制,NoneBot 处理事件的吞吐量有了很大的保障,再配合 WebSocket 通信方式(也是最建议的通信方式),NoneBot 的性能可以达到 HTTP 通信方式的两倍以上,相较于传统同步 I/O 的 HTTP 通信,更是有质的飞跃。
|
||||
NoneBot2 是一个现代、跨平台、可扩展的 Python 聊天机器人框架,它基于 Python 的类型注解和异步特性,能够为你的需求实现提供便捷灵活的支持。
|
||||
|
||||
## 特色
|
||||
|
||||
NoneBot2 的驱动框架 `Driver` 以及通信协议 `Adapter` 均可**自定义**,并且可以作为插件进行**替换/添加**!
|
||||
- 异步优先:基于 Python 的异步特性,即使是~~非常~~大量的消息,也能吞吐自如
|
||||
- 易于开发:配合 NB-CLI 脚手架,代码编写上手简单,没有过多的冗余代码,可以让开发者专注于业务逻辑
|
||||
- 生而可靠:100% 类型注解覆盖,配合编辑器的类型推导功能,能将绝大多数的 Bug 杜绝在编辑器中 ([编辑器支持](https://v2.nonebot.dev/docs/start/editor-support))
|
||||
- 社区丰富:社区用户众多,直接和间接用户超过十万人,每天都有大量的活跃用户 ([社区资源](#社区资源))
|
||||
- 海纳百川:一个框架,支持多个聊天软件平台,可自定义通信协议
|
||||
- [OneBot 协议](https://onebot.dev/) (QQ 等)
|
||||
- [钉钉](https://ding-doc.dingtalk.com/document#/org-dev-guide/elzz1p)
|
||||
- [Telegram](https://core.telegram.org/bots/api)
|
||||
- [飞书](https://open.feishu.cn/document/home/index)
|
||||
- [QQ 频道](https://bot.q.qq.com/wiki/)
|
||||
- 坚实后盾:支持多种 web 框架,可自定义替换
|
||||
- [FastAPI](https://fastapi.tiangolo.com/)
|
||||
- [Quart](https://pgjones.gitlab.io/quart/) (异步 Flask)
|
||||
- [aiohttp](https://docs.aiohttp.org/en/stable/)
|
||||
- [httpx](https://www.python-httpx.org/)
|
||||
- [websockets](https://websockets.readthedocs.io/en/stable/)
|
||||
|
||||
目前 NoneBot2 内置的驱动框架:
|
||||
更多:[概览](https://v2.nonebot.dev/docs/)
|
||||
|
||||
- [FastAPI](https://fastapi.tiangolo.com/)
|
||||
## 什么不是 NoneBot2
|
||||
|
||||
目前 NoneBot2 内置的协议适配:
|
||||
NoneBot2 不是某个平台或者协议的具体实现,它只负责和已有协议适配器通信,并处理接收到的事件。所以,“NoneBot 有 blabla 平台的 blabla 功能吗?”这种问题是与 NoneBot2 无关的。请在相应平台的功能文档中确认,或与相应平台的协议适配开发者联系。
|
||||
|
||||
- [OneBot(CQHTTP) 协议](https://github.com/howmanybots/onebot/blob/master/README.md) (QQ 等)
|
||||
- [Mirai-API-HTTP 协议](https://github.com/project-mirai/mirai-api-http)
|
||||
- [钉钉](https://ding-doc.dingtalk.com/document#/org-dev-guide/elzz1p) _开发中_
|
||||
- [Telegram](https://core.telegram.org/bots/api) _计划中_
|
||||
NoneBot2 不是 NoneBot1 的替代品。事实上,它们都在被积极的维护着。但是,如果你想尝试一些新功能,或者想要支持更多的平台,可以考虑使用 NoneBot2。
|
||||
|
||||
> ~~NoneBot2 和 NoneBot1 的区别,就像是 VisualStudio Code 和 VisualStudio 一样~~
|
||||
|
||||
## 即刻开始
|
||||
|
||||
~~完整~~文档可以在 [这里](https://v2.nonebot.dev/) 查看。
|
||||
|
||||
懒得看文档?下面是快速安装指南:~~这是坏文明~~
|
||||
懒得看文档?下面是快速安装指南:
|
||||
|
||||
1. (**强烈建议**)使用你喜欢的 Python 环境管理工具创建新的虚拟环境。
|
||||
|
||||
1. (可选)使用你喜欢的 Python 环境管理工具创建新的虚拟环境。
|
||||
2. 使用 `pip` (或其他) 安装 NoneBot 脚手架。
|
||||
|
||||
```bash
|
||||
@@ -97,26 +131,57 @@ NoneBot2 的驱动框架 `Driver` 以及通信协议 `Adapter` 均可**自定义
|
||||
nb create
|
||||
```
|
||||
|
||||
## 插件
|
||||
## 社区资源
|
||||
|
||||
### 常见问题
|
||||
|
||||
- [常见问题解答(FAQ)](https://faq.nonebot.dev/)
|
||||
- [论坛(Discussion)](https://discussions.nonebot.dev/)
|
||||
|
||||
### 教程/实际项目/经验分享
|
||||
|
||||
- [awesome-nonebot](https://github.com/nonebot/awesome-nonebot)
|
||||
|
||||
### 插件
|
||||
|
||||
此外,NoneBot2 还有丰富的官方以及第三方现成的插件供大家使用:
|
||||
|
||||
- [NoneBot-Plugin-Docs](https://github.com/nonebot/nonebot2/tree/master/packages/nonebot-plugin-docs):离线文档至本地使用(别再说文档打不开了!)
|
||||
- [NoneBot-Plugin-Docs](https://github.com/nonebot/nonebot2/tree/master/packages/nonebot-plugin-docs):离线文档至本地项目使用 (别再说文档打不开了!)
|
||||
|
||||
在项目目录下执行:
|
||||
|
||||
```bash
|
||||
nb plugin install nonebot_plugin_docs
|
||||
```
|
||||
|
||||
- 其他插件请查看 [插件商店](https://v2.nonebot.dev/plugin-store.html)
|
||||
或者尝试以下镜像:
|
||||
|
||||
## 贡献
|
||||
- [文档镜像(中国境内)](https://nb2.baka.icu)
|
||||
- [文档镜像(Vercel)](https://nonebot2-vercel-mirror.vercel.app)
|
||||
|
||||
如果你在使用过程中发现任何问题,可以 [提交 issue](https://github.com/nonebot/nonebot2/issues/new) 或自行 fork 修改后提交 pull request。
|
||||
|
||||
如果你要提交 pull request,请确保你的代码风格和项目已有的代码保持一致,遵循 [PEP 8](https://www.python.org/dev/peps/pep-0008/),变量命名清晰,有适当的注释。
|
||||
- 其他插件请查看 [商店](https://v2.nonebot.dev/store)
|
||||
|
||||
## 许可证
|
||||
|
||||
`NoneBot` 采用 `MIT` 协议开源,协议文件参考 [LICENSE](./LICENSE)。
|
||||
`NoneBot` 采用 `MIT` 许可证进行开源
|
||||
|
||||
特别的,由于 `mirai` 使用 `AGPLv3` 协议并要求使用 `mirai` 的软件同样以 `AGPLv3` 协议开源,本项目 `mirai` 适配器部分(即 [`nonebot/adapters/mirai/`](./nonebot/adapters/mirai/) 目录)以 `AGPLv3` 协议开源,协议文件参考 [LICENSE](./nonebot/adapters/mirai/LICENSE)。
|
||||
```text
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
```
|
||||
|
||||
## 贡献
|
||||
|
||||
请参考 [贡献指南](./CONTRIBUTING.md)
|
||||
|
||||
### 鸣谢
|
||||
|
||||
感谢以下开发者对 NoneBot2 作出的贡献:
|
||||
|
||||
<a href="https://github.com/nonebot/nonebot2/graphs/contributors">
|
||||
<img src="https://contrib.rocks/image?repo=nonebot/nonebot2" />
|
||||
</a>
|
||||
|
@@ -1,15 +0,0 @@
|
||||
---
|
||||
home: true
|
||||
heroImage: /logo.png
|
||||
tagline: An asynchronous QQ bot framework.
|
||||
actionText: 开始使用
|
||||
actionLink: guide/
|
||||
features:
|
||||
- title: 简洁
|
||||
details: 提供极其简洁易懂的 API,使你可以毫无压力地开始验证你的绝佳创意,只需编写最少量的代码,即可实现丰富的功能。
|
||||
- title: 易于扩展
|
||||
details: 精心设计的消息处理流程使得你可以很方便地将原型扩充为具有大量实用功能的完整聊天机器人,并持续保证扩展性。
|
||||
- title: 高性能
|
||||
details: 采用异步 I/O,利用 WebSocket 进行通信,以获得极高的性能;同时,支持使用多账号同时接入,减少业务宕机的可能。
|
||||
footer: MIT Licensed | Copyright © 2018 - 2020 NoneBot Team
|
||||
---
|
@@ -1,7 +0,0 @@
|
||||
# 深入
|
||||
|
||||
## 它如何工作?
|
||||
|
||||
<!-- TODO: how to work -->
|
||||
|
||||
~~未填坑~~
|
@@ -1 +0,0 @@
|
||||
# 跨插件访问
|
@@ -1 +0,0 @@
|
||||
# 权限控制
|
@@ -1 +0,0 @@
|
||||
# 发布插件
|
@@ -1 +0,0 @@
|
||||
# 运行时插槽
|
@@ -1 +0,0 @@
|
||||
# 定时任务
|
@@ -1,52 +0,0 @@
|
||||
# NoneBot Api Reference
|
||||
|
||||
|
||||
* **模块索引**
|
||||
|
||||
|
||||
* [nonebot](nonebot.html)
|
||||
|
||||
|
||||
* [nonebot.config](config.html)
|
||||
|
||||
|
||||
* [nonebot.plugin](plugin.html)
|
||||
|
||||
|
||||
* [nonebot.message](message.html)
|
||||
|
||||
|
||||
* [nonebot.matcher](matcher.html)
|
||||
|
||||
|
||||
* [nonebot.rule](rule.html)
|
||||
|
||||
|
||||
* [nonebot.permission](permission.html)
|
||||
|
||||
|
||||
* [nonebot.log](log.html)
|
||||
|
||||
|
||||
* [nonebot.utils](utils.html)
|
||||
|
||||
|
||||
* [nonebot.typing](typing.html)
|
||||
|
||||
|
||||
* [nonebot.exception](exception.html)
|
||||
|
||||
|
||||
* [nonebot.drivers](drivers/)
|
||||
|
||||
|
||||
* [nonebot.drivers.fastapi](drivers/fastapi.html)
|
||||
|
||||
|
||||
* [nonebot.adapters](adapters/)
|
||||
|
||||
|
||||
* [nonebot.adapters.cqhttp](adapters/cqhttp.html)
|
||||
|
||||
|
||||
* [nonebot.adapters.ding](adapters/ding.html)
|
@@ -1,362 +0,0 @@
|
||||
---
|
||||
contentSidebar: true
|
||||
sidebarDepth: 0
|
||||
---
|
||||
|
||||
# NoneBot.adapters 模块
|
||||
|
||||
## 协议适配基类
|
||||
|
||||
各协议请继承以下基类,并使用 `driver.register_adapter` 注册适配器
|
||||
|
||||
|
||||
## _class_ `BaseBot`
|
||||
|
||||
基类:`abc.ABC`
|
||||
|
||||
Bot 基类。用于处理上报消息,并提供 API 调用接口。
|
||||
|
||||
|
||||
### _abstract_ `__init__(driver, connection_type, config, self_id, *, websocket=None)`
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `driver: Driver`: Driver 对象
|
||||
|
||||
|
||||
* `connection_type: str`: http 或者 websocket
|
||||
|
||||
|
||||
* `config: Config`: Config 对象
|
||||
|
||||
|
||||
* `self_id: str`: 机器人 ID
|
||||
|
||||
|
||||
* `websocket: Optional[WebSocket]`: Websocket 连接对象
|
||||
|
||||
|
||||
|
||||
### `driver`
|
||||
|
||||
Driver 对象
|
||||
|
||||
|
||||
### `connection_type`
|
||||
|
||||
连接类型
|
||||
|
||||
|
||||
### `config`
|
||||
|
||||
Config 配置对象
|
||||
|
||||
|
||||
### `self_id`
|
||||
|
||||
机器人 ID
|
||||
|
||||
|
||||
### `websocket`
|
||||
|
||||
Websocket 连接对象
|
||||
|
||||
|
||||
### _abstract property_ `type`
|
||||
|
||||
Adapter 类型
|
||||
|
||||
|
||||
### _abstract async classmethod_ `check_permission(driver, connection_type, headers, body)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
检查连接请求是否合法的函数,如果合法则返回当前连接 `唯一标识符`,通常为机器人 ID;如果不合法则抛出 `RequestDenied` 异常。
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `driver: Driver`: Driver 对象
|
||||
|
||||
|
||||
* `connection_type: str`: 连接类型
|
||||
|
||||
|
||||
* `headers: dict`: 请求头
|
||||
|
||||
|
||||
* `body: Optional[dict]`: 请求数据,WebSocket 连接该部分为空
|
||||
|
||||
|
||||
|
||||
* **返回**
|
||||
|
||||
|
||||
* `str`: 连接唯一标识符
|
||||
|
||||
|
||||
|
||||
* **异常**
|
||||
|
||||
|
||||
* `RequestDenied`: 请求非法
|
||||
|
||||
|
||||
|
||||
### _abstract async_ `handle_message(message)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
处理上报消息的函数,转换为 `Event` 事件后调用 `nonebot.message.handle_event` 进一步处理事件。
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `message: dict`: 收到的上报消息
|
||||
|
||||
|
||||
|
||||
### _abstract async_ `call_api(api, **data)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
调用机器人 API 接口,可以通过该函数或直接通过 bot 属性进行调用
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `api: str`: API 名称
|
||||
|
||||
|
||||
* `**data`: API 数据
|
||||
|
||||
|
||||
|
||||
* **示例**
|
||||
|
||||
|
||||
```python
|
||||
await bot.call_api("send_msg", message="hello world"})
|
||||
await bot.send_msg(message="hello world")
|
||||
```
|
||||
|
||||
|
||||
### _abstract async_ `send(event, message, **kwargs)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
调用机器人基础发送消息接口
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `event: Event`: 上报事件
|
||||
|
||||
|
||||
* `message: Union[str, Message, MessageSegment]`: 要发送的消息
|
||||
|
||||
|
||||
* `**kwargs`
|
||||
|
||||
|
||||
|
||||
## _class_ `BaseEvent`
|
||||
|
||||
基类:`abc.ABC`, `typing.Generic`
|
||||
|
||||
Event 基类。提供上报信息的关键信息,其余信息可从原始上报消息获取。
|
||||
|
||||
|
||||
### `__init__(raw_event)`
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `raw_event: Union[dict, T]`: 原始上报消息
|
||||
|
||||
|
||||
|
||||
### _property_ `raw_event`
|
||||
|
||||
原始上报消息
|
||||
|
||||
|
||||
### _abstract property_ `id`
|
||||
|
||||
事件 ID
|
||||
|
||||
|
||||
### _abstract property_ `name`
|
||||
|
||||
事件名称
|
||||
|
||||
|
||||
### _abstract property_ `self_id`
|
||||
|
||||
机器人 ID
|
||||
|
||||
|
||||
### _abstract property_ `time`
|
||||
|
||||
事件发生时间
|
||||
|
||||
|
||||
### _abstract property_ `type`
|
||||
|
||||
事件主类型
|
||||
|
||||
|
||||
### _abstract property_ `detail_type`
|
||||
|
||||
事件详细类型
|
||||
|
||||
|
||||
### _abstract property_ `sub_type`
|
||||
|
||||
事件子类型
|
||||
|
||||
|
||||
### _abstract property_ `user_id`
|
||||
|
||||
触发事件的主体 ID
|
||||
|
||||
|
||||
### _abstract property_ `group_id`
|
||||
|
||||
触发事件的主体群 ID
|
||||
|
||||
|
||||
### _abstract property_ `to_me`
|
||||
|
||||
事件是否为发送给机器人的消息
|
||||
|
||||
|
||||
### _abstract property_ `message`
|
||||
|
||||
消息内容
|
||||
|
||||
|
||||
### _abstract property_ `reply`
|
||||
|
||||
回复的消息
|
||||
|
||||
|
||||
### _abstract property_ `raw_message`
|
||||
|
||||
原始消息
|
||||
|
||||
|
||||
### _abstract property_ `plain_text`
|
||||
|
||||
纯文本消息
|
||||
|
||||
|
||||
### _abstract property_ `sender`
|
||||
|
||||
消息发送者信息
|
||||
|
||||
|
||||
## _class_ `BaseMessageSegment`
|
||||
|
||||
基类:`abc.ABC`
|
||||
|
||||
消息段基类
|
||||
|
||||
|
||||
### `type`
|
||||
|
||||
|
||||
* 类型: `str`
|
||||
|
||||
|
||||
* 说明: 消息段类型
|
||||
|
||||
|
||||
### `data`
|
||||
|
||||
|
||||
* 类型: `Dict[str, Union[str, list]]`
|
||||
|
||||
|
||||
* 说明: 消息段数据
|
||||
|
||||
|
||||
## _class_ `BaseMessage`
|
||||
|
||||
基类:`list`, `abc.ABC`
|
||||
|
||||
消息数组
|
||||
|
||||
|
||||
### `__init__(message=None, *args, **kwargs)`
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `message: Union[str, dict, list, BaseModel, MessageSegment, Message]`: 消息内容
|
||||
|
||||
|
||||
|
||||
### `append(obj)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
添加一个消息段到消息数组末尾
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `obj: Union[str, MessageSegment]`: 要添加的消息段
|
||||
|
||||
|
||||
|
||||
### `extend(obj)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
拼接一个消息数组或多个消息段到消息数组末尾
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `obj: Union[Message, Iterable[MessageSegment]]`: 要添加的消息数组
|
||||
|
||||
|
||||
|
||||
### `reduce()`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
缩减消息数组,即按 MessageSegment 的实现拼接相邻消息段
|
||||
|
||||
|
||||
|
||||
### `extract_plain_text()`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
提取消息内纯文本消息
|
@@ -1,442 +0,0 @@
|
||||
---
|
||||
contentSidebar: true
|
||||
sidebarDepth: 0
|
||||
---
|
||||
|
||||
# NoneBot.adapters.cqhttp 模块
|
||||
|
||||
|
||||
## `escape(s, *, escape_comma=True)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
对字符串进行 CQ 码转义。
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `s: str`: 需要转义的字符串
|
||||
|
||||
|
||||
* `escape_comma: bool`: 是否转义逗号(`,`)。
|
||||
|
||||
|
||||
|
||||
## `unescape(s)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
对字符串进行 CQ 码去转义。
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `s: str`: 需要转义的字符串
|
||||
|
||||
|
||||
|
||||
## _exception_ `CQHTTPAdapterException`
|
||||
|
||||
基类:[`nonebot.exception.AdapterException`](../exception.md#nonebot.exception.AdapterException)
|
||||
|
||||
|
||||
## _exception_ `ActionFailed`
|
||||
|
||||
基类:[`nonebot.exception.ActionFailed`](../exception.md#nonebot.exception.ActionFailed), `nonebot.adapters.cqhttp.exception.CQHTTPAdapterException`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
API 请求返回错误信息。
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `retcode: Optional[int]`: 错误码
|
||||
|
||||
|
||||
|
||||
## _exception_ `NetworkError`
|
||||
|
||||
基类:[`nonebot.exception.NetworkError`](../exception.md#nonebot.exception.NetworkError), `nonebot.adapters.cqhttp.exception.CQHTTPAdapterException`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
网络错误。
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `retcode: Optional[int]`: 错误码
|
||||
|
||||
|
||||
|
||||
## _exception_ `ApiNotAvailable`
|
||||
|
||||
基类:[`nonebot.exception.ApiNotAvailable`](../exception.md#nonebot.exception.ApiNotAvailable), `nonebot.adapters.cqhttp.exception.CQHTTPAdapterException`
|
||||
|
||||
|
||||
## _async_ `_check_reply(bot, event)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
检查消息中存在的回复,去除并赋值 `event.reply`, `event.to_me`
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `bot: Bot`: Bot 对象
|
||||
|
||||
|
||||
* `event: Event`: Event 对象
|
||||
|
||||
|
||||
|
||||
## `_check_at_me(bot, event)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
检查消息开头或结尾是否存在 @机器人,去除并赋值 `event.to_me`
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `bot: Bot`: Bot 对象
|
||||
|
||||
|
||||
* `event: Event`: Event 对象
|
||||
|
||||
|
||||
|
||||
## `_check_nickname(bot, event)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
检查消息开头是否存在,去除并赋值 `event.to_me`
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `bot: Bot`: Bot 对象
|
||||
|
||||
|
||||
* `event: Event`: Event 对象
|
||||
|
||||
|
||||
|
||||
## `_handle_api_result(result)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
处理 API 请求返回值。
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `result: Optional[Dict[str, Any]]`: API 返回数据
|
||||
|
||||
|
||||
|
||||
* **返回**
|
||||
|
||||
|
||||
* `Any`: API 调用返回数据
|
||||
|
||||
|
||||
|
||||
* **异常**
|
||||
|
||||
|
||||
* `ActionFailed`: API 调用失败
|
||||
|
||||
|
||||
|
||||
## _class_ `Bot`
|
||||
|
||||
基类:[`nonebot.adapters.BaseBot`](README.md#nonebot.adapters.BaseBot)
|
||||
|
||||
CQHTTP 协议 Bot 适配。继承属性参考 [BaseBot](./#class-basebot) 。
|
||||
|
||||
|
||||
### _property_ `type`
|
||||
|
||||
|
||||
* 返回: `"cqhttp"`
|
||||
|
||||
|
||||
### _async classmethod_ `check_permission(driver, connection_type, headers, body)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
CQHTTP (OneBot) 协议鉴权。参考 [鉴权](https://github.com/howmanybots/onebot/blob/master/v11/specs/communication/authorization.md)
|
||||
|
||||
|
||||
|
||||
### _async_ `handle_message(message)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
调用 [_check_reply](#async-check-reply-bot-event), [_check_at_me](#check-at-me-bot-event), [_check_nickname](#check-nickname-bot-event) 处理事件并转换为 [Event](#class-event)
|
||||
|
||||
|
||||
|
||||
### _async_ `call_api(api, **data)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
调用 CQHTTP 协议 API
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `api: str`: API 名称
|
||||
|
||||
|
||||
* `**data: Any`: API 参数
|
||||
|
||||
|
||||
|
||||
* **返回**
|
||||
|
||||
|
||||
* `Any`: API 调用返回数据
|
||||
|
||||
|
||||
|
||||
* **异常**
|
||||
|
||||
|
||||
* `NetworkError`: 网络错误
|
||||
|
||||
|
||||
* `ActionFailed`: API 调用失败
|
||||
|
||||
|
||||
|
||||
### _async_ `send(event, message, at_sender=False, **kwargs)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
根据 `event` 向触发事件的主体发送消息。
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `event: Event`: Event 对象
|
||||
|
||||
|
||||
* `message: Union[str, Message, MessageSegment]`: 要发送的消息
|
||||
|
||||
|
||||
* `at_sender: bool`: 是否 @ 事件主体
|
||||
|
||||
|
||||
* `**kwargs`: 覆盖默认参数
|
||||
|
||||
|
||||
|
||||
* **返回**
|
||||
|
||||
|
||||
* `Any`: API 调用返回数据
|
||||
|
||||
|
||||
|
||||
* **异常**
|
||||
|
||||
|
||||
* `ValueError`: 缺少 `user_id`, `group_id`
|
||||
|
||||
|
||||
* `NetworkError`: 网络错误
|
||||
|
||||
|
||||
* `ActionFailed`: API 调用失败
|
||||
|
||||
|
||||
|
||||
## _class_ `Event`
|
||||
|
||||
基类:[`nonebot.adapters.BaseEvent`](README.md#nonebot.adapters.BaseEvent)
|
||||
|
||||
CQHTTP 协议 Event 适配。继承属性参考 [BaseEvent](./#class-baseevent) 。
|
||||
|
||||
|
||||
### _property_ `id`
|
||||
|
||||
|
||||
* 类型: `Optional[int]`
|
||||
|
||||
|
||||
* 说明: 事件/消息 ID
|
||||
|
||||
|
||||
### _property_ `name`
|
||||
|
||||
|
||||
* 类型: `str`
|
||||
|
||||
|
||||
* 说明: 事件名称,由类型与 `.` 组合而成
|
||||
|
||||
|
||||
### _property_ `self_id`
|
||||
|
||||
|
||||
* 类型: `str`
|
||||
|
||||
|
||||
* 说明: 机器人自身 ID
|
||||
|
||||
|
||||
### _property_ `time`
|
||||
|
||||
|
||||
* 类型: `int`
|
||||
|
||||
|
||||
* 说明: 事件发生时间
|
||||
|
||||
|
||||
### _property_ `type`
|
||||
|
||||
|
||||
* 类型: `str`
|
||||
|
||||
|
||||
* 说明: 事件类型
|
||||
|
||||
|
||||
### _property_ `detail_type`
|
||||
|
||||
|
||||
* 类型: `str`
|
||||
|
||||
|
||||
* 说明: 事件详细类型
|
||||
|
||||
|
||||
### _property_ `sub_type`
|
||||
|
||||
|
||||
* 类型: `Optional[str]`
|
||||
|
||||
|
||||
* 说明: 事件子类型
|
||||
|
||||
|
||||
### _property_ `user_id`
|
||||
|
||||
|
||||
* 类型: `Optional[int]`
|
||||
|
||||
|
||||
* 说明: 事件主体 ID
|
||||
|
||||
|
||||
### _property_ `group_id`
|
||||
|
||||
|
||||
* 类型: `Optional[int]`
|
||||
|
||||
|
||||
* 说明: 事件主体群 ID
|
||||
|
||||
|
||||
### _property_ `to_me`
|
||||
|
||||
|
||||
* 类型: `Optional[bool]`
|
||||
|
||||
|
||||
* 说明: 消息是否与机器人相关
|
||||
|
||||
|
||||
### _property_ `message`
|
||||
|
||||
|
||||
* 类型: `Optional[Message]`
|
||||
|
||||
|
||||
* 说明: 消息内容
|
||||
|
||||
|
||||
### _property_ `reply`
|
||||
|
||||
|
||||
* 类型: `Optional[dict]`
|
||||
|
||||
|
||||
* 说明: 回复消息详情
|
||||
|
||||
|
||||
### _property_ `raw_message`
|
||||
|
||||
|
||||
* 类型: `Optional[str]`
|
||||
|
||||
|
||||
* 说明: 原始消息
|
||||
|
||||
|
||||
### _property_ `plain_text`
|
||||
|
||||
|
||||
* 类型: `Optional[str]`
|
||||
|
||||
|
||||
* 说明: 纯文本消息内容
|
||||
|
||||
|
||||
### _property_ `sender`
|
||||
|
||||
|
||||
* 类型: `Optional[dict]`
|
||||
|
||||
|
||||
* 说明: 消息发送者信息
|
||||
|
||||
|
||||
## _class_ `MessageSegment`
|
||||
|
||||
基类:[`nonebot.adapters.BaseMessageSegment`](README.md#nonebot.adapters.BaseMessageSegment)
|
||||
|
||||
CQHTTP 协议 MessageSegment 适配。具体方法参考协议消息段类型或源码。
|
||||
|
||||
|
||||
## _class_ `Message`
|
||||
|
||||
基类:[`nonebot.adapters.BaseMessage`](README.md#nonebot.adapters.BaseMessage)
|
||||
|
||||
CQHTTP 协议 Message 适配。
|
@@ -1,380 +0,0 @@
|
||||
---
|
||||
contentSidebar: true
|
||||
sidebarDepth: 0
|
||||
---
|
||||
|
||||
# NoneBot.adapters.ding 模块
|
||||
|
||||
|
||||
## _exception_ `DingAdapterException`
|
||||
|
||||
基类:[`nonebot.exception.AdapterException`](../exception.md#nonebot.exception.AdapterException)
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
钉钉 Adapter 错误基类
|
||||
|
||||
|
||||
|
||||
## _exception_ `ActionFailed`
|
||||
|
||||
基类:[`nonebot.exception.ActionFailed`](../exception.md#nonebot.exception.ActionFailed), `nonebot.adapters.ding.exception.DingAdapterException`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
API 请求返回错误信息。
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `errcode: Optional[int]`: 错误码
|
||||
|
||||
|
||||
* `errmsg: Optional[str]`: 错误信息
|
||||
|
||||
|
||||
|
||||
## _exception_ `ApiNotAvailable`
|
||||
|
||||
基类:[`nonebot.exception.ApiNotAvailable`](../exception.md#nonebot.exception.ApiNotAvailable), `nonebot.adapters.ding.exception.DingAdapterException`
|
||||
|
||||
|
||||
## _exception_ `NetworkError`
|
||||
|
||||
基类:[`nonebot.exception.NetworkError`](../exception.md#nonebot.exception.NetworkError), `nonebot.adapters.ding.exception.DingAdapterException`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
网络错误。
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `retcode: Optional[int]`: 错误码
|
||||
|
||||
|
||||
|
||||
## _exception_ `SessionExpired`
|
||||
|
||||
基类:[`nonebot.exception.ApiNotAvailable`](../exception.md#nonebot.exception.ApiNotAvailable), `nonebot.adapters.ding.exception.DingAdapterException`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
发消息的 session 已经过期。
|
||||
|
||||
|
||||
|
||||
## _class_ `Bot`
|
||||
|
||||
基类:[`nonebot.adapters.BaseBot`](README.md#nonebot.adapters.BaseBot)
|
||||
|
||||
钉钉 协议 Bot 适配。继承属性参考 [BaseBot](./#class-basebot) 。
|
||||
|
||||
|
||||
### _property_ `type`
|
||||
|
||||
|
||||
* 返回: `"ding"`
|
||||
|
||||
|
||||
### _async classmethod_ `check_permission(driver, connection_type, headers, body)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
钉钉协议鉴权。参考 [鉴权](https://ding-doc.dingtalk.com/doc#/serverapi2/elzz1p)
|
||||
|
||||
|
||||
|
||||
### _async_ `handle_message(body)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
处理上报消息的函数,转换为 `Event` 事件后调用 `nonebot.message.handle_event` 进一步处理事件。
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `message: dict`: 收到的上报消息
|
||||
|
||||
|
||||
|
||||
### _async_ `call_api(api, event=None, **data)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
调用 钉钉 协议 API
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `api: str`: API 名称
|
||||
|
||||
|
||||
* `**data: Any`: API 参数
|
||||
|
||||
|
||||
|
||||
* **返回**
|
||||
|
||||
|
||||
* `Any`: API 调用返回数据
|
||||
|
||||
|
||||
|
||||
* **异常**
|
||||
|
||||
|
||||
* `NetworkError`: 网络错误
|
||||
|
||||
|
||||
* `ActionFailed`: API 调用失败
|
||||
|
||||
|
||||
|
||||
### _async_ `send(event, message, at_sender=False, **kwargs)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
根据 `event` 向触发事件的主体发送消息。
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `event: Event`: Event 对象
|
||||
|
||||
|
||||
* `message: Union[str, Message, MessageSegment]`: 要发送的消息
|
||||
|
||||
|
||||
* `at_sender: bool`: 是否 @ 事件主体
|
||||
|
||||
|
||||
* `**kwargs`: 覆盖默认参数
|
||||
|
||||
|
||||
|
||||
* **返回**
|
||||
|
||||
|
||||
* `Any`: API 调用返回数据
|
||||
|
||||
|
||||
|
||||
* **异常**
|
||||
|
||||
|
||||
* `ValueError`: 缺少 `user_id`, `group_id`
|
||||
|
||||
|
||||
* `NetworkError`: 网络错误
|
||||
|
||||
|
||||
* `ActionFailed`: API 调用失败
|
||||
|
||||
|
||||
|
||||
## _class_ `Event`
|
||||
|
||||
基类:[`nonebot.adapters.BaseEvent`](README.md#nonebot.adapters.BaseEvent)
|
||||
|
||||
钉钉 协议 Event 适配。继承属性参考 [BaseEvent](./#class-baseevent) 。
|
||||
|
||||
|
||||
### _property_ `raw_event`
|
||||
|
||||
原始上报消息
|
||||
|
||||
|
||||
### _property_ `id`
|
||||
|
||||
|
||||
* 类型: `Optional[str]`
|
||||
|
||||
|
||||
* 说明: 消息 ID
|
||||
|
||||
|
||||
### _property_ `name`
|
||||
|
||||
|
||||
* 类型: `str`
|
||||
|
||||
|
||||
* 说明: 事件名称,由 type.\`detail_type\` 组合而成
|
||||
|
||||
|
||||
### _property_ `self_id`
|
||||
|
||||
|
||||
* 类型: `str`
|
||||
|
||||
|
||||
* 说明: 机器人自身 ID
|
||||
|
||||
|
||||
### _property_ `time`
|
||||
|
||||
|
||||
* 类型: `int`
|
||||
|
||||
|
||||
* 说明: 消息的时间戳,单位 s
|
||||
|
||||
|
||||
### _property_ `type`
|
||||
|
||||
|
||||
* 类型: `str`
|
||||
|
||||
|
||||
* 说明: 事件类型
|
||||
|
||||
|
||||
### _property_ `detail_type`
|
||||
|
||||
|
||||
* 类型: `str`
|
||||
|
||||
|
||||
* 说明: 事件详细类型
|
||||
|
||||
|
||||
### _property_ `sub_type`
|
||||
|
||||
|
||||
* 类型: `None`
|
||||
|
||||
|
||||
* 说明: 钉钉适配器无事件子类型
|
||||
|
||||
|
||||
### _property_ `user_id`
|
||||
|
||||
|
||||
* 类型: `Optional[str]`
|
||||
|
||||
|
||||
* 说明: 发送者 ID
|
||||
|
||||
|
||||
### _property_ `group_id`
|
||||
|
||||
|
||||
* 类型: `Optional[str]`
|
||||
|
||||
|
||||
* 说明: 事件主体群 ID
|
||||
|
||||
|
||||
### _property_ `to_me`
|
||||
|
||||
|
||||
* 类型: `Optional[bool]`
|
||||
|
||||
|
||||
* 说明: 消息是否与机器人相关
|
||||
|
||||
|
||||
### _property_ `message`
|
||||
|
||||
|
||||
* 类型: `Optional[Message]`
|
||||
|
||||
|
||||
* 说明: 消息内容
|
||||
|
||||
|
||||
### _property_ `reply`
|
||||
|
||||
|
||||
* 类型: `None`
|
||||
|
||||
|
||||
* 说明: 回复消息详情
|
||||
|
||||
|
||||
### _property_ `raw_message`
|
||||
|
||||
|
||||
* 类型: `Optional[str]`
|
||||
|
||||
|
||||
* 说明: 原始消息
|
||||
|
||||
|
||||
### _property_ `plain_text`
|
||||
|
||||
|
||||
* 类型: `Optional[str]`
|
||||
|
||||
|
||||
* 说明: 纯文本消息内容
|
||||
|
||||
|
||||
### _property_ `sender`
|
||||
|
||||
|
||||
* 类型: `Optional[dict]`
|
||||
|
||||
|
||||
* 说明: 消息发送者信息
|
||||
|
||||
|
||||
## _class_ `MessageSegment`
|
||||
|
||||
基类:[`nonebot.adapters.BaseMessageSegment`](README.md#nonebot.adapters.BaseMessageSegment)
|
||||
|
||||
钉钉 协议 MessageSegment 适配。具体方法参考协议消息段类型或源码。
|
||||
|
||||
|
||||
### _static_ `actionCardSingleMultiBtns(title, text, btns=[], hideAvatar=False, btnOrientation='1')`
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `btnOrientation`: 0:按钮竖直排列 1:按钮横向排列
|
||||
|
||||
|
||||
* `btns`: [{ "title": title, "actionURL": actionURL }, ...]
|
||||
|
||||
|
||||
|
||||
### _static_ `feedCard(links=[])`
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `links`: [{ "title": xxx, "messageURL": xxx, "picURL": xxx }, ...]
|
||||
|
||||
|
||||
|
||||
### _static_ `empty()`
|
||||
|
||||
不想回复消息到群里
|
||||
|
||||
|
||||
## _class_ `Message`
|
||||
|
||||
基类:[`nonebot.adapters.BaseMessage`](README.md#nonebot.adapters.BaseMessage)
|
||||
|
||||
钉钉 协议 Message 适配。
|
@@ -1,285 +0,0 @@
|
||||
---
|
||||
contentSidebar: true
|
||||
sidebarDepth: 0
|
||||
---
|
||||
|
||||
# NoneBot.config 模块
|
||||
|
||||
## 配置
|
||||
|
||||
NoneBot 使用 [pydantic](https://pydantic-docs.helpmanual.io/) 以及 [python-dotenv](https://saurabh-kumar.com/python-dotenv/) 来读取配置。
|
||||
|
||||
配置项需符合特殊格式或 json 序列化格式。详情见 [pydantic Field Type](https://pydantic-docs.helpmanual.io/usage/types/) 文档。
|
||||
|
||||
|
||||
## _class_ `Env`
|
||||
|
||||
基类:`pydantic.env_settings.BaseSettings`
|
||||
|
||||
运行环境配置。大小写不敏感。
|
||||
|
||||
将会从 `nonebot.init 参数` > `环境变量` > `.env 环境配置文件` 的优先级读取配置。
|
||||
|
||||
|
||||
### `environment`
|
||||
|
||||
|
||||
* **类型**: `str`
|
||||
|
||||
|
||||
* **默认值**: `"prod"`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
当前环境名。 NoneBot 将从 `.env.{environment}` 文件中加载配置。
|
||||
|
||||
|
||||
|
||||
## _class_ `Config`
|
||||
|
||||
基类:`nonebot.config.BaseConfig`
|
||||
|
||||
NoneBot 主要配置。大小写不敏感。
|
||||
|
||||
除了 NoneBot 的配置项外,还可以自行添加配置项到 `.env.{environment}` 文件中。
|
||||
这些配置将会在 json 反序列化后一起带入 `Config` 类中。
|
||||
|
||||
|
||||
### `driver`
|
||||
|
||||
|
||||
* **类型**: `str`
|
||||
|
||||
|
||||
* **默认值**: `"nonebot.drivers.fastapi"`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
NoneBot 运行所使用的 `Driver` 。继承自 `nonebot.driver.BaseDriver` 。
|
||||
|
||||
|
||||
|
||||
### `host`
|
||||
|
||||
|
||||
* **类型**: `IPvAnyAddress`
|
||||
|
||||
|
||||
* **默认值**: `127.0.0.1`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
NoneBot 的 HTTP 和 WebSocket 服务端监听的 IP/主机名。
|
||||
|
||||
|
||||
|
||||
### `port`
|
||||
|
||||
|
||||
* **类型**: `int`
|
||||
|
||||
|
||||
* **默认值**: `8080`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
NoneBot 的 HTTP 和 WebSocket 服务端监听的端口。
|
||||
|
||||
|
||||
|
||||
### `debug`
|
||||
|
||||
|
||||
* **类型**: `bool`
|
||||
|
||||
|
||||
* **默认值**: `False`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
是否以调试模式运行 NoneBot。
|
||||
|
||||
|
||||
|
||||
### `api_root`
|
||||
|
||||
|
||||
* **类型**: `Dict[str, str]`
|
||||
|
||||
|
||||
* **默认值**: `{}`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
以机器人 ID 为键,上报地址为值的字典,环境变量或文件中应使用 json 序列化。
|
||||
|
||||
|
||||
|
||||
* **示例**
|
||||
|
||||
|
||||
```default
|
||||
API_ROOT={"123456": "http://127.0.0.1:5700"}
|
||||
```
|
||||
|
||||
|
||||
### `api_timeout`
|
||||
|
||||
|
||||
* **类型**: `Optional[float]`
|
||||
|
||||
|
||||
* **默认值**: `30.`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
API 请求超时时间,单位: 秒。
|
||||
|
||||
|
||||
|
||||
### `access_token`
|
||||
|
||||
|
||||
* **类型**: `Optional[str]`
|
||||
|
||||
|
||||
* **默认值**: `None`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
API 请求以及上报所需密钥,在请求头中携带。
|
||||
|
||||
|
||||
|
||||
* **示例**
|
||||
|
||||
|
||||
```http
|
||||
POST /cqhttp/ HTTP/1.1
|
||||
Authorization: Bearer kSLuTF2GC2Q4q4ugm3
|
||||
```
|
||||
|
||||
|
||||
### `secret`
|
||||
|
||||
|
||||
* **类型**: `Optional[str]`
|
||||
|
||||
|
||||
* **默认值**: `None`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
HTTP POST 形式上报所需签名,在请求头中携带。
|
||||
|
||||
|
||||
|
||||
* **示例**
|
||||
|
||||
|
||||
```http
|
||||
POST /cqhttp/ HTTP/1.1
|
||||
X-Signature: sha1=f9ddd4863ace61e64f462d41ca311e3d2c1176e2
|
||||
```
|
||||
|
||||
|
||||
### `superusers`
|
||||
|
||||
|
||||
* **类型**: `Set[int]`
|
||||
|
||||
|
||||
* **默认值**: `set()`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
机器人超级用户。
|
||||
|
||||
|
||||
|
||||
* **示例**
|
||||
|
||||
|
||||
```default
|
||||
SUPER_USERS=[12345789]
|
||||
```
|
||||
|
||||
|
||||
### `nickname`
|
||||
|
||||
|
||||
* **类型**: `Set[str]`
|
||||
|
||||
|
||||
* **默认值**: `set()`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
机器人昵称。
|
||||
|
||||
|
||||
|
||||
### `command_start`
|
||||
|
||||
|
||||
* **类型**: `Set[str]`
|
||||
|
||||
|
||||
* **默认值**: `{"/"}`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
命令的起始标记,用于判断一条消息是不是命令。
|
||||
|
||||
|
||||
|
||||
### `command_sep`
|
||||
|
||||
|
||||
* **类型**: `Set[str]`
|
||||
|
||||
|
||||
* **默认值**: `{"."}`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
命令的分隔标记,用于将文本形式的命令切分为元组(实际的命令名)。
|
||||
|
||||
|
||||
|
||||
### `session_expire_timeout`
|
||||
|
||||
|
||||
* **类型**: `timedelta`
|
||||
|
||||
|
||||
* **默认值**: `timedelta(minutes=2)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
等待用户回复的超时时间。
|
||||
|
||||
|
||||
|
||||
* **示例**
|
||||
|
||||
|
||||
```default
|
||||
SESSION_EXPIRE_TIMEOUT=120 # 单位: 秒
|
||||
SESSION_EXPIRE_TIMEOUT=[DD ][HH:MM]SS[.ffffff]
|
||||
SESSION_EXPIRE_TIMEOUT=P[DD]DT[HH]H[MM]M[SS]S # ISO 8601
|
||||
```
|
@@ -1,246 +0,0 @@
|
||||
---
|
||||
contentSidebar: true
|
||||
sidebarDepth: 0
|
||||
---
|
||||
|
||||
# NoneBot.drivers 模块
|
||||
|
||||
## 后端驱动适配基类
|
||||
|
||||
各驱动请继承以下基类
|
||||
|
||||
|
||||
## _class_ `BaseDriver`
|
||||
|
||||
基类:`abc.ABC`
|
||||
|
||||
Driver 基类。将后端框架封装,以满足适配器使用。
|
||||
|
||||
|
||||
### `_adapters`
|
||||
|
||||
|
||||
* **类型**
|
||||
|
||||
`Dict[str, Type[Bot]]`
|
||||
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
已注册的适配器列表
|
||||
|
||||
|
||||
|
||||
### _abstract_ `__init__(env, config)`
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `env: Env`: 包含环境信息的 Env 对象
|
||||
|
||||
|
||||
* `config: Config`: 包含配置信息的 Config 对象
|
||||
|
||||
|
||||
|
||||
### `env`
|
||||
|
||||
|
||||
* **类型**
|
||||
|
||||
`str`
|
||||
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
环境名称
|
||||
|
||||
|
||||
|
||||
### `config`
|
||||
|
||||
|
||||
* **类型**
|
||||
|
||||
`Config`
|
||||
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
配置对象
|
||||
|
||||
|
||||
|
||||
### `_clients`
|
||||
|
||||
|
||||
* **类型**
|
||||
|
||||
`Dict[str, Bot]`
|
||||
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
已连接的 Bot
|
||||
|
||||
|
||||
|
||||
### _classmethod_ `register_adapter(name, adapter)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
注册一个协议适配器
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `name: str`: 适配器名称,用于在连接时进行识别
|
||||
|
||||
|
||||
* `adapter: Type[Bot]`: 适配器 Class
|
||||
|
||||
|
||||
|
||||
### _abstract property_ `type`
|
||||
|
||||
驱动类型名称
|
||||
|
||||
|
||||
### _abstract property_ `server_app`
|
||||
|
||||
驱动 APP 对象
|
||||
|
||||
|
||||
### _abstract property_ `asgi`
|
||||
|
||||
驱动 ASGI 对象
|
||||
|
||||
|
||||
### _abstract property_ `logger`
|
||||
|
||||
驱动专属 logger 日志记录器
|
||||
|
||||
|
||||
### _property_ `bots`
|
||||
|
||||
|
||||
* **类型**
|
||||
|
||||
`Dict[str, Bot]`
|
||||
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
获取当前所有已连接的 Bot
|
||||
|
||||
|
||||
|
||||
### _abstract_ `on_startup(func)`
|
||||
|
||||
注册一个在驱动启动时运行的函数
|
||||
|
||||
|
||||
### _abstract_ `on_shutdown(func)`
|
||||
|
||||
注册一个在驱动停止时运行的函数
|
||||
|
||||
|
||||
### _abstract_ `run(host=None, port=None, *args, **kwargs)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
启动驱动框架
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `host: Optional[str]`: 驱动绑定 IP
|
||||
|
||||
|
||||
* `post: Optional[int]`: 驱动绑定端口
|
||||
|
||||
|
||||
* `*args`
|
||||
|
||||
|
||||
* `**kwargs`
|
||||
|
||||
|
||||
|
||||
### _abstract async_ `_handle_http()`
|
||||
|
||||
用于处理 HTTP 类型请求的函数
|
||||
|
||||
|
||||
### _abstract async_ `_handle_ws_reverse()`
|
||||
|
||||
用于处理 WebSocket 类型请求的函数
|
||||
|
||||
|
||||
## _class_ `BaseWebSocket`
|
||||
|
||||
基类:`object`
|
||||
|
||||
WebSocket 连接封装,统一接口方便外部调用。
|
||||
|
||||
|
||||
### _abstract_ `__init__(websocket)`
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `websocket: Any`: WebSocket 连接对象
|
||||
|
||||
|
||||
|
||||
### _property_ `websocket`
|
||||
|
||||
WebSocket 连接对象
|
||||
|
||||
|
||||
### _abstract property_ `closed`
|
||||
|
||||
|
||||
* **类型**
|
||||
|
||||
`bool`
|
||||
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
连接是否已经关闭
|
||||
|
||||
|
||||
|
||||
### _abstract async_ `accept()`
|
||||
|
||||
接受 WebSocket 连接请求
|
||||
|
||||
|
||||
### _abstract async_ `close(code)`
|
||||
|
||||
关闭 WebSocket 连接请求
|
||||
|
||||
|
||||
### _abstract async_ `receive()`
|
||||
|
||||
接收一条 WebSocket 信息
|
||||
|
||||
|
||||
### _abstract async_ `send(data)`
|
||||
|
||||
发送一条 WebSocket 信息
|
@@ -1,118 +0,0 @@
|
||||
---
|
||||
contentSidebar: true
|
||||
sidebarDepth: 0
|
||||
---
|
||||
|
||||
# NoneBot.drivers.fastapi 模块
|
||||
|
||||
## FastAPI 驱动适配
|
||||
|
||||
后端使用方法请参考: [FastAPI 文档](https://fastapi.tiangolo.com/)
|
||||
|
||||
|
||||
## _class_ `Driver`
|
||||
|
||||
基类:[`nonebot.drivers.BaseDriver`](README.md#nonebot.drivers.BaseDriver)
|
||||
|
||||
FastAPI 驱动框架
|
||||
|
||||
|
||||
* **上报地址**
|
||||
|
||||
|
||||
* `/{adapter name}/`: HTTP POST 上报
|
||||
|
||||
|
||||
* `/{adapter name}/http/`: HTTP POST 上报
|
||||
|
||||
|
||||
* `/{adapter name}/ws`: WebSocket 上报
|
||||
|
||||
|
||||
* `/{adapter name}/ws/`: WebSocket 上报
|
||||
|
||||
|
||||
|
||||
### _property_ `type`
|
||||
|
||||
驱动名称: `fastapi`
|
||||
|
||||
|
||||
### _property_ `server_app`
|
||||
|
||||
`FastAPI APP` 对象
|
||||
|
||||
|
||||
### _property_ `asgi`
|
||||
|
||||
`FastAPI APP` 对象
|
||||
|
||||
|
||||
### _property_ `logger`
|
||||
|
||||
fastapi 使用的 logger
|
||||
|
||||
|
||||
### `on_startup(func)`
|
||||
|
||||
参考文档: [Events](https://fastapi.tiangolo.com/advanced/events/#startup-event)
|
||||
|
||||
|
||||
### `on_shutdown(func)`
|
||||
|
||||
参考文档: [Events](https://fastapi.tiangolo.com/advanced/events/#startup-event)
|
||||
|
||||
|
||||
### `run(host=None, port=None, *, app=None, **kwargs)`
|
||||
|
||||
使用 `uvicorn` 启动 FastAPI
|
||||
|
||||
|
||||
### _async_ `_handle_http(adapter, request, data=Body(Ellipsis))`
|
||||
|
||||
用于处理 HTTP 类型请求的函数
|
||||
|
||||
|
||||
### _async_ `_handle_ws_reverse(adapter, websocket)`
|
||||
|
||||
用于处理 WebSocket 类型请求的函数
|
||||
|
||||
|
||||
## _class_ `WebSocket`
|
||||
|
||||
基类:[`nonebot.drivers.BaseWebSocket`](README.md#nonebot.drivers.BaseWebSocket)
|
||||
|
||||
|
||||
### _property_ `closed`
|
||||
|
||||
|
||||
* **类型**
|
||||
|
||||
`bool`
|
||||
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
连接是否已经关闭
|
||||
|
||||
|
||||
|
||||
### _async_ `accept()`
|
||||
|
||||
接受 WebSocket 连接请求
|
||||
|
||||
|
||||
### _async_ `close(code=1000)`
|
||||
|
||||
关闭 WebSocket 连接请求
|
||||
|
||||
|
||||
### _async_ `receive()`
|
||||
|
||||
接收一条 WebSocket 信息
|
||||
|
||||
|
||||
### _async_ `send(data)`
|
||||
|
||||
发送一条 WebSocket 信息
|
@@ -1,182 +0,0 @@
|
||||
---
|
||||
contentSidebar: true
|
||||
sidebarDepth: 0
|
||||
---
|
||||
|
||||
# NoneBot.exception 模块
|
||||
|
||||
## 异常
|
||||
|
||||
下列文档中的异常是所有 NoneBot 运行时可能会抛出的。
|
||||
这些异常并非所有需要用户处理,在 NoneBot 内部运行时被捕获,并进行对应操作。
|
||||
|
||||
|
||||
## _exception_ `NoneBotException`
|
||||
|
||||
基类:`Exception`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
所有 NoneBot 发生的异常基类。
|
||||
|
||||
|
||||
|
||||
## _exception_ `IgnoredException`
|
||||
|
||||
基类:`nonebot.exception.NoneBotException`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
指示 NoneBot 应该忽略该事件。可由 PreProcessor 抛出。
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `reason`: 忽略事件的原因
|
||||
|
||||
|
||||
|
||||
## _exception_ `PausedException`
|
||||
|
||||
基类:`nonebot.exception.NoneBotException`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
指示 NoneBot 结束当前 `Handler` 并等待下一条消息后继续下一个 `Handler`。
|
||||
可用于用户输入新信息。
|
||||
|
||||
|
||||
|
||||
* **用法**
|
||||
|
||||
可以在 `Handler` 中通过 `Matcher.pause()` 抛出。
|
||||
|
||||
|
||||
|
||||
## _exception_ `RejectedException`
|
||||
|
||||
基类:`nonebot.exception.NoneBotException`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
指示 NoneBot 结束当前 `Handler` 并等待下一条消息后重新运行当前 `Handler`。
|
||||
可用于用户重新输入。
|
||||
|
||||
|
||||
|
||||
* **用法**
|
||||
|
||||
可以在 `Handler` 中通过 `Matcher.reject()` 抛出。
|
||||
|
||||
|
||||
|
||||
## _exception_ `FinishedException`
|
||||
|
||||
基类:`nonebot.exception.NoneBotException`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
指示 NoneBot 结束当前 `Handler` 且后续 `Handler` 不再被运行。
|
||||
可用于结束用户会话。
|
||||
|
||||
|
||||
|
||||
* **用法**
|
||||
|
||||
可以在 `Handler` 中通过 `Matcher.finish()` 抛出。
|
||||
|
||||
|
||||
|
||||
## _exception_ `StopPropagation`
|
||||
|
||||
基类:`nonebot.exception.NoneBotException`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
指示 NoneBot 终止事件向下层传播。
|
||||
|
||||
|
||||
|
||||
* **用法**
|
||||
|
||||
在 `Matcher.block == True` 时抛出。
|
||||
|
||||
|
||||
|
||||
## _exception_ `RequestDenied`
|
||||
|
||||
基类:`nonebot.exception.NoneBotException`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
Bot 连接请求不合法。
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `status_code: int`: HTTP 状态码
|
||||
|
||||
|
||||
* `reason: str`: 拒绝原因
|
||||
|
||||
|
||||
|
||||
## _exception_ `AdapterException`
|
||||
|
||||
基类:`nonebot.exception.NoneBotException`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
代表 `Adapter` 抛出的异常,所有的 `Adapter` 都要在内部继承自这个 `Exception`
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `adapter_name: str`: 标识 adapter
|
||||
|
||||
|
||||
|
||||
## _exception_ `ApiNotAvailable`
|
||||
|
||||
基类:`nonebot.exception.AdapterException`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
在 API 连接不可用时抛出。
|
||||
|
||||
|
||||
|
||||
## _exception_ `NetworkError`
|
||||
|
||||
基类:`nonebot.exception.AdapterException`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
在网络出现问题时抛出,如: API 请求地址不正确, API 请求无返回或返回状态非正常等。
|
||||
|
||||
|
||||
|
||||
## _exception_ `ActionFailed`
|
||||
|
||||
基类:`nonebot.exception.AdapterException`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
API 请求成功返回数据,但 API 操作失败。
|
@@ -1,55 +0,0 @@
|
||||
---
|
||||
contentSidebar: true
|
||||
sidebarDepth: 0
|
||||
---
|
||||
|
||||
# NoneBot.log 模块
|
||||
|
||||
## 日志
|
||||
|
||||
NoneBot 使用 [loguru](https://github.com/Delgan/loguru) 来记录日志信息。
|
||||
|
||||
自定义 logger 请参考 [loguru](https://github.com/Delgan/loguru) 文档。
|
||||
|
||||
|
||||
## `logger`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
NoneBot 日志记录器对象。
|
||||
|
||||
|
||||
|
||||
* **默认信息**
|
||||
|
||||
|
||||
* 格式: `[%(asctime)s %(name)s] %(levelname)s: %(message)s`
|
||||
|
||||
|
||||
* 等级: `DEBUG` / `INFO` ,根据 config 配置改变
|
||||
|
||||
|
||||
* 输出: 输出至 stdout
|
||||
|
||||
|
||||
|
||||
* **用法**
|
||||
|
||||
|
||||
```python
|
||||
from nonebot.log import logger
|
||||
```
|
||||
|
||||
|
||||
## _class_ `LoguruHandler`
|
||||
|
||||
基类:`logging.Handler`
|
||||
|
||||
|
||||
### `emit(record)`
|
||||
|
||||
Do whatever it takes to actually log the specified logging record.
|
||||
|
||||
This version is intended to be implemented by subclasses and so
|
||||
raises a NotImplementedError.
|
@@ -1,452 +0,0 @@
|
||||
---
|
||||
contentSidebar: true
|
||||
sidebarDepth: 0
|
||||
---
|
||||
|
||||
# NoneBot.matcher 模块
|
||||
|
||||
## 事件响应器
|
||||
|
||||
该模块实现事件响应器的创建与运行,并提供一些快捷方法来帮助用户更好的与机器人进行 对话 。
|
||||
|
||||
|
||||
## `matchers`
|
||||
|
||||
|
||||
* **类型**
|
||||
|
||||
`Dict[int, List[Type[Matcher]]]`
|
||||
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
用于存储当前所有的事件响应器
|
||||
|
||||
|
||||
|
||||
## _class_ `Matcher`
|
||||
|
||||
基类:`object`
|
||||
|
||||
事件响应器类
|
||||
|
||||
|
||||
### `module`
|
||||
|
||||
|
||||
* **类型**
|
||||
|
||||
`Optional[str]`
|
||||
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
事件响应器所在模块名称
|
||||
|
||||
|
||||
|
||||
### `type`
|
||||
|
||||
|
||||
* **类型**
|
||||
|
||||
`str`
|
||||
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
事件响应器类型
|
||||
|
||||
|
||||
|
||||
### `rule`
|
||||
|
||||
|
||||
* **类型**
|
||||
|
||||
`Rule`
|
||||
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
事件响应器匹配规则
|
||||
|
||||
|
||||
|
||||
### `permission`
|
||||
|
||||
|
||||
* **类型**
|
||||
|
||||
`Permission`
|
||||
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
事件响应器触发权限
|
||||
|
||||
|
||||
|
||||
### `priority`
|
||||
|
||||
|
||||
* **类型**
|
||||
|
||||
`int`
|
||||
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
事件响应器优先级
|
||||
|
||||
|
||||
|
||||
### `block`
|
||||
|
||||
|
||||
* **类型**
|
||||
|
||||
`bool`
|
||||
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
事件响应器是否阻止事件传播
|
||||
|
||||
|
||||
|
||||
### `temp`
|
||||
|
||||
|
||||
* **类型**
|
||||
|
||||
`bool`
|
||||
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
事件响应器是否为临时
|
||||
|
||||
|
||||
|
||||
### `expire_time`
|
||||
|
||||
|
||||
* **类型**
|
||||
|
||||
`Optional[datetime]`
|
||||
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
事件响应器过期时间点
|
||||
|
||||
|
||||
|
||||
### `_default_state`
|
||||
|
||||
|
||||
* **类型**
|
||||
|
||||
`dict`
|
||||
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
事件响应器默认状态
|
||||
|
||||
|
||||
|
||||
### `_default_parser`
|
||||
|
||||
|
||||
* **类型**
|
||||
|
||||
`Optional[ArgsParser]`
|
||||
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
事件响应器默认参数解析函数
|
||||
|
||||
|
||||
|
||||
### `__init__()`
|
||||
|
||||
实例化 Matcher 以便运行
|
||||
|
||||
|
||||
### `handlers`
|
||||
|
||||
|
||||
* **类型**
|
||||
|
||||
`List[Handler]`
|
||||
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
事件响应器拥有的事件处理函数列表
|
||||
|
||||
|
||||
|
||||
### _classmethod_ `new(type_='', rule=None, permission=None, handlers=None, temp=False, priority=1, block=False, *, module=None, default_state=None, expire_time=None)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
创建一个新的事件响应器,并存储至 [matchers](#matchers)
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `type_: str`: 事件响应器类型,与 `event.type` 一致时触发,空字符串表示任意
|
||||
|
||||
|
||||
* `rule: Optional[Rule]`: 匹配规则
|
||||
|
||||
|
||||
* `permission: Optional[Permission]`: 权限
|
||||
|
||||
|
||||
* `handlers: Optional[List[Handler]]`: 事件处理函数列表
|
||||
|
||||
|
||||
* `temp: bool`: 是否为临时事件响应器,即触发一次后删除
|
||||
|
||||
|
||||
* `priority: int`: 响应优先级
|
||||
|
||||
|
||||
* `block: bool`: 是否阻止事件向更低优先级的响应器传播
|
||||
|
||||
|
||||
* `module: Optional[str]`: 事件响应器所在模块名称
|
||||
|
||||
|
||||
* `default_state: Optional[dict]`: 默认状态 `state`
|
||||
|
||||
|
||||
* `expire_time: Optional[datetime]`: 事件响应器最终有效时间点,过时即被删除
|
||||
|
||||
|
||||
|
||||
* **返回**
|
||||
|
||||
|
||||
* `Type[Matcher]`: 新的事件响应器类
|
||||
|
||||
|
||||
|
||||
### _async classmethod_ `check_perm(bot, event)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
检查是否满足触发权限
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `bot: Bot`: Bot 对象
|
||||
|
||||
|
||||
* `event: Event`: 上报事件
|
||||
|
||||
|
||||
|
||||
* **返回**
|
||||
|
||||
|
||||
* `bool`: 是否满足权限
|
||||
|
||||
|
||||
|
||||
### _async classmethod_ `check_rule(bot, event, state)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
检查是否满足匹配规则
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `bot: Bot`: Bot 对象
|
||||
|
||||
|
||||
* `event: Event`: 上报事件
|
||||
|
||||
|
||||
* `state: dict`: 当前状态
|
||||
|
||||
|
||||
|
||||
* **返回**
|
||||
|
||||
|
||||
* `bool`: 是否满足匹配规则
|
||||
|
||||
|
||||
|
||||
### _classmethod_ `args_parser(func)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
装饰一个函数来更改当前事件响应器的默认参数解析函数
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `func: ArgsParser`: 参数解析函数
|
||||
|
||||
|
||||
|
||||
### _classmethod_ `handle()`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
装饰一个函数来向事件响应器直接添加一个处理函数
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* 无
|
||||
|
||||
|
||||
|
||||
### _classmethod_ `receive()`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
装饰一个函数来指示 NoneBot 在接收用户新的一条消息后继续运行该函数
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* 无
|
||||
|
||||
|
||||
|
||||
### _classmethod_ `got(key, prompt=None, args_parser=None)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
装饰一个函数来指示 NoneBot 当要获取的 `key` 不存在时接收用户新的一条消息并经过 `ArgsParser` 处理后再运行该函数,如果 `key` 已存在则直接继续运行
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `key: str`: 参数名
|
||||
|
||||
|
||||
* `prompt: Optional[Union[str, Message, MessageSegment]]`: 在参数不存在时向用户发送的消息
|
||||
|
||||
|
||||
* `args_parser: Optional[ArgsParser]`: 可选参数解析函数,空则使用默认解析函数
|
||||
|
||||
|
||||
|
||||
### _async classmethod_ `send(message, **kwargs)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
发送一条消息给当前交互用户
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `message: Union[str, Message, MessageSegment]`: 消息内容
|
||||
|
||||
|
||||
* `**kwargs`: 其他传递给 `bot.send` 的参数,请参考对应 adapter 的 bot 对象 api
|
||||
|
||||
|
||||
|
||||
### _async classmethod_ `finish(message=None, **kwargs)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
发送一条消息给当前交互用户并结束当前事件响应器
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `message: Union[str, Message, MessageSegment]`: 消息内容
|
||||
|
||||
|
||||
* `**kwargs`: 其他传递给 `bot.send` 的参数,请参考对应 adapter 的 bot 对象 api
|
||||
|
||||
|
||||
|
||||
### _async classmethod_ `pause(prompt=None, **kwargs)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
发送一条消息给当前交互用户并暂停事件响应器,在接收用户新的一条消息后继续下一个处理函数
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `prompt: Union[str, Message, MessageSegment]`: 消息内容
|
||||
|
||||
|
||||
* `**kwargs`: 其他传递给 `bot.send` 的参数,请参考对应 adapter 的 bot 对象 api
|
||||
|
||||
|
||||
|
||||
### _async classmethod_ `reject(prompt=None, **kwargs)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
发送一条消息给当前交互用户并暂停事件响应器,在接收用户新的一条消息后重新运行当前处理函数
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `prompt: Union[str, Message, MessageSegment]`: 消息内容
|
||||
|
||||
|
||||
* `**kwargs`: 其他传递给 `bot.send` 的参数,请参考对应 adapter 的 bot 对象 api
|
@@ -1,143 +0,0 @@
|
||||
---
|
||||
contentSidebar: true
|
||||
sidebarDepth: 0
|
||||
---
|
||||
|
||||
# NoneBot.message 模块
|
||||
|
||||
## 事件处理
|
||||
|
||||
NoneBot 内部处理并按优先级分发事件给所有事件响应器,提供了多个插槽以进行事件的预处理等。
|
||||
|
||||
|
||||
## `event_preprocessor(func)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
事件预处理。装饰一个函数,使它在每次接收到事件并分发给各响应器之前执行。
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
事件预处理函数接收三个参数。
|
||||
|
||||
|
||||
* `bot: Bot`: Bot 对象
|
||||
|
||||
|
||||
* `event: Event`: Event 对象
|
||||
|
||||
|
||||
* `state: dict`: 当前 State
|
||||
|
||||
|
||||
|
||||
## `event_postprocessor(func)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
事件后处理。装饰一个函数,使它在每次接收到事件并分发给各响应器之后执行。
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
事件后处理函数接收三个参数。
|
||||
|
||||
|
||||
* `bot: Bot`: Bot 对象
|
||||
|
||||
|
||||
* `event: Event`: Event 对象
|
||||
|
||||
|
||||
* `state: dict`: 当前事件运行前 State
|
||||
|
||||
|
||||
|
||||
## `run_preprocessor(func)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
运行预处理。装饰一个函数,使它在每次事件响应器运行前执行。
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
运行预处理函数接收四个参数。
|
||||
|
||||
|
||||
* `matcher: Matcher`: 当前要运行的事件响应器
|
||||
|
||||
|
||||
* `bot: Bot`: Bot 对象
|
||||
|
||||
|
||||
* `event: Event`: Event 对象
|
||||
|
||||
|
||||
* `state: dict`: 当前 State
|
||||
|
||||
|
||||
|
||||
## `run_postprocessor(func)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
运行后处理。装饰一个函数,使它在每次事件响应器运行后执行。
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
运行后处理函数接收五个参数。
|
||||
|
||||
|
||||
* `matcher: Matcher`: 运行完毕的事件响应器
|
||||
|
||||
|
||||
* `exception: Optional[Exception]`: 事件响应器运行错误(如果存在)
|
||||
|
||||
|
||||
* `bot: Bot`: Bot 对象
|
||||
|
||||
|
||||
* `event: Event`: Event 对象
|
||||
|
||||
|
||||
* `state: dict`: 当前 State
|
||||
|
||||
|
||||
|
||||
## _async_ `handle_event(bot, event)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
处理一个事件。调用该函数以实现分发事件。
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `bot: Bot`: Bot 对象
|
||||
|
||||
|
||||
* `event: Event`: Event 对象
|
||||
|
||||
|
||||
|
||||
* **示例**
|
||||
|
||||
|
||||
```python
|
||||
import asyncio
|
||||
asyncio.create_task(handle_event(bot, event))
|
||||
```
|
@@ -1,266 +0,0 @@
|
||||
---
|
||||
contentSidebar: true
|
||||
sidebarDepth: 0
|
||||
---
|
||||
|
||||
# NoneBot 模块
|
||||
|
||||
## 快捷导入
|
||||
|
||||
为方便使用,`nonebot` 模块从子模块导入了部分内容
|
||||
|
||||
|
||||
* `on_message` => `nonebot.plugin.on_message`
|
||||
|
||||
|
||||
* `on_notice` => `nonebot.plugin.on_notice`
|
||||
|
||||
|
||||
* `on_request` => `nonebot.plugin.on_request`
|
||||
|
||||
|
||||
* `on_metaevent` => `nonebot.plugin.on_metaevent`
|
||||
|
||||
|
||||
* `on_startswith` => `nonebot.plugin.on_startswith`
|
||||
|
||||
|
||||
* `on_endswith` => `nonebot.plugin.on_endswith`
|
||||
|
||||
|
||||
* `on_keyword` => `nonebot.plugin.on_keyword`
|
||||
|
||||
|
||||
* `on_command` => `nonebot.plugin.on_command`
|
||||
|
||||
|
||||
* `on_regex` => `nonebot.plugin.on_regex`
|
||||
|
||||
|
||||
* `CommandGroup` => `nonebot.plugin.CommandGroup`
|
||||
|
||||
|
||||
* `MatcherGroup` => `nonebot.plugin.MatcherGroup`
|
||||
|
||||
|
||||
* `load_plugin` => `nonebot.plugin.load_plugin`
|
||||
|
||||
|
||||
* `load_plugins` => `nonebot.plugin.load_plugins`
|
||||
|
||||
|
||||
* `load_builtin_plugins` => `nonebot.plugin.load_builtin_plugins`
|
||||
|
||||
|
||||
* `get_plugin` => `nonebot.plugin.get_plugin`
|
||||
|
||||
|
||||
* `get_loaded_plugins` => `nonebot.plugin.get_loaded_plugins`
|
||||
|
||||
|
||||
* `export` => `nonebot.plugin.export`
|
||||
|
||||
|
||||
* `require` => `nonebot.plugin.require`
|
||||
|
||||
|
||||
## `get_driver()`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
获取全局 Driver 对象。可用于在计划任务的回调中获取当前 Driver 对象。
|
||||
|
||||
|
||||
|
||||
* **返回**
|
||||
|
||||
|
||||
* `Driver`: 全局 Driver 对象
|
||||
|
||||
|
||||
|
||||
* **异常**
|
||||
|
||||
|
||||
* `ValueError`: 全局 Driver 对象尚未初始化 (nonebot.init 尚未调用)
|
||||
|
||||
|
||||
|
||||
* **用法**
|
||||
|
||||
|
||||
```python
|
||||
driver = nonebot.get_driver()
|
||||
```
|
||||
|
||||
|
||||
## `get_app()`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
获取全局 Driver 对应 Server App 对象。
|
||||
|
||||
|
||||
|
||||
* **返回**
|
||||
|
||||
|
||||
* `Any`: Server App 对象
|
||||
|
||||
|
||||
|
||||
* **异常**
|
||||
|
||||
|
||||
* `ValueError`: 全局 Driver 对象尚未初始化 (nonebot.init 尚未调用)
|
||||
|
||||
|
||||
|
||||
* **用法**
|
||||
|
||||
|
||||
```python
|
||||
app = nonebot.get_app()
|
||||
```
|
||||
|
||||
|
||||
## `get_asgi()`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
获取全局 Driver 对应 Asgi 对象。
|
||||
|
||||
|
||||
|
||||
* **返回**
|
||||
|
||||
|
||||
* `Any`: Asgi 对象
|
||||
|
||||
|
||||
|
||||
* **异常**
|
||||
|
||||
|
||||
* `ValueError`: 全局 Driver 对象尚未初始化 (nonebot.init 尚未调用)
|
||||
|
||||
|
||||
|
||||
* **用法**
|
||||
|
||||
|
||||
```python
|
||||
asgi = nonebot.get_asgi()
|
||||
```
|
||||
|
||||
|
||||
## `get_bots()`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
获取所有通过 ws 连接 NoneBot 的 Bot 对象。
|
||||
|
||||
|
||||
|
||||
* **返回**
|
||||
|
||||
|
||||
* `Dict[str, Bot]`: 一个以字符串 ID 为键,Bot 对象为值的字典
|
||||
|
||||
|
||||
|
||||
* **异常**
|
||||
|
||||
|
||||
* `ValueError`: 全局 Driver 对象尚未初始化 (nonebot.init 尚未调用)
|
||||
|
||||
|
||||
|
||||
* **用法**
|
||||
|
||||
|
||||
```python
|
||||
bots = nonebot.get_bots()
|
||||
```
|
||||
|
||||
|
||||
## `init(*, _env_file=None, **kwargs)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
初始化 NoneBot 以及 全局 Driver 对象。
|
||||
|
||||
NoneBot 将会从 .env 文件中读取环境信息,并使用相应的 env 文件配置。
|
||||
|
||||
你也可以传入自定义的 _env_file 来指定 NoneBot 从该文件读取配置。
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `_env_file: Optional[str]`: 配置文件名,默认从 .env.{env_name} 中读取配置
|
||||
|
||||
|
||||
* `**kwargs`: 任意变量,将会存储到 Config 对象里
|
||||
|
||||
|
||||
|
||||
* **返回**
|
||||
|
||||
|
||||
* `None`
|
||||
|
||||
|
||||
|
||||
* **用法**
|
||||
|
||||
|
||||
```python
|
||||
nonebot.init(database=Database(...))
|
||||
```
|
||||
|
||||
|
||||
## `run(host=None, port=None, *args, **kwargs)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
启动 NoneBot,即运行全局 Driver 对象。
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `host: Optional[str]`: 主机名/IP,若不传入则使用配置文件中指定的值
|
||||
|
||||
|
||||
* `port: Optional[int]`: 端口,若不传入则使用配置文件中指定的值
|
||||
|
||||
|
||||
* `*args`: 传入 Driver.run 的位置参数
|
||||
|
||||
|
||||
* `**kwargs`: 传入 Driver.run 的命名参数
|
||||
|
||||
|
||||
|
||||
* **返回**
|
||||
|
||||
|
||||
* `None`
|
||||
|
||||
|
||||
|
||||
* **用法**
|
||||
|
||||
|
||||
```python
|
||||
nonebot.run(host="127.0.0.1", port=8080)
|
||||
```
|
@@ -1,121 +0,0 @@
|
||||
---
|
||||
contentSidebar: true
|
||||
sidebarDepth: 0
|
||||
---
|
||||
|
||||
# NoneBot.permission 模块
|
||||
|
||||
## 权限
|
||||
|
||||
每个 `Matcher` 拥有一个 `Permission` ,其中是 **异步** `PermissionChecker` 的集合,只要有一个 `PermissionChecker` 检查结果为 `True` 时就会继续运行。
|
||||
|
||||
:::tip 提示
|
||||
`PermissionChecker` 既可以是 async function 也可以是 sync function
|
||||
:::
|
||||
|
||||
|
||||
## `MESSAGE`
|
||||
|
||||
|
||||
* **说明**: 匹配任意 `message` 类型事件,仅在需要同时捕获不同类型事件时使用。优先使用 message type 的 Matcher。
|
||||
|
||||
|
||||
## `NOTICE`
|
||||
|
||||
|
||||
* **说明**: 匹配任意 `notice` 类型事件,仅在需要同时捕获不同类型事件时使用。优先使用 notice type 的 Matcher。
|
||||
|
||||
|
||||
## `REQUEST`
|
||||
|
||||
|
||||
* **说明**: 匹配任意 `request` 类型事件,仅在需要同时捕获不同类型事件时使用。优先使用 request type 的 Matcher。
|
||||
|
||||
|
||||
## `METAEVENT`
|
||||
|
||||
|
||||
* **说明**: 匹配任意 `meta_event` 类型事件,仅在需要同时捕获不同类型事件时使用。优先使用 meta_event type 的 Matcher。
|
||||
|
||||
|
||||
## `USER(*user, perm=<nonebot.permission.Permission object>)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
在白名单内且满足 perm
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `*user: int`: 白名单
|
||||
|
||||
|
||||
* `perm: Permission`: 需要同时满足的权限
|
||||
|
||||
|
||||
|
||||
## `PRIVATE`
|
||||
|
||||
|
||||
* **说明**: 匹配任意私聊消息类型事件
|
||||
|
||||
|
||||
## `PRIVATE_FRIEND`
|
||||
|
||||
|
||||
* **说明**: 匹配任意好友私聊消息类型事件
|
||||
|
||||
|
||||
## `PRIVATE_GROUP`
|
||||
|
||||
|
||||
* **说明**: 匹配任意群临时私聊消息类型事件
|
||||
|
||||
|
||||
## `PRIVATE_OTHER`
|
||||
|
||||
|
||||
* **说明**: 匹配任意其他私聊消息类型事件
|
||||
|
||||
|
||||
## `GROUP`
|
||||
|
||||
|
||||
* **说明**: 匹配任意群聊消息类型事件
|
||||
|
||||
|
||||
## `GROUP_MEMBER`
|
||||
|
||||
|
||||
* **说明**: 匹配任意群员群聊消息类型事件
|
||||
|
||||
:::warning 警告
|
||||
该权限通过 event.sender 进行判断且不包含管理员以及群主!
|
||||
:::
|
||||
|
||||
|
||||
## `GROUP_ADMIN`
|
||||
|
||||
|
||||
* **说明**: 匹配任意群管理员群聊消息类型事件
|
||||
|
||||
|
||||
## `GROUP_OWNER`
|
||||
|
||||
|
||||
* **说明**: 匹配任意群主群聊消息类型事件
|
||||
|
||||
|
||||
## `SUPERUSER`
|
||||
|
||||
|
||||
* **说明**: 匹配任意超级用户消息类型事件
|
||||
|
||||
|
||||
## `EVERYBODY`
|
||||
|
||||
|
||||
* **说明**: 匹配任意消息类型事件
|
File diff suppressed because it is too large
Load Diff
@@ -1,210 +0,0 @@
|
||||
---
|
||||
contentSidebar: true
|
||||
sidebarDepth: 0
|
||||
---
|
||||
|
||||
# NoneBot.rule 模块
|
||||
|
||||
## 规则
|
||||
|
||||
每个事件响应器 `Matcher` 拥有一个匹配规则 `Rule` ,其中是 **异步** `RuleChecker` 的集合,只有当所有 `RuleChecker` 检查结果为 `True` 时继续运行。
|
||||
|
||||
:::tip 提示
|
||||
`RuleChecker` 既可以是 async function 也可以是 sync function,但在最终会被 `nonebot.utils.run_sync` 转换为 async function
|
||||
:::
|
||||
|
||||
|
||||
## _class_ `Rule`
|
||||
|
||||
基类:`object`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
`Matcher` 规则类,当事件传递时,在 `Matcher` 运行前进行检查。
|
||||
|
||||
|
||||
|
||||
* **示例**
|
||||
|
||||
|
||||
```python
|
||||
Rule(async_function) & sync_function
|
||||
# 等价于
|
||||
from nonebot.utils import run_sync
|
||||
Rule(async_function, run_sync(sync_function))
|
||||
```
|
||||
|
||||
|
||||
### `__init__(*checkers)`
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `*checkers: Callable[[Bot, Event, dict], Awaitable[bool]]`: **异步** RuleChecker
|
||||
|
||||
|
||||
|
||||
### `checkers`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
存储 `RuleChecker`
|
||||
|
||||
|
||||
|
||||
* **类型**
|
||||
|
||||
|
||||
* `Set[Callable[[Bot, Event, dict], Awaitable[bool]]]`
|
||||
|
||||
|
||||
|
||||
### _async_ `__call__(bot, event, state)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
检查是否符合所有规则
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `bot: Bot`: Bot 对象
|
||||
|
||||
|
||||
* `event: Event`: Event 对象
|
||||
|
||||
|
||||
* `state: dict`: 当前 State
|
||||
|
||||
|
||||
|
||||
* **返回**
|
||||
|
||||
|
||||
* `bool`
|
||||
|
||||
|
||||
|
||||
## `startswith(msg)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
匹配消息开头
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `msg: str`: 消息开头字符串
|
||||
|
||||
|
||||
|
||||
## `endswith(msg)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
匹配消息结尾
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `msg: str`: 消息结尾字符串
|
||||
|
||||
|
||||
|
||||
## `keyword(*keywords)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
匹配消息关键词
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `*keywords: str`: 关键词
|
||||
|
||||
|
||||
|
||||
## `command(*cmds)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
命令形式匹配,根据配置里提供的 `command_start`, `command_sep` 判断消息是否为命令。
|
||||
|
||||
可以通过 `state["_prefix"]["command"]` 获取匹配成功的命令(例:`("test",)`),通过 `state["_prefix"]["raw_command"]` 获取匹配成功的原始命令文本(例:`"/test"`)。
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `*cmds: Union[str, Tuple[str, ...]]`: 命令内容
|
||||
|
||||
|
||||
|
||||
* **示例**
|
||||
|
||||
使用默认 `command_start`, `command_sep` 配置
|
||||
|
||||
命令 `("test",)` 可以匹配:`/test` 开头的消息
|
||||
命令 `("test", "sub")` 可以匹配”`/test.sub` 开头的消息
|
||||
|
||||
|
||||
:::tip 提示
|
||||
命令内容与后续消息间无需空格!
|
||||
:::
|
||||
|
||||
|
||||
## `regex(regex, flags=0)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
根据正则表达式进行匹配。
|
||||
|
||||
可以通过 `state["_matched"]` 获取正则表达式匹配成功的文本。
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `regex: str`: 正则表达式
|
||||
|
||||
|
||||
* `flags: Union[int, re.RegexFlag]`: 正则标志
|
||||
|
||||
|
||||
:::tip 提示
|
||||
正则表达式匹配使用 search 而非 match,如需从头匹配请使用 `r"^xxx"` 来确保匹配开头
|
||||
:::
|
||||
|
||||
|
||||
## `to_me()`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
通过 `event.to_me` 判断消息是否是发送给机器人
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* 无
|
@@ -1,300 +0,0 @@
|
||||
---
|
||||
contentSidebar: true
|
||||
sidebarDepth: 0
|
||||
---
|
||||
|
||||
# NoneBot.typing 模块
|
||||
|
||||
## 类型
|
||||
|
||||
下面的文档中,「类型」部分使用 Python 的 Type Hint 语法,见 [PEP 484](https://www.python.org/dev/peps/pep-0484/)、[PEP 526](https://www.python.org/dev/peps/pep-0526/) 和 [typing](https://docs.python.org/3/library/typing.html)。
|
||||
|
||||
除了 Python 内置的类型,下面还出现了如下 NoneBot 自定类型,实际上它们是 Python 内置类型的别名。
|
||||
|
||||
以下类型均可从 nonebot.typing 模块导入。
|
||||
|
||||
|
||||
## `Driver`
|
||||
|
||||
|
||||
* **类型**
|
||||
|
||||
`BaseDriver`
|
||||
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
所有 Driver 的基类。
|
||||
|
||||
|
||||
|
||||
|
||||
## `WebSocket`
|
||||
|
||||
|
||||
* **类型**
|
||||
|
||||
`BaseWebSocket`
|
||||
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
所有 WebSocket 的基类。
|
||||
|
||||
|
||||
|
||||
|
||||
## `Bot`
|
||||
|
||||
|
||||
* **类型**
|
||||
|
||||
`BaseBot`
|
||||
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
所有 Bot 的基类。
|
||||
|
||||
|
||||
|
||||
|
||||
## `Event`
|
||||
|
||||
|
||||
* **类型**
|
||||
|
||||
`BaseEvent`
|
||||
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
所有 Event 的基类。
|
||||
|
||||
|
||||
|
||||
|
||||
## `Message`
|
||||
|
||||
|
||||
* **类型**
|
||||
|
||||
`BaseMessage`
|
||||
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
所有 Message 的基类。
|
||||
|
||||
|
||||
|
||||
|
||||
## `MessageSegment`
|
||||
|
||||
|
||||
* **类型**
|
||||
|
||||
`BaseMessageSegment`
|
||||
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
所有 MessageSegment 的基类。
|
||||
|
||||
|
||||
|
||||
|
||||
## `EventPreProcessor`
|
||||
|
||||
|
||||
* **类型**
|
||||
|
||||
`Callable[[Bot, Event, dict], Union[Awaitable[None], Awaitable[NoReturn]]]`
|
||||
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
事件预处理函数 EventPreProcessor 类型
|
||||
|
||||
|
||||
|
||||
|
||||
## `EventPostProcessor`
|
||||
|
||||
|
||||
* **类型**
|
||||
|
||||
`Callable[[Bot, Event, dict], Union[Awaitable[None], Awaitable[NoReturn]]]`
|
||||
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
事件预处理函数 EventPostProcessor 类型
|
||||
|
||||
|
||||
|
||||
|
||||
## `RunPreProcessor`
|
||||
|
||||
|
||||
* **类型**
|
||||
|
||||
`Callable[[Matcher, Bot, Event, dict], Union[Awaitable[None], Awaitable[NoReturn]]]`
|
||||
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
事件响应器运行前预处理函数 RunPreProcessor 类型
|
||||
|
||||
|
||||
|
||||
|
||||
## `RunPostProcessor`
|
||||
|
||||
|
||||
* **类型**
|
||||
|
||||
`Callable[[Matcher, Optional[Exception], Bot, Event, dict], Union[Awaitable[None], Awaitable[NoReturn]]]`
|
||||
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
事件响应器运行前预处理函数 RunPostProcessor 类型,第二个参数为运行时产生的错误(如果存在)
|
||||
|
||||
|
||||
|
||||
|
||||
## `Matcher`
|
||||
|
||||
|
||||
* **类型**
|
||||
|
||||
`Matcher`
|
||||
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
Matcher 即响应事件的处理类。通过 Rule 判断是否响应事件,运行 Handler。
|
||||
|
||||
|
||||
|
||||
|
||||
## `MatcherGroup`
|
||||
|
||||
|
||||
* **类型**
|
||||
|
||||
`MatcherGroup`
|
||||
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
MatcherGroup 为 Matcher 的集合。可以共享 Handler。
|
||||
|
||||
|
||||
|
||||
|
||||
## `Rule`
|
||||
|
||||
|
||||
* **类型**
|
||||
|
||||
`Rule`
|
||||
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
Rule 即判断是否响应事件的处理类。内部存储 RuleChecker ,返回全为 True 则响应事件。
|
||||
|
||||
|
||||
|
||||
|
||||
## `RuleChecker`
|
||||
|
||||
|
||||
* **类型**
|
||||
|
||||
`Callable[[Bot, Event, dict], Union[bool, Awaitable[bool]]]`
|
||||
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
RuleChecker 即判断是否响应事件的处理函数。
|
||||
|
||||
|
||||
|
||||
|
||||
## `Permission`
|
||||
|
||||
|
||||
* **类型**
|
||||
|
||||
`Permission`
|
||||
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
Permission 即判断是否响应消息的处理类。内部存储 PermissionChecker ,返回只要有一个 True 则响应消息。
|
||||
|
||||
|
||||
|
||||
|
||||
## `PermissionChecker`
|
||||
|
||||
|
||||
* **类型**
|
||||
|
||||
`Callable[[Bot, Event], Union[bool, Awaitable[bool]]]`
|
||||
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
RuleChecker 即判断是否响应消息的处理函数。
|
||||
|
||||
|
||||
|
||||
|
||||
## `Handler`
|
||||
|
||||
|
||||
* **类型**
|
||||
|
||||
`Callable[[Bot, Event, dict], Union[Awaitable[None], Awaitable[NoReturn]]]`
|
||||
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
Handler 即事件的处理函数。
|
||||
|
||||
|
||||
|
||||
|
||||
## `ArgsParser`
|
||||
|
||||
|
||||
* **类型**
|
||||
|
||||
`Callable[[Bot, Event, dict], Union[Awaitable[None], Awaitable[NoReturn]]]`
|
||||
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
ArgsParser 即消息参数解析函数,在 Matcher.got 获取参数时被运行。
|
@@ -1,60 +0,0 @@
|
||||
---
|
||||
contentSidebar: true
|
||||
sidebarDepth: 0
|
||||
---
|
||||
|
||||
# NoneBot.utils 模块
|
||||
|
||||
|
||||
## `escape_tag(s)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
用于记录带颜色日志时转义 `<tag>` 类型特殊标签
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `s: str`: 需要转义的字符串
|
||||
|
||||
|
||||
|
||||
* **返回**
|
||||
|
||||
|
||||
* `str`
|
||||
|
||||
|
||||
|
||||
## `run_sync(func)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
一个用于包装 sync function 为 async function 的装饰器
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `func: Callable[..., Any]`: 被装饰的同步函数
|
||||
|
||||
|
||||
|
||||
* **返回**
|
||||
|
||||
|
||||
* `Callable[..., Awaitable[Any]]`
|
||||
|
||||
|
||||
|
||||
## _class_ `DataclassEncoder`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
在JSON序列化 `Message` (List[Dataclass]) 时使用的 `JSONEncoder`
|
@@ -1,33 +0,0 @@
|
||||
# 概览
|
||||
|
||||
<!-- :::tip 提示
|
||||
如果在阅读本文档时遇到难以理解的词汇,请随时查阅 [术语表](../glossary.md) 或使用 [Google 搜索](https://www.google.com/)。
|
||||
::: -->
|
||||
|
||||
:::tip 提示
|
||||
初次使用时可能会觉得这里的概览过于枯燥,可以先简单略读之后直接前往 [安装](./installation.md) 查看安装方法,并进行后续的基础使用教程。
|
||||
:::
|
||||
|
||||
## 简介
|
||||
|
||||
NoneBot2 是一个可扩展的 Python 异步机器人框架,它会对机器人收到的事件进行解析和处理,并以插件化的形式,按优先级分发给事件所对应的事件响应器,来完成具体的功能。
|
||||
|
||||
除了起到解析事件的作用,NoneBot 还为插件提供了大量实用的预设操作和权限控制机制。对于命令处理,它更是提供了完善且易用的会话机制和内部调用机制,以分别适应命令的连续交互和插件内部功能复用等需求。
|
||||
|
||||
得益于 Python 的 [asyncio](https://docs.python.org/3/library/asyncio.html) 机制,NoneBot 处理事件的吞吐量有了很大的保障,再配合 WebSocket 通信方式(也是最建议的通信方式),NoneBot 的性能可以达到 HTTP 通信方式的两倍以上,相较于传统同步 I/O 的 HTTP 通信,更是有质的飞跃。
|
||||
|
||||
需要注意的是,NoneBot 仅支持 **Python 3.7+**
|
||||
|
||||
## 特色
|
||||
|
||||
NoneBot2 的驱动框架 `Driver` 以及通信协议 `Adapter` 均可**自定义**,并且可以作为插件进行**替换/添加**!
|
||||
|
||||
- 提供使用简易的脚手架
|
||||
- 提供丰富的官方插件
|
||||
- 提供可添加/替换的驱动以及协议选项
|
||||
- 基于异步 I/O
|
||||
- 同时支持 HTTP 和反向 WebSocket 通信方式
|
||||
- 支持多个机器人账号负载均衡
|
||||
- 提供直观的交互式会话接口
|
||||
- 提供可自定义的权限控制机制
|
||||
- 多种方式渲染要发送的消息内容,使对话足够自然
|
@@ -1,68 +0,0 @@
|
||||
# 基本配置
|
||||
|
||||
到目前为止我们还在使用 NoneBot 的默认行为,在开始编写自己的插件之前,我们先尝试在配置文件上动动手脚,让 NoneBot 表现出不同的行为。
|
||||
|
||||
在上一章节中,我们创建了默认的项目结构,其中 `.env`, `.env.*` 均为项目的配置文件,下面将介绍几种 NoneBot 配置方式。
|
||||
|
||||
:::danger 警告
|
||||
请勿将敏感信息写入配置文件并提交至开源仓库!
|
||||
:::
|
||||
|
||||
## .env 文件
|
||||
|
||||
NoneBot 在启动时将会从系统环境变量或者 `.env` 文件中寻找变量 `ENVIRONMENT` (大小写不敏感),默认值为 `prod`。
|
||||
这将引导 NoneBot 从系统环境变量或者 `.env.{ENVIRONMENT}` 文件中进一步加载具体配置。
|
||||
|
||||
现在,我们在 `.env` 文件中写入当前环境信息
|
||||
|
||||
```bash
|
||||
# .env
|
||||
ENVIRONMENT=dev
|
||||
```
|
||||
|
||||
## .env.\* 文件
|
||||
|
||||
详细配置文件,使用 [pydantic](https://pydantic-docs.helpmanual.io/) 加载配置。在 NoneBot 初始化时可以指定忽略 `.env` 中的环境信息转而加载某个配置文件: `nonebot.init(_env_file=".env.dev")`。
|
||||
|
||||
:::warning 提示
|
||||
由于 `pydantic` 使用 JSON 加载配置项,请确保配置项值为 JSON 能够解析的数据。如果 JSON 解析失败将作为字符串处理。
|
||||
:::
|
||||
|
||||
示例及说明:
|
||||
|
||||
```bash
|
||||
HOST=0.0.0.0 # 配置 NoneBot 监听的 IP/主机名
|
||||
PORT=8080 # 配置 NoneBot 监听的端口
|
||||
DEBUG=true # 开启 debug 模式 **请勿在生产环境开启**
|
||||
SUPERUSERS=["123456789", "987654321"] # 配置 NoneBot 超级用户
|
||||
NICKNAME=["awesome", "bot"] # 配置机器人的昵称
|
||||
COMMAND_START=["/", ""] # 配置命令起始字符
|
||||
COMMAND_SEP=["."] # 配置命令分割字符
|
||||
|
||||
# Custom Configs
|
||||
CUSTOM_CONFIG1="config in env file"
|
||||
CUSTOM_CONFIG2= # 留空则从系统环境变量读取,如不存在则为空字符串
|
||||
```
|
||||
|
||||
详细的配置项参考 [Config Reference](../api/config.md) 。
|
||||
|
||||
## bot.py 文件
|
||||
|
||||
配置项也可以在 NoneBot 初始化时传入。此处可以传入任意合法 Python 变量。当然也可以在初始化完成后修改或新增。
|
||||
|
||||
示例:
|
||||
|
||||
```python
|
||||
# bot.py
|
||||
import nonebot
|
||||
|
||||
nonebot.init(custom_config3="config on init")
|
||||
|
||||
config = nonebot.get_driver().config
|
||||
config.custom_config3 = "changed after init"
|
||||
config.custom_config4 = "new config after init"
|
||||
```
|
||||
|
||||
## 优先级
|
||||
|
||||
`bot.py init` > `env file` > `system env`
|
@@ -1,159 +0,0 @@
|
||||
# 事件处理
|
||||
|
||||
在上一章中,我们已经注册了事件响应器,现在我们可以正式编写事件处理逻辑了!
|
||||
|
||||
## [事件处理函数](../api/typing.md#handler)
|
||||
|
||||
```python{1,2,8,9}
|
||||
@weather.handle()
|
||||
async def handle_first_receive(bot: Bot, event: Event, state: dict):
|
||||
args = str(event.message).strip() # 首次发送命令时跟随的参数,例:/天气 上海,则args为上海
|
||||
if args:
|
||||
state["city"] = args # 如果用户发送了参数则直接赋值
|
||||
|
||||
|
||||
@weather.got("city", prompt="你想查询哪个城市的天气呢?")
|
||||
async def handle_city(bot: Bot, event: Event, state: dict):
|
||||
city = state["city"]
|
||||
if city not in ["上海", "北京"]:
|
||||
await weather.reject("你想查询的城市暂不支持,请重新输入!")
|
||||
city_weather = await get_weather(city)
|
||||
await weather.finish(city_weather)
|
||||
```
|
||||
|
||||
在之前的样例中,我们定义了两个函数 `handle_first_receive`, `handle_city`,他们被事件响应器的装饰器装饰从而成为事件响应器的事件处理函数。
|
||||
|
||||
:::tip 提示
|
||||
在事件响应器中,事件处理函数是**顺序**执行的!
|
||||
:::
|
||||
|
||||
### 添加一个事件处理函数
|
||||
|
||||
事件响应器提供了三种装饰事件处理函数的装饰器,分别是:
|
||||
|
||||
1. [handle()](../api/matcher.md#classmethod-handle)
|
||||
2. [receive()](../api/matcher.md#classmethod-receive)
|
||||
3. [got(key, prompt, args_parser)](../api/matcher.md#classmethod-got-key-prompt-none-args-parser-none)
|
||||
|
||||
#### handle()
|
||||
|
||||
简单的为事件响应器添加一个事件处理函数,这个函数将会在上一个处理函数正常返回执行完毕后立即执行。
|
||||
|
||||
#### receive()
|
||||
|
||||
指示 NoneBot 接收一条新的用户消息后继续执行该处理函数。此时函数将会接收到新的消息而非前一条消息,之前相关信息可以存储在 state 中。
|
||||
|
||||
特别的,当装饰的函数前没有其他事件处理函数,那么 `receive()` 不会接收一条新的消息而是直接使用第一条接收到的消息。
|
||||
|
||||
#### got(key, prompt, args_parser)
|
||||
|
||||
指示 NoneBot 当 `state` 中不存在 `key` 时向用户发送 `prompt` 等待用户回复并赋值给 `state[key]`。
|
||||
|
||||
`prompt` 可以为 `str`, `Message`, `MessageSegment`,若为空则不会向用户发送,若不为空则会在 format 之后发送,即 `prompt.format(**state)`,注意对 `{}` 进行转义。示例:
|
||||
|
||||
```python
|
||||
@matcher.receive()
|
||||
async def handle(bot: Bot, event: Event, state: dict):
|
||||
state["key"] = "hello"
|
||||
|
||||
|
||||
@matcher.got("key2", prompt="{key}!")
|
||||
async def handle2(bot: Bot, event: Event, state: dict):
|
||||
pass
|
||||
```
|
||||
|
||||
`args_parser` 为参数处理函数,在这里传入一个新的函数以覆盖默认的参数处理。详情参照 [args_parser](#参数处理函数-args-parser)
|
||||
|
||||
特别的,这些装饰器都可以套娃使用:
|
||||
|
||||
```python
|
||||
@matcher.got("key1")
|
||||
@matcher.got("key2")
|
||||
async def handle(bot: Bot, event: Event, state: dict):
|
||||
pass
|
||||
```
|
||||
|
||||
### 事件处理函数参数
|
||||
|
||||
事件处理函数类型为 `Callable[[Bot, Event, dict], Union[Awaitable[None], Awaitable[NoReturn]]]` 。
|
||||
|
||||
参数分别为:
|
||||
|
||||
1. [nonebot.typing.Bot](../api/typing.md#bot): 即事件上报连接对应的 Bot 对象,为 BaseBot 的子类。特别注意,此处的类型注释可以替换为指定的 Bot 类型,例如:`nonebot.adapters.cqhttp.Bot`,只有在上报事件的 Bot 类型与类型注释相符时才会执行该处理函数!可用于多平台进行不同的处理。
|
||||
2. [nonebot.typing.Event](../api/typing.md#event): 即上报事件对象,可以获取到上报的所有信息。
|
||||
3. `state`: 状态字典,可以存储任意的信息,其中还包含一些特殊的值以获取 NoneBot 内部处理时的一些信息,如:
|
||||
|
||||
- `state["_current_key"]`: 存储当前 `got` 获取的参数名
|
||||
- `state["_prefix"]`, `state["_suffix"]`: 存储当前 TRIE 匹配的前缀/后缀,可以通过该值获取用户命令的原始命令
|
||||
|
||||
### 参数处理函数 args_parser
|
||||
|
||||
在使用 `got` 获取用户输入参数时,需要对用户的消息进行处理以转换为我们所需要的信息。在默认情况下,NoneBot 会把用户的消息字符串原封不动的赋值给 `state[key]` 。可以通过以下两种方式修改默认处理逻辑:
|
||||
|
||||
- `@matcher.args_parser` 装饰器:直接装饰一个函数作为参数处理器
|
||||
- `got(key, prompt, args_parser)`:直接把函数作为参数传入
|
||||
|
||||
参数处理函数类型为:`Callable[[Bot, Event, dict], Union[Awaitable[None], Awaitable[NoReturn]]]`,即:
|
||||
|
||||
```python
|
||||
async def parser(bot: Bot, event: Event, state: dict):
|
||||
state[state["_current_key"]] = str(event.message)
|
||||
```
|
||||
|
||||
特别的,`state["_current_key"]` 中存储了当前获取的参数名
|
||||
|
||||
### 逻辑控制
|
||||
|
||||
NoneBot 也为事件处理函数提供了一些便捷的逻辑控制函数:
|
||||
|
||||
#### `matcher.send`
|
||||
|
||||
这个函数用于发送一条消息给当前交互的用户。~~其实这并不是一个逻辑控制函数,只是不知道放在哪里……~~
|
||||
|
||||
#### `matcher.pause`
|
||||
|
||||
这个函数用于结束当前事件处理函数,强制接收一条新的消息再运行**下一个消息处理函数**。
|
||||
|
||||
#### `matcher.reject`
|
||||
|
||||
这个函数用于结束当前事件处理函数,强制接收一条新的消息再**再次运行当前消息处理函数**。常用于用户输入信息不符合预期。
|
||||
|
||||
#### `matcher.finish`
|
||||
|
||||
这个函数用于直接结束当前事件处理。
|
||||
|
||||
以上三个函数都拥有一个参数 `message` / `prompt`,用于向用户发送一条消息。以及 `**kwargs` 直接传递给 `bot.send` 的额外参数。
|
||||
|
||||
## 常用事件处理结构
|
||||
|
||||
```python
|
||||
matcher = on_command("test")
|
||||
|
||||
# 修改默认参数处理
|
||||
@matcher.args_parser
|
||||
async def parse(bot: Bot, event: Event, state: dict):
|
||||
print(state["_current_key"], ":", str(event.message))
|
||||
state[state["_current_key"]] = str(event.message)
|
||||
|
||||
@matcher.handle()
|
||||
async def first_receive(bot: Bot, event: Event, state: dict):
|
||||
# 获取用户原始命令,如:/test
|
||||
print(state["_prefix"]["raw_command"])
|
||||
# 处理用户输入参数,如:/test arg1 arg2
|
||||
raw_args = str(event.message).strip()
|
||||
if raw_args:
|
||||
arg_list = raw_args.split()
|
||||
# 将参数存入state以阻止后续再向用户询问参数
|
||||
state["arg1"] = arg_list[0]
|
||||
|
||||
|
||||
@matcher.got("arg1", prompt="参数?")
|
||||
async def arg_handle(bot: Bot, event: Event, state: dict):
|
||||
# 在这里对参数进行验证
|
||||
if state["arg1"] not in ["allow", "list"]:
|
||||
await matcher.reject("参数不正确!请重新输入")
|
||||
# 发送一些信息
|
||||
await bot.send(event, "message")
|
||||
await matcher.send("message")
|
||||
await matcher.finish("message")
|
||||
```
|
@@ -1,144 +0,0 @@
|
||||
# 注册事件响应器
|
||||
|
||||
好了,现在插件已经创建完毕,我们可以开始编写实际代码了,下面将以一个简易单文件天气查询插件为例。
|
||||
|
||||
在插件目录下 `weather.py` 中添加如下代码:
|
||||
|
||||
```python
|
||||
from nonebot import on_command
|
||||
from nonebot.rule import to_me
|
||||
from nonebot.adapters.cqhttp import Bot, Event
|
||||
|
||||
weather = on_command("天气", rule=to_me(), priority=5)
|
||||
|
||||
|
||||
@weather.handle()
|
||||
async def handle_first_receive(bot: Bot, event: Event, state: dict):
|
||||
args = str(event.message).strip() # 首次发送命令时跟随的参数,例:/天气 上海,则args为上海
|
||||
if args:
|
||||
state["city"] = args # 如果用户发送了参数则直接赋值
|
||||
|
||||
|
||||
@weather.got("city", prompt="你想查询哪个城市的天气呢?")
|
||||
async def handle_city(bot: Bot, event: Event, state: dict):
|
||||
city = state["city"]
|
||||
if city not in ["上海", "北京"]:
|
||||
await weather.reject("你想查询的城市暂不支持,请重新输入!")
|
||||
city_weather = await get_weather(city)
|
||||
await weather.finish(city_weather)
|
||||
|
||||
|
||||
async def get_weather(city: str):
|
||||
return f"{city}的天气是..."
|
||||
```
|
||||
|
||||
为了简单起见,我们在这里的例子中没有接入真实的天气数据,但要接入也非常简单,你可以使用中国天气网、和风天气等网站提供的 API。
|
||||
|
||||
接下来我们来说明这段代码是如何工作的。
|
||||
|
||||
:::tip 提示
|
||||
从这里开始,你需要对 Python 的 asyncio 编程有所了解,因为 NoneBot 是完全基于 asyncio 的,具体可以参考 [廖雪峰的 Python 教程](https://www.liaoxuefeng.com/wiki/1016959663602400/1017959540289152)
|
||||
:::
|
||||
|
||||
## [事件响应器](../api/matcher.md)
|
||||
|
||||
```python{4}
|
||||
from nonebot import on_command
|
||||
from nonebot.rule import to_me
|
||||
from nonebot.permission import Permission
|
||||
|
||||
weather = on_command("天气", rule=to_me(), permission=Permission(), priority=5)
|
||||
```
|
||||
|
||||
在上方代码中,我们注册了一个事件响应器 `Matcher`,它由几个部分组成:
|
||||
|
||||
1. `on_command` 注册一个消息类型的命令处理器
|
||||
2. `"天气"` 指定 command 参数 - 命令名
|
||||
3. `rule` 补充事件响应器的匹配规则
|
||||
4. `priority` 事件响应器优先级
|
||||
5. `block` 是否阻止事件传递
|
||||
|
||||
其他详细配置可以参考 API 文档,下面我们详细说明各个部分:
|
||||
|
||||
### 事件响应器类型 type
|
||||
|
||||
事件响应器类型其实就是对应事件的类型 `Event.type` ,NoneBot 提供了一个基础类型事件响应器 `on()` 以及一些其他内置的事件响应器。
|
||||
|
||||
以下所有类型的事件响应器都是由 `on(type, rule)` 的形式进行了简化封装。
|
||||
|
||||
- `on("事件类型")`: 基础事件响应器,第一个参数为事件类型,空字符串表示不限
|
||||
- `on_metaevent()` ~ `on("meta_event")`: 元事件响应器
|
||||
- `on_message()` ~ `on("message")`: 消息事件响应器
|
||||
- `on_request()` ~ `on("request")`: 请求事件响应器
|
||||
- `on_notice()` ~ `on("notice")`: 通知事件响应器
|
||||
- `on_startswith(str)` ~ `on("message", startswith(str))`: 消息开头匹配响应器,参考 [startswith](../api/rule.md#startswith-msg)
|
||||
- `on_endswith(str)` ~ `on("message", endswith(str))`: 消息结尾匹配响应器,参考 [endswith](../api/rule.md#endswith-msg)
|
||||
- `on_keyword(set)` ~ `on("message", keyword(str))`: 消息关键词匹配响应器,参考 [keyword](../api/rule.md#keyword-keywords)
|
||||
- `on_command(str|tuple)` ~ `on("message", command(str|tuple))`: 命令响应器,参考 [command](../api/rule.md#command-cmds)
|
||||
- `on_regex(pattern_str)` ~ `on("message", regex(pattern_str))`: 正则匹配处理器,参考 [regex](../api/rule.md#regex-regex-flags-0)
|
||||
|
||||
### 匹配规则 rule
|
||||
|
||||
事件响应器的匹配规则即 `Rule`,详细内容在下方介绍。[直达](#自定义-rule)
|
||||
|
||||
### 优先级 priority
|
||||
|
||||
事件响应器的优先级代表事件响应器的执行顺序,同一优先级的事件响应器会 **同时执行!**,优先级数字**越小**越先响应!优先级请从 `1` 开始排序!
|
||||
|
||||
:::tip 提示
|
||||
使用 `nonebot-test` 可以看到当前所有事件响应器的执行流程,有助理解事件响应流程!
|
||||
|
||||
```bash
|
||||
pip install nonebot2[test]
|
||||
```
|
||||
|
||||
:::
|
||||
|
||||
### 阻断 block
|
||||
|
||||
当有任意事件响应器发出了阻止事件传递信号时,该事件将不再会传递给下一优先级,直接结束处理。
|
||||
|
||||
NoneBot 内置的事件响应器中,所有 `message` 类的事件响应器默认会阻断事件传递,其他则不会。
|
||||
|
||||
## 自定义 rule
|
||||
|
||||
rule 的出现使得 nonebot 对事件的响应可以非常自由,nonebot 内置了一些规则:
|
||||
|
||||
- [startswith(msg)](../api/rule.md#startswith-msg)
|
||||
- [endswith(msg)](../api/rule.md#endswith-msg)
|
||||
- [keyword(\*keywords)](../api/rule.md#keyword-keywords)
|
||||
- [command(\*cmds)](../api/rule.md#command-cmds)
|
||||
- [regex(regex, flag)](../api/rule.md#regex-regex-flags-0)
|
||||
|
||||
以上规则都是返回类型为 `Rule` 的函数,`Rule` 由非负个 `RuleChecker` 组成,当所有 `RuleChecker` 返回 `True` 时匹配成功。这些 `Rule`, `RuleChecker` 的形式如下:
|
||||
|
||||
```python
|
||||
from nonebot.rule import Rule
|
||||
|
||||
async def async_checker(bot: Bot, event: Event, state: dict) -> bool:
|
||||
return True
|
||||
|
||||
def sync_checker(bot: Bot, event: Event, state: dict) -> bool:
|
||||
return True
|
||||
|
||||
def check(arg1, args2):
|
||||
|
||||
async def _checker(bot: Bot, event: Event, state: dict) -> bool:
|
||||
return bool(arg1 + arg2)
|
||||
|
||||
return Rule(_check)
|
||||
```
|
||||
|
||||
`Rule` 和 `RuleChecker` 之间可以使用 `与 &` 互相组合:
|
||||
|
||||
```python
|
||||
from nonebot.rule import Rule
|
||||
|
||||
Rule(async_checker1) & sync_checker & async_checker2
|
||||
```
|
||||
|
||||
**_请勿将事件处理的逻辑写入 `rule` 中,这会使得事件处理返回奇怪的响应。_**
|
||||
|
||||
:::danger 警告
|
||||
`Rule(*checkers)` 只接受 async function,或使用 `nonebot.utils.run_sync` 自行包裹 sync function。在使用 `与 &` 时,NoneBot 会自动包裹 sync function
|
||||
:::
|
@@ -1,119 +0,0 @@
|
||||
# 创建插件
|
||||
|
||||
如果之前使用 `nb-cli` 生成了项目结构,那我们已经有了一个空的插件目录 `Awesome-Bot/awesome_bot/plugins`,并且它已在 `bot.py` 中被加载,我们现在可以开始创建插件了!
|
||||
|
||||
使用 `nb-cli` 创建包形式插件,或自行创建文件(夹)
|
||||
|
||||
```bash
|
||||
nb plugin new
|
||||
```
|
||||
|
||||
插件通常有两种形式,下面分别介绍
|
||||
|
||||
## 单文件形式
|
||||
|
||||
在插件目录下创建名为 `foo.py` 的 Python 文件,暂时留空,此时目录结构如下:
|
||||
|
||||
<!-- prettier-ignore-start -->
|
||||
:::vue
|
||||
AweSome-Bot
|
||||
├── awesome_bot
|
||||
│ └── plugins
|
||||
│ └── `foo.py`
|
||||
├── .env
|
||||
├── .env.dev
|
||||
├── .env.prod
|
||||
├── .gitignore
|
||||
├── bot.py
|
||||
├── docker-compose.yml
|
||||
├── Dockerfile
|
||||
├── pyproject.toml
|
||||
└── README.md
|
||||
:::
|
||||
<!-- prettier-ignore-end -->
|
||||
|
||||
这个时候它已经可以被称为一个插件了,尽管它还什么都没做。
|
||||
|
||||
## 包形式(推荐)
|
||||
|
||||
在插件目录下创建文件夹 `foo`,并在该文件夹下创建文件 `__init__.py`,此时目录结构如下:
|
||||
|
||||
<!-- prettier-ignore-start -->
|
||||
:::vue
|
||||
AweSome-Bot
|
||||
├── awesome_bot
|
||||
│ └── plugins
|
||||
│ └── `foo`
|
||||
│ └── `__init__.py`
|
||||
├── .env
|
||||
├── .env.dev
|
||||
├── .env.prod
|
||||
├── .gitignore
|
||||
├── bot.py
|
||||
├── docker-compose.yml
|
||||
├── Dockerfile
|
||||
├── pyproject.toml
|
||||
└── README.md
|
||||
:::
|
||||
<!-- prettier-ignore-end -->
|
||||
|
||||
这个时候 `foo` 就是一个合法的 Python 包了,同时也是合法的 NoneBot 插件,插件内容可以在 `__init__.py` 中编写。
|
||||
|
||||
### 推荐结构(仅供参考)
|
||||
|
||||
<!-- prettier-ignore-start -->
|
||||
:::vue
|
||||
foo
|
||||
├── `__init__.py`
|
||||
├── `config.py`
|
||||
├── `data_source.py`
|
||||
└── `model.py`
|
||||
:::
|
||||
<!-- prettier-ignore-end -->
|
||||
|
||||
#### \_\_init\_\_.py
|
||||
|
||||
在该文件中编写各类事件响应及处理逻辑。
|
||||
|
||||
#### config.py
|
||||
|
||||
在该文件中使用 `pydantic` 定义插件所需要的配置项以及类型。
|
||||
|
||||
示例:
|
||||
|
||||
```python
|
||||
from pydantic import BaseSetting
|
||||
|
||||
|
||||
class Config(BaseSetting):
|
||||
|
||||
# plugin custom config
|
||||
plugin_setting: str = "default"
|
||||
|
||||
class Config:
|
||||
extra = "ignore"
|
||||
```
|
||||
|
||||
并在 `__init__.py` 文件中添加以下行
|
||||
|
||||
```python
|
||||
import nonebot
|
||||
from .config import Config
|
||||
|
||||
global_config = nonebot.get_driver().config
|
||||
plugin_config = Config(**global_config.dict())
|
||||
```
|
||||
|
||||
此时就可以通过 `plugin_config.plugin_setting` 获取到插件所需要的配置项了。
|
||||
|
||||
#### data_source.py
|
||||
|
||||
在该文件中编写数据获取函数。
|
||||
|
||||
:::warning 警告
|
||||
数据获取应尽量使用**异步**处理!例如使用 [httpx](https://www.python-httpx.org/) 而非 [requests](https://requests.readthedocs.io/en/master/)
|
||||
:::
|
||||
|
||||
#### model.py
|
||||
|
||||
在该文件中编写数据库模型。
|
@@ -1,51 +0,0 @@
|
||||
# 创建一个完整的项目
|
||||
|
||||
上一章中我们已经运行了一个最小的 NoneBot 实例,在这一章,我们将从零开始一个完整的项目。
|
||||
|
||||
## 目录结构
|
||||
|
||||
首先,我们可以使用 `nb-cli` 或者自行创建完整的项目目录:
|
||||
|
||||
```bash
|
||||
nb create
|
||||
```
|
||||
|
||||
<!-- prettier-ignore-start -->
|
||||
:::vue
|
||||
AweSome-Bot
|
||||
├── `awesome_bot` _(**或是 src**)_
|
||||
│ └── `plugins`
|
||||
├── `.env` _(**可选的**)_
|
||||
├── `.env.dev` _(**可选的**)_
|
||||
├── `.env.prod` _(**可选的**)_
|
||||
├── .gitignore
|
||||
├── `bot.py`
|
||||
├── docker-compose.yml
|
||||
├── Dockerfile
|
||||
├── `pyproject.toml`
|
||||
└── README.md
|
||||
:::
|
||||
<!-- prettier-ignore-end -->
|
||||
|
||||
- `awesome_bot/plugins` 或 `src/plugins`: 用于存放编写的 bot 插件
|
||||
- `.env`, `.env.dev`, `.env.prod`: 各环境配置文件
|
||||
- `bot.py`: bot 入口文件
|
||||
- `pyproject.toml`: 项目依赖管理文件,默认使用 [poetry](https://python-poetry.org/)
|
||||
|
||||
## 启动 Bot
|
||||
|
||||
如果你使用 `nb-cli`
|
||||
|
||||
```bash
|
||||
nb run [--file=bot.py] [--app=app]
|
||||
```
|
||||
|
||||
或者使用
|
||||
|
||||
```bash
|
||||
python bot.py
|
||||
```
|
||||
|
||||
:::tip 提示
|
||||
如果在 bot 入口文件内定义了 asgi server, `nb-cli` 将会为你启动**冷重载模式**
|
||||
:::
|
@@ -1,9 +0,0 @@
|
||||
# 结语
|
||||
|
||||
至此,相信你已经能够写出一个基础的插件了,更多的用法将会在 进阶 部分进行介绍,这里给出几个小提示:
|
||||
|
||||
- 请千万注意事件处理器的优先级设定
|
||||
- 在匹配规则中请勿使用耗时极长的函数
|
||||
- 同一个用户可以**跨群**(**私聊**)继续他的事件处理(除非做出权限限制,将在后续介绍)
|
||||
|
||||
如果你还不能满足,前往 [进阶](../advanced/README.md) 获得更多的功能信息。
|
@@ -1,173 +0,0 @@
|
||||
# 开始使用
|
||||
|
||||
一切都安装成功后,你就已经做好了进行简单配置以运行一个最小的 NoneBot 实例的准备。
|
||||
|
||||
## 最小实例
|
||||
|
||||
如果你已经按照推荐方式安装了 `nb-cli`,使用脚手架创建一个空项目:
|
||||
|
||||
```bash
|
||||
nb create
|
||||
```
|
||||
|
||||
根据脚手架引导,将在当前目录下创建一个项目目录,项目目录内包含 `bot.py`。
|
||||
|
||||
如果未安装 `nb-cli`,使用你最熟悉的编辑器或 IDE,创建一个名为 `bot.py` 的文件,内容如下:
|
||||
|
||||
```python{3,4,7}
|
||||
import nonebot
|
||||
from nonebot.adapters.cqhttp import Bot as CQHTTPBot
|
||||
|
||||
nonebot.init()
|
||||
driver = nonebot.get_driver()
|
||||
driver.register_adapter("cqhttp", CQHTTPBot)
|
||||
nonebot.load_builtin_plugins()
|
||||
|
||||
if __name__ == "__main__":
|
||||
nonebot.run()
|
||||
```
|
||||
|
||||
## 解读
|
||||
|
||||
在上方 `bot.py` 中,这几行高亮代码将依次:
|
||||
|
||||
1. 使用默认配置初始化 NoneBot
|
||||
2. 加载 NoneBot 内置的插件
|
||||
3. 在地址 `127.0.0.1:8080` 运行 NoneBot
|
||||
|
||||
在命令行使用如下命令即可运行这个 NoneBot 实例:
|
||||
|
||||
```bash
|
||||
# nb-cli
|
||||
nb run
|
||||
# 其他
|
||||
python bot.py
|
||||
```
|
||||
|
||||
运行后会产生如下日志:
|
||||
|
||||
```plain
|
||||
09-14 21:02:00 [INFO] nonebot | Succeeded to import "nonebot.plugins.base"
|
||||
09-14 21:02:00 [INFO] nonebot | Running NoneBot...
|
||||
09-14 21:02:00 [INFO] uvicorn | Started server process [1234]
|
||||
09-14 21:02:00 [INFO] uvicorn | Waiting for application startup.
|
||||
09-14 21:02:00 [INFO] uvicorn | Application startup complete.
|
||||
09-14 21:02:00 [INFO] uvicorn | Uvicorn running on http://127.0.0.1:8080 (Press CTRL+C to quit)
|
||||
```
|
||||
|
||||
## 配置 QQ 协议端
|
||||
|
||||
单纯运行 NoneBot 实例并不会产生任何效果,因为此刻 QQ 这边还不知道 NoneBot 的存在,也就无法把消息发送给它,因此现在需要使用一个无头 QQ 来把消息等事件上报给 NoneBot。
|
||||
|
||||
目前支持的协议有:
|
||||
|
||||
- [OneBot(CQHTTP)](https://github.com/howmanybots/onebot/blob/master/README.md)
|
||||
|
||||
QQ 协议端举例:
|
||||
|
||||
- [go-cqhttp](https://github.com/Mrs4s/go-cqhttp) (基于 [MiraiGo](https://github.com/Mrs4s/MiraiGo))
|
||||
- [cqhttp-mirai-embedded](https://github.com/yyuueexxiinngg/cqhttp-mirai/tree/embedded)
|
||||
- [Mirai](https://github.com/mamoe/mirai) + [cqhttp-mirai](https://github.com/yyuueexxiinngg/cqhttp-mirai)
|
||||
- [Mirai](https://github.com/mamoe/mirai) + [Mirai Native](https://github.com/iTXTech/mirai-native) + [CQHTTP](https://github.com/richardchien/coolq-http-api)
|
||||
- [OICQ-http-api](https://github.com/takayama-lily/onebot) (基于 [OICQ](https://github.com/takayama-lily/oicq))
|
||||
|
||||
这里以 [go-cqhttp](https://github.com/Mrs4s/go-cqhttp) 为例
|
||||
|
||||
1. 下载 go-cqhttp 对应平台的 release 文件,[点此前往](https://github.com/Mrs4s/go-cqhttp/releases)
|
||||
2. 运行 exe 文件或者使用 `./go-cqhttp` 启动
|
||||
3. 生成默认配置文件并修改默认配置
|
||||
|
||||
```json{2,3,35-36,42}
|
||||
{
|
||||
"uin": 你的QQ号,
|
||||
"password": "你的密码",
|
||||
"encrypt_password": false,
|
||||
"password_encrypted": "",
|
||||
"enable_db": true,
|
||||
"access_token": "",
|
||||
"relogin": {
|
||||
"enabled": true,
|
||||
"relogin_delay": 3,
|
||||
"max_relogin_times": 0
|
||||
},
|
||||
"_rate_limit": {
|
||||
"enabled": false,
|
||||
"frequency": 0,
|
||||
"bucket_size": 0
|
||||
},
|
||||
"ignore_invalid_cqcode": false,
|
||||
"force_fragmented": true,
|
||||
"heartbeat_interval": 0,
|
||||
"http_config": {
|
||||
"enabled": false,
|
||||
"host": "0.0.0.0",
|
||||
"port": 5700,
|
||||
"timeout": 0,
|
||||
"post_urls": {}
|
||||
},
|
||||
"ws_config": {
|
||||
"enabled": false,
|
||||
"host": "0.0.0.0",
|
||||
"port": 6700
|
||||
},
|
||||
"ws_reverse_servers": [
|
||||
{
|
||||
"enabled": true,
|
||||
"reverse_url": "ws://127.0.0.1:8080/cqhttp/ws",
|
||||
"reverse_api_url": "",
|
||||
"reverse_event_url": "",
|
||||
"reverse_reconnect_interval": 3000
|
||||
}
|
||||
],
|
||||
"post_message_format": "array",
|
||||
"use_sso_address": false,
|
||||
"debug": false,
|
||||
"log_level": "",
|
||||
"web_ui": {
|
||||
"enabled": true,
|
||||
"host": "0.0.0.0",
|
||||
"web_ui_port": 9999,
|
||||
"web_input": false
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
其中 `ws://127.0.0.1:8080/cqhttp/ws` 中的 `127.0.0.1` 和 `8080` 应分别对应 nonebot 配置的 HOST 和 PORT
|
||||
|
||||
## 历史性的第一次对话
|
||||
|
||||
一旦新的配置文件正确生效之后,NoneBot 所在的控制台(如果正在运行的话)应该会输出类似下面的内容(两条访问日志):
|
||||
|
||||
```default
|
||||
09-14 21:31:16 [INFO] uvicorn | ('127.0.0.1', 12345) - "WebSocket /cqhttp/ws" [accepted]
|
||||
09-14 21:31:16 [INFO] nonebot | WebSocket Connection from CQHTTP Bot 你的QQ号 Accepted!
|
||||
```
|
||||
|
||||
这表示 QQ 协议端已经成功地使用 CQHTTP 协议连接上了 NoneBot。
|
||||
|
||||
:::warning 注意
|
||||
如果到这一步你没有看到上面这样的成功日志,CQHTTP 的日志中在不断地重连或无反应,请注意检查配置中的 IP 和端口是否确实可以访问。比较常见的出错点包括:
|
||||
|
||||
- NoneBot 监听 `0.0.0.0`,然后在 CQHTTP 配置中填了 `ws://0.0.0.0:8080/cqhttp/ws`
|
||||
- 在 Docker 容器内运行 CQHTTP,并通过 `127.0.0.1` 访问宿主机上的 NoneBot
|
||||
- 想从公网访问,但没有修改云服务商的安全组策略或系统防火墙
|
||||
- NoneBot 所监听的端口存在冲突,已被其它程序占用
|
||||
- 弄混了 NoneBot 的 `host`、`port` 参数与 CQHTTP 配置中的 `host`、`port` 参数
|
||||
- 使用了 `ws_reverse_api_url` 和 `ws_reverse_event_url` 而非 universal client
|
||||
- `ws://` 错填为 `http://`
|
||||
- CQHTTP 或 NoneBot 启动时遭到外星武器干扰
|
||||
|
||||
请尝试重启 CQHTTP、重启 NoneBot、更换端口、修改防火墙、重启系统、仔细阅读前面的文档及提示、更新 CQHTTP 和 NoneBot 到最新版本等方式来解决。
|
||||
:::
|
||||
|
||||
现在,尝试向你的 QQ 机器人账号发送如下内容:
|
||||
|
||||
```default
|
||||
/echo 你好,世界
|
||||
```
|
||||
|
||||
到这里如果一切 OK,你应该会收到机器人给你回复了 `你好,世界`。这一历史性的对话标志着你已经成功地运行了一个 NoneBot 的最小实例,开始了编写更强大的 QQ 机器人的创意之旅!
|
||||
|
||||
<ClientOnly>
|
||||
<Messenger :messages="[{ position: 'right', msg: '/echo 你好,世界' }, { position: 'left', msg: '你好,世界' }]"/>
|
||||
</ClientOnly>
|
@@ -1,87 +0,0 @@
|
||||
# 安装
|
||||
|
||||
## NoneBot
|
||||
|
||||
:::warning 注意
|
||||
请确保你的 Python 版本 >= 3.7。
|
||||
:::
|
||||
|
||||
:::warning 注意
|
||||
请在安装 nonebot2 之前卸载 nonebot 1.x
|
||||
|
||||
```bash
|
||||
pip uninstall nonebot
|
||||
```
|
||||
|
||||
:::
|
||||
|
||||
### 通过脚手架安装(推荐安装方式)
|
||||
|
||||
1. (可选)使用你喜欢的 Python 环境管理工具创建新的虚拟环境。
|
||||
2. 使用 `pip` (或其他) 安装 NoneBot 脚手架。
|
||||
|
||||
```bash
|
||||
pip install nb-cli
|
||||
```
|
||||
|
||||
3. 点个 star 吧
|
||||
|
||||
nonebot2: [](https://github.com/nonebot/nonebot2)
|
||||
|
||||
nb-cli: [](https://github.com/nonebot/nb-cli)
|
||||
|
||||
### 不使用脚手架(纯净安装)
|
||||
|
||||
```bash
|
||||
# poetry
|
||||
poetry add nonebot2
|
||||
# pip
|
||||
pip install nonebot2
|
||||
```
|
||||
|
||||
如果你需要使用最新的(可能**尚未发布**的)特性,可以直接从 GitHub 仓库安装:
|
||||
|
||||
```bash
|
||||
# master
|
||||
poetry add git+https://github.com/nonebot/nonebot2.git#master
|
||||
# dev
|
||||
poetry add git+https://github.com/nonebot/nonebot2.git#dev
|
||||
```
|
||||
|
||||
或者克隆 Git 仓库后手动安装:
|
||||
|
||||
```bash
|
||||
git clone https://github.com/nonebot/nonebot2.git
|
||||
cd nonebot2
|
||||
poetry install --no-dev # 推荐
|
||||
pip install . # 不推荐
|
||||
```
|
||||
|
||||
## 安装插件
|
||||
|
||||
插件可以通过 `nb-cli` 进行安装,也可以自行安装并加载插件。
|
||||
|
||||
```bash
|
||||
# 列出所有的插件
|
||||
nb plugin list
|
||||
# 搜索插件
|
||||
nb plugin search xxx
|
||||
# 安装插件
|
||||
nb plugin install xxx
|
||||
```
|
||||
|
||||
如果急于上线 Bot 或想要使用现成的插件,以下插件可作为参考:
|
||||
|
||||
### 官方插件
|
||||
|
||||
~~自用插件~~ ~~确信~~
|
||||
|
||||
- [NoneBot-Plugin-Docs](https://github.com/nonebot/nonebot2/tree/master/packages/nonebot-plugin-docs) 离线文档插件
|
||||
- [NoneBot-Plugin-Test](https://github.com/nonebot/plugin-test) 本地机器人测试前端插件
|
||||
- [NoneBot-Plugin-APScheduler](https://github.com/nonebot/plugin-apscheduler) 定时任务插件
|
||||
- [NoneBot-Plugin-Sentry](https://github.com/cscs181/QQ-GitHub-Bot/tree/master/src/plugins/nonebot_plugin_sentry) Sentry 在线日志分析插件
|
||||
- [NoneBot-Plugin-Status](https://github.com/cscs181/QQ-GitHub-Bot/tree/master/src/plugins/nonebot_plugin_status) 服务器状态查看插件
|
||||
|
||||
### 其他插件
|
||||
|
||||
还有更多的插件在 [这里](/plugin-store.md) 等着你发现~
|
@@ -1,116 +0,0 @@
|
||||
# 加载插件
|
||||
|
||||
在 [创建一个完整的项目](creating-a-project) 一章节中,我们已经创建了插件目录 `awesome_bot/plugins`,现在我们在机器人入口文件中加载它。当然,你也可以单独加载一个插件。
|
||||
|
||||
## 加载内置插件
|
||||
|
||||
在 `bot.py` 文件中添加以下行:
|
||||
|
||||
```python{5}
|
||||
import nonebot
|
||||
|
||||
nonebot.init()
|
||||
# 加载 nonebot 内置插件
|
||||
nonebot.load_builtin_plugins()
|
||||
|
||||
app = nonebot.get_asgi()
|
||||
|
||||
if __name__ == "__main__":
|
||||
nonebot.run()
|
||||
```
|
||||
|
||||
这将会加载 nonebot 内置的插件,它包含:
|
||||
|
||||
- 命令 `say`:可由**superuser**使用,可以将消息内容由特殊纯文本转为富文本
|
||||
- 命令 `echo`:可由任何人使用,将消息原样返回
|
||||
|
||||
以上命令均需要指定机器人,即私聊、群聊内@机器人、群聊内称呼机器人昵称。参考 [Rule: to_me](../api/rule.md#to-me)
|
||||
|
||||
## 加载插件目录
|
||||
|
||||
在 `bot.py` 文件中添加以下行:
|
||||
|
||||
```python{5}
|
||||
import nonebot
|
||||
|
||||
nonebot.init()
|
||||
# 加载插件目录,该目录下为各插件,以下划线开头的插件将不会被加载
|
||||
nonebot.load_plugins("awesome_bot/plugins")
|
||||
|
||||
app = nonebot.get_asgi()
|
||||
|
||||
if __name__ == "__main__":
|
||||
nonebot.run()
|
||||
```
|
||||
|
||||
:::tip 提示
|
||||
加载插件目录时,目录下以 `_` 下划线开头的插件将不会被加载!
|
||||
:::
|
||||
|
||||
:::warning 提示
|
||||
**插件不能存在相同名称!**
|
||||
:::
|
||||
|
||||
:::danger 警告
|
||||
插件间不应该存在过多的耦合,如果确实需要导入某个插件内的数据,可以参考 [进阶-跨插件访问](../advanced/export-and-require.md)
|
||||
:::
|
||||
|
||||
## 加载单个插件
|
||||
|
||||
在 `bot.py` 文件中添加以下行:
|
||||
|
||||
```python{5,7}
|
||||
import nonebot
|
||||
|
||||
nonebot.init()
|
||||
# 加载一个 pip 安装的插件
|
||||
nonebot.load_plugin("nonebot_plugin_status")
|
||||
# 加载本地的单独插件
|
||||
nonebot.load_plugin("awesome_bot.plugins.xxx")
|
||||
|
||||
app = nonebot.get_asgi()
|
||||
|
||||
if __name__ == "__main__":
|
||||
nonebot.run()
|
||||
```
|
||||
|
||||
## 子插件(嵌套插件)
|
||||
|
||||
在插件中同样可以加载子插件,例如如下插件目录结构:
|
||||
|
||||
<!-- prettier-ignore-start -->
|
||||
:::vue
|
||||
foo_plugin
|
||||
├── `plugins`
|
||||
│ ├── `sub_plugin1`
|
||||
│ │ └── \_\_init\_\_.py
|
||||
│ └── `sub_plugin2.py`
|
||||
├── `__init__.py`
|
||||
└── config.py
|
||||
:::
|
||||
<!-- prettier-ignore-end -->
|
||||
|
||||
在插件目录下的 `__init__.py` 中添加如下代码:
|
||||
|
||||
```python
|
||||
from pathlib import Path
|
||||
|
||||
import nonebot
|
||||
|
||||
# store all subplugins
|
||||
_sub_plugins = set()
|
||||
# load sub plugins
|
||||
_sub_plugins |= nonebot.load_plugins(
|
||||
str((Path(__file__).parent / "plugins").resolve()))
|
||||
```
|
||||
|
||||
插件将会被加载并存储于 `_sub_plugins` 中。
|
||||
|
||||
## 运行结果
|
||||
|
||||
尝试运行 `nb run` 或者 `python bot.py`,可以看到日志输出了类似如下内容:
|
||||
|
||||
```plain
|
||||
09-19 21:51:59 [INFO] nonebot | Succeeded to import "nonebot.plugins.base"
|
||||
09-19 21:51:59 [INFO] nonebot | Succeeded to import "plugin_in_folder"
|
||||
```
|
@@ -1,161 +0,0 @@
|
||||
{
|
||||
"sidebar": {},
|
||||
"locales": {
|
||||
"/": {
|
||||
"label": "简体中文",
|
||||
"selectText": "Languages",
|
||||
"editLinkText": "在 GitHub 上编辑此页",
|
||||
"lastUpdated": "上次更新",
|
||||
"nav": [
|
||||
{
|
||||
"text": "主页",
|
||||
"link": "/"
|
||||
},
|
||||
{
|
||||
"text": "指南",
|
||||
"link": "/guide/"
|
||||
},
|
||||
{
|
||||
"text": "进阶",
|
||||
"link": "/advanced/"
|
||||
},
|
||||
{
|
||||
"text": "API",
|
||||
"link": "/api/"
|
||||
},
|
||||
{
|
||||
"text": "插件广场",
|
||||
"link": "/plugin-store"
|
||||
},
|
||||
{
|
||||
"text": "更新日志",
|
||||
"link": "/changelog"
|
||||
}
|
||||
],
|
||||
"sidebarDepth": 2,
|
||||
"sidebar": {
|
||||
"/guide/": [
|
||||
{
|
||||
"title": "开始",
|
||||
"collapsable": false,
|
||||
"sidebar": "auto",
|
||||
"children": [
|
||||
"",
|
||||
"installation",
|
||||
"getting-started",
|
||||
"creating-a-project",
|
||||
"basic-configuration"
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "编写插件",
|
||||
"collapsable": false,
|
||||
"sidebar": "auto",
|
||||
"children": [
|
||||
"loading-a-plugin",
|
||||
"creating-a-plugin",
|
||||
"creating-a-matcher",
|
||||
"creating-a-handler",
|
||||
"end-or-start"
|
||||
]
|
||||
}
|
||||
],
|
||||
"/advanced/": [
|
||||
{
|
||||
"title": "进阶",
|
||||
"collapsable": false,
|
||||
"sidebar": "auto",
|
||||
"children": [
|
||||
"",
|
||||
"scheduler",
|
||||
"permission",
|
||||
"runtime-hook",
|
||||
"export-and-require"
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "发布",
|
||||
"collapsable": false,
|
||||
"sidebar": "auto",
|
||||
"children": [
|
||||
"publish-plugin"
|
||||
]
|
||||
}
|
||||
],
|
||||
"/api/": [
|
||||
{
|
||||
"title": "NoneBot Api Reference",
|
||||
"path": "",
|
||||
"collapsable": false,
|
||||
"children": [
|
||||
{
|
||||
"title": "nonebot 模块",
|
||||
"path": "nonebot"
|
||||
},
|
||||
{
|
||||
"title": "nonebot.config 模块",
|
||||
"path": "config"
|
||||
},
|
||||
{
|
||||
"title": "nonebot.plugin 模块",
|
||||
"path": "plugin"
|
||||
},
|
||||
{
|
||||
"title": "nonebot.message 模块",
|
||||
"path": "message"
|
||||
},
|
||||
{
|
||||
"title": "nonebot.matcher 模块",
|
||||
"path": "matcher"
|
||||
},
|
||||
{
|
||||
"title": "nonebot.rule 模块",
|
||||
"path": "rule"
|
||||
},
|
||||
{
|
||||
"title": "nonebot.permission 模块",
|
||||
"path": "permission"
|
||||
},
|
||||
{
|
||||
"title": "nonebot.log 模块",
|
||||
"path": "log"
|
||||
},
|
||||
{
|
||||
"title": "nonebot.utils 模块",
|
||||
"path": "utils"
|
||||
},
|
||||
{
|
||||
"title": "nonebot.typing 模块",
|
||||
"path": "typing"
|
||||
},
|
||||
{
|
||||
"title": "nonebot.exception 模块",
|
||||
"path": "exception"
|
||||
},
|
||||
{
|
||||
"title": "nonebot.drivers 模块",
|
||||
"path": "drivers/"
|
||||
},
|
||||
{
|
||||
"title": "nonebot.drivers.fastapi 模块",
|
||||
"path": "drivers/fastapi"
|
||||
},
|
||||
{
|
||||
"title": "nonebot.adapters 模块",
|
||||
"path": "adapters/"
|
||||
},
|
||||
{
|
||||
"title": "nonebot.adapters.cqhttp 模块",
|
||||
"path": "adapters/cqhttp"
|
||||
},
|
||||
{
|
||||
"title": "nonebot.adapters.ding 模块",
|
||||
"path": "adapters/ding"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,15 +0,0 @@
|
||||
---
|
||||
home: true
|
||||
heroImage: /logo.png
|
||||
tagline: An asynchronous bot framework.
|
||||
actionText: 开始使用
|
||||
actionLink: guide/
|
||||
features:
|
||||
- title: 简洁
|
||||
details: 提供极其简洁易懂的 API,使你可以毫无压力地开始验证你的绝佳创意,只需编写最少量的代码,即可实现丰富的功能。
|
||||
- title: 易于扩展
|
||||
details: 精心设计的消息处理流程使得你可以很方便地将原型扩充为具有大量实用功能的完整聊天机器人,并持续保证扩展性。
|
||||
- title: 高性能
|
||||
details: 采用异步 I/O,利用 WebSocket 进行通信,以获得极高的性能;同时,支持使用多账号同时接入,减少业务宕机的可能。
|
||||
footer: MIT Licensed | Copyright © 2018 - 2020 NoneBot Team
|
||||
---
|
@@ -1,7 +0,0 @@
|
||||
# 深入
|
||||
|
||||
## 它如何工作?
|
||||
|
||||
<!-- TODO: how to work -->
|
||||
|
||||
~~未填坑~~
|
@@ -1 +0,0 @@
|
||||
# 跨插件访问
|
@@ -1 +0,0 @@
|
||||
# 事件处理函数重载
|
@@ -1 +0,0 @@
|
||||
# 权限控制
|
@@ -1 +0,0 @@
|
||||
# 发布插件
|
@@ -1 +0,0 @@
|
||||
# 运行时插槽
|
@@ -1,52 +0,0 @@
|
||||
# NoneBot Api Reference
|
||||
|
||||
|
||||
* **模块索引**
|
||||
|
||||
|
||||
* [nonebot](nonebot.html)
|
||||
|
||||
|
||||
* [nonebot.config](config.html)
|
||||
|
||||
|
||||
* [nonebot.plugin](plugin.html)
|
||||
|
||||
|
||||
* [nonebot.message](message.html)
|
||||
|
||||
|
||||
* [nonebot.matcher](matcher.html)
|
||||
|
||||
|
||||
* [nonebot.rule](rule.html)
|
||||
|
||||
|
||||
* [nonebot.permission](permission.html)
|
||||
|
||||
|
||||
* [nonebot.log](log.html)
|
||||
|
||||
|
||||
* [nonebot.utils](utils.html)
|
||||
|
||||
|
||||
* [nonebot.typing](typing.html)
|
||||
|
||||
|
||||
* [nonebot.exception](exception.html)
|
||||
|
||||
|
||||
* [nonebot.drivers](drivers/)
|
||||
|
||||
|
||||
* [nonebot.drivers.fastapi](drivers/fastapi.html)
|
||||
|
||||
|
||||
* [nonebot.adapters](adapters/)
|
||||
|
||||
|
||||
* [nonebot.adapters.cqhttp](adapters/cqhttp.html)
|
||||
|
||||
|
||||
* [nonebot.adapters.ding](adapters/ding.html)
|
@@ -1,423 +0,0 @@
|
||||
---
|
||||
contentSidebar: true
|
||||
sidebarDepth: 0
|
||||
---
|
||||
|
||||
# NoneBot.adapters 模块
|
||||
|
||||
## 协议适配基类
|
||||
|
||||
各协议请继承以下基类,并使用 `driver.register_adapter` 注册适配器
|
||||
|
||||
|
||||
## _class_ `Bot`
|
||||
|
||||
基类:`abc.ABC`
|
||||
|
||||
Bot 基类。用于处理上报消息,并提供 API 调用接口。
|
||||
|
||||
|
||||
### _abstract_ `__init__(driver, connection_type, config, self_id, *, websocket=None)`
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `driver: Driver`: Driver 对象
|
||||
|
||||
|
||||
* `connection_type: str`: http 或者 websocket
|
||||
|
||||
|
||||
* `config: Config`: Config 对象
|
||||
|
||||
|
||||
* `self_id: str`: 机器人 ID
|
||||
|
||||
|
||||
* `websocket: Optional[WebSocket]`: Websocket 连接对象
|
||||
|
||||
|
||||
|
||||
### `driver`
|
||||
|
||||
Driver 对象
|
||||
|
||||
|
||||
### `connection_type`
|
||||
|
||||
连接类型
|
||||
|
||||
|
||||
### `config`
|
||||
|
||||
Config 配置对象
|
||||
|
||||
|
||||
### `self_id`
|
||||
|
||||
机器人 ID
|
||||
|
||||
|
||||
### `websocket`
|
||||
|
||||
Websocket 连接对象
|
||||
|
||||
|
||||
### _abstract property_ `type`
|
||||
|
||||
Adapter 类型
|
||||
|
||||
|
||||
### _abstract async classmethod_ `check_permission(driver, connection_type, headers, body)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
检查连接请求是否合法的函数,如果合法则返回当前连接 `唯一标识符`,通常为机器人 ID;如果不合法则抛出 `RequestDenied` 异常。
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `driver: Driver`: Driver 对象
|
||||
|
||||
|
||||
* `connection_type: str`: 连接类型
|
||||
|
||||
|
||||
* `headers: dict`: 请求头
|
||||
|
||||
|
||||
* `body: Optional[dict]`: 请求数据,WebSocket 连接该部分为空
|
||||
|
||||
|
||||
|
||||
* **返回**
|
||||
|
||||
|
||||
* `str`: 连接唯一标识符
|
||||
|
||||
|
||||
|
||||
* **异常**
|
||||
|
||||
|
||||
* `RequestDenied`: 请求非法
|
||||
|
||||
|
||||
|
||||
### _abstract async_ `handle_message(message)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
处理上报消息的函数,转换为 `Event` 事件后调用 `nonebot.message.handle_event` 进一步处理事件。
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `message: dict`: 收到的上报消息
|
||||
|
||||
|
||||
|
||||
### _abstract async_ `call_api(api, **data)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
调用机器人 API 接口,可以通过该函数或直接通过 bot 属性进行调用
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `api: str`: API 名称
|
||||
|
||||
|
||||
* `**data`: API 数据
|
||||
|
||||
|
||||
|
||||
* **示例**
|
||||
|
||||
|
||||
```python
|
||||
await bot.call_api("send_msg", message="hello world")
|
||||
await bot.send_msg(message="hello world")
|
||||
```
|
||||
|
||||
|
||||
### _abstract async_ `send(event, message, **kwargs)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
调用机器人基础发送消息接口
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `event: Event`: 上报事件
|
||||
|
||||
|
||||
* `message: Union[str, Message, MessageSegment]`: 要发送的消息
|
||||
|
||||
|
||||
* `**kwargs`
|
||||
|
||||
|
||||
|
||||
## _class_ `MessageSegment`
|
||||
|
||||
基类:`abc.ABC`
|
||||
|
||||
消息段基类
|
||||
|
||||
|
||||
### `type`
|
||||
|
||||
|
||||
* 类型: `str`
|
||||
|
||||
|
||||
* 说明: 消息段类型
|
||||
|
||||
|
||||
### `data`
|
||||
|
||||
|
||||
* 类型: `Dict[str, Union[str, list]]`
|
||||
|
||||
|
||||
* 说明: 消息段数据
|
||||
|
||||
|
||||
## _class_ `Message`
|
||||
|
||||
基类:`list`, `abc.ABC`
|
||||
|
||||
消息数组
|
||||
|
||||
|
||||
### `__init__(message=None, *args, **kwargs)`
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `message: Union[str, list, dict, MessageSegment, Message, Any]`: 消息内容
|
||||
|
||||
|
||||
|
||||
### `append(obj)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
添加一个消息段到消息数组末尾
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `obj: Union[str, MessageSegment]`: 要添加的消息段
|
||||
|
||||
|
||||
|
||||
### `extend(obj)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
拼接一个消息数组或多个消息段到消息数组末尾
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `obj: Union[Message, Iterable[MessageSegment]]`: 要添加的消息数组
|
||||
|
||||
|
||||
|
||||
### `reduce()`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
缩减消息数组,即按 MessageSegment 的实现拼接相邻消息段
|
||||
|
||||
|
||||
|
||||
### `extract_plain_text()`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
提取消息内纯文本消息
|
||||
|
||||
|
||||
|
||||
## _class_ `Event`
|
||||
|
||||
基类:`abc.ABC`, `pydantic.main.BaseModel`
|
||||
|
||||
Event 基类。提供获取关键信息的方法,其余信息可直接获取。
|
||||
|
||||
|
||||
### _abstract_ `get_type()`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
获取事件类型的方法,类型通常为 NoneBot 内置的四种类型。
|
||||
|
||||
|
||||
|
||||
* **返回**
|
||||
|
||||
|
||||
* `Literal["message", "notice", "request", "meta_event"]`
|
||||
|
||||
|
||||
|
||||
### _abstract_ `get_event_name()`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
获取事件名称的方法。
|
||||
|
||||
|
||||
|
||||
* **返回**
|
||||
|
||||
|
||||
* `str`
|
||||
|
||||
|
||||
|
||||
### _abstract_ `get_event_description()`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
获取事件描述的方法,通常为事件具体内容。
|
||||
|
||||
|
||||
|
||||
* **返回**
|
||||
|
||||
|
||||
* `str`
|
||||
|
||||
|
||||
|
||||
### `get_log_string()`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
获取事件日志信息的方法,通常你不需要修改这个方法,只有当希望 NoneBot 隐藏该事件日志时,可以抛出 `NoLogException` 异常。
|
||||
|
||||
|
||||
|
||||
* **返回**
|
||||
|
||||
|
||||
* `str`
|
||||
|
||||
|
||||
|
||||
* **异常**
|
||||
|
||||
|
||||
* `NoLogException`
|
||||
|
||||
|
||||
|
||||
### _abstract_ `get_user_id()`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
获取事件主体 id 的方法,通常是用户 id 。
|
||||
|
||||
|
||||
|
||||
* **返回**
|
||||
|
||||
|
||||
* `str`
|
||||
|
||||
|
||||
|
||||
### _abstract_ `get_session_id()`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
获取会话 id 的方法,用于判断当前事件属于哪一个会话,通常是用户 id、群组 id 组合。
|
||||
|
||||
|
||||
|
||||
* **返回**
|
||||
|
||||
|
||||
* `str`
|
||||
|
||||
|
||||
|
||||
### _abstract_ `get_message()`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
获取事件消息内容的方法。
|
||||
|
||||
|
||||
|
||||
* **返回**
|
||||
|
||||
|
||||
* `Message`
|
||||
|
||||
|
||||
|
||||
### `get_plaintext()`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
获取消息纯文本的方法,通常不需要修改,默认通过 `get_message().extract_plain_text` 获取。
|
||||
|
||||
|
||||
|
||||
* **返回**
|
||||
|
||||
|
||||
* `str`
|
||||
|
||||
|
||||
|
||||
### _abstract_ `is_tome()`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
获取事件是否与机器人有关的方法。
|
||||
|
||||
|
||||
|
||||
* **返回**
|
||||
|
||||
|
||||
* `bool`
|
@@ -1,564 +0,0 @@
|
||||
---
|
||||
contentSidebar: true
|
||||
sidebarDepth: 0
|
||||
---
|
||||
|
||||
# NoneBot.adapters.cqhttp 模块
|
||||
|
||||
## CQHTTP (OneBot) v11 协议适配
|
||||
|
||||
协议详情请看: [CQHTTP](https://github.com/howmanybots/onebot/blob/master/README.md) | [OneBot](https://github.com/howmanybots/onebot/blob/master/README.md)
|
||||
|
||||
# NoneBot.adapters.cqhttp.utils 模块
|
||||
|
||||
|
||||
## `escape(s, *, escape_comma=True)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
对字符串进行 CQ 码转义。
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `s: str`: 需要转义的字符串
|
||||
|
||||
|
||||
* `escape_comma: bool`: 是否转义逗号(`,`)。
|
||||
|
||||
|
||||
|
||||
## `unescape(s)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
对字符串进行 CQ 码去转义。
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `s: str`: 需要转义的字符串
|
||||
|
||||
|
||||
# NoneBot.adapters.cqhttp.exception 模块
|
||||
|
||||
|
||||
## _exception_ `ActionFailed`
|
||||
|
||||
基类:[`nonebot.exception.ActionFailed`](../exception.md#nonebot.exception.ActionFailed), `nonebot.adapters.cqhttp.exception.CQHTTPAdapterException`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
API 请求返回错误信息。
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `retcode: Optional[int]`: 错误码
|
||||
|
||||
|
||||
|
||||
## _exception_ `NetworkError`
|
||||
|
||||
基类:[`nonebot.exception.NetworkError`](../exception.md#nonebot.exception.NetworkError), `nonebot.adapters.cqhttp.exception.CQHTTPAdapterException`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
网络错误。
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `retcode: Optional[int]`: 错误码
|
||||
|
||||
|
||||
# NoneBot.adapters.cqhttp.bot 模块
|
||||
|
||||
|
||||
## _async_ `_check_reply(bot, event)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
检查消息中存在的回复,去除并赋值 `event.reply`, `event.to_me`
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `bot: Bot`: Bot 对象
|
||||
|
||||
|
||||
* `event: Event`: Event 对象
|
||||
|
||||
|
||||
|
||||
## `_check_at_me(bot, event)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
检查消息开头或结尾是否存在 @机器人,去除并赋值 `event.to_me`
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `bot: Bot`: Bot 对象
|
||||
|
||||
|
||||
* `event: Event`: Event 对象
|
||||
|
||||
|
||||
|
||||
## `_check_nickname(bot, event)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
检查消息开头是否存在,去除并赋值 `event.to_me`
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `bot: Bot`: Bot 对象
|
||||
|
||||
|
||||
* `event: Event`: Event 对象
|
||||
|
||||
|
||||
|
||||
## `_handle_api_result(result)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
处理 API 请求返回值。
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `result: Optional[Dict[str, Any]]`: API 返回数据
|
||||
|
||||
|
||||
|
||||
* **返回**
|
||||
|
||||
|
||||
* `Any`: API 调用返回数据
|
||||
|
||||
|
||||
|
||||
* **异常**
|
||||
|
||||
|
||||
* `ActionFailed`: API 调用失败
|
||||
|
||||
|
||||
|
||||
## _class_ `Bot`
|
||||
|
||||
基类:[`nonebot.adapters.Bot`](README.md#nonebot.adapters.Bot)
|
||||
|
||||
CQHTTP 协议 Bot 适配。继承属性参考 [BaseBot](./#class-basebot) 。
|
||||
|
||||
|
||||
### _property_ `type`
|
||||
|
||||
|
||||
* 返回: `"cqhttp"`
|
||||
|
||||
|
||||
### _async classmethod_ `check_permission(driver, connection_type, headers, body)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
CQHTTP (OneBot) 协议鉴权。参考 [鉴权](https://github.com/howmanybots/onebot/blob/master/v11/specs/communication/authorization.md)
|
||||
|
||||
|
||||
|
||||
### _async_ `handle_message(message)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
调用 [_check_reply](#async-check-reply-bot-event), [_check_at_me](#check-at-me-bot-event), [_check_nickname](#check-nickname-bot-event) 处理事件并转换为 [Event](#class-event)
|
||||
|
||||
|
||||
|
||||
### _async_ `call_api(api, **data)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
调用 CQHTTP 协议 API
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `api: str`: API 名称
|
||||
|
||||
|
||||
* `**data: Any`: API 参数
|
||||
|
||||
|
||||
|
||||
* **返回**
|
||||
|
||||
|
||||
* `Any`: API 调用返回数据
|
||||
|
||||
|
||||
|
||||
* **异常**
|
||||
|
||||
|
||||
* `NetworkError`: 网络错误
|
||||
|
||||
|
||||
* `ActionFailed`: API 调用失败
|
||||
|
||||
|
||||
|
||||
### _async_ `send(event, message, at_sender=False, **kwargs)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
根据 `event` 向触发事件的主体发送消息。
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `event: Event`: Event 对象
|
||||
|
||||
|
||||
* `message: Union[str, Message, MessageSegment]`: 要发送的消息
|
||||
|
||||
|
||||
* `at_sender: bool`: 是否 @ 事件主体
|
||||
|
||||
|
||||
* `**kwargs`: 覆盖默认参数
|
||||
|
||||
|
||||
|
||||
* **返回**
|
||||
|
||||
|
||||
* `Any`: API 调用返回数据
|
||||
|
||||
|
||||
|
||||
* **异常**
|
||||
|
||||
|
||||
* `ValueError`: 缺少 `user_id`, `group_id`
|
||||
|
||||
|
||||
* `NetworkError`: 网络错误
|
||||
|
||||
|
||||
* `ActionFailed`: API 调用失败
|
||||
|
||||
|
||||
# NoneBot.adapters.cqhttp.message 模块
|
||||
|
||||
|
||||
## _class_ `MessageSegment`
|
||||
|
||||
基类:[`nonebot.adapters.MessageSegment`](README.md#nonebot.adapters.MessageSegment)
|
||||
|
||||
CQHTTP 协议 MessageSegment 适配。具体方法参考协议消息段类型或源码。
|
||||
|
||||
|
||||
## _class_ `Message`
|
||||
|
||||
基类:[`nonebot.adapters.Message`](README.md#nonebot.adapters.Message)
|
||||
|
||||
CQHTTP 协议 Message 适配。
|
||||
|
||||
# NoneBot.adapters.cqhttp.permission 模块
|
||||
|
||||
|
||||
## `PRIVATE`
|
||||
|
||||
|
||||
* **说明**: 匹配任意私聊消息类型事件
|
||||
|
||||
|
||||
## `PRIVATE_FRIEND`
|
||||
|
||||
|
||||
* **说明**: 匹配任意好友私聊消息类型事件
|
||||
|
||||
|
||||
## `PRIVATE_GROUP`
|
||||
|
||||
|
||||
* **说明**: 匹配任意群临时私聊消息类型事件
|
||||
|
||||
|
||||
## `PRIVATE_OTHER`
|
||||
|
||||
|
||||
* **说明**: 匹配任意其他私聊消息类型事件
|
||||
|
||||
|
||||
## `GROUP`
|
||||
|
||||
|
||||
* **说明**: 匹配任意群聊消息类型事件
|
||||
|
||||
|
||||
## `GROUP_MEMBER`
|
||||
|
||||
|
||||
* **说明**: 匹配任意群员群聊消息类型事件
|
||||
|
||||
:::warning 警告
|
||||
该权限通过 event.sender 进行判断且不包含管理员以及群主!
|
||||
:::
|
||||
|
||||
|
||||
## `GROUP_ADMIN`
|
||||
|
||||
|
||||
* **说明**: 匹配任意群管理员群聊消息类型事件
|
||||
|
||||
|
||||
## `GROUP_OWNER`
|
||||
|
||||
|
||||
* **说明**: 匹配任意群主群聊消息类型事件
|
||||
|
||||
# NoneBot.adapters.cqhttp.event 模块
|
||||
|
||||
|
||||
## _class_ `Event`
|
||||
|
||||
基类:[`nonebot.adapters.Event`](README.md#nonebot.adapters.Event)
|
||||
|
||||
CQHTTP 协议事件,字段与 CQHTTP 一致。各事件字段参考 [CQHTTP 文档](https://github.com/howmanybots/onebot/blob/master/README.md)
|
||||
|
||||
|
||||
## _class_ `MessageEvent`
|
||||
|
||||
基类:`nonebot.adapters.cqhttp.event.Event`
|
||||
|
||||
消息事件
|
||||
|
||||
|
||||
### `to_me`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
消息是否与机器人有关
|
||||
|
||||
|
||||
|
||||
* **类型**
|
||||
|
||||
`bool`
|
||||
|
||||
|
||||
|
||||
### `reply`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
消息中提取的回复消息,内容为 `get_msg` API 返回结果
|
||||
|
||||
|
||||
|
||||
* **类型**
|
||||
|
||||
`Optional[Reply]`
|
||||
|
||||
|
||||
|
||||
## _class_ `PrivateMessageEvent`
|
||||
|
||||
基类:`nonebot.adapters.cqhttp.event.MessageEvent`
|
||||
|
||||
私聊消息
|
||||
|
||||
|
||||
## _class_ `GroupMessageEvent`
|
||||
|
||||
基类:`nonebot.adapters.cqhttp.event.MessageEvent`
|
||||
|
||||
群消息
|
||||
|
||||
|
||||
## _class_ `NoticeEvent`
|
||||
|
||||
基类:`nonebot.adapters.cqhttp.event.Event`
|
||||
|
||||
通知事件
|
||||
|
||||
|
||||
## _class_ `GroupUploadNoticeEvent`
|
||||
|
||||
基类:`nonebot.adapters.cqhttp.event.NoticeEvent`
|
||||
|
||||
群文件上传事件
|
||||
|
||||
|
||||
## _class_ `GroupAdminNoticeEvent`
|
||||
|
||||
基类:`nonebot.adapters.cqhttp.event.NoticeEvent`
|
||||
|
||||
群管理员变动
|
||||
|
||||
|
||||
## _class_ `GroupDecreaseNoticeEvent`
|
||||
|
||||
基类:`nonebot.adapters.cqhttp.event.NoticeEvent`
|
||||
|
||||
群成员减少事件
|
||||
|
||||
|
||||
## _class_ `GroupIncreaseNoticeEvent`
|
||||
|
||||
基类:`nonebot.adapters.cqhttp.event.NoticeEvent`
|
||||
|
||||
群成员增加事件
|
||||
|
||||
|
||||
## _class_ `GroupBanNoticeEvent`
|
||||
|
||||
基类:`nonebot.adapters.cqhttp.event.NoticeEvent`
|
||||
|
||||
群禁言事件
|
||||
|
||||
|
||||
## _class_ `FriendAddNoticeEvent`
|
||||
|
||||
基类:`nonebot.adapters.cqhttp.event.NoticeEvent`
|
||||
|
||||
好友添加事件
|
||||
|
||||
|
||||
## _class_ `GroupRecallNoticeEvent`
|
||||
|
||||
基类:`nonebot.adapters.cqhttp.event.NoticeEvent`
|
||||
|
||||
群消息撤回事件
|
||||
|
||||
|
||||
## _class_ `FriendRecallNoticeEvent`
|
||||
|
||||
基类:`nonebot.adapters.cqhttp.event.NoticeEvent`
|
||||
|
||||
好友消息撤回事件
|
||||
|
||||
|
||||
## _class_ `NotifyEvent`
|
||||
|
||||
基类:`nonebot.adapters.cqhttp.event.NoticeEvent`
|
||||
|
||||
提醒事件
|
||||
|
||||
|
||||
## _class_ `PokeNotifyEvent`
|
||||
|
||||
基类:`nonebot.adapters.cqhttp.event.NotifyEvent`
|
||||
|
||||
戳一戳提醒事件
|
||||
|
||||
|
||||
## _class_ `LuckyKingNotifyEvent`
|
||||
|
||||
基类:`nonebot.adapters.cqhttp.event.NotifyEvent`
|
||||
|
||||
群红包运气王提醒事件
|
||||
|
||||
|
||||
## _class_ `HonorNotifyEvent`
|
||||
|
||||
基类:`nonebot.adapters.cqhttp.event.NotifyEvent`
|
||||
|
||||
群荣誉变更提醒事件
|
||||
|
||||
|
||||
## _class_ `RequestEvent`
|
||||
|
||||
基类:`nonebot.adapters.cqhttp.event.Event`
|
||||
|
||||
请求事件
|
||||
|
||||
|
||||
## _class_ `FriendRequestEvent`
|
||||
|
||||
基类:`nonebot.adapters.cqhttp.event.RequestEvent`
|
||||
|
||||
加好友请求事件
|
||||
|
||||
|
||||
## _class_ `GroupRequestEvent`
|
||||
|
||||
基类:`nonebot.adapters.cqhttp.event.RequestEvent`
|
||||
|
||||
加群请求/邀请事件
|
||||
|
||||
|
||||
## _class_ `MetaEvent`
|
||||
|
||||
基类:`nonebot.adapters.cqhttp.event.Event`
|
||||
|
||||
元事件
|
||||
|
||||
|
||||
## _class_ `LifecycleMetaEvent`
|
||||
|
||||
基类:`nonebot.adapters.cqhttp.event.MetaEvent`
|
||||
|
||||
生命周期元事件
|
||||
|
||||
|
||||
## _class_ `HeartbeatMetaEvent`
|
||||
|
||||
基类:`nonebot.adapters.cqhttp.event.MetaEvent`
|
||||
|
||||
心跳元事件
|
||||
|
||||
|
||||
## `get_event_model(event_name)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
根据事件名获取对应 `Event Model` 及 `FallBack Event Model` 列表
|
||||
|
||||
|
||||
|
||||
* **返回**
|
||||
|
||||
|
||||
* `List[Type[Event]]`
|
@@ -1,293 +0,0 @@
|
||||
---
|
||||
contentSidebar: true
|
||||
sidebarDepth: 0
|
||||
---
|
||||
|
||||
# NoneBot.adapters.ding 模块
|
||||
|
||||
## 钉钉群机器人 协议适配
|
||||
|
||||
协议详情请看: [钉钉文档](https://ding-doc.dingtalk.com/document#/org-dev-guide/elzz1p)
|
||||
|
||||
# NoneBot.adapters.ding.exception 模块
|
||||
|
||||
|
||||
## _exception_ `DingAdapterException`
|
||||
|
||||
基类:[`nonebot.exception.AdapterException`](../exception.md#nonebot.exception.AdapterException)
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
钉钉 Adapter 错误基类
|
||||
|
||||
|
||||
|
||||
## _exception_ `ActionFailed`
|
||||
|
||||
基类:[`nonebot.exception.ActionFailed`](../exception.md#nonebot.exception.ActionFailed), `nonebot.adapters.ding.exception.DingAdapterException`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
API 请求返回错误信息。
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `errcode: Optional[int]`: 错误码
|
||||
|
||||
|
||||
* `errmsg: Optional[str]`: 错误信息
|
||||
|
||||
|
||||
|
||||
## _exception_ `NetworkError`
|
||||
|
||||
基类:[`nonebot.exception.NetworkError`](../exception.md#nonebot.exception.NetworkError), `nonebot.adapters.ding.exception.DingAdapterException`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
网络错误。
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `retcode: Optional[int]`: 错误码
|
||||
|
||||
|
||||
|
||||
## _exception_ `SessionExpired`
|
||||
|
||||
基类:`nonebot.adapters.ding.exception.ApiNotAvailable`, `nonebot.adapters.ding.exception.DingAdapterException`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
发消息的 session 已经过期。
|
||||
|
||||
|
||||
# NoneBot.adapters.ding.bot 模块
|
||||
|
||||
|
||||
## _class_ `Bot`
|
||||
|
||||
基类:[`nonebot.adapters.Bot`](README.md#nonebot.adapters.Bot)
|
||||
|
||||
钉钉 协议 Bot 适配。继承属性参考 [BaseBot](./#class-basebot) 。
|
||||
|
||||
|
||||
### _property_ `type`
|
||||
|
||||
|
||||
* 返回: `"ding"`
|
||||
|
||||
|
||||
### _async classmethod_ `check_permission(driver, connection_type, headers, body)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
钉钉协议鉴权。参考 [鉴权](https://ding-doc.dingtalk.com/doc#/serverapi2/elzz1p)
|
||||
|
||||
|
||||
|
||||
### _async_ `call_api(api, event=None, **data)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
调用 钉钉 协议 API
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `api: str`: API 名称
|
||||
|
||||
|
||||
* `**data: Any`: API 参数
|
||||
|
||||
|
||||
|
||||
* **返回**
|
||||
|
||||
|
||||
* `Any`: API 调用返回数据
|
||||
|
||||
|
||||
|
||||
* **异常**
|
||||
|
||||
|
||||
* `NetworkError`: 网络错误
|
||||
|
||||
|
||||
* `ActionFailed`: API 调用失败
|
||||
|
||||
|
||||
|
||||
### _async_ `send(event, message, at_sender=False, **kwargs)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
根据 `event` 向触发事件的主体发送消息。
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `event: Event`: Event 对象
|
||||
|
||||
|
||||
* `message: Union[str, Message, MessageSegment]`: 要发送的消息
|
||||
|
||||
|
||||
* `at_sender: bool`: 是否 @ 事件主体
|
||||
|
||||
|
||||
* `**kwargs`: 覆盖默认参数
|
||||
|
||||
|
||||
|
||||
* **返回**
|
||||
|
||||
|
||||
* `Any`: API 调用返回数据
|
||||
|
||||
|
||||
|
||||
* **异常**
|
||||
|
||||
|
||||
* `ValueError`: 缺少 `user_id`, `group_id`
|
||||
|
||||
|
||||
* `NetworkError`: 网络错误
|
||||
|
||||
|
||||
* `ActionFailed`: API 调用失败
|
||||
|
||||
|
||||
# NoneBot.adapters.ding.message 模块
|
||||
|
||||
|
||||
## _class_ `MessageSegment`
|
||||
|
||||
基类:[`nonebot.adapters.MessageSegment`](README.md#nonebot.adapters.MessageSegment)
|
||||
|
||||
钉钉 协议 MessageSegment 适配。具体方法参考协议消息段类型或源码。
|
||||
|
||||
|
||||
### _static_ `atAll()`
|
||||
|
||||
@全体
|
||||
|
||||
|
||||
### _static_ `atMobiles(*mobileNumber)`
|
||||
|
||||
@指定手机号人员
|
||||
|
||||
|
||||
### _static_ `text(text)`
|
||||
|
||||
发送 `text` 类型消息
|
||||
|
||||
|
||||
### _static_ `image(picURL)`
|
||||
|
||||
发送 `image` 类型消息
|
||||
|
||||
|
||||
### _static_ `extension(dict_)`
|
||||
|
||||
"标记 text 文本的 extension 属性,需要与 text 消息段相加。
|
||||
|
||||
|
||||
### _static_ `markdown(title, text)`
|
||||
|
||||
发送 `markdown` 类型消息
|
||||
|
||||
|
||||
### _static_ `actionCardSingleBtn(title, text, singleTitle, singleURL)`
|
||||
|
||||
发送 `actionCardSingleBtn` 类型消息
|
||||
|
||||
|
||||
### _static_ `actionCardMultiBtns(title, text, btns, hideAvatar=False, btnOrientation='1')`
|
||||
|
||||
发送 `actionCardMultiBtn` 类型消息
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `btnOrientation`: 0:按钮竖直排列 1:按钮横向排列
|
||||
|
||||
|
||||
* `btns`: [{ "title": title, "actionURL": actionURL }, ...]
|
||||
|
||||
|
||||
|
||||
### _static_ `feedCard(links)`
|
||||
|
||||
发送 `feedCard` 类型消息
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `links`: [{ "title": xxx, "messageURL": xxx, "picURL": xxx }, ...]
|
||||
|
||||
|
||||
|
||||
## _class_ `Message`
|
||||
|
||||
基类:[`nonebot.adapters.Message`](README.md#nonebot.adapters.Message)
|
||||
|
||||
钉钉 协议 Message 适配。
|
||||
|
||||
# NoneBot.adapters.ding.event 模块
|
||||
|
||||
|
||||
## _class_ `Event`
|
||||
|
||||
基类:[`nonebot.adapters.Event`](README.md#nonebot.adapters.Event)
|
||||
|
||||
钉钉协议事件。各事件字段参考 [钉钉文档](https://ding-doc.dingtalk.com/document#/org-dev-guide/elzz1p)
|
||||
|
||||
|
||||
## _class_ `ConversationType`
|
||||
|
||||
基类:`str`, `enum.Enum`
|
||||
|
||||
An enumeration.
|
||||
|
||||
|
||||
## _class_ `MessageEvent`
|
||||
|
||||
基类:`nonebot.adapters.ding.event.Event`
|
||||
|
||||
消息事件
|
||||
|
||||
|
||||
## _class_ `PrivateMessageEvent`
|
||||
|
||||
基类:`nonebot.adapters.ding.event.MessageEvent`
|
||||
|
||||
私聊消息事件
|
||||
|
||||
|
||||
## _class_ `GroupMessageEvent`
|
||||
|
||||
基类:`nonebot.adapters.ding.event.MessageEvent`
|
||||
|
||||
群消息事件
|
@@ -1,285 +0,0 @@
|
||||
---
|
||||
contentSidebar: true
|
||||
sidebarDepth: 0
|
||||
---
|
||||
|
||||
# NoneBot.config 模块
|
||||
|
||||
## 配置
|
||||
|
||||
NoneBot 使用 [pydantic](https://pydantic-docs.helpmanual.io/) 以及 [python-dotenv](https://saurabh-kumar.com/python-dotenv/) 来读取配置。
|
||||
|
||||
配置项需符合特殊格式或 json 序列化格式。详情见 [pydantic Field Type](https://pydantic-docs.helpmanual.io/usage/types/) 文档。
|
||||
|
||||
|
||||
## _class_ `Env`
|
||||
|
||||
基类:`pydantic.env_settings.BaseSettings`
|
||||
|
||||
运行环境配置。大小写不敏感。
|
||||
|
||||
将会从 `nonebot.init 参数` > `环境变量` > `.env 环境配置文件` 的优先级读取配置。
|
||||
|
||||
|
||||
### `environment`
|
||||
|
||||
|
||||
* **类型**: `str`
|
||||
|
||||
|
||||
* **默认值**: `"prod"`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
当前环境名。 NoneBot 将从 `.env.{environment}` 文件中加载配置。
|
||||
|
||||
|
||||
|
||||
## _class_ `Config`
|
||||
|
||||
基类:`nonebot.config.BaseConfig`
|
||||
|
||||
NoneBot 主要配置。大小写不敏感。
|
||||
|
||||
除了 NoneBot 的配置项外,还可以自行添加配置项到 `.env.{environment}` 文件中。
|
||||
这些配置将会在 json 反序列化后一起带入 `Config` 类中。
|
||||
|
||||
|
||||
### `driver`
|
||||
|
||||
|
||||
* **类型**: `str`
|
||||
|
||||
|
||||
* **默认值**: `"nonebot.drivers.fastapi"`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
NoneBot 运行所使用的 `Driver` 。继承自 `nonebot.driver.BaseDriver` 。
|
||||
|
||||
|
||||
|
||||
### `host`
|
||||
|
||||
|
||||
* **类型**: `IPvAnyAddress`
|
||||
|
||||
|
||||
* **默认值**: `127.0.0.1`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
NoneBot 的 HTTP 和 WebSocket 服务端监听的 IP/主机名。
|
||||
|
||||
|
||||
|
||||
### `port`
|
||||
|
||||
|
||||
* **类型**: `int`
|
||||
|
||||
|
||||
* **默认值**: `8080`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
NoneBot 的 HTTP 和 WebSocket 服务端监听的端口。
|
||||
|
||||
|
||||
|
||||
### `debug`
|
||||
|
||||
|
||||
* **类型**: `bool`
|
||||
|
||||
|
||||
* **默认值**: `False`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
是否以调试模式运行 NoneBot。
|
||||
|
||||
|
||||
|
||||
### `api_root`
|
||||
|
||||
|
||||
* **类型**: `Dict[str, str]`
|
||||
|
||||
|
||||
* **默认值**: `{}`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
以机器人 ID 为键,上报地址为值的字典,环境变量或文件中应使用 json 序列化。
|
||||
|
||||
|
||||
|
||||
* **示例**
|
||||
|
||||
|
||||
```default
|
||||
API_ROOT={"123456": "http://127.0.0.1:5700"}
|
||||
```
|
||||
|
||||
|
||||
### `api_timeout`
|
||||
|
||||
|
||||
* **类型**: `Optional[float]`
|
||||
|
||||
|
||||
* **默认值**: `30.`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
API 请求超时时间,单位: 秒。
|
||||
|
||||
|
||||
|
||||
### `access_token`
|
||||
|
||||
|
||||
* **类型**: `Optional[str]`
|
||||
|
||||
|
||||
* **默认值**: `None`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
API 请求以及上报所需密钥,在请求头中携带。
|
||||
|
||||
|
||||
|
||||
* **示例**
|
||||
|
||||
|
||||
```http
|
||||
POST /cqhttp/ HTTP/1.1
|
||||
Authorization: Bearer kSLuTF2GC2Q4q4ugm3
|
||||
```
|
||||
|
||||
|
||||
### `secret`
|
||||
|
||||
|
||||
* **类型**: `Optional[str]`
|
||||
|
||||
|
||||
* **默认值**: `None`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
HTTP POST 形式上报所需签名,在请求头中携带。
|
||||
|
||||
|
||||
|
||||
* **示例**
|
||||
|
||||
|
||||
```http
|
||||
POST /cqhttp/ HTTP/1.1
|
||||
X-Signature: sha1=f9ddd4863ace61e64f462d41ca311e3d2c1176e2
|
||||
```
|
||||
|
||||
|
||||
### `superusers`
|
||||
|
||||
|
||||
* **类型**: `Set[str]`
|
||||
|
||||
|
||||
* **默认值**: `set()`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
机器人超级用户。
|
||||
|
||||
|
||||
|
||||
* **示例**
|
||||
|
||||
|
||||
```default
|
||||
SUPER_USERS=["12345789"]
|
||||
```
|
||||
|
||||
|
||||
### `nickname`
|
||||
|
||||
|
||||
* **类型**: `Set[str]`
|
||||
|
||||
|
||||
* **默认值**: `set()`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
机器人昵称。
|
||||
|
||||
|
||||
|
||||
### `command_start`
|
||||
|
||||
|
||||
* **类型**: `Set[str]`
|
||||
|
||||
|
||||
* **默认值**: `{"/"}`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
命令的起始标记,用于判断一条消息是不是命令。
|
||||
|
||||
|
||||
|
||||
### `command_sep`
|
||||
|
||||
|
||||
* **类型**: `Set[str]`
|
||||
|
||||
|
||||
* **默认值**: `{"."}`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
命令的分隔标记,用于将文本形式的命令切分为元组(实际的命令名)。
|
||||
|
||||
|
||||
|
||||
### `session_expire_timeout`
|
||||
|
||||
|
||||
* **类型**: `timedelta`
|
||||
|
||||
|
||||
* **默认值**: `timedelta(minutes=2)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
等待用户回复的超时时间。
|
||||
|
||||
|
||||
|
||||
* **示例**
|
||||
|
||||
|
||||
```default
|
||||
SESSION_EXPIRE_TIMEOUT=120 # 单位: 秒
|
||||
SESSION_EXPIRE_TIMEOUT=[DD ][HH:MM]SS[.ffffff]
|
||||
SESSION_EXPIRE_TIMEOUT=P[DD]DT[HH]H[MM]M[SS]S # ISO 8601
|
||||
```
|
@@ -1,318 +0,0 @@
|
||||
---
|
||||
contentSidebar: true
|
||||
sidebarDepth: 0
|
||||
---
|
||||
|
||||
# NoneBot.drivers 模块
|
||||
|
||||
## 后端驱动适配基类
|
||||
|
||||
各驱动请继承以下基类
|
||||
|
||||
|
||||
## _class_ `Driver`
|
||||
|
||||
基类:`abc.ABC`
|
||||
|
||||
Driver 基类。将后端框架封装,以满足适配器使用。
|
||||
|
||||
|
||||
### `_adapters`
|
||||
|
||||
|
||||
* **类型**
|
||||
|
||||
`Dict[str, Type[Bot]]`
|
||||
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
已注册的适配器列表
|
||||
|
||||
|
||||
|
||||
### `_ws_connection_hook`
|
||||
|
||||
|
||||
* **类型**
|
||||
|
||||
`Set[T_WebSocketConnectionHook]`
|
||||
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
WebSocket 连接建立时执行的函数
|
||||
|
||||
|
||||
|
||||
### `_ws_disconnection_hook`
|
||||
|
||||
|
||||
* **类型**
|
||||
|
||||
`Set[T_WebSocketDisconnectionHook]`
|
||||
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
WebSocket 连接断开时执行的函数
|
||||
|
||||
|
||||
|
||||
### _abstract_ `__init__(env, config)`
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `env: Env`: 包含环境信息的 Env 对象
|
||||
|
||||
|
||||
* `config: Config`: 包含配置信息的 Config 对象
|
||||
|
||||
|
||||
|
||||
### `env`
|
||||
|
||||
|
||||
* **类型**
|
||||
|
||||
`str`
|
||||
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
环境名称
|
||||
|
||||
|
||||
|
||||
### `config`
|
||||
|
||||
|
||||
* **类型**
|
||||
|
||||
`Config`
|
||||
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
配置对象
|
||||
|
||||
|
||||
|
||||
### `_clients`
|
||||
|
||||
|
||||
* **类型**
|
||||
|
||||
`Dict[str, Bot]`
|
||||
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
已连接的 Bot
|
||||
|
||||
|
||||
|
||||
### _classmethod_ `register_adapter(name, adapter)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
注册一个协议适配器
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `name: str`: 适配器名称,用于在连接时进行识别
|
||||
|
||||
|
||||
* `adapter: Type[Bot]`: 适配器 Class
|
||||
|
||||
|
||||
|
||||
### _abstract property_ `type`
|
||||
|
||||
驱动类型名称
|
||||
|
||||
|
||||
### _abstract property_ `server_app`
|
||||
|
||||
驱动 APP 对象
|
||||
|
||||
|
||||
### _abstract property_ `asgi`
|
||||
|
||||
驱动 ASGI 对象
|
||||
|
||||
|
||||
### _abstract property_ `logger`
|
||||
|
||||
驱动专属 logger 日志记录器
|
||||
|
||||
|
||||
### _property_ `bots`
|
||||
|
||||
|
||||
* **类型**
|
||||
|
||||
`Dict[str, Bot]`
|
||||
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
获取当前所有已连接的 Bot
|
||||
|
||||
|
||||
|
||||
### _abstract_ `on_startup(func)`
|
||||
|
||||
注册一个在驱动启动时运行的函数
|
||||
|
||||
|
||||
### _abstract_ `on_shutdown(func)`
|
||||
|
||||
注册一个在驱动停止时运行的函数
|
||||
|
||||
|
||||
### `on_bot_connect(func)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
装饰一个函数使他在 bot 通过 WebSocket 连接成功时执行。
|
||||
|
||||
|
||||
|
||||
* **函数参数**
|
||||
|
||||
|
||||
* `bot: Bot`: 当前连接上的 Bot 对象
|
||||
|
||||
|
||||
|
||||
### `on_bot_disconnect(func)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
装饰一个函数使他在 bot 通过 WebSocket 连接断开时执行。
|
||||
|
||||
|
||||
|
||||
* **函数参数**
|
||||
|
||||
|
||||
* `bot: Bot`: 当前连接上的 Bot 对象
|
||||
|
||||
|
||||
|
||||
### `_bot_connect(bot)`
|
||||
|
||||
在 WebSocket 连接成功后,调用该函数来注册 bot 对象
|
||||
|
||||
|
||||
### `_bot_disconnect(bot)`
|
||||
|
||||
在 WebSocket 连接断开后,调用该函数来注销 bot 对象
|
||||
|
||||
|
||||
### _abstract_ `run(host=None, port=None, *args, **kwargs)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
启动驱动框架
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `host: Optional[str]`: 驱动绑定 IP
|
||||
|
||||
|
||||
* `post: Optional[int]`: 驱动绑定端口
|
||||
|
||||
|
||||
* `*args`
|
||||
|
||||
|
||||
* `**kwargs`
|
||||
|
||||
|
||||
|
||||
### _abstract async_ `_handle_http()`
|
||||
|
||||
用于处理 HTTP 类型请求的函数
|
||||
|
||||
|
||||
### _abstract async_ `_handle_ws_reverse()`
|
||||
|
||||
用于处理 WebSocket 类型请求的函数
|
||||
|
||||
|
||||
## _class_ `WebSocket`
|
||||
|
||||
基类:`object`
|
||||
|
||||
WebSocket 连接封装,统一接口方便外部调用。
|
||||
|
||||
|
||||
### _abstract_ `__init__(websocket)`
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `websocket: Any`: WebSocket 连接对象
|
||||
|
||||
|
||||
|
||||
### _property_ `websocket`
|
||||
|
||||
WebSocket 连接对象
|
||||
|
||||
|
||||
### _abstract property_ `closed`
|
||||
|
||||
|
||||
* **类型**
|
||||
|
||||
`bool`
|
||||
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
连接是否已经关闭
|
||||
|
||||
|
||||
|
||||
### _abstract async_ `accept()`
|
||||
|
||||
接受 WebSocket 连接请求
|
||||
|
||||
|
||||
### _abstract async_ `close(code)`
|
||||
|
||||
关闭 WebSocket 连接请求
|
||||
|
||||
|
||||
### _abstract async_ `receive()`
|
||||
|
||||
接收一条 WebSocket 信息
|
||||
|
||||
|
||||
### _abstract async_ `send(data)`
|
||||
|
||||
发送一条 WebSocket 信息
|
@@ -1,68 +0,0 @@
|
||||
---
|
||||
contentSidebar: true
|
||||
sidebarDepth: 0
|
||||
---
|
||||
|
||||
# NoneBot.drivers.fastapi 模块
|
||||
|
||||
## FastAPI 驱动适配
|
||||
|
||||
后端使用方法请参考: [FastAPI 文档](https://fastapi.tiangolo.com/)
|
||||
|
||||
|
||||
## _class_ `Driver`
|
||||
|
||||
基类:[`nonebot.drivers.Driver`](README.md#nonebot.drivers.Driver)
|
||||
|
||||
FastAPI 驱动框架
|
||||
|
||||
|
||||
* **上报地址**
|
||||
|
||||
|
||||
* `/{adapter name}/`: HTTP POST 上报
|
||||
|
||||
|
||||
* `/{adapter name}/http/`: HTTP POST 上报
|
||||
|
||||
|
||||
* `/{adapter name}/ws`: WebSocket 上报
|
||||
|
||||
|
||||
* `/{adapter name}/ws/`: WebSocket 上报
|
||||
|
||||
|
||||
|
||||
### _property_ `type`
|
||||
|
||||
驱动名称: `fastapi`
|
||||
|
||||
|
||||
### _property_ `server_app`
|
||||
|
||||
`FastAPI APP` 对象
|
||||
|
||||
|
||||
### _property_ `asgi`
|
||||
|
||||
`FastAPI APP` 对象
|
||||
|
||||
|
||||
### _property_ `logger`
|
||||
|
||||
fastapi 使用的 logger
|
||||
|
||||
|
||||
### `on_startup(func)`
|
||||
|
||||
参考文档: [Events](https://fastapi.tiangolo.com/advanced/events/#startup-event)
|
||||
|
||||
|
||||
### `on_shutdown(func)`
|
||||
|
||||
参考文档: [Events](https://fastapi.tiangolo.com/advanced/events/#startup-event)
|
||||
|
||||
|
||||
### `run(host=None, port=None, *, app=None, **kwargs)`
|
||||
|
||||
使用 `uvicorn` 启动 FastAPI
|
@@ -1,193 +0,0 @@
|
||||
---
|
||||
contentSidebar: true
|
||||
sidebarDepth: 0
|
||||
---
|
||||
|
||||
# NoneBot.exception 模块
|
||||
|
||||
## 异常
|
||||
|
||||
下列文档中的异常是所有 NoneBot 运行时可能会抛出的。
|
||||
这些异常并非所有需要用户处理,在 NoneBot 内部运行时被捕获,并进行对应操作。
|
||||
|
||||
|
||||
## _exception_ `NoneBotException`
|
||||
|
||||
基类:`Exception`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
所有 NoneBot 发生的异常基类。
|
||||
|
||||
|
||||
|
||||
## _exception_ `IgnoredException`
|
||||
|
||||
基类:`nonebot.exception.NoneBotException`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
指示 NoneBot 应该忽略该事件。可由 PreProcessor 抛出。
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `reason`: 忽略事件的原因
|
||||
|
||||
|
||||
|
||||
## _exception_ `PausedException`
|
||||
|
||||
基类:`nonebot.exception.NoneBotException`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
指示 NoneBot 结束当前 `Handler` 并等待下一条消息后继续下一个 `Handler`。
|
||||
可用于用户输入新信息。
|
||||
|
||||
|
||||
|
||||
* **用法**
|
||||
|
||||
可以在 `Handler` 中通过 `Matcher.pause()` 抛出。
|
||||
|
||||
|
||||
|
||||
## _exception_ `RejectedException`
|
||||
|
||||
基类:`nonebot.exception.NoneBotException`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
指示 NoneBot 结束当前 `Handler` 并等待下一条消息后重新运行当前 `Handler`。
|
||||
可用于用户重新输入。
|
||||
|
||||
|
||||
|
||||
* **用法**
|
||||
|
||||
可以在 `Handler` 中通过 `Matcher.reject()` 抛出。
|
||||
|
||||
|
||||
|
||||
## _exception_ `FinishedException`
|
||||
|
||||
基类:`nonebot.exception.NoneBotException`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
指示 NoneBot 结束当前 `Handler` 且后续 `Handler` 不再被运行。
|
||||
可用于结束用户会话。
|
||||
|
||||
|
||||
|
||||
* **用法**
|
||||
|
||||
可以在 `Handler` 中通过 `Matcher.finish()` 抛出。
|
||||
|
||||
|
||||
|
||||
## _exception_ `StopPropagation`
|
||||
|
||||
基类:`nonebot.exception.NoneBotException`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
指示 NoneBot 终止事件向下层传播。
|
||||
|
||||
|
||||
|
||||
* **用法**
|
||||
|
||||
在 `Matcher.block == True` 时抛出。
|
||||
|
||||
|
||||
|
||||
## _exception_ `RequestDenied`
|
||||
|
||||
基类:`nonebot.exception.NoneBotException`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
Bot 连接请求不合法。
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `status_code: int`: HTTP 状态码
|
||||
|
||||
|
||||
* `reason: str`: 拒绝原因
|
||||
|
||||
|
||||
|
||||
## _exception_ `AdapterException`
|
||||
|
||||
基类:`nonebot.exception.NoneBotException`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
代表 `Adapter` 抛出的异常,所有的 `Adapter` 都要在内部继承自这个 `Exception`
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `adapter_name: str`: 标识 adapter
|
||||
|
||||
|
||||
|
||||
## _exception_ `NoLogException`
|
||||
|
||||
基类:`Exception`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
指示 NoneBot 对当前 `Event` 进行处理但不显示 Log 信息,可在 `get_log_string` 时抛出
|
||||
|
||||
|
||||
|
||||
## _exception_ `ApiNotAvailable`
|
||||
|
||||
基类:`nonebot.exception.AdapterException`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
在 API 连接不可用时抛出。
|
||||
|
||||
|
||||
|
||||
## _exception_ `NetworkError`
|
||||
|
||||
基类:`nonebot.exception.AdapterException`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
在网络出现问题时抛出,如: API 请求地址不正确, API 请求无返回或返回状态非正常等。
|
||||
|
||||
|
||||
|
||||
## _exception_ `ActionFailed`
|
||||
|
||||
基类:`nonebot.exception.AdapterException`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
API 请求成功返回数据,但 API 操作失败。
|
@@ -1,42 +0,0 @@
|
||||
---
|
||||
contentSidebar: true
|
||||
sidebarDepth: 0
|
||||
---
|
||||
|
||||
# NoneBot.log 模块
|
||||
|
||||
## 日志
|
||||
|
||||
NoneBot 使用 [loguru](https://github.com/Delgan/loguru) 来记录日志信息。
|
||||
|
||||
自定义 logger 请参考 [loguru](https://github.com/Delgan/loguru) 文档。
|
||||
|
||||
|
||||
## `logger`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
NoneBot 日志记录器对象。
|
||||
|
||||
|
||||
|
||||
* **默认信息**
|
||||
|
||||
|
||||
* 格式: `[%(asctime)s %(name)s] %(levelname)s: %(message)s`
|
||||
|
||||
|
||||
* 等级: `DEBUG` / `INFO` ,根据 config 配置改变
|
||||
|
||||
|
||||
* 输出: 输出至 stdout
|
||||
|
||||
|
||||
|
||||
* **用法**
|
||||
|
||||
|
||||
```python
|
||||
from nonebot.log import logger
|
||||
```
|
@@ -1,470 +0,0 @@
|
||||
---
|
||||
contentSidebar: true
|
||||
sidebarDepth: 0
|
||||
---
|
||||
|
||||
# NoneBot.matcher 模块
|
||||
|
||||
## 事件响应器
|
||||
|
||||
该模块实现事件响应器的创建与运行,并提供一些快捷方法来帮助用户更好的与机器人进行 对话 。
|
||||
|
||||
|
||||
## `matchers`
|
||||
|
||||
|
||||
* **类型**
|
||||
|
||||
`Dict[int, List[Type[Matcher]]]`
|
||||
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
用于存储当前所有的事件响应器
|
||||
|
||||
|
||||
|
||||
## _class_ `Matcher`
|
||||
|
||||
基类:`object`
|
||||
|
||||
事件响应器类
|
||||
|
||||
|
||||
### `module`
|
||||
|
||||
|
||||
* **类型**
|
||||
|
||||
`Optional[str]`
|
||||
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
事件响应器所在模块名称
|
||||
|
||||
|
||||
|
||||
### `type`
|
||||
|
||||
|
||||
* **类型**
|
||||
|
||||
`str`
|
||||
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
事件响应器类型
|
||||
|
||||
|
||||
|
||||
### `rule`
|
||||
|
||||
|
||||
* **类型**
|
||||
|
||||
`Rule`
|
||||
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
事件响应器匹配规则
|
||||
|
||||
|
||||
|
||||
### `permission`
|
||||
|
||||
|
||||
* **类型**
|
||||
|
||||
`Permission`
|
||||
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
事件响应器触发权限
|
||||
|
||||
|
||||
|
||||
### `priority`
|
||||
|
||||
|
||||
* **类型**
|
||||
|
||||
`int`
|
||||
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
事件响应器优先级
|
||||
|
||||
|
||||
|
||||
### `block`
|
||||
|
||||
|
||||
* **类型**
|
||||
|
||||
`bool`
|
||||
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
事件响应器是否阻止事件传播
|
||||
|
||||
|
||||
|
||||
### `temp`
|
||||
|
||||
|
||||
* **类型**
|
||||
|
||||
`bool`
|
||||
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
事件响应器是否为临时
|
||||
|
||||
|
||||
|
||||
### `expire_time`
|
||||
|
||||
|
||||
* **类型**
|
||||
|
||||
`Optional[datetime]`
|
||||
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
事件响应器过期时间点
|
||||
|
||||
|
||||
|
||||
### `_default_state`
|
||||
|
||||
|
||||
* **类型**
|
||||
|
||||
`T_State`
|
||||
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
事件响应器默认状态
|
||||
|
||||
|
||||
|
||||
### `_default_state_factory`
|
||||
|
||||
|
||||
* **类型**
|
||||
|
||||
`Optional[T_State]`
|
||||
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
事件响应器默认工厂函数
|
||||
|
||||
|
||||
|
||||
### `_default_parser`
|
||||
|
||||
|
||||
* **类型**
|
||||
|
||||
`Optional[T_ArgsParser]`
|
||||
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
事件响应器默认参数解析函数
|
||||
|
||||
|
||||
|
||||
### `__init__()`
|
||||
|
||||
实例化 Matcher 以便运行
|
||||
|
||||
|
||||
### `handlers`
|
||||
|
||||
|
||||
* **类型**
|
||||
|
||||
`List[T_Handler]`
|
||||
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
事件响应器拥有的事件处理函数列表
|
||||
|
||||
|
||||
|
||||
### _classmethod_ `new(type_='', rule=None, permission=None, handlers=None, temp=False, priority=1, block=False, *, module=None, default_state=None, default_state_factory=None, expire_time=None)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
创建一个新的事件响应器,并存储至 [matchers](#matchers)
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `type_: str`: 事件响应器类型,与 `event.get_type()` 一致时触发,空字符串表示任意
|
||||
|
||||
|
||||
* `rule: Optional[Rule]`: 匹配规则
|
||||
|
||||
|
||||
* `permission: Optional[Permission]`: 权限
|
||||
|
||||
|
||||
* `handlers: Optional[List[T_Handler]]`: 事件处理函数列表
|
||||
|
||||
|
||||
* `temp: bool`: 是否为临时事件响应器,即触发一次后删除
|
||||
|
||||
|
||||
* `priority: int`: 响应优先级
|
||||
|
||||
|
||||
* `block: bool`: 是否阻止事件向更低优先级的响应器传播
|
||||
|
||||
|
||||
* `module: Optional[str]`: 事件响应器所在模块名称
|
||||
|
||||
|
||||
* `default_state: Optional[T_State]`: 默认状态 `state`
|
||||
|
||||
|
||||
* `default_state_factory: Optional[T_StateFactory]`: 默认状态 `state` 的工厂函数
|
||||
|
||||
|
||||
* `expire_time: Optional[datetime]`: 事件响应器最终有效时间点,过时即被删除
|
||||
|
||||
|
||||
|
||||
* **返回**
|
||||
|
||||
|
||||
* `Type[Matcher]`: 新的事件响应器类
|
||||
|
||||
|
||||
|
||||
### _async classmethod_ `check_perm(bot, event)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
检查是否满足触发权限
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `bot: Bot`: Bot 对象
|
||||
|
||||
|
||||
* `event: Event`: 上报事件
|
||||
|
||||
|
||||
|
||||
* **返回**
|
||||
|
||||
|
||||
* `bool`: 是否满足权限
|
||||
|
||||
|
||||
|
||||
### _async classmethod_ `check_rule(bot, event, state)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
检查是否满足匹配规则
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `bot: Bot`: Bot 对象
|
||||
|
||||
|
||||
* `event: Event`: 上报事件
|
||||
|
||||
|
||||
* `state: T_State`: 当前状态
|
||||
|
||||
|
||||
|
||||
* **返回**
|
||||
|
||||
|
||||
* `bool`: 是否满足匹配规则
|
||||
|
||||
|
||||
|
||||
### _classmethod_ `args_parser(func)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
装饰一个函数来更改当前事件响应器的默认参数解析函数
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `func: T_ArgsParser`: 参数解析函数
|
||||
|
||||
|
||||
|
||||
### _classmethod_ `handle()`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
装饰一个函数来向事件响应器直接添加一个处理函数
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* 无
|
||||
|
||||
|
||||
|
||||
### _classmethod_ `receive()`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
装饰一个函数来指示 NoneBot 在接收用户新的一条消息后继续运行该函数
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* 无
|
||||
|
||||
|
||||
|
||||
### _classmethod_ `got(key, prompt=None, args_parser=None)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
装饰一个函数来指示 NoneBot 当要获取的 `key` 不存在时接收用户新的一条消息并经过 `ArgsParser` 处理后再运行该函数,如果 `key` 已存在则直接继续运行
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `key: str`: 参数名
|
||||
|
||||
|
||||
* `prompt: Optional[Union[str, Message, MessageSegment]]`: 在参数不存在时向用户发送的消息
|
||||
|
||||
|
||||
* `args_parser: Optional[T_ArgsParser]`: 可选参数解析函数,空则使用默认解析函数
|
||||
|
||||
|
||||
|
||||
### _async classmethod_ `send(message, **kwargs)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
发送一条消息给当前交互用户
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `message: Union[str, Message, MessageSegment]`: 消息内容
|
||||
|
||||
|
||||
* `**kwargs`: 其他传递给 `bot.send` 的参数,请参考对应 adapter 的 bot 对象 api
|
||||
|
||||
|
||||
|
||||
### _async classmethod_ `finish(message=None, **kwargs)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
发送一条消息给当前交互用户并结束当前事件响应器
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `message: Union[str, Message, MessageSegment]`: 消息内容
|
||||
|
||||
|
||||
* `**kwargs`: 其他传递给 `bot.send` 的参数,请参考对应 adapter 的 bot 对象 api
|
||||
|
||||
|
||||
|
||||
### _async classmethod_ `pause(prompt=None, **kwargs)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
发送一条消息给当前交互用户并暂停事件响应器,在接收用户新的一条消息后继续下一个处理函数
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `prompt: Union[str, Message, MessageSegment]`: 消息内容
|
||||
|
||||
|
||||
* `**kwargs`: 其他传递给 `bot.send` 的参数,请参考对应 adapter 的 bot 对象 api
|
||||
|
||||
|
||||
|
||||
### _async classmethod_ `reject(prompt=None, **kwargs)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
发送一条消息给当前交互用户并暂停事件响应器,在接收用户新的一条消息后重新运行当前处理函数
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `prompt: Union[str, Message, MessageSegment]`: 消息内容
|
||||
|
||||
|
||||
* `**kwargs`: 其他传递给 `bot.send` 的参数,请参考对应 adapter 的 bot 对象 api
|
@@ -1,143 +0,0 @@
|
||||
---
|
||||
contentSidebar: true
|
||||
sidebarDepth: 0
|
||||
---
|
||||
|
||||
# NoneBot.message 模块
|
||||
|
||||
## 事件处理
|
||||
|
||||
NoneBot 内部处理并按优先级分发事件给所有事件响应器,提供了多个插槽以进行事件的预处理等。
|
||||
|
||||
|
||||
## `event_preprocessor(func)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
事件预处理。装饰一个函数,使它在每次接收到事件并分发给各响应器之前执行。
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
事件预处理函数接收三个参数。
|
||||
|
||||
|
||||
* `bot: Bot`: Bot 对象
|
||||
|
||||
|
||||
* `event: Event`: Event 对象
|
||||
|
||||
|
||||
* `state: T_State`: 当前 State
|
||||
|
||||
|
||||
|
||||
## `event_postprocessor(func)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
事件后处理。装饰一个函数,使它在每次接收到事件并分发给各响应器之后执行。
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
事件后处理函数接收三个参数。
|
||||
|
||||
|
||||
* `bot: Bot`: Bot 对象
|
||||
|
||||
|
||||
* `event: Event`: Event 对象
|
||||
|
||||
|
||||
* `state: T_State`: 当前事件运行前 State
|
||||
|
||||
|
||||
|
||||
## `run_preprocessor(func)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
运行预处理。装饰一个函数,使它在每次事件响应器运行前执行。
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
运行预处理函数接收四个参数。
|
||||
|
||||
|
||||
* `matcher: Matcher`: 当前要运行的事件响应器
|
||||
|
||||
|
||||
* `bot: Bot`: Bot 对象
|
||||
|
||||
|
||||
* `event: Event`: Event 对象
|
||||
|
||||
|
||||
* `state: T_State`: 当前 State
|
||||
|
||||
|
||||
|
||||
## `run_postprocessor(func)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
运行后处理。装饰一个函数,使它在每次事件响应器运行后执行。
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
运行后处理函数接收五个参数。
|
||||
|
||||
|
||||
* `matcher: Matcher`: 运行完毕的事件响应器
|
||||
|
||||
|
||||
* `exception: Optional[Exception]`: 事件响应器运行错误(如果存在)
|
||||
|
||||
|
||||
* `bot: Bot`: Bot 对象
|
||||
|
||||
|
||||
* `event: Event`: Event 对象
|
||||
|
||||
|
||||
* `state: T_State`: 当前 State
|
||||
|
||||
|
||||
|
||||
## _async_ `handle_event(bot, event)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
处理一个事件。调用该函数以实现分发事件。
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `bot: Bot`: Bot 对象
|
||||
|
||||
|
||||
* `event: Event`: Event 对象
|
||||
|
||||
|
||||
|
||||
* **示例**
|
||||
|
||||
|
||||
```python
|
||||
import asyncio
|
||||
asyncio.create_task(handle_event(bot, event))
|
||||
```
|
@@ -1,266 +0,0 @@
|
||||
---
|
||||
contentSidebar: true
|
||||
sidebarDepth: 0
|
||||
---
|
||||
|
||||
# NoneBot 模块
|
||||
|
||||
## 快捷导入
|
||||
|
||||
为方便使用,`nonebot` 模块从子模块导入了部分内容
|
||||
|
||||
|
||||
* `on_message` => `nonebot.plugin.on_message`
|
||||
|
||||
|
||||
* `on_notice` => `nonebot.plugin.on_notice`
|
||||
|
||||
|
||||
* `on_request` => `nonebot.plugin.on_request`
|
||||
|
||||
|
||||
* `on_metaevent` => `nonebot.plugin.on_metaevent`
|
||||
|
||||
|
||||
* `on_startswith` => `nonebot.plugin.on_startswith`
|
||||
|
||||
|
||||
* `on_endswith` => `nonebot.plugin.on_endswith`
|
||||
|
||||
|
||||
* `on_keyword` => `nonebot.plugin.on_keyword`
|
||||
|
||||
|
||||
* `on_command` => `nonebot.plugin.on_command`
|
||||
|
||||
|
||||
* `on_regex` => `nonebot.plugin.on_regex`
|
||||
|
||||
|
||||
* `CommandGroup` => `nonebot.plugin.CommandGroup`
|
||||
|
||||
|
||||
* `Matchergroup` => `nonebot.plugin.MatcherGroup`
|
||||
|
||||
|
||||
* `load_plugin` => `nonebot.plugin.load_plugin`
|
||||
|
||||
|
||||
* `load_plugins` => `nonebot.plugin.load_plugins`
|
||||
|
||||
|
||||
* `load_builtin_plugins` => `nonebot.plugin.load_builtin_plugins`
|
||||
|
||||
|
||||
* `get_plugin` => `nonebot.plugin.get_plugin`
|
||||
|
||||
|
||||
* `get_loaded_plugins` => `nonebot.plugin.get_loaded_plugins`
|
||||
|
||||
|
||||
* `export` => `nonebot.plugin.export`
|
||||
|
||||
|
||||
* `require` => `nonebot.plugin.require`
|
||||
|
||||
|
||||
## `get_driver()`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
获取全局 Driver 对象。可用于在计划任务的回调中获取当前 Driver 对象。
|
||||
|
||||
|
||||
|
||||
* **返回**
|
||||
|
||||
|
||||
* `Driver`: 全局 Driver 对象
|
||||
|
||||
|
||||
|
||||
* **异常**
|
||||
|
||||
|
||||
* `ValueError`: 全局 Driver 对象尚未初始化 (nonebot.init 尚未调用)
|
||||
|
||||
|
||||
|
||||
* **用法**
|
||||
|
||||
|
||||
```python
|
||||
driver = nonebot.get_driver()
|
||||
```
|
||||
|
||||
|
||||
## `get_app()`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
获取全局 Driver 对应 Server App 对象。
|
||||
|
||||
|
||||
|
||||
* **返回**
|
||||
|
||||
|
||||
* `Any`: Server App 对象
|
||||
|
||||
|
||||
|
||||
* **异常**
|
||||
|
||||
|
||||
* `ValueError`: 全局 Driver 对象尚未初始化 (nonebot.init 尚未调用)
|
||||
|
||||
|
||||
|
||||
* **用法**
|
||||
|
||||
|
||||
```python
|
||||
app = nonebot.get_app()
|
||||
```
|
||||
|
||||
|
||||
## `get_asgi()`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
获取全局 Driver 对应 Asgi 对象。
|
||||
|
||||
|
||||
|
||||
* **返回**
|
||||
|
||||
|
||||
* `Any`: Asgi 对象
|
||||
|
||||
|
||||
|
||||
* **异常**
|
||||
|
||||
|
||||
* `ValueError`: 全局 Driver 对象尚未初始化 (nonebot.init 尚未调用)
|
||||
|
||||
|
||||
|
||||
* **用法**
|
||||
|
||||
|
||||
```python
|
||||
asgi = nonebot.get_asgi()
|
||||
```
|
||||
|
||||
|
||||
## `get_bots()`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
获取所有通过 ws 连接 NoneBot 的 Bot 对象。
|
||||
|
||||
|
||||
|
||||
* **返回**
|
||||
|
||||
|
||||
* `Dict[str, Bot]`: 一个以字符串 ID 为键,Bot 对象为值的字典
|
||||
|
||||
|
||||
|
||||
* **异常**
|
||||
|
||||
|
||||
* `ValueError`: 全局 Driver 对象尚未初始化 (nonebot.init 尚未调用)
|
||||
|
||||
|
||||
|
||||
* **用法**
|
||||
|
||||
|
||||
```python
|
||||
bots = nonebot.get_bots()
|
||||
```
|
||||
|
||||
|
||||
## `init(*, _env_file=None, **kwargs)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
初始化 NoneBot 以及 全局 Driver 对象。
|
||||
|
||||
NoneBot 将会从 .env 文件中读取环境信息,并使用相应的 env 文件配置。
|
||||
|
||||
你也可以传入自定义的 _env_file 来指定 NoneBot 从该文件读取配置。
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `_env_file: Optional[str]`: 配置文件名,默认从 .env.{env_name} 中读取配置
|
||||
|
||||
|
||||
* `**kwargs`: 任意变量,将会存储到 Config 对象里
|
||||
|
||||
|
||||
|
||||
* **返回**
|
||||
|
||||
|
||||
* `None`
|
||||
|
||||
|
||||
|
||||
* **用法**
|
||||
|
||||
|
||||
```python
|
||||
nonebot.init(database=Database(...))
|
||||
```
|
||||
|
||||
|
||||
## `run(host=None, port=None, *args, **kwargs)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
启动 NoneBot,即运行全局 Driver 对象。
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `host: Optional[str]`: 主机名/IP,若不传入则使用配置文件中指定的值
|
||||
|
||||
|
||||
* `port: Optional[int]`: 端口,若不传入则使用配置文件中指定的值
|
||||
|
||||
|
||||
* `*args`: 传入 Driver.run 的位置参数
|
||||
|
||||
|
||||
* `**kwargs`: 传入 Driver.run 的命名参数
|
||||
|
||||
|
||||
|
||||
* **返回**
|
||||
|
||||
|
||||
* `None`
|
||||
|
||||
|
||||
|
||||
* **用法**
|
||||
|
||||
|
||||
```python
|
||||
nonebot.run(host="127.0.0.1", port=8080)
|
||||
```
|
@@ -1,63 +0,0 @@
|
||||
---
|
||||
contentSidebar: true
|
||||
sidebarDepth: 0
|
||||
---
|
||||
|
||||
# NoneBot.permission 模块
|
||||
|
||||
## 权限
|
||||
|
||||
每个 `Matcher` 拥有一个 `Permission` ,其中是 **异步** `PermissionChecker` 的集合,只要有一个 `PermissionChecker` 检查结果为 `True` 时就会继续运行。
|
||||
|
||||
:::tip 提示
|
||||
`PermissionChecker` 既可以是 async function 也可以是 sync function
|
||||
:::
|
||||
|
||||
|
||||
## `MESSAGE`
|
||||
|
||||
|
||||
* **说明**: 匹配任意 `message` 类型事件,仅在需要同时捕获不同类型事件时使用。优先使用 message type 的 Matcher。
|
||||
|
||||
|
||||
## `NOTICE`
|
||||
|
||||
|
||||
* **说明**: 匹配任意 `notice` 类型事件,仅在需要同时捕获不同类型事件时使用。优先使用 notice type 的 Matcher。
|
||||
|
||||
|
||||
## `REQUEST`
|
||||
|
||||
|
||||
* **说明**: 匹配任意 `request` 类型事件,仅在需要同时捕获不同类型事件时使用。优先使用 request type 的 Matcher。
|
||||
|
||||
|
||||
## `METAEVENT`
|
||||
|
||||
|
||||
* **说明**: 匹配任意 `meta_event` 类型事件,仅在需要同时捕获不同类型事件时使用。优先使用 meta_event type 的 Matcher。
|
||||
|
||||
|
||||
## `USER(*user, perm=<nonebot.permission.Permission object>)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
在白名单内且满足 perm
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `*user: str`: 白名单
|
||||
|
||||
|
||||
* `perm: Permission`: 需要同时满足的权限
|
||||
|
||||
|
||||
|
||||
## `SUPERUSER`
|
||||
|
||||
|
||||
* **说明**: 匹配任意超级用户消息类型事件
|
File diff suppressed because it is too large
Load Diff
@@ -1,210 +0,0 @@
|
||||
---
|
||||
contentSidebar: true
|
||||
sidebarDepth: 0
|
||||
---
|
||||
|
||||
# NoneBot.rule 模块
|
||||
|
||||
## 规则
|
||||
|
||||
每个事件响应器 `Matcher` 拥有一个匹配规则 `Rule` ,其中是 **异步** `RuleChecker` 的集合,只有当所有 `RuleChecker` 检查结果为 `True` 时继续运行。
|
||||
|
||||
:::tip 提示
|
||||
`RuleChecker` 既可以是 async function 也可以是 sync function,但在最终会被 `nonebot.utils.run_sync` 转换为 async function
|
||||
:::
|
||||
|
||||
|
||||
## _class_ `Rule`
|
||||
|
||||
基类:`object`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
`Matcher` 规则类,当事件传递时,在 `Matcher` 运行前进行检查。
|
||||
|
||||
|
||||
|
||||
* **示例**
|
||||
|
||||
|
||||
```python
|
||||
Rule(async_function) & sync_function
|
||||
# 等价于
|
||||
from nonebot.utils import run_sync
|
||||
Rule(async_function, run_sync(sync_function))
|
||||
```
|
||||
|
||||
|
||||
### `__init__(*checkers)`
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `*checkers: Callable[[Bot, Event, T_State], Awaitable[bool]]`: **异步** RuleChecker
|
||||
|
||||
|
||||
|
||||
### `checkers`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
存储 `RuleChecker`
|
||||
|
||||
|
||||
|
||||
* **类型**
|
||||
|
||||
|
||||
* `Set[Callable[[Bot, Event, T_State], Awaitable[bool]]]`
|
||||
|
||||
|
||||
|
||||
### _async_ `__call__(bot, event, state)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
检查是否符合所有规则
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `bot: Bot`: Bot 对象
|
||||
|
||||
|
||||
* `event: Event`: Event 对象
|
||||
|
||||
|
||||
* `state: T_State`: 当前 State
|
||||
|
||||
|
||||
|
||||
* **返回**
|
||||
|
||||
|
||||
* `bool`
|
||||
|
||||
|
||||
|
||||
## `startswith(msg)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
匹配消息开头
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `msg: str`: 消息开头字符串
|
||||
|
||||
|
||||
|
||||
## `endswith(msg)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
匹配消息结尾
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `msg: str`: 消息结尾字符串
|
||||
|
||||
|
||||
|
||||
## `keyword(*keywords)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
匹配消息关键词
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `*keywords: str`: 关键词
|
||||
|
||||
|
||||
|
||||
## `command(*cmds)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
命令形式匹配,根据配置里提供的 `command_start`, `command_sep` 判断消息是否为命令。
|
||||
|
||||
可以通过 `state["_prefix"]["command"]` 获取匹配成功的命令(例:`("test",)`),通过 `state["_prefix"]["raw_command"]` 获取匹配成功的原始命令文本(例:`"/test"`)。
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `*cmds: Union[str, Tuple[str, ...]]`: 命令内容
|
||||
|
||||
|
||||
|
||||
* **示例**
|
||||
|
||||
使用默认 `command_start`, `command_sep` 配置
|
||||
|
||||
命令 `("test",)` 可以匹配:`/test` 开头的消息
|
||||
命令 `("test", "sub")` 可以匹配”`/test.sub` 开头的消息
|
||||
|
||||
|
||||
:::tip 提示
|
||||
命令内容与后续消息间无需空格!
|
||||
:::
|
||||
|
||||
|
||||
## `regex(regex, flags=0)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
根据正则表达式进行匹配。
|
||||
|
||||
可以通过 `state["_matched"]` 获取正则表达式匹配成功的文本。
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `regex: str`: 正则表达式
|
||||
|
||||
|
||||
* `flags: Union[int, re.RegexFlag]`: 正则标志
|
||||
|
||||
|
||||
:::tip 提示
|
||||
正则表达式匹配使用 search 而非 match,如需从头匹配请使用 `r"^xxx"` 来确保匹配开头
|
||||
:::
|
||||
|
||||
|
||||
## `to_me()`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
通过 `event.is_tome()` 判断事件是否与机器人有关
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* 无
|
@@ -1,214 +0,0 @@
|
||||
---
|
||||
contentSidebar: true
|
||||
sidebarDepth: 0
|
||||
---
|
||||
|
||||
# NoneBot.typing 模块
|
||||
|
||||
## 类型
|
||||
|
||||
下面的文档中,「类型」部分使用 Python 的 Type Hint 语法,见 [PEP 484](https://www.python.org/dev/peps/pep-0484/)、[PEP 526](https://www.python.org/dev/peps/pep-0526/) 和 [typing](https://docs.python.org/3/library/typing.html)。
|
||||
|
||||
除了 Python 内置的类型,下面还出现了如下 NoneBot 自定类型,实际上它们是 Python 内置类型的别名。
|
||||
|
||||
以下类型均可从 nonebot.typing 模块导入。
|
||||
|
||||
|
||||
## `T_State`
|
||||
|
||||
|
||||
* **类型**
|
||||
|
||||
`Dict[Any, Any]`
|
||||
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
事件处理状态 State 类型
|
||||
|
||||
|
||||
|
||||
|
||||
## `T_StateFactory`
|
||||
|
||||
|
||||
* **类型**
|
||||
|
||||
`Callable[[Bot, Event], Awaitable[T_State]]`
|
||||
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
事件处理状态 State 类工厂函数
|
||||
|
||||
|
||||
|
||||
|
||||
## `T_WebSocketConnectionHook`
|
||||
|
||||
|
||||
* **类型**
|
||||
|
||||
`Callable[[Bot], Awaitable[None]]`
|
||||
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
WebSocket 连接建立时执行的函数
|
||||
|
||||
|
||||
|
||||
|
||||
## `T_WebSocketDisconnectionHook`
|
||||
|
||||
|
||||
* **类型**
|
||||
|
||||
`Callable[[Bot], Awaitable[None]]`
|
||||
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
WebSocket 连接断开时执行的函数
|
||||
|
||||
|
||||
|
||||
|
||||
## `T_EventPreProcessor`
|
||||
|
||||
|
||||
* **类型**
|
||||
|
||||
`Callable[[Bot, Event, T_State], Awaitable[None]]`
|
||||
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
事件预处理函数 EventPreProcessor 类型
|
||||
|
||||
|
||||
|
||||
|
||||
## `T_EventPostProcessor`
|
||||
|
||||
|
||||
* **类型**
|
||||
|
||||
`Callable[[Bot, Event, T_State], Awaitable[None]]`
|
||||
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
事件预处理函数 EventPostProcessor 类型
|
||||
|
||||
|
||||
|
||||
|
||||
## `T_RunPreProcessor`
|
||||
|
||||
|
||||
* **类型**
|
||||
|
||||
`Callable[[Matcher, Bot, Event, T_State], Awaitable[None]]`
|
||||
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
事件响应器运行前预处理函数 RunPreProcessor 类型
|
||||
|
||||
|
||||
|
||||
|
||||
## `T_RunPostProcessor`
|
||||
|
||||
|
||||
* **类型**
|
||||
|
||||
`Callable[[Matcher, Optional[Exception], Bot, Event, T_State], Awaitable[None]]`
|
||||
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
事件响应器运行前预处理函数 RunPostProcessor 类型,第二个参数为运行时产生的错误(如果存在)
|
||||
|
||||
|
||||
|
||||
|
||||
## `T_RuleChecker`
|
||||
|
||||
|
||||
* **类型**
|
||||
|
||||
`Callable[[Bot, Event, T_State], Union[bool, Awaitable[bool]]]`
|
||||
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
RuleChecker 即判断是否响应事件的处理函数。
|
||||
|
||||
|
||||
|
||||
|
||||
## `T_PermissionChecker`
|
||||
|
||||
|
||||
* **类型**
|
||||
|
||||
`Callable[[Bot, Event], Union[bool, Awaitable[bool]]]`
|
||||
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
RuleChecker 即判断是否响应消息的处理函数。
|
||||
|
||||
|
||||
|
||||
|
||||
## `T_Handler`
|
||||
|
||||
|
||||
* **类型**
|
||||
|
||||
|
||||
* `Callable[[Bot, Event, T_State], Union[Awaitable[None], Awaitable[NoReturn]]]`
|
||||
|
||||
|
||||
* `Callable[[Bot, Event], Union[Awaitable[None], Awaitable[NoReturn]]]`
|
||||
|
||||
|
||||
* `Callable[[Bot, T_State], Union[Awaitable[None], Awaitable[NoReturn]]]`
|
||||
|
||||
|
||||
* `Callable[[Bot], Union[Awaitable[None], Awaitable[NoReturn]]]`
|
||||
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
Handler 即事件的处理函数。
|
||||
|
||||
|
||||
|
||||
|
||||
## `T_ArgsParser`
|
||||
|
||||
|
||||
* **类型**
|
||||
|
||||
`Callable[[Bot, Event, T_State], Union[Awaitable[None], Awaitable[NoReturn]]]`
|
||||
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
ArgsParser 即消息参数解析函数,在 Matcher.got 获取参数时被运行。
|
@@ -1,84 +0,0 @@
|
||||
---
|
||||
contentSidebar: true
|
||||
sidebarDepth: 0
|
||||
---
|
||||
|
||||
# NoneBot.utils 模块
|
||||
|
||||
|
||||
## `escape_tag(s)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
用于记录带颜色日志时转义 `<tag>` 类型特殊标签
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `s: str`: 需要转义的字符串
|
||||
|
||||
|
||||
|
||||
* **返回**
|
||||
|
||||
|
||||
* `str`
|
||||
|
||||
|
||||
|
||||
## `run_sync(func)`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
一个用于包装 sync function 为 async function 的装饰器
|
||||
|
||||
|
||||
|
||||
* **参数**
|
||||
|
||||
|
||||
* `func: Callable[..., Any]`: 被装饰的同步函数
|
||||
|
||||
|
||||
|
||||
* **返回**
|
||||
|
||||
|
||||
* `Callable[..., Awaitable[Any]]`
|
||||
|
||||
|
||||
|
||||
## `logger_wrapper`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
|
||||
用于打印 adapter 的日志。
|
||||
|
||||
|
||||
* **Log 参数**
|
||||
|
||||
|
||||
|
||||
* `level: Literal['WARNING', 'DEBUG', 'INFO']`: 日志等级
|
||||
|
||||
|
||||
* `message: str`: 日志信息
|
||||
|
||||
|
||||
* `exception: Optional[Exception]`: 异常信息
|
||||
|
||||
|
||||
## _class_ `DataclassEncoder`
|
||||
|
||||
基类:`json.encoder.JSONEncoder`
|
||||
|
||||
|
||||
* **说明**
|
||||
|
||||
在JSON序列化 `Message` (List[Dataclass]) 时使用的 `JSONEncoder`
|
@@ -1,33 +0,0 @@
|
||||
# 概览
|
||||
|
||||
<!-- :::tip 提示
|
||||
如果在阅读本文档时遇到难以理解的词汇,请随时查阅 [术语表](../glossary.md) 或使用 [Google 搜索](https://www.google.com/)。
|
||||
::: -->
|
||||
|
||||
:::tip 提示
|
||||
初次使用时可能会觉得这里的概览过于枯燥,可以先简单略读之后直接前往 [安装](./installation.md) 查看安装方法,并进行后续的基础使用教程。
|
||||
:::
|
||||
|
||||
## 简介
|
||||
|
||||
NoneBot2 是一个可扩展的 Python 异步机器人框架,它会对机器人收到的事件进行解析和处理,并以插件化的形式,按优先级分发给事件所对应的事件响应器,来完成具体的功能。
|
||||
|
||||
除了起到解析事件的作用,NoneBot 还为插件提供了大量实用的预设操作和权限控制机制。对于命令处理,它更是提供了完善且易用的会话机制和内部调用机制,以分别适应命令的连续交互和插件内部功能复用等需求。
|
||||
|
||||
得益于 Python 的 [asyncio](https://docs.python.org/3/library/asyncio.html) 机制,NoneBot 处理事件的吞吐量有了很大的保障,再配合 WebSocket 通信方式(也是最建议的通信方式),NoneBot 的性能可以达到 HTTP 通信方式的两倍以上,相较于传统同步 I/O 的 HTTP 通信,更是有质的飞跃。
|
||||
|
||||
需要注意的是,NoneBot 仅支持 **Python 3.7+**
|
||||
|
||||
## 特色
|
||||
|
||||
NoneBot2 的驱动框架 `Driver` 以及通信协议 `Adapter` 均可**自定义**,并且可以作为插件进行**替换/添加**!
|
||||
|
||||
- 提供使用简易的脚手架
|
||||
- 提供丰富的官方插件
|
||||
- 提供可添加/替换的驱动以及协议选项
|
||||
- 基于异步 I/O
|
||||
- 同时支持 HTTP 和反向 WebSocket 通信方式
|
||||
- 支持多个机器人账号负载均衡
|
||||
- 提供直观的交互式会话接口
|
||||
- 提供可自定义的权限控制机制
|
||||
- 多种方式渲染要发送的消息内容,使对话足够自然
|
@@ -1,83 +0,0 @@
|
||||
# 基本配置
|
||||
|
||||
到目前为止我们还在使用 NoneBot 的默认行为,在开始编写自己的插件之前,我们先尝试在配置文件上动动手脚,让 NoneBot 表现出不同的行为。
|
||||
|
||||
在上一章节中,我们创建了默认的项目结构,其中 `.env`, `.env.*` 均为项目的配置文件,下面将介绍几种 NoneBot 配置方式。
|
||||
|
||||
:::danger 警告
|
||||
请勿将敏感信息写入配置文件并提交至开源仓库!
|
||||
:::
|
||||
|
||||
## .env 文件
|
||||
|
||||
NoneBot 在启动时将会从系统环境变量或者 `.env` 文件中寻找变量 `ENVIRONMENT` (大小写不敏感),默认值为 `prod`。
|
||||
这将引导 NoneBot 从系统环境变量或者 `.env.{ENVIRONMENT}` 文件中进一步加载具体配置。
|
||||
|
||||
现在,我们在 `.env` 文件中写入当前环境信息:
|
||||
|
||||
```bash
|
||||
# .env
|
||||
ENVIRONMENT=dev
|
||||
```
|
||||
|
||||
如你所想,之后 NoneBot 就会从 `.env.dev` 文件中加载环境变量。
|
||||
|
||||
## .env.\* 文件
|
||||
|
||||
NoneBot 使用 [pydantic](https://pydantic-docs.helpmanual.io/) 进行配置管理,会从 `.env.{ENVIRONMENT}` 文件中获悉环境配置。
|
||||
|
||||
可以在 NoneBot 初始化时指定加载某个环境配置文件: `nonebot.init(_env_file=".env.dev")`,这将忽略你在 `.env` 中设置的环境信息。
|
||||
|
||||
:::warning 提示
|
||||
由于 `pydantic` 使用 JSON 解析配置项,请确保配置项值为 JSON 格式的数据。如:
|
||||
|
||||
```bash
|
||||
list=["123456789", "987654321", 1]
|
||||
test={"hello": "world"}
|
||||
```
|
||||
|
||||
如果配置项值解析失败将作为字符串处理。
|
||||
:::
|
||||
|
||||
示例及说明:
|
||||
|
||||
```bash
|
||||
HOST=0.0.0.0 # 配置 NoneBot 监听的 IP/主机名
|
||||
PORT=8080 # 配置 NoneBot 监听的端口
|
||||
DEBUG=true # 开启 debug 模式 **请勿在生产环境开启**
|
||||
SUPERUSERS=["123456789", "987654321"] # 配置 NoneBot 超级用户
|
||||
NICKNAME=["awesome", "bot"] # 配置机器人的昵称
|
||||
COMMAND_START=["/", ""] # 配置命令起始字符
|
||||
COMMAND_SEP=["."] # 配置命令分割字符
|
||||
|
||||
# Custom Configs
|
||||
CUSTOM_CONFIG1="config in env file"
|
||||
CUSTOM_CONFIG2= # 留空则从系统环境变量读取,如不存在则为空字符串
|
||||
```
|
||||
|
||||
详细的配置项参考 [Config Reference](../api/config.md) 。
|
||||
|
||||
## 系统环境变量
|
||||
|
||||
如果在系统环境变量中定义了配置,则一样会被读取。
|
||||
|
||||
## bot.py 文件
|
||||
|
||||
配置项也可以在 NoneBot 初始化时传入。此处可以传入任意合法 Python 变量。当然也可以在初始化完成后修改或新增。
|
||||
|
||||
示例:
|
||||
|
||||
```python
|
||||
# bot.py
|
||||
import nonebot
|
||||
|
||||
nonebot.init(custom_config3="config on init")
|
||||
|
||||
config = nonebot.get_driver().config
|
||||
config.custom_config3 = "changed after init"
|
||||
config.custom_config4 = "new config after init"
|
||||
```
|
||||
|
||||
## 优先级
|
||||
|
||||
`bot.py init` > `system env` > `env file`
|
@@ -1,101 +0,0 @@
|
||||
# CQHTTP 协议使用指南
|
||||
|
||||
## 配置 CQHTTP 协议端(以 QQ 为例)
|
||||
|
||||
单纯运行 NoneBot 实例并不会产生任何效果,因为此刻 QQ 这边还不知道 NoneBot 的存在,也就无法把消息发送给它,因此现在需要使用一个无头 QQ 来把消息等事件上报给 NoneBot。
|
||||
|
||||
QQ 协议端举例:
|
||||
|
||||
- [go-cqhttp](https://github.com/Mrs4s/go-cqhttp) (基于 [MiraiGo](https://github.com/Mrs4s/MiraiGo))
|
||||
- [cqhttp-mirai-embedded](https://github.com/yyuueexxiinngg/cqhttp-mirai/tree/embedded)
|
||||
- [Mirai](https://github.com/mamoe/mirai) + [cqhttp-mirai](https://github.com/yyuueexxiinngg/cqhttp-mirai)
|
||||
- [Mirai](https://github.com/mamoe/mirai) + [Mirai Native](https://github.com/iTXTech/mirai-native) + [CQHTTP](https://github.com/richardchien/coolq-http-api)
|
||||
- [OICQ-http-api](https://github.com/takayama-lily/onebot) (基于 [OICQ](https://github.com/takayama-lily/oicq))
|
||||
|
||||
这里以 [go-cqhttp](https://github.com/Mrs4s/go-cqhttp) 为例
|
||||
|
||||
1. 下载 go-cqhttp 对应平台的 release 文件,[点此前往](https://github.com/Mrs4s/go-cqhttp/releases)
|
||||
2. 运行 exe 文件或者使用 `./go-cqhttp` 启动
|
||||
3. 生成默认配置文件并修改默认配置
|
||||
|
||||
```hjson{2,3,35-36,42}
|
||||
{
|
||||
uin: 机器人QQ号
|
||||
password: 机器人密码
|
||||
encrypt_password: false
|
||||
password_encrypted: ""
|
||||
enable_db: true
|
||||
access_token: ""
|
||||
relogin: {
|
||||
enabled: true
|
||||
relogin_delay: 3
|
||||
max_relogin_times: 0
|
||||
}
|
||||
_rate_limit: {
|
||||
enabled: false
|
||||
frequency: 1
|
||||
bucket_size: 1
|
||||
}
|
||||
ignore_invalid_cqcode: false
|
||||
force_fragmented: false
|
||||
heartbeat_interval: 0
|
||||
http_config: {
|
||||
enabled: false
|
||||
host: "0.0.0.0"
|
||||
port: 5700
|
||||
timeout: 0
|
||||
post_urls: {}
|
||||
}
|
||||
ws_config: {
|
||||
enabled: false
|
||||
host: "0.0.0.0"
|
||||
port: 6700
|
||||
}
|
||||
ws_reverse_servers: [
|
||||
{
|
||||
enabled: true
|
||||
reverse_url: ws://127.0.0.1:8080/cqhttp/ws
|
||||
reverse_api_url: ws://you_websocket_api.server
|
||||
reverse_event_url: ws://you_websocket_event.server
|
||||
reverse_reconnect_interval: 3000
|
||||
}
|
||||
]
|
||||
post_message_format: array
|
||||
use_sso_address: false
|
||||
debug: false
|
||||
log_level: ""
|
||||
web_ui: {
|
||||
enabled: false
|
||||
host: 127.0.0.1
|
||||
web_ui_port: 9999
|
||||
web_input: false
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
其中 `ws://127.0.0.1:8080/cqhttp/ws` 中的 `127.0.0.1` 和 `8080` 应分别对应 nonebot 配置的 HOST 和 PORT。
|
||||
|
||||
`cqhttp` 是前述 `register_adapter` 时传入的第一个参数,代表设置的 `CQHTTPBot` 适配器的路径,你可以对不同的适配器设置不同路径以作区别。
|
||||
|
||||
## 历史性的第一次对话
|
||||
|
||||
一旦新的配置文件正确生效之后,NoneBot 所在的控制台(如果正在运行的话)应该会输出类似下面的内容(两条访问日志):
|
||||
|
||||
```default
|
||||
09-14 21:31:16 [INFO] uvicorn | ('127.0.0.1', 12345) - "WebSocket /cqhttp/ws" [accepted]
|
||||
09-14 21:31:16 [INFO] nonebot | WebSocket Connection from CQHTTP Bot 你的QQ号 Accepted!
|
||||
```
|
||||
|
||||
这表示 CQHTTP 协议端已经成功地使用 CQHTTP 协议连接上了 NoneBot。
|
||||
|
||||
现在,尝试向你的机器人账号发送如下内容:
|
||||
|
||||
```default
|
||||
/echo 你好,世界
|
||||
```
|
||||
|
||||
到这里如果一切 OK,你应该会收到机器人给你回复了 `你好,世界`。这一历史性的对话标志着你已经成功地运行了一个 NoneBot 的最小实例,开始了编写更强大的 QQ 机器人的创意之旅!
|
||||
|
||||
<ClientOnly>
|
||||
<Messenger :messages="[{ position: 'right', msg: '/echo 你好,世界' }, { position: 'left', msg: '你好,世界' }]"/>
|
||||
</ClientOnly>
|
@@ -1,197 +0,0 @@
|
||||
# 事件处理
|
||||
|
||||
在上一章中,我们已经注册了事件响应器,现在我们可以正式编写事件处理逻辑了!
|
||||
|
||||
## [事件处理函数](../api/typing.md#handler)
|
||||
|
||||
```python{1,2,8,9}
|
||||
@weather.handle()
|
||||
async def handle_first_receive(bot: Bot, event: Event, state: T_State):
|
||||
args = str(event.get_message()).strip() # 首次发送命令时跟随的参数,例:/天气 上海,则args为上海
|
||||
if args:
|
||||
state["city"] = args # 如果用户发送了参数则直接赋值
|
||||
|
||||
|
||||
@weather.got("city", prompt="你想查询哪个城市的天气呢?")
|
||||
async def handle_city(bot: Bot, event: Event, state: T_State):
|
||||
city = state["city"]
|
||||
if city not in ["上海", "北京"]:
|
||||
await weather.reject("你想查询的城市暂不支持,请重新输入!")
|
||||
city_weather = await get_weather(city)
|
||||
await weather.finish(city_weather)
|
||||
```
|
||||
|
||||
在之前的样例中,我们定义了两个函数 `handle_first_receive`, `handle_city`,他们被事件响应器的装饰器装饰从而成为事件响应器的事件处理函数。
|
||||
|
||||
:::tip 提示
|
||||
在事件响应器中,事件处理函数是**顺序**执行的!
|
||||
:::
|
||||
|
||||
### 添加一个事件处理函数
|
||||
|
||||
事件响应器提供了三种装饰事件处理函数的装饰器,分别是:
|
||||
|
||||
1. [handle()](../api/matcher.md#classmethod-handle)
|
||||
2. [receive()](../api/matcher.md#classmethod-receive)
|
||||
3. [got(key, prompt, args_parser)](../api/matcher.md#classmethod-got-key-prompt-none-args-parser-none)
|
||||
|
||||
#### handle()
|
||||
|
||||
简单的为事件响应器添加一个事件处理函数,这个函数将会在上一个处理函数正常返回执行完毕后立即执行。
|
||||
|
||||
#### receive()
|
||||
|
||||
指示 NoneBot 接收一条新的用户消息后继续执行该处理函数。此时函数将会接收到新的消息而非前一条消息,之前相关信息可以存储在 state 中。
|
||||
|
||||
特别的,当装饰的函数前没有其他事件处理函数,那么 `receive()` 不会接收一条新的消息而是直接使用第一条接收到的消息。
|
||||
|
||||
#### got(key, prompt, args_parser)
|
||||
|
||||
指示 NoneBot 当 `state` 中不存在 `key` 时向用户发送 `prompt` 等待用户回复并赋值给 `state[key]`。
|
||||
|
||||
`prompt` 可以为 `str`, `Message`, `MessageSegment`,若为空则不会向用户发送,若不为空则会在 format 之后发送,即 `prompt.format(**state)`,注意对 `{}` 进行转义。示例:
|
||||
|
||||
```python
|
||||
@matcher.receive()
|
||||
async def handle(bot: Bot, event: Event, state: T_State):
|
||||
state["key"] = "hello"
|
||||
|
||||
|
||||
@matcher.got("key2", prompt="{key}!")
|
||||
async def handle2(bot: Bot, event: Event, state: T_State):
|
||||
pass
|
||||
```
|
||||
|
||||
`args_parser` 为参数处理函数,在这里传入一个新的函数以覆盖默认的参数处理。详情参照 [args_parser](#参数处理函数-args-parser)
|
||||
|
||||
特别的,这些装饰器都可以套娃使用:
|
||||
|
||||
```python
|
||||
@matcher.got("key1")
|
||||
@matcher.got("key2")
|
||||
async def handle(bot: Bot, event: Event, state: T_State):
|
||||
pass
|
||||
```
|
||||
|
||||
### 事件处理函数参数
|
||||
|
||||
事件处理函数类型为:
|
||||
|
||||
- `Callable[[Bot, Event, T_State, Matcher], Union[Awaitable[None], Awaitable[NoReturn]]]`
|
||||
- `Callable[[Bot, Event, T_State], Union[Awaitable[None], Awaitable[NoReturn]]]`
|
||||
- `Callable[[Bot, Event, Matcher], Union[Awaitable[None], Awaitable[NoReturn]]]`
|
||||
- `Callable[[Bot, T_State, Matcher], Union[Awaitable[None], Awaitable[NoReturn]]]`
|
||||
- `Callable[[Bot, Event], Union[Awaitable[None], Awaitable[NoReturn]]]`
|
||||
- `Callable[[Bot, T_State], Union[Awaitable[None], Awaitable[NoReturn]]]`
|
||||
- `Callable[[Bot, Matcher], Union[Awaitable[None], Awaitable[NoReturn]]]`
|
||||
- `Callable[[Bot], Union[Awaitable[None], Awaitable[NoReturn]]]`
|
||||
|
||||
简单说就是:除了 `bot` 参数,其他都是可选的。
|
||||
|
||||
以下函数都是合法的事件处理函数(仅列举常用的):
|
||||
|
||||
```python
|
||||
async def handle(bot: Bot, event: Event, state: T_State):
|
||||
pass
|
||||
|
||||
async def handle(bot: Bot, event: Event, state: T_State, matcher: Matcher):
|
||||
pass
|
||||
|
||||
async def handle(bot: Bot, event: Event):
|
||||
pass
|
||||
|
||||
async def handle(bot: Bot, state: T_State):
|
||||
pass
|
||||
|
||||
async def handle(bot: Bot):
|
||||
pass
|
||||
```
|
||||
|
||||
:::danger 警告
|
||||
函数的参数名固定不能修改!
|
||||
:::
|
||||
|
||||
参数分别为:
|
||||
|
||||
1. [nonebot.adapters.Bot](../api/adapters/#class-bot): 即事件上报连接对应的 Bot 对象,为 BaseBot 的子类。特别注意,此处的类型注释可以替换为指定的 Bot 类型,例如:`nonebot.adapters.cqhttp.Bot`,只有在上报事件的 Bot 类型与类型注释相符时才会执行该处理函数!可用于多平台进行不同的处理。
|
||||
2. [nonebot.adapters.Event](../api/adapters/#class-event): 即上报事件对象,可以获取到上报的所有信息。
|
||||
3. [state](../api/typing.md#t-state): 状态字典,可以存储任意的信息,其中还包含一些特殊的值以获取 NoneBot 内部处理时的一些信息,如:
|
||||
|
||||
- `state["_current_key"]`: 存储当前 `got` 获取的参数名
|
||||
- `state["_prefix"]`, `state["_suffix"]`: 存储当前 TRIE 匹配的前缀/后缀,可以通过该值获取用户命令的原始命令
|
||||
|
||||
:::tip 提示
|
||||
NoneBot 会对不同类型的参数进行不同的操作,详情查看 [事件处理函数重载](../advanced/overloaded-handlers.md)
|
||||
:::
|
||||
|
||||
### 参数处理函数 args_parser
|
||||
|
||||
在使用 `got` 获取用户输入参数时,需要对用户的消息进行处理以转换为我们所需要的信息。在默认情况下,NoneBot 会把用户的消息字符串原封不动的赋值给 `state[key]` 。可以通过以下两种方式修改默认处理逻辑:
|
||||
|
||||
- `@matcher.args_parser` 装饰器:直接装饰一个函数作为参数处理器
|
||||
- `got(key, prompt, args_parser)`:直接把函数作为参数传入
|
||||
|
||||
参数处理函数类型为:`Callable[[Bot, Event, T_State], Union[Awaitable[None], Awaitable[NoReturn]]]`,即:
|
||||
|
||||
```python
|
||||
async def parser(bot: Bot, event: Event, state: T_State):
|
||||
state[state["_current_key"]] = str(event.get_message())
|
||||
```
|
||||
|
||||
特别的,`state["_current_key"]` 中存储了当前获取的参数名
|
||||
|
||||
### 逻辑控制
|
||||
|
||||
NoneBot 也为事件处理函数提供了一些便捷的逻辑控制函数:
|
||||
|
||||
#### `matcher.send`
|
||||
|
||||
这个函数用于发送一条消息给当前交互的用户。~~其实这并不是一个逻辑控制函数,只是不知道放在哪里……~~
|
||||
|
||||
#### `matcher.pause`
|
||||
|
||||
这个函数用于结束当前事件处理函数,强制接收一条新的消息再运行**下一个消息处理函数**。
|
||||
|
||||
#### `matcher.reject`
|
||||
|
||||
这个函数用于结束当前事件处理函数,强制接收一条新的消息再**再次运行当前消息处理函数**。常用于用户输入信息不符合预期。
|
||||
|
||||
#### `matcher.finish`
|
||||
|
||||
这个函数用于直接结束当前事件处理。
|
||||
|
||||
以上三个函数都拥有一个参数 `message` / `prompt`,用于向用户发送一条消息。以及 `**kwargs` 直接传递给 `bot.send` 的额外参数。
|
||||
|
||||
## 常用事件处理结构
|
||||
|
||||
```python
|
||||
matcher = on_command("test")
|
||||
|
||||
# 修改默认参数处理
|
||||
@matcher.args_parser
|
||||
async def parse(bot: Bot, event: Event, state: T_State):
|
||||
print(state["_current_key"], ":", str(event.get_message()))
|
||||
state[state["_current_key"]] = str(event.get_message())
|
||||
|
||||
@matcher.handle()
|
||||
async def first_receive(bot: Bot, event: Event, state: T_State):
|
||||
# 获取用户原始命令,如:/test
|
||||
print(state["_prefix"]["raw_command"])
|
||||
# 处理用户输入参数,如:/test arg1 arg2
|
||||
raw_args = str(event.get_message()).strip()
|
||||
if raw_args:
|
||||
arg_list = raw_args.split()
|
||||
# 将参数存入state以阻止后续再向用户询问参数
|
||||
state["arg1"] = arg_list[0]
|
||||
|
||||
|
||||
@matcher.got("arg1", prompt="参数?")
|
||||
async def arg_handle(bot: Bot, event: Event, state: T_State):
|
||||
# 在这里对参数进行验证
|
||||
if state["arg1"] not in ["allow", "list"]:
|
||||
await matcher.reject("参数不正确!请重新输入")
|
||||
# 发送一些信息
|
||||
await bot.send(event, "message")
|
||||
await matcher.send("message")
|
||||
await matcher.finish("message")
|
||||
```
|
@@ -1,146 +0,0 @@
|
||||
# 注册事件响应器
|
||||
|
||||
好了,现在插件已经创建完毕,我们可以开始编写实际代码了,下面将以一个简易单文件天气查询插件为例。
|
||||
|
||||
在插件目录下 `weather.py` 中添加如下代码:
|
||||
|
||||
```python
|
||||
from nonebot import on_command
|
||||
from nonebot.rule import to_me
|
||||
from nonebot.typing import T_State
|
||||
from nonebot.adapters import Bot, Event
|
||||
|
||||
weather = on_command("天气", rule=to_me(), priority=5)
|
||||
|
||||
|
||||
@weather.handle()
|
||||
async def handle_first_receive(bot: Bot, event: Event, state: T_State):
|
||||
args = str(event.get_message()).strip() # 首次发送命令时跟随的参数,例:/天气 上海,则args为上海
|
||||
if args:
|
||||
state["city"] = args # 如果用户发送了参数则直接赋值
|
||||
|
||||
|
||||
@weather.got("city", prompt="你想查询哪个城市的天气呢?")
|
||||
async def handle_city(bot: Bot, event: Event, state: T_State):
|
||||
city = state["city"]
|
||||
if city not in ["上海", "北京"]:
|
||||
await weather.reject("你想查询的城市暂不支持,请重新输入!")
|
||||
city_weather = await get_weather(city)
|
||||
await weather.finish(city_weather)
|
||||
|
||||
|
||||
async def get_weather(city: str):
|
||||
return f"{city}的天气是..."
|
||||
```
|
||||
|
||||
为了简单起见,我们在这里的例子中没有接入真实的天气数据,但要接入也非常简单,你可以使用中国天气网、和风天气等网站提供的 API。
|
||||
|
||||
接下来我们来说明这段代码是如何工作的。
|
||||
|
||||
:::tip 提示
|
||||
从这里开始,你需要对 Python 的 asyncio 编程有所了解,因为 NoneBot 是完全基于 asyncio 的,具体可以参考 [廖雪峰的 Python 教程](https://www.liaoxuefeng.com/wiki/1016959663602400/1017959540289152)
|
||||
:::
|
||||
|
||||
## [事件响应器](../api/matcher.md)
|
||||
|
||||
```python{5}
|
||||
from nonebot import on_command
|
||||
from nonebot.rule import to_me
|
||||
from nonebot.permission import Permission
|
||||
|
||||
weather = on_command("天气", rule=to_me(), permission=Permission(), priority=5)
|
||||
```
|
||||
|
||||
在上方代码中,我们注册了一个事件响应器 `Matcher`,它由几个部分组成:
|
||||
|
||||
1. `on_command` 注册一个消息类型的命令处理器
|
||||
2. `"天气"` 指定 command 参数 - 命令名
|
||||
3. `rule` 补充事件响应器的匹配规则
|
||||
4. `priority` 事件响应器优先级
|
||||
5. `block` 是否阻止事件传递
|
||||
|
||||
其他详细配置可以参考 API 文档,下面我们详细说明各个部分:
|
||||
|
||||
### 事件响应器类型 type
|
||||
|
||||
事件响应器类型其实就是对应事件的类型 `Event.get_type()` ,NoneBot 提供了一个基础类型事件响应器 `on()` 以及一些其他内置的事件响应器。
|
||||
|
||||
以下所有类型的事件响应器都是由 `on(type, rule)` 的形式进行了简化封装。
|
||||
|
||||
- `on("事件类型")`: 基础事件响应器,第一个参数为事件类型,空字符串表示不限
|
||||
- `on_metaevent()` ~ `on("meta_event")`: 元事件响应器
|
||||
- `on_message()` ~ `on("message")`: 消息事件响应器
|
||||
- `on_request()` ~ `on("request")`: 请求事件响应器
|
||||
- `on_notice()` ~ `on("notice")`: 通知事件响应器
|
||||
- `on_startswith(str)` ~ `on("message", startswith(str))`: 消息开头匹配响应器,参考 [startswith](../api/rule.md#startswith-msg)
|
||||
- `on_endswith(str)` ~ `on("message", endswith(str))`: 消息结尾匹配响应器,参考 [endswith](../api/rule.md#endswith-msg)
|
||||
- `on_keyword(set)` ~ `on("message", keyword(str))`: 消息关键词匹配响应器,参考 [keyword](../api/rule.md#keyword-keywords)
|
||||
- `on_command(str|tuple)` ~ `on("message", command(str|tuple))`: 命令响应器,参考 [command](../api/rule.md#command-cmds)
|
||||
- `on_regex(pattern_str)` ~ `on("message", regex(pattern_str))`: 正则匹配处理器,参考 [regex](../api/rule.md#regex-regex-flags-0)
|
||||
|
||||
### 匹配规则 rule
|
||||
|
||||
事件响应器的匹配规则即 `Rule`,详细内容在下方介绍。[直达](#自定义-rule)
|
||||
|
||||
### 优先级 priority
|
||||
|
||||
事件响应器的优先级代表事件响应器的执行顺序,同一优先级的事件响应器会 **同时执行!**,优先级数字**越小**越先响应!优先级请从 `1` 开始排序!
|
||||
|
||||
:::tip 提示
|
||||
使用 `nonebot-plugin-test` 可以在网页端查看当前所有事件响应器的执行流程,有助理解事件响应流程!
|
||||
|
||||
```bash
|
||||
nb plugin install nonebot_plugin_test
|
||||
```
|
||||
|
||||
:::
|
||||
|
||||
### 阻断 block
|
||||
|
||||
当有任意事件响应器发出了阻止事件传递信号时,该事件将不再会传递给下一优先级,直接结束处理。
|
||||
|
||||
NoneBot 内置的事件响应器中,所有 `message` 类的事件响应器默认会阻断事件传递,其他则不会。
|
||||
|
||||
## 自定义 rule
|
||||
|
||||
rule 的出现使得 nonebot 对事件的响应可以非常自由,nonebot 内置了一些规则:
|
||||
|
||||
- [startswith(msg)](../api/rule.md#startswith-msg)
|
||||
- [endswith(msg)](../api/rule.md#endswith-msg)
|
||||
- [keyword(\*keywords)](../api/rule.md#keyword-keywords)
|
||||
- [command(\*cmds)](../api/rule.md#command-cmds)
|
||||
- [regex(regex, flag)](../api/rule.md#regex-regex-flags-0)
|
||||
|
||||
以上规则都是返回类型为 `Rule` 的函数,`Rule` 由非负个 `RuleChecker` 组成,当所有 `RuleChecker` 返回 `True` 时匹配成功。这些 `Rule`, `RuleChecker` 的形式如下:
|
||||
|
||||
```python
|
||||
from nonebot.rule import Rule
|
||||
from nonebot.typing import T_State
|
||||
|
||||
async def async_checker(bot: Bot, event: Event, state: T_State) -> bool:
|
||||
return True
|
||||
|
||||
def sync_checker(bot: Bot, event: Event, state: T_State) -> bool:
|
||||
return True
|
||||
|
||||
def check(arg1, args2):
|
||||
|
||||
async def _checker(bot: Bot, event: Event, state: T_State) -> bool:
|
||||
return bool(arg1 + arg2)
|
||||
|
||||
return Rule(_checker)
|
||||
```
|
||||
|
||||
`Rule` 和 `RuleChecker` 之间可以使用 `与 &` 互相组合:
|
||||
|
||||
```python
|
||||
from nonebot.rule import Rule
|
||||
|
||||
Rule(async_checker1) & sync_checker & async_checker2
|
||||
```
|
||||
|
||||
**_请勿将事件处理的逻辑写入 `rule` 中,这会使得事件处理返回奇怪的响应。_**
|
||||
|
||||
:::danger 警告
|
||||
`Rule(*checkers)` 只接受 async function,或使用 `nonebot.utils.run_sync` 自行包裹 sync function。在使用 `与 &` 时,NoneBot 会自动包裹 sync function
|
||||
:::
|
@@ -1,119 +0,0 @@
|
||||
# 创建插件
|
||||
|
||||
如果之前使用 `nb-cli` 生成了项目结构,那我们已经有了一个空的插件目录 `Awesome-Bot/awesome_bot/plugins`,并且它已在 `bot.py` 中被加载,我们现在可以开始创建插件了!
|
||||
|
||||
使用 `nb-cli` 创建包形式插件,或自行创建文件(夹)
|
||||
|
||||
```bash
|
||||
nb plugin new
|
||||
```
|
||||
|
||||
插件通常有两种形式,下面分别介绍
|
||||
|
||||
## 单文件形式
|
||||
|
||||
在插件目录下创建名为 `foo.py` 的 Python 文件,暂时留空,此时目录结构如下:
|
||||
|
||||
<!-- prettier-ignore-start -->
|
||||
:::vue
|
||||
AweSome-Bot
|
||||
├── awesome_bot
|
||||
│ └── plugins
|
||||
│ └── `foo.py`
|
||||
├── .env
|
||||
├── .env.dev
|
||||
├── .env.prod
|
||||
├── .gitignore
|
||||
├── bot.py
|
||||
├── docker-compose.yml
|
||||
├── Dockerfile
|
||||
├── pyproject.toml
|
||||
└── README.md
|
||||
:::
|
||||
<!-- prettier-ignore-end -->
|
||||
|
||||
这个时候它已经可以被称为一个插件了,尽管它还什么都没做。
|
||||
|
||||
## 包形式(推荐)
|
||||
|
||||
在插件目录下创建文件夹 `foo`,并在该文件夹下创建文件 `__init__.py`,此时目录结构如下:
|
||||
|
||||
<!-- prettier-ignore-start -->
|
||||
:::vue
|
||||
AweSome-Bot
|
||||
├── awesome_bot
|
||||
│ └── plugins
|
||||
│ └── `foo`
|
||||
│ └── `__init__.py`
|
||||
├── .env
|
||||
├── .env.dev
|
||||
├── .env.prod
|
||||
├── .gitignore
|
||||
├── bot.py
|
||||
├── docker-compose.yml
|
||||
├── Dockerfile
|
||||
├── pyproject.toml
|
||||
└── README.md
|
||||
:::
|
||||
<!-- prettier-ignore-end -->
|
||||
|
||||
这个时候 `foo` 就是一个合法的 Python 包了,同时也是合法的 NoneBot 插件,插件内容可以在 `__init__.py` 中编写。
|
||||
|
||||
### 推荐结构(仅供参考)
|
||||
|
||||
<!-- prettier-ignore-start -->
|
||||
:::vue
|
||||
foo
|
||||
├── `__init__.py`
|
||||
├── `config.py`
|
||||
├── `data_source.py`
|
||||
└── `model.py`
|
||||
:::
|
||||
<!-- prettier-ignore-end -->
|
||||
|
||||
#### \_\_init\_\_.py
|
||||
|
||||
在该文件中编写各类事件响应及处理逻辑。
|
||||
|
||||
#### config.py
|
||||
|
||||
在该文件中使用 `pydantic` 定义插件所需要的配置项以及类型。
|
||||
|
||||
示例:
|
||||
|
||||
```python
|
||||
from pydantic import BaseSettings
|
||||
|
||||
|
||||
class Config(BaseSettings):
|
||||
|
||||
# plugin custom config
|
||||
plugin_setting: str = "default"
|
||||
|
||||
class Config:
|
||||
extra = "ignore"
|
||||
```
|
||||
|
||||
并在 `__init__.py` 文件中添加以下行
|
||||
|
||||
```python
|
||||
import nonebot
|
||||
from .config import Config
|
||||
|
||||
global_config = nonebot.get_driver().config
|
||||
plugin_config = Config(**global_config.dict())
|
||||
```
|
||||
|
||||
此时就可以通过 `plugin_config.plugin_setting` 获取到插件所需要的配置项了。
|
||||
|
||||
#### data_source.py
|
||||
|
||||
在该文件中编写数据获取函数。
|
||||
|
||||
:::warning 警告
|
||||
数据获取应尽量使用**异步**处理!例如使用 [httpx](https://www.python-httpx.org/) 而非 [requests](https://requests.readthedocs.io/en/master/)
|
||||
:::
|
||||
|
||||
#### model.py
|
||||
|
||||
在该文件中编写数据库模型。
|
@@ -1,51 +0,0 @@
|
||||
# 创建一个完整的项目
|
||||
|
||||
上一章中我们已经运行了一个简单的 NoneBot 实例,在这一章,我们将从零开始一个完整的项目。
|
||||
|
||||
## 目录结构
|
||||
|
||||
可以使用 `nb-cli` 或者自行创建完整的项目目录:
|
||||
|
||||
```bash
|
||||
nb create
|
||||
```
|
||||
|
||||
<!-- prettier-ignore-start -->
|
||||
:::vue
|
||||
AweSome-Bot
|
||||
├── `awesome_bot` _(**或是 src**)_
|
||||
│ └── `plugins`
|
||||
├── `.env` _(**可选的**)_
|
||||
├── `.env.dev` _(**可选的**)_
|
||||
├── `.env.prod` _(**可选的**)_
|
||||
├── .gitignore
|
||||
├── `bot.py`
|
||||
├── docker-compose.yml
|
||||
├── Dockerfile
|
||||
├── `pyproject.toml`
|
||||
└── README.md
|
||||
:::
|
||||
<!-- prettier-ignore-end -->
|
||||
|
||||
- `awesome_bot/plugins` 或 `src/plugins`: 用于存放编写的 bot 插件
|
||||
- `.env`, `.env.dev`, `.env.prod`: 各环境配置文件
|
||||
- `bot.py`: bot 入口文件
|
||||
- `pyproject.toml`: 项目依赖管理文件,默认使用 [poetry](https://python-poetry.org/)
|
||||
|
||||
## 启动 Bot
|
||||
|
||||
如果你使用 `nb-cli`
|
||||
|
||||
```bash
|
||||
nb run [--file=bot.py] [--app=app]
|
||||
```
|
||||
|
||||
或者使用
|
||||
|
||||
```bash
|
||||
python bot.py
|
||||
```
|
||||
|
||||
:::tip 提示
|
||||
如果在 bot 入口文件内定义了 asgi server, `nb-cli` 将会为你启动**冷重载模式**
|
||||
:::
|
@@ -1,3 +0,0 @@
|
||||
# 钉钉机器人使用指南
|
||||
|
||||
~~TODO~~
|
@@ -1,9 +0,0 @@
|
||||
# 结语
|
||||
|
||||
至此,相信你已经能够写出一个基础的插件了。这里给出几个小提示:
|
||||
|
||||
- 请千万注意事件处理器的优先级设定
|
||||
- 在匹配规则中请勿使用耗时极长的函数
|
||||
- 同一个用户可以**跨群**(**私聊**)继续他的事件处理(除非做出权限限制,将在后续介绍)
|
||||
|
||||
如果「指南」还不能满足你,前往 [进阶](../advanced/README.md) 查看更多的功能信息。
|
@@ -1,86 +0,0 @@
|
||||
# 开始使用
|
||||
|
||||
一切都安装成功后,你就已经做好了进行简单配置以运行一个最小的 NoneBot 实例的准备。
|
||||
|
||||
## 最小实例
|
||||
|
||||
如果你已经按照推荐方式安装了 `nb-cli`,使用脚手架创建一个空项目:
|
||||
|
||||
```bash
|
||||
nb create
|
||||
```
|
||||
|
||||
根据脚手架引导,将在当前目录下创建一个项目目录,项目目录内包含 `bot.py`。
|
||||
|
||||
如果未安装 `nb-cli`,使用你最熟悉的编辑器或 IDE,创建一个名为 `bot.py` 的文件,内容如下(这里以 CQHTTP 为例):
|
||||
|
||||
```python{4,6,7,10}
|
||||
import nonebot
|
||||
from nonebot.adapters.cqhttp import Bot as CQHTTPBot
|
||||
|
||||
nonebot.init()
|
||||
driver = nonebot.get_driver()
|
||||
driver.register_adapter("cqhttp", CQHTTPBot)
|
||||
nonebot.load_builtin_plugins()
|
||||
|
||||
if __name__ == "__main__":
|
||||
nonebot.run()
|
||||
```
|
||||
|
||||
## 解读
|
||||
|
||||
在上方 `bot.py` 中,这几行高亮代码将依次:
|
||||
|
||||
1. 使用默认配置初始化 NoneBot
|
||||
2. 加载 NoneBot 内置的 CQHTTP 协议适配组件
|
||||
`register_adapter` 的第一个参数我们传入了一个字符串,该字符串将会在后文 [配置 CQHTTP 协议端](#配置-cqhttp-协议端-以-qq-为例) 时使用。
|
||||
3. 加载 NoneBot 内置的插件
|
||||
4. 在地址 `127.0.0.1:8080` 运行 NoneBot
|
||||
|
||||
在命令行使用如下命令即可运行这个 NoneBot 实例:
|
||||
|
||||
```bash
|
||||
# nb-cli
|
||||
nb run
|
||||
# 其他
|
||||
python bot.py
|
||||
```
|
||||
|
||||
运行后会产生如下日志:
|
||||
|
||||
```plain
|
||||
09-14 21:02:00 [INFO] nonebot | Succeeded to import "nonebot.plugins.base"
|
||||
09-14 21:02:00 [INFO] nonebot | Running NoneBot...
|
||||
09-14 21:02:00 [INFO] uvicorn | Started server process [1234]
|
||||
09-14 21:02:00 [INFO] uvicorn | Waiting for application startup.
|
||||
09-14 21:02:00 [INFO] uvicorn | Application startup complete.
|
||||
09-14 21:02:00 [INFO] uvicorn | Uvicorn running on http://127.0.0.1:8080 (Press CTRL+C to quit)
|
||||
```
|
||||
|
||||
## 配置协议端上报
|
||||
|
||||
在 `bot.py` 文件中使用 `register_adapter` 注册协议适配之后即可配置协议端来完成与 NoneBot 的通信,详细配置方法参考:
|
||||
|
||||
- [配置 CQHTTP](./cqhttp-guide.md)
|
||||
- [配置钉钉](./ding-guide.md)
|
||||
|
||||
NoneBot 接受的上报地址与 `Driver` 有关,默认使用的 `FastAPI Driver` 所接受的上报地址有:
|
||||
|
||||
- `/{adapter name}/`: HTTP POST 上报
|
||||
- `/{adapter name}/http/`: HTTP POST 上报
|
||||
- `/{adapter name}/ws`: WebSocket 上报
|
||||
- `/{adapter name}/ws/`: WebSocket 上报
|
||||
|
||||
:::warning 注意
|
||||
如果到这一步你没有在 NoneBot 看到连接成功日志,比较常见的出错点包括:
|
||||
|
||||
- NoneBot 监听 `0.0.0.0`,然后在协议端上报配置中填了 `ws://0.0.0.0:8080/***/ws`
|
||||
- 在 Docker 容器内运行协议端,并通过 `127.0.0.1` 访问宿主机上的 NoneBot
|
||||
- 想从公网访问,但没有修改云服务商的安全组策略或系统防火墙
|
||||
- NoneBot 所监听的端口存在冲突,已被其它程序占用
|
||||
- 弄混了 NoneBot 的 `host`、`port` 参数与协议端上报配置中的 `host`、`port` 参数
|
||||
- `ws://` 错填为 `http://`
|
||||
- 协议端或 NoneBot 启动时遭到外星武器干扰
|
||||
|
||||
请尝试重启协议端 NoneBot、更换端口、修改防火墙、重启系统、仔细阅读前面的文档及提示、更新协议端 和 NoneBot 到最新版本等方式来解决。
|
||||
:::
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user