mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-10 17:28:27 -04:00
Compare commits
990 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
a52a246982 | ||
|
803fe5db2f | ||
|
39980a1374 | ||
|
d2c4af273b | ||
|
d51dfa88f1 | ||
|
869b9d3b9d | ||
|
f4b26c5b40 | ||
|
15f629ec53 | ||
|
9406a9cc34 | ||
|
52438f45e1 | ||
|
7b2ce072ee | ||
|
89d93dcffb | ||
|
0fb34b1c61 | ||
|
980a6b0af8 | ||
|
5c7a467caa | ||
|
35fd5c415d | ||
|
2762108986 | ||
|
876d63fd8b | ||
|
263ef4b47f | ||
|
1c540476d3 | ||
|
1d0f3d3fd6 | ||
|
c7cec25a29 | ||
|
23c8dc00e8 | ||
|
0da8190637 | ||
|
d766295286 | ||
|
21e3c64e01 | ||
|
9ddcd6d89e | ||
|
a154d5881c | ||
|
fb594e50fd | ||
|
75c5a003bf | ||
|
6f4cbddcad | ||
|
40528150f7 | ||
|
2b80823a1b | ||
|
37ee769119 | ||
|
cfd39ebbd5 | ||
|
0532b30f7f | ||
|
b92a38f49d | ||
|
81711c557a | ||
|
57895ac751 | ||
|
73cceb3aa6 | ||
|
08e7784fbd | ||
|
0174862106 | ||
|
3803ecd35d | ||
|
6ad0f13096 | ||
|
e070ca3b87 | ||
|
6caea8e9e7 | ||
|
d30fa44f3c | ||
|
b1e554d09f | ||
|
4e559d2606 | ||
|
4f0692db59 | ||
|
bbc277f4b9 | ||
|
b3a847e395 | ||
|
8f0b44252d | ||
|
577d62a1c1 | ||
|
3e71d9f1ba | ||
|
03c5124122 | ||
|
8e589660ac | ||
|
64ef775bee | ||
|
6a7ab79446 | ||
|
ea0b51d474 | ||
|
7637de8fed | ||
|
6327e242ca | ||
|
96ad5516d3 | ||
|
7d916a5513 | ||
|
4fc0cded15 | ||
|
48e51784da | ||
|
3ef05f8aa7 | ||
|
fc4858830c | ||
|
a25adefc65 | ||
|
daa2177559 | ||
|
d28c7b500d | ||
|
4bab94b329 | ||
|
e963ffeaab | ||
|
ddeded9a70 | ||
|
4a378b9663 | ||
|
812b865add | ||
|
e0819f760c | ||
|
6c9c8bf63e | ||
|
bca845d76a | ||
|
6c305860bc | ||
|
863929bb0f | ||
|
eee4e64d80 | ||
|
236a8aa9ac | ||
|
eca4a14cb6 | ||
|
6bc8e4b7d2 | ||
|
b34f383649 | ||
|
006fa1a9fe | ||
|
a04a427af2 | ||
|
e1d027eaf5 | ||
|
49563ea6d4 | ||
|
59b9742c19 | ||
|
f491e3d37d | ||
|
1f11e4f227 | ||
|
08d8da25cd | ||
|
74690c73d6 | ||
|
1aebca14e1 | ||
|
5060d606cf | ||
|
23b3ad5837 | ||
|
7297318538 | ||
|
c9fb0a8b03 | ||
|
18619b4d3a | ||
|
ef06388335 | ||
|
cc060da1a7 | ||
|
d1db54498b | ||
|
eef5b3f948 | ||
|
1c41fbfce2 | ||
|
d86b5b2b6c | ||
|
2d3ff83c7c | ||
|
043ad98473 | ||
|
127a46a9b8 | ||
|
a7e1e8a982 | ||
|
b0ac35b82e | ||
|
367135be6a | ||
|
f69f8548b0 | ||
|
45b654eab1 | ||
|
449dbafff7 | ||
|
afba004d85 | ||
|
d71021eb11 | ||
|
ef4d38bc87 | ||
|
96851c7c2d | ||
|
41ae182373 | ||
|
9bf5a5a3cd | ||
|
bab23c25a5 | ||
|
0ba8555f56 | ||
|
340c5b2268 | ||
|
77e8c66b73 | ||
|
9d9f8f7f98 | ||
|
bc77783820 | ||
|
a28be0d343 | ||
|
94c08b0b9e | ||
|
77358a563d | ||
|
82a48b101b | ||
|
6ebe321de9 | ||
|
f67a2e9922 | ||
|
b4fec10ee6 | ||
|
42b9a01550 | ||
|
5f94b20015 | ||
|
9d4d94cbc1 | ||
|
f35b1a9219 | ||
|
9332c8a24c | ||
|
201aa45c6b | ||
|
97ae7b5a5b | ||
|
59544a107c | ||
|
e158ba5b35 | ||
|
f4b9c1c0e6 | ||
|
cdf9adc8a4 | ||
|
9b09f223d9 | ||
|
2caf406254 | ||
|
3c3d082112 | ||
|
2d548b55de | ||
|
dfbe1721f3 | ||
|
17ef3caefd | ||
|
f4b21a9445 | ||
|
2d3399b7e6 | ||
|
22e8b62df2 | ||
|
8f62a46016 | ||
|
842a8a2f71 | ||
|
be1d14d095 | ||
|
ce5e04b398 | ||
|
775487ad47 | ||
|
41e4936f52 | ||
|
d831a116d9 | ||
|
8f43b44677 | ||
|
93df4f3bf3 | ||
|
073b832065 | ||
|
a01e580e03 | ||
|
6124e2fab5 | ||
|
4dd31d6a0b | ||
|
e8706d4006 | ||
|
b34cd534c3 | ||
|
ec2b7b3ad6 | ||
|
4bc3147697 | ||
|
2c63b1cce7 | ||
|
069f8fab9d | ||
|
1f1b01995e | ||
|
140cc43c98 | ||
|
26b7149435 | ||
|
b354ee7269 | ||
|
b829ca0109 | ||
|
37acdb81e8 | ||
|
a9aea65134 | ||
|
308ba36b2e | ||
|
01f70f0a24 | ||
|
5c03c5ba16 | ||
|
42f00c08fa | ||
|
09171fb10a | ||
|
db2328cdaf | ||
|
7a60868632 | ||
|
0af8048938 | ||
|
598d3b8967 | ||
|
8df41c749b | ||
|
1ad0bc33af | ||
|
8c8e9f7770 | ||
|
e91646594f | ||
|
ff066b6473 | ||
|
0eaa8be2d2 | ||
|
bdbe76f9f8 | ||
|
08b609a4b4 | ||
|
42d13b32b2 | ||
|
096ada367f | ||
|
0fed33ebda | ||
|
cb9e918681 | ||
|
bbf167df4d | ||
|
595a2b401c | ||
|
5713e8414e | ||
|
a551caf0da | ||
|
b13f05c4c0 | ||
|
6d6a3a811f | ||
|
fb4aac9f0d | ||
|
2353488c70 | ||
|
3ab4460597 | ||
|
a98981de86 | ||
|
9ef3646711 | ||
|
9c174b8b6f | ||
|
657c1e461c | ||
|
f5a4a698bd | ||
|
8112337aaf | ||
|
73f7394e31 | ||
|
987d88287a | ||
|
9dc783b36f | ||
|
13741b8317 | ||
|
313ca2674e | ||
|
98956481e9 | ||
|
1efda23c3d | ||
|
51e887fe04 | ||
|
8ceab64b96 | ||
|
92b8511cf1 | ||
|
a6a052571e | ||
|
307003e6fe | ||
|
6827c195ad | ||
|
affaaf2fab | ||
|
f0ac087fdb | ||
|
63a9ae2dac | ||
|
0fe4f14d96 | ||
|
699a5e0c8c | ||
|
76fedc5ff1 | ||
|
30d7ff958b | ||
|
992aa781fa | ||
|
e52bf798cf | ||
|
710f4f2ed8 | ||
|
dcc27a4a99 | ||
|
032b6bfd57 | ||
|
737bbb8ec1 | ||
|
e71708f5e8 | ||
|
9841d72622 | ||
|
391a3f0513 | ||
|
aa3409a9cf | ||
|
9a80383327 | ||
|
7e61f7fb46 | ||
|
d526a2fac6 | ||
|
80efb954f1 | ||
|
67c156e40f | ||
|
26f76ef7b9 | ||
|
90cee1bfa9 | ||
|
26171a0ff7 | ||
|
59447d7aa8 | ||
|
a4053d0666 | ||
|
fcd016aed3 | ||
|
719f62a0ac | ||
|
9b9fa2f357 | ||
|
823f4731c3 | ||
|
5feff8f4b2 | ||
|
95d20609a8 | ||
|
b416b9f963 | ||
|
a7c48b13a0 | ||
|
003b71ba00 | ||
|
89593dcc2c | ||
|
fa9352d1f8 | ||
|
4a2f7ffc76 | ||
|
fb1555c075 | ||
|
7a0b409d88 | ||
|
c869f2e335 | ||
|
01da7e813e | ||
|
76b7e09905 | ||
|
8dca948224 | ||
|
ffcbfe6467 | ||
|
d5c70def93 | ||
|
34dccab16b | ||
|
2fab61c4f8 | ||
|
9f96edbb46 | ||
|
3c23b58088 | ||
|
e10530bc0e | ||
|
f24692e79b | ||
|
8a6edc17e4 | ||
|
9ce2837f5a | ||
|
e49e3eec69 | ||
|
3992ae392b | ||
|
8f0c5fab47 | ||
|
780a260b88 | ||
|
25692b9585 | ||
|
ed3ce52865 | ||
|
f5f0f1e250 | ||
|
9d9e61fdfb | ||
|
e68e948a80 | ||
|
cb98f4aa15 | ||
|
bfec0cbcbf | ||
|
3e1268f3bb | ||
|
c28f458972 | ||
|
27ac948463 | ||
|
3f9a3c4c18 | ||
|
9a5545a951 | ||
|
584193db18 | ||
|
1a132fd234 | ||
|
fd6a51ac82 | ||
|
eb1fabb2b7 | ||
|
d079e684bd | ||
|
bf817a1436 | ||
|
78f1624aaf | ||
|
793a49fc64 | ||
|
8b6be656b3 | ||
|
89a88304dc | ||
|
a7fe9ae08f | ||
|
0469705037 | ||
|
dc568fe0e2 | ||
|
eb01bb6c08 | ||
|
71a3539d0e | ||
|
c896a0cdb8 | ||
|
8effe817ad | ||
|
eedf6998b6 | ||
|
e6b7c31a72 | ||
|
2f77fd57b0 | ||
|
fda3d92134 | ||
|
fe6f28143b | ||
|
df3909fc55 | ||
|
9ffa701742 | ||
|
a4f7df8aee | ||
|
15e6cff14a | ||
|
e63ac07a52 | ||
|
a294e3bf8f | ||
|
a5b2fac69c | ||
|
a8e06a5ae4 | ||
|
761bdd8610 | ||
|
b5904889b0 | ||
|
5b4517cf5c | ||
|
72158c0a2c | ||
|
1ca6f6dc5c | ||
|
005fd7b8c6 | ||
|
3fc53b0609 | ||
|
62ec2241e4 | ||
|
75f8254a8e | ||
|
f23ffe0c67 | ||
|
d1a818542c | ||
|
15f67e3a51 | ||
|
412f346ac8 | ||
|
8107a80c4c | ||
|
f1c7d7437a | ||
|
9a013db25f | ||
|
6f75161c80 | ||
|
3f56e5b651 | ||
|
4875abbe86 | ||
|
83863f3a6c | ||
|
f07abad1ec | ||
|
b6909a4120 | ||
|
aaf7f04216 | ||
|
628871b0da | ||
|
a50ad09c8d | ||
|
1358ff50a4 | ||
|
ee9fede3b1 | ||
|
1d7e9e8471 | ||
|
d2fe7f8d11 | ||
|
75958efe17 | ||
|
7746d2aca1 | ||
|
e631df3326 | ||
|
ba44fdb55f | ||
|
59a1e56dad | ||
|
cd6fe46c2b | ||
|
fb4f470b44 | ||
|
b69e25edf4 | ||
|
9eae27bc15 | ||
|
bed36f8784 | ||
|
623f5ccd5e | ||
|
6da8201c2d | ||
|
d1c24d4721 | ||
|
7e5055268a | ||
|
e84e33b94f | ||
|
f21c96bdf4 | ||
|
430daf9b19 | ||
|
7c8756096d | ||
|
7d9e456fe5 | ||
|
948db31384 | ||
|
df1a775fec | ||
|
6c169e057b | ||
|
b164da38e3 | ||
|
dc229ea2b3 | ||
|
b853495d65 | ||
|
0ff02cede9 | ||
|
f7e0e635e6 | ||
|
a065189023 | ||
|
1affeb0683 | ||
|
6b3c9f01ca | ||
|
e9eb6ff2ad | ||
|
0170536d1c | ||
|
c65e769128 | ||
|
998779203a | ||
|
e0e4d697c3 | ||
|
e9c7293014 | ||
|
cf876a4148 | ||
|
6b9a858f28 | ||
|
38e3badb87 | ||
|
13d2fbd560 | ||
|
8d3f2f186a | ||
|
9572b9dc43 | ||
|
ca32086089 | ||
|
57f839dbcd | ||
|
71d6eeb9dd | ||
|
8c51cf8537 | ||
|
b683026cf3 | ||
|
bca2bc5af1 | ||
|
b385a83bdd | ||
|
3bf0286c81 | ||
|
98272f66e7 | ||
|
cf3788c6ea | ||
|
4b3fc53cb6 | ||
|
4e17dca856 | ||
|
82d89148f3 | ||
|
cc4c09b4d7 | ||
|
616f01f8b2 | ||
|
56f89a02bc | ||
|
48ce988d20 | ||
|
119b1cdec2 | ||
|
43fa5a22f5 | ||
|
3c715a29ca | ||
|
31e1cbb19f | ||
|
8e464e9f09 | ||
|
a190a3d933 | ||
|
bedba98130 | ||
|
d69f8435f6 | ||
|
8440b34338 | ||
|
a2715740c1 | ||
|
36b7fd2352 | ||
|
6563cb507a | ||
|
cc6128997e | ||
|
e942da4470 | ||
|
ab2bcdf00d | ||
|
d7c1dad4f0 | ||
|
8bd6b887b8 | ||
|
d326e19196 | ||
|
fa822853df | ||
|
22bff7838a | ||
|
25fce1bd75 | ||
|
a73482e838 | ||
|
bb395f18a2 | ||
|
e20212a6cb | ||
|
0f8291c589 | ||
|
a7b3a238f5 | ||
|
bb800f4e38 | ||
|
b10eded334 | ||
|
3e15e50667 | ||
|
516bc1e484 | ||
|
6a042c3faa | ||
|
967784c860 | ||
|
ccf92ca702 | ||
|
c20b851dc7 | ||
|
39fc21d41c | ||
|
c8c0b27d6a | ||
|
9a21ba3d53 | ||
|
0042c22ceb | ||
|
a0ba9be34e | ||
|
91da78a2ee | ||
|
8eca8e1dfb | ||
|
b12e97a0a7 | ||
|
99c60459f8 | ||
|
3db194c186 | ||
|
0b720a0439 | ||
|
d9011106ac | ||
|
17ca609fe9 | ||
|
0f1ba400db | ||
|
2b8daa2177 | ||
|
f3ed14de5b | ||
|
251d5a4df4 | ||
|
f761714f15 | ||
|
93b0e38264 | ||
|
5f7b030a66 | ||
|
0b122e8d3f | ||
|
34955f88f6 | ||
|
b34fd6da4e | ||
|
9a35716331 | ||
|
156069db0e | ||
|
ea8e444b10 | ||
|
ff779ad494 | ||
|
c9287dc166 | ||
|
7885106266 | ||
|
946b095d4b | ||
|
5bb8f3f7c8 | ||
|
f41b1fb93c | ||
|
8efdd3dffe | ||
|
fb9a7964df | ||
|
1396d9d55a | ||
|
e7ddcebeab | ||
|
9d3a386f32 | ||
|
83c9c372e4 | ||
|
4bb4209c92 | ||
|
744018802f | ||
|
470bb9657f | ||
|
2fb4bb2ea4 | ||
|
43dd37c4f1 | ||
|
5fac500dcf | ||
|
fd25f5bf45 | ||
|
9d3e80eb32 | ||
|
42cbb7f626 | ||
|
4d175477f5 | ||
|
643987c41f | ||
|
03396642a4 | ||
|
3fd5f0c97a | ||
|
5d78f29329 | ||
|
2a98aceae6 | ||
|
5c933b676d | ||
|
2e4de7723e | ||
|
a8e00a19ba | ||
|
8acf6b1194 | ||
|
11d9db99ff | ||
|
c66e0fb6b7 | ||
|
1517a35ef7 | ||
|
c5179979d7 | ||
|
6b14c04e37 | ||
|
4ec3eb7855 | ||
|
4752c4b7cd | ||
|
dfec2f589e | ||
|
f616364d8a | ||
|
4294f8efd5 | ||
|
69eb5f2c56 | ||
|
8d26d16fff | ||
|
bdde065209 | ||
|
e2477638b5 | ||
|
f398cddaf0 | ||
|
dc846965ae | ||
|
dbbdc66dca | ||
|
df85b3b250 | ||
|
f1d9db699f | ||
|
210da263ad | ||
|
1716c69132 | ||
|
14bfcb54dc | ||
|
9f445c0866 | ||
|
3343fd2f6e | ||
|
9103dd9fdb | ||
|
1a8c9a6cba | ||
|
9d2f251923 | ||
|
3744dd287c | ||
|
f65ba100af | ||
|
cc52605c90 | ||
|
3d3dc532dc | ||
|
6c58a6a72d | ||
|
cefd81d810 | ||
|
34c96c697a | ||
|
1cc5e0e1d8 | ||
|
deaedce6c7 | ||
|
91e4d9dffc | ||
|
a826f4245f | ||
|
780eec62b3 | ||
|
dbeb83561a | ||
|
6c11d11645 | ||
|
e9923a7691 | ||
|
5fbe93d898 | ||
|
65995bdca4 | ||
|
f7c333b671 | ||
|
f9d18aa086 | ||
|
571e1c801f | ||
|
f922543d33 | ||
|
6bec67006c | ||
|
050eaa48eb | ||
|
248ce8b3d2 | ||
|
04a488cdf2 | ||
|
6bc2fc88f9 | ||
|
69b6ed6a49 | ||
|
e30b126726 | ||
|
a5e2321c5b | ||
|
322e9a329d | ||
|
7ca6ab8562 | ||
|
8a27dcc481 | ||
|
bed61c521f | ||
|
46ea1698eb | ||
|
c47417024d | ||
|
eedc2d05ff | ||
|
d24dba7ed0 | ||
|
9bdf58ec27 | ||
|
5de9c5d067 | ||
|
64b2a46c95 | ||
|
f42deda3e2 | ||
|
a464e7c643 | ||
|
1f36fa75c4 | ||
|
ad6d732687 | ||
|
1f51c54449 | ||
|
7b5145f116 | ||
|
18b10b8c6f | ||
|
f05435f864 | ||
|
7cbedc82bf | ||
|
3be208f1b3 | ||
|
2606bda8df | ||
|
ab1272b491 | ||
|
43047c0ab0 | ||
|
34471abd64 | ||
|
fa259384f1 | ||
|
cb865d5012 | ||
|
1db97decd1 | ||
|
b02768a08e | ||
|
e55d60f1aa | ||
|
b009438e0e | ||
|
4b5d27d963 | ||
|
91ee0d121c | ||
|
a8767f1136 | ||
|
44478e0f47 | ||
|
c73c2da6a4 | ||
|
5ed005211e | ||
|
d80cbb4647 | ||
|
9a96ef76ba | ||
|
5b5bc278ff | ||
|
5cb95cf94d | ||
|
f132aa2624 | ||
|
3b6b3bcf07 | ||
|
78d97db224 | ||
|
35ddd150ba | ||
|
39ae070c9d | ||
|
24a9a02cc3 | ||
|
0f68abcac9 | ||
|
908c61633d | ||
|
054fc30672 | ||
|
11ffdd84a3 | ||
|
5d2d74b92a | ||
|
18400dc53a | ||
|
29d94640af | ||
|
f6a53b96c7 | ||
|
1aa95a5dd0 | ||
|
fcfeb152c9 | ||
|
0b64df95ef | ||
|
7512f4a1e0 | ||
|
789c453863 | ||
|
615e1dd044 | ||
|
7cb15f5278 | ||
|
3a516ab32a | ||
|
6159d84988 | ||
|
cbe617bc59 | ||
|
e4b98a0c07 | ||
|
e23233ee06 | ||
|
8b1efa9b4f | ||
|
8e1ec2ed9e | ||
|
0e555a4ed7 | ||
|
a6a1d8cb6f | ||
|
6595c3a43d | ||
|
77bb5724d8 | ||
|
48ea595136 | ||
|
1068457584 | ||
|
eca7973266 | ||
|
46ba2df0b8 | ||
|
a8f9a6e439 | ||
|
cca5b5d41b | ||
|
95bde7021a | ||
|
9bf9e06dbf | ||
|
c1bfb19a1d | ||
|
ad0a9ceb9d | ||
|
75f0574cc8 | ||
|
c3fda25a93 | ||
|
7991659f74 | ||
|
77195843d0 | ||
|
bed3347cd9 | ||
|
0c74a9874e | ||
|
b079492d38 | ||
|
28720ebcea | ||
|
3d456e5c14 | ||
|
83017e25ab | ||
|
72b3565e2e | ||
|
59cea6ee38 | ||
|
cbcfa77a34 | ||
|
cfb202cc95 | ||
|
b7d1fd1b47 | ||
|
4cf3bdb53a | ||
|
aab5bc9744 | ||
|
1f14c9066e | ||
|
9ade3c9537 | ||
|
1dc393d2b1 | ||
|
798b66db9b | ||
|
57e65e5515 | ||
|
86e728b753 | ||
|
fd032d3e91 | ||
|
eab16865cd | ||
|
fc4cbf5276 | ||
|
a34a86bbfa | ||
|
a016b3546f | ||
|
e09435da37 | ||
|
416f3d604c | ||
|
d9f371f994 | ||
|
c1c22d0477 | ||
|
339f13d31a | ||
|
4190f07d9c | ||
|
a9bdf36c53 | ||
|
1913cd4309 | ||
|
624439f684 | ||
|
3e14dc22cb | ||
|
f4178aeacd | ||
|
aaf3c9cfe9 | ||
|
f6ee012b15 | ||
|
363ef42923 | ||
|
cc522ef872 | ||
|
0e192ee7f0 | ||
|
ddd0592b30 | ||
|
c4efe2965b | ||
|
a90b5a62f3 | ||
|
50a4497532 | ||
|
c3d6183d73 | ||
|
864a8fd7b6 | ||
|
e7db631151 | ||
|
c7b312196e | ||
|
8cd7a50720 | ||
|
f82c4c7019 | ||
|
03367c5ec4 | ||
|
01cc6e52d5 | ||
|
c903bc9003 | ||
|
323699d103 | ||
|
63ced029ab | ||
|
0aa8c20b75 | ||
|
578b7fefb4 | ||
|
80800673b9 | ||
|
f5a706f57a | ||
|
18efdc004d | ||
|
0fa2b7d171 | ||
|
bb90cdc3c9 | ||
|
c89a5789e6 | ||
|
ad2c0033df | ||
|
0f9037b228 | ||
|
4fc377686b | ||
|
f61ff27ca3 | ||
|
06c90fee0b | ||
|
6fbfe30cc5 | ||
|
45a898b66d | ||
|
27cbb6be78 | ||
|
2105c86111 | ||
|
1929c6b338 | ||
|
e0e044278e | ||
|
60e0729988 | ||
|
8c1c75c246 | ||
|
4b722c815f | ||
|
e6e802b563 | ||
|
7ed1b13e85 | ||
|
6895c8a2a4 | ||
|
f250cac8d5 | ||
|
09800cb8a3 | ||
|
0c1ccfacf8 | ||
|
d853151053 | ||
|
94e594ae8b | ||
|
46453f5f08 | ||
|
e194155689 | ||
|
dd5bc0eeda | ||
|
1622eb05c9 | ||
|
0008eabdd2 | ||
|
22eabff276 | ||
|
d42036845a | ||
|
3d1f9b8b75 | ||
|
73555ff70e | ||
|
a8960e8769 | ||
|
eda38e64d1 | ||
|
f77f2f433f | ||
|
eecccc8100 | ||
|
15ee3dd638 | ||
|
41653a317b | ||
|
b4a493971a | ||
|
ffa2c3f119 | ||
|
b22cd5a81e | ||
|
7ee51332b0 | ||
|
d31cfcc5a8 | ||
|
2d90ecaa51 | ||
|
3e0bbd8ada | ||
|
0f36242597 | ||
|
cd812304f7 | ||
|
3910dc7499 | ||
|
81533b7f69 | ||
|
02e59bd5a5 | ||
|
a402f33a4c | ||
|
c6b0d75fd7 | ||
|
0c88dd84cf | ||
|
0ef2da6f10 | ||
|
80e3507841 | ||
|
df5a7ecc47 | ||
|
7a8fbb418b | ||
|
0620133c5e | ||
|
4ac7d329fd | ||
|
4c2f7dde5f | ||
|
a70b58332f | ||
|
fa41c5a319 | ||
|
b41571a7fd | ||
|
9d2d2fcca5 | ||
|
3c90dc239e | ||
|
1d27b4e7e8 | ||
|
8ace24f0fc | ||
|
f9fff5a27e | ||
|
63d1741534 | ||
|
9b10094ea0 | ||
|
9de75d9109 | ||
|
73901158ab | ||
|
b044eb2d9a | ||
|
c58ae9fc13 | ||
|
17cdd6f893 | ||
|
f07a855912 | ||
|
2ce3262d59 | ||
|
a6330119e8 | ||
|
73de20b615 | ||
|
352ec9a562 | ||
|
f1770cbb8f | ||
|
51a396ec9f | ||
|
ac6e0c2f84 | ||
|
7b84d6363c | ||
|
e1fca41a70 | ||
|
e9f42bf4df | ||
|
6c39044435 | ||
|
f13d7d2c80 | ||
|
3aa6a54b6e | ||
|
ef49030841 | ||
|
ade880a6e6 | ||
|
21bef1a98e | ||
|
df3e60b61f | ||
|
4e60ea4241 | ||
|
ca9fa1b0ac | ||
|
2edda76218 | ||
|
6322e0e077 | ||
|
25f249ab5e | ||
|
3428073208 | ||
|
4b6af0e4ef | ||
|
9c590668df | ||
|
9b4eb21321 | ||
|
f81f9fadd3 | ||
|
8c6fcd2ce6 | ||
|
25eeffa163 | ||
|
6eee161b6b | ||
|
82000c97a4 | ||
|
723447c7d4 | ||
|
d093f7eed7 | ||
|
0acd2931eb | ||
|
7b6539632c | ||
|
44104bb0e4 | ||
|
59f5056035 | ||
|
0634470a8a | ||
|
89c2cda9ec | ||
|
1b0392dfab | ||
|
9ae030a5c5 | ||
|
d5fd6aae8e | ||
|
b85ba177cd | ||
|
d18f9429c6 | ||
|
68741ec484 | ||
|
77bbc5ef7a | ||
|
26ee6ce4d3 | ||
|
594a3b1f97 | ||
|
856dcd048a | ||
|
643dc1824f | ||
|
da849f7c7b | ||
|
93b8bca018 | ||
|
f78e4d457c | ||
|
0b8c3b3f2b | ||
|
c66e491ce9 | ||
|
52b2c0910c | ||
|
9a4bb7bff9 | ||
|
ab5450a125 | ||
|
bcce32423c | ||
|
c42d529016 | ||
|
cbea5077be | ||
|
9223d78849 | ||
|
edd60ae656 | ||
|
da2ee0c158 | ||
|
1b2017024c | ||
|
345a9e9524 | ||
|
cd379fd308 | ||
|
ee33313519 | ||
|
bc31dae965 | ||
|
cdc2cc1439 | ||
|
87819f21bf | ||
|
d1be56fbc1 | ||
|
14016a761d | ||
|
12a64c4c4d | ||
|
d922120f58 | ||
|
8e8e349e65 | ||
|
ccdf0fc077 | ||
|
8c66bcb1e1 | ||
|
77fb47183f | ||
|
d275dc36b2 | ||
|
7bff20cc70 | ||
|
29f5dcc359 | ||
|
14f2851072 | ||
|
a2b25f8246 | ||
|
a38951b5ad | ||
|
4c1b911cb7 | ||
|
6c9f231453 | ||
|
83daf3c30f | ||
|
9be8140d4d | ||
|
96c9b699aa | ||
|
3c0768a372 | ||
|
58b22e3d9e | ||
|
0474551e2f | ||
|
c85bdec396 | ||
|
5fa39eaa9f | ||
|
8eaaa35c7a | ||
|
1c24f95efa | ||
|
fcc49dbbdb | ||
|
3a317590b4 | ||
|
36c013fbb5 | ||
|
a9ec8049f6 | ||
|
ced0d97e3a | ||
|
24d0f57dc3 | ||
|
514ecd6be8 | ||
|
02eb6e172b | ||
|
d22c579875 | ||
|
f70e49fc6a | ||
|
8b410561f9 | ||
|
3c79fd1d6f | ||
|
e9f1a9b1dd | ||
|
3c293ae6db | ||
|
a5d9e7de66 | ||
|
4d9e48cd41 | ||
|
b7ead22e09 | ||
|
9f219cddbb | ||
|
cf9792f24a | ||
|
0187dd57ac | ||
|
2d2e54e31e | ||
|
cb7c5e48fd | ||
|
771c2745dc | ||
|
59c0f2f4b3 | ||
|
219ca39cd1 | ||
|
1e6d0806d7 | ||
|
71f1e43272 | ||
|
8499e1da70 | ||
|
a2ea806bed | ||
|
732b5dfeed | ||
|
d4dcdc761a | ||
|
57996ba290 | ||
|
4b29b3a239 | ||
|
54ac955395 | ||
|
f4fa298866 | ||
|
b2fafc964f | ||
|
22b452e449 | ||
|
fda385a5e4 | ||
|
c28f7cfa07 | ||
|
0a029a7847 | ||
|
c050ce2123 | ||
|
27613410dd | ||
|
1513008b4b | ||
|
bf97cffd84 | ||
|
e37d1c46db | ||
|
06c20c6fa4 | ||
|
aa518d60a5 | ||
|
d55ce7accc | ||
|
502c5cec07 | ||
|
ee5c13607b | ||
|
5a681a5194 | ||
|
68395372f0 | ||
|
c8e01bd158 | ||
|
1d57191700 | ||
|
02c7ded457 | ||
|
12c483d222 | ||
|
c80898a7bf | ||
|
aae2805785 | ||
|
fc3695d090 | ||
|
428429ff44 | ||
|
dc344caec6 | ||
|
2a4d55f81d | ||
|
d090aa23ee | ||
|
65062306c6 | ||
|
9ae3b66fc2 | ||
|
c4ba43ec6d | ||
|
1141791ce5 | ||
|
49f1ef7db0 | ||
|
a70c35e101 | ||
|
717543f6c2 | ||
|
b61b1dbfaa | ||
|
92365fd22d | ||
|
24a4745193 | ||
|
1af75fd813 | ||
|
18160164eb | ||
|
2fd7d97025 | ||
|
6ada15049d | ||
|
0ebc40b95c | ||
|
02de25a931 | ||
|
0b395e9176 | ||
|
4532f992cd | ||
|
34201f0558 | ||
|
d2f4d63183 | ||
|
b41c014869 | ||
|
d348347762 | ||
|
db7cf3d757 | ||
|
83ea046d5f | ||
|
d5c94424e9 | ||
|
ff95b3d00f | ||
|
4b5fa3bb04 | ||
|
52c9ec670d | ||
|
1ac472c676 | ||
|
39f01a3164 | ||
|
486916944b | ||
|
68e96cd1bb | ||
|
5a647d100a | ||
|
a562a571e2 | ||
|
12146ad2da | ||
|
453ac3efd2 | ||
|
c9e89e1911 | ||
|
611817f78a | ||
|
2e66137f3e |
@@ -1,14 +1,12 @@
|
||||
# Ignore all files
|
||||
*
|
||||
|
||||
# Use NadekoBot project
|
||||
!src/NadekoBot/**
|
||||
# Use NadekoBot.Coordinator project
|
||||
!src/NadekoBot.Coordinator/**
|
||||
# Use Generators project
|
||||
!src/NadekoBot.Generators/**
|
||||
# Use Ayu stuff
|
||||
!src/ayu/**
|
||||
# Don't ignore nugetconfig
|
||||
!./NuGet.Config
|
||||
|
||||
# Don't ignore src projects
|
||||
!src/**
|
||||
!docker-entrypoint.sh
|
||||
|
||||
# ignore bin and obj folders in projects
|
||||
src/**/bin/*
|
||||
|
11
.gitignore
vendored
11
.gitignore
vendored
@@ -1,5 +1,12 @@
|
||||
#Manually added files
|
||||
|
||||
src/NadekoBot/data/last_known_version.txt
|
||||
|
||||
# medusa stuff
|
||||
src/NadekoBot/data/medusae/
|
||||
|
||||
# other
|
||||
|
||||
command_errors*.txt
|
||||
output/
|
||||
src/NadekoBot/output
|
||||
@@ -8,7 +15,7 @@ src/NadekoBot/creds.yml
|
||||
src/NadekoBot/Command Errors*.txt
|
||||
|
||||
src/NadekoBot/creds.yml
|
||||
# credentials file before and after migrations
|
||||
# credentials file before and after v3
|
||||
src/NadekoBot/credentials.json
|
||||
src/NadekoBot/old_credentials.json
|
||||
src/NadekoBot/credentials.json.bak
|
||||
@@ -256,7 +263,7 @@ PublishScripts/
|
||||
!**/packages/build/
|
||||
# Uncomment if necessary however generally it will be regenerated when needed
|
||||
#!**/packages/repositories.config
|
||||
# NuGet v3's project.json files produces more ignoreable files
|
||||
# NuGet v4's project.json files produces more ignoreable files
|
||||
*.nuget.props
|
||||
*.nuget.targets
|
||||
|
||||
|
182
.gitlab-ci.yml
182
.gitlab-ci.yml
@@ -1,58 +1,94 @@
|
||||
image: mcr.microsoft.com/dotnet/sdk:5.0
|
||||
image: mcr.microsoft.com/dotnet/sdk:8.0
|
||||
|
||||
stages:
|
||||
- build
|
||||
- test
|
||||
- build-installer
|
||||
- upload-builds
|
||||
- release
|
||||
- publish-windows
|
||||
- upload-windows-updater-release
|
||||
- publish-medusa-package
|
||||
|
||||
variables:
|
||||
project: "NadekoBot"
|
||||
tests: "NadekoBot.Tests"
|
||||
LINUX_X64_OUTPUT_DIR: "nadekobot-linux-x64"
|
||||
LINUX_X64_RELEASE: "$CI_COMMIT_TAG-linux-x64-build.tar"
|
||||
LINUX_ARM64_OUTPUT_DIR: "nadekobot-linux-arm64"
|
||||
LINUX_ARM64_RELEASE: "$CI_COMMIT_TAG-linux-arm64-build.tar"
|
||||
MACOS_X64_OUTPUT_DIR: "nadekobot-osx-x64"
|
||||
MACOS_X64_RELEASE: "$CI_COMMIT_TAG-osx-x64-build.tar"
|
||||
MACOS_ARM64_OUTPUT_DIR: "nadekobot-osx-arm64"
|
||||
MACOS_ARM64_RELEASE: "$CI_COMMIT_TAG-osx-arm64-build.tar"
|
||||
WIN_X64_OUTPUT_DIR: "nadekobot-windows-x64"
|
||||
WIN_X64_RELEASE: "$CI_COMMIT_TAG-windows-x64-build.zip"
|
||||
WIN_ARM64_OUTPUT_DIR: "nadekobot-windows-arm64"
|
||||
WIN_ARM64_RELEASE: "$CI_COMMIT_TAG-windows-arm64-build.zip"
|
||||
PACKAGE_REGISTRY_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/NadekoBot-build/${CI_COMMIT_TAG}"
|
||||
INSTALLER_OUTPUT_DIR: "nadeko-installers/${CI_COMMIT_TAG}"
|
||||
INSTALLER_FILE_NAME: "nadeko-setup-${CI_COMMIT_TAG}.exe"
|
||||
|
||||
|
||||
build:
|
||||
stage: build
|
||||
script:
|
||||
- "dotnet publish -c Release -r linux-x64 -o $LINUX_X64_OUTPUT_DIR src/NadekoBot/NadekoBot.csproj"
|
||||
- "dotnet publish -c Release -r win7-x64 -o $WIN_X64_OUTPUT_DIR src/NadekoBot/NadekoBot.csproj"
|
||||
- "dotnet publish -c Release -r linux-x64 --self-contained -o $LINUX_X64_OUTPUT_DIR src/NadekoBot/NadekoBot.csproj"
|
||||
- "dotnet publish -c Release -r linux-arm64 --self-contained -o $LINUX_ARM64_OUTPUT_DIR src/NadekoBot/NadekoBot.csproj"
|
||||
- "dotnet publish -c Release -r win-x64 --self-contained -o $WIN_X64_OUTPUT_DIR src/NadekoBot/NadekoBot.csproj"
|
||||
- "dotnet publish -c Release -r win-arm64 --self-contained -o $WIN_ARM64_OUTPUT_DIR src/NadekoBot/NadekoBot.csproj"
|
||||
- "dotnet publish -c Release -r osx-x64 --self-contained -o $MACOS_X64_OUTPUT_DIR src/NadekoBot/NadekoBot.csproj"
|
||||
- "dotnet publish -c Release -r osx-arm64 --self-contained -o $MACOS_ARM64_OUTPUT_DIR src/NadekoBot/NadekoBot.csproj"
|
||||
artifacts:
|
||||
paths:
|
||||
- "$LINUX_X64_OUTPUT_DIR/"
|
||||
- "$LINUX_ARM64_OUTPUT_DIR/"
|
||||
- "$WIN_X64_OUTPUT_DIR/"
|
||||
- "$WIN_ARM64_OUTPUT_DIR/"
|
||||
- "$MACOS_X64_OUTPUT_DIR/"
|
||||
- "$MACOS_ARM64_OUTPUT_DIR/"
|
||||
|
||||
upload-builds:
|
||||
stage: upload-builds
|
||||
image: alpine:latest
|
||||
rules:
|
||||
- if: $CI_COMMIT_TAG
|
||||
script:
|
||||
- apk add --no-cache curl tar zip
|
||||
- "tar cvf $LINUX_X64_RELEASE $LINUX_X64_OUTPUT_DIR/*"
|
||||
- "zip -r $WIN_X64_RELEASE $WIN_X64_OUTPUT_DIR/*"
|
||||
- |
|
||||
curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file $LINUX_X64_RELEASE $PACKAGE_REGISTRY_URL/$LINUX_X64_RELEASE
|
||||
- |
|
||||
curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file $WIN_X64_RELEASE $PACKAGE_REGISTRY_URL/$WIN_X64_RELEASE
|
||||
stage: upload-builds
|
||||
image: alpine:latest
|
||||
rules:
|
||||
- if: $CI_COMMIT_TAG
|
||||
script:
|
||||
- apk add --no-cache curl tar zip
|
||||
- "tar cvf $LINUX_X64_RELEASE $LINUX_X64_OUTPUT_DIR/*"
|
||||
- "tar cvf $LINUX_ARM64_RELEASE $LINUX_ARM64_OUTPUT_DIR/*"
|
||||
- "tar cvf $MACOS_X64_RELEASE $MACOS_X64_OUTPUT_DIR/*"
|
||||
- "tar cvf $MACOS_ARM64_RELEASE $MACOS_ARM64_OUTPUT_DIR/*"
|
||||
- "zip -r $WIN_X64_RELEASE $WIN_X64_OUTPUT_DIR/*"
|
||||
- "zip -r $WIN_ARM64_RELEASE $WIN_ARM64_OUTPUT_DIR/*"
|
||||
- "mv $INSTALLER_OUTPUT_DIR/$INSTALLER_FILE_NAME $INSTALLER_FILE_NAME"
|
||||
- |
|
||||
curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file $LINUX_X64_RELEASE $PACKAGE_REGISTRY_URL/$LINUX_X64_RELEASE
|
||||
- |
|
||||
curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file $LINUX_ARM64_RELEASE $PACKAGE_REGISTRY_URL/$LINUX_ARM64_RELEASE
|
||||
- |
|
||||
curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file $WIN_X64_RELEASE $PACKAGE_REGISTRY_URL/$WIN_X64_RELEASE
|
||||
- |
|
||||
curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file $WIN_ARM64_RELEASE $PACKAGE_REGISTRY_URL/$WIN_ARM64_RELEASE
|
||||
- |
|
||||
curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file $MACOS_X64_RELEASE $PACKAGE_REGISTRY_URL/$MACOS_X64_RELEASE
|
||||
- |
|
||||
curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file $MACOS_ARM64_RELEASE $PACKAGE_REGISTRY_URL/$MACOS_ARM64_RELEASE
|
||||
- |
|
||||
curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file $INSTALLER_FILE_NAME $PACKAGE_REGISTRY_URL/$INSTALLER_FILE_NAME
|
||||
|
||||
release:
|
||||
stage: release
|
||||
image: registry.gitlab.com/gitlab-org/release-cli:latest
|
||||
rules:
|
||||
- if: $CI_COMMIT_TAG
|
||||
script:
|
||||
- |
|
||||
release-cli create --name "NadekoBot v$CI_COMMIT_TAG" --description "## [Changelog](https://gitlab.com/Kwoth/nadekobot/-/blob/v3/CHANGELOG.md#$(echo "$CI_COMMIT_TAG" | sed "s/\.//g")-$(date +%d%m%Y))" --tag-name $CI_COMMIT_TAG \
|
||||
--assets-link "{\"name\":\"${LINUX_X64_RELEASE}\",\"url\":\"${PACKAGE_REGISTRY_URL}/${LINUX_X64_RELEASE}\"}" \
|
||||
--assets-link "{\"name\":\"${WIN_X64_RELEASE}\",\"url\":\"${PACKAGE_REGISTRY_URL}/${WIN_X64_RELEASE}\"}"
|
||||
stage: release
|
||||
image: registry.gitlab.com/gitlab-org/release-cli:latest
|
||||
rules:
|
||||
- if: $CI_COMMIT_TAG
|
||||
script:
|
||||
- |
|
||||
release-cli create --name "NadekoBot v$CI_COMMIT_TAG" --description "## [Changelog](https://gitlab.com/kwoth/nadekobot/-/blob/v5/CHANGELOG.md#$(echo "$CI_COMMIT_TAG" | sed "s/\.//g")-$(date +%d%m%Y))" --tag-name $CI_COMMIT_TAG \
|
||||
--assets-link "{\"name\":\"${LINUX_X64_RELEASE}\",\"url\":\"${PACKAGE_REGISTRY_URL}/${LINUX_X64_RELEASE}\"}" \
|
||||
--assets-link "{\"name\":\"${LINUX_ARM64_RELEASE}\",\"url\":\"${PACKAGE_REGISTRY_URL}/${LINUX_ARM64_RELEASE}\"}" \
|
||||
--assets-link "{\"name\":\"${WIN_X64_RELEASE}\",\"url\":\"${PACKAGE_REGISTRY_URL}/${WIN_X64_RELEASE}\"}" \
|
||||
--assets-link "{\"name\":\"${WIN_ARM64_RELEASE}\",\"url\":\"${PACKAGE_REGISTRY_URL}/${WIN_ARM64_RELEASE}\"}" \
|
||||
--assets-link "{\"name\":\"${MACOS_X64_RELEASE}\",\"url\":\"${PACKAGE_REGISTRY_URL}/${MACOS_X64_RELEASE}\"}" \
|
||||
--assets-link "{\"name\":\"${MACOS_ARM64_RELEASE}\",\"url\":\"${PACKAGE_REGISTRY_URL}/${MACOS_ARM64_RELEASE}\"}" \
|
||||
--assets-link "{\"name\":\"${INSTALLER_FILE_NAME}\",\"url\":\"${PACKAGE_REGISTRY_URL}/${INSTALLER_FILE_NAME}\"}"
|
||||
|
||||
test:
|
||||
stage: test
|
||||
@@ -62,37 +98,63 @@ test:
|
||||
- "cd $tests_path"
|
||||
- "dotnet test"
|
||||
|
||||
publish-windows:
|
||||
stage: publish-windows
|
||||
rules:
|
||||
- if: '$CI_COMMIT_TAG'
|
||||
image: scottyhardy/docker-wine
|
||||
before_script:
|
||||
- choco install dotnet-5.0-runtime -y
|
||||
- choco install dotnet-5.0-sdk -y
|
||||
- choco install innosetup -y
|
||||
artifacts:
|
||||
paths:
|
||||
- "$INSTALLER_OUTPUT_DIR/$INSTALLER_FILE_NAME"
|
||||
script:
|
||||
- dotnet clean
|
||||
- dotnet restore
|
||||
- dotnet publish -c Release --runtime win7-x64 /p:Version=$CI_COMMIT_TAG src/NadekoBot
|
||||
- $env:NADEKOBOT_INSTALL_VERSION = $CI_COMMIT_TAG
|
||||
- iscc.exe "/O+" ".\exe_builder.iss"
|
||||
tags:
|
||||
- windows
|
||||
build-installer:
|
||||
stage: build-installer
|
||||
rules:
|
||||
- if: "$CI_COMMIT_TAG"
|
||||
image: scottyhardy/docker-wine
|
||||
before_script:
|
||||
- choco install dotnet-runtime --version=8.0.4 -y
|
||||
- choco install dotnet-sdk --version=8.0.204 -y
|
||||
- choco install innosetup -y
|
||||
artifacts:
|
||||
paths:
|
||||
- "$INSTALLER_OUTPUT_DIR/$INSTALLER_FILE_NAME"
|
||||
script:
|
||||
- dotnet clean
|
||||
- dotnet restore -f --no-cache -v n
|
||||
- dotnet publish -c Release --self-contained --runtime win-x64 /p:Version=$CI_COMMIT_TAG src/NadekoBot
|
||||
- $env:NADEKOBOT_INSTALL_VERSION = $CI_COMMIT_TAG
|
||||
- iscc.exe "/O+" ".\exe_builder.iss"
|
||||
tags:
|
||||
- saas-windows-medium-amd64
|
||||
|
||||
upload-windows-updater-release:
|
||||
stage: upload-windows-updater-release
|
||||
rules:
|
||||
- if: '$CI_COMMIT_TAG'
|
||||
image:
|
||||
name: amazon/aws-cli
|
||||
entrypoint: [""]
|
||||
script:
|
||||
- sed -i "s/_INSTALLER_FILE_NAME_/$INSTALLER_FILE_NAME/g" releases-v3.json
|
||||
- sed -i "s/_VERSION_/$CI_COMMIT_TAG/g" releases-v3.json
|
||||
- aws --version
|
||||
- aws --endpoint-url $AWS_SERVICE_URL s3api put-object --bucket "$AWS_BUCKET_NAME" --key "dl/bot/$INSTALLER_FILE_NAME" --acl public-read --body "$INSTALLER_OUTPUT_DIR/$INSTALLER_FILE_NAME"
|
||||
- aws --endpoint-url $AWS_SERVICE_URL s3api put-object --bucket "$AWS_BUCKET_NAME" --key "dl/bot/releases-v3.json" --acl public-read --body "releases-v3.json"
|
||||
publish-medusa-package:
|
||||
stage: publish-medusa-package
|
||||
allow_failure: true
|
||||
rules:
|
||||
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_TAG
|
||||
script:
|
||||
- LAST_TAG=$(git describe --tags --abbrev=0)
|
||||
- if [ $CI_COMMIT_TAG ];then MEDUSA_VERSION="$CI_COMMIT_TAG"; else MEDUSA_VERSION="$LAST_TAG-alpha$CI_COMMIT_SHORT_SHA"; fi
|
||||
- cd src/Nadeko.Medusa/
|
||||
- dotnet pack -c Release /p:Version=$MEDUSA_VERSION -o bin/Release/packed
|
||||
- dotnet nuget push bin/Release/packed/ --source https://www.myget.org/F/nadeko/api/v2/package --api-key "$MYGET_API_KEY"
|
||||
|
||||
docker-build:
|
||||
# Use the official docker image.
|
||||
image: docker:latest
|
||||
stage: build
|
||||
allow_failure: true
|
||||
services:
|
||||
- docker:dind
|
||||
before_script:
|
||||
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
|
||||
# Default branch leaves tag empty (= latest tag)
|
||||
# All other branches are tagged with the escaped branch name (commit ref slug)
|
||||
script:
|
||||
- |
|
||||
if [[ "$CI_COMMIT_BRANCH" == "$CI_DEFAULT_BRANCH" ]]; then
|
||||
tag=""
|
||||
echo "Running on default branch '$CI_DEFAULT_BRANCH': tag = 'latest'"
|
||||
else
|
||||
tag=":$CI_COMMIT_SHA"
|
||||
echo "Running on branch '$CI_COMMIT_BRANCH': tag = $tag"
|
||||
fi
|
||||
- docker build --pull -t "$CI_REGISTRY_IMAGE${tag}" .
|
||||
- docker push "$CI_REGISTRY_IMAGE${tag}"
|
||||
# Run this job in a branch where a Dockerfile exists
|
||||
rules:
|
||||
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_TAG
|
||||
exists:
|
||||
- Dockerfile
|
||||
|
19
.readthedocs.yaml
Normal file
19
.readthedocs.yaml
Normal file
@@ -0,0 +1,19 @@
|
||||
# Read the Docs configuration file for MkDocs projects
|
||||
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
|
||||
|
||||
# Required
|
||||
version: 2
|
||||
|
||||
# Set the version of Python and other tools you might need
|
||||
build:
|
||||
os: ubuntu-22.04
|
||||
tools:
|
||||
python: "3.12"
|
||||
|
||||
mkdocs:
|
||||
configuration: mkdocs.yml
|
||||
|
||||
# Optionally declare the Python requirements required to build your docs
|
||||
python:
|
||||
install:
|
||||
- requirements: mkdocs-requirements.txt
|
1053
CHANGELOG.md
1053
CHANGELOG.md
File diff suppressed because it is too large
Load Diff
60
Dockerfile
60
Dockerfile
@@ -1,22 +1,60 @@
|
||||
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
|
||||
# Use the .NET 8.0 SDK as the base image for the build stage
|
||||
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
|
||||
WORKDIR /source
|
||||
|
||||
# Copy the .csproj files for each project
|
||||
COPY src/Nadeko.Medusa/*.csproj src/Nadeko.Medusa/
|
||||
COPY src/NadekoBot/*.csproj src/NadekoBot/
|
||||
COPY src/NadekoBot.Coordinator/*.csproj src/NadekoBot.Coordinator/
|
||||
COPY src/NadekoBot.Generators/*.csproj src/NadekoBot.Generators/
|
||||
COPY src/ayu/Ayu.Discord.Voice/*.csproj src/ayu/Ayu.Discord.Voice/
|
||||
COPY src/NadekoBot.Voice/*.csproj src/NadekoBot.Voice/
|
||||
COPY NuGet.Config ./
|
||||
|
||||
# Restore the dependencies for the NadekoBot project
|
||||
RUN dotnet restore src/NadekoBot/
|
||||
|
||||
# Copy the rest of the source code
|
||||
COPY . .
|
||||
WORKDIR /source/src/NadekoBot
|
||||
RUN dotnet --version
|
||||
RUN dotnet publish -c Release -o /app --no-restore
|
||||
|
||||
# final stage/image
|
||||
FROM mcr.microsoft.com/dotnet/runtime:5.0
|
||||
# Set the working directory to the NadekoBot project
|
||||
WORKDIR /source/src/NadekoBot
|
||||
|
||||
# Build and publish the NadekoBot project, then clean up unnecessary files
|
||||
RUN set -xe; \
|
||||
dotnet --version; \
|
||||
dotnet publish -c Release -o /app --no-restore; \
|
||||
mv /app/data /app/data_init; \
|
||||
rm -Rf libopus* libsodium* opus.* runtimes/win* runtimes/osx* runtimes/linux-arm* runtimes/linux-mips*; \
|
||||
find /app -type f -exec chmod -x {} \; ;\
|
||||
chmod +x /app/NadekoBot
|
||||
|
||||
# Use the .NET 8.0 runtime as the base image for the final stage
|
||||
FROM mcr.microsoft.com/dotnet/runtime:8.0
|
||||
WORKDIR /app
|
||||
|
||||
# Create a new user, install dependencies, and set up sudoers file
|
||||
RUN set -xe; \
|
||||
useradd -m nadeko; \
|
||||
apt-get update; \
|
||||
apt-get install -y --no-install-recommends libsqlite3-0 curl ffmpeg sudo python3; \
|
||||
echo 'Defaults>nadeko env_keep+="ASPNETCORE_* DOTNET_* NadekoBot_* shard_id total_shards TZ"' > /etc/sudoers.d/nadeko; \
|
||||
curl -Lo /usr/local/bin/yt-dlp https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp; \
|
||||
chmod a+rx /usr/local/bin/yt-dlp; \
|
||||
apt-get autoremove -y; \
|
||||
apt-get autoclean -y
|
||||
|
||||
# Copy the built application and the entrypoint script from the build stage
|
||||
COPY --from=build /app ./
|
||||
COPY docker-entrypoint.sh /usr/local/sbin
|
||||
|
||||
# Set environment variables
|
||||
ENV shard_id=0
|
||||
ENV total_shards=1
|
||||
WORKDIR /app
|
||||
COPY --from=build /app ./
|
||||
VOLUME [ "app/data", "app/creds.yml", "app/creds_example.yml" ]
|
||||
ENTRYPOINT dotnet NadekoBot.dll "$shard_id" "$total_shards"
|
||||
ENV NadekoBot__creds=/app/data/creds.yml
|
||||
|
||||
# Define the data directory as a volume
|
||||
VOLUME [ "/app/data" ]
|
||||
|
||||
# Set the entrypoint and default command
|
||||
ENTRYPOINT [ "/usr/local/sbin/docker-entrypoint.sh" ]
|
||||
CMD dotnet NadekoBot.dll "$shard_id" "$total_shards"
|
@@ -1,4 +1,4 @@
|
||||
Copyright 2021 Kwoth
|
||||
Copyright 2023 Kwoth
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
|
@@ -11,19 +11,25 @@ ProjectSection(SolutionItems) = preProject
|
||||
LICENSE.md = LICENSE.md
|
||||
README.md = README.md
|
||||
.gitlab-ci.yml = .gitlab-ci.yml
|
||||
Dockerfile = Dockerfile
|
||||
NuGet.Config = NuGet.Config
|
||||
migrate.ps1 = migrate.ps1
|
||||
remove-migration.ps1 = remove-migration.ps1
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NadekoBot", "src\NadekoBot\NadekoBot.csproj", "{45EC1473-C678-4857-A544-07DFE0D0B478}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ayu", "ayu", "{6058FEDF-A318-4CD4-8F04-A7E8E7EC8874}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ayu.Discord.Voice", "src\ayu\Ayu.Discord.Voice\Ayu.Discord.Voice.csproj", "{2F4CF6D6-0C2F-4944-B204-9508CDA53195}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NadekoBot.Voice", "src\NadekoBot.Voice\NadekoBot.Voice.csproj", "{2F4CF6D6-0C2F-4944-B204-9508CDA53195}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NadekoBot.Tests", "src\NadekoBot.Tests\NadekoBot.Tests.csproj", "{DB448DD4-C97F-40E9-8BD3-F605FF1FF833}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NadekoBot.Coordinator", "src\NadekoBot.Coordinator\NadekoBot.Coordinator.csproj", "{AE9B7F8C-81D7-4401-83A3-643B38258374}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NadekoBot.Generators", "src\NadekoBot.Generators\NadekoBot.Generators.csproj", "{3BC3BDF8-1A0B-45EB-AB2B-C0891D4D37B8}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NadekoBot.VotesApi", "src\NadekoBot.VotesApi\NadekoBot.VotesApi.csproj", "{3BC82CFE-BEE7-451F-986B-17EDD1570C4F}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nadeko.Medusa", "src\Nadeko.Medusa\Nadeko.Medusa.csproj", "{E685977E-31A4-46F4-A5D7-4E3E39E82E43}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NadekoBot.Generators", "src\NadekoBot.Generators\NadekoBot.Generators.csproj", "{92770AF3-83EE-49F1-A0BB-79124D19A13D}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@@ -56,23 +62,36 @@ Global
|
||||
{AE9B7F8C-81D7-4401-83A3-643B38258374}.GlobalNadeko|Any CPU.Build.0 = Debug|Any CPU
|
||||
{AE9B7F8C-81D7-4401-83A3-643B38258374}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{AE9B7F8C-81D7-4401-83A3-643B38258374}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{3BC3BDF8-1A0B-45EB-AB2B-C0891D4D37B8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{3BC3BDF8-1A0B-45EB-AB2B-C0891D4D37B8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{3BC3BDF8-1A0B-45EB-AB2B-C0891D4D37B8}.GlobalNadeko|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{3BC3BDF8-1A0B-45EB-AB2B-C0891D4D37B8}.GlobalNadeko|Any CPU.Build.0 = Debug|Any CPU
|
||||
{3BC3BDF8-1A0B-45EB-AB2B-C0891D4D37B8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{3BC3BDF8-1A0B-45EB-AB2B-C0891D4D37B8}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{3BC82CFE-BEE7-451F-986B-17EDD1570C4F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{3BC82CFE-BEE7-451F-986B-17EDD1570C4F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{3BC82CFE-BEE7-451F-986B-17EDD1570C4F}.GlobalNadeko|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{3BC82CFE-BEE7-451F-986B-17EDD1570C4F}.GlobalNadeko|Any CPU.Build.0 = Debug|Any CPU
|
||||
{3BC82CFE-BEE7-451F-986B-17EDD1570C4F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{3BC82CFE-BEE7-451F-986B-17EDD1570C4F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{E685977E-31A4-46F4-A5D7-4E3E39E82E43}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{E685977E-31A4-46F4-A5D7-4E3E39E82E43}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{E685977E-31A4-46F4-A5D7-4E3E39E82E43}.GlobalNadeko|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{E685977E-31A4-46F4-A5D7-4E3E39E82E43}.GlobalNadeko|Any CPU.Build.0 = Debug|Any CPU
|
||||
{E685977E-31A4-46F4-A5D7-4E3E39E82E43}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E685977E-31A4-46F4-A5D7-4E3E39E82E43}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{92770AF3-83EE-49F1-A0BB-79124D19A13D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{92770AF3-83EE-49F1-A0BB-79124D19A13D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{92770AF3-83EE-49F1-A0BB-79124D19A13D}.GlobalNadeko|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{92770AF3-83EE-49F1-A0BB-79124D19A13D}.GlobalNadeko|Any CPU.Build.0 = Debug|Any CPU
|
||||
{92770AF3-83EE-49F1-A0BB-79124D19A13D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{92770AF3-83EE-49F1-A0BB-79124D19A13D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(NestedProjects) = preSolution
|
||||
{45EC1473-C678-4857-A544-07DFE0D0B478} = {04929013-5BAB-42B0-B9B2-8F2BB8F16AF2}
|
||||
{6058FEDF-A318-4CD4-8F04-A7E8E7EC8874} = {04929013-5BAB-42B0-B9B2-8F2BB8F16AF2}
|
||||
{2F4CF6D6-0C2F-4944-B204-9508CDA53195} = {6058FEDF-A318-4CD4-8F04-A7E8E7EC8874}
|
||||
{DB448DD4-C97F-40E9-8BD3-F605FF1FF833} = {04929013-5BAB-42B0-B9B2-8F2BB8F16AF2}
|
||||
{AE9B7F8C-81D7-4401-83A3-643B38258374} = {04929013-5BAB-42B0-B9B2-8F2BB8F16AF2}
|
||||
{3BC3BDF8-1A0B-45EB-AB2B-C0891D4D37B8} = {04929013-5BAB-42B0-B9B2-8F2BB8F16AF2}
|
||||
{3BC82CFE-BEE7-451F-986B-17EDD1570C4F} = {04929013-5BAB-42B0-B9B2-8F2BB8F16AF2}
|
||||
{E685977E-31A4-46F4-A5D7-4E3E39E82E43} = {04929013-5BAB-42B0-B9B2-8F2BB8F16AF2}
|
||||
{92770AF3-83EE-49F1-A0BB-79124D19A13D} = {04929013-5BAB-42B0-B9B2-8F2BB8F16AF2}
|
||||
{2F4CF6D6-0C2F-4944-B204-9508CDA53195} = {04929013-5BAB-42B0-B9B2-8F2BB8F16AF2}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {5F3F555C-855F-4BE8-B526-D062D3E8ACA4}
|
||||
|
12
NuGet.Config
12
NuGet.Config
@@ -1,8 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<packageSources>
|
||||
<add key="Discord.Net" value="https://www.myget.org/F/discord-net/api/v3/index.json" />
|
||||
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
|
||||
<add key="Kwoth-myget" value="https://www.myget.org/F/kwoth/api/v3/index.json" />
|
||||
</packageSources>
|
||||
</configuration>
|
||||
<packageSources>
|
||||
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
|
||||
<add key="nadeko.bot" value="https://www.myget.org/F/nadeko/api/v3/index.json" protocolVersion="3" />
|
||||
</packageSources>
|
||||
</configuration>
|
||||
|
@@ -1,8 +1,3 @@
|
||||
[](https://discord.gg/nadekobot)
|
||||
[](http://nadekobot.readthedocs.io/en/v3/?badge=v3)
|
||||
[](https://top.gg/bot/116275390695079945)
|
||||
|
||||
|
||||
[](https://nadeko.bot/)
|
||||
|
||||
[](https://invite.nadeko.bot/)
|
||||
@@ -10,6 +5,5 @@
|
||||
[](https://nadeko.bot/commands)
|
||||
|
||||
### Useful links
|
||||
- ❗ [2.x to v3 migration guide](https://nadekobot.readthedocs.io/en/v3/guides/migration-guide/)
|
||||
- [Self hosting Guides and Docs](https://nadekobot.readthedocs.io/en/v3)
|
||||
- [Self hosting Guides and Docs](https://nadekobot.readthedocs.io/en/latest)
|
||||
- [Discord support server](https://discord.nadeko.bot)
|
||||
|
28
docker-entrypoint.sh
Executable file
28
docker-entrypoint.sh
Executable file
@@ -0,0 +1,28 @@
|
||||
#!/bin/sh
|
||||
set -e;
|
||||
|
||||
data_init=/app/data_init
|
||||
data=/app/data
|
||||
|
||||
# populate /app/data if empty
|
||||
for i in $(ls $data_init)
|
||||
do
|
||||
if [ ! -e "$data/$i" ]; then
|
||||
[ -f "$data_init/$i" ] && cp "$data_init/$i" "$data/$i"
|
||||
[ -d "$data_init/$i" ] && cp -r "$data_init/$i" "$data/$i"
|
||||
fi
|
||||
done
|
||||
|
||||
# creds.yml migration
|
||||
if [ -f /app/creds.yml ]; then
|
||||
echo "Default location for creds.yml is now /app/data/creds.yml."
|
||||
echo "Please move your creds.yml and update your docker-compose.yml accordingly."
|
||||
|
||||
export Nadeko_creds=/app/creds.yml
|
||||
fi
|
||||
|
||||
# ensure nadeko can write on /app/data
|
||||
chown -R nadeko:nadeko "$data"
|
||||
|
||||
# drop to regular user and launch command
|
||||
exec sudo -u nadeko "$@"
|
@@ -24,6 +24,10 @@ The list below is not complete. Use commands above to see up-to-date list for yo
|
||||
|
||||
`trivia.min_win_req` - Restricts a user's ability to make a trivia game with a win requirement less than the set value.
|
||||
`trivia.currency_reward` - Sets the amount of currency a user will win if they place first in a completed trivia game.
|
||||
`hangman.currency_reward` - Sets the amount of currency a user will win if they win a game of hangman.
|
||||
`chatbot` - Sets which chatbot API the bot should use, values: `gpt3`, `cleverbot`.
|
||||
`gpt.model` - Sets which GPT-3 model the bot should use, values: `ada001`, `babbage001`, `curie001`, `davinci003`.
|
||||
`gpt.max_tokens` - Sets the limit of tokens GPT-3 can use per call. Find out more about tokens [here](https://help.openai.com/en/articles/4936856-what-are-tokens-and-how-to-count-them).
|
||||
|
||||
*more settings may be available in `data/games.yml` file*
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
# How to contribute
|
||||
|
||||
1. Make Merge Requests to the [**v3 branch**](https://gitlab.com/Kwoth/nadekobot/tree/v3)
|
||||
1. Make Merge Requests to the [**v5 branch**](https://gitlab.com/kwoth/nadekobot/tree/v5)
|
||||
2. Keep a single Merge Request to a single feature
|
||||
3. Fill out the MR template
|
||||
|
||||
|
@@ -13,8 +13,13 @@ This document aims to guide you through the process of creating a Discord accoun
|
||||
- Click on the `Add a Bot` button and confirm that you do want to add a bot to this app.
|
||||
- **Optional:** Add bot's avatar and description.
|
||||
- Copy your Token to `creds.yml` as shown above.
|
||||
- Scroll down to the `Privileged Gateway Intents` section and enable both intents.
|
||||
These are required for a number of features to function properly, and should both be on.
|
||||
- Scroll down to the **`Privileged Gateway Intents`** section
|
||||
- **Enable the following:**
|
||||
- **PRESENCE INTENT**
|
||||
- **SERVER MEMBERS INTENT**
|
||||
- **MESSAGE CONTENT INTENT**
|
||||
|
||||
These are required for a number of features to function properly, and all should be on.
|
||||
|
||||
##### Getting Owner ID*(s)*:
|
||||
|
||||
@@ -28,17 +33,17 @@ This document aims to guide you through the process of creating a Discord accoun
|
||||
For a single owner, it should look like this:
|
||||
|
||||
```yml
|
||||
OwnerIds:
|
||||
- 105635576866156544
|
||||
OwnerIds:
|
||||
- 105635576866156544
|
||||
```
|
||||
|
||||
For multiple owners, it should look like this (pay attention to the commas, the last ID should **never** have a comma next to it):
|
||||
For multiple owners, it should look like this:
|
||||
|
||||
```yml
|
||||
OwnerIds:
|
||||
- 105635123466156544
|
||||
- 145521851676884992
|
||||
- 341420590009417729
|
||||
OwnerIds:
|
||||
- 105635123466156544
|
||||
- 145521851676884992
|
||||
- 341420590009417729
|
||||
```
|
||||
|
||||
|
||||
@@ -56,4 +61,4 @@ For multiple owners, it should look like this (pay attention to the commas, the
|
||||
|
||||
That's it! You may now go back to the installation guide you were following before 🎉
|
||||
|
||||
[DiscordApp]: https://discordapp.com/developers/applications/me
|
||||
[DiscordApp]: https://discordapp.com/developers/applications/me
|
||||
|
@@ -1,23 +1,23 @@
|
||||
## Custom Reactions / Expressions
|
||||
## Expressions
|
||||
|
||||
### Important
|
||||
|
||||
- For modifying **global** custom reactions, the ones which will work across all the servers your bot is connected to, you **must** be a Bot Owner.
|
||||
You must also use the commands for adding, deleting and listing these reactions in a direct message with the bot.
|
||||
- For modifying **local** custom reactions, the ones which will only work on the server that they are added on, it is required to have the **Administrator** permission.
|
||||
You must also use the commands for adding, deleting and listing these reactions in the server you want the custom reactions to work on.
|
||||
- For modifying **global** expressions, the ones which will work across all the servers your bot is connected to, you **must** be a Bot Owner.
|
||||
You must also use the commands for adding, deleting and listing these expressions in a direct message with the bot.
|
||||
- For modifying **local** expressions, the ones which will only work on the server that they are added on, it is required to have the **Administrator** permission.
|
||||
You must also use the commands for adding, deleting and listing these expressions in the server you want the expressions to work on.
|
||||
|
||||
### Commands and Their Use
|
||||
|
||||
| Command Name | Description | Example |
|
||||
| :----------: | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------- |
|
||||
| `.acr` | Add a custom reaction with a trigger and a response. Running this command in a server requries the Administrator permission. Running this command in DM is Bot Owner only, and adds a new global custom reaction. | `.acr "hello" Hi there, %user%!` |
|
||||
| `.lcr` | Lists a page of global or server custom reactions (15 reactions per page). Running this command in a DM will list the global custom reactions, while running it in a server will list that server's custom reactions. | `.lcr 1` |
|
||||
| `.dcr` | Deletes a custom reaction based on the provided index. Running this command in a server requires the Administrator permission. Running this command in DM is Bot Owner only, and will delete a global custom reaction. | `.dcr 5` |
|
||||
| `.exa` | Add an expression with a trigger and a response. Running this command in a server requries the Administrator permission. Running this command in DM is Bot Owner only, and adds a new global expression. | `.exadd "hello" Hi there, %user%!` |
|
||||
| `exl` | Lists a page of global or server expression(15 expressions per page). Running this command in a DM will list the global expression, while running it in a server will list that server's expression. | `.exl 1` |
|
||||
| `.exd` | Deletes an expression based on the provided index. Running this command in a server requires the Administrator permission. Running this command in DM is Bot Owner only, and will delete a global expression. | `.exd 5` |
|
||||
|
||||
#### Now that we know the commands let's take a look at an example of adding a command with `.acr`,
|
||||
#### Now that we know the commands let's take a look at an example of adding a command with `.exa`,
|
||||
|
||||
`.acr "Nice Weather" It sure is, %user%!`
|
||||
`.exadd "Nice Weather" It sure is, %user%!`
|
||||
|
||||
This command can be split into two different arguments:
|
||||
|
||||
@@ -28,16 +28,16 @@ An important thing to note about the triger is that, to be more than one word, w
|
||||
|
||||
There's no special requirement for the formatting of the response, so we could just write it in exactly the same way we want it to respond, albeit with a placeholder - which will be explained in this next section.
|
||||
|
||||
Now, if that command was ran in a server, anyone on that server can make the bot mention them, saying `It sure is, @Username` anytime they say "Nice Weather". If the command is ran in a direct message with the bot, then the custom reaction can be used on every server the bot is connected to.
|
||||
Now, if that command was ran in a server, anyone on that server can make the bot mention them, saying `It sure is, @Username` anytime they say "Nice Weather". If the command is ran in a direct message with the bot, then the expression can be used on every server the bot is connected to.
|
||||
|
||||
### Block global Custom Reactions
|
||||
### Block global Expressions
|
||||
|
||||
If you want to disable a global custom reaction which you do not like, and you do not want to remove it, or you are not the bot owner, you can do so by adding a new Custom Reaction with the same trigger on your server, and set the response to `-`.
|
||||
If you want to disable a global expression which you do not like, and you do not want to remove it, or you are not the bot owner, you can do so by adding a new expression with the same trigger on your server, and set the response to `-`.
|
||||
|
||||
For example:
|
||||
`.acr /o/ -`
|
||||
`.exa /o/ -`
|
||||
|
||||
Now if you try to trigger `/o/`, it won't print anything even if there is a global custom reaction with the same name.
|
||||
Now if you try to trigger `/o/`, it won't print anything even if there is a global expression with the same name.
|
||||
|
||||
### Placeholders!
|
||||
|
||||
|
@@ -10,7 +10,7 @@ Donating to us also gives you the following benefits:
|
||||
- A hoisted **Donators role** in our [Discord server][discord-server]
|
||||
- Access to exclusive **#noticed** text and voice channels
|
||||
- **1000 flowers** on the public bot per dollar donated (after fees)
|
||||
- **Custom Reactions** on the public bot for [Patreon pledges][patreon] of $5 or higher
|
||||
- **Expressions** on the public bot for [Patreon pledges][patreon] of $5 or higher
|
||||
|
||||
## Patreon
|
||||
|
||||
@@ -30,7 +30,7 @@ You can also donate to us through [PayPal][paypal] for one-time donations using
|
||||
|
||||
[![img][paypal-button]][paypal]
|
||||
|
||||
[gitlab]: https://gitlab.com/Kwoth/nadekobot
|
||||
[gitlab]: https://gitlab.com/kwoth/nadekobot
|
||||
[discord-server]: https://discord.nadeko.bot/
|
||||
[patreon]: https://www.patreon.com/nadekobot
|
||||
[patreon-button]: ./assets/patreon.png
|
||||
|
@@ -1,20 +1,25 @@
|
||||
# Setting up NadekoBot with Docker
|
||||
|
||||
# DO NOT USE YET - WORK IN PROGRESS
|
||||
# WORK IN PROGRESS
|
||||
|
||||
Upgrade from 2.x to v3 does not work because the file is mount readonly
|
||||
### Installation
|
||||
|
||||
### Docker Compose
|
||||
1. Create a `/srv/nadeko` folder
|
||||
- `mkdir -p /srv/nadeko`
|
||||
2. Create a `docker-compose.yml`
|
||||
- nano `docker-compose.yml`
|
||||
- copy the following contents into it:
|
||||
##### docker-compose.yml
|
||||
```yml
|
||||
version: "3.7"
|
||||
services:
|
||||
nadeko:
|
||||
image: registry.gitlab.com/veovis/nadekobot:v3-docker
|
||||
image: registry.gitlab.com/kwoth/nadekobot:latest
|
||||
depends_on:
|
||||
- redis
|
||||
environment:
|
||||
TZ: Europe/Paris
|
||||
#NadekoBot_RedisOptions: redis,name=nadeko
|
||||
NadekoBot_RedisOptions: redis,name=nadeko
|
||||
#NadekoBot_ShardRunCommand: dotnet
|
||||
#NadekoBot_ShardRunArguments: /app/NadekoBot.dll {0} {1}
|
||||
volumes:
|
||||
@@ -29,6 +34,12 @@ services:
|
||||
volumes:
|
||||
- /srv/nadeko/redis-data:/data
|
||||
```
|
||||
3. Save your file and run docker compose
|
||||
- `docker-compose up`
|
||||
4. Edit creds in `/srv/nadeko/conf/creds.yml`
|
||||
5. Run it again with
|
||||
- `docker-compose up`
|
||||
|
||||
### Updating
|
||||
- `cd /srv/nadeko`
|
||||
- `docker-compose pull`
|
||||
|
@@ -1,42 +1,85 @@
|
||||
## Migration from 2.x
|
||||
# Setting up NadekoBot on Linux
|
||||
|
||||
##### ⚠ If you're already hosting NadekoBot, _You **MUST** update to latest version of 2.x and **run your bot at least once**_ before switching over to v3.
|
||||
| Table of Contents |
|
||||
| :-------------------------------------------------- |
|
||||
| [Linux From Source] |
|
||||
| [Source Update Instructions] |
|
||||
| [Linux Release] |
|
||||
| [Release Update Instructions] |
|
||||
| [Tmux (Preferred Method)] |
|
||||
| [Systemd] |
|
||||
| [Systemd + Script] |
|
||||
| [Setting up Nadeko on a VPS (Digital Ocean)] |
|
||||
|
||||
#### [Linux migration instructions](../migration-guide/#linux)
|
||||
#### Operating System Compatibility
|
||||
|
||||
##### Compatible operating systems:
|
||||
|
||||
- Ubuntu: 20.04, 21.04, 21.10, 22.04
|
||||
- Mint: 19, 20
|
||||
- Debian: 10, 11, 12
|
||||
- RockyLinux: 8, 9
|
||||
- AlmaLinux: 8, 9
|
||||
- openSUSE Leap: 15.5, 15.6 & Tumbleweed
|
||||
- Fedora: 38, 39, 40, 41, 42
|
||||
|
||||
## Linux From Source
|
||||
|
||||
Open Terminal (if you're on an installation with a window manager) and navigate to the location where you want to install the bot (for example `cd ~`)
|
||||
##### Migration from v3 -> v5
|
||||
|
||||
Follow the following few steps only if you're migrating from v3. If not, skip to installation instructions.
|
||||
|
||||
Use the new installer script: `cd ~ && wget -N https://gitlab.com/kwoth/nadeko-bash-installer/-/raw/v5/linuxAIO.sh && bash linuxAIO.sh`
|
||||
> - Install prerequisites (type `1` and press `enter`)
|
||||
> - Download (type `2` and press `enter`)
|
||||
> - Run (type `3` and press `enter`)
|
||||
> - Done
|
||||
|
||||
##### Installation Instructions
|
||||
|
||||
1. Download and run the **new** installer script `cd ~ && wget -N https://gitlab.com/Kwoth/nadeko-bash-installer/-/raw/master/linuxAIO.sh && bash linuxAIO.sh`
|
||||
Open Terminal (if you're on an installation with a window manager) and navigate to the location where you want to install the bot (for example `cd ~`)
|
||||
|
||||
1. Download and run the **new** installer script `cd ~ && wget -N https://gitlab.com/kwoth/nadeko-bash-installer/-/raw/v5/linuxAIO.sh && bash linuxAIO.sh`
|
||||
2. Install prerequisites (type `1` and press enter)
|
||||
3. Download the bot (type `2` and press enter)
|
||||
4. Exit the installer in order to set up your `creds.yml`
|
||||
4. Exit the installer (type `6` and press enter)
|
||||
5. Copy the creds.yml template `cp nadekobot/output/creds_example.yml nadekobot/output/creds.yml`
|
||||
6. Open `nadekobot/output/creds.yml` with your favorite text editor. We will use nano here
|
||||
- `nano nadekobot/output/creds.yml`
|
||||
7. [Enter your bot's token](../../creds-guide)
|
||||
7. [Click here to follow creds guide](../../creds-guide)
|
||||
- After you're done, you can close nano (and save the file) by inputting, in order
|
||||
- `CTRL` + `X`
|
||||
- `Y`
|
||||
- `Enter`
|
||||
8. Run the bot (type `3` and press enter)
|
||||
8. Run the installer script again `cd ~ && wget -N https://gitlab.com/kwoth/nadeko-bash-installer/-/raw/v5/linuxAIO.sh && bash linuxAIO.sh`
|
||||
9. Run the bot (type `3` and press enter)
|
||||
|
||||
##### Update Instructions
|
||||
##### Source Update Instructions
|
||||
|
||||
1. ⚠ Stop the bot
|
||||
2. Update and run the **new** installer script `cd ~ && wget -N https://gitlab.com/Kwoth/nadeko-bash-installer/-/raw/master/linuxAIO.sh && bash linuxAIO.sh`
|
||||
1. ⚠ Stop the bot ⚠
|
||||
2. Update and run the **new** installer script `cd ~ && wget -N https://gitlab.com/kwoth/nadeko-bash-installer/-/raw/v5/linuxAIO.sh && bash linuxAIO.sh`
|
||||
3. Update the bot (type `2` and press enter)
|
||||
4. Run the bot (type `3` and press enter)
|
||||
5. 🎉
|
||||
|
||||
## **⚠ IF YOU ARE FOLLOWING THE GUIDE ABOVE, IGNORE THIS SECTION ⚠**
|
||||
|
||||
## Linux Release
|
||||
|
||||
###### Prerequisites
|
||||
|
||||
1. (Optional) Installing Redis
|
||||
- ubuntu installation command: `sudo apt-get install redis-server`
|
||||
2. Playing music requires `ffmpeg`, `libopus`, `libsodium` and `youtube-dl` (which in turn requires python3)
|
||||
- ubuntu installation command: `sudo apt-get install ffmpeg libopus0 opus-tools libopus-dev libsodium-dev -y`
|
||||
3. Make sure your python is version 3+ with `python --version`
|
||||
- if it's not, you can install python 3 and make it the default with: `sudo apt-get install python3.8 python-is-python3`
|
||||
|
||||
*You can use nadeko bash script [prerequisites installer](https://gitlab.com/kwoth/nadeko-bash-installer/-/blob/v5/n-prereq.sh) as a reference*
|
||||
|
||||
##### Installation Instructions
|
||||
|
||||
1. Download the latest release from <https://gitlab.com/Kwoth/nadekobot/-/releases>
|
||||
1. Download the latest release from <https://gitlab.com/kwoth/nadekobot/-/releases>
|
||||
- Look for the file called "X.XX.X-linux-x64-build.tar" (where X.XX.X is a series of numbers) and download it
|
||||
2. Untar it
|
||||
- ⚠ Make sure that you change X.XX.X to the same series of numbers as in step 1!
|
||||
@@ -49,7 +92,7 @@ Open Terminal (if you're on an installation with a window manager) and navigate
|
||||
- `cp creds_example.yml creds.yml`
|
||||
6. Open `creds.yml` with your favorite text editor. We will use nano here
|
||||
- `nano nadekobot/output/creds.yml`
|
||||
8. [Enter your bot's token](#creds-guide)
|
||||
8. [Click here to follow creds guide](../../creds-guide)
|
||||
- After you're done, you can close nano (and save the file) by inputting, in order
|
||||
- `CTRL` + `X`
|
||||
- `Y`
|
||||
@@ -57,10 +100,10 @@ Open Terminal (if you're on an installation with a window manager) and navigate
|
||||
9. Run the bot
|
||||
- `./NadekoBot`
|
||||
|
||||
##### Update Instructions
|
||||
##### Release Update Instructions
|
||||
|
||||
1. Stop the bot
|
||||
2. Download the latest release from <https://gitlab.com/Kwoth/nadekobot/-/releases>
|
||||
2. Download the latest release from <https://gitlab.com/kwoth/nadekobot/-/releases>
|
||||
- Look for the file called "x.x.x-linux-x64-build.tar" (where `X.X.X` is a version, for example 3.0.4) and download it
|
||||
3. Untar it
|
||||
- ⚠ Make sure that you change `X.X.X` to the same series of numbers as in step 2!
|
||||
@@ -104,23 +147,46 @@ cd nadekobot && chmod +x NadekoBot
|
||||
|
||||
While there are two run modes built into the installer, these options only run Nadeko within the current session. Below are 3 methods of running Nadeko as a background process.
|
||||
|
||||
### Tmux (Preferred Method)
|
||||
### Tmux Method (Preferred)
|
||||
|
||||
Using `tmux` is the simplest method, and is therefore recommended for most users.
|
||||
|
||||
1. Start a tmux session:
|
||||
- `tmux`
|
||||
2. Navigate to the project's root directory
|
||||
- Project root directory location example: `/home/user/nadekobot/`
|
||||
3. Enter the `output` directory:
|
||||
- `cd output`
|
||||
4. Run the bot using:
|
||||
- `dotnet NadekoBot.dll`
|
||||
5. Detatch the tmux session:
|
||||
**Before proceeding, make sure your bot is not running by either running `.die` in your Discord server or exiting the process with `Ctrl+C`.**
|
||||
|
||||
If you are presented with the installer main menu, exit it by choosing Option `8`.
|
||||
|
||||
1. Create a new session: `tmux new -s nadeko`
|
||||
|
||||
The above command will create a new session named **nadeko** *(you can replace “nadeko” with anything you prefer, it's your session name)*.
|
||||
|
||||
2. Run the installer: `bash linuxAIO.sh`
|
||||
|
||||
3. There are a few options when it comes to running Nadeko.
|
||||
|
||||
- Run `3` to *Run the bot normally*
|
||||
- Run `4` to *Run the bot with Auto Restart* (This is may or may not work)
|
||||
|
||||
4. If option `4` was selected, you have the following options
|
||||
```
|
||||
1. Run Auto Restart normally without updating NadekoBot.
|
||||
2. Run Auto Restart and update NadekoBot.
|
||||
3. Exit
|
||||
|
||||
Choose:
|
||||
[1] to Run NadekoBot with Auto Restart on "die" command without updating.
|
||||
[2] to Run with Auto Updating on restart after using "die" command.
|
||||
```
|
||||
- Run `1` to restart the bot without updating. (This is done using the `.die` command)
|
||||
- Run `2` to update the bot upon restart. (This is also done using the `.die` command)
|
||||
|
||||
5. That's it! to detatch the tmux session:
|
||||
- Press `Ctrl` + `B`
|
||||
- Then press `D`
|
||||
|
||||
Nadeko should now be running in the background of your system. To re-open the tmux session to either update, restart, or whatever, execute `tmux a`.
|
||||
Now check your Discord server, the bot should be online. Nadeko should now be running in the background of your system.
|
||||
|
||||
To re-open the tmux session to either update, restart, or whatever, execute `tmux a -t nadeko`. *(Make sure to replace "nadeko" with your session name. If you didn't change it, leave it as it.)*
|
||||
|
||||
|
||||
### Systemd
|
||||
|
||||
@@ -134,6 +200,8 @@ Compared to using tmux, this method requires a little bit more work to set up, b
|
||||
echo "[Unit]
|
||||
Description=NadekoBot service
|
||||
After=network.target
|
||||
StartLimitIntervalSec=60
|
||||
StartLimitBurst=2
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
@@ -144,10 +212,11 @@ Compared to using tmux, this method requires a little bit more work to set up, b
|
||||
# source code.
|
||||
#ExecStartPre=/usr/bin/dotnet build ../src/NadekoBot/NadekoBot.csproj -c Release -o output/
|
||||
ExecStart=/usr/bin/dotnet NadekoBot.dll
|
||||
Restart=on-failure
|
||||
RestartSec=5
|
||||
StandardOutput=syslog
|
||||
StandardError=syslog
|
||||
SyslogIdentifier=NadekoBot
|
||||
Restart=always
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target" | sudo tee /etc/systemd/system/nadeko.service
|
||||
@@ -172,12 +241,16 @@ This method is similar to the one above, but requires one extra step, with the a
|
||||
echo "[Unit]
|
||||
Description=NadekoBot service
|
||||
After=network.target
|
||||
StartLimitIntervalSec=60
|
||||
StartLimitBurst=2
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=$USER
|
||||
WorkingDirectory=$PWD
|
||||
WorkingDirectory=$_WORKING_DIR
|
||||
ExecStart=/bin/bash NadekoRun.sh
|
||||
Restart=on-failure
|
||||
RestartSec=5
|
||||
StandardOutput=syslog
|
||||
StandardError=syslog
|
||||
SyslogIdentifier=NadekoBot
|
||||
@@ -191,14 +264,14 @@ This method is similar to the one above, but requires one extra step, with the a
|
||||
4. Use the following command to create a script that will be used to start Nadeko:
|
||||
|
||||
```bash
|
||||
echo "#\!/bin/bash
|
||||
|
||||
echo \"\"
|
||||
echo \"Running NadekoBot in the background with auto restart\"
|
||||
{
|
||||
echo '#!/bin/bash'
|
||||
echo ""
|
||||
echo "echo \"Running NadekoBot in the background with auto restart\"
|
||||
youtube-dl -U
|
||||
|
||||
# If you want Nadeko to be compiled prior to every startup, uncomment the lines
|
||||
# below. Note that it's not neccessary unless you are personally modifying the
|
||||
# below. Note that it's not necessary unless you are personally modifying the
|
||||
# source code.
|
||||
#echo \"Compiling NadekoBot...\"
|
||||
#cd \"$PWD\"/nadekobot
|
||||
@@ -207,23 +280,93 @@ This method is similar to the one above, but requires one extra step, with the a
|
||||
echo \"Starting NadekoBot...\"
|
||||
|
||||
while true; do
|
||||
{
|
||||
cd \"$PWD\"/nadekobot/output
|
||||
dotnet NadekoBot.dll
|
||||
## If a non-zero exit code is produced, exit this script.
|
||||
} || {
|
||||
error_code=\"\$?\"
|
||||
if [[ -d $PWD/nadekobot/output ]]; then
|
||||
cd $PWD/nadekobot/output || {
|
||||
echo \"Failed to change working directory to $PWD/nadekobot/output\" >&2
|
||||
echo \"Ensure that the working directory inside of '/etc/systemd/system/nadeko.service' is correct\"
|
||||
echo \"Exiting...\"
|
||||
exit 1
|
||||
}
|
||||
else
|
||||
echo \"$PWD/nadekobot/output doesn't exist\"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
dotnet NadekoBot.dll || {
|
||||
echo \"An error occurred when trying to start NadekBot\"
|
||||
echo \"EXIT CODE: \$?\"
|
||||
exit \"\$error_code\"
|
||||
echo \"Exiting...\"
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
||||
echo \"Waiting for 5 seconds...\"
|
||||
sleep 5
|
||||
youtube-dl -U
|
||||
echo \"Restarting NadekoBot...\"
|
||||
done
|
||||
|
||||
echo \"Stopping NadekoBot...\"" > NadekoRun.sh
|
||||
echo \"Stopping NadekoBot...\""
|
||||
} > NadekoRun.sh
|
||||
```
|
||||
|
||||
5. Start Nadeko:
|
||||
- `sudo systemctl start nadeko.service && sudo systemctl enable nadeko.service`
|
||||
- `sudo systemctl start nadeko.service && sudo systemctl enable nadeko.service`
|
||||
|
||||
### Setting up Nadeko on a Linux VPS (Digital Ocean Droplet)
|
||||
|
||||
If you want Nadeko to play music for you 24/7 without having to hosting it on your PC and want to keep it cheap, reliable and convenient as possible, you can try Nadeko on Linux Digital Ocean Droplet using the link [DigitalOcean](http://m.do.co/c/46b4d3d44795/) (by using this link, you will get **$10 credit** and also support Nadeko)
|
||||
|
||||
To set up the VPS, please select the options below
|
||||
```
|
||||
These are the min requirements you must follow:
|
||||
|
||||
OS: Any between Ubuntu, Fedora, and Debian
|
||||
|
||||
Plan: Basic
|
||||
|
||||
CPU options: regular with SSD
|
||||
1 GB / 1 CPU
|
||||
25 GB SSD Disk
|
||||
1000 GB transfer
|
||||
|
||||
Note: You can select the cheapest option with 512 MB /1 CPU but this has been a hit or miss.
|
||||
|
||||
Datacenter region: Choose one depending on where you are located.
|
||||
|
||||
Authentication: Password or SSH
|
||||
(Select SSH if you know what you are doing, otherwise choose password)
|
||||
```
|
||||
**Setting up NadekoBot**
|
||||
Assuming you have followed the link above to setup an account and a Droplet with a 64-bit operational system on Digital Ocean and got the `IP address and root password (in your e-mail)` to login, it's time to get started.
|
||||
|
||||
**This section is only relevant to those who want to host Nadeko on DigitalOcean. Go through this whole section before setting the bot up.**
|
||||
|
||||
#### Prerequisites
|
||||
|
||||
- Download [PuTTY](http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html)
|
||||
- Download [WinSCP](https://winscp.net/eng/download.php) *(optional)*
|
||||
- [Create and invite the bot](../../creds-guide).
|
||||
|
||||
#### Starting up
|
||||
|
||||
- **Open PuTTY** and paste or enter your `IP address` and then click **Open**.
|
||||
If you entered your Droplets IP address correctly, it should show **login as:** in a newly opened window.
|
||||
- Now for **login as:**, type `root` and press enter.
|
||||
- It should then ask for a password. Type the `root password` you have received in your e-mail address, then press Enter.
|
||||
|
||||
If you are running your droplet for the first time, it will most likely ask you to change your root password. To do that, copy the **password you've received by e-mail** and paste it on PuTTY.
|
||||
|
||||
- To paste, just right-click the window (it won't show any changes on the screen), then press Enter.
|
||||
- Type a **new password** somewhere, copy and paste it on PuTTY. Press Enter then paste it again.
|
||||
|
||||
**Save the new password somewhere safe.**
|
||||
|
||||
After that, your droplet should be ready for use. [Follow the guide from the beginning](#linux-from-source) to set Nadeko up on your newly created VPS.
|
||||
|
||||
[Linux From Source]: #linux-from-source
|
||||
[Source Update Instructions]: #source-update-instructions
|
||||
[Linux Release]: #linux-release
|
||||
[Release Update Instructions]: #release-update-instructions
|
||||
[Tmux (Preferred Method)]: #tmux-preferred-method
|
||||
[Systemd]: #systemd
|
||||
[Systemd + Script]: #systemd-script
|
||||
[Setting up Nadeko on a VPS (Digital Ocean)]: #setting-up-nadeko-on-a-linux-vps-digital-ocean-droplet
|
||||
|
@@ -1,66 +0,0 @@
|
||||
# Migration instructions (2.x to v3)
|
||||
|
||||
## Windows
|
||||
|
||||
1. Run your NadekoBot Updater first, and **make sure your bot is updated to at least 2.46.5**
|
||||
- **Run your 2.46.5 Bot** and make sure it works, and then **stop it**
|
||||
- Close your old NadekoBot Updater
|
||||
2. Get the new NadekoBot v3 Updater [here](https://dl.nadeko.bot/v3)
|
||||
3. Click on the + icon to add a new bot
|
||||
4. Next to the path, click on the folder icon and select the folder where your 2.46.5 bot is
|
||||
- ℹ In case you're not sure where it's located, you can open your old updater and see it
|
||||
5. If you've selected the correct path, you should have an **Update** button available, click it
|
||||
6. You're done; you can now run your bot, and you can uninstall your old updater if you no longer have 2.x bots
|
||||
7. 🎉
|
||||
|
||||
## Linux
|
||||
|
||||
1. In order to migrate a bot hosted on **Linux**, first update your current version to the latest 2.x version using the 2.x installer, run the bot, and make sure it works. Then:
|
||||
- Run the **old** installer with `cd ~ && wget -N https://github.com/Kwoth/NadekoBot-BashScript/raw/1.9/linuxAIO.sh && bash linuxAIO.sh`
|
||||
- Run option **1** again
|
||||
- You **MUST** Run the bot now to ensure database is ready for migration
|
||||
- Type `.stats` and ensure the version is `2.46.5` or later
|
||||
- Stop the bot
|
||||
2. Make sure your bot's folder is called `NadekoBot`
|
||||
- Run `cd ~ && ls`
|
||||
- Confirm there is a folder called NadekoBot (not nadekobot, in all lowercase)
|
||||
3. Migrate your bot's data using the new installer:
|
||||
- Run the **new** installer `cd ~ && wget -N https://gitlab.com/Kwoth/nadeko-bash-installer/-/raw/master/linuxAIO.sh && bash linuxAIO.sh`
|
||||
- The installer should notify you that your data is ready for migration in a message above the menu.
|
||||
- Install prerequisites (type `1` and press enter), and make sure it is successful
|
||||
- Download NadekoBot v3 (type `2` and press enter)
|
||||
- Run the bot (type `3` and press enter)
|
||||
4. Make sure your permissions, custom reactions, credentials, and other data is preserved
|
||||
- `.stats` to ensure owner id (credentials) is correct
|
||||
- `.lcr` to see custom reactions
|
||||
- `.lp` to list permissions
|
||||
5. 🎉 Enjoy. If you want to learn how to update the bot, click [here](../linux-guide/#update-instructions)
|
||||
|
||||
## Manual
|
||||
|
||||
⚠ NOT RECOMMENDED
|
||||
⚠ NadekoBot v3 requires [.net 5](https://dotnet.microsoft.com/download/dotnet/5.0)
|
||||
|
||||
1. In order to migrate a bot hosted **on Linux or from source on Windows**
|
||||
- First update your current version to the latest 2.x version using the 2.x installer
|
||||
- Then you **must** run the bot to prepare the database for the migration, and make sure the bot works prior to upgrade.
|
||||
Then:
|
||||
2. Rename your old nadeko bot folder to `nadekobot_2x`
|
||||
- `mv NadekoBot nadekobot_2x`
|
||||
3. Build the new version and move old data to the output folder
|
||||
1. Clone the v3 branch to a separate folder
|
||||
- `git clone https://gitlab.com/kwoth/nadekobot -b v3 --depth 1`
|
||||
2. Build the bot
|
||||
- `dotnet publish -c Release -o output/ src/NadekoBot/`
|
||||
3. Copy old data
|
||||
- ⚠ Be sure you copy the correct command for your system!
|
||||
- **Windows:** `cp -r -fo nadekobot_2x/src/NadekoBot/data nadekobot/src/NadekoBot/data`
|
||||
- **Linux:** `cp -rf nadekobot_2x/src/NadekoBot/data nadekobot/src/NadekoBot/data`
|
||||
4. Copy the database
|
||||
- `cp nadekobot_2x/src/NadekoBot/bin/Release/netcoreapp2.1/data/NadekoBot.db nadekobot/output/data`
|
||||
5. Copy your credentials
|
||||
- `cp nadekobot_2x/src/NadekoBot/credentials.json nadekobot/output/`
|
||||
4. Run the bot
|
||||
- `cd nadekobot/output`
|
||||
- `dotnet NadekoBot.dll`
|
||||
5. That's it. Just make sure that when you're updating the bot, you're properly backing up your old data.
|
@@ -2,17 +2,36 @@
|
||||
|
||||
Open Terminal (if you don't know how to, click on the magnifying glass on the top right corner of your screen and type **Terminal** on the window that pops up) and navigate to the location where you want to install the bot (for example `cd ~`)
|
||||
|
||||
##### Installing Homebrew and wget
|
||||
##### Installing Homebrew, wget and dotnet
|
||||
|
||||
###### Homebrew/wget
|
||||
*Skip this step if you already have homebrew installed*
|
||||
- Copy and paste this command, then press Enter:
|
||||
- `/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"`
|
||||
- `/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"`
|
||||
- Install wget
|
||||
- `brew install wget`
|
||||
- `brew install wget`
|
||||
|
||||
###### Dotnet
|
||||
- Download [.net6 SDK](https://dotnet.microsoft.com/download/dotnet/6.0)
|
||||
- Open the `.pkg` file you've downloaded and install it.
|
||||
- Run this command in Terminal. There might be output. If there is, disregard it. (copy-paste the entire block)
|
||||
```bash
|
||||
sudo mkdir /usr/local/bin
|
||||
|
||||
sudo mkdir /usr/local/lib
|
||||
```
|
||||
- Run this command in Terminal. There won't be any output. (copy-paste the entire block):
|
||||
```bash
|
||||
sudo ln -s /usr/local/share/dotnet/dotnet /usr/local/bin
|
||||
|
||||
sudo ln -s /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/
|
||||
|
||||
sudo ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/
|
||||
```
|
||||
|
||||
##### Installation Instructions
|
||||
|
||||
1. Download and run the **new** installer script `cd ~ && wget -N https://gitlab.com/Kwoth/nadeko-bash-installer/-/raw/master/linuxAIO.sh && bash linuxAIO.sh`
|
||||
1. Download and run the **new** installer script `cd ~ && wget -N https://gitlab.com/kwoth/nadeko-bash-installer/-/raw/v5/linuxAIO.sh && bash linuxAIO.sh`
|
||||
2. Install prerequisites (type `1` and press enter)
|
||||
3. Download the bot (type `2` and press enter)
|
||||
4. Exit the installer in order to set up your `creds.yml`
|
||||
@@ -30,16 +49,18 @@ Open Terminal (if you don't know how to, click on the magnifying glass on the to
|
||||
##### Update Instructions
|
||||
|
||||
1. ⚠ Stop the bot
|
||||
2. Update and run the **new** installer script `cd ~ && wget -N https://gitlab.com/Kwoth/nadeko-bash-installer/-/raw/master/linuxAIO.sh && bash linuxAIO.sh`
|
||||
2. Update and run the **new** installer script `cd ~ && wget -N https://gitlab.com/kwoth/nadeko-bash-installer/-/raw/v5/linuxAIO.sh && bash linuxAIO.sh`
|
||||
3. Update the bot (type `2` and press enter)
|
||||
4. Run the bot (type `3` and press enter)
|
||||
5. 🎉
|
||||
|
||||
## MacOS Manual Release installation instructions
|
||||
|
||||
⚠ IF YOU ARE FOLLOWING THE GUIDE ABOVE, IGNORE THIS SECTION ⚠
|
||||
|
||||
##### Installation Instructions
|
||||
|
||||
1. Download the latest release from <https://gitlab.com/Kwoth/nadekobot/-/releases>
|
||||
1. Download the latest release from <https://gitlab.com/kwoth/nadekobot/-/releases>
|
||||
- Look for the file called "X.XX.X-linux-x64-build.tar" (where X.XX.X is a series of numbers) and download it
|
||||
2. Untar it
|
||||
⚠ Make sure that you change X.XX.X to the same series of numbers as in step 1!
|
||||
@@ -63,7 +84,7 @@ Open Terminal (if you don't know how to, click on the magnifying glass on the to
|
||||
##### Update Instructions
|
||||
|
||||
1. Stop the bot
|
||||
2. Download the latest release from <https://gitlab.com/Kwoth/nadekobot/-/releases>
|
||||
2. Download the latest release from <https://gitlab.com/kwoth/nadekobot/-/releases>
|
||||
- Look for the file called "X.XX.X-linux-x64-build.tar" (where X.XX.X is a series of numbers) and download it
|
||||
3. Untar it
|
||||
⚠ Make sure that you change X.XX.X to the same series of numbers as in step 2!
|
||||
@@ -101,4 +122,4 @@ rm -r nadekobot-old/data/strings && \
|
||||
cp -RT nadekobot-old/data/ nadekobot/data/ && \
|
||||
cp nadekobot-old/creds.yml nadekobot/ && \
|
||||
cd nadekobot && chmod +x NadekoBot
|
||||
```
|
||||
```
|
||||
|
@@ -1,9 +1,3 @@
|
||||
## Migration from 2.x
|
||||
|
||||
⚠ If you're already hosting NadekoBot, You **MUST** update to latest version of 2.x and **run your bot at least once** before switching over to v3.
|
||||
|
||||
#### [Windows migration instructions](../migration-guide#windows)
|
||||
|
||||
## Setting Up NadekoBot on Windows With the Updater
|
||||
|
||||
| Table of Contents|
|
||||
@@ -12,33 +6,31 @@
|
||||
| [Setup](#setup) |
|
||||
| [Starting the Bot](#starting-the-bot) |
|
||||
| [Updating Nadeko](#updating-nadeko) |
|
||||
| [Manually Installing the Prerequisites from the Updater](#if-the-updater-fails-to-install-the-prerequisites-for-any-reason) |
|
||||
| [Manually Installing the Prerequisites from the Updater](#music-prerequisites) |
|
||||
|
||||
*Note: If you want to make changes to Nadeko's source code, please follow the [From Source][SourceGuide] guide instead.*
|
||||
|
||||
*If you have Windows 7 or a 32-bit system, please refer to the [From Source][SourceGuide] guide.*
|
||||
*Note: If you want to make changes to Nadeko's source code, please follow the [From Source](#windows-from-source) guide instead.*
|
||||
|
||||
#### Prerequisites
|
||||
|
||||
- Windows 8 or later (64-bit)
|
||||
- [Create a Discord Bot application and invite the bot to your server](../../creds-guide.md)
|
||||
- Windows 10 or later (64-bit)
|
||||
- [Create a Discord Bot application and invite the bot to your server](../creds-guide.md)
|
||||
|
||||
**Optional**
|
||||
|
||||
- [Notepad++] (makes it easier to edit your credentials)
|
||||
- [Visual Studio Code](https://code.visualstudio.com/Download) (Highly suggested if you plan on editing files)
|
||||
- [Visual C++ 2010 (x86)] and [Visual C++ 2017 (x64)] (both are required if you want Nadeko to play music - restart Windows after installation)
|
||||
|
||||
#### Setup
|
||||
|
||||
- Download and run the [NadekoBot v3 Updater][Updater].
|
||||
- Click on the + at the top left to create a new bot.
|
||||

|
||||

|
||||
- Give your bot a name and then click **`Go to setup`** at the lower right.
|
||||

|
||||

|
||||
- Click on **`DOWNLOAD`** at the lower right
|
||||

|
||||
- Click on **`Install`** next to **`Redis`**.
|
||||
- If you will use the music module, click on **`Install`** next to **`FFMPEG`** and **`Youtube-DL`**.
|
||||

|
||||
- **Note: Redis is optional. install Redis manually here: [Redis] Download and run the **`.msi`** file.**
|
||||
- If you will use the music module, click on **`Install`** next to **`FFMPEG`** and **`Youtube-DLP`**.
|
||||
- If any dependencies fail to install, you can temporarily disable your Windows Defender/AV until you install them. If you don't want to, then read [the last section of this guide](#Manual-Prerequisite-Installation).
|
||||
- When installation is finished, click on **`CREDS`** to the left of **`RUN`** at the lower right.
|
||||
- Follow the guide on how to [Set up the creds.yml](../../creds-guide) file.
|
||||
@@ -47,9 +39,11 @@
|
||||
|
||||
- Either click on **`RUN`** button in the updater or run the bot via its desktop shortcut.
|
||||
|
||||
### If you get a "No owner channels created..." message. Please follow the creds guide again [**HERE**](../../creds-guide).
|
||||
|
||||
#### Updating Nadeko
|
||||
|
||||
- Make sure Nadeko is closed and not running
|
||||
- Make sure Nadeko is closed and not running
|
||||
(Run `.die` in a connected server to ensure it's not running).
|
||||
- Open NadekoBot Updater
|
||||
- Click on your bot at the upper left (looks like a spy).
|
||||
@@ -62,31 +56,34 @@
|
||||
|
||||
You can still install them manually:
|
||||
|
||||
- [Redis Installer](https://github.com/MicrosoftArchive/redis/releases/tag/win-3.0.504) - Download and run the **`.msi`** file
|
||||
- [Redis] (OPTIONAL) - Download and run the **`.msi`** file
|
||||
- [ffmpeg-32bit] | [ffmpeg-64bit] - Download the **appropriate version** for your system (32 bit if you're running a 32 bit OS, or 64 if you're running a 64bit OS). Unzip it, and move `ffmpeg.exe` to a path that's in your PATH environment variable. If you don't know what that is, then just move the `ffmpeg.exe` file to NadekoBot/system
|
||||
- [youtube-dl] - Click to download the file. Then put `youtube-dl.exe` in a path that's in your PATH environment variable. If you don't know what that is, then just move the `youtube-dl.exe` file to NadekoBot/system
|
||||
- [youtube-dlp] - Click to download the `yt-dlp.exe` file then put `yt-dlp.exe` in a path that's in your PATH environment variable. If you don't know what that is, then just move the `yt-dlp.exe` file to NadekoBot/system
|
||||
|
||||
## **⚠ IF YOU ARE FOLLOWING THE GUIDE ABOVE, IGNORE THIS SECTION ⚠**
|
||||
|
||||
### Windows From Source
|
||||
|
||||
##### Prerequisites
|
||||
|
||||
**Install these before proceeding or your bot will not work!**
|
||||
- [.net 5](https://dotnet.microsoft.com/download/dotnet/5.0) - needed to compile and run the bot
|
||||
- [.net 8](https://dotnet.microsoft.com/en-us/download) - needed to compile and run the bot
|
||||
- [git](https://git-scm.com/downloads) - needed to clone the repository (you can also download the zip manually and extract it, but this guide assumes you're using git)
|
||||
- [redis](https://github.com/MicrosoftArchive/redis/releases/download/win-3.0.504/Redis-x64-3.0.504.msi) - to cache things needed by some features and persist through restarts
|
||||
- [Redis] (OPTIONAL)- to cache things needed by some features and persist through restarts
|
||||
|
||||
##### Installation Instructions
|
||||
|
||||
Open PowerShell (press windows button on your keyboard and type powershell, it should show up; alternatively, right click the start menu and select Windows PowerShell), and navigate to the location where you want to install the bot (for example `cd ~/Desktop/`)
|
||||
Open PowerShell (press windows button on your keyboard and type powershell, it should show up; alternatively, right click the start menu and select Windows PowerShell), and navigate to the location where you want to install the bot (for example `cd ~/Desktop/`)
|
||||
|
||||
1. `git clone https://gitlab.com/kwoth/nadekobot -b v3 --depth 1`
|
||||
1. `git clone https://gitlab.com/kwoth/nadekobot -b v5 --depth 1`
|
||||
2. `cd nadekobot`
|
||||
3. `dotnet publish -c Release -o output/ src/NadekoBot/`
|
||||
4. `cd output && cp creds_example.yml creds.yml`
|
||||
5. Open `creds.yml` with your favorite text editor (Please don't use Notepad or WordPad. You can use Notepad++, VSCode, Atom, Sublime, or something similar)
|
||||
6. [Enter your bot's token](#creds-guide)
|
||||
7. Run the bot `dotnet NadekoBot.dll`
|
||||
8. 🎉
|
||||
4. `cd output`
|
||||
5. `cp creds_example.yml creds.yml`
|
||||
6. Open `creds.yml` with your favorite text editor (Please don't use Notepad or WordPad. You can use Notepad++, VSCode, Atom, Sublime, or something similar)
|
||||
7. [Enter your bot's token](#creds-guide)
|
||||
8. Run the bot `dotnet NadekoBot.dll`
|
||||
9. 🎉
|
||||
|
||||
##### Update Instructions
|
||||
|
||||
@@ -96,14 +93,18 @@ Open PowerShell as described above and run the following commands:
|
||||
- ⚠️ Make sure you don't have your database, credentials or any other nadekobot folder open in some application, this might prevent some of the steps from executing succesfully
|
||||
2. Navigate to your bot's folder, example:
|
||||
- `cd ~/Desktop/nadekobot`
|
||||
3. Pull the new version
|
||||
- `git pull`
|
||||
3. Pull the new version, and make sure you're on the v5 branch
|
||||
- *⚠️ the first 3 lines can be omitted if you're already on v5. If you're updating from v4, you must run them*
|
||||
- `git remote set-branches origin '*'`
|
||||
- `git fetch -v --depth=1`
|
||||
- `git checkout v5`
|
||||
- `git pull`
|
||||
- ⚠️ If this fails, you may want to stash or remove your code changes if you don't know how to resolve merge conflicts
|
||||
4. **Backup** old output in case your data is overwritten
|
||||
- `cp -r -fo output/ output-old`
|
||||
5. Build the bot again
|
||||
- `dotnet publish -c Release -o output/ src/NadekoBot/`
|
||||
6. Remove old strings and aliases to avoid overwriting the updated versions of those files
|
||||
6. Remove old strings and aliases to avoid overwriting the updated versions of those files
|
||||
- ⚠ If you've modified said files, back them up instead
|
||||
- `rm output-old/data/aliases.yml`
|
||||
- `rm -r output-old/data/strings`
|
||||
@@ -111,25 +112,23 @@ Open PowerShell as described above and run the following commands:
|
||||
- `cp -Recurse .\output-old\data\ .\output\ -Force`
|
||||
8. Copy creds.yml
|
||||
- `cp output-old/creds.yml output/`
|
||||
9. Run the bot
|
||||
9. Run the bot
|
||||
- `cd output`
|
||||
- `dotnet NadekoBot.dll`
|
||||
|
||||
🎉 Enjoy
|
||||
|
||||
#### Music prerequisites
|
||||
In order to use music commands, you need ffmpeg and youtube-dl installed.
|
||||
#### Music prerequisites
|
||||
In order to use music commands, you need ffmpeg and yt-dlp installed.
|
||||
- [ffmpeg-32bit] | [ffmpeg-64bit] - Download the **appropriate version** for your system (32 bit if you're running a 32 bit OS, or 64 if you're running a 64bit OS). Unzip it, and move `ffmpeg.exe` to a path that's in your PATH environment variable. If you don't know what that is, just move the `ffmpeg.exe` file to `NadekoBot/output`.
|
||||
- [youtube-dl] - Click to download the file, then move `youtube-dl.exe` to a path that's in your PATH environment variable. If you don't know what that is, just move the `youtube-dl.exe` file to `NadekoBot/system`.
|
||||
- [youtube-dlp] - Click to download the `yt-dlp.exe` file, then move `yt-dlp.exe` to a path that's in your PATH environment variable. If you don't know what that is, just move the `yt-dlp.exe` file to `NadekoBot/system`.
|
||||
|
||||
[Updater]: https://dl.nadeko.bot/v3
|
||||
[Updater]: https://dl.nadeko.bot/v3/
|
||||
[Notepad++]: https://notepad-plus-plus.org/
|
||||
[.net]: https://dotnet.microsoft.com/download/dotnet/5.0
|
||||
[Redis]: https://github.com/MicrosoftArchive/redis/releases/download/win-3.0.504/Redis-x64-3.0.504.msi
|
||||
[Visual C++ 2010 (x86)]: https://download.microsoft.com/download/1/6/5/165255E7-1014-4D0A-B094-B6A430A6BFFC/vcredist_x86.exe
|
||||
[Visual C++ 2017 (x64)]: https://aka.ms/vs/15/release/vc_redist.x64.exe
|
||||
[SourceGuide]: ../from-source
|
||||
[ffmpeg-32bit]: https://cdn.nadeko.bot/dl/ffmpeg-32.zip
|
||||
[ffmpeg-64bit]: https://cdn.nadeko.bot/dl/ffmpeg-64.zip
|
||||
[youtube-dl]: https://yt-dl.org/downloads/latest/youtube-dl.exe
|
||||
|
||||
[youtube-dlp]: https://github.com/yt-dlp/yt-dlp/releases
|
||||
|
@@ -17,8 +17,6 @@ To self-host your own Nadeko, use the guides below:
|
||||
- [:material-linux: Linux guide][linux-guide]
|
||||
- [:material-apple: Mac OS guide][macos-guide]
|
||||
|
||||
Alternatively, you may also setup the bot [from source][from-source-guide] if you want to modify the code.
|
||||
|
||||
In case you need any help, join our [Discord server][discord-server] where we may provide support.
|
||||
|
||||
---
|
||||
@@ -38,6 +36,6 @@ If you're unsure whether something is an issue, ask in our support server first.
|
||||
[macos-guide]: ./guides/osx-guide.md
|
||||
[from-source-guide]: ./guides/from-source.md
|
||||
[discord-server]: https://discord.nadeko.bot/
|
||||
[gitlab]: https://gitlab.com/Kwoth/nadekobot
|
||||
[issues]: https://gitlab.com/Kwoth/nadekobot/issues
|
||||
[gitlab]: https://gitlab.com/kwoth/nadekobot
|
||||
[issues]: https://gitlab.com/kwoth/nadekobot/issues
|
||||
[donate]: ./donate.md
|
||||
|
@@ -8,8 +8,14 @@ This part is completely optional, **however it's necessary for music and a few o
|
||||
- Go to [Google Console][Google Console] and log in.
|
||||
- Create a new project (name does not matter).
|
||||
- Once the project is created, go into `Library`
|
||||
- Under the `YouTube APIs` section, enable `YouTube Data API`
|
||||
- On the left tab, access `Credentials`,
|
||||
- Under the `YouTube APIs` section
|
||||
- Select `YouTube Data API v3`,
|
||||
- Click enable.
|
||||
- Search for `Custom Search API`
|
||||
- Select `Custom Search API`,
|
||||
- Click enable.
|
||||
- Open up the `Navigation menu` on the top right with the three lines.
|
||||
- select `APIs & Services`, then select `Credentials`,
|
||||
- Click `Create Credentials` button,
|
||||
- Click on `API Key`
|
||||
- A new window will appear with your `Google API key`
|
||||
@@ -18,7 +24,7 @@ This part is completely optional, **however it's necessary for music and a few o
|
||||
- Open up `creds.yml` and look for `GoogleAPIKey`, paste your API key after the `:`.
|
||||
- It should look like this:
|
||||
```yml
|
||||
GoogleApiKey: "AIzaSyDSci1sdlWQOWNVj1vlXxxxxxbk0oWMEzM"
|
||||
GoogleApiKey: 'AIzaSyDSci1sdlWQOWNVj1vlXxxxxxbk0oWMEzM'
|
||||
```
|
||||
- **MashapeKey**
|
||||
- Required for Hearthstone cards.
|
||||
@@ -34,16 +40,19 @@ This part is completely optional, **however it's necessary for music and a few o
|
||||
- For Patreon creators only.
|
||||
- **PatreonCampaignId**
|
||||
- For Patreon creators only. Id of your campaign.
|
||||
- **TwitchClientId**
|
||||
- **TwitchClientId and TwitchClientSecret**
|
||||
- Mandatory for following twitch streams with `.twitch` (or `.stadd` with twitch link)
|
||||
- Go to [apps page](https://dev.twitch.tv/console/apps/create) on twitch and register your application.
|
||||
- Go to [apps page](https://dev.twitch.tv/console) on twitch and register your application.
|
||||
- You need 2FA enabled on twitch in order to create an application
|
||||
- You can set `http://localhost` as the OAuth Redirect URL (and press Add button)
|
||||
- Select `Chat Bot` from the Category dropdown
|
||||
- Once created, clicking on your application will show a new Client ID field
|
||||
- Copy it to your creds.yml as shown below
|
||||
- Once created, `click Manage`
|
||||
- Click `New Secret` and select `OK` in the popup
|
||||
**Note: You will need to generate a new Client Secret everytime you exit the page**
|
||||
- Copy both to your creds.yml as shown below
|
||||
```yml
|
||||
TwitchClientId: "516tr61tr1qweqwe86trg3g"
|
||||
twitchClientId: 516tr61tr1qweqwe86trg3g
|
||||
twitchClientSecret: 16tr61tr1q86tweqwe
|
||||
```
|
||||
- **LocationIqApiKey**
|
||||
- Optional. Used only for the `.time` command. https://locationiq.com api key (register and you will receive the token in the email).
|
||||
@@ -69,6 +78,7 @@ For Windows (Updater), add this to your `creds.yml`
|
||||
```yml
|
||||
RestartCommand:
|
||||
Cmd: "NadekoBot.exe"
|
||||
args: "{0}"
|
||||
```
|
||||
|
||||
For Windows (Source), Linux or OSX, add this to your `creds.yml`
|
||||
@@ -87,16 +97,15 @@ RestartCommand:
|
||||
|
||||
```yml
|
||||
# DO NOT CHANGE
|
||||
version: 1
|
||||
version: 4
|
||||
# Bot token. Do not share with anyone ever -> https://discordapp.com/developers/applications/
|
||||
token: 'MTE5Nzc3MDIxMzE5NTc3NjEw.VlhNCw.BuqJFyzdIUAK1PRf1eK1Cu89Jew'
|
||||
# List of Ids of the users who have bot owner permissions
|
||||
# **DO NOT ADD PEOPLE YOU DON'T TRUST**
|
||||
ownerIds: [
|
||||
105635123466156544,
|
||||
145521851676884992,
|
||||
341420590009417729
|
||||
]
|
||||
ownerIds:
|
||||
- 105635123466156544
|
||||
- 145521851676884992
|
||||
- 341420590009417729
|
||||
# The number of shards that the bot will running on.
|
||||
# Leave at 1 if you don't know what you're doing.
|
||||
totalShards: 1
|
||||
@@ -147,6 +156,13 @@ timezoneDbApiKey:
|
||||
coinmarketcapApiKey:
|
||||
# Api key used for Osu related commands. Obtain this key at https://osu.ppy.sh/p/api
|
||||
osuApiKey: 4c8c8fdffdsfdsfsdfsfa33f3f3140a7d93320d6
|
||||
# Optional Trovo client id.
|
||||
# You should use this if Trovo stream notifications stopped working or you're getting ratelimit errors.
|
||||
trovoClientId:
|
||||
# Obtain by creating an application at https://dev.twitch.tv/console/apps
|
||||
twitchClientId: jf2w6kkyrlzfl6mp1b4k25h4jr6b2o
|
||||
# Obtain by creating an application at https://dev.twitch.tv/console/apps
|
||||
twitchClientSecret: 16tr61tr1q86tweqwe
|
||||
# Command and args which will be used to restart the bot.
|
||||
# Only used if bot is executed directly (NOT through the coordinator)
|
||||
# placeholders:
|
||||
@@ -156,8 +172,8 @@ osuApiKey: 4c8c8fdffdsfdsfsdfsfa33f3f3140a7d93320d6
|
||||
# cmd: dotnet
|
||||
# args: "NadekoBot.dll -- {0}"
|
||||
# Windows default
|
||||
# cmd: NadekoBot.exe
|
||||
# args: {0}
|
||||
# cmd: "NadekoBot.exe"
|
||||
# args: "{0}"
|
||||
restartCommand:
|
||||
cmd:
|
||||
args:
|
||||
|
252
docs/medusa/creating-a-medusa.md
Normal file
252
docs/medusa/creating-a-medusa.md
Normal file
@@ -0,0 +1,252 @@
|
||||
# Creating A Medusa
|
||||
|
||||
## Theory
|
||||
|
||||
### Introduction
|
||||
|
||||
Medusa system allows you to write independent medusae (known as "modules", "cogs" or "plugins" in other software) which you can then load, unload and update at will without restarting the bot.
|
||||
|
||||
The system itself borrows some design from the current way Nadeko's Modules are written but mostly from never-released `Ayu.Commands` system which was designed to be used for a full Nadeko v3 rewrite.
|
||||
|
||||
The medusa base classes used for development are open source [here](https://gitlab.com/kwoth/nadekobot/-/tree/v5/src/Nadeko.Medusa) in case you need reference, as there is no generated documentation at the moment.
|
||||
|
||||
### Term list
|
||||
|
||||
#### Medusa
|
||||
|
||||
- The project itself which compiles to a single `.dll` (and some optional auxiliary files), it can contain multiple [Sneks](#snek), [Services](#service), and [ParamParsers](#param-parser)
|
||||
|
||||
#### Snek
|
||||
|
||||
- A class which will be added as a single Module to NadekoBot on load. It also acts as a [lifecycle handler](snek-lifecycle.md) and as a singleton service with the support for initialize and cleanup.
|
||||
- It can contain a Snek (called SubSnek) but only 1 level of nesting is supported (you can only have a snek contain a subsnek, but a subsnek can't contain any other sneks)
|
||||
- Sneks can have their own prefix
|
||||
- For example if you set this to 'test' then a command called 'cmd' will have to be invoked by using `.test cmd` instead of `.cmd`
|
||||
|
||||
#### Snek Command
|
||||
|
||||
- Acts as a normal command
|
||||
- Has context injected as a first argument which controls where the command can be executed
|
||||
- `AnyContext` the command can be executed in both DMs and Servers
|
||||
- `GuildContext` the command can only be executed in Servers
|
||||
- `DmContext` the command can only be executed in DMs
|
||||
- Support the usual features such as default values, leftover, params, etc.
|
||||
- It also supports dependency injection via `[inject]` attribute. These dependencies must come after the context and before any input parameters
|
||||
- Supports `ValueTask`, `Task`, `Task<T>` and `void` return types
|
||||
|
||||
#### Param Parser
|
||||
|
||||
- Allows custom parsing of command arguments into your own types.
|
||||
- Overriding existing parsers (for example for IGuildUser, etc...) can cause issues.
|
||||
|
||||
#### Service
|
||||
|
||||
- Usually not needed.
|
||||
- They are marked with a `[svc]` attribute, and offer a way to inject dependencies to different parts of your medusa.
|
||||
- Transient and Singleton lifetimes are supported.
|
||||
|
||||
### Localization
|
||||
|
||||
Response and command strings can be kept in one of three different places based on whether you plan to allow support for localization
|
||||
|
||||
option 1) `res.yml` and `cmds.yml`
|
||||
|
||||
If you don't plan on having your app localized, but you just *may* in the future, you should keep your strings in the `res.yml` and `cmds.yml` file the root folder of your project, and they will be automatically copied to the output whenever you build your medusa.
|
||||
|
||||
##### Example project folder structure:
|
||||
- uwu/
|
||||
- uwu.csproj
|
||||
- uwu.cs
|
||||
- res.yml
|
||||
- cmds.yml
|
||||
|
||||
##### Example output folder structure:
|
||||
- medusae/uwu/
|
||||
- uwu.dll
|
||||
- res.yml
|
||||
- cmds.yml
|
||||
|
||||
option 2) `strings` folder
|
||||
|
||||
If you plan on having your app localized (or want to allow your consumers to easily add languages themselves), you should keep your response strings in the `strings/res/en-us.yml` and your command strings in `strings/cmds/en-us.yml` file. This will be your base file, and from there you can make support for additional languages, for example `strings/res/ru-ru.yml` and `strings/cmds/ru-ru.yml`
|
||||
|
||||
##### Example project folder structure:
|
||||
- uwu/
|
||||
- uwu.csproj
|
||||
- uwu.cs
|
||||
- strings/
|
||||
- res/
|
||||
- en-us.yml
|
||||
- ru-ru.yml
|
||||
- cmds/
|
||||
- en-us.yml
|
||||
- ru-ru.yml
|
||||
|
||||
##### Example output folder structure:
|
||||
- medusae/uwu/
|
||||
- uwu.dll
|
||||
- strings/
|
||||
- res/
|
||||
- en-us.yml
|
||||
- ru-ru.yml
|
||||
- cmds/
|
||||
- en-us.yml
|
||||
- ru-ru.yml
|
||||
|
||||
option 3) In the code
|
||||
|
||||
If you don't want any auxiliary files, and you don't want to bother making new .yml files to keep your strings in, you can specify the command strings directly in the `[cmd]` attribute itself, and use non-localized methods for message sending in your commands.
|
||||
|
||||
If you update your response strings .yml file(s) while the medusa is loaded and running, running `.stringsreload` will reload the responses without the need to reload the medusa or restart the bot.
|
||||
|
||||
#### Config
|
||||
|
||||
- Medusa config is kept in `medusae/medusa.yml` file
|
||||
- At the moment this config only keeps track of which medusae are currently loaded (they will also be always loaded at startup)
|
||||
- If a medusa is causing issues and you're unable to unload it, you can remove it from the `loaded:` list in this config file and restart the bot. It won't be loaded next time the bot is started up
|
||||
|
||||
#### Unloadability issues
|
||||
|
||||
To make sure your medusa can be properly unloaded/reloaded you must:
|
||||
|
||||
- Make sure that none of your types and objects are referenced by the Bot or Bot's services after the DisposeAsync is called on your Snek instances.
|
||||
|
||||
- Make sure that all of your commands execute quickly and don't have any long running tasks, as they will hold a reference to a type from your assembly
|
||||
|
||||
- If you are still having issues, you can always run `.meunload` followed by a bot restart, or if you want to find what is causing the medusa unloadability issues, you can check the [microsoft's assembly unloadability debugging guide](https://docs.microsoft.com/en-us/dotnet/standard/assembly/unloadability)
|
||||
|
||||
## Practice
|
||||
|
||||
This section will guide you through how to create a simple custom medusa. You can find the entirety of this code hosted [here](https://gitlab.com/nadeko/example_medusa)
|
||||
|
||||
#### Prerequisite
|
||||
- [.net6 sdk](https://dotnet.microsoft.com/en-us/download) installed
|
||||
- Optional: use [vscode](https://code.visualstudio.com/download) to write code
|
||||
|
||||
#### Guide
|
||||
|
||||
|
||||
- Open your favorite terminal and navigate to a folder where you will keep your project .
|
||||
|
||||
- Create a new folder
|
||||
- `mkdir example_medusa`
|
||||
- Create a new .net class library
|
||||
- `dotnet new classlib`
|
||||
- Open the current folder with your favorite editor/IDE. In this case we'll use VsCode
|
||||
- `code .`
|
||||
- Remove the `Class1.cs` file
|
||||
- Replace the contents of the `.csproj` file with the following contents
|
||||
```xml
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
|
||||
<!-- Reduces some boilerplate in your .cs files -->
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
|
||||
<!-- Use latest .net features -->
|
||||
<LangVersion>preview</LangVersion>
|
||||
<EnablePreviewFeatures>true</EnablePreviewFeatures>
|
||||
<GenerateRequiresPreviewFeaturesAttribute>true</GenerateRequiresPreviewFeaturesAttribute>
|
||||
|
||||
<!-- tell .net that this library will be used as a plugin -->
|
||||
<EnableDynamicLoading>true</EnableDynamicLoading>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<!-- Base medusa package. You MUST reference this in order to have a working medusa -->
|
||||
<!-- Also, this package comes from MyGet, which requires you to have a NuGet.Config file next to your .csproj -->
|
||||
<PackageReference Include="Nadeko.Medusa" Version="4.3.9">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
|
||||
<!-- Note: If you want to use NadekoBot services etc... You will have to manually clone
|
||||
the https://gitlab.com/kwoth/nadekobot repo locally and reference the NadekoBot.csproj because there is no NadekoBot package atm.
|
||||
It is strongly recommended that you checkout a specific tag which matches your version of nadeko,
|
||||
as there could be breaking changes even between minor versions of NadekoBot.
|
||||
For example if you're running NadekoBot 4.1.0 locally for which you want to create a medusa for,
|
||||
you should do "git checkout 4.1.0" in your NadekoBot solution and then reference the NadekoBot.csproj
|
||||
-->
|
||||
</ItemGroup>
|
||||
|
||||
<!-- Copy shortcut and full strings to output (if they exist) -->
|
||||
<ItemGroup>
|
||||
<None Update="res.yml;cmds.yml;strings/**">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
```
|
||||
- Create a `MySnek.cs` file and add the following contents
|
||||
```cs
|
||||
using Nadeko.Snake;
|
||||
using NadekoBot;
|
||||
using Discord;
|
||||
|
||||
public sealed class MySnek : Snek
|
||||
{
|
||||
[cmd]
|
||||
public async Task Hello(AnyContext ctx)
|
||||
{
|
||||
await ctx.Channel.SendMessageAsync($"Hello everyone!");
|
||||
}
|
||||
|
||||
[cmd]
|
||||
public async Task Hello(AnyContext ctx, IUser target)
|
||||
{
|
||||
await ctx.ConfirmLocalizedAsync("hello", target);
|
||||
}
|
||||
}
|
||||
```
|
||||
- Create `res.yml` and `cmds.yml` files with the following contents
|
||||
`res.yml`
|
||||
```yml
|
||||
medusa.description: "This is my medusa's description"
|
||||
hello: "Hello {0}, from res.yml!"
|
||||
```
|
||||
|
||||
`cmds.yml`
|
||||
```yml
|
||||
hello:
|
||||
desc: "This is a basic hello command"
|
||||
args:
|
||||
- ""
|
||||
- "@Someone"
|
||||
```
|
||||
|
||||
- Add `NuGet.Config` file which will let you use the base Nadeko.Medusa package. This file should always look like this and you shouldn't change it
|
||||
|
||||
```xml
|
||||
<configuration>
|
||||
<packageSources>
|
||||
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
|
||||
<add key="nadeko.bot" value="https://www.myget.org/F/nadeko/api/v3/index.json" protocolVersion="3" />
|
||||
</packageSources>
|
||||
</configuration>
|
||||
```
|
||||
|
||||
### Build it
|
||||
|
||||
- Build your Medusa into a dll that Nadeko can load. In your terminal, type:
|
||||
- `dotnet publish -o bin/medusae/example_medusa /p:DebugType=embedded`
|
||||
|
||||
- Done. You can now try it out in action.
|
||||
|
||||
### Try it out
|
||||
|
||||
- Copy the `bin/medusae/example_medusa` folder into your NadekoBot's `data/medusae/` folder. (Nadeko version 4.1.0+)
|
||||
|
||||
- Load it with `.meload example_medusa`
|
||||
|
||||
- In the channel your bot can see, run the following commands to try it out
|
||||
- `.hello` and
|
||||
- `.hello @<someone>`
|
||||
|
||||
- Check its information with
|
||||
- `.meinfo example_medusa`
|
||||
|
||||
- Unload it
|
||||
- `.meunload example_medusa`
|
||||
|
||||
- Congrats! You've just made your first medusa!
|
31
docs/medusa/getting-started.md
Normal file
31
docs/medusa/getting-started.md
Normal file
@@ -0,0 +1,31 @@
|
||||
## Getting Started
|
||||
|
||||
### What is the Medusa system?
|
||||
|
||||
- It is a dynamic module/plugin/cog system for NadekoBot introduced in **NadekoBot 4.1.0**
|
||||
|
||||
- Allows developers to add custom functionality to Nadeko without modifying the original code
|
||||
|
||||
- Allows for those custom features to be updated during bot runtime (if properly written), without the need for bot restart.
|
||||
|
||||
- They are added to `data/medusae` folder and are loaded, unloaded and handled through discord commands.
|
||||
- `.meload` Loads the specified medusa (see `.h .meload`)
|
||||
- `.meunload` Unloads the specified medusa (see `.h .meunload`)
|
||||
- `.meinfo` Checks medusae information (see `.h .meinfo`)
|
||||
- `.melist` Lists the available medusae (see `.h .melist`)
|
||||
|
||||
### How to make one?
|
||||
|
||||
Medusae are written in [C#](https://docs.microsoft.com/en-us/dotnet/csharp/tour-of-csharp/) programming language, so you will need at least low-intermediate knowledge of it in order to make a useful Medusa.
|
||||
|
||||
Follow the [creating a medusa guide](creating-a-medusa.md)
|
||||
|
||||
### Where to get medusae other people made?
|
||||
|
||||
⚠ *It is EXTREMELY, and I repeat **EXTREMELY** dangerous to run medusae of strangers or people you don't FULLY trust.* ⚠
|
||||
⚠ *It can not only lead to your bot being stolen, but it also puts your entire computer and personal files in jeopardy.* ⚠
|
||||
|
||||
**It is strongly recommended to run only the medusae you yourself wrote, and only on a hosted VPS or dedicated server which ONLY hosts your bot, to minimize the potential damage caused by bad actors.**
|
||||
|
||||
No easy way at the moment, except asking in the `#dev-and-modding` chat in [#NadekoLog server](https://discord.nadeko.bot)
|
||||
|
19
docs/medusa/snek-lifecycle.md
Normal file
19
docs/medusa/snek-lifecycle.md
Normal file
@@ -0,0 +1,19 @@
|
||||
# Snek Lifecycle
|
||||
|
||||
*You can override several methods to hook into command handler's lifecycle.
|
||||
These methods start with `Exec*`*
|
||||
|
||||
|
||||
- `ExecOnMessageAsync` runs first right after any message was received
|
||||
- `ExecInputTransformAsync` runs after ExecOnMessageAsync and allows you to transform the message content before the bot looks for the matching command
|
||||
- `ExecPreCommandAsync` runs after a command was found but not executed, allowing you to potentially prevent command execution
|
||||
- `ExecPostCommandAsync` runs if the command was successfully executed
|
||||
- `ExecOnNoCommandAsync` runs instead of ExecPostCommandAsync if no command was found for a message
|
||||
|
||||
|
||||
*Besides that, sneks have 2 methods with which you can initialize and cleanup your snek*
|
||||
|
||||
|
||||
- `InitializeAsync` Runs when the medusa which contains this snek is being loaded
|
||||
- `DisposeAsync` Runs when the medusa which contains this snek is being unloaded
|
||||
|
@@ -8,7 +8,7 @@ Permissions are very handy at setting who can use what commands in a server. All
|
||||
|
||||
Several commands still require that you have the correct permissions on Discord to be able to use them, so for users to be able to use commands like `.kick` and `.voicemute`, they need **Kick** and **Mute Members** server permissions, respectively.
|
||||
|
||||
With the permissions system it possible to restrict who can skip the current song, pick NadekoFlowers or use the NSFW module.
|
||||
With the permissions system it possible to restrict who can skip the current song.
|
||||
|
||||
## First Time Setup
|
||||
|
||||
@@ -64,23 +64,14 @@ To allow users to only see the current song and have a DJ role for queuing follo
|
||||
4. `.rm Music enable DJ`
|
||||
- Enables all music commands only for the DJ role
|
||||
|
||||
#### How do I create a NSFW role?
|
||||
#### How do I disable Expressions from triggering?
|
||||
|
||||
Say you want to only enable NSFW commands for a specific role, just do the following two steps.
|
||||
If you don't want server or global Expressions, just block the module that controls their usage:
|
||||
|
||||
1. `.sm NSFW disable`
|
||||
- Disables the NSFW module from being used
|
||||
2. `.rm NSFW enable Lewd`
|
||||
- Enables usage of the NSFW module for the Lewd role
|
||||
1. `.sm ActualExpressions disable`
|
||||
- Disables the ActualExpression module from being used
|
||||
|
||||
#### How do I disable custom reactions from triggering?
|
||||
|
||||
If you don't want server or global custom reactions, just block the module that controls their usage:
|
||||
|
||||
1. `.sm ActualCustomReactions disable`
|
||||
- Disables the ActualCustomReactions module from being used
|
||||
|
||||
**Note**: The `ActualCustomReactions` module controls the usage of custom reactions. The `CustomReactions` module controls commands related to custom reactions (such as `.acr`, `.lcr`, `.crca`, etc).
|
||||
**Note**: The `Expressions` module controls the usage of Expressions. The `Expressions` module controls commands related to Expressions (such as `.acr`, `.lcr`, `.crca`, etc).
|
||||
|
||||
#### I've broken permissions and am stuck, can I reset permissions?
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
# Placeholders
|
||||
|
||||
Placeholders are used in Quotes, Custom Reactions, Greet/Bye messages, playing statuses, and a few other places.
|
||||
Placeholders are used in Quotes, Expressions, Greet/Bye messages, playing statuses, and a few other places.
|
||||
|
||||
They can be used to make the message more user friendly, generate random numbers or pictures, etc.
|
||||
|
||||
@@ -28,6 +28,8 @@ Some features have their own specific placeholders which are noted in that featu
|
||||
- `%server.id%` - Server ID
|
||||
- `%server.name%` - Server name
|
||||
- `%server.members%` - Member count
|
||||
- `%server.boosters%` - Number of users boosting the server
|
||||
- `%server.boost_level%` - Server Boost level
|
||||
- `%server.time%` - Server time (requires `.timezone` to be set)
|
||||
|
||||
### Channel placeholders
|
||||
@@ -36,7 +38,7 @@ Some features have their own specific placeholders which are noted in that featu
|
||||
- `%channel.name%` - Channel name
|
||||
- `%channel.id%` - Channel ID
|
||||
- `%channel.created%` - Channel creation date
|
||||
- `%channel.nsfw%` - Returns either `True` or `False`, depending on if the channel is designated as NSFW using discord
|
||||
- `%channel.nsfw%` - Returns either `True` or `False`, depending on if the channel is designated as age-restricted in discord
|
||||
- `%channel.topic%` - Channel topic
|
||||
|
||||
### User placeholders
|
||||
@@ -66,12 +68,7 @@ Some features have their own specific placeholders which are noted in that featu
|
||||
- `%ban.reason%` - Reason for the ban, if provided
|
||||
- `%ban.duration%` - Duration of the ban in the form Days.Hours:Minutes (6.05:04)
|
||||
|
||||
### Bot stats placeholders
|
||||
|
||||
- `%servers%` - Server count bot has joined
|
||||
- `%users%` - Combined user count on servers the bot has joined
|
||||
|
||||
### Shard stats placeholders
|
||||
### Shard stats placeholders
|
||||
|
||||
- `%shard.servercount%` - Server count on current shard
|
||||
- `%shard.usercount%` - Combined user count on current shard
|
||||
@@ -79,16 +76,13 @@ Some features have their own specific placeholders which are noted in that featu
|
||||
|
||||
### Music placeholders
|
||||
|
||||
!!! Note
|
||||
These placeholders will only work in rotating playing statuses.
|
||||
|
||||
- `%music.queued%` - Amount of songs currently queued
|
||||
- `%music.playing%` - Current song name
|
||||
- `%music.queued%` - Number of songs currently queued
|
||||
- `%music.playing%` - Current song name (random playing song if bot is playing on multiple servers)
|
||||
- `%music.servers%` - Number of servers currently listening to music
|
||||
|
||||
### Miscellaneous placeholders
|
||||
|
||||
- `%rngX-Y%` - Returns a random number between X and Y
|
||||
- `%target%` - Returns anything the user has written after the trigger (only works on custom reactions)
|
||||
- `%img:stuff%` - Returns an `imgur.com` search for "stuff" (only works on custom reactions)
|
||||
- `%target%` - Returns anything the user has written after the trigger (only works on Expressions)
|
||||
|
||||

|
||||
|
@@ -1,7 +1,7 @@
|
||||
#define sysfolder "system"
|
||||
#define version GetEnv("NADEKOBOT_INSTALL_VERSION")
|
||||
#define target "win7-x64"
|
||||
#define platform "net5.0"
|
||||
#define target "win-x64"
|
||||
#define platform "net8.0"
|
||||
|
||||
[Setup]
|
||||
AppName = {param:botname|NadekoBot}
|
||||
|
10
migrate.ps1
Normal file
10
migrate.ps1
Normal file
@@ -0,0 +1,10 @@
|
||||
if ($args.Length -eq 0) {
|
||||
Write-Host "Please provide a migration name." -ForegroundColor Red
|
||||
}
|
||||
else {
|
||||
$migrationName = $args[0]
|
||||
dotnet ef migrations add $migrationName -c SqliteContext -p src/NadekoBot/NadekoBot.csproj
|
||||
dotnet ef migrations add $migrationName -c PostgreSqlContext -p src/NadekoBot/NadekoBot.csproj
|
||||
dotnet ef migrations add $migrationName -c MysqlContext -p src/NadekoBot/NadekoBot.csproj
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
site_name: 'NadekoBot'
|
||||
site_url: 'https://nadeko.bot'
|
||||
repo_url: 'https://gitlab.com/kwoth/nadekobot'
|
||||
repo_url: 'https://gitlab.com/nadeko/nadekobot'
|
||||
site_author: 'Kwoth'
|
||||
|
||||
theme:
|
||||
@@ -72,7 +72,6 @@ markdown_extensions:
|
||||
nav:
|
||||
- Home: index.md
|
||||
- Guides:
|
||||
- ❗ Migration Guide: guides/migration-guide.md
|
||||
- Windows Guide: guides/windows-guide.md
|
||||
- Linux Guide: guides/linux-guide.md
|
||||
- OSX Guide: guides/osx-guide.md
|
||||
@@ -87,7 +86,9 @@ nav:
|
||||
- Custom Reactions: custom-reactions.md
|
||||
- Placeholders: placeholders.md
|
||||
- Config: config-guide.md
|
||||
- Bot Config: bce-guide.md
|
||||
- Medusa System:
|
||||
- medusa/getting-started.md
|
||||
- medusa/creating-a-medusa.md
|
||||
- medusa/snek-lifecycle.md
|
||||
- Contribution Guide: contribution-guide.md
|
||||
- Donate: donate.md
|
||||
- License: license.md
|
||||
|
11
privacy-policy.md
Normal file
11
privacy-policy.md
Normal file
@@ -0,0 +1,11 @@
|
||||
# Privacy Policy
|
||||
|
||||
## Profile Information
|
||||
Nadeko stores userids, avatars, usernames, discriminators and nicknames of users who were targeted by or have used commands which require Xp, Clubs or Waifu features (not limited to these, as other features may be added over time).
|
||||
|
||||
## Other
|
||||
Nadeko doesn't do analytics, doesn't store messages, doesn't track users, doesn't store their emails etc.
|
||||
Nadeko only stores user settings and states as the result of executed commands or as the effect of administration tools (for example warnings or protection commands).
|
||||
|
||||
## Sensitive Information
|
||||
Nadeko doesn't store sensitive information, and users are strongly discouraged from adding their passwords, keys, or other important information as quotes or expressions.
|
63
release.ps1
63
release.ps1
@@ -1,63 +0,0 @@
|
||||
function Get-Changelog($lastTag)
|
||||
{
|
||||
if(!$lastTag)
|
||||
{
|
||||
$lastTag = git describe --tags --abbrev=0
|
||||
}
|
||||
|
||||
$tag = "$lastTag..HEAD"
|
||||
|
||||
$clArr = (git log $tag --oneline)
|
||||
[array]::Reverse($clArr)
|
||||
$changelog = $clArr | where { "$_" -notlike "*(POEditor.com)*" -and "$_" -notlike "*Merge branch*" -and "$_" -notlike "*Merge pull request*" -and "$_" -notlike "^-*" -and "$_" -notlike "*Merge remote tracking*" }
|
||||
$changelog = [string]::join([Environment]::NewLine, $changelog)
|
||||
|
||||
$cl2 = $clArr | where { "$_" -like "*Merge pull request*" }
|
||||
$changelog = "## Changes$nl$changelog"
|
||||
if ($null -ne $cl2) {
|
||||
$cl2 = [string]::join([Environment]::NewLine, $cl2)
|
||||
$changelog = $changelog + "$nl ## Pull Requests Merged$nl$cl2"
|
||||
}
|
||||
|
||||
return $changelog
|
||||
}
|
||||
|
||||
function Build-Installer($versionNumber)
|
||||
{
|
||||
$env:NADEKOBOT_INSTALL_VERSION = $versionNumber
|
||||
|
||||
dotnet clean
|
||||
# rm -r -fo "src\NadekoBot\bin"
|
||||
dotnet publish -c Release --runtime win7-x64 /p:Version=$versionNumber src/NadekoBot
|
||||
# .\rcedit-x64.exe "src\NadekoBot\bin\Release\netcoreapp2.1\win7-x64\nadekobot.exe" --set-icon "src\NadekoBot\bin\Release\netcoreapp2.1\win7-x64\nadeko_icon.ico"
|
||||
|
||||
& "iscc.exe" "/O+" ".\exe_builder.iss"
|
||||
|
||||
Write-ReleaseFile($versionNumber)
|
||||
# $path = [Environment]::GetFolderPath('MyDocuments') + "\_projekti\new_installer\$versionNumber\";
|
||||
# $binPath = $path + "nadeko-setup-$versionNumber.exe";
|
||||
# Copy-Item -Path $path -Destination $dest -Force -ErrorAction Stop
|
||||
|
||||
# return $path
|
||||
}
|
||||
|
||||
function Write-ReleaseFile($versionNumber) {
|
||||
$changelog = ""
|
||||
# pull the changes if they exist
|
||||
# git pull
|
||||
# attempt to build teh installer
|
||||
# $path = Build-Installer $versionNumber
|
||||
|
||||
# get changelog before tagging
|
||||
$changelog = Get-Changelog
|
||||
# tag the release
|
||||
# & (git tag, $tag)
|
||||
|
||||
# print out the changelog to the console
|
||||
# Write-Host $changelog
|
||||
|
||||
$jsonReleaseFile = "[{""VersionName"": ""$versionNumber"", ""DownloadLink"": ""https://cdn.nadeko.bot/dl/bot/nadeko-setup-$versionNumber.exe"", ""Changelog"": """"}]"
|
||||
|
||||
$releaseJsonOutPath = [Environment]::GetFolderPath('MyDocuments') + "\_projekti\nadeko-installers\$versionNumber\"
|
||||
New-Item -Path $releaseJsonOutPath -Value $jsonReleaseFile -Name "releases.json" -Force
|
||||
}
|
@@ -1 +0,0 @@
|
||||
[{ "VersionName":"_VERSION_", "DownloadLink":"https://cdn.nadeko.bot/dl/bot/_INSTALLER_FILE_NAME_" }]
|
4
remove-migration.ps1
Normal file
4
remove-migration.ps1
Normal file
@@ -0,0 +1,4 @@
|
||||
dotnet ef migrations remove -c SqliteContext -f
|
||||
dotnet ef migrations remove -c PostgreSqlContext -f
|
||||
dotnet ef migrations remove -c MysqlContext -f
|
||||
|
10
src/Nadeko.Medusa/Attributes/FilterAttribute.cs
Normal file
10
src/Nadeko.Medusa/Attributes/FilterAttribute.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace NadekoBot.Medusa;
|
||||
|
||||
/// <summary>
|
||||
/// Overridden to implement custom checks which commands have to pass in order to be executed.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, AllowMultiple = true)]
|
||||
public abstract class FilterAttribute : Attribute
|
||||
{
|
||||
public abstract ValueTask<bool> CheckAsync(AnyContext ctx);
|
||||
}
|
10
src/Nadeko.Medusa/Attributes/MedusaPermAttribute.cs
Normal file
10
src/Nadeko.Medusa/Attributes/MedusaPermAttribute.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace NadekoBot.Medusa;
|
||||
|
||||
/// <summary>
|
||||
/// Used as a marker class for bot_perm and user_perm Attributes
|
||||
/// Has no functionality.
|
||||
/// </summary>
|
||||
public abstract class MedusaPermAttribute : Attribute
|
||||
{
|
||||
|
||||
}
|
7
src/Nadeko.Medusa/Attributes/bot_owner_onlyAttribute.cs
Normal file
7
src/Nadeko.Medusa/Attributes/bot_owner_onlyAttribute.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace NadekoBot.Medusa;
|
||||
|
||||
[AttributeUsage(AttributeTargets.Method)]
|
||||
public sealed class bot_owner_onlyAttribute : MedusaPermAttribute
|
||||
{
|
||||
|
||||
}
|
23
src/Nadeko.Medusa/Attributes/bot_permAttribute.cs
Normal file
23
src/Nadeko.Medusa/Attributes/bot_permAttribute.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using Discord;
|
||||
|
||||
namespace NadekoBot.Medusa;
|
||||
|
||||
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
|
||||
public sealed class bot_permAttribute : MedusaPermAttribute
|
||||
{
|
||||
public GuildPermission? GuildPerm { get; }
|
||||
public ChannelPermission? ChannelPerm { get; }
|
||||
|
||||
|
||||
public bot_permAttribute(GuildPermission perm)
|
||||
{
|
||||
GuildPerm = perm;
|
||||
ChannelPerm = null;
|
||||
}
|
||||
|
||||
public bot_permAttribute(ChannelPermission perm)
|
||||
{
|
||||
ChannelPerm = perm;
|
||||
GuildPerm = null;
|
||||
}
|
||||
}
|
37
src/Nadeko.Medusa/Attributes/cmdAttribute.cs
Normal file
37
src/Nadeko.Medusa/Attributes/cmdAttribute.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
namespace NadekoBot.Medusa;
|
||||
|
||||
/// <summary>
|
||||
/// Marks a method as a snek command
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Method)]
|
||||
public class cmdAttribute : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Command description. Avoid using, as cmds.yml is preferred
|
||||
/// </summary>
|
||||
public string? desc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Command args examples. Avoid using, as cmds.yml is preferred
|
||||
/// </summary>
|
||||
public string[]? args { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Command aliases
|
||||
/// </summary>
|
||||
public string[] Aliases { get; }
|
||||
|
||||
public cmdAttribute()
|
||||
{
|
||||
desc = null;
|
||||
args = null;
|
||||
Aliases = Array.Empty<string>();
|
||||
}
|
||||
|
||||
public cmdAttribute(params string[] aliases)
|
||||
{
|
||||
Aliases = aliases;
|
||||
desc = null;
|
||||
args = null;
|
||||
}
|
||||
}
|
10
src/Nadeko.Medusa/Attributes/injectAttribute.cs
Normal file
10
src/Nadeko.Medusa/Attributes/injectAttribute.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace NadekoBot.Medusa;
|
||||
|
||||
/// <summary>
|
||||
/// Marks services in command arguments for injection.
|
||||
/// The injected services must come after the context and before any input parameters.
|
||||
/// </summary>
|
||||
public class injectAttribute : Attribute
|
||||
{
|
||||
|
||||
}
|
10
src/Nadeko.Medusa/Attributes/leftoverAttribute.cs
Normal file
10
src/Nadeko.Medusa/Attributes/leftoverAttribute.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace NadekoBot.Medusa;
|
||||
|
||||
/// <summary>
|
||||
/// Marks the parameter to take
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Parameter)]
|
||||
public class leftoverAttribute : Attribute
|
||||
{
|
||||
|
||||
}
|
20
src/Nadeko.Medusa/Attributes/prioAttribute.cs
Normal file
20
src/Nadeko.Medusa/Attributes/prioAttribute.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
namespace NadekoBot.Medusa;
|
||||
|
||||
/// <summary>
|
||||
/// Sets the priority of a command in case there are multiple commands with the same name but different parameters.
|
||||
/// Higher value means higher priority.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Method)]
|
||||
public class prioAttribute : Attribute
|
||||
{
|
||||
public int Priority { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Snek command priority
|
||||
/// </summary>
|
||||
/// <param name="priority">Priority value. The higher the value, the higher the priority</param>
|
||||
public prioAttribute(int priority)
|
||||
{
|
||||
Priority = priority;
|
||||
}
|
||||
}
|
23
src/Nadeko.Medusa/Attributes/svcAttribute.cs
Normal file
23
src/Nadeko.Medusa/Attributes/svcAttribute.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
namespace NadekoBot.Medusa;
|
||||
|
||||
/// <summary>
|
||||
/// Marks the class as a service which can be used within the same Medusa
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
public class svcAttribute : Attribute
|
||||
{
|
||||
public Lifetime Lifetime { get; }
|
||||
public svcAttribute(Lifetime lifetime)
|
||||
{
|
||||
Lifetime = lifetime;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Lifetime for <see cref="svcAttribute"/>
|
||||
/// </summary>
|
||||
public enum Lifetime
|
||||
{
|
||||
Singleton,
|
||||
Transient
|
||||
}
|
22
src/Nadeko.Medusa/Attributes/user_permAttribute.cs
Normal file
22
src/Nadeko.Medusa/Attributes/user_permAttribute.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using Discord;
|
||||
|
||||
namespace NadekoBot.Medusa;
|
||||
|
||||
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
|
||||
public sealed class user_permAttribute : MedusaPermAttribute
|
||||
{
|
||||
public GuildPermission? GuildPerm { get; }
|
||||
public ChannelPermission? ChannelPerm { get; }
|
||||
|
||||
public user_permAttribute(GuildPermission perm)
|
||||
{
|
||||
GuildPerm = perm;
|
||||
ChannelPerm = null;
|
||||
}
|
||||
|
||||
public user_permAttribute(ChannelPermission perm)
|
||||
{
|
||||
ChannelPerm = perm;
|
||||
GuildPerm = null;
|
||||
}
|
||||
}
|
43
src/Nadeko.Medusa/Context/AnyContext.cs
Normal file
43
src/Nadeko.Medusa/Context/AnyContext.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using Discord;
|
||||
using NadekoBot;
|
||||
|
||||
namespace NadekoBot.Medusa;
|
||||
|
||||
/// <summary>
|
||||
/// Commands which take this class as a first parameter can be executed in both DMs and Servers
|
||||
/// </summary>
|
||||
public abstract class AnyContext
|
||||
{
|
||||
/// <summary>
|
||||
/// Channel from the which the command is invoked
|
||||
/// </summary>
|
||||
public abstract IMessageChannel Channel { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Message which triggered the command
|
||||
/// </summary>
|
||||
public abstract IUserMessage Message { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The user who invoked the command
|
||||
/// </summary>
|
||||
public abstract IUser User { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Bot user
|
||||
/// </summary>
|
||||
public abstract ISelfUser Bot { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Provides access to strings used by this medusa
|
||||
/// </summary>
|
||||
public abstract IMedusaStrings Strings { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a formatted localized string using a key and arguments which should be formatted in
|
||||
/// </summary>
|
||||
/// <param name="key">The key of the string as specified in localization files</param>
|
||||
/// <param name="args">Arguments (if any) to format in</param>
|
||||
/// <returns>A formatted localized string</returns>
|
||||
public abstract string GetText(string key, object[]? args = null);
|
||||
}
|
11
src/Nadeko.Medusa/Context/DmContext.cs
Normal file
11
src/Nadeko.Medusa/Context/DmContext.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using Discord;
|
||||
|
||||
namespace NadekoBot.Medusa;
|
||||
|
||||
/// <summary>
|
||||
/// Commands which take this type as the first parameter can only be executed in DMs
|
||||
/// </summary>
|
||||
public abstract class DmContext : AnyContext
|
||||
{
|
||||
public abstract override IDMChannel Channel { get; }
|
||||
}
|
12
src/Nadeko.Medusa/Context/GuildContext.cs
Normal file
12
src/Nadeko.Medusa/Context/GuildContext.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using Discord;
|
||||
|
||||
namespace NadekoBot.Medusa;
|
||||
|
||||
/// <summary>
|
||||
/// Commands which take this type as a first parameter can only be executed in a server
|
||||
/// </summary>
|
||||
public abstract class GuildContext : AnyContext
|
||||
{
|
||||
public abstract override ITextChannel Channel { get; }
|
||||
public abstract IGuild Guild { get; }
|
||||
}
|
8
src/Nadeko.Medusa/EmbedColor.cs
Normal file
8
src/Nadeko.Medusa/EmbedColor.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace NadekoBot;
|
||||
|
||||
public enum EmbedColor
|
||||
{
|
||||
Ok,
|
||||
Pending,
|
||||
Error
|
||||
}
|
61
src/Nadeko.Medusa/Extensions/MedusaExtensions.cs
Normal file
61
src/Nadeko.Medusa/Extensions/MedusaExtensions.cs
Normal file
@@ -0,0 +1,61 @@
|
||||
using Discord;
|
||||
|
||||
namespace NadekoBot.Medusa;
|
||||
|
||||
public static class MedusaExtensions
|
||||
{
|
||||
public static Task<IUserMessage> EmbedAsync(this IMessageChannel ch, EmbedBuilder embed, string msg = "")
|
||||
=> ch.SendMessageAsync(msg,
|
||||
embed: embed.Build(),
|
||||
options: new()
|
||||
{
|
||||
RetryMode = RetryMode.Retry502
|
||||
});
|
||||
|
||||
// unlocalized
|
||||
public static Task<IUserMessage> SendConfirmAsync(this AnyContext ctx, string msg)
|
||||
=> ctx.Channel.EmbedAsync(new EmbedBuilder()
|
||||
.WithColor(0, 200, 0)
|
||||
.WithDescription(msg));
|
||||
|
||||
public static Task<IUserMessage> SendPendingAsync(this AnyContext ctx, string msg)
|
||||
=> ctx.Channel.EmbedAsync(new EmbedBuilder()
|
||||
.WithColor(200, 200, 0)
|
||||
.WithDescription(msg));
|
||||
|
||||
public static Task<IUserMessage> SendErrorAsync(this AnyContext ctx, string msg)
|
||||
=> ctx.Channel.EmbedAsync(new EmbedBuilder()
|
||||
.WithColor(200, 0, 0)
|
||||
.WithDescription(msg));
|
||||
|
||||
// localized
|
||||
public static Task ConfirmAsync(this AnyContext ctx)
|
||||
=> ctx.Message.AddReactionAsync(new Emoji("✅"));
|
||||
|
||||
public static Task ErrorAsync(this AnyContext ctx)
|
||||
=> ctx.Message.AddReactionAsync(new Emoji("❌"));
|
||||
|
||||
public static Task WarningAsync(this AnyContext ctx)
|
||||
=> ctx.Message.AddReactionAsync(new Emoji("⚠️"));
|
||||
|
||||
public static Task WaitAsync(this AnyContext ctx)
|
||||
=> ctx.Message.AddReactionAsync(new Emoji("🤔"));
|
||||
|
||||
public static Task<IUserMessage> ErrorLocalizedAsync(this AnyContext ctx, string key, params object[]? args)
|
||||
=> ctx.SendErrorAsync(ctx.GetText(key, args));
|
||||
|
||||
public static Task<IUserMessage> PendingLocalizedAsync(this AnyContext ctx, string key, params object[]? args)
|
||||
=> ctx.SendPendingAsync(ctx.GetText(key, args));
|
||||
|
||||
public static Task<IUserMessage> ConfirmLocalizedAsync(this AnyContext ctx, string key, params object[]? args)
|
||||
=> ctx.SendConfirmAsync(ctx.GetText(key, args));
|
||||
|
||||
public static Task<IUserMessage> ReplyErrorLocalizedAsync(this AnyContext ctx, string key, params object[]? args)
|
||||
=> ctx.SendErrorAsync($"{Format.Bold(ctx.User.ToString())} {ctx.GetText(key, args)}");
|
||||
|
||||
public static Task<IUserMessage> ReplyPendingLocalizedAsync(this AnyContext ctx, string key, params object[]? args)
|
||||
=> ctx.SendPendingAsync($"{Format.Bold(ctx.User.ToString())} {ctx.GetText(key, args)}");
|
||||
|
||||
public static Task<IUserMessage> ReplyConfirmLocalizedAsync(this AnyContext ctx, string key, params object[]? args)
|
||||
=> ctx.SendConfirmAsync($"{Format.Bold(ctx.User.ToString())} {ctx.GetText(key, args)}");
|
||||
}
|
20
src/Nadeko.Medusa/Nadeko.Medusa.csproj
Normal file
20
src/Nadeko.Medusa/Nadeko.Medusa.csproj
Normal file
@@ -0,0 +1,20 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
|
||||
<Authors>The NadekoBot Team</Authors>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Discord.Net.Core" Version="3.204.0" />
|
||||
<PackageReference Include="Serilog" Version="3.1.1" />
|
||||
<PackageReference Include="YamlDotNet" Version="15.1.4" />
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(Version)' == '' ">
|
||||
<Version>9.0.0</Version>
|
||||
</PropertyGroup>
|
||||
</Project>
|
16
src/Nadeko.Medusa/ParamParser/ParamParser.cs
Normal file
16
src/Nadeko.Medusa/ParamParser/ParamParser.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
namespace NadekoBot.Medusa;
|
||||
|
||||
/// <summary>
|
||||
/// Overridden to implement parsers for custom types
|
||||
/// </summary>
|
||||
/// <typeparam name="T">Type into which to parse the input</typeparam>
|
||||
public abstract class ParamParser<T>
|
||||
{
|
||||
/// <summary>
|
||||
/// Overridden to implement parsing logic
|
||||
/// </summary>
|
||||
/// <param name="ctx">Context</param>
|
||||
/// <param name="input">Input to parse</param>
|
||||
/// <returns>A <see cref="ParseResult{T}"/> with successful or failed status</returns>
|
||||
public abstract ValueTask<ParseResult<T>> TryParseAsync(AnyContext ctx, string input);
|
||||
}
|
48
src/Nadeko.Medusa/ParamParser/ParseResult.cs
Normal file
48
src/Nadeko.Medusa/ParamParser/ParseResult.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
namespace NadekoBot.Medusa;
|
||||
|
||||
public readonly struct ParseResult<T>
|
||||
{
|
||||
/// <summary>
|
||||
/// Whether the parsing was successful
|
||||
/// </summary>
|
||||
public bool IsSuccess { get; private init; }
|
||||
|
||||
/// <summary>
|
||||
/// Parsed value. It should only have value if <see cref="IsSuccess"/> is set to true
|
||||
/// </summary>
|
||||
public T? Data { get; private init; }
|
||||
|
||||
/// <summary>
|
||||
/// Instantiate a **successful** parse result
|
||||
/// </summary>
|
||||
/// <param name="data">Parsed value</param>
|
||||
public ParseResult(T data)
|
||||
{
|
||||
Data = data;
|
||||
IsSuccess = true;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Create a new <see cref="ParseResult{T}"/> with IsSuccess = false
|
||||
/// </summary>
|
||||
/// <returns>A new <see cref="ParseResult{T}"/></returns>
|
||||
public static ParseResult<T> Fail()
|
||||
=> new ParseResult<T>
|
||||
{
|
||||
IsSuccess = false,
|
||||
Data = default,
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Create a new <see cref="ParseResult{T}"/> with IsSuccess = true
|
||||
/// </summary>
|
||||
/// <param name="obj">Value of the parsed object</param>
|
||||
/// <returns>A new <see cref="ParseResult{T}"/></returns>
|
||||
public static ParseResult<T> Success(T obj)
|
||||
=> new ParseResult<T>
|
||||
{
|
||||
IsSuccess = true,
|
||||
Data = obj,
|
||||
};
|
||||
}
|
1
src/Nadeko.Medusa/README.md
Normal file
1
src/Nadeko.Medusa/README.md
Normal file
@@ -0,0 +1 @@
|
||||
This is the library which is the base of any medusa.
|
143
src/Nadeko.Medusa/Snek.cs
Normal file
143
src/Nadeko.Medusa/Snek.cs
Normal file
@@ -0,0 +1,143 @@
|
||||
using Discord;
|
||||
|
||||
namespace NadekoBot.Medusa;
|
||||
|
||||
/// <summary>
|
||||
/// The base class which will be loaded as a module into NadekoBot
|
||||
/// Any user-defined snek has to inherit from this class.
|
||||
/// Sneks get instantiated ONLY ONCE during the loading,
|
||||
/// and any snek commands will be executed on the same instance.
|
||||
/// </summary>
|
||||
public abstract class Snek : IAsyncDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// Name of the snek. Defaults to the lowercase class name
|
||||
/// </summary>
|
||||
public virtual string Name
|
||||
=> GetType().Name.ToLowerInvariant();
|
||||
|
||||
/// <summary>
|
||||
/// The prefix required before the command name. For example
|
||||
/// if you set this to 'test' then a command called 'cmd' will have to be invoked by using
|
||||
/// '.test cmd' instead of `.cmd`
|
||||
/// </summary>
|
||||
public virtual string Prefix
|
||||
=> string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Executed once this snek has been instantiated and before any command is executed.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="ValueTask"/> representing completion</returns>
|
||||
public virtual ValueTask InitializeAsync()
|
||||
=> default;
|
||||
|
||||
/// <summary>
|
||||
/// Override to cleanup any resources or references which might hold this snek in memory
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public virtual ValueTask DisposeAsync()
|
||||
=> default;
|
||||
|
||||
/// <summary>
|
||||
/// This method is called right after the message was received by the bot.
|
||||
/// You can use this method to make the bot conditionally ignore some messages and prevent further processing.
|
||||
/// <para>Execution order:</para>
|
||||
/// <para>
|
||||
/// *<see cref="ExecOnMessageAsync"/>* →
|
||||
/// <see cref="ExecInputTransformAsync"/> →
|
||||
/// <see cref="ExecPreCommandAsync"/> →
|
||||
/// <see cref="ExecPostCommandAsync"/> OR <see cref="ExecOnNoCommandAsync"/>
|
||||
/// </para>
|
||||
/// </summary>
|
||||
/// <param name="guild">Guild in which the message was sent</param>
|
||||
/// <param name="msg">Message received by the bot</param>
|
||||
/// <returns>A <see cref="ValueTask"/> representing whether the message should be ignored and not processed further</returns>
|
||||
public virtual ValueTask<bool> ExecOnMessageAsync(IGuild? guild, IUserMessage msg)
|
||||
=> default;
|
||||
|
||||
/// <summary>
|
||||
/// Override this method to modify input before the bot searches for any commands matching the input
|
||||
/// Executed after <see cref="ExecOnMessageAsync"/>
|
||||
/// This is useful if you want to reinterpret the message under some conditions
|
||||
/// <para>Execution order:</para>
|
||||
/// <para>
|
||||
/// <see cref="ExecOnMessageAsync"/> →
|
||||
/// *<see cref="ExecInputTransformAsync"/>* →
|
||||
/// <see cref="ExecPreCommandAsync"/> →
|
||||
/// <see cref="ExecPostCommandAsync"/> OR <see cref="ExecOnNoCommandAsync"/>
|
||||
/// </para>
|
||||
/// </summary>
|
||||
/// <param name="guild">Guild in which the message was sent</param>
|
||||
/// <param name="channel">Channel in which the message was sent</param>
|
||||
/// <param name="user">User who sent the message</param>
|
||||
/// <param name="input">Content of the message</param>
|
||||
/// <returns>A <see cref="ValueTask"/> representing new, potentially modified content</returns>
|
||||
public virtual ValueTask<string?> ExecInputTransformAsync(
|
||||
IGuild? guild,
|
||||
IMessageChannel channel,
|
||||
IUser user,
|
||||
string input
|
||||
)
|
||||
=> default;
|
||||
|
||||
/// <summary>
|
||||
/// This method is called after the command was found but not executed,
|
||||
/// and can be used to prevent the command's execution.
|
||||
/// The command information doesn't have to be from this snek as this method
|
||||
/// will be called when *any* command from any module or snek was found.
|
||||
/// You can choose to prevent the execution of the command by returning "true" value.
|
||||
/// <para>Execution order:</para>
|
||||
/// <para>
|
||||
/// <see cref="ExecOnMessageAsync"/> →
|
||||
/// <see cref="ExecInputTransformAsync"/> →
|
||||
/// *<see cref="ExecPreCommandAsync"/>* →
|
||||
/// <see cref="ExecPostCommandAsync"/> OR <see cref="ExecOnNoCommandAsync"/>
|
||||
/// </para>
|
||||
/// </summary>
|
||||
/// <param name="context">Command context</param>
|
||||
/// <param name="moduleName">Name of the snek or module from which the command originates</param>
|
||||
/// <param name="commandName">Name of the command which is about to be executed</param>
|
||||
/// <returns>A <see cref="ValueTask"/> representing whether the execution should be blocked</returns>
|
||||
public virtual ValueTask<bool> ExecPreCommandAsync(
|
||||
AnyContext context,
|
||||
string moduleName,
|
||||
string commandName
|
||||
)
|
||||
=> default;
|
||||
|
||||
/// <summary>
|
||||
/// This method is called after the command was succesfully executed.
|
||||
/// If this method was called, then <see cref="ExecOnNoCommandAsync"/> will not be executed
|
||||
/// <para>Execution order:</para>
|
||||
/// <para>
|
||||
/// <see cref="ExecOnMessageAsync"/> →
|
||||
/// <see cref="ExecInputTransformAsync"/> →
|
||||
/// <see cref="ExecPreCommandAsync"/> →
|
||||
/// *<see cref="ExecPostCommandAsync"/>* OR <see cref="ExecOnNoCommandAsync"/>
|
||||
/// </para>
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="ValueTask"/> representing completion</returns>
|
||||
public virtual ValueTask ExecPostCommandAsync(AnyContext ctx, string moduleName, string commandName)
|
||||
=> default;
|
||||
|
||||
/// <summary>
|
||||
/// This method is called if no command was found for the input.
|
||||
/// Useful if you want to have games or features which take arbitrary input
|
||||
/// but ignore any messages which were blocked or caused a command execution
|
||||
/// If this method was called, then <see cref="ExecPostCommandAsync"/> will not be executed
|
||||
/// <para>Execution order:</para>
|
||||
/// <para>
|
||||
/// <see cref="ExecOnMessageAsync"/> →
|
||||
/// <see cref="ExecInputTransformAsync"/> →
|
||||
/// <see cref="ExecPreCommandAsync"/> →
|
||||
/// <see cref="ExecPostCommandAsync"/> OR *<see cref="ExecOnNoCommandAsync"/>*
|
||||
/// </para>
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="ValueTask"/> representing completion</returns>
|
||||
public virtual ValueTask ExecOnNoCommandAsync(IGuild? guild, IUserMessage msg)
|
||||
=> default;
|
||||
}
|
||||
|
||||
public readonly struct ExecResponse
|
||||
{
|
||||
}
|
24
src/Nadeko.Medusa/Strings/CommandStrings.cs
Normal file
24
src/Nadeko.Medusa/Strings/CommandStrings.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using YamlDotNet.Serialization;
|
||||
|
||||
namespace NadekoBot.Medusa;
|
||||
|
||||
public readonly struct CommandStrings
|
||||
{
|
||||
public CommandStrings(string? desc, string[]? args)
|
||||
{
|
||||
Desc = desc;
|
||||
Args = args;
|
||||
}
|
||||
|
||||
[YamlMember(Alias = "desc")]
|
||||
public string? Desc { get; init; }
|
||||
|
||||
[YamlMember(Alias = "args")]
|
||||
public string[]? Args { get; init; }
|
||||
|
||||
public void Deconstruct(out string? desc, out string[]? args)
|
||||
{
|
||||
desc = Desc;
|
||||
args = Args;
|
||||
}
|
||||
}
|
15
src/Nadeko.Medusa/Strings/IMedusaStrings.cs
Normal file
15
src/Nadeko.Medusa/Strings/IMedusaStrings.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System.Globalization;
|
||||
|
||||
namespace NadekoBot.Medusa;
|
||||
|
||||
/// <summary>
|
||||
/// Defines methods to retrieve and reload medusa strings
|
||||
/// </summary>
|
||||
public interface IMedusaStrings
|
||||
{
|
||||
// string GetText(string key, ulong? guildId = null, params object[] data);
|
||||
string? GetText(string key, CultureInfo locale, params object[] data);
|
||||
void Reload();
|
||||
CommandStrings GetCommandStrings(string commandName, CultureInfo cultureInfo);
|
||||
string? GetDescription(CultureInfo? locale);
|
||||
}
|
28
src/Nadeko.Medusa/Strings/IMedusaStringsProvider.cs
Normal file
28
src/Nadeko.Medusa/Strings/IMedusaStringsProvider.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
namespace NadekoBot.Medusa;
|
||||
|
||||
/// <summary>
|
||||
/// Implemented by classes which provide localized strings in their own ways
|
||||
/// </summary>
|
||||
public interface IMedusaStringsProvider
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets localized string
|
||||
/// </summary>
|
||||
/// <param name="localeName">Language name</param>
|
||||
/// <param name="key">String key</param>
|
||||
/// <returns>Localized string</returns>
|
||||
string? GetText(string localeName, string key);
|
||||
|
||||
/// <summary>
|
||||
/// Reloads string cache
|
||||
/// </summary>
|
||||
void Reload();
|
||||
|
||||
// /// <summary>
|
||||
// /// Gets command arg examples and description
|
||||
// /// </summary>
|
||||
// /// <param name="localeName">Language name</param>
|
||||
// /// <param name="commandName">Command name</param>
|
||||
// CommandStrings GetCommandStrings(string localeName, string commandName);
|
||||
CommandStrings? GetCommandStrings(string localeName, string commandName);
|
||||
}
|
40
src/Nadeko.Medusa/Strings/LocalMedusaStringsProvider.cs
Normal file
40
src/Nadeko.Medusa/Strings/LocalMedusaStringsProvider.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
namespace NadekoBot.Medusa;
|
||||
|
||||
public class LocalMedusaStringsProvider : IMedusaStringsProvider
|
||||
{
|
||||
private readonly StringsLoader _source;
|
||||
private IReadOnlyDictionary<string, IReadOnlyDictionary<string, string>> _responseStrings;
|
||||
private IReadOnlyDictionary<string, IReadOnlyDictionary<string, CommandStrings>> _commandStrings;
|
||||
|
||||
public LocalMedusaStringsProvider(StringsLoader source)
|
||||
{
|
||||
_source = source;
|
||||
_responseStrings = _source.GetResponseStrings();
|
||||
_commandStrings = _source.GetCommandStrings();
|
||||
}
|
||||
|
||||
public void Reload()
|
||||
{
|
||||
_responseStrings = _source.GetResponseStrings();
|
||||
_commandStrings = _source.GetCommandStrings();
|
||||
}
|
||||
|
||||
|
||||
public string? GetText(string localeName, string key)
|
||||
{
|
||||
if (_responseStrings.TryGetValue(localeName.ToLowerInvariant(), out var langStrings)
|
||||
&& langStrings.TryGetValue(key.ToLowerInvariant(), out var text))
|
||||
return text;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public CommandStrings? GetCommandStrings(string localeName, string commandName)
|
||||
{
|
||||
if (_commandStrings.TryGetValue(localeName.ToLowerInvariant(), out var langStrings)
|
||||
&& langStrings.TryGetValue(commandName.ToLowerInvariant(), out var strings))
|
||||
return strings;
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
79
src/Nadeko.Medusa/Strings/MedusaStrings.cs
Normal file
79
src/Nadeko.Medusa/Strings/MedusaStrings.cs
Normal file
@@ -0,0 +1,79 @@
|
||||
using System.Globalization;
|
||||
using Serilog;
|
||||
|
||||
namespace NadekoBot.Medusa;
|
||||
|
||||
public class MedusaStrings : IMedusaStrings
|
||||
{
|
||||
/// <summary>
|
||||
/// Used as failsafe in case response key doesn't exist in the selected or default language.
|
||||
/// </summary>
|
||||
private readonly CultureInfo _usCultureInfo = new("en-US");
|
||||
|
||||
private readonly IMedusaStringsProvider _stringsProvider;
|
||||
|
||||
public MedusaStrings(IMedusaStringsProvider stringsProvider)
|
||||
{
|
||||
_stringsProvider = stringsProvider;
|
||||
}
|
||||
|
||||
private string? GetString(string key, CultureInfo cultureInfo)
|
||||
=> _stringsProvider.GetText(cultureInfo.Name, key);
|
||||
|
||||
public string? GetText(string key, CultureInfo cultureInfo)
|
||||
=> GetString(key, cultureInfo)
|
||||
?? GetString(key, _usCultureInfo);
|
||||
|
||||
public string? GetText(string key, CultureInfo cultureInfo, params object[] data)
|
||||
{
|
||||
var text = GetText(key, cultureInfo);
|
||||
|
||||
if (string.IsNullOrWhiteSpace(text))
|
||||
return null;
|
||||
|
||||
try
|
||||
{
|
||||
return string.Format(text, data);
|
||||
}
|
||||
catch (FormatException)
|
||||
{
|
||||
Log.Warning(" Key '{Key}' is not properly formatted in '{LanguageName}' response strings",
|
||||
key,
|
||||
cultureInfo.Name);
|
||||
|
||||
return $"⚠️ Response string key '{key}' is not properly formatted. Please report this.\n\n{text}";
|
||||
}
|
||||
}
|
||||
|
||||
public CommandStrings GetCommandStrings(string commandName, CultureInfo cultureInfo)
|
||||
{
|
||||
var cmdStrings = _stringsProvider.GetCommandStrings(cultureInfo.Name, commandName);
|
||||
if (cmdStrings is null)
|
||||
{
|
||||
if (cultureInfo.Name == _usCultureInfo.Name)
|
||||
{
|
||||
Log.Warning("'{CommandName}' doesn't exist in 'en-US' command strings for one of the medusae",
|
||||
commandName);
|
||||
|
||||
return new(null, null);
|
||||
}
|
||||
|
||||
Log.Information("Missing '{CommandName}' command strings for the '{LocaleName}' locale",
|
||||
commandName,
|
||||
cultureInfo.Name);
|
||||
|
||||
return GetCommandStrings(commandName, _usCultureInfo);
|
||||
}
|
||||
|
||||
return cmdStrings.Value;
|
||||
}
|
||||
|
||||
public string? GetDescription(CultureInfo? locale = null)
|
||||
=> GetText("medusa.description", locale ?? _usCultureInfo);
|
||||
|
||||
public static MedusaStrings CreateDefault(string basePath)
|
||||
=> new MedusaStrings(new LocalMedusaStringsProvider(new(basePath)));
|
||||
|
||||
public void Reload()
|
||||
=> _stringsProvider.Reload();
|
||||
}
|
137
src/Nadeko.Medusa/Strings/StringsLoader.cs
Normal file
137
src/Nadeko.Medusa/Strings/StringsLoader.cs
Normal file
@@ -0,0 +1,137 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Serilog;
|
||||
using YamlDotNet.Serialization;
|
||||
|
||||
namespace NadekoBot.Medusa;
|
||||
|
||||
/// <summary>
|
||||
/// Loads strings from the shortcut or localizable path
|
||||
/// </summary>
|
||||
public class StringsLoader
|
||||
{
|
||||
private readonly string _localizableResponsesPath;
|
||||
private readonly string _shortcutResponsesFile;
|
||||
|
||||
private readonly string _localizableCommandsPath;
|
||||
private readonly string _shortcutCommandsFile;
|
||||
|
||||
public StringsLoader(string basePath)
|
||||
{
|
||||
_localizableResponsesPath = Path.Join(basePath, "strings/res");
|
||||
_shortcutResponsesFile = Path.Join(basePath, "res.yml");
|
||||
|
||||
_localizableCommandsPath = Path.Join(basePath, "strings/cmds");
|
||||
_shortcutCommandsFile = Path.Join(basePath, "cmds.yml");
|
||||
}
|
||||
|
||||
public IReadOnlyDictionary<string, IReadOnlyDictionary<string, CommandStrings>> GetCommandStrings()
|
||||
{
|
||||
var outputDict = new Dictionary<string, IReadOnlyDictionary<string, CommandStrings>>();
|
||||
|
||||
if (File.Exists(_shortcutCommandsFile))
|
||||
{
|
||||
if (TryLoadCommandsFromFile(_shortcutCommandsFile, out var dict, out _))
|
||||
{
|
||||
outputDict["en-us"] = dict;
|
||||
}
|
||||
|
||||
return outputDict;
|
||||
}
|
||||
|
||||
if (Directory.Exists(_localizableCommandsPath))
|
||||
{
|
||||
foreach (var cmdsFile in Directory.EnumerateFiles(_localizableCommandsPath))
|
||||
{
|
||||
if (TryLoadCommandsFromFile(cmdsFile, out var dict, out var locale) && locale is not null)
|
||||
{
|
||||
outputDict[locale.ToLowerInvariant()] = dict;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return outputDict;
|
||||
}
|
||||
|
||||
|
||||
private static readonly IDeserializer _deserializer = new DeserializerBuilder().Build();
|
||||
private static bool TryLoadCommandsFromFile(string file,
|
||||
[NotNullWhen(true)] out IReadOnlyDictionary<string, CommandStrings>? strings,
|
||||
out string? localeName)
|
||||
{
|
||||
try
|
||||
{
|
||||
var text = File.ReadAllText(file);
|
||||
strings = _deserializer.Deserialize<Dictionary<string, CommandStrings>?>(text)
|
||||
?? new();
|
||||
localeName = GetLocaleName(file);
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, "Error loading {FileName} command strings: {ErrorMessage}", file, ex.Message);
|
||||
}
|
||||
|
||||
strings = null;
|
||||
localeName = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public IReadOnlyDictionary<string, IReadOnlyDictionary<string, string>> GetResponseStrings()
|
||||
{
|
||||
var outputDict = new Dictionary<string, IReadOnlyDictionary<string, string>>();
|
||||
|
||||
// try to load a shortcut file
|
||||
if (File.Exists(_shortcutResponsesFile))
|
||||
{
|
||||
if (TryLoadResponsesFromFile(_shortcutResponsesFile, out var dict, out _))
|
||||
{
|
||||
outputDict["en-us"] = dict;
|
||||
}
|
||||
|
||||
return outputDict;
|
||||
}
|
||||
|
||||
if (!Directory.Exists(_localizableResponsesPath))
|
||||
return outputDict;
|
||||
|
||||
// if shortcut file doesn't exist, try to load localizable files
|
||||
foreach (var file in Directory.GetFiles(_localizableResponsesPath))
|
||||
{
|
||||
if (TryLoadResponsesFromFile(file, out var strings, out var localeName) && localeName is not null)
|
||||
{
|
||||
outputDict[localeName.ToLowerInvariant()] = strings;
|
||||
}
|
||||
}
|
||||
|
||||
return outputDict;
|
||||
}
|
||||
|
||||
private static bool TryLoadResponsesFromFile(string file,
|
||||
[NotNullWhen(true)] out IReadOnlyDictionary<string, string>? strings,
|
||||
out string? localeName)
|
||||
{
|
||||
try
|
||||
{
|
||||
strings = _deserializer.Deserialize<Dictionary<string, string>?>(File.ReadAllText(file));
|
||||
if (strings is null)
|
||||
{
|
||||
localeName = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
localeName = GetLocaleName(file).ToLowerInvariant();
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, "Error loading {FileName} response strings: {ErrorMessage}", file, ex.Message);
|
||||
strings = null;
|
||||
localeName = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static string GetLocaleName(string fileName)
|
||||
=> Path.GetFileNameWithoutExtension(fileName);
|
||||
}
|
2
src/Nadeko.Medusa/pack-and-push.ps1
Normal file
2
src/Nadeko.Medusa/pack-and-push.ps1
Normal file
@@ -0,0 +1,2 @@
|
||||
dotnet pack -o bin/Release/packed
|
||||
dotnet nuget push bin/Release/packed/ --api-key $env:nadeko_myget_api_key --source https://www.myget.org/F/nadeko/api/v2/package
|
@@ -12,9 +12,7 @@ namespace NadekoBot.Coordinator
|
||||
public IConfiguration Configuration { get; }
|
||||
|
||||
public CoordStartup(IConfiguration config)
|
||||
{
|
||||
Configuration = config;
|
||||
}
|
||||
=> Configuration = config;
|
||||
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
|
@@ -15,13 +15,16 @@ namespace NadekoBot.Services
|
||||
.MinimumLevel.Override("System", LogEventLevel.Information)
|
||||
.MinimumLevel.Override("Microsoft.AspNetCore", LogEventLevel.Warning)
|
||||
.Enrich.FromLogContext()
|
||||
.WriteTo.File("coord.log", LogEventLevel.Information,
|
||||
rollOnFileSizeLimit: true,
|
||||
fileSizeLimitBytes: 10_000_000)
|
||||
.WriteTo.Console(LogEventLevel.Information,
|
||||
theme: GetTheme(),
|
||||
outputTemplate: "[{Timestamp:HH:mm:ss} {Level:u3}] | #{LogSource} | {Message:lj}{NewLine}{Exception}")
|
||||
.Enrich.WithProperty("LogSource", source)
|
||||
.CreateLogger();
|
||||
|
||||
System.Console.OutputEncoding = Encoding.UTF8;
|
||||
Console.OutputEncoding = Encoding.UTF8;
|
||||
}
|
||||
|
||||
private static ConsoleTheme GetTheme()
|
||||
|
@@ -1,7 +1,8 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<NoWarn>CS8981</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@@ -9,10 +10,11 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Grpc.AspNetCore" Version="2.38.0" />
|
||||
<PackageReference Include="Serilog" Version="2.10.0" />
|
||||
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.0" />
|
||||
<PackageReference Include="YamlDotNet" Version="11.2.1" />
|
||||
<PackageReference Include="Grpc.AspNetCore" Version="2.62.0" />
|
||||
<PackageReference Include="Serilog" Version="3.1.1" />
|
||||
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.1" />
|
||||
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
|
||||
<PackageReference Include="YamlDotNet" Version="15.1.4" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
@@ -6,7 +6,6 @@ using System.Linq;
|
||||
using System.Text.Json;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Serilog;
|
||||
using YamlDotNet.Serialization;
|
||||
@@ -30,7 +29,7 @@ namespace NadekoBot.Coordinator
|
||||
private readonly Random _rng;
|
||||
private bool _gracefulImminent;
|
||||
|
||||
public CoordinatorRunner(IConfiguration configuration)
|
||||
public CoordinatorRunner()
|
||||
{
|
||||
_serializer = new();
|
||||
_deserializer = new();
|
||||
@@ -91,7 +90,7 @@ namespace NadekoBot.Coordinator
|
||||
var shardIds = Enumerable.Range(0, 1) // shard 0 is always first
|
||||
.Append((int)((117523346618318850 >> 22) % _config.TotalShards)) // then nadeko server shard
|
||||
.Concat(Enumerable.Range(1, _config.TotalShards - 1)
|
||||
.OrderBy(x => _rng.Next())) // then all other shards in a random order
|
||||
.OrderBy(_ => _rng.Next())) // then all other shards in a random order
|
||||
.Distinct()
|
||||
.ToList();
|
||||
|
||||
@@ -115,14 +114,6 @@ namespace NadekoBot.Coordinator
|
||||
StartShard(shardId);
|
||||
break;
|
||||
}
|
||||
|
||||
if (status.Process is null or {HasExited: true})
|
||||
{
|
||||
Log.Warning("Shard {ShardId} is starting (process)...", shardId);
|
||||
hadAction = true;
|
||||
StartShard(shardId);
|
||||
break;
|
||||
}
|
||||
|
||||
if (DateTime.UtcNow - status.LastUpdate >
|
||||
TimeSpan.FromSeconds(_config.UnresponsiveSec))
|
||||
@@ -140,6 +131,24 @@ namespace NadekoBot.Coordinator
|
||||
StartShard(shardId);
|
||||
break;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (status.Process is null or { HasExited: true })
|
||||
{
|
||||
Log.Warning("Shard {ShardId} is starting (process)...", shardId);
|
||||
hadAction = true;
|
||||
StartShard(shardId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (InvalidOperationException)
|
||||
{
|
||||
Log.Warning("Process for shard {ShardId} is bugged... ", shardId);
|
||||
hadAction = true;
|
||||
StartShard(shardId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,18 +169,20 @@ namespace NadekoBot.Coordinator
|
||||
private void StartShard(int shardId)
|
||||
{
|
||||
var status = _shardStatuses[shardId];
|
||||
if (status.Process is {HasExited: false} p)
|
||||
try
|
||||
{
|
||||
status.Process?.Kill(true);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
try
|
||||
{
|
||||
status.Process?.Dispose();
|
||||
}
|
||||
catch
|
||||
{
|
||||
try
|
||||
{
|
||||
p.Kill(true);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
status.Process?.Dispose();
|
||||
|
||||
var proc = StartShardProcess(shardId);
|
||||
_shardStatuses[shardId] = status with
|
||||
@@ -185,8 +196,7 @@ namespace NadekoBot.Coordinator
|
||||
}
|
||||
|
||||
private Process StartShardProcess(int shardId)
|
||||
{
|
||||
return Process.Start(new ProcessStartInfo()
|
||||
=> Process.Start(new ProcessStartInfo()
|
||||
{
|
||||
FileName = _config.ShardStartCommand,
|
||||
Arguments = string.Format(_config.ShardStartArgs,
|
||||
@@ -199,7 +209,6 @@ namespace NadekoBot.Coordinator
|
||||
// CreateNoWindow = true,
|
||||
// UseShellExecute = false,
|
||||
});
|
||||
}
|
||||
|
||||
public bool Heartbeat(int shardId, int guildCount, ConnState state)
|
||||
{
|
||||
@@ -233,7 +242,6 @@ namespace NadekoBot.Coordinator
|
||||
{
|
||||
lock (locker)
|
||||
{
|
||||
ref var toSave = ref _config;
|
||||
SaveConfig(new Config(
|
||||
totalShards,
|
||||
_config.RecheckIntervalMs,
|
||||
@@ -280,8 +288,8 @@ namespace NadekoBot.Coordinator
|
||||
var status = _shardStatuses[shardId];
|
||||
if (status.Process is Process p)
|
||||
{
|
||||
p.Kill();
|
||||
p.Dispose();
|
||||
try{p.Kill();} catch {}
|
||||
try{p.Dispose();} catch {}
|
||||
_shardStatuses[shardId] = status with
|
||||
{
|
||||
Process = null,
|
||||
@@ -308,7 +316,7 @@ namespace NadekoBot.Coordinator
|
||||
})
|
||||
.ToList()
|
||||
};
|
||||
var jsonState = JsonSerializer.Serialize(coordState, new ()
|
||||
var jsonState = JsonSerializer.Serialize(coordState, new JsonSerializerOptions()
|
||||
{
|
||||
WriteIndented = true,
|
||||
});
|
||||
@@ -340,7 +348,7 @@ namespace NadekoBot.Coordinator
|
||||
|
||||
if (savedState.StatusObjects.Count != _config.TotalShards)
|
||||
{
|
||||
Log.Error("Unable to restore old state because shard count doesn't match.");
|
||||
Log.Error("Unable to restore old state because shard count doesn't match");
|
||||
File.Move(GRACEFUL_STATE_PATH, GRACEFUL_STATE_BACKUP_PATH, overwrite: true);
|
||||
return false;
|
||||
}
|
||||
@@ -351,7 +359,7 @@ namespace NadekoBot.Coordinator
|
||||
{
|
||||
var statusObj = savedState.StatusObjects[shardId];
|
||||
Process p = null;
|
||||
if (statusObj.Pid is int pid)
|
||||
if (statusObj.Pid is { } pid)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -359,7 +367,7 @@ namespace NadekoBot.Coordinator
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Warning(ex, $"Process for shard {shardId} is not runnning.");
|
||||
Log.Warning(ex, "Process for shard {ShardId} is not runnning", shardId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -409,8 +417,7 @@ namespace NadekoBot.Coordinator
|
||||
{
|
||||
lock (locker)
|
||||
{
|
||||
if (shardId >= _shardStatuses.Length)
|
||||
throw new ArgumentOutOfRangeException(nameof(shardId));
|
||||
ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(shardId, _shardStatuses.Length);
|
||||
|
||||
return _shardStatuses[shardId];
|
||||
}
|
||||
@@ -435,9 +442,7 @@ namespace NadekoBot.Coordinator
|
||||
}
|
||||
|
||||
public string GetConfigText()
|
||||
{
|
||||
return File.ReadAllText(CONFIG_PATH);
|
||||
}
|
||||
=> File.ReadAllText(CONFIG_PATH);
|
||||
|
||||
public void SetConfigText(string text)
|
||||
{
|
||||
|
@@ -5,14 +5,12 @@ using Grpc.Core;
|
||||
|
||||
namespace NadekoBot.Coordinator
|
||||
{
|
||||
public sealed class CoordinatorService : NadekoBot.Coordinator.Coordinator.CoordinatorBase
|
||||
public sealed class CoordinatorService : Coordinator.CoordinatorBase
|
||||
{
|
||||
private readonly CoordinatorRunner _runner;
|
||||
|
||||
public CoordinatorService(CoordinatorRunner runner)
|
||||
{
|
||||
_runner = runner;
|
||||
}
|
||||
=> _runner = runner;
|
||||
|
||||
public override Task<HeartbeatReply> Heartbeat(HeartbeatRequest request, ServerCallContext context)
|
||||
{
|
||||
@@ -113,11 +111,10 @@ namespace NadekoBot.Coordinator
|
||||
return new DieReply();
|
||||
}
|
||||
|
||||
public override async Task<SetConfigTextReply> SetConfigText(SetConfigTextRequest request, ServerCallContext context)
|
||||
public override Task<SetConfigTextReply> SetConfigText(SetConfigTextRequest request, ServerCallContext context)
|
||||
{
|
||||
await Task.Yield();
|
||||
string error = string.Empty;
|
||||
bool success = true;
|
||||
var error = string.Empty;
|
||||
var success = true;
|
||||
try
|
||||
{
|
||||
_runner.SetConfigText(request.ConfigYml);
|
||||
@@ -128,11 +125,11 @@ namespace NadekoBot.Coordinator
|
||||
success = false;
|
||||
}
|
||||
|
||||
return new(new()
|
||||
return Task.FromResult<SetConfigTextReply>(new(new()
|
||||
{
|
||||
Success = success,
|
||||
Error = error
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
public override Task<GetConfigTextReply> GetConfigText(GetConfigTextRequest request, ServerCallContext context)
|
||||
|
@@ -1,6 +1,4 @@
|
||||
using System;
|
||||
|
||||
namespace NadekoBot.Coordinator
|
||||
namespace NadekoBot.Coordinator
|
||||
{
|
||||
public class JsonStatusObject
|
||||
{
|
||||
|
258
src/NadekoBot.Generators/Cloneable/CloneableGenerator.cs
Normal file
258
src/NadekoBot.Generators/Cloneable/CloneableGenerator.cs
Normal file
@@ -0,0 +1,258 @@
|
||||
// Code temporarily yeeted from
|
||||
// https://github.com/mostmand/Cloneable/blob/master/Cloneable/CloneableGenerator.cs
|
||||
// because of NRT issue
|
||||
#nullable enable
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.CodeAnalysis.CSharp;
|
||||
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||
using Microsoft.CodeAnalysis.Text;
|
||||
using System.Text;
|
||||
|
||||
namespace Cloneable
|
||||
{
|
||||
[Generator]
|
||||
public class CloneableGenerator : ISourceGenerator
|
||||
{
|
||||
private const string PREVENT_DEEP_COPY_KEY_STRING = "PreventDeepCopy";
|
||||
private const string EXPLICIT_DECLARATION_KEY_STRING = "ExplicitDeclaration";
|
||||
|
||||
private const string CLONEABLE_NAMESPACE = "Cloneable";
|
||||
private const string CLONEABLE_ATTRIBUTE_STRING = "CloneableAttribute";
|
||||
private const string CLONE_ATTRIBUTE_STRING = "CloneAttribute";
|
||||
private const string IGNORE_CLONE_ATTRIBUTE_STRING = "IgnoreCloneAttribute";
|
||||
|
||||
private const string CLONEABLE_ATTRIBUTE_TEXT = $$"""
|
||||
// <AutoGenerated/>
|
||||
using System;
|
||||
|
||||
namespace {{CLONEABLE_NAMESPACE}}
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, Inherited = true, AllowMultiple = false)]
|
||||
internal sealed class {{CLONEABLE_ATTRIBUTE_STRING}} : Attribute
|
||||
{
|
||||
public {{CLONEABLE_ATTRIBUTE_STRING}}()
|
||||
{
|
||||
}
|
||||
|
||||
public bool {{EXPLICIT_DECLARATION_KEY_STRING}} { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
""";
|
||||
|
||||
private const string CLONE_PROPERTY_ATTRIBUTE_TEXT = $$"""
|
||||
// <AutoGenerated/>
|
||||
using System;
|
||||
|
||||
namespace {{CLONEABLE_NAMESPACE}}
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Property, Inherited = true, AllowMultiple = false)]
|
||||
internal sealed class {{CLONE_ATTRIBUTE_STRING}} : Attribute
|
||||
{
|
||||
public {{CLONE_ATTRIBUTE_STRING}}()
|
||||
{
|
||||
}
|
||||
|
||||
public bool {{PREVENT_DEEP_COPY_KEY_STRING}} { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
""";
|
||||
|
||||
private const string IGNORE_CLONE_PROPERTY_ATTRIBUTE_TEXT = $$"""
|
||||
// <AutoGenerated/>
|
||||
using System;
|
||||
|
||||
namespace {{CLONEABLE_NAMESPACE}}
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Property, Inherited = true, AllowMultiple = false)]
|
||||
internal sealed class {{IGNORE_CLONE_ATTRIBUTE_STRING}} : Attribute
|
||||
{
|
||||
public {{IGNORE_CLONE_ATTRIBUTE_STRING}}()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
""";
|
||||
|
||||
private INamedTypeSymbol? _cloneableAttribute;
|
||||
private INamedTypeSymbol? _ignoreCloneAttribute;
|
||||
private INamedTypeSymbol? _cloneAttribute;
|
||||
|
||||
public void Initialize(GeneratorInitializationContext context)
|
||||
=> context.RegisterForSyntaxNotifications(() => new SyntaxReceiver());
|
||||
|
||||
public void Execute(GeneratorExecutionContext context)
|
||||
{
|
||||
InjectCloneableAttributes(context);
|
||||
GenerateCloneMethods(context);
|
||||
}
|
||||
|
||||
private void GenerateCloneMethods(GeneratorExecutionContext context)
|
||||
{
|
||||
if (context.SyntaxReceiver is not SyntaxReceiver receiver)
|
||||
return;
|
||||
|
||||
Compilation compilation = GetCompilation(context);
|
||||
|
||||
InitAttributes(compilation);
|
||||
|
||||
var classSymbols = GetClassSymbols(compilation, receiver);
|
||||
foreach (var classSymbol in classSymbols)
|
||||
{
|
||||
if (!classSymbol.TryGetAttribute(_cloneableAttribute!, out var attributes))
|
||||
continue;
|
||||
|
||||
var attribute = attributes.Single();
|
||||
var isExplicit = (bool?)attribute.NamedArguments.FirstOrDefault(e => e.Key.Equals(EXPLICIT_DECLARATION_KEY_STRING)).Value.Value ?? false;
|
||||
context.AddSource($"{classSymbol.Name}_cloneable.g.cs", SourceText.From(CreateCloneableCode(classSymbol, isExplicit), Encoding.UTF8));
|
||||
}
|
||||
}
|
||||
|
||||
private void InitAttributes(Compilation compilation)
|
||||
{
|
||||
_cloneableAttribute = compilation.GetTypeByMetadataName($"{CLONEABLE_NAMESPACE}.{CLONEABLE_ATTRIBUTE_STRING}")!;
|
||||
_cloneAttribute = compilation.GetTypeByMetadataName($"{CLONEABLE_NAMESPACE}.{CLONE_ATTRIBUTE_STRING}")!;
|
||||
_ignoreCloneAttribute = compilation.GetTypeByMetadataName($"{CLONEABLE_NAMESPACE}.{IGNORE_CLONE_ATTRIBUTE_STRING}")!;
|
||||
}
|
||||
|
||||
private static Compilation GetCompilation(GeneratorExecutionContext context)
|
||||
{
|
||||
var options = context.Compilation.SyntaxTrees.First().Options as CSharpParseOptions;
|
||||
|
||||
var compilation = context.Compilation.AddSyntaxTrees(CSharpSyntaxTree.ParseText(SourceText.From(CLONEABLE_ATTRIBUTE_TEXT, Encoding.UTF8), options)).
|
||||
AddSyntaxTrees(CSharpSyntaxTree.ParseText(SourceText.From(CLONE_PROPERTY_ATTRIBUTE_TEXT, Encoding.UTF8), options)).
|
||||
AddSyntaxTrees(CSharpSyntaxTree.ParseText(SourceText.From(IGNORE_CLONE_PROPERTY_ATTRIBUTE_TEXT, Encoding.UTF8), options));
|
||||
return compilation;
|
||||
}
|
||||
|
||||
private string CreateCloneableCode(INamedTypeSymbol classSymbol, bool isExplicit)
|
||||
{
|
||||
string namespaceName = classSymbol.ContainingNamespace.ToDisplayString();
|
||||
var fieldAssignmentsCode = GenerateFieldAssignmentsCode(classSymbol, isExplicit).ToList();
|
||||
var fieldAssignmentsCodeSafe = fieldAssignmentsCode.Select(x =>
|
||||
{
|
||||
if (x.isCloneable)
|
||||
return x.line + "Safe(referenceChain)";
|
||||
return x.line;
|
||||
});
|
||||
var fieldAssignmentsCodeFast = fieldAssignmentsCode.Select(x =>
|
||||
{
|
||||
if (x.isCloneable)
|
||||
return x.line + "()";
|
||||
return x.line;
|
||||
});
|
||||
|
||||
return $@"using System.Collections.Generic;
|
||||
|
||||
namespace {namespaceName}
|
||||
{{
|
||||
{GetAccessModifier(classSymbol)} partial class {classSymbol.Name}
|
||||
{{
|
||||
/// <summary>
|
||||
/// Creates a copy of {classSymbol.Name} with NO circular reference checking. This method should be used if performance matters.
|
||||
///
|
||||
/// <exception cref=""StackOverflowException"">Will occur on any object that has circular references in the hierarchy.</exception>
|
||||
/// </summary>
|
||||
public {classSymbol.Name} Clone()
|
||||
{{
|
||||
return new {classSymbol.Name}
|
||||
{{
|
||||
{string.Join(",\n", fieldAssignmentsCodeFast)}
|
||||
}};
|
||||
}}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a copy of {classSymbol.Name} with circular reference checking. If a circular reference was detected, only a reference of the leaf object is passed instead of cloning it.
|
||||
/// </summary>
|
||||
/// <param name=""referenceChain"">Should only be provided if specific objects should not be cloned but passed by reference instead.</param>
|
||||
public {classSymbol.Name} CloneSafe(Stack<object> referenceChain = null)
|
||||
{{
|
||||
if(referenceChain?.Contains(this) == true)
|
||||
return this;
|
||||
referenceChain ??= new Stack<object>();
|
||||
referenceChain.Push(this);
|
||||
var result = new {classSymbol.Name}
|
||||
{{
|
||||
{string.Join($",\n", fieldAssignmentsCodeSafe)}
|
||||
}};
|
||||
referenceChain.Pop();
|
||||
return result;
|
||||
}}
|
||||
}}
|
||||
}}";
|
||||
}
|
||||
|
||||
private IEnumerable<(string line, bool isCloneable)> GenerateFieldAssignmentsCode(INamedTypeSymbol classSymbol, bool isExplicit )
|
||||
{
|
||||
var fieldNames = GetCloneableProperties(classSymbol, isExplicit);
|
||||
|
||||
var fieldAssignments = fieldNames.Select(field => IsFieldCloneable(field, classSymbol))
|
||||
.OrderBy(x => x.isCloneable)
|
||||
.Select(x => (GenerateAssignmentCode(x.item.Name, x.isCloneable), x.isCloneable));
|
||||
return fieldAssignments;
|
||||
}
|
||||
|
||||
private string GenerateAssignmentCode(string name, bool isCloneable)
|
||||
{
|
||||
if (isCloneable)
|
||||
{
|
||||
return $@" {name} = this.{name}?.Clone";
|
||||
}
|
||||
|
||||
return $@" {name} = this.{name}";
|
||||
}
|
||||
|
||||
private (IPropertySymbol item, bool isCloneable) IsFieldCloneable(IPropertySymbol x, INamedTypeSymbol classSymbol)
|
||||
{
|
||||
if (SymbolEqualityComparer.Default.Equals(x.Type, classSymbol))
|
||||
{
|
||||
return (x, false);
|
||||
}
|
||||
|
||||
if (!x.Type.TryGetAttribute(_cloneableAttribute!, out var attributes))
|
||||
{
|
||||
return (x, false);
|
||||
}
|
||||
|
||||
var preventDeepCopy = (bool?)attributes.Single().NamedArguments.FirstOrDefault(e => e.Key.Equals(PREVENT_DEEP_COPY_KEY_STRING)).Value.Value ?? false;
|
||||
return (item: x, !preventDeepCopy);
|
||||
}
|
||||
|
||||
private string GetAccessModifier(INamedTypeSymbol classSymbol)
|
||||
=> classSymbol.DeclaredAccessibility.ToString().ToLowerInvariant();
|
||||
|
||||
private IEnumerable<IPropertySymbol> GetCloneableProperties(ITypeSymbol classSymbol, bool isExplicit)
|
||||
{
|
||||
var targetSymbolMembers = classSymbol.GetMembers().OfType<IPropertySymbol>()
|
||||
.Where(x => x.SetMethod is not null &&
|
||||
x.CanBeReferencedByName);
|
||||
if (isExplicit)
|
||||
{
|
||||
return targetSymbolMembers.Where(x => x.HasAttribute(_cloneAttribute!));
|
||||
}
|
||||
else
|
||||
{
|
||||
return targetSymbolMembers.Where(x => !x.HasAttribute(_ignoreCloneAttribute!));
|
||||
}
|
||||
}
|
||||
|
||||
private static IEnumerable<INamedTypeSymbol> GetClassSymbols(Compilation compilation, SyntaxReceiver receiver)
|
||||
=> receiver.CandidateClasses.Select(clazz => GetClassSymbol(compilation, clazz));
|
||||
|
||||
private static INamedTypeSymbol GetClassSymbol(Compilation compilation, ClassDeclarationSyntax clazz)
|
||||
{
|
||||
var model = compilation.GetSemanticModel(clazz.SyntaxTree);
|
||||
var classSymbol = model.GetDeclaredSymbol(clazz)!;
|
||||
return classSymbol;
|
||||
}
|
||||
|
||||
private static void InjectCloneableAttributes(GeneratorExecutionContext context)
|
||||
{
|
||||
context.AddSource(CLONEABLE_ATTRIBUTE_STRING, SourceText.From(CLONEABLE_ATTRIBUTE_TEXT, Encoding.UTF8));
|
||||
context.AddSource(CLONE_ATTRIBUTE_STRING, SourceText.From(CLONE_PROPERTY_ATTRIBUTE_TEXT, Encoding.UTF8));
|
||||
context.AddSource(IGNORE_CLONE_ATTRIBUTE_STRING, SourceText.From(IGNORE_CLONE_PROPERTY_ATTRIBUTE_TEXT, Encoding.UTF8));
|
||||
}
|
||||
}
|
||||
}
|
23
src/NadekoBot.Generators/Cloneable/SymbolExtensions.cs
Normal file
23
src/NadekoBot.Generators/Cloneable/SymbolExtensions.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
// Code temporarily yeeted from
|
||||
// https://github.com/mostmand/Cloneable/blob/master/Cloneable/CloneableGenerator.cs
|
||||
// because of NRT issue
|
||||
|
||||
using Microsoft.CodeAnalysis;
|
||||
|
||||
namespace Cloneable
|
||||
{
|
||||
internal static class SymbolExtensions
|
||||
{
|
||||
public static bool TryGetAttribute(this ISymbol symbol, INamedTypeSymbol attributeType,
|
||||
out IEnumerable<AttributeData> attributes)
|
||||
{
|
||||
attributes = symbol.GetAttributes()
|
||||
.Where(a => SymbolEqualityComparer.Default.Equals(a.AttributeClass, attributeType));
|
||||
return attributes.Any();
|
||||
}
|
||||
|
||||
public static bool HasAttribute(this ISymbol symbol, INamedTypeSymbol attributeType)
|
||||
=> symbol.GetAttributes()
|
||||
.Any(a => SymbolEqualityComparer.Default.Equals(a.AttributeClass, attributeType));
|
||||
}
|
||||
}
|
27
src/NadekoBot.Generators/Cloneable/SyntaxReceiver.cs
Normal file
27
src/NadekoBot.Generators/Cloneable/SyntaxReceiver.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
// Code temporarily yeeted from
|
||||
// https://github.com/mostmand/Cloneable/blob/master/Cloneable/CloneableGenerator.cs
|
||||
// because of NRT issue
|
||||
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||
|
||||
namespace Cloneable
|
||||
{
|
||||
internal class SyntaxReceiver : ISyntaxReceiver
|
||||
{
|
||||
public IList<ClassDeclarationSyntax> CandidateClasses { get; } = new List<ClassDeclarationSyntax>();
|
||||
|
||||
/// <summary>
|
||||
/// Called for every syntax node in the compilation, we can inspect the nodes and save any information useful for generation
|
||||
/// </summary>
|
||||
public void OnVisitSyntaxNode(SyntaxNode syntaxNode)
|
||||
{
|
||||
// any field with at least one attribute is a candidate for being cloneable
|
||||
if (syntaxNode is ClassDeclarationSyntax classDeclarationSyntax &&
|
||||
classDeclarationSyntax.AttributeLists.Count > 0)
|
||||
{
|
||||
CandidateClasses.Add(classDeclarationSyntax);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,43 +1,44 @@
|
||||
using System;
|
||||
#nullable enable
|
||||
using System.CodeDom.Compiler;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Diagnostics;
|
||||
using System.Text.RegularExpressions;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.CodeAnalysis.Text;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace NadekoBot.Generators
|
||||
{
|
||||
internal class TranslationPair
|
||||
internal readonly struct TranslationPair
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string Value { get; set; }
|
||||
public string Name { get; }
|
||||
public string Value { get; }
|
||||
|
||||
public TranslationPair(string name, string value)
|
||||
{
|
||||
Name = name;
|
||||
Value = value;
|
||||
}
|
||||
}
|
||||
|
||||
[Generator]
|
||||
public class LocalizedStringsGenerator : ISourceGenerator
|
||||
{
|
||||
private const string LocStrSource = @"namespace NadekoBot
|
||||
{
|
||||
public readonly struct LocStr
|
||||
{
|
||||
public readonly string Key;
|
||||
public readonly object[] Params;
|
||||
|
||||
public LocStr(string key, params object[] data)
|
||||
{
|
||||
Key = key;
|
||||
Params = data;
|
||||
}
|
||||
}
|
||||
}";
|
||||
// private const string LOC_STR_SOURCE = @"namespace NadekoBot
|
||||
// {
|
||||
// public readonly struct LocStr
|
||||
// {
|
||||
// public readonly string Key;
|
||||
// public readonly object[] Params;
|
||||
//
|
||||
// public LocStr(string key, params object[] data)
|
||||
// {
|
||||
// Key = key;
|
||||
// Params = data;
|
||||
// }
|
||||
// }
|
||||
// }";
|
||||
|
||||
public void Initialize(GeneratorInitializationContext context)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Execute(GeneratorExecutionContext context)
|
||||
@@ -49,14 +50,15 @@ namespace NadekoBot.Generators
|
||||
using (var stringWriter = new StringWriter())
|
||||
using (var sw = new IndentedTextWriter(stringWriter))
|
||||
{
|
||||
sw.WriteLine("namespace NadekoBot");
|
||||
sw.WriteLine("{");
|
||||
sw.Indent++;
|
||||
sw.WriteLine("#pragma warning disable CS8981");
|
||||
sw.WriteLine("namespace NadekoBot;");
|
||||
sw.WriteLine();
|
||||
|
||||
sw.WriteLine("public static class strs");
|
||||
sw.WriteLine("{");
|
||||
sw.Indent++;
|
||||
|
||||
var typedParamStrings = new List<string>(10);
|
||||
foreach (var field in fields)
|
||||
{
|
||||
var matches = Regex.Matches(field.Value, @"{(?<num>\d)[}:]");
|
||||
@@ -66,50 +68,70 @@ namespace NadekoBot.Generators
|
||||
max = Math.Max(max, int.Parse(match.Groups["num"].Value) + 1);
|
||||
}
|
||||
|
||||
List<string> typedParamStrings = new List<string>();
|
||||
var paramStrings = string.Empty;
|
||||
typedParamStrings.Clear();
|
||||
var typeParams = new string[max];
|
||||
var passedParamString = string.Empty;
|
||||
for (var i = 0; i < max; i++)
|
||||
{
|
||||
typedParamStrings.Add($"object p{i}");
|
||||
paramStrings += $", p{i}";
|
||||
typedParamStrings.Add($"in T{i} p{i}");
|
||||
passedParamString += $", p{i}";
|
||||
typeParams[i] = $"T{i}";
|
||||
}
|
||||
|
||||
|
||||
var sig = string.Empty;
|
||||
if(max > 0)
|
||||
var typeParamStr = string.Empty;
|
||||
if (max > 0)
|
||||
{
|
||||
sig = $"({string.Join(", ", typedParamStrings)})";
|
||||
|
||||
sw.WriteLine($"public static LocStr {field.Name}{sig} => new LocStr(\"{field.Name}\"{paramStrings});");
|
||||
typeParamStr = $"<{string.Join(", ", typeParams)}>";
|
||||
}
|
||||
|
||||
sw.WriteLine("public static LocStr {0}{1}{2} => new LocStr(\"{3}\"{4});",
|
||||
field.Name,
|
||||
typeParamStr,
|
||||
sig,
|
||||
field.Name,
|
||||
passedParamString);
|
||||
}
|
||||
|
||||
sw.Indent--;
|
||||
sw.WriteLine("}");
|
||||
sw.Indent--;
|
||||
sw.WriteLine("}");
|
||||
|
||||
|
||||
sw.Flush();
|
||||
context.AddSource("strs.cs", stringWriter.ToString());
|
||||
context.AddSource("strs.g.cs", stringWriter.ToString());
|
||||
}
|
||||
|
||||
context.AddSource("LocStr.cs", LocStrSource);
|
||||
// context.AddSource("LocStr.g.cs", LOC_STR_SOURCE);
|
||||
}
|
||||
|
||||
private List<TranslationPair> GetFields(string dataText)
|
||||
private List<TranslationPair> GetFields(string? dataText)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(dataText))
|
||||
throw new ArgumentNullException(nameof(dataText));
|
||||
return new();
|
||||
|
||||
var data = JsonConvert.DeserializeObject<Dictionary<string, string>>(dataText);
|
||||
Dictionary<string, string> data;
|
||||
try
|
||||
{
|
||||
var output = JsonConvert.DeserializeObject<Dictionary<string, string>>(dataText!);
|
||||
if (output is null)
|
||||
return new();
|
||||
|
||||
data = output;
|
||||
}
|
||||
catch
|
||||
{
|
||||
Debug.WriteLine("Failed parsing responses file.");
|
||||
return new();
|
||||
}
|
||||
|
||||
var list = new List<TranslationPair>();
|
||||
foreach (var entry in data)
|
||||
{
|
||||
list.Add(new TranslationPair()
|
||||
{
|
||||
Name = entry.Key,
|
||||
Value = entry.Value
|
||||
});
|
||||
list.Add(new(
|
||||
entry.Key,
|
||||
entry.Value
|
||||
));
|
||||
}
|
||||
|
||||
return list;
|
||||
|
@@ -1,16 +1,19 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<IncludeBuildOutput>false</IncludeBuildOutput>
|
||||
<IsRoslynComponent>true</IsRoslynComponent>
|
||||
<ImplicitUsings>true</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="3.8.0" PrivateAssets="all" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.2" PrivateAssets="all" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" PrivateAssets="all" GeneratePathProperty="true" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.0.1" PrivateAssets="all" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.3" PrivateAssets="all" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" PrivateAssets="all" GeneratePathProperty="true" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
<PropertyGroup>
|
||||
<GetTargetPathDependsOn>$(GetTargetPathDependsOn);GetDependencyTargetPaths</GetTargetPathDependsOn>
|
||||
</PropertyGroup>
|
||||
@@ -21,3 +24,4 @@
|
||||
</ItemGroup>
|
||||
</Target>
|
||||
</Project>
|
||||
|
||||
|
@@ -3,9 +3,9 @@ using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Discord.Commands;
|
||||
using NadekoBot.Common;
|
||||
using NadekoBot.Common.Attributes;
|
||||
using NadekoBot.Services;
|
||||
using NadekoBot.Modules;
|
||||
|
||||
namespace NadekoBot.Tests
|
||||
{
|
||||
@@ -14,26 +14,25 @@ namespace NadekoBot.Tests
|
||||
private const string responsesPath = "../../../../NadekoBot/data/strings/responses";
|
||||
private const string commandsPath = "../../../../NadekoBot/data/strings/commands";
|
||||
private const string aliasesPath = "../../../../NadekoBot/data/aliases.yml";
|
||||
|
||||
[Test]
|
||||
public void AllCommandNamesHaveStrings()
|
||||
{
|
||||
var stringsSource = new LocalFileStringsSource(
|
||||
responsesPath,
|
||||
commandsPath);
|
||||
var strings = new LocalBotStringsProvider(stringsSource);
|
||||
var strings = new MemoryBotStringsProvider(stringsSource);
|
||||
|
||||
var culture = new CultureInfo("en-US");
|
||||
|
||||
var isSuccess = true;
|
||||
foreach (var entry in CommandNameLoadHelper.LoadCommandNames(aliasesPath))
|
||||
foreach (var (methodName, _) in CommandNameLoadHelper.LoadAliases(aliasesPath))
|
||||
{
|
||||
var commandName = entry.Value[0];
|
||||
|
||||
var cmdStrings = strings.GetCommandStrings(culture.Name, commandName);
|
||||
var cmdStrings = strings.GetCommandStrings(culture.Name, methodName);
|
||||
if (cmdStrings is null)
|
||||
{
|
||||
isSuccess = false;
|
||||
TestContext.Out.WriteLine($"{commandName} doesn't exist in commands.en-US.yml");
|
||||
TestContext.Out.WriteLine($"{methodName} doesn't exist in commands.en-US.yml");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,29 +40,29 @@ namespace NadekoBot.Tests
|
||||
}
|
||||
|
||||
private static string[] GetCommandMethodNames()
|
||||
=> typeof(NadekoBot.Bot).Assembly
|
||||
=> typeof(Bot).Assembly
|
||||
.GetExportedTypes()
|
||||
.Where(type => type.IsClass && !type.IsAbstract)
|
||||
.Where(type => typeof(NadekoModule).IsAssignableFrom(type) // if its a top level module
|
||||
|| !(type.GetCustomAttribute<GroupAttribute>(true) is null)) // or a submodule
|
||||
.SelectMany(x => x.GetMethods()
|
||||
.Where(mi => mi.CustomAttributes
|
||||
.Any(ca => ca.AttributeType == typeof(NadekoCommandAttribute))))
|
||||
.Any(ca => ca.AttributeType == typeof(CmdAttribute))))
|
||||
.Select(x => x.Name.ToLowerInvariant())
|
||||
.ToArray();
|
||||
|
||||
[Test]
|
||||
public void AllCommandMethodsHaveNames()
|
||||
{
|
||||
var allAliases = CommandNameLoadHelper.LoadCommandNames(
|
||||
var allAliases = CommandNameLoadHelper.LoadAliases(
|
||||
aliasesPath);
|
||||
|
||||
var methodNames = GetCommandMethodNames();
|
||||
|
||||
|
||||
var isSuccess = true;
|
||||
foreach (var methodName in methodNames)
|
||||
{
|
||||
if (!allAliases.TryGetValue(methodName, out var _))
|
||||
if (!allAliases.TryGetValue(methodName, out _))
|
||||
{
|
||||
TestContext.Error.WriteLine($"{methodName} is missing an alias.");
|
||||
isSuccess = false;
|
||||
@@ -76,7 +75,7 @@ namespace NadekoBot.Tests
|
||||
[Test]
|
||||
public void NoObsoleteAliases()
|
||||
{
|
||||
var allAliases = CommandNameLoadHelper.LoadCommandNames(aliasesPath);
|
||||
var allAliases = CommandNameLoadHelper.LoadAliases(aliasesPath);
|
||||
|
||||
var methodNames = GetCommandMethodNames()
|
||||
.ToHashSet();
|
||||
@@ -94,34 +93,39 @@ namespace NadekoBot.Tests
|
||||
}
|
||||
}
|
||||
|
||||
Assert.IsTrue(isSuccess);
|
||||
if(isSuccess)
|
||||
Assert.Pass();
|
||||
else
|
||||
Assert.Warn("There are some unused entries in data/aliases.yml");
|
||||
}
|
||||
|
||||
// [Test]
|
||||
// public void NoObsoleteCommandStrings()
|
||||
// {
|
||||
// var stringsSource = new LocalFileStringsSource(responsesPath, commandsPath);
|
||||
//
|
||||
// var culture = new CultureInfo("en-US");
|
||||
//
|
||||
// var isSuccess = true;
|
||||
// var allCommandNames = CommandNameLoadHelper.LoadCommandNames(aliasesPath);
|
||||
// var enUsCommandNames = allCommandNames
|
||||
// .Select(x => x.Value[0]) // first alias is command name
|
||||
// .ToHashSet();
|
||||
// foreach (var entry in stringsSource.GetCommandStrings()[culture.Name])
|
||||
// {
|
||||
// // key is command name which should be specified in aliases[0] of any method name
|
||||
// var cmdName = entry.Key;
|
||||
//
|
||||
// if (!enUsCommandNames.Contains(cmdName))
|
||||
// {
|
||||
// TestContext.Out.WriteLine($"'{cmdName}' It's either obsolete or missing an alias entry.");
|
||||
// isSuccess = false;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// Assert.IsTrue(isSuccess);
|
||||
// }
|
||||
[Test]
|
||||
public void NoObsoleteCommandStrings()
|
||||
{
|
||||
var stringsSource = new LocalFileStringsSource(responsesPath, commandsPath);
|
||||
|
||||
var culture = new CultureInfo("en-US");
|
||||
|
||||
var methodNames = GetCommandMethodNames()
|
||||
.ToHashSet();
|
||||
|
||||
var isSuccess = true;
|
||||
// var allCommandNames = CommandNameLoadHelper.LoadCommandStrings(commandsPath));
|
||||
foreach (var entry in stringsSource.GetCommandStrings()[culture.Name])
|
||||
{
|
||||
var cmdName = entry.Key;
|
||||
|
||||
if (!methodNames.Contains(cmdName))
|
||||
{
|
||||
TestContext.Out.WriteLine($"'{cmdName}' from commands.en-US.yml doesn't have a matching command method.");
|
||||
isSuccess = false;
|
||||
}
|
||||
}
|
||||
|
||||
if(isSuccess)
|
||||
Assert.IsTrue(isSuccess);
|
||||
else
|
||||
Assert.Warn("There are some unused command strings in data/strings/commands.en-US.yml");
|
||||
}
|
||||
}
|
||||
}
|
93
src/NadekoBot.Tests/ConcurrentHashSetTests.cs
Normal file
93
src/NadekoBot.Tests/ConcurrentHashSetTests.cs
Normal file
@@ -0,0 +1,93 @@
|
||||
using System.Collections.Generic;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace NadekoBot.Tests;
|
||||
|
||||
public class ConcurrentHashSetTests
|
||||
{
|
||||
private ConcurrentHashSet<(int?, int?)> _set;
|
||||
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
_set = new();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AddTest()
|
||||
{
|
||||
var result = _set.Add((1, 2));
|
||||
|
||||
Assert.AreEqual(true, result);
|
||||
|
||||
result = _set.Add((1, 2));
|
||||
|
||||
Assert.AreEqual(false, result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TryRemoveTest()
|
||||
{
|
||||
_set.Add((1, 2));
|
||||
var result = _set.TryRemove((1, 2));
|
||||
|
||||
Assert.AreEqual(true, result);
|
||||
|
||||
result = _set.TryRemove((1, 2));
|
||||
Assert.AreEqual(false, result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CountTest()
|
||||
{
|
||||
_set.Add((1, 2)); // 1
|
||||
_set.Add((1, 2)); // 1
|
||||
|
||||
_set.Add((2, 2)); // 2
|
||||
|
||||
_set.Add((3, 2)); // 3
|
||||
_set.Add((3, 2)); // 3
|
||||
|
||||
Assert.AreEqual(3, _set.Count);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ClearTest()
|
||||
{
|
||||
_set.Add((1, 2));
|
||||
_set.Add((1, 3));
|
||||
_set.Add((1, 4));
|
||||
|
||||
_set.Clear();
|
||||
|
||||
Assert.AreEqual(0, _set.Count);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ContainsTest()
|
||||
{
|
||||
_set.Add((1, 2));
|
||||
_set.Add((3, 2));
|
||||
|
||||
Assert.AreEqual(true, _set.Contains((1, 2)));
|
||||
Assert.AreEqual(true, _set.Contains((3, 2)));
|
||||
Assert.AreEqual(false, _set.Contains((2, 1)));
|
||||
Assert.AreEqual(false, _set.Contains((2, 3)));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RemoveWhereTest()
|
||||
{
|
||||
_set.Add((1, 2));
|
||||
_set.Add((1, 3));
|
||||
_set.Add((1, 4));
|
||||
_set.Add((2, 5));
|
||||
|
||||
// remove tuples which have even second item
|
||||
_set.RemoveWhere(static x => x.Item2 % 2 == 0);
|
||||
|
||||
Assert.AreEqual(2, _set.Count);
|
||||
Assert.AreEqual(true, _set.Contains((1, 3)));
|
||||
Assert.AreEqual(true, _set.Contains((2, 5)));
|
||||
}
|
||||
}
|
@@ -1,7 +1,6 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Nadeko.Common;
|
||||
using NadekoBot.Services;
|
||||
using NUnit.Framework;
|
||||
|
||||
@@ -13,9 +12,7 @@ namespace NadekoBot.Tests
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_grouper = new GreetGrouper<int>();
|
||||
}
|
||||
=> _grouper = new GreetGrouper<int>();
|
||||
|
||||
[Test]
|
||||
public void CreateTest()
|
||||
@@ -62,8 +59,8 @@ namespace NadekoBot.Tests
|
||||
_grouper.CreateOrAdd(0, 5);
|
||||
|
||||
// add 15 items
|
||||
await Task.WhenAll(Enumerable.Range(10, 15)
|
||||
.Select(x => Task.Run(() => _grouper.CreateOrAdd(0, x))));
|
||||
await Enumerable.Range(10, 15)
|
||||
.Select(x => Task.Run(() => _grouper.CreateOrAdd(0, x))).WhenAll();
|
||||
|
||||
// get 5 at most
|
||||
_grouper.ClearGroup(0, 5, out var items);
|
||||
|
@@ -1,5 +1,5 @@
|
||||
using NadekoBot.Common.Collections;
|
||||
using NadekoBot.Services.Database.Models;
|
||||
using Nadeko.Common;
|
||||
using NadekoBot.Db.Models;
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -62,7 +62,10 @@ namespace NadekoBot.Tests
|
||||
collection.Clear();
|
||||
|
||||
Assert.IsTrue(collection.Count == 0, "Collection has not been cleared.");
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() => collection.Contains(collection[0]), "Collection has not been cleared.");
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() =>
|
||||
{
|
||||
_ = collection[0];
|
||||
}, "Collection has not been cleared.");
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -115,7 +118,7 @@ namespace NadekoBot.Tests
|
||||
[Test]
|
||||
public void ContainsTest()
|
||||
{
|
||||
var subCol = new ShopEntry[]
|
||||
var subCol = new[]
|
||||
{
|
||||
new ShopEntry() { Id = 111 },
|
||||
new ShopEntry() { Id = 222 },
|
||||
|
@@ -1,5 +1,4 @@
|
||||
using System.Linq;
|
||||
using NadekoBot.Common;
|
||||
using Nadeko.Common;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace NadekoBot.Tests
|
||||
|
@@ -1,17 +1,17 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<LangVersion>9.0</LangVersion>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="NUnit" Version="3.13.2" />
|
||||
<PackageReference Include="NUnit3TestAdapter" Version="4.0.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
|
||||
<PackageReference Include="NUnit" Version="3.13.3" />
|
||||
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\NadekoBot\NadekoBot.csproj" />
|
||||
</ItemGroup>
|
||||
|
83
src/NadekoBot.Tests/NewDeckTests.cs
Normal file
83
src/NadekoBot.Tests/NewDeckTests.cs
Normal file
@@ -0,0 +1,83 @@
|
||||
using Nadeko.Econ;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace NadekoBot.Tests;
|
||||
|
||||
public class NewDeckTests
|
||||
{
|
||||
private RegularDeck _deck;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_deck = new RegularDeck();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCount()
|
||||
{
|
||||
Assert.AreEqual(52, _deck.TotalCount);
|
||||
Assert.AreEqual(52, _deck.CurrentCount);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestDeckDraw()
|
||||
{
|
||||
var card = _deck.Draw();
|
||||
|
||||
Assert.IsNotNull(card);
|
||||
Assert.AreEqual(card.Suit, RegularSuit.Hearts);
|
||||
Assert.AreEqual(card.Value, RegularValue.Ace);
|
||||
Assert.AreEqual(_deck.CurrentCount, _deck.TotalCount - 1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestDeckSpent()
|
||||
{
|
||||
for (var i = 0; i < _deck.TotalCount - 1; ++i)
|
||||
{
|
||||
_deck.Draw();
|
||||
}
|
||||
|
||||
var lastCard = _deck.Draw();
|
||||
|
||||
Assert.IsNotNull(lastCard);
|
||||
Assert.AreEqual(new RegularCard(RegularSuit.Spades, RegularValue.King), lastCard);
|
||||
|
||||
var noCard = _deck.Draw();
|
||||
|
||||
Assert.IsNull(noCard);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCardGetName()
|
||||
{
|
||||
var ace = _deck.Draw()!;
|
||||
var two = _deck.Draw()!;
|
||||
|
||||
Assert.AreEqual("Ace of Hearts", ace.GetName());
|
||||
Assert.AreEqual("Two of Hearts", two.GetName());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestPeek()
|
||||
{
|
||||
var ace = _deck.Peek()!;
|
||||
|
||||
var tenOfSpades = _deck.Peek(48);
|
||||
Assert.AreEqual(new RegularCard(RegularSuit.Hearts, RegularValue.Ace), ace);
|
||||
Assert.AreEqual(new RegularCard(RegularSuit.Spades, RegularValue.Ten), tenOfSpades);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestMultipleDeck()
|
||||
{
|
||||
var quadDeck = new MultipleRegularDeck(4);
|
||||
var count = quadDeck.TotalCount;
|
||||
|
||||
Assert.AreEqual(52 * 4, count);
|
||||
|
||||
var card = quadDeck.Peek(54);
|
||||
Assert.AreEqual(new RegularCard(RegularSuit.Hearts, RegularValue.Three), card);
|
||||
}
|
||||
}
|
@@ -1,5 +1,5 @@
|
||||
using System.Threading.Tasks;
|
||||
using NadekoBot.Common;
|
||||
using Nadeko.Common;
|
||||
using NUnit.Framework;
|
||||
using NUnit.Framework.Internal;
|
||||
|
||||
|
@@ -9,10 +9,8 @@ namespace NadekoBot.Tests
|
||||
{
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
Console.OutputEncoding = Encoding.UTF8;
|
||||
}
|
||||
|
||||
=> Console.OutputEncoding = Encoding.UTF8;
|
||||
|
||||
[Test]
|
||||
public void Utf8CodepointsToEmoji()
|
||||
{
|
||||
|
@@ -1,11 +1,11 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Ayu.Discord.Voice
|
||||
namespace NadekoBot.Voice
|
||||
{
|
||||
internal static unsafe class LibOpus
|
||||
{
|
||||
public const string OPUS = "opus";
|
||||
public const string OPUS = "data/lib/opus";
|
||||
|
||||
[DllImport(OPUS, EntryPoint = "opus_encoder_create", CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern IntPtr CreateEncoder(int Fs, int channels, int application, out OpusError error);
|
||||
@@ -64,9 +64,7 @@ namespace Ayu.Discord.Voice
|
||||
}
|
||||
|
||||
public int SetControl(OpusCtl ctl, int value)
|
||||
{
|
||||
return LibOpus.EncoderCtl(_encoderPtr, ctl, value);
|
||||
}
|
||||
=> LibOpus.EncoderCtl(_encoderPtr, ctl, value);
|
||||
|
||||
public int Encode(Span<byte> input, byte[] output)
|
||||
{
|
||||
@@ -84,9 +82,7 @@ namespace Ayu.Discord.Voice
|
||||
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
LibOpus.DestroyEncoder(_encoderPtr);
|
||||
}
|
||||
=> LibOpus.DestroyEncoder(_encoderPtr);
|
||||
}
|
||||
|
||||
public enum OpusCtl
|
@@ -1,11 +1,11 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Ayu.Discord.Voice
|
||||
namespace NadekoBot.Voice
|
||||
{
|
||||
internal static unsafe class Sodium
|
||||
{
|
||||
private const string SODIUM = "libsodium";
|
||||
private const string SODIUM = "data/lib/libsodium";
|
||||
|
||||
[DllImport(SODIUM, EntryPoint = "crypto_secretbox_easy", CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern int SecretBoxEasy(byte* output, byte* input, long inputLength, byte* nonce, byte* secret);
|
@@ -1,6 +1,6 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Ayu.Discord.Voice.Models
|
||||
namespace NadekoBot.Voice.Models
|
||||
{
|
||||
public sealed class SelectProtocol
|
||||
{
|
@@ -1,6 +1,6 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Ayu.Discord.Voice.Models
|
||||
namespace NadekoBot.Voice.Models
|
||||
{
|
||||
public sealed class VoiceHello
|
||||
{
|
@@ -1,6 +1,6 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Ayu.Discord.Voice.Models
|
||||
namespace NadekoBot.Voice.Models
|
||||
{
|
||||
public sealed class VoiceIdentify
|
||||
{
|
@@ -1,6 +1,6 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Ayu.Discord.Voice.Models
|
||||
namespace NadekoBot.Voice.Models
|
||||
{
|
||||
public sealed class VoiceReady
|
||||
{
|
@@ -1,6 +1,6 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Ayu.Discord.Voice.Models
|
||||
namespace NadekoBot.Voice.Models
|
||||
{
|
||||
public sealed class VoiceResume
|
||||
{
|
@@ -1,6 +1,6 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Ayu.Discord.Voice.Models
|
||||
namespace NadekoBot.Voice.Models
|
||||
{
|
||||
public sealed class VoiceSessionDescription
|
||||
{
|
@@ -1,7 +1,7 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
|
||||
namespace Ayu.Discord.Voice.Models
|
||||
namespace NadekoBot.Voice.Models
|
||||
{
|
||||
public sealed class VoiceSpeaking
|
||||
{
|
@@ -5,10 +5,11 @@
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<NoWarn>CS8632</NoWarn>
|
||||
<Version>1.0.2</Version>
|
||||
<RootNamespace>NadekoBot.Voice</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||
<PackageReference Include="Serilog" Version="2.10.0" />
|
||||
<PackageReference Include="System.Threading.Channels" Version="5.0.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="Serilog" Version="3.1.1" />
|
||||
<PackageReference Include="System.Threading.Channels" Version="8.0.0" />
|
||||
</ItemGroup>
|
||||
</Project>
|
@@ -1,14 +1,13 @@
|
||||
using System;
|
||||
#nullable enable
|
||||
using System;
|
||||
using System.Buffers;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
#nullable enable
|
||||
namespace Ayu.Discord.Voice
|
||||
namespace NadekoBot.Voice
|
||||
{
|
||||
public sealed class PoopyBufferImmortalized : ISongBuffer
|
||||
{
|
||||
private readonly int _frameSize;
|
||||
private readonly byte[] _buffer;
|
||||
private readonly byte[] _outputArray;
|
||||
private CancellationToken _cancellationToken;
|
||||
@@ -27,7 +26,6 @@ namespace Ayu.Discord.Voice
|
||||
|
||||
public PoopyBufferImmortalized(int frameSize)
|
||||
{
|
||||
_frameSize = frameSize;
|
||||
_buffer = ArrayPool<byte>.Shared.Rent(1_000_000);
|
||||
_outputArray = new byte[frameSize];
|
||||
|
||||
@@ -36,9 +34,7 @@ namespace Ayu.Discord.Voice
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
_isStopped = true;
|
||||
}
|
||||
=> _isStopped = true;
|
||||
|
||||
// this method needs a rewrite
|
||||
public Task<bool> BufferAsync(ITrackDataSource source, CancellationToken cancellationToken)
|
||||
@@ -129,9 +125,7 @@ namespace Ayu.Discord.Voice
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
ArrayPool<byte>.Shared.Return(_buffer);
|
||||
}
|
||||
=> ArrayPool<byte>.Shared.Return(_buffer);
|
||||
|
||||
public void Reset()
|
||||
{
|
@@ -9,7 +9,7 @@ namespace Ayu.Discord.Gateway
|
||||
{
|
||||
public class SocketClient : IDisposable
|
||||
{
|
||||
private ClientWebSocket? _ws = null;
|
||||
private ClientWebSocket? _ws;
|
||||
|
||||
public event Func<byte[], Task>? PayloadReceived = delegate { return Task.CompletedTask; };
|
||||
public event Func<string, Task>? WebsocketClosed = delegate { return Task.CompletedTask; };
|
||||
@@ -22,7 +22,7 @@ namespace Ayu.Discord.Gateway
|
||||
var bufferWriter = new ArrayBufferWriter<byte>(CHUNK_SIZE);
|
||||
try
|
||||
{
|
||||
using (_ws = new ClientWebSocket())
|
||||
using (_ws = new())
|
||||
{
|
||||
await _ws.ConnectAsync(url, cancel).ConfigureAwait(false);
|
||||
// WebsocketConnected!.Invoke(this);
|
||||
@@ -94,10 +94,10 @@ namespace Ayu.Discord.Gateway
|
||||
var ws = _ws;
|
||||
if (ws is null)
|
||||
throw new WebSocketException("Websocket is disconnected.");
|
||||
for (int i = 0; i < data.Length; i += 4096)
|
||||
for (var i = 0; i < data.Length; i += 4096)
|
||||
{
|
||||
var count = i + 4096 > data.Length ? data.Length - i : 4096;
|
||||
await ws.SendAsync(new ArraySegment<byte>(data, i, count),
|
||||
await ws.SendAsync(new(data, i, count),
|
||||
WebSocketMessageType.Text,
|
||||
i + count >= data.Length,
|
||||
CancellationToken.None).ConfigureAwait(false);
|
||||
@@ -115,7 +115,7 @@ namespace Ayu.Discord.Gateway
|
||||
if (ws is null)
|
||||
throw new WebSocketException("Websocket is disconnected.");
|
||||
|
||||
await ws.SendAsync(new ArraySegment<byte>(data, 0, data.Length),
|
||||
await ws.SendAsync(new(data, 0, data.Length),
|
||||
WebSocketMessageType.Binary,
|
||||
true,
|
||||
CancellationToken.None).ConfigureAwait(false);
|
||||
@@ -123,7 +123,7 @@ namespace Ayu.Discord.Gateway
|
||||
|
||||
public async Task<bool> CloseAsync(string msg = "Stop")
|
||||
{
|
||||
if (_ws != null && _ws.State != WebSocketState.Closed)
|
||||
if (_ws is not null && _ws.State != WebSocketState.Closed)
|
||||
{
|
||||
try
|
||||
{
|
@@ -4,7 +4,7 @@ using System.Diagnostics;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Ayu.Discord.Voice
|
||||
namespace NadekoBot.Voice
|
||||
{
|
||||
public interface ISongBuffer : IDisposable
|
||||
{
|
@@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System.Buffers;
|
||||
|
||||
namespace Ayu.Discord.Voice
|
||||
namespace NadekoBot.Voice
|
||||
{
|
||||
public sealed class VoiceClient : IDisposable
|
||||
{
|
||||
@@ -37,7 +37,7 @@ namespace Ayu.Discord.Voice
|
||||
this.channels = (int) channels;
|
||||
this.bitDepth = (int) bitDepthEnum;
|
||||
|
||||
this.Encoder = new LibOpusEncoder(this.sampleRate, this.channels, this.bitRate, this.frameDelay);
|
||||
this.Encoder = new(this.sampleRate, this.channels, this.bitRate, this.frameDelay);
|
||||
|
||||
Encode = bitDepthEnum switch
|
||||
{
|
||||
@@ -58,7 +58,6 @@ namespace Ayu.Discord.Voice
|
||||
_arrayPool = ArrayPool<byte>.Shared;
|
||||
}
|
||||
|
||||
// todo 3.2 direct opus streams
|
||||
public int SendPcmFrame(VoiceGateway gw, Span<byte> data, int offset, int count)
|
||||
{
|
||||
var secretKey = gw.SecretKey;
|
||||
@@ -148,7 +147,7 @@ namespace Ayu.Discord.Voice
|
||||
Buffer.BlockCopy(nonce, 0, rtpData, rtpDataLength - 4, 4);
|
||||
|
||||
gw.SendRtpData(rtpData, rtpDataLength);
|
||||
// todo 3.2 When there's a break in the sent data,
|
||||
// FUTURE When there's a break in the sent data,
|
||||
// the packet transmission shouldn't simply stop.
|
||||
// Instead, send five frames of silence (0xF8, 0xFF, 0xFE)
|
||||
// before stopping to avoid unintended Opus interpolation
|
||||
@@ -163,9 +162,7 @@ namespace Ayu.Discord.Voice
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Encoder.Dispose();
|
||||
}
|
||||
=> Encoder.Dispose();
|
||||
}
|
||||
|
||||
public enum SendPcmError
|
@@ -1,4 +1,4 @@
|
||||
using Ayu.Discord.Voice.Models;
|
||||
using NadekoBot.Voice.Models;
|
||||
using Discord.Models.Gateway;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Serilog;
|
||||
@@ -12,7 +12,7 @@ using System.Threading.Tasks;
|
||||
using Ayu.Discord.Gateway;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Ayu.Discord.Voice
|
||||
namespace NadekoBot.Voice
|
||||
{
|
||||
public class VoiceGateway
|
||||
{
|
||||
@@ -46,16 +46,16 @@ namespace Ayu.Discord.Voice
|
||||
private IPEndPoint? _udpEp;
|
||||
|
||||
public uint Ssrc { get; private set; }
|
||||
public string Ip { get; private set; } = "";
|
||||
public string Ip { get; private set; } = string.Empty;
|
||||
public int Port { get; private set; } = 0;
|
||||
public byte[] SecretKey { get; private set; } = Array.Empty<byte>();
|
||||
public string Mode { get; private set; } = "";
|
||||
public string Mode { get; private set; } = string.Empty;
|
||||
public ushort Sequence { get; set; }
|
||||
public uint NonceSequence { get; set; }
|
||||
public uint Timestamp { get; set; }
|
||||
public string MyIp { get; private set; } = "";
|
||||
public string MyIp { get; private set; } = string.Empty;
|
||||
public ushort MyPort { get; private set; }
|
||||
private bool shouldResume = false;
|
||||
private bool _shouldResume;
|
||||
|
||||
private readonly CancellationTokenSource _stopCancellationSource;
|
||||
private readonly CancellationToken _stopCancellationToken;
|
||||
@@ -74,21 +74,21 @@ namespace Ayu.Discord.Voice
|
||||
//Log.Information("g: {GuildId} u: {UserId} sess: {Session} tok: {Token} ep: {Endpoint}",
|
||||
// guildId, userId, session, token, endpoint);
|
||||
|
||||
this._websocketUrl = new Uri($"wss://{_endpoint.Replace(":80", "")}?v=4");
|
||||
this._channel = Channel.CreateUnbounded<QueueItem>(new UnboundedChannelOptions
|
||||
this._websocketUrl = new($"wss://{_endpoint.Replace(":80", "")}?v=4");
|
||||
this._channel = Channel.CreateUnbounded<QueueItem>(new()
|
||||
{
|
||||
SingleReader = true,
|
||||
SingleWriter = false,
|
||||
AllowSynchronousContinuations = false,
|
||||
});
|
||||
|
||||
ConnectingFinished = new TaskCompletionSource<bool>();
|
||||
ConnectingFinished = new();
|
||||
|
||||
_rng = new Random();
|
||||
_rng = new();
|
||||
|
||||
_ws = new SocketClient();
|
||||
_udpClient = new UdpClient();
|
||||
_stopCancellationSource = new CancellationTokenSource();
|
||||
_ws = new();
|
||||
_udpClient = new();
|
||||
_stopCancellationSource = new();
|
||||
_stopCancellationToken = _stopCancellationSource.Token;
|
||||
|
||||
_ws.PayloadReceived += _ws_PayloadReceived;
|
||||
@@ -123,6 +123,8 @@ namespace Ayu.Discord.Voice
|
||||
private async Task _ws_PayloadReceived(byte[] arg)
|
||||
{
|
||||
var payload = JsonConvert.DeserializeObject<VoicePayload>(Encoding.UTF8.GetString(arg));
|
||||
if (payload is null)
|
||||
return;
|
||||
try
|
||||
{
|
||||
//Log.Information("Received payload with opcode {OpCode}", payload.OpCode);
|
||||
@@ -138,7 +140,7 @@ namespace Ayu.Discord.Voice
|
||||
case VoiceOpCode.Ready:
|
||||
var ready = payload.Data.ToObject<VoiceReady>();
|
||||
await HandleReadyAsync(ready!);
|
||||
shouldResume = true;
|
||||
_shouldResume = true;
|
||||
break;
|
||||
case VoiceOpCode.Heartbeat:
|
||||
// sent, not received
|
||||
@@ -161,7 +163,7 @@ namespace Ayu.Discord.Voice
|
||||
await HandleHelloAsync(hello!);
|
||||
break;
|
||||
case VoiceOpCode.Resumed:
|
||||
shouldResume = true;
|
||||
_shouldResume = true;
|
||||
break;
|
||||
case VoiceOpCode.ClientDisconnect:
|
||||
break;
|
||||
@@ -183,7 +185,7 @@ namespace Ayu.Discord.Voice
|
||||
hbt?.Change(Timeout.Infinite, Timeout.Infinite);
|
||||
_heartbeatTimer = null;
|
||||
|
||||
if (!_stopCancellationToken.IsCancellationRequested && shouldResume)
|
||||
if (!_stopCancellationToken.IsCancellationRequested && _shouldResume)
|
||||
{
|
||||
_ = _ws.RunAndBlockAsync(_websocketUrl, _stopCancellationToken);
|
||||
return Task.CompletedTask;
|
||||
@@ -199,9 +201,7 @@ namespace Ayu.Discord.Voice
|
||||
}
|
||||
|
||||
public void SendRtpData(byte[] rtpData, int length)
|
||||
{
|
||||
_udpClient.Send(rtpData, length, _udpEp);
|
||||
}
|
||||
=> _udpClient.Send(rtpData, length, _udpEp);
|
||||
|
||||
private Task HandleSessionDescription(VoiceSessionDescription sd)
|
||||
{
|
||||
@@ -215,8 +215,8 @@ namespace Ayu.Discord.Voice
|
||||
|
||||
private Task ResumeAsync()
|
||||
{
|
||||
shouldResume = false;
|
||||
return SendCommandPayloadAsync(new VoicePayload
|
||||
_shouldResume = false;
|
||||
return SendCommandPayloadAsync(new()
|
||||
{
|
||||
OpCode = VoiceOpCode.Resume,
|
||||
Data = JToken.FromObject(new VoiceResume
|
||||
@@ -234,23 +234,28 @@ namespace Ayu.Discord.Voice
|
||||
|
||||
//Log.Information("Received ready {GuildId}, {Session}, {Token}", guildId, session, token);
|
||||
|
||||
_udpEp = new IPEndPoint(IPAddress.Parse(ready.Ip), ready.Port);
|
||||
_udpEp = new(IPAddress.Parse(ready.Ip), ready.Port);
|
||||
|
||||
var ssrcBytes = BitConverter.GetBytes(Ssrc);
|
||||
var ipDiscoveryData = new byte[70];
|
||||
Buffer.BlockCopy(ssrcBytes, 0, ipDiscoveryData, 0, ssrcBytes.Length);
|
||||
Array.Reverse(ssrcBytes);
|
||||
var ipDiscoveryData = new byte[74];
|
||||
Buffer.BlockCopy(ssrcBytes, 0, ipDiscoveryData, 4, ssrcBytes.Length);
|
||||
ipDiscoveryData[0] = 0x00;
|
||||
ipDiscoveryData[1] = 0x01;
|
||||
ipDiscoveryData[2] = 0x00;
|
||||
ipDiscoveryData[3] = 0x46;
|
||||
await _udpClient.SendAsync(ipDiscoveryData, ipDiscoveryData.Length, _udpEp);
|
||||
while (true)
|
||||
{
|
||||
var buffer = _udpClient.Receive(ref _udpEp);
|
||||
|
||||
if (buffer.Length == 70)
|
||||
if (buffer.Length == 74)
|
||||
{
|
||||
//Log.Information("Received IP discovery data.");
|
||||
|
||||
var myIp = Encoding.UTF8.GetString(buffer, 4, buffer.Length - 8);
|
||||
var myIp = Encoding.UTF8.GetString(buffer, 8, buffer.Length - 10);
|
||||
MyIp = myIp.TrimEnd('\0');
|
||||
MyPort = BitConverter.ToUInt16(buffer, buffer.Length - 2);
|
||||
MyPort = (ushort)((buffer[^2] << 8) | buffer[^1]);
|
||||
|
||||
//Log.Information("{MyIp}:{MyPort}", MyIp, MyPort);
|
||||
|
||||
@@ -265,12 +270,12 @@ namespace Ayu.Discord.Voice
|
||||
private Task HandleHelloAsync(VoiceHello data)
|
||||
{
|
||||
_receivedAck = true;
|
||||
_heartbeatTimer = new Timer(async _ =>
|
||||
_heartbeatTimer = new(async _ =>
|
||||
{
|
||||
await SendHeartbeatAsync();
|
||||
}, default, data.HeartbeatInterval, data.HeartbeatInterval);
|
||||
|
||||
if (shouldResume)
|
||||
if (_shouldResume)
|
||||
{
|
||||
return ResumeAsync();
|
||||
}
|
||||
@@ -279,7 +284,7 @@ namespace Ayu.Discord.Voice
|
||||
}
|
||||
|
||||
private Task IdentifyAsync()
|
||||
=> SendCommandPayloadAsync(new VoicePayload
|
||||
=> SendCommandPayloadAsync(new()
|
||||
{
|
||||
OpCode = VoiceOpCode.Identify,
|
||||
Data = JToken.FromObject(new VoiceIdentify
|
||||
@@ -292,13 +297,13 @@ namespace Ayu.Discord.Voice
|
||||
});
|
||||
|
||||
private Task SelectProtocol()
|
||||
=> SendCommandPayloadAsync(new VoicePayload
|
||||
=> SendCommandPayloadAsync(new()
|
||||
{
|
||||
OpCode = VoiceOpCode.SelectProtocol,
|
||||
Data = JToken.FromObject(new SelectProtocol
|
||||
{
|
||||
Protocol = "udp",
|
||||
Data = new SelectProtocol.ProtocolData()
|
||||
Data = new()
|
||||
{
|
||||
Address = MyIp,
|
||||
Port = MyPort,
|
||||
@@ -319,7 +324,7 @@ namespace Ayu.Discord.Voice
|
||||
}
|
||||
|
||||
_receivedAck = false;
|
||||
await SendCommandPayloadAsync(new VoicePayload
|
||||
await SendCommandPayloadAsync(new()
|
||||
{
|
||||
OpCode = VoiceOpCode.Heartbeat,
|
||||
Data = JToken.FromObject(_rng.Next())
|
||||
@@ -327,7 +332,7 @@ namespace Ayu.Discord.Voice
|
||||
}
|
||||
|
||||
public Task SendSpeakingAsync(VoiceSpeaking.State speaking)
|
||||
=> SendCommandPayloadAsync(new VoicePayload
|
||||
=> SendCommandPayloadAsync(new()
|
||||
{
|
||||
OpCode = VoiceOpCode.Speaking,
|
||||
Data = JToken.FromObject(new VoiceSpeaking
|
||||
@@ -341,7 +346,7 @@ namespace Ayu.Discord.Voice
|
||||
public Task StopAsync()
|
||||
{
|
||||
Started = false;
|
||||
shouldResume = false;
|
||||
_shouldResume = false;
|
||||
if(!_stopCancellationSource.IsCancellationRequested)
|
||||
try { _stopCancellationSource.Cancel(); } catch { }
|
||||
return _ws.CloseAsync("Stopped by the user.");
|
||||
@@ -367,4 +372,4 @@ namespace Ayu.Discord.Voice
|
||||
await complete.Task;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
25
src/NadekoBot.VotesApi/.dockerignore
Normal file
25
src/NadekoBot.VotesApi/.dockerignore
Normal file
@@ -0,0 +1,25 @@
|
||||
**/.dockerignore
|
||||
**/.env
|
||||
**/.git
|
||||
**/.gitignore
|
||||
**/.project
|
||||
**/.settings
|
||||
**/.toolstarget
|
||||
**/.vs
|
||||
**/.vscode
|
||||
**/.idea
|
||||
**/*.*proj.user
|
||||
**/*.dbmdl
|
||||
**/*.jfm
|
||||
**/azds.yaml
|
||||
**/bin
|
||||
**/charts
|
||||
**/docker-compose*
|
||||
**/Dockerfile*
|
||||
**/node_modules
|
||||
**/npm-debug.log
|
||||
**/obj
|
||||
**/secrets.dev.yaml
|
||||
**/values.dev.yaml
|
||||
LICENSE
|
||||
README.md
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user