mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-10 17:28:27 -04:00
Compare commits
598 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
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 |
@@ -1,16 +1,11 @@
|
||||
# Ignore all files
|
||||
*
|
||||
|
||||
# Use Nadeko.Medusa project
|
||||
!src/Nadeko.Medusa/**
|
||||
# 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
|
||||
|
5
.gitignore
vendored
5
.gitignore
vendored
@@ -1,8 +1,9 @@
|
||||
#Manually added files
|
||||
|
||||
src/NadekoBot/data/last_known_version.txt
|
||||
|
||||
# medusa stuff
|
||||
!src/NadekoBot/data/medusae/medusa.yml
|
||||
src/NadekoBot/data/medusae/**
|
||||
src/NadekoBot/data/medusae/
|
||||
|
||||
# other
|
||||
|
||||
|
@@ -1,47 +1,78 @@
|
||||
image: mcr.microsoft.com/dotnet/sdk:6.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:
|
||||
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
|
||||
@@ -50,9 +81,14 @@ release:
|
||||
- if: $CI_COMMIT_TAG
|
||||
script:
|
||||
- |
|
||||
release-cli create --name "NadekoBot v$CI_COMMIT_TAG" --description "## [Changelog](https://gitlab.com/Kwoth/nadekobot/-/blob/v4/CHANGELOG.md#$(echo "$CI_COMMIT_TAG" | sed "s/\.//g")-$(date +%d%m%Y))" --tag-name $CI_COMMIT_TAG \
|
||||
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\":\"${WIN_X64_RELEASE}\",\"url\":\"${PACKAGE_REGISTRY_URL}/${WIN_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,45 +98,44 @@ test:
|
||||
- "cd $tests_path"
|
||||
- "dotnet test"
|
||||
|
||||
publish-windows:
|
||||
stage: publish-windows
|
||||
build-installer:
|
||||
stage: build-installer
|
||||
rules:
|
||||
- if: '$CI_COMMIT_TAG'
|
||||
- if: "$CI_COMMIT_TAG"
|
||||
image: scottyhardy/docker-wine
|
||||
before_script:
|
||||
- choco install dotnet-6.0-runtime -y
|
||||
- choco install dotnet-6.0-sdk -y
|
||||
- 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
|
||||
- dotnet publish -c Release --runtime win7-x64 /p:Version=$CI_COMMIT_TAG src/NadekoBot
|
||||
- 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:
|
||||
- windows
|
||||
- saas-windows-medium-amd64
|
||||
|
||||
upload-windows-updater-release:
|
||||
stage: upload-windows-updater-release
|
||||
publish-medusa-package:
|
||||
stage: publish-medusa-package
|
||||
allow_failure: true
|
||||
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"
|
||||
- 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:
|
||||
@@ -113,13 +148,13 @@ docker-build:
|
||||
tag=""
|
||||
echo "Running on default branch '$CI_DEFAULT_BRANCH': tag = 'latest'"
|
||||
else
|
||||
tag=":$CI_COMMIT_REF_SLUG"
|
||||
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
|
||||
- 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
|
815
CHANGELOG.md
815
CHANGELOG.md
@@ -1,8 +1,765 @@
|
||||
# Changelog
|
||||
|
||||
Experimental changelog. Mostly based on [keepachangelog](https://keepachangelog.com/en/1.0.0/) except date format. a-c-f-r-o
|
||||
Mostly based on [keepachangelog](https://keepachangelog.com/en/1.0.0/) except date format. a-c-f-r-o
|
||||
|
||||
## Unreleased
|
||||
## [5.0.5] - 11.05.2024
|
||||
|
||||
### Fixed
|
||||
|
||||
- `%server.members%` placeholder fixed
|
||||
- `.say #channel <message>` should now be working properly again
|
||||
- `.repeat`, `.greet`, `.bye` and `.boost` command can now once again mention anyone
|
||||
|
||||
## [5.0.4] - 10.05.2024
|
||||
|
||||
### Added
|
||||
|
||||
- Added `.shopadd command` You can now sell commands in the shop. The command will execute as if you were the one running it when someone buys it
|
||||
- type `.h .shopadd` for more info
|
||||
- Added `.stickyroles` Users leaving the server will have their roles saved to the database and reapplied if they rejoin within 30 days.
|
||||
- Giveaway commands
|
||||
- `.ga start <duration> <text>` starts the giveway with the specified duration and message (prize). You may have up to 5 giveaways on the server at once
|
||||
- `.ga end <id>` prematurely ends the giveaway and selects a winner
|
||||
- `.ga cancel <id>` cancels the giveaway and doesn't select a winner
|
||||
- `.ga list` lists active giveaways on the current server
|
||||
- `.ga reroll <id>` rerolls the winner on the completed giveaway. This only works for 24 hours after the giveaway has ended, or until the bot restarts.
|
||||
- Users can join the giveaway by adding a :tada: reaction
|
||||
- Added Todo Commands
|
||||
- `.todo add <name>` - adds a new todo
|
||||
- `.todo delete <id>` - deletes a todo item
|
||||
- `.todo done <id>` - completes a todo (marks it with a checkmark)
|
||||
- `.todo list` - lists all todos
|
||||
- `.todo edit <id> <new message>` - edits a todo item message
|
||||
- `.todo show <id>` - Shows the text of the specified todo item
|
||||
- In addition to that, there are also Todo archive commands
|
||||
- `.todo archive add <name>` - adds all current todos (completed and not completed) to the archived list, your current todo list will become cleared
|
||||
- `.todo archive list` - lists all your archived todo lists
|
||||
- `.todo archive show <id>` - shows the todo items from one of your archived lists
|
||||
- `.todo archive delete <id>` - deletes and archived todo list
|
||||
- Added `.queufairplay` / `.qfp` (music feature) re-added but it works differently
|
||||
- Once you run it, it will reorganize currently queued songs so that they're in a fair order.
|
||||
- Added `.clubrename` command to uh rename your club
|
||||
- For self-hosters:
|
||||
- Added `.sqlselectcsv` which will return results in a csv file instead of an embed.
|
||||
- You can set whether nadeko ignores other bots in `bot.yml`
|
||||
- You can set shop sale cut in `gambling.yml`
|
||||
- Added a page parameter to `.feedlist`
|
||||
- Added seconds/sec/s to `.convert` command
|
||||
- Added `.prunecancel` to cancel an active prune
|
||||
- Added progress reporting when using `.prune`.
|
||||
- Added audit log reason for `.setrole` and some other features
|
||||
|
||||
### Changed
|
||||
|
||||
- Users who have manage messages perm in the channel will now be excluded from link and invite filtering (`.sfi` and `.sfl`)
|
||||
- `.send` command should work consistently and correctly now. You can have targets from other shards too. The usage has been changed. refer to `.h .send` for more info
|
||||
- `.serverinfo` no longer takes a server name. It only takes an id or no arguments
|
||||
- You can now target a different channel with .repeat
|
||||
- `.cmds <module name>`, `.cmds <group name` and `.mdls` looks better
|
||||
- The bot will now send a discord Reply to every command
|
||||
- `.queuesearch` / `.qs` will now show the results with respective video thumbnails
|
||||
- A lot of code cleanup (still a lot to be done) and Quality of Life improvements
|
||||
- `.inrole` will now show mentions primarily, and use a spoiler to show usernames
|
||||
|
||||
### Fixed
|
||||
|
||||
- `.feed` should now correctly accept (and show) the message which can be passed as the third parameter
|
||||
- `.say` will now correctly report errors if the user or the bot don't have sufficent perms to send a message in the targeted channel
|
||||
- Fixed `.invitelist` not paginating correctly
|
||||
- `.serverinfo` will now correctly work for other shards
|
||||
- `.send` will now correctly work for other shards
|
||||
- `.translate` command will no longer fail if the user capitalizes the language name
|
||||
- Fixed xp card user avatar not showing for some users
|
||||
|
||||
### Removed
|
||||
|
||||
- `.poll` commands removed as discord added polls
|
||||
- `.scpl` and other music soundcloud commands have been removed as soundcloud isn't issuing new api tokens for years now
|
||||
- Removed a lot of useless and nsfw commands
|
||||
- Removed log voice presence TTS
|
||||
- Cleanup: Removed a lot of obsolete aliases from aliases.yml
|
||||
|
||||
## [4.3.22] - 23.04.2024
|
||||
|
||||
### Added
|
||||
- Added `.setbanner` command (thx cata)
|
||||
|
||||
### Fixed
|
||||
- Fixed pagination error due to a missing emoji
|
||||
|
||||
|
||||
## [4.3.21] - 19.04.2024
|
||||
|
||||
### Fixed
|
||||
- Possible fix for a duplicate in `.h bank`
|
||||
- Fixed `.stock` command
|
||||
- Fixed `.clubapply` and `.clubaccept`
|
||||
- Removed some redundant discriminators
|
||||
|
||||
## [4.3.20] - 20.01.2024
|
||||
|
||||
### Fixed
|
||||
- Fixed `.config searches followedStreams.maxCount` not working
|
||||
|
||||
## [4.3.19] - 20.01.2024
|
||||
|
||||
### Added
|
||||
- Added `followedStreams.maxCount` to `searches.yml` which lets bot owners change the default of 10 per server
|
||||
|
||||
### Changed
|
||||
- Improvements to GPT ChatterBot (thx alexandra)
|
||||
- Add a personality prompt to tweak the way chatgpt bot behaves
|
||||
- Added Chat history support to chatgpt ChatterBot
|
||||
- Chatgpt token usage now correctly calculated
|
||||
- More chatgpt configs in `games.yml`
|
||||
|
||||
## [4.3.18] - 26.12.2023
|
||||
|
||||
### Added
|
||||
|
||||
- Added `.cacheusers` command (thx Kotz)
|
||||
- Added `.clubreject` which lets you reject club applications
|
||||
|
||||
### Changed
|
||||
|
||||
- Updated discord lib, there should be less console errors now
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed `icon_url` when using `.showembed`
|
||||
- Fixed `.quoteshow` not showing sometimes (thx Cata)
|
||||
- Notifications will no longer be sent if dms are off when using `.give`
|
||||
- Users should no longer be able to apply to clubs while in a club already (especially not to the same club they're already in)
|
||||
|
||||
### Removed
|
||||
|
||||
- `.revimg` and `.revav` as google removed reverse image search
|
||||
|
||||
## [4.3.17] - 06.09.2023
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fix to waifu gifts being character limited
|
||||
- Fixes UserUpdated and UserPresence not correctly ignoring users that are logignored
|
||||
- Added Trim() to activity names since apparently some activities have trailing spaces.
|
||||
|
||||
## [4.3.16] - 24.05.2023
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed missing events from `.logevents`
|
||||
- Fixed `.log` thread deleted and thread created events not working properly
|
||||
|
||||
## [4.3.15] - 21.05.2023
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed -w 0 in trivia
|
||||
- Fixed `.rps` amount field in the response
|
||||
- Fixed `.showembed` output
|
||||
- Fixed bank award's incorrect output message
|
||||
|
||||
## [4.3.14] - 02.04.2023
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed voice hearbeat issue
|
||||
- `.banktake` had ok/error responses flipped. No functional change
|
||||
- PermRole should deny messages in threads todo
|
||||
- Fixed chucknorris jokes
|
||||
- `.logserver` will now
|
||||
|
||||
## [4.3.13] - 20.02.2023
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed `.log userpresence`
|
||||
- `.q` will now use `yt-dlp` if anything other than `ytProvider: Ytdl` is set in `data/searches.yml`
|
||||
- Fixed Title links on some embeds
|
||||
|
||||
## [4.3.12] - 12.02.2023
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed `.betstats` not working on european locales
|
||||
- Timed `.ban` will work on users who are not in the server
|
||||
- Fixed some bugs in the medusa system
|
||||
|
||||
## [4.3.11] - 21.01.2023
|
||||
|
||||
### Added
|
||||
|
||||
- Added `.doas` Bot owner only command
|
||||
- Added `.stickeradd` command
|
||||
|
||||
### Changed
|
||||
|
||||
- `.waifuinfo` optimized
|
||||
- You can now specify an optional custom message in `.feed` and `.yun` which will be posted along with an update
|
||||
- Greet/bye messages will now get disabled if they're set to a deleted/unknown channel
|
||||
- Updated response strings
|
||||
- `.translate` now supports many more languages
|
||||
- `.translangs` prettier output
|
||||
|
||||
### Fixed
|
||||
|
||||
- Added logging for thread events
|
||||
- Fixed a bug for `.quotedeleteauthor` causing the executing user to delete own messages
|
||||
- Fixed TimeOut punishment not alklowing duration
|
||||
- Fixed a nullref in streamrole service
|
||||
- Fixed some potential causes for ratelimit due to default message retry settings
|
||||
- Fixed a patron rewards bug caused by monthly donation checking not accounting for year increase
|
||||
- Fixed a patron rewards bug for users who connected the same discord account with multiple patreon accounts
|
||||
- `.deletecurrency` will now also reset banked currency
|
||||
- Fixed DMHelpText reply
|
||||
- `.h` command show now properly show both channel and server user permission requirements
|
||||
- Many fixes and improvements to medusa system
|
||||
- Fixed trivia --nohint
|
||||
- `.joinrace` will no longer fail if the user isn't in the database yet
|
||||
|
||||
## [4.3.10] - 10.11.2022
|
||||
|
||||
### Added
|
||||
|
||||
- `.filterlist` / `.fl` command which lists link and invite filtering channels and status
|
||||
- Added support for `%target%` placeholder in `.alias` command
|
||||
- Added .forwardtochannel which will forward messages to the current channel. It has lower priority than fwtoall
|
||||
- Added .exprtoggleglobal / .extg which can be used to toggle usage of global expressions on the server
|
||||
|
||||
### Changed
|
||||
|
||||
- .meload and .meunload are now case sensitive. Previously loaded medusae may need to be reloaded or data/medusae/medusa.yml may need to be edited manually
|
||||
- Several club related command have their error messages improved
|
||||
- Updated help text for .antispam and .antiraid
|
||||
- You can now specify time and date (time is optional) in `.remind` command instead of relative time, in the format `HH:mm dd.MM.YYYY`
|
||||
- OwnerId will be automatically added to `creds.yml` at bot startup if it's missing
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed `.cmdcd` console error
|
||||
- Fixed an error when currency is add per xp
|
||||
- Fixed an issue preventing execution of expressions starting with @Bot when cleverbot is enabled on the server
|
||||
- Fixed `.feedadd`
|
||||
- Fixed `.prune @target` not working
|
||||
- Medusa modules (sneks) should now inherit medusa description when listed in .mdls command
|
||||
- Fixed command cooldown calculation
|
||||
|
||||
## [4.3.9] - 12.10.2022
|
||||
|
||||
### Added
|
||||
|
||||
- `.betstats` shows sum of all bets, payouts and the payout rate in %. Updates once an hour
|
||||
|
||||
### Changed
|
||||
|
||||
- `.betstats` looks way better (except on Mac)
|
||||
- `.feedadd` errors clarified and separated in individual error messages for each issue.
|
||||
- `.clubban` and `.clubunban` errors clarified and separated in individual error messages for each issue.
|
||||
- `.clubapply` better error messages
|
||||
|
||||
### Fixed
|
||||
|
||||
- `.timely` 'Remind' button fixed in DMs
|
||||
- `.cmdcd` database bugs fixed
|
||||
- Fixed bugged mysql and postgresql migrations
|
||||
- Fixed issues with lodaing medusae due to strict versioning
|
||||
|
||||
### Removed
|
||||
|
||||
- `.slotstats` Superseded by `.betstats`
|
||||
|
||||
## [4.3.8] - 02.10.2022
|
||||
|
||||
### Added
|
||||
|
||||
- Added `.autopublish` command which will automatically publish messages posted in the channel.
|
||||
- Added `--after <messageid>` option to prune which will make prune only delete messages after the specified message id.
|
||||
|
||||
### Changed
|
||||
|
||||
- `.prune` options `--after` and `--safe` are now proper command options, and will show in .h help
|
||||
- `.cmdcd` code mostly rewritten, slight QoL improvements.
|
||||
- Clarified `.remind` permission requirements in help text
|
||||
- `.cmdcds` looks a little better, and is paginated
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed trivia bugs
|
||||
- Fixed `.yun` not working with channels with underscore in the name
|
||||
|
||||
## [4.3.7] - 14.09.2022
|
||||
|
||||
### Added
|
||||
|
||||
- Added `.exprdelserv` (.exds) to completement .exas. Deletes an expression on the current server and is susceptible to .dpo, unlike .exd
|
||||
- Added `.shopreq` which lets you set role requirement for specific shop items
|
||||
- Added `.shopbuy` alias to `.buy`
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed `.convertlist` showing currencies twice (this may not apply to existing users and it may require you to manually remove all currencies from units.json)
|
||||
|
||||
### Removed
|
||||
|
||||
- Removed `Viewer` field from stream online notification as it is (almost?) always 0.
|
||||
|
||||
## [4.3.6] - 08.09.2022
|
||||
|
||||
### Added
|
||||
|
||||
- Added `.expraddserver` (.exas) which will server as a server-only alternative to '.exa' in case users want to override default Admin permissions with .dpo
|
||||
- Added .banprune command which sets how many days worth of messages will be pruned when bot (soft)bans a person either through a command or another punishment feature.
|
||||
- Added .qdelauth - Delete all quotes by the specified author on this server. If you target yourself - no permission required
|
||||
- Added `.timeout` command
|
||||
- Added an option to award currency based on received xp
|
||||
|
||||
### Changed
|
||||
|
||||
- Reminders now have embed support, but plaintext field is not supported.
|
||||
- User friendlier errors when parsing a number in a command fails
|
||||
|
||||
### Fixed
|
||||
|
||||
- Awarded xp is now correctly used in level up calculations
|
||||
|
||||
## [4.3.5] - 17.08.2022
|
||||
|
||||
### Added
|
||||
|
||||
- Added a 'Use' button when a user already owns an item
|
||||
- Added a 'Pull Again' button to slots
|
||||
- Added `.roleinfo` command
|
||||
- Added `.emojiremove` command
|
||||
- Added `.threadcreate` and `.threaddelete` commands
|
||||
- Added `.bank seize` / `.bank award` owner only commands
|
||||
|
||||
### Changed
|
||||
|
||||
- Running a .timely command early now shows a pending color
|
||||
- .xp system is once again no longer opt in for servers
|
||||
- It's still opt-in for global and requires users to run .xp at least once in order to start gaining global xp
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed users not getting club xp
|
||||
|
||||
## [4.3.4] - 07.08.2022
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed users getting XP out of nowhere while voice xp is enabled
|
||||
|
||||
## [4.3.3] - 06.08.2022
|
||||
|
||||
### Added
|
||||
|
||||
- Added `betroll` option to `.bettest` command
|
||||
- Added `.xpshopbuy` and `.xpshopuse` convenience commands
|
||||
- Added an optional preview url to teh xp shop item config model which will be shown instead of the real Url
|
||||
|
||||
### Changed
|
||||
|
||||
- Updated position of Username and Club name on the .xp card
|
||||
- Improved text visibility on the .xp card
|
||||
|
||||
### Fixed
|
||||
|
||||
- Possibly fixed .trivia not stopping bug
|
||||
- Fixed very low payout rate on `.betroll`
|
||||
- Fixed an issue with youtube song resolver which caused invalid data to be cached
|
||||
- Added client id to the cache key as a potential fix for VoiceXp 'bug'. The solution may be to use different redis instances for each bot, or to switch from botCache: from 'redis' to 'memory' in creds.yml
|
||||
- Bot owner should now be able to buy items from the xpshop when patron requirement is set
|
||||
- Fixed youtube-dl caching invalid data. Please use yt-dlp instead
|
||||
|
||||
## [4.3.2] - 28.07.2022
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed Reaction Roles not working properly with animated emojis
|
||||
- Fixed `.slot` alignment
|
||||
- Fixed `mysql` and `postgresql` reactionrole migration
|
||||
- Fixed repeat loop with `postgresql` db provider
|
||||
- Fixed `.bank withdraw <expression>` will now correctly use bank amount for calculation
|
||||
- [dev] Fixed medusa Reply*LocalizedAsync not working with placeholders
|
||||
|
||||
## [4.3.1] - 27.07.2022
|
||||
|
||||
### Changed
|
||||
|
||||
- Check for updates will run once per hour as it was supposed to
|
||||
|
||||
## [4.3.0] - 27.07.2022
|
||||
|
||||
### Added
|
||||
|
||||
- Added `.bettest` command which lets you test many gambling commands
|
||||
- Better than .slottest
|
||||
- Counts win/loss streaks too
|
||||
- Doesn't count 1x returns as neither wins nor losses
|
||||
- multipliers < 1 are considered losses, > 1 considered wins
|
||||
- Added `.betdraw` command which lets you guess red/black and/or high/low for a random card
|
||||
- They payouts are very good, but seven always loses
|
||||
- Added `.lula` command. Plays the same as `.wof` but looks much nicer, and is easily customizable from gambling.yml without any changes to the sourcecode needed.
|
||||
- Added `.repeatskip` command which makes the next repeat trigger not post anything
|
||||
- Added `.linkonly` which will make the bot only allow link posts in the channel. Exclusive with `.imageonly`
|
||||
- Added release notifications. Bot owners will now receive new release notifications in dms if they have `checkForUpdates` set to `true` in data/bot.yml
|
||||
- You can also configure it via `.conf bot checkfor
|
||||
- updates <true/false>`
|
||||
- Added `.xpshop` which lets bot owners add xp backgrounds and xp frames for sale by configuring `data/xp.yml`
|
||||
- You can also toggle xpshop feature via `.conf xp shop.is_enabled`
|
||||
|
||||
### Changed
|
||||
|
||||
- `.t` Trivia code cleaned up, added ALL pokemon generations
|
||||
|
||||
- `.xpadd` will now work on roles too. It will add the specified xp to each user (visible to the bot) in the role
|
||||
- Improved / cleaned up / modernized how most gambling commands look
|
||||
- `.roll`
|
||||
- `.rolluo`
|
||||
- `.draw`
|
||||
- `.flip`
|
||||
- `.slot`
|
||||
- `.betroll`
|
||||
- `.betflip`
|
||||
- Try them out!
|
||||
- `.draw`, `.betdraw` and some other card commands (not all) will use the new, rewritten deck system
|
||||
- Error will be printed to the console if there's a problem in `.plant`
|
||||
- [dev] Split Nadeko.Common into a separate project
|
||||
- [dev] It will contain classes/utilities which can be shared across different nadeko related projects
|
||||
- [dev] Split Nadeko.Econ into a separate project
|
||||
- [dev] It should be home for the backend any gambling/currency/economy feature
|
||||
- [dev] It will contain most gambling games and any shared logic
|
||||
- [dev] Compliation should take less time and RAM
|
||||
- [dev] No longer using generator and partial methods for commands
|
||||
|
||||
### Fixed
|
||||
|
||||
- `.slot` will now show correct multipliers if they've been modified
|
||||
- Fix patron errors showing up even with permissions disabling the command
|
||||
- Fixed an issue with voice xp breaking xp gain.
|
||||
|
||||
### Removed
|
||||
|
||||
- Removed `.slottest`, replaced by `.bettest`
|
||||
- Removed `.wof`, replaced by `.lula`
|
||||
- [dev] Removed a lot of unused methods
|
||||
- [dev] Removed several unused response strings
|
||||
|
||||
## [4.2.15] - 12.07.2022
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed `.nh*ntai` nsfw command
|
||||
- Xp Freezes may have been fixed
|
||||
- `data/images.yml` should once again support local file paths
|
||||
- Fixed multiword aliases
|
||||
|
||||
## [4.2.14] - 03.07.2022
|
||||
|
||||
### Added
|
||||
|
||||
- Added `.log userwarned` (Logging user warnings)
|
||||
- Claiming `.timely` will now show a button which you can click to set a reminder
|
||||
- Added `%server.icon%` placeholder
|
||||
- Added `warn` punishment action for protection commands (it won't work with `.warnp`)
|
||||
|
||||
### Changed
|
||||
|
||||
- `.log userbanned` will now have a ban reason
|
||||
- When `.die` is used, bot will try to update it's status to `Invisible`
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed elipsis character issue with aliases/quotes. You should now be able to set an elipsis to be an alias of `.quoteprint`
|
||||
|
||||
## [4.2.13] - 30.06.2022
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed `.cash` bank interaction not being ephemeral anymore
|
||||
|
||||
## [4.2.12] - 30.06.2022
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed `.trivia --pokemon` showing incorrect pokemons
|
||||
|
||||
## [4.2.11] - 29.06.2022
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed `.draw` command
|
||||
|
||||
## [4.2.10] - 29.06.2022
|
||||
|
||||
- Fixed currency generation working only once
|
||||
|
||||
## [4.2.9] - 25.06.2022
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed `creds_example.yml` misssing from output directory
|
||||
|
||||
## [4.2.8] - 24.06.2022
|
||||
|
||||
### Fixed
|
||||
|
||||
- `.timely` should be fixed
|
||||
|
||||
## [4.2.7] - 24.06.2022
|
||||
|
||||
### Changed
|
||||
|
||||
- New cache abstraction added
|
||||
- 2 implemenations: redis and memory
|
||||
- All current bots will stay on redis cache, all new bots will use **in-process memory cache by default**
|
||||
- This change removes bot's hard dependency on redis
|
||||
- Configurable in `creds.yml` (please read the comments)
|
||||
- You **MUST** use 'redis' if your bot runs on more than 1 shard (2000+ servers)
|
||||
- [dev] Using new non-locking ConcurrentDictionary
|
||||
|
||||
### Fixed
|
||||
|
||||
- `.xp` will now show default user avatars too
|
||||
|
||||
### Removed
|
||||
|
||||
- Removed `.imagesreload` as images are now lazily loaded on request and then cached
|
||||
|
||||
## [4.2.6] - 22.06.2022
|
||||
|
||||
### Fixed
|
||||
|
||||
- Patron system should now properly by disabled on selfhosts by default.
|
||||
|
||||
## [4.2.5] - 18.06.2022
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed `.crypto`, you will still need coinmarketcapApiKey in `creds.yml` in order to make it run consistently as the key is shared
|
||||
|
||||
## [4.2.3] - 17.06.2022
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed `.timely` nullref bug and made it nicer
|
||||
- Fixed `.streamrole` not updating in real time!
|
||||
- Disabling specific Global Expressions should now work with `.sc` (and other permission commands)
|
||||
|
||||
## [4.2.2] - 15.06.2022
|
||||
|
||||
### Fixed
|
||||
|
||||
- Added missing Patron Tiers and fixed Patron pledge update bugs
|
||||
- Prevented creds_example.yml error in docker containers from crashing it
|
||||
|
||||
### Changed
|
||||
|
||||
- Rss feeds will now show error counter before deletion
|
||||
|
||||
## [4.2.1] - 14.06.2022
|
||||
|
||||
### Added
|
||||
|
||||
- Localized strings updated
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed `.exexport`, `.savechat`, and `.quoteexport`
|
||||
- Fixed plaintext-only embeds
|
||||
- Fixed greet message footer not showing origin server
|
||||
|
||||
## [4.2.0] - 14.06.2022
|
||||
|
||||
### Added
|
||||
|
||||
- Added `data/searches.yml` file which configures some of the new search functionality
|
||||
The file comments explaining what each property does.
|
||||
Explained briefly here:
|
||||
```yml
|
||||
# what will be used for .google command. Either google (official api) or searx
|
||||
webSearchEngine: Google
|
||||
# what will be used for .img command. Either google (official api) or searx
|
||||
imgSearchEngine: Google
|
||||
# how will yt results be retrieved: ytdataapi or ytdl or ytdlp
|
||||
ytProvider: YtDataApiv3
|
||||
# in case web or img search is set to searx, the following instances will be used:
|
||||
searxInstances: []
|
||||
# in case ytProvider is set to invidious, the following instances will be used
|
||||
invidiousInstances: []
|
||||
```
|
||||
- Added new properties to `creds.yml`. google -> searchId and google -> searchImageId.
|
||||
- These properties are used as `cx` (google api query parameter) in case you've setup your `data/searches.yml` to use the official google api.
|
||||
`searchId` is used for web search
|
||||
`searchimageId` is used for image search
|
||||
```yml
|
||||
google:
|
||||
searchId: ""
|
||||
searchImageId: ""
|
||||
```
|
||||
- Check `creds_example.yml` for comments explaining how to obtain them.
|
||||
|
||||
#### Patronage system added
|
||||
- Added `data/patron.yml` for configuration
|
||||
- Implemented only for patreon so far
|
||||
- Patreon subscription code completely rewritten
|
||||
- Users who pledge on patreon get benefits based on the amount they pledged
|
||||
- Public nadeko only. But selfhosters can adapt it to their own patreon pages by configuring their patreon credentials in `creds.yml` and enabling the system in `data/patron.yml` file.
|
||||
- Most of the patronage system strings are hardcoded atm, so if you wish to use this system on selfhosts, you will have to modify the source
|
||||
- Pledge amounts are split into tiers. This is not configurable atm.
|
||||
- Tier I - 1$ - 4.99$ a month
|
||||
- Tier V - 5$ - 9.99$ a month
|
||||
- Tier X - 10$ - 19.99$ a month
|
||||
- Tier XX - 20$ - 49.99$ a month
|
||||
- Tier L - 50$ - 99.99$ a month
|
||||
- Tier C - 100$+ a month
|
||||
- Rewards and command quotas for each of the tiers are configurable
|
||||
- Limitations to certain features are also configurable. ex:
|
||||
```yml
|
||||
quotas:
|
||||
features:
|
||||
"rero:max_count":
|
||||
x: 50
|
||||
```
|
||||
- ^ this setting would set the maximum number of reaction roles to be 50 for a user who is in Patron Tier X
|
||||
- Read the comments in the .yml file for (much) more info
|
||||
- Quota system allows the owner to set up hourly, daily and monthly quota usage for each tier
|
||||
- Quota system applies to entire server owner by a patron
|
||||
- Patron spends own quota by using the commands on any server
|
||||
- Any user on *any* server owned by a patron spends that patron's quota
|
||||
- When users subscribe to patreon they will receive a welcome message
|
||||
- If you're enabling patron system for a selfhost, you will want to edit it
|
||||
|
||||
Added `.patron` and `.patronmessage` commands
|
||||
- `.patron` checks your patronage status, and quotas. Requires patron system to be enabled.
|
||||
- `.patronmessage` (owner only) sends message to all patrons with the specified tier or higher. Supports embeds
|
||||
|
||||
- Added a fake `.cmdcd` command `cleverbot:response` which can be used to limit how often users can talk to the cleverbot.
|
||||
|
||||
### Changed
|
||||
|
||||
- CurrencyReward now support adding additional flowers to patrons.
|
||||
- `.donate` command completely reworked.
|
||||
- Works only on public bot (OnlyPublicBotAttribute)
|
||||
- Guides user on how to donate to support the project
|
||||
- Added interaction explaining selfhosting
|
||||
|
||||
- `.google` reimplemented. It now has 2 modes configurable in `data/searches.yml` under the `webSearchengine` property
|
||||
- If set to `google`, official custom search api will be used. You will need to set googleapikey and google.searchId in `creds.yml`
|
||||
- if set to `searx` one of the instances specified in the `searxInstances:` property will be randomly chosen for each request
|
||||
- instances must have `format=json` allowed (public ones usually don't allow it)
|
||||
- instances are specified as a fully qualified url, example: `https://my.cool.searx.instance.io`
|
||||
- `.image` reimplemented. Same as `.google` - it uses either `google` official api (in which case it uses `google.searchImageId` from `creds.yml`) or `searx`
|
||||
|
||||
- `.youtube` reimplemented. It will use a `ytProvider:` property from `data/searches.yml` to determine how to retrieve results
|
||||
- `ytdataapi` will use the official google api (requires `GoogleApiKey` specified in `creds.yml`) and YoutubeDataApi enabled in the dev console
|
||||
- `ytdl` will use `youtube-dl` program from the host machine. It must be downloaded and it's location must be added to path env variable.
|
||||
- `ytdlp` will use `yt-dlp` program from the host machine. Same as `youtube-dl` - must be in path env variable.
|
||||
- `invidious` will use one of invidious instances specified in the `invidiousInstances` property. Very good.
|
||||
|
||||
- `.google`, `.youtube` and `.image` moved to the new Search group
|
||||
|
||||
Note: Results of each `.youtube` query will be cached for 1 hour to improve perfomance
|
||||
- Removed 30 second `.ping` ratelimit on public nadeko
|
||||
|
||||
- xp image generation changes
|
||||
- In case you have default settings, your xp image will look slightly different
|
||||
- If you've modified xp_template.json, your xp image might look broken. Your old template will be saved in xp_template.json.old
|
||||
- Xp number outline is now slightly thicker
|
||||
- Xp number will now have Center vertical and horizontal alignment
|
||||
- LastLevelUp no longer supported
|
||||
|
||||
- Some commands will now use timestamp tags for better user experience
|
||||
- `.prune` was slightly slowed down to avoid ratelimits
|
||||
- `.wof` moved from it's own group to the default Gambling group
|
||||
- `.feed` urls which error for more than 100 times will be automatically removed.
|
||||
- `.ve` is now enabled by default
|
||||
|
||||
- [dev] nadeko interaction slightly improved to make it less nonsense (they still don't make sense)
|
||||
- [dev] RewardedUsers table slightly changed to make it more general
|
||||
- [dev] renamed `// todo`s which aren't planned soon to `// FUTURE`
|
||||
- [dev] currency rewards have been reimplemented and moved to a separate service
|
||||
|
||||
### Fixed
|
||||
|
||||
- `.rh` no longer needs quotes for multi word roles
|
||||
- `.deletexp` will now properly delete server xp too
|
||||
- Fixed `.crypto` sparklines
|
||||
- [dev] added support for configs to properly parse enums without case sensitivity (ConfigParsers.InsensitiveEnum)
|
||||
- [dev] Fixed a bug in .gencmdlist
|
||||
- [dev] small fixes to creds provider
|
||||
|
||||
### Removed
|
||||
|
||||
- `.ddg` removed.
|
||||
- [dev] removed some dead code and comments
|
||||
|
||||
## [4.1.6] - 14.05.2022
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed windows release and updated packages
|
||||
|
||||
## [4.1.5] - 11.05.2022
|
||||
|
||||
### Changed
|
||||
|
||||
- `.clubdesc <msg>` will now have a nicer response
|
||||
|
||||
### Fixed
|
||||
|
||||
- `.give` DM will once again show an amount
|
||||
- Fixed an issue with filters not working and with custom reactions no longer being able to override commands.
|
||||
- Fixed `.stock` command
|
||||
|
||||
## [4.1.4] - 06.05.2022
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed `.yun`
|
||||
|
||||
## [4.1.3] - 06.05.2022
|
||||
|
||||
### Added
|
||||
|
||||
- Added support for embed arrays in commands such as .say, .greet, .bye, etc...
|
||||
- Website to create them is live at eb.nadeko.bot (old one is moved to oldeb.nadeko.bot)
|
||||
- Embed arrays don't have a plainText property (it's renamed to 'content')
|
||||
- Embed arrays use color hex values instead of an integer
|
||||
- Old embed format will still work
|
||||
- There shouldn't be any breaking changes
|
||||
- Added `.stondel` command which, when toggled, will make the bot delete online stream messages on the server when the stream goes offline
|
||||
- Added a simple bank system.
|
||||
- Users can deposit, withdraw and check the balance of their currency in the bank.
|
||||
- Users can't check other user's bank balances.
|
||||
- Added a button on a .$ command which, when clicked, sends you a message with your bank balance that only you can see.
|
||||
- Added `.h <command group>`
|
||||
- Using this command will list all commands in the specified group
|
||||
- Atm only .bank is a proper group (`.h bank`)
|
||||
- Added "Bank Accounts" entry to `.economy`
|
||||
|
||||
### Changed
|
||||
|
||||
- Reaction roles rewritten completely
|
||||
- Supports multiple exclusivity groups per message
|
||||
- Supports level requirements
|
||||
- However they can only be added one by one
|
||||
- Use the following commands for more information
|
||||
- `.h .reroa`
|
||||
- `.h .reroli`
|
||||
- `.h .rerot`
|
||||
- `.h .rerorm`
|
||||
- `.h .rerodela`
|
||||
- Pagination is now using buttons instead of reactions
|
||||
- Bot will now support much higher XP values for global and server levels
|
||||
- [dev] Small change and generation perf improvement for the localized response strings
|
||||
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed `.deletexp` command
|
||||
- `.give` command should send DMs again
|
||||
- `.modules` command now has a medusa module description
|
||||
|
||||
## [4.1.2] - 16.04.2022
|
||||
|
||||
@@ -18,7 +775,7 @@ Experimental changelog. Mostly based on [keepachangelog](https://keepachangelog.
|
||||
- To change the db nadeko will use, simply change the `db type` in `creds.yml`
|
||||
- There is no migration code right now, which means that if you want to switch to another system you'll either have to manually export/import your database or start fresh
|
||||
- Medusa system
|
||||
- A massive new feature which allows developers to create custom modules/plugins/cogs
|
||||
- A massive new feature which allows developers to create custom modules/plugins/cogs
|
||||
- They can be load/unloaded/updated at runtime without restarting the bot
|
||||
|
||||
### Changed
|
||||
@@ -54,7 +811,7 @@ Experimental changelog. Mostly based on [keepachangelog](https://keepachangelog.
|
||||
### Fixed
|
||||
|
||||
- Fixed the `id` which shows up when you add a new Expression
|
||||
- Fixed some strings which were still referring to "CustomReaction(s)" instead of "Expression(s)"
|
||||
- Fixed some strings which were still referring to "CustomReaction(s)" instead of "Expression(s)"
|
||||
|
||||
## [4.0.3] - 04.03.2022
|
||||
|
||||
@@ -80,20 +837,20 @@ Experimental changelog. Mostly based on [keepachangelog](https://keepachangelog.
|
||||
### Added
|
||||
- Added `.deleteemptyservers` command
|
||||
- Added `.curtr <id>` which lets you see full information about one of your own transactions with the specified id
|
||||
- Added trovo.live support for stream notifications (`.stadd`)
|
||||
- Added trovo.live support for stream notifications (`.stadd`)
|
||||
- Added unclaimed waifu decay functionality
|
||||
- Added 3 new settings to `data/gambling.yml` to control it:
|
||||
- waifu.decay.percent - How much % to subtract from unclaimed waifu
|
||||
- waifu.decay.hourInterval - How often to decay the price
|
||||
- waifu.decay.hourInterval - How often to decay the price
|
||||
- waifu.decay.minPrice - Unclaimed waifus with price lower than the one specified here will not be affected by the decay
|
||||
- Added `currency.transactionsLifetime` to `data/gambling.yml` Any transaction older than the number of days specified will be automatically deleted
|
||||
- Added `.stock` command to check stock prices and charts
|
||||
- Re-added `.qap / .queueautoplay`
|
||||
- Re-added `.qap / .queueautoplay`
|
||||
|
||||
### Changed
|
||||
- CustomReactions module (and customreactions db table) has been renamed to Expressions.
|
||||
- This was done to remove confusion about how it relates to discord Reactions (it doesn't, it was created and named before discord reactions existed)
|
||||
- Expression command now start with ex/expr and end with the name of the action or setting.
|
||||
- This was done to remove confusion about how it relates to discord Reactions (it doesn't, it was created and named before discord reactions existed)
|
||||
- Expression command now start with ex/expr and end with the name of the action or setting.
|
||||
- For example `.exd` (`.dcr`) is expression delete, `.exa` (`.acr`)
|
||||
- Permissions (`.lp`) be automatically updated with "ACTUALEXPRESSIONS", "EXPRESSIONS" instead of "ACTUALCUSTOMREACTIONS" and "CUSTOMREACTIONS"
|
||||
- Permissions for `.ecr` (now `.exe`), `.scr` (now `.exs`), `.dcr` (now `.exd`), `.acr` (now `.exa`), `.lcr` (now `.exl`) will be automatically updated
|
||||
@@ -110,8 +867,8 @@ Experimental changelog. Mostly based on [keepachangelog](https://keepachangelog.
|
||||
- [dev] Added Type, Extra, OtherId fields to the database
|
||||
- [dev] CommandStrings will now use methodname as the key, and **not** the command name (first entry in aliases.yml)
|
||||
- In other words aliases.yml and commands.en-US.yml will use the same keys (once again)
|
||||
- [dev] Reorganized module and submodule folders
|
||||
- [dev] Permissionv2 db table renamed to Permissions
|
||||
- [dev] Reorganized module and submodule folders
|
||||
- [dev] Permissionv2 db table renamed to Permissions
|
||||
- [dev] Moved FilterWordsChannelId to a separate table
|
||||
|
||||
### Fixed
|
||||
@@ -126,9 +883,9 @@ Experimental changelog. Mostly based on [keepachangelog](https://keepachangelog.
|
||||
- Fixed embed color when disabling `.antialt`
|
||||
|
||||
### Removed
|
||||
- Removed `.bce` - use `.config` or `.config bot` specifically for bot config
|
||||
- Removed obsolete placeholders: %users% %servers% %userfull% %username% %userdiscrim% %useravatar% %id% %uid% %chname% %cid% %sid% %members% %server_time% %shardid% %time% %mention%
|
||||
- Removed some obsolete commands and strings
|
||||
- Removed `.bce` - use `.config` or `.config bot` specifically for bot config
|
||||
- Removed obsolete placeholders: %users% %servers% %userfull% %username% %userdiscrim% %useravatar% %id% %uid% %chname% %cid% %sid% %members% %server_time% %shardid% %time% %mention%
|
||||
- Removed some obsolete commands and strings
|
||||
- Removed code which migrated 2.x to v3 credentials, settings, etc...
|
||||
|
||||
## [3.0.13] - 14.01.2022
|
||||
@@ -167,7 +924,7 @@ Experimental changelog. Mostly based on [keepachangelog](https://keepachangelog.
|
||||
- Looks much nicer
|
||||
- Bot will now reply to user messages with a translation if `del` is disabled
|
||||
- Bot will make an embed with original and translated text with user avatar and name if `del` is enabled
|
||||
- If the bot is unable to delete messages while having `del` enabled, it will reset back to the no-del behavior for the current session
|
||||
- If the bot is unable to delete messages while having `del` enabled, it will reset back to the no-del behavior for the current session
|
||||
|
||||
### Fixed
|
||||
- `.crypto` now supports top 5000 coins
|
||||
@@ -181,7 +938,7 @@ Experimental changelog. Mostly based on [keepachangelog](https://keepachangelog.
|
||||
### Fixed
|
||||
- `.xprewsreset` now has correct permissions
|
||||
|
||||
### Removed
|
||||
### Removed
|
||||
- Removed slot.numbers from `images.yml` as they're no longer used
|
||||
|
||||
## [3.0.9] - 21.11.2021
|
||||
@@ -191,7 +948,7 @@ Experimental changelog. Mostly based on [keepachangelog](https://keepachangelog.
|
||||
|
||||
### Added
|
||||
- Added `.emojiadd` with 3 overloads
|
||||
- `.ea :customEmoji:` which copies another server's emoji
|
||||
- `.ea :customEmoji:` which copies another server's emoji
|
||||
- `.ea newName :customEmoji:` which copies emoji under a different name
|
||||
- `.ea emojiName <imagelink.png>` which creates a new emoji from the specified image
|
||||
- Patreon Access and Refresh Tokens should now be automatically updated once a month as long as the user has provided the necessary credentials in creds.yml file:
|
||||
@@ -205,7 +962,7 @@ Experimental changelog. Mostly based on [keepachangelog](https://keepachangelog.
|
||||
|
||||
## [3.0.8] - 03.11.2021
|
||||
|
||||
### Added
|
||||
### Added
|
||||
- Created VotesApi project nad re-worked vote rewards handling
|
||||
- Updated votes entries in creds.yml with explanations on how to set up vote links
|
||||
|
||||
@@ -230,10 +987,10 @@ Experimental changelog. Mostly based on [keepachangelog](https://keepachangelog.
|
||||
- They are called negative gifts
|
||||
- They show up at the end of the `.gifts` page and are marked with a broken heart
|
||||
- They have a separate multiplier (`waifu.multi.negative_gift_effect` default 0.5, changeable via `.config gambling` or `data/gambling.yml`)
|
||||
- When gifted, the waifu's price will be reduced by the `price * multiplier`
|
||||
- When gifted, the waifu's price will be reduced by the `price * multiplier`
|
||||
- Negative gifts don't show up in `.waifuinfo` nor is the record of them kept in the database
|
||||
|
||||
### Fixed
|
||||
### Fixed
|
||||
- Fixed `%users%` and `%shard.usercount%` placeholders not showing correct values
|
||||
|
||||
## [3.0.6] - 27.09.2021
|
||||
@@ -274,7 +1031,7 @@ Experimental changelog. Mostly based on [keepachangelog](https://keepachangelog.
|
||||
- Possible fix for `.repeat` bug
|
||||
- Slight adjustment for repeater logic
|
||||
- Timer should no longer increase on some repeaters
|
||||
- Repeaters should no longer have periods when they're missing from the list
|
||||
- Repeaters should no longer have periods when they're missing from the list
|
||||
- Fixed several commands which used error color for success confirmation messages
|
||||
|
||||
## [3.0.3] - 15.09.2021
|
||||
@@ -335,7 +1092,7 @@ Experimental changelog. Mostly based on [keepachangelog](https://keepachangelog.
|
||||
- Explanations on how to get the keys are added as the comments
|
||||
- Code cleanup
|
||||
- Command attributes cleaned up
|
||||
- Removed dummy Remarks and Usages attributes as hey were unused for a few patches but stayed in the code to avoid big git diffsmigration code has ran and it can be safely removed
|
||||
- Removed dummy Remarks and Usages attributes as hey were unused for a few patches but stayed in the code to avoid big git diffsmigration code has ran and it can be safely removed
|
||||
- There are 2 projects: NadekoBot and NadekoBot.Coordinator
|
||||
- You can directly run NadekoBot as the regular bot with one shard
|
||||
- Run NadekoBot.Coordinator if you want more control over your shards and a grpc api for coordinator with which you can start, restart, kill and see status of shards
|
||||
@@ -356,7 +1113,7 @@ Experimental changelog. Mostly based on [keepachangelog](https://keepachangelog.
|
||||
|
||||
## [2.46.2] - 14.07.2021
|
||||
|
||||
### Fixed
|
||||
### Fixed
|
||||
|
||||
- Fixed .save for local songs
|
||||
- Fixed .lq for local songs if the song names are too long
|
||||
@@ -427,7 +1184,7 @@ Experimental changelog. Mostly based on [keepachangelog](https://keepachangelog.
|
||||
|
||||
### Added
|
||||
|
||||
- Added `.crsexport` and `.crsimport`
|
||||
- Added `.crsexport` and `.crsimport`
|
||||
- Allows for quick export/import of server or global custom reactions
|
||||
- Requires admin permissions for server crs, and owner for global crs
|
||||
- Explanation of the fields is in the comment at the top of the `.crsexport` .yml file
|
||||
@@ -460,7 +1217,7 @@ Experimental changelog. Mostly based on [keepachangelog](https://keepachangelog.
|
||||
### Added
|
||||
|
||||
- Re-added `%music.playing%` and `%music.queued%` (#290)
|
||||
- Added `%music.servers%` which shows how many servers have a song queued up to play
|
||||
- Added `%music.servers%` which shows how many servers have a song queued up to play
|
||||
ℹ️ ^ Only available to `.ropl` / `.adpl` feature atm
|
||||
- `.autodc` re-added
|
||||
- `.qrp`, `.vol`, `.smch` `.autodc` will now persist
|
||||
@@ -480,7 +1237,7 @@ Experimental changelog. Mostly based on [keepachangelog](https://keepachangelog.
|
||||
- Removing last song in the queue will no longer reset queue index
|
||||
- Having `.rpl` disabled will now correctly stop after the last song, closes #292
|
||||
|
||||
### Removed
|
||||
### Removed
|
||||
|
||||
- `.sad` removed. It's more or less useless. Use `.qrp` and `.autodc` now for similar effect
|
||||
|
||||
@@ -495,7 +1252,7 @@ Experimental changelog. Mostly based on [keepachangelog](https://keepachangelog.
|
||||
|
||||
- Minor perf improvement for filter checks
|
||||
|
||||
### Fixed
|
||||
### Fixed
|
||||
|
||||
- `.qs` result urls are now valid
|
||||
- Custom reactions with "`-`" as a response should once again disable that custom reaction completely
|
||||
@@ -511,8 +1268,8 @@ Experimental changelog. Mostly based on [keepachangelog](https://keepachangelog.
|
||||
- Much faster starting and skipping once the songs are in the queue
|
||||
- Higher quality audio (no stuttering too!)
|
||||
- Local tracks will now have durations if you have ffprobe installed (comes with ffmpeg)
|
||||
- Bot supports joining a different vc without skipping the song if you use `.j`
|
||||
- ⚠️ **DO NOT DRAG THE BOT** to another vc, as it's not properly supported atm, and you will have to do `.play` after dragging it)
|
||||
- Bot supports joining a different vc without skipping the song if you use `.j`
|
||||
- ⚠️ **DO NOT DRAG THE BOT** to another vc, as it's not properly supported atm, and you will have to do `.play` after dragging it)
|
||||
- `.j` makes the bot join your voice channel
|
||||
- `.p` is now alias of play, pause is `.pause`
|
||||
- `.qs` should work without google api key now for most users as it is using a custom loader
|
||||
|
19
Dockerfile
19
Dockerfile
@@ -1,11 +1,12 @@
|
||||
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
|
||||
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
|
||||
WORKDIR /source
|
||||
|
||||
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 ./
|
||||
RUN dotnet restore src/NadekoBot/
|
||||
|
||||
COPY . .
|
||||
@@ -19,24 +20,26 @@ RUN set -xe; \
|
||||
chmod +x /app/NadekoBot
|
||||
|
||||
# final stage/image
|
||||
FROM mcr.microsoft.com/dotnet/runtime:6.0
|
||||
FROM mcr.microsoft.com/dotnet/runtime:8.0
|
||||
WORKDIR /app
|
||||
|
||||
RUN set -xe; \
|
||||
useradd -m nadeko; \
|
||||
apt-get update; \
|
||||
apt-get install -y libopus0 libsodium23 libsqlite3-0 curl ffmpeg python3 python3-pip sudo; \
|
||||
update-alternatives --install /usr/bin/python python /usr/bin/python3.9 1; \
|
||||
apt-get install -y --no-install-recommends libopus0 libsodium23 libsqlite3-0 curl ffmpeg python3 sudo; \
|
||||
update-alternatives --install /usr/local/bin/python python /usr/bin/python3.9 1; \
|
||||
echo 'Defaults>nadeko env_keep+="ASPNETCORE_* DOTNET_* NadekoBot_* shard_id total_shards TZ"' > /etc/sudoers.d/nadeko; \
|
||||
pip3 install --upgrade youtube-dl; \
|
||||
apt-get remove -y python3-pip; \
|
||||
chmod +x /usr/local/bin/youtube-dl
|
||||
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 --from=build /app ./
|
||||
COPY docker-entrypoint.sh /usr/local/sbin
|
||||
|
||||
ENV shard_id=0
|
||||
ENV total_shards=1
|
||||
ENV NadekoBot__creds=/app/data/creds.yml
|
||||
|
||||
VOLUME [ "/app/data" ]
|
||||
ENTRYPOINT [ "/usr/local/sbin/docker-entrypoint.sh" ]
|
||||
|
@@ -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:
|
||||
|
||||
|
@@ -12,24 +12,25 @@ ProjectSection(SolutionItems) = preProject
|
||||
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}"
|
||||
EndProject
|
||||
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
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@@ -61,12 +62,6 @@ 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
|
||||
@@ -79,19 +74,24 @@ Global
|
||||
{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}
|
||||
|
6
NuGet.Config
Normal file
6
NuGet.Config
Normal file
@@ -0,0 +1,6 @@
|
||||
<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/v4/?badge=v4)
|
||||
[](https://top.gg/bot/116275390695079945)
|
||||
|
||||
|
||||
[](https://nadeko.bot/)
|
||||
|
||||
[](https://invite.nadeko.bot/)
|
||||
@@ -10,5 +5,5 @@
|
||||
[](https://nadeko.bot/commands)
|
||||
|
||||
### Useful links
|
||||
- [Self hosting Guides and Docs](https://nadekobot.readthedocs.io/en/v4)
|
||||
- [Self hosting Guides and Docs](https://nadekobot.readthedocs.io/en/latest)
|
||||
- [Discord support server](https://discord.nadeko.bot)
|
||||
|
23
docker-compose.yml
Normal file
23
docker-compose.yml
Normal file
@@ -0,0 +1,23 @@
|
||||
version: "3.7"
|
||||
|
||||
services:
|
||||
nadeko:
|
||||
image: insert-image-name-here:latest
|
||||
depends_on:
|
||||
- redis
|
||||
environment:
|
||||
TZ: Europe/Paris
|
||||
NadekoBot_RedisOptions: redis,name=nadeko
|
||||
#NadekoBot_ShardRunCommand: dotnet
|
||||
#NadekoBot_ShardRunArguments: /app/NadekoBot.dll {0} {1}
|
||||
volumes:
|
||||
- /srv/nadeko/conf:/app/conf:ro
|
||||
- /srv/nadeko/data:/app/data
|
||||
|
||||
redis:
|
||||
image: redis:4-alpine
|
||||
sysctls:
|
||||
- net.core.somaxconn=511
|
||||
command: redis-server --maxmemory 32M --maxmemory-policy volatile-lru
|
||||
volumes:
|
||||
- /srv/nadeko/redis-data:/data
|
@@ -13,7 +13,15 @@ do
|
||||
fi
|
||||
done
|
||||
|
||||
# fix folder permissions
|
||||
# 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
|
||||
|
@@ -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 [**v4 branch**](https://gitlab.com/Kwoth/nadekobot/tree/v4)
|
||||
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
|
||||
|
||||
|
@@ -33,17 +33,17 @@ These are required for a number of features to function properly, and all should
|
||||
For a single owner, it should look like this:
|
||||
|
||||
```yml
|
||||
OwnerIds:
|
||||
- 105635576866156544
|
||||
OwnerIds:
|
||||
- 105635576866156544
|
||||
```
|
||||
|
||||
For multiple owners, it should look like this:
|
||||
|
||||
```yml
|
||||
OwnerIds:
|
||||
- 105635123466156544
|
||||
- 145521851676884992
|
||||
- 341420590009417729
|
||||
OwnerIds:
|
||||
- 105635123466156544
|
||||
- 145521851676884992
|
||||
- 341420590009417729
|
||||
```
|
||||
|
||||
|
||||
|
@@ -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
|
||||
|
@@ -13,24 +13,23 @@
|
||||
|
||||
#### Operating System Compatibility
|
||||
|
||||
It is recommended that you use **Ubuntu 20.04**, as there have been nearly no problems with it. Also, **32-bit systems are incompatible**.
|
||||
|
||||
##### Compatible operating systems:
|
||||
|
||||
- Ubuntu: 16.04, 18.04, 20.04, 21.04, 21.10
|
||||
- Ubuntu: 16.04, 18.04, 20.04, 21.04, 21.10, 22.04
|
||||
- Mint: 19, 20
|
||||
- Debian: 9, 10
|
||||
- CentOS: 7
|
||||
- openSUSE
|
||||
- Fedora: 33, 34, 35
|
||||
- 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
|
||||
|
||||
##### Migration from v3 -> v4
|
||||
##### 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/v4/linuxAIO.sh && bash linuxAIO.sh`
|
||||
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`)
|
||||
@@ -40,7 +39,7 @@ Use the new installer script: `cd ~ && wget -N https://gitlab.com/Kwoth/nadeko-
|
||||
|
||||
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/v4/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 (type `6` and press enter)
|
||||
@@ -52,24 +51,35 @@ Open Terminal (if you're on an installation with a window manager) and navigate
|
||||
- `CTRL` + `X`
|
||||
- `Y`
|
||||
- `Enter`
|
||||
8. Run the installer script again `cd ~ && wget -N https://gitlab.com/Kwoth/nadeko-bash-installer/-/raw/v4/linuxAIO.sh && bash linuxAIO.sh`
|
||||
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)
|
||||
|
||||
##### 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/v4/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. 🎉
|
||||
|
||||
## **⚠ IF YOU ARE FOLLOWING THE GUIDE ABOVE, IGNORE THIS SECTION ⚠**
|
||||
|
||||
## Linux Release
|
||||
|
||||
**⚠ IF YOU ARE FOLLOWING THE GUIDE ABOVE, IGNORE THIS SECTION ⚠**
|
||||
###### 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!
|
||||
@@ -93,7 +103,7 @@ Open Terminal (if you're on an installation with a window manager) and navigate
|
||||
##### 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!
|
||||
@@ -149,15 +159,30 @@ If you are presented with the installer main menu, exit it by choosing Option `8
|
||||
|
||||
The above command will create a new session named **nadeko** *(you can replace “nadeko” with anything you prefer, it's your session name)*.
|
||||
|
||||
2. Navigate to the project's root directory
|
||||
- Project root directory location example: `cd /home/user/nadekobot/`
|
||||
3. Enter the `output` directory:
|
||||
- `cd output`
|
||||
4. Run the bot using:
|
||||
- `dotnet NadekoBot.dll`
|
||||
5. Detatch the tmux session:
|
||||
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`
|
||||
|
||||
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.)*
|
||||
@@ -290,6 +315,26 @@ This method is similar to the one above, but requires one extra step, with the a
|
||||
|
||||
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.
|
||||
|
||||
|
@@ -7,7 +7,7 @@ Open Terminal (if you don't know how to, click on the magnifying glass on the to
|
||||
###### 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`
|
||||
|
||||
@@ -31,7 +31,7 @@ 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/v4/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`
|
||||
@@ -49,7 +49,7 @@ sudo ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/
|
||||
##### 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/v4/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. 🎉
|
||||
@@ -60,7 +60,7 @@ sudo ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/
|
||||
|
||||
##### 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!
|
||||
@@ -84,7 +84,7 @@ sudo ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/
|
||||
##### 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!
|
||||
|
@@ -10,16 +10,14 @@
|
||||
|
||||
*Note: If you want to make changes to Nadeko's source code, please follow the [From Source](#windows-from-source) guide instead.*
|
||||
|
||||
*If you have Windows 7 or a 32-bit system, please refer to the [From Source](#windows-from-source)) guide.*
|
||||
|
||||
#### Prerequisites
|
||||
|
||||
- Windows 8 or later (64-bit)
|
||||
- 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
|
||||
@@ -31,9 +29,8 @@
|
||||

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

|
||||
- Click on **`Install`** next to **`Redis`**.
|
||||
- Note: If Redis fails to install, install Redis manually here: [Redis Installer](https://github.com/MicrosoftArchive/redis/releases/tag/win-3.0.504) Download and run the **`.msi`** file.
|
||||
- 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.
|
||||
@@ -46,7 +43,7 @@
|
||||
|
||||
#### 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).
|
||||
@@ -59,33 +56,33 @@
|
||||
|
||||
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
|
||||
|
||||
⚠ IF YOU ARE FOLLOWING THE GUIDE ABOVE, IGNORE THIS SECTION ⚠
|
||||
|
||||
##### Prerequisites
|
||||
|
||||
**Install these before proceeding or your bot will not work!**
|
||||
- [.net 6](https://dotnet.microsoft.com/download/dotnet/6.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 v4 --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`
|
||||
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`
|
||||
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,18 +112,18 @@ 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/
|
||||
[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
|
||||
@@ -130,4 +131,4 @@ In order to use music commands, you need ffmpeg and youtube-dl installed.
|
||||
[Visual C++ 2017 (x64)]: https://aka.ms/vs/15/release/vc_redist.x64.exe
|
||||
[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,7 +8,7 @@ Medusa system allows you to write independent medusae (known as "modules", "cogs
|
||||
|
||||
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/v4/src/Nadeko.Medusa) in case you need reference, as there is no generated documentation at the moment.
|
||||
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
|
||||
|
||||
@@ -147,6 +147,7 @@ This section will guide you through how to create a simple custom medusa. You ca
|
||||
<!-- 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>
|
||||
@@ -155,12 +156,12 @@ This section will guide you through how to create a simple custom medusa. You ca
|
||||
<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="1.0.1">
|
||||
<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 gitlab.com/kwoth/nadekobot repo locally and reference the NadekoBot.csproj because there is no NadekoBot package atm.
|
||||
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,
|
||||
@@ -248,4 +249,4 @@ hello:
|
||||
- Unload it
|
||||
- `.meunload example_medusa`
|
||||
|
||||
- Congrats! You've just made your first medusa!
|
||||
- Congrats! You've just made your first medusa!
|
||||
|
@@ -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.
|
||||
|
||||
@@ -38,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
|
||||
@@ -68,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
|
||||
@@ -88,7 +83,6 @@ Some features have their own specific placeholders which are noted in that featu
|
||||
### 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 "net6.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:
|
||||
@@ -92,4 +92,3 @@ nav:
|
||||
- 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
|
||||
|
@@ -1,4 +1,4 @@
|
||||
namespace Nadeko.Snake;
|
||||
namespace NadekoBot.Medusa;
|
||||
|
||||
/// <summary>
|
||||
/// Overridden to implement custom checks which commands have to pass in order to be executed.
|
||||
|
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;
|
||||
}
|
||||
}
|
@@ -1,4 +1,4 @@
|
||||
namespace Nadeko.Snake;
|
||||
namespace NadekoBot.Medusa;
|
||||
|
||||
/// <summary>
|
||||
/// Marks a method as a snek command
|
||||
|
@@ -1,4 +1,4 @@
|
||||
namespace Nadeko.Snake;
|
||||
namespace NadekoBot.Medusa;
|
||||
|
||||
/// <summary>
|
||||
/// Marks services in command arguments for injection.
|
||||
|
@@ -1,4 +1,4 @@
|
||||
namespace Nadeko.Snake;
|
||||
namespace NadekoBot.Medusa;
|
||||
|
||||
/// <summary>
|
||||
/// Marks the parameter to take
|
||||
|
@@ -1,4 +1,4 @@
|
||||
namespace Nadeko.Snake;
|
||||
namespace NadekoBot.Medusa;
|
||||
|
||||
/// <summary>
|
||||
/// Sets the priority of a command in case there are multiple commands with the same name but different parameters.
|
||||
|
@@ -1,4 +1,4 @@
|
||||
namespace Nadeko.Snake;
|
||||
namespace NadekoBot.Medusa;
|
||||
|
||||
/// <summary>
|
||||
/// Marks the class as a service which can be used within the same Medusa
|
||||
|
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;
|
||||
}
|
||||
}
|
@@ -1,7 +1,7 @@
|
||||
using Discord;
|
||||
using NadekoBot;
|
||||
|
||||
namespace Nadeko.Snake;
|
||||
namespace NadekoBot.Medusa;
|
||||
|
||||
/// <summary>
|
||||
/// Commands which take this class as a first parameter can be executed in both DMs and Servers
|
||||
@@ -22,6 +22,11 @@ public abstract class AnyContext
|
||||
/// 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
|
||||
@@ -35,13 +40,4 @@ public abstract class AnyContext
|
||||
/// <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);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a context-aware <see cref="IEmbedBuilder"/> instance
|
||||
/// (future feature for guild-based embed colors)
|
||||
/// Any code dealing with embeds should use it for future-proofness
|
||||
/// instead of manually creating embedbuilder instances
|
||||
/// </summary>
|
||||
/// <returns>A context-aware <see cref="IEmbedBuilder"/> instance </returns>
|
||||
public abstract IEmbedBuilder Embed();
|
||||
}
|
@@ -1,6 +1,6 @@
|
||||
using Discord;
|
||||
|
||||
namespace Nadeko.Snake;
|
||||
namespace NadekoBot.Medusa;
|
||||
|
||||
/// <summary>
|
||||
/// Commands which take this type as the first parameter can only be executed in DMs
|
||||
|
@@ -1,6 +1,6 @@
|
||||
using Discord;
|
||||
|
||||
namespace Nadeko.Snake;
|
||||
namespace NadekoBot.Medusa;
|
||||
|
||||
/// <summary>
|
||||
/// Commands which take this type as a first parameter can only be executed in a server
|
||||
|
@@ -1,14 +0,0 @@
|
||||
namespace NadekoBot;
|
||||
|
||||
public static class EmbedBuilderExtensions
|
||||
{
|
||||
public static IEmbedBuilder WithOkColor(this IEmbedBuilder eb)
|
||||
=> eb.WithColor(EmbedColor.Ok);
|
||||
|
||||
public static IEmbedBuilder WithPendingColor(this IEmbedBuilder eb)
|
||||
=> eb.WithColor(EmbedColor.Pending);
|
||||
|
||||
public static IEmbedBuilder WithErrorColor(this IEmbedBuilder eb)
|
||||
=> eb.WithColor(EmbedColor.Error);
|
||||
|
||||
}
|
@@ -1,37 +1,32 @@
|
||||
using Discord;
|
||||
using Nadeko.Snake;
|
||||
|
||||
namespace NadekoBot;
|
||||
namespace NadekoBot.Medusa;
|
||||
|
||||
public static class MedusaExtensions
|
||||
{
|
||||
public static Task<IUserMessage> EmbedAsync(this IMessageChannel ch, IEmbedBuilder embed, string msg = "")
|
||||
public static Task<IUserMessage> EmbedAsync(this IMessageChannel ch, EmbedBuilder embed, string msg = "")
|
||||
=> ch.SendMessageAsync(msg,
|
||||
embed: embed.Build(),
|
||||
options: new()
|
||||
{
|
||||
RetryMode = RetryMode.AlwaysRetry
|
||||
RetryMode = RetryMode.Retry502
|
||||
});
|
||||
|
||||
// unlocalized
|
||||
public static Task<IUserMessage> SendConfirmAsync(this IMessageChannel ch, AnyContext ctx, string msg)
|
||||
=> ch.EmbedAsync(ctx.Embed().WithOkColor().WithDescription(msg));
|
||||
|
||||
public static Task<IUserMessage> SendPendingAsync(this IMessageChannel ch, AnyContext ctx, string msg)
|
||||
=> ch.EmbedAsync(ctx.Embed().WithPendingColor().WithDescription(msg));
|
||||
|
||||
public static Task<IUserMessage> SendErrorAsync(this IMessageChannel ch, AnyContext ctx, string msg)
|
||||
=> ch.EmbedAsync(ctx.Embed().WithErrorColor().WithDescription(msg));
|
||||
|
||||
// unlocalized
|
||||
public static Task<IUserMessage> SendConfirmAsync(this AnyContext ctx, string msg)
|
||||
=> ctx.Channel.SendConfirmAsync(ctx, msg);
|
||||
=> ctx.Channel.EmbedAsync(new EmbedBuilder()
|
||||
.WithColor(0, 200, 0)
|
||||
.WithDescription(msg));
|
||||
|
||||
public static Task<IUserMessage> SendPendingAsync(this AnyContext ctx, string msg)
|
||||
=> ctx.Channel.SendPendingAsync(ctx, msg);
|
||||
=> ctx.Channel.EmbedAsync(new EmbedBuilder()
|
||||
.WithColor(200, 200, 0)
|
||||
.WithDescription(msg));
|
||||
|
||||
public static Task<IUserMessage> SendErrorAsync(this AnyContext ctx, string msg)
|
||||
=> ctx.Channel.SendErrorAsync(ctx, msg);
|
||||
=> ctx.Channel.EmbedAsync(new EmbedBuilder()
|
||||
.WithColor(200, 0, 0)
|
||||
.WithDescription(msg));
|
||||
|
||||
// localized
|
||||
public static Task ConfirmAsync(this AnyContext ctx)
|
||||
@@ -47,7 +42,7 @@ public static class MedusaExtensions
|
||||
=> ctx.Message.AddReactionAsync(new Emoji("🤔"));
|
||||
|
||||
public static Task<IUserMessage> ErrorLocalizedAsync(this AnyContext ctx, string key, params object[]? args)
|
||||
=> ctx.SendErrorAsync(ctx.GetText(key));
|
||||
=> 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));
|
||||
@@ -56,11 +51,11 @@ public static class MedusaExtensions
|
||||
=> 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)}");
|
||||
=> 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)}");
|
||||
=> 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)}");
|
||||
=> ctx.SendConfirmAsync($"{Format.Bold(ctx.User.ToString())} {ctx.GetText(key, args)}");
|
||||
}
|
@@ -1,17 +0,0 @@
|
||||
using Discord;
|
||||
|
||||
namespace NadekoBot;
|
||||
|
||||
public interface IEmbedBuilder
|
||||
{
|
||||
IEmbedBuilder WithDescription(string? desc);
|
||||
IEmbedBuilder WithTitle(string title);
|
||||
IEmbedBuilder AddField(string title, object value, bool isInline = false);
|
||||
IEmbedBuilder WithFooter(string text, string? iconUrl = null);
|
||||
IEmbedBuilder WithAuthor(string name, string? iconUrl = null, string? url = null);
|
||||
IEmbedBuilder WithColor(EmbedColor color);
|
||||
Embed Build();
|
||||
IEmbedBuilder WithUrl(string url);
|
||||
IEmbedBuilder WithImageUrl(string url);
|
||||
IEmbedBuilder WithThumbnailUrl(string url);
|
||||
}
|
@@ -1,21 +1,20 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<LangVersion>preview</LangVersion>
|
||||
<EnablePreviewFeatures>true</EnablePreviewFeatures>
|
||||
<RootNamespace>Nadeko.Snake</RootNamespace>
|
||||
|
||||
<Authors>The NadekoBot Team</Authors>
|
||||
<Version>1.0.2</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Discord.Net.Core" Version="3.5.0" />
|
||||
<PackageReference Include="Serilog" Version="2.10.0" />
|
||||
<PackageReference Include="YamlDotNet" Version="11.2.1" />
|
||||
<PackageReference Include="Discord.Net.Core" Version="3.204.0" />
|
||||
<PackageReference Include="Serilog" Version="3.1.1" />
|
||||
<PackageReference Include="YamlDotNet" Version="15.1.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(Version)' == '' ">
|
||||
<Version>9.0.0</Version>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
|
@@ -1,4 +1,4 @@
|
||||
namespace Nadeko.Snake;
|
||||
namespace NadekoBot.Medusa;
|
||||
|
||||
/// <summary>
|
||||
/// Overridden to implement parsers for custom types
|
||||
|
@@ -1,4 +1,4 @@
|
||||
namespace Nadeko.Snake;
|
||||
namespace NadekoBot.Medusa;
|
||||
|
||||
public readonly struct ParseResult<T>
|
||||
{
|
||||
|
@@ -1,6 +1,6 @@
|
||||
using Discord;
|
||||
|
||||
namespace Nadeko.Snake;
|
||||
namespace NadekoBot.Medusa;
|
||||
|
||||
/// <summary>
|
||||
/// The base class which will be loaded as a module into NadekoBot
|
||||
|
@@ -1,6 +1,6 @@
|
||||
using YamlDotNet.Serialization;
|
||||
|
||||
namespace Nadeko.Snake;
|
||||
namespace NadekoBot.Medusa;
|
||||
|
||||
public readonly struct CommandStrings
|
||||
{
|
||||
|
@@ -1,6 +1,6 @@
|
||||
using System.Globalization;
|
||||
|
||||
namespace Nadeko.Snake;
|
||||
namespace NadekoBot.Medusa;
|
||||
|
||||
/// <summary>
|
||||
/// Defines methods to retrieve and reload medusa strings
|
||||
|
@@ -1,4 +1,4 @@
|
||||
namespace Nadeko.Snake;
|
||||
namespace NadekoBot.Medusa;
|
||||
|
||||
/// <summary>
|
||||
/// Implemented by classes which provide localized strings in their own ways
|
||||
|
@@ -1,4 +1,4 @@
|
||||
namespace Nadeko.Snake;
|
||||
namespace NadekoBot.Medusa;
|
||||
|
||||
public class LocalMedusaStringsProvider : IMedusaStringsProvider
|
||||
{
|
||||
|
@@ -1,7 +1,7 @@
|
||||
using System.Globalization;
|
||||
using Serilog;
|
||||
|
||||
namespace Nadeko.Snake;
|
||||
namespace NadekoBot.Medusa;
|
||||
|
||||
public class MedusaStrings : IMedusaStrings
|
||||
{
|
||||
|
@@ -2,7 +2,7 @@
|
||||
using Serilog;
|
||||
using YamlDotNet.Serialization;
|
||||
|
||||
namespace Nadeko.Snake;
|
||||
namespace NadekoBot.Medusa;
|
||||
|
||||
/// <summary>
|
||||
/// Loads strings from the shortcut or localizable path
|
||||
|
@@ -1,7 +1,8 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<NoWarn>CS8981</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@@ -9,11 +10,11 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Grpc.AspNetCore" Version="2.44.0" />
|
||||
<PackageReference Include="Serilog" Version="2.10.0" />
|
||||
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.1" />
|
||||
<PackageReference Include="Serilog.Sinks.File" 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.2" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
@@ -6,8 +6,6 @@ using Microsoft.CodeAnalysis;
|
||||
using Microsoft.CodeAnalysis.CSharp;
|
||||
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||
using Microsoft.CodeAnalysis.Text;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Cloneable
|
||||
@@ -23,54 +21,60 @@ namespace Cloneable
|
||||
private const string CLONE_ATTRIBUTE_STRING = "CloneAttribute";
|
||||
private const string IGNORE_CLONE_ATTRIBUTE_STRING = "IgnoreCloneAttribute";
|
||||
|
||||
private const string CLONEABLE_ATTRIBUTE_TEXT = @"// <AutoGenerated/>
|
||||
using System;
|
||||
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; }
|
||||
}
|
||||
}
|
||||
|
||||
namespace " + CLONEABLE_NAMESPACE + @"
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, Inherited = true, AllowMultiple = false)]
|
||||
public 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 CLONE_PROPERTY_ATTRIBUTE_TEXT = @"// <AutoGenerated/>
|
||||
using System;
|
||||
""";
|
||||
|
||||
namespace " + CLONEABLE_NAMESPACE + @"
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Property, Inherited = true, AllowMultiple = false)]
|
||||
public sealed class " + CLONE_ATTRIBUTE_STRING + @" : Attribute
|
||||
{
|
||||
public " + CLONE_ATTRIBUTE_STRING + @"()
|
||||
{
|
||||
}
|
||||
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}}()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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)]
|
||||
public sealed class " + IGNORE_CLONE_ATTRIBUTE_STRING + @" : Attribute
|
||||
{
|
||||
public " + IGNORE_CLONE_ATTRIBUTE_STRING + @"()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
";
|
||||
""";
|
||||
|
||||
private INamedTypeSymbol? _cloneableAttribute;
|
||||
private INamedTypeSymbol? _ignoreCloneAttribute;
|
||||
|
@@ -1,8 +1,7 @@
|
||||
// Code temporarily yeeted from
|
||||
// https://github.com/mostmand/Cloneable/blob/master/Cloneable/CloneableGenerator.cs
|
||||
// because of NRT issue
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using Microsoft.CodeAnalysis;
|
||||
|
||||
namespace Cloneable
|
||||
|
@@ -1,7 +1,7 @@
|
||||
// Code temporarily yeeted from
|
||||
// https://github.com/mostmand/Cloneable/blob/master/Cloneable/CloneableGenerator.cs
|
||||
// because of NRT issue
|
||||
using System.Collections.Generic;
|
||||
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||
|
||||
|
@@ -1,323 +0,0 @@
|
||||
#nullable enable
|
||||
using System;
|
||||
using System.CodeDom.Compiler;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.CodeAnalysis.CSharp;
|
||||
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||
using Microsoft.CodeAnalysis.Text;
|
||||
|
||||
namespace NadekoBot.Generators.Command;
|
||||
|
||||
[Generator]
|
||||
public class CommandAttributesGenerator : IIncrementalGenerator
|
||||
{
|
||||
public const string ATTRIBUTE = @"// <AutoGenerated />
|
||||
|
||||
namespace NadekoBot.Common;
|
||||
|
||||
[System.AttributeUsage(System.AttributeTargets.Method)]
|
||||
public class CmdAttribute : System.Attribute
|
||||
{
|
||||
|
||||
}";
|
||||
|
||||
public class MethodModel
|
||||
{
|
||||
public string? Namespace { get; }
|
||||
public IReadOnlyCollection<string> Classes { get; }
|
||||
public string ReturnType { get; }
|
||||
public string MethodName { get; }
|
||||
public IEnumerable<string> Params { get; }
|
||||
|
||||
public MethodModel(string? ns, IReadOnlyCollection<string> classes, string returnType, string methodName, IEnumerable<string> @params)
|
||||
{
|
||||
Namespace = ns;
|
||||
Classes = classes;
|
||||
ReturnType = returnType;
|
||||
MethodName = methodName;
|
||||
Params = @params;
|
||||
}
|
||||
}
|
||||
|
||||
public class FileModel
|
||||
{
|
||||
public string? Namespace { get; }
|
||||
public IReadOnlyCollection<string> ClassHierarchy { get; }
|
||||
public IReadOnlyCollection<MethodModel> Methods { get; }
|
||||
|
||||
public FileModel(string? ns, IReadOnlyCollection<string> classHierarchy, IReadOnlyCollection<MethodModel> methods)
|
||||
{
|
||||
Namespace = ns;
|
||||
ClassHierarchy = classHierarchy;
|
||||
Methods = methods;
|
||||
}
|
||||
}
|
||||
|
||||
public void Initialize(IncrementalGeneratorInitializationContext context)
|
||||
{
|
||||
// #if DEBUG
|
||||
// SpinWait.SpinUntil(() => Debugger.IsAttached);
|
||||
// #endif
|
||||
context.RegisterPostInitializationOutput(static ctx => ctx.AddSource(
|
||||
"CmdAttribute.g.cs",
|
||||
SourceText.From(ATTRIBUTE, Encoding.UTF8)));
|
||||
|
||||
var methods = context.SyntaxProvider
|
||||
.CreateSyntaxProvider(
|
||||
static (node, _) => node is MethodDeclarationSyntax { AttributeLists.Count: > 0 },
|
||||
static (ctx, cancel) => Transform(ctx, cancel))
|
||||
.Where(static m => m is not null)
|
||||
.Where(static m => m?.ChildTokens().Any(static x => x.IsKind(SyntaxKind.PublicKeyword)) ?? false);
|
||||
|
||||
var compilationMethods = context.CompilationProvider.Combine(methods.Collect());
|
||||
|
||||
context.RegisterSourceOutput(compilationMethods,
|
||||
static (ctx, tuple) => RegisterAction(in ctx, tuple.Left, in tuple.Right));
|
||||
}
|
||||
|
||||
private static void RegisterAction(in SourceProductionContext ctx,
|
||||
Compilation comp,
|
||||
in ImmutableArray<MethodDeclarationSyntax?> methods)
|
||||
{
|
||||
if (methods is { IsDefaultOrEmpty: true })
|
||||
return;
|
||||
|
||||
var models = GetModels(comp, methods, ctx.CancellationToken);
|
||||
|
||||
foreach (var model in models)
|
||||
{
|
||||
var name = $"{model.Namespace}.{string.Join(".", model.ClassHierarchy)}.g.cs";
|
||||
try
|
||||
{
|
||||
Debug.WriteLine($"Writing {name}");
|
||||
var source = GetSourceText(model);
|
||||
ctx.AddSource(name, SourceText.From(source, Encoding.UTF8));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine($"Error writing source file {name}\n" + ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static string GetSourceText(FileModel model)
|
||||
{
|
||||
using var sw = new StringWriter();
|
||||
using var tw = new IndentedTextWriter(sw);
|
||||
|
||||
tw.WriteLine("// <AutoGenerated />");
|
||||
tw.WriteLine("#pragma warning disable CS1066");
|
||||
|
||||
if (model.Namespace is not null)
|
||||
{
|
||||
tw.WriteLine($"namespace {model.Namespace};");
|
||||
tw.WriteLine();
|
||||
}
|
||||
|
||||
foreach (var className in model.ClassHierarchy)
|
||||
{
|
||||
tw.WriteLine($"public partial class {className}");
|
||||
tw.WriteLine("{");
|
||||
tw.Indent ++;
|
||||
}
|
||||
|
||||
foreach (var method in model.Methods)
|
||||
{
|
||||
tw.WriteLine("[NadekoCommand]");
|
||||
tw.WriteLine("[NadekoDescription]");
|
||||
tw.WriteLine("[Aliases]");
|
||||
tw.WriteLine($"public partial {method.ReturnType} {method.MethodName}({string.Join(", ", method.Params)});");
|
||||
}
|
||||
|
||||
foreach (var _ in model.ClassHierarchy)
|
||||
{
|
||||
tw.Indent --;
|
||||
tw.WriteLine("}");
|
||||
}
|
||||
|
||||
tw.Flush();
|
||||
return sw.ToString();
|
||||
}
|
||||
|
||||
private static IReadOnlyCollection<FileModel> GetModels(Compilation compilation,
|
||||
in ImmutableArray<MethodDeclarationSyntax?> inputMethods,
|
||||
CancellationToken cancel)
|
||||
{
|
||||
var models = new List<FileModel>();
|
||||
|
||||
var methods = inputMethods
|
||||
.Where(static x => x is not null)
|
||||
.Distinct();
|
||||
|
||||
var methodModels = methods
|
||||
.Select(x => MethodDeclarationToMethodModel(compilation, x!));
|
||||
|
||||
var groups = methodModels
|
||||
.GroupBy(static x => $"{x.Namespace}.{string.Join(".", x.Classes)}");
|
||||
|
||||
foreach (var group in groups)
|
||||
{
|
||||
if (cancel.IsCancellationRequested)
|
||||
return new Collection<FileModel>();
|
||||
|
||||
if (group is null)
|
||||
continue;
|
||||
|
||||
var elems = group.ToList();
|
||||
if (elems.Count is 0)
|
||||
continue;
|
||||
|
||||
var model = new FileModel(
|
||||
methods: elems,
|
||||
ns: elems[0].Namespace,
|
||||
classHierarchy: elems[0].Classes
|
||||
);
|
||||
|
||||
models.Add(model);
|
||||
}
|
||||
|
||||
|
||||
return models;
|
||||
}
|
||||
|
||||
private static MethodModel MethodDeclarationToMethodModel(Compilation comp, MethodDeclarationSyntax decl)
|
||||
{
|
||||
// SpinWait.SpinUntil(static () => Debugger.IsAttached);
|
||||
|
||||
var semanticModel = comp.GetSemanticModel(decl.SyntaxTree);
|
||||
var methodModel = new MethodModel(
|
||||
@params: decl.ParameterList.Parameters
|
||||
.Where(p => p.Type is not null)
|
||||
.Select(p =>
|
||||
{
|
||||
var prefix = p.Modifiers.Any(static x => x.IsKind(SyntaxKind.ParamsKeyword))
|
||||
? "params "
|
||||
: string.Empty;
|
||||
|
||||
var type = semanticModel
|
||||
.GetTypeInfo(p.Type!)
|
||||
.Type
|
||||
?.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat);
|
||||
|
||||
|
||||
var name = p.Identifier.Text;
|
||||
|
||||
var suffix = string.Empty;
|
||||
if (p.Default is not null)
|
||||
{
|
||||
if (p.Default.Value is LiteralExpressionSyntax)
|
||||
{
|
||||
suffix = " = " + p.Default.Value;
|
||||
}
|
||||
else if (p.Default.Value is MemberAccessExpressionSyntax maes)
|
||||
{
|
||||
var maesSemModel = comp.GetSemanticModel(maes.SyntaxTree);
|
||||
var sym = maesSemModel.GetSymbolInfo(maes.Name);
|
||||
if (sym.Symbol is null)
|
||||
{
|
||||
suffix = " = " + p.Default.Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
suffix = " = " + sym.Symbol.ToDisplayString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $"{prefix}{type} {name}{suffix}";
|
||||
})
|
||||
.ToList(),
|
||||
methodName: decl.Identifier.Text,
|
||||
returnType: decl.ReturnType.ToString(),
|
||||
ns: GetNamespace(decl),
|
||||
classes: GetClasses(decl)
|
||||
);
|
||||
|
||||
return methodModel;
|
||||
}
|
||||
|
||||
//https://github.com/andrewlock/NetEscapades.EnumGenerators/blob/main/src/NetEscapades.EnumGenerators/EnumGenerator.cs
|
||||
static string? GetNamespace(MethodDeclarationSyntax declarationSyntax)
|
||||
{
|
||||
// determine the namespace the class is declared in, if any
|
||||
string? nameSpace = null;
|
||||
var parentOfInterest = declarationSyntax.Parent;
|
||||
while (parentOfInterest is not null)
|
||||
{
|
||||
parentOfInterest = parentOfInterest.Parent;
|
||||
|
||||
if (parentOfInterest is BaseNamespaceDeclarationSyntax ns)
|
||||
{
|
||||
nameSpace = ns.Name.ToString();
|
||||
while (true)
|
||||
{
|
||||
if (ns.Parent is not NamespaceDeclarationSyntax parent)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
ns = parent;
|
||||
nameSpace = $"{ns.Name}.{nameSpace}";
|
||||
}
|
||||
|
||||
return nameSpace;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return nameSpace;
|
||||
}
|
||||
|
||||
static IReadOnlyCollection<string> GetClasses(MethodDeclarationSyntax declarationSyntax)
|
||||
{
|
||||
// determine the namespace the class is declared in, if any
|
||||
var classes = new LinkedList<string>();
|
||||
var parentOfInterest = declarationSyntax.Parent;
|
||||
while (parentOfInterest is not null)
|
||||
{
|
||||
if (parentOfInterest is ClassDeclarationSyntax cds)
|
||||
{
|
||||
classes.AddFirst(cds.Identifier.ToString());
|
||||
}
|
||||
|
||||
parentOfInterest = parentOfInterest.Parent;
|
||||
}
|
||||
|
||||
Debug.WriteLine($"Method {declarationSyntax.Identifier.Text} has {classes.Count} classes");
|
||||
|
||||
return classes;
|
||||
}
|
||||
|
||||
private static MethodDeclarationSyntax? Transform(GeneratorSyntaxContext ctx, CancellationToken cancel)
|
||||
{
|
||||
var methodDecl = ctx.Node as MethodDeclarationSyntax;
|
||||
if (methodDecl is null)
|
||||
return default;
|
||||
|
||||
foreach (var attListSyntax in methodDecl.AttributeLists)
|
||||
{
|
||||
foreach (var attSyntax in attListSyntax.Attributes)
|
||||
{
|
||||
if (cancel.IsCancellationRequested)
|
||||
return default;
|
||||
|
||||
var symbol = ctx.SemanticModel.GetSymbolInfo(attSyntax).Symbol;
|
||||
if (symbol is not IMethodSymbol attSymbol)
|
||||
continue;
|
||||
|
||||
if (attSymbol.ContainingType.ToDisplayString() == "NadekoBot.Common.CmdAttribute")
|
||||
return methodDecl;
|
||||
}
|
||||
}
|
||||
|
||||
return default;
|
||||
}
|
||||
}
|
@@ -1,10 +1,6 @@
|
||||
#nullable enable
|
||||
using System;
|
||||
using System.CodeDom.Compiler;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Newtonsoft.Json;
|
||||
@@ -26,24 +22,23 @@ namespace NadekoBot.Generators
|
||||
[Generator]
|
||||
public class LocalizedStringsGenerator : ISourceGenerator
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}";
|
||||
// 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)
|
||||
@@ -55,6 +50,7 @@ namespace NadekoBot.Generators
|
||||
using (var stringWriter = new StringWriter())
|
||||
using (var sw = new IndentedTextWriter(stringWriter))
|
||||
{
|
||||
sw.WriteLine("#pragma warning disable CS8981");
|
||||
sw.WriteLine("namespace NadekoBot;");
|
||||
sw.WriteLine();
|
||||
|
||||
@@ -62,6 +58,7 @@ namespace NadekoBot.Generators
|
||||
sw.WriteLine("{");
|
||||
sw.Indent++;
|
||||
|
||||
var typedParamStrings = new List<string>(10);
|
||||
foreach (var field in fields)
|
||||
{
|
||||
var matches = Regex.Matches(field.Value, @"{(?<num>\d)[}:]");
|
||||
@@ -71,20 +68,30 @@ 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--;
|
||||
@@ -95,7 +102,7 @@ namespace NadekoBot.Generators
|
||||
context.AddSource("strs.g.cs", stringWriter.ToString());
|
||||
}
|
||||
|
||||
context.AddSource("LocStr.g.cs", LOC_STR_SOURCE);
|
||||
// context.AddSource("LocStr.g.cs", LOC_STR_SOURCE);
|
||||
}
|
||||
|
||||
private List<TranslationPair> GetFields(string? dataText)
|
||||
|
@@ -5,14 +5,15 @@
|
||||
<LangVersion>latest</LangVersion>
|
||||
<IncludeBuildOutput>false</IncludeBuildOutput>
|
||||
<IsRoslynComponent>true</IsRoslynComponent>
|
||||
<ImplicitUsings>true</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
<ItemGroup>
|
||||
<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.1" PrivateAssets="all" GeneratePathProperty="true" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" PrivateAssets="all" GeneratePathProperty="true" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
<PropertyGroup>
|
||||
<GetTargetPathDependsOn>$(GetTargetPathDependsOn);GetDependencyTargetPaths</GetTargetPathDependsOn>
|
||||
</PropertyGroup>
|
||||
@@ -23,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
|
||||
{
|
||||
@@ -21,7 +21,7 @@ namespace NadekoBot.Tests
|
||||
var stringsSource = new LocalFileStringsSource(
|
||||
responsesPath,
|
||||
commandsPath);
|
||||
var strings = new LocalBotStringsProvider(stringsSource);
|
||||
var strings = new MemoryBotStringsProvider(stringsSource);
|
||||
|
||||
var culture = new CultureInfo("en-US");
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace NadekoBot.Tests
|
||||
|| !(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();
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace NadekoBot.Tests
|
||||
aliasesPath);
|
||||
|
||||
var methodNames = GetCommandMethodNames();
|
||||
|
||||
|
||||
var isSuccess = true;
|
||||
foreach (var methodName in methodNames)
|
||||
{
|
||||
@@ -99,31 +99,33 @@ namespace NadekoBot.Tests
|
||||
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,6 +1,6 @@
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using NadekoBot.Extensions;
|
||||
using Nadeko.Common;
|
||||
using NadekoBot.Services;
|
||||
using NUnit.Framework;
|
||||
|
||||
|
@@ -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;
|
||||
|
@@ -1,4 +1,4 @@
|
||||
using NadekoBot.Common;
|
||||
using Nadeko.Common;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace NadekoBot.Tests
|
||||
|
@@ -1,18 +1,17 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<LangVersion>10.0</LangVersion>
|
||||
<EnablePreviewFeatures>True</EnablePreviewFeatures>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="NUnit" Version="3.13.2" />
|
||||
<PackageReference Include="NUnit" Version="3.13.3" />
|
||||
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
|
||||
<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;
|
||||
|
||||
|
@@ -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);
|
@@ -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="6.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>
|
@@ -4,7 +4,7 @@ using System.Buffers;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Ayu.Discord.Voice
|
||||
namespace NadekoBot.Voice
|
||||
{
|
||||
public sealed class PoopyBufferImmortalized : ISongBuffer
|
||||
{
|
@@ -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
|
||||
{
|
||||
@@ -147,7 +147,7 @@ namespace Ayu.Discord.Voice
|
||||
Buffer.BlockCopy(nonce, 0, rtpData, rtpDataLength - 4, 4);
|
||||
|
||||
gw.SendRtpData(rtpData, rtpDataLength);
|
||||
// todo future 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
|
@@ -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
|
||||
{
|
||||
@@ -237,20 +237,25 @@ namespace Ayu.Discord.Voice
|
||||
_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);
|
||||
|
||||
@@ -367,4 +372,4 @@ namespace Ayu.Discord.Voice
|
||||
await complete.Task;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -20,9 +20,8 @@ namespace NadekoBot.VotesApi
|
||||
public AuthHandler(IOptionsMonitor<AuthenticationSchemeOptions> options,
|
||||
ILoggerFactory logger,
|
||||
UrlEncoder encoder,
|
||||
ISystemClock clock,
|
||||
IConfiguration conf)
|
||||
: base(options, logger, encoder, clock)
|
||||
: base(options, logger, encoder)
|
||||
=> _conf = conf;
|
||||
|
||||
protected override Task<AuthenticateResult> HandleAuthenticateAsync()
|
||||
|
@@ -1,13 +1,13 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="MorseCode.ITask" Version="2.0.3" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
@@ -357,3 +357,4 @@ resharper_arrange_redundant_parentheses_highlighting = hint
|
||||
|
||||
# IDE0011: Add braces
|
||||
dotnet_diagnostic.IDE0011.severity = warning
|
||||
|
||||
|
@@ -1,10 +1,10 @@
|
||||
#nullable disable
|
||||
using DryIoc;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using NadekoBot.Common.Configs;
|
||||
using NadekoBot.Common.ModuleBehaviors;
|
||||
using NadekoBot.Db;
|
||||
using NadekoBot.Modules.Administration;
|
||||
using NadekoBot.Services.Database.Models;
|
||||
using NadekoBot.Db.Models;
|
||||
using System.Collections.Immutable;
|
||||
using System.Diagnostics;
|
||||
using System.Reflection;
|
||||
@@ -12,16 +12,15 @@ using RunMode = Discord.Commands.RunMode;
|
||||
|
||||
namespace NadekoBot;
|
||||
|
||||
public sealed class Bot
|
||||
public sealed class Bot : IBot
|
||||
{
|
||||
public event Func<GuildConfig, Task> JoinedGuild = delegate { return Task.CompletedTask; };
|
||||
|
||||
public DiscordSocketClient Client { get; }
|
||||
public ImmutableArray<GuildConfig> AllGuildConfigs { get; private set; }
|
||||
public IReadOnlyCollection<GuildConfig> AllGuildConfigs { get; private set; }
|
||||
|
||||
private IServiceProvider Services { get; set; }
|
||||
private IContainer Services { get; set; }
|
||||
|
||||
public string Mention { get; private set; }
|
||||
public bool IsReady { get; private set; }
|
||||
public int ShardId { get; set; }
|
||||
|
||||
@@ -30,18 +29,19 @@ public sealed class Bot
|
||||
private readonly DbService _db;
|
||||
|
||||
private readonly IBotCredsProvider _credsProvider;
|
||||
|
||||
private readonly Assembly[] _loadedAssemblies;
|
||||
// private readonly InteractionService _interactionService;
|
||||
|
||||
public Bot(int shardId, int? totalShards)
|
||||
public Bot(int shardId, int? totalShards, string credPath = null)
|
||||
{
|
||||
if (shardId < 0)
|
||||
throw new ArgumentOutOfRangeException(nameof(shardId));
|
||||
ArgumentOutOfRangeException.ThrowIfLessThan(shardId, 0);
|
||||
|
||||
ShardId = shardId;
|
||||
_credsProvider = new BotCredsProvider(totalShards);
|
||||
_credsProvider = new BotCredsProvider(totalShards, credPath);
|
||||
_creds = _credsProvider.GetCreds();
|
||||
|
||||
_db = new(_credsProvider);
|
||||
_db = new NadekoDbService(_credsProvider);
|
||||
|
||||
var messageCacheSize =
|
||||
#if GLOBAL_NADEKO
|
||||
@@ -50,9 +50,9 @@ public sealed class Bot
|
||||
50;
|
||||
#endif
|
||||
|
||||
if(!_creds.UsePrivilegedIntents)
|
||||
if (!_creds.UsePrivilegedIntents)
|
||||
Log.Warning("You are not using privileged intents. Some features will not work properly");
|
||||
|
||||
|
||||
Client = new(new()
|
||||
{
|
||||
MessageCacheSize = messageCacheSize,
|
||||
@@ -67,21 +67,27 @@ public sealed class Bot
|
||||
? GatewayIntents.All
|
||||
: GatewayIntents.AllUnprivileged,
|
||||
LogGatewayIntentWarnings = false,
|
||||
FormatUsersInBidirectionalUnicode = false,
|
||||
DefaultRetryMode = RetryMode.Retry502
|
||||
});
|
||||
|
||||
_commandService = new(new()
|
||||
{
|
||||
CaseSensitiveCommands = false,
|
||||
DefaultRunMode = RunMode.Sync
|
||||
DefaultRunMode = RunMode.Sync,
|
||||
});
|
||||
|
||||
// _interactionService = new(Client.Rest);
|
||||
|
||||
Client.Log += Client_Log;
|
||||
_loadedAssemblies = new[]
|
||||
{
|
||||
typeof(Bot).Assembly, // bot
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public List<ulong> GetCurrentGuildIds()
|
||||
public IReadOnlyList<ulong> GetCurrentGuildIds()
|
||||
=> Client.Guilds.Select(x => x.Id).ToList();
|
||||
|
||||
private void AddServices()
|
||||
@@ -93,124 +99,89 @@ public sealed class Bot
|
||||
using (var uow = _db.GetDbContext())
|
||||
{
|
||||
uow.EnsureUserCreated(bot.Id, bot.Username, bot.Discriminator, bot.AvatarId);
|
||||
AllGuildConfigs = uow.GuildConfigs.GetAllGuildConfigs(startingGuildIdList).ToImmutableArray();
|
||||
AllGuildConfigs = uow.Set<GuildConfig>().GetAllGuildConfigs(startingGuildIdList).ToImmutableArray();
|
||||
}
|
||||
|
||||
var svcs = new ServiceCollection().AddTransient(_ => _credsProvider.GetCreds()) // bot creds
|
||||
.AddSingleton(_credsProvider)
|
||||
.AddSingleton(_db) // database
|
||||
.AddRedis(_creds.RedisOptions) // redis
|
||||
.AddSingleton(Client) // discord socket client
|
||||
.AddSingleton(_commandService)
|
||||
// .AddSingleton(_interactionService)
|
||||
.AddSingleton(this)
|
||||
.AddSingleton<ISeria, JsonSeria>()
|
||||
.AddSingleton<IPubSub, RedisPubSub>()
|
||||
.AddSingleton<IConfigSeria, YamlSeria>()
|
||||
.AddBotStringsServices(_creds.TotalShards)
|
||||
.AddConfigServices()
|
||||
.AddConfigMigrators()
|
||||
.AddMemoryCache()
|
||||
// music
|
||||
.AddMusic();
|
||||
// admin
|
||||
#if GLOBAL_NADEKO
|
||||
svcs.AddSingleton<ILogCommandService, DummyLogCommandService>();
|
||||
#endif
|
||||
// var svcs = new StandardKernel(new NinjectSettings()
|
||||
// {
|
||||
// // ThrowOnGetServiceNotFound = true,
|
||||
// ActivationCacheDisabled = true,
|
||||
// });
|
||||
|
||||
svcs.AddHttpClient();
|
||||
svcs.AddHttpClient("memelist")
|
||||
.ConfigurePrimaryHttpMessageHandler(() => new HttpClientHandler
|
||||
{
|
||||
AllowAutoRedirect = false
|
||||
});
|
||||
var svcs = new Container();
|
||||
|
||||
// this is required in order for medusa unloading to work
|
||||
// svcs.Components.Remove<IPlanner, Planner>();
|
||||
// svcs.Components.Add<IPlanner, RemovablePlanner>();
|
||||
|
||||
svcs.AddSingleton<IBotCredentials, IBotCredentials>(_ => _credsProvider.GetCreds());
|
||||
svcs.AddSingleton<DbService, DbService>(_db);
|
||||
svcs.AddSingleton<IBotCredsProvider>(_credsProvider);
|
||||
svcs.AddSingleton<DiscordSocketClient>(Client);
|
||||
svcs.AddSingleton<CommandService>(_commandService);
|
||||
svcs.AddSingleton<Bot>(this);
|
||||
svcs.AddSingleton<IBot>(this);
|
||||
|
||||
svcs.AddSingleton<ISeria, JsonSeria>();
|
||||
svcs.AddSingleton<IConfigSeria, YamlSeria>();
|
||||
svcs.AddSingleton<IMemoryCache, MemoryCache>(new MemoryCache(new MemoryCacheOptions()));
|
||||
svcs.AddSingleton<IBehaviorHandler, BehaviorHandler>();
|
||||
svcs.AddSingleton<ILocalization, Localization>();
|
||||
|
||||
|
||||
foreach (var a in _loadedAssemblies)
|
||||
{
|
||||
svcs.AddConfigServices(a)
|
||||
.AddLifetimeServices(a);
|
||||
}
|
||||
|
||||
svcs.AddMusic()
|
||||
.AddCache(_creds)
|
||||
.AddHttpClients();
|
||||
|
||||
if (Environment.GetEnvironmentVariable("NADEKOBOT_IS_COORDINATED") != "1")
|
||||
{
|
||||
svcs.AddSingleton<ICoordinator, SingleProcessCoordinator>();
|
||||
}
|
||||
else
|
||||
{
|
||||
svcs.AddSingleton<RemoteGrpcCoordinator>()
|
||||
.AddSingleton<ICoordinator>(x => x.GetRequiredService<RemoteGrpcCoordinator>())
|
||||
.AddSingleton<IReadyExecutor>(x => x.GetRequiredService<RemoteGrpcCoordinator>());
|
||||
svcs.AddSingleton<RemoteGrpcCoordinator>();
|
||||
svcs.AddSingleton<ICoordinator>(_ => svcs.GetRequiredService<RemoteGrpcCoordinator>());
|
||||
svcs.AddSingleton<IReadyExecutor>(_ => svcs.GetRequiredService<RemoteGrpcCoordinator>());
|
||||
}
|
||||
|
||||
svcs.AddSingleton<RedisLocalDataCache>()
|
||||
.AddSingleton<ILocalDataCache>(x => x.GetRequiredService<RedisLocalDataCache>())
|
||||
.AddSingleton<RedisImagesCache>()
|
||||
.AddSingleton<IImageCache>(x => x.GetRequiredService<RedisImagesCache>())
|
||||
.AddSingleton<IReadyExecutor>(x => x.GetRequiredService<RedisImagesCache>())
|
||||
.AddSingleton<IDataCache, RedisCache>();
|
||||
|
||||
svcs.Scan(scan => scan.FromAssemblyOf<IReadyExecutor>()
|
||||
.AddClasses(classes => classes.AssignableToAny(
|
||||
// services
|
||||
typeof(INService),
|
||||
|
||||
// behaviours
|
||||
typeof(IExecOnMessage),
|
||||
typeof(IInputTransformer),
|
||||
typeof(IExecPreCommand),
|
||||
typeof(IExecPostCommand),
|
||||
typeof(IExecNoCommand))
|
||||
.WithoutAttribute<DontAddToIocContainerAttribute>()
|
||||
#if GLOBAL_NADEKO
|
||||
.WithoutAttribute<NoPublicBotAttribute>()
|
||||
#endif
|
||||
)
|
||||
.AsSelfWithInterfaces()
|
||||
.WithSingletonLifetime());
|
||||
svcs.AddSingleton<IServiceProvider>(svcs);
|
||||
|
||||
//initialize Services
|
||||
Services = svcs.BuildServiceProvider();
|
||||
Services = svcs;
|
||||
Services.GetRequiredService<IBehaviorHandler>().Initialize();
|
||||
|
||||
if (Client.ShardId == 0)
|
||||
ApplyConfigMigrations();
|
||||
|
||||
_ = LoadTypeReaders(typeof(Bot).Assembly);
|
||||
foreach (var a in _loadedAssemblies)
|
||||
{
|
||||
LoadTypeReaders(a);
|
||||
}
|
||||
|
||||
sw.Stop();
|
||||
Log.Information( "All services loaded in {ServiceLoadTime:F2}s", sw.Elapsed.TotalSeconds);
|
||||
Log.Information("All services loaded in {ServiceLoadTime:F2}s", sw.Elapsed.TotalSeconds);
|
||||
}
|
||||
|
||||
private void ApplyConfigMigrations()
|
||||
private void LoadTypeReaders(Assembly assembly)
|
||||
{
|
||||
// execute all migrators
|
||||
var migrators = Services.GetServices<IConfigMigrator>();
|
||||
foreach (var migrator in migrators)
|
||||
migrator.EnsureMigrated();
|
||||
}
|
||||
|
||||
private IEnumerable<object> LoadTypeReaders(Assembly assembly)
|
||||
{
|
||||
Type[] allTypes;
|
||||
try
|
||||
{
|
||||
allTypes = assembly.GetTypes();
|
||||
}
|
||||
catch (ReflectionTypeLoadException ex)
|
||||
{
|
||||
Log.Warning(ex.LoaderExceptions[0], "Error getting types");
|
||||
return Enumerable.Empty<object>();
|
||||
}
|
||||
|
||||
var filteredTypes = allTypes.Where(x => x.IsSubclassOf(typeof(TypeReader))
|
||||
var filteredTypes = assembly.GetExportedTypes()
|
||||
.Where(x => x.IsSubclassOf(typeof(TypeReader))
|
||||
&& x.BaseType?.GetGenericArguments().Length > 0
|
||||
&& !x.IsAbstract);
|
||||
|
||||
var toReturn = new List<object>();
|
||||
foreach (var ft in filteredTypes)
|
||||
{
|
||||
var x = (TypeReader)ActivatorUtilities.CreateInstance(Services, ft);
|
||||
var baseType = ft.BaseType;
|
||||
if (baseType is null)
|
||||
continue;
|
||||
var typeArgs = baseType.GetGenericArguments();
|
||||
_commandService.AddTypeReader(typeArgs[0], x);
|
||||
toReturn.Add(x);
|
||||
}
|
||||
|
||||
return toReturn;
|
||||
var typeReader = (TypeReader)ActivatorUtilities.CreateInstance(Services, ft);
|
||||
var typeArgs = baseType.GetGenericArguments();
|
||||
_commandService.AddTypeReader(typeArgs[0], typeReader);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task LoginAsync(string token)
|
||||
@@ -250,13 +221,14 @@ public sealed class Bot
|
||||
LoginErrorHandler.Handle(ex);
|
||||
Helpers.ReadErrorAndExit(4);
|
||||
}
|
||||
|
||||
|
||||
await clientReady.Task.ConfigureAwait(false);
|
||||
Client.Ready -= SetClientReady;
|
||||
|
||||
|
||||
Client.JoinedGuild += Client_JoinedGuild;
|
||||
Client.LeftGuild += Client_LeftGuild;
|
||||
|
||||
// _ = Client.SetStatusAsync(UserStatus.Online);
|
||||
Log.Information("Shard {ShardId} logged in", Client.ShardId);
|
||||
}
|
||||
|
||||
@@ -286,12 +258,11 @@ public sealed class Bot
|
||||
{
|
||||
if (ShardId == 0)
|
||||
await _db.SetupAsync();
|
||||
|
||||
|
||||
var sw = Stopwatch.StartNew();
|
||||
|
||||
await LoginAsync(_creds.Token);
|
||||
|
||||
Mention = Client.CurrentUser.Mention;
|
||||
|
||||
Log.Information("Shard {ShardId} loading services...", Client.ShardId);
|
||||
try
|
||||
{
|
||||
@@ -310,13 +281,36 @@ public sealed class Bot
|
||||
// start handling messages received in commandhandler
|
||||
await commandHandler.StartHandling();
|
||||
|
||||
await _commandService.AddModulesAsync(typeof(Bot).Assembly, Services);
|
||||
foreach (var a in _loadedAssemblies)
|
||||
{
|
||||
await _commandService.AddModulesAsync(a, Services);
|
||||
}
|
||||
|
||||
// await _interactionService.AddModulesAsync(typeof(Bot).Assembly, Services);
|
||||
IsReady = true;
|
||||
|
||||
await EnsureBotOwnershipAsync();
|
||||
_ = Task.Run(ExecuteReadySubscriptions);
|
||||
Log.Information("Shard {ShardId} ready", Client.ShardId);
|
||||
}
|
||||
|
||||
private async ValueTask EnsureBotOwnershipAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (_creds.OwnerIds.Count != 0)
|
||||
return;
|
||||
|
||||
Log.Information("Initializing Owner Id...");
|
||||
var info = await Client.GetApplicationInfoAsync();
|
||||
_credsProvider.ModifyCredsFile(x => x.OwnerIds = new[] { info.Owner.Id });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Warning("Getting application info failed: {ErrorMessage}", ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
private Task ExecuteReadySubscriptions()
|
||||
{
|
||||
var readyExecutors = Services.GetServices<IReadyExecutor>();
|
||||
@@ -345,29 +339,30 @@ public sealed class Bot
|
||||
|
||||
if (arg.Exception is { InnerException: WebSocketClosedException { CloseCode: 4014 } })
|
||||
{
|
||||
Log.Error(@"
|
||||
Login failed.
|
||||
|
||||
*** Please enable privileged intents ***
|
||||
|
||||
Certain Nadeko features require Discord's privileged gateway intents.
|
||||
These include greeting and goodbye messages, as well as creating the Owner message channels for DM forwarding.
|
||||
|
||||
How to enable privileged intents:
|
||||
1. Head over to the Discord Developer Portal https://discord.com/developers/applications/
|
||||
2. Select your Application.
|
||||
3. Click on `Bot` in the left side navigation panel, and scroll down to the intents section.
|
||||
4. Enable all intents.
|
||||
5. Restart your bot.
|
||||
|
||||
Read this only if your bot is in 100 or more servers:
|
||||
|
||||
You'll need to apply to use the intents with Discord, but for small selfhosts, all that is required is enabling the intents in the developer portal.
|
||||
Yes, this is a new thing from Discord, as of October 2020. No, there's nothing we can do about it. Yes, we're aware it worked before.
|
||||
While waiting for your bot to be accepted, you can change the 'usePrivilegedIntents' inside your creds.yml to 'false', although this will break many of the nadeko's features");
|
||||
Log.Error("""
|
||||
Login failed.
|
||||
|
||||
*** Please enable privileged intents ***
|
||||
|
||||
Certain Nadeko features require Discord's privileged gateway intents.
|
||||
These include greeting and goodbye messages, as well as creating the Owner message channels for DM forwarding.
|
||||
|
||||
How to enable privileged intents:
|
||||
1. Head over to the Discord Developer Portal https://discord.com/developers/applications/
|
||||
2. Select your Application.
|
||||
3. Click on `Bot` in the left side navigation panel, and scroll down to the intents section.
|
||||
4. Enable all intents.
|
||||
5. Restart your bot.
|
||||
|
||||
Read this only if your bot is in 100 or more servers:
|
||||
|
||||
You'll need to apply to use the intents with Discord, but for small selfhosts, all that is required is enabling the intents in the developer portal.
|
||||
Yes, this is a new thing from Discord, as of October 2020. No, there's nothing we can do about it. Yes, we're aware it worked before.
|
||||
While waiting for your bot to be accepted, you can change the 'usePrivilegedIntents' inside your creds.yml to 'false', although this will break many of the nadeko's features
|
||||
""");
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
|
||||
#if GLOBAL_NADEKO || DEBUG
|
||||
if (arg.Exception is not null)
|
||||
Log.Warning(arg.Exception, "{ErrorSource} | {ErrorMessage}", arg.Source, arg.Message);
|
||||
|
@@ -1,13 +0,0 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace NadekoBot.Common.Attributes;
|
||||
|
||||
[AttributeUsage(AttributeTargets.Method)]
|
||||
public sealed class NadekoCommandAttribute : CommandAttribute
|
||||
{
|
||||
public string MethodName { get; }
|
||||
|
||||
public NadekoCommandAttribute([CallerMemberName] string memberName = "")
|
||||
: base(CommandNameLoadHelper.GetCommandNameFor(memberName))
|
||||
=> MethodName = memberName.ToLowerInvariant();
|
||||
}
|
@@ -1,30 +0,0 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace NadekoBot.Common.Attributes;
|
||||
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
internal sealed class NadekoModuleAttribute : GroupAttribute
|
||||
{
|
||||
public NadekoModuleAttribute(string moduleName)
|
||||
: base(moduleName)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Method)]
|
||||
internal sealed class NadekoDescriptionAttribute : SummaryAttribute
|
||||
{
|
||||
public NadekoDescriptionAttribute([CallerMemberName] string name = "")
|
||||
: base(name.ToLowerInvariant())
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Method)]
|
||||
internal sealed class NadekoUsageAttribute : RemarksAttribute
|
||||
{
|
||||
public NadekoUsageAttribute([CallerMemberName] string name = "")
|
||||
: base(name.ToLowerInvariant())
|
||||
{
|
||||
}
|
||||
}
|
@@ -1,10 +0,0 @@
|
||||
namespace NadekoBot.Common.Attributes;
|
||||
|
||||
[AttributeUsage(AttributeTargets.Method)]
|
||||
public sealed class NadekoOptionsAttribute : Attribute
|
||||
{
|
||||
public Type OptionType { get; set; }
|
||||
|
||||
public NadekoOptionsAttribute(Type t)
|
||||
=> OptionType = t;
|
||||
}
|
@@ -1,821 +0,0 @@
|
||||
#nullable disable
|
||||
#pragma warning disable
|
||||
// License MIT
|
||||
// Source: https://github.com/i3arnon/ConcurrentHashSet
|
||||
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace System.Collections.Generic;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a thread-safe hash-based unique collection.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the items in the collection.</typeparam>
|
||||
/// <remarks>
|
||||
/// All public members of <see cref="ConcurrentHashSet{T}" /> are thread-safe and may be used
|
||||
/// concurrently from multiple threads.
|
||||
/// </remarks>
|
||||
[DebuggerDisplay("Count = {Count}")]
|
||||
public sealed class ConcurrentHashSet<T> : IReadOnlyCollection<T>, ICollection<T>
|
||||
{
|
||||
private const int DEFAULT_CAPACITY = 31;
|
||||
private const int MAX_LOCK_NUMBER = 1024;
|
||||
|
||||
private static int DefaultConcurrencyLevel
|
||||
=> PlatformHelper.ProcessorCount;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value that indicates whether the <see cref="ConcurrentHashSet{T}" /> is empty.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// true if the <see cref="ConcurrentHashSet{T}" /> is empty; otherwise,
|
||||
/// false.
|
||||
/// </value>
|
||||
public bool IsEmpty
|
||||
{
|
||||
get
|
||||
{
|
||||
var acquiredLocks = 0;
|
||||
try
|
||||
{
|
||||
AcquireAllLocks(ref acquiredLocks);
|
||||
|
||||
for (var i = 0; i < tables.CountPerLock.Length; i++)
|
||||
{
|
||||
if (tables.CountPerLock[i] != 0)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
ReleaseLocks(0, acquiredLocks);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool ICollection<T>.IsReadOnly
|
||||
=> false;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of items contained in the
|
||||
/// <see
|
||||
/// cref="ConcurrentHashSet{T}" />
|
||||
/// .
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The number of items contained in the
|
||||
/// <see
|
||||
/// cref="ConcurrentHashSet{T}" />
|
||||
/// .
|
||||
/// </value>
|
||||
/// <remarks>
|
||||
/// Count has snapshot semantics and represents the number of items in the
|
||||
/// <see
|
||||
/// cref="ConcurrentHashSet{T}" />
|
||||
/// at the moment when Count was accessed.
|
||||
/// </remarks>
|
||||
public int Count
|
||||
{
|
||||
get
|
||||
{
|
||||
var count = 0;
|
||||
var acquiredLocks = 0;
|
||||
try
|
||||
{
|
||||
AcquireAllLocks(ref acquiredLocks);
|
||||
|
||||
for (var i = 0; i < tables.CountPerLock.Length; i++)
|
||||
count += tables.CountPerLock[i];
|
||||
}
|
||||
finally
|
||||
{
|
||||
ReleaseLocks(0, acquiredLocks);
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
||||
private readonly IEqualityComparer<T> _comparer;
|
||||
private readonly bool _growLockArray;
|
||||
|
||||
private int budget;
|
||||
private volatile Tables tables;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the
|
||||
/// <see
|
||||
/// cref="ConcurrentHashSet{T}" />
|
||||
/// class that is empty, has the default concurrency level, has the default initial capacity, and
|
||||
/// uses the default comparer for the item type.
|
||||
/// </summary>
|
||||
public ConcurrentHashSet()
|
||||
: this(DefaultConcurrencyLevel, DEFAULT_CAPACITY, true, EqualityComparer<T>.Default)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the
|
||||
/// <see
|
||||
/// cref="ConcurrentHashSet{T}" />
|
||||
/// class that is empty, has the specified concurrency level and capacity, and uses the default
|
||||
/// comparer for the item type.
|
||||
/// </summary>
|
||||
/// <param name="concurrencyLevel">
|
||||
/// The estimated number of threads that will update the
|
||||
/// <see cref="ConcurrentHashSet{T}" /> concurrently.
|
||||
/// </param>
|
||||
/// <param name="capacity">
|
||||
/// The initial number of elements that the
|
||||
/// <see
|
||||
/// cref="ConcurrentHashSet{T}" />
|
||||
/// can contain.
|
||||
/// </param>
|
||||
/// <exception cref="T:System.ArgumentOutOfRangeException">
|
||||
/// <paramref name="concurrencyLevel" /> is
|
||||
/// less than 1.
|
||||
/// </exception>
|
||||
/// <exception cref="T:System.ArgumentOutOfRangeException">
|
||||
/// <paramref name="capacity" /> is less than
|
||||
/// 0.
|
||||
/// </exception>
|
||||
public ConcurrentHashSet(int concurrencyLevel, int capacity)
|
||||
: this(concurrencyLevel, capacity, false, EqualityComparer<T>.Default)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ConcurrentHashSet{T}" />
|
||||
/// class that contains elements copied from the specified
|
||||
/// <see
|
||||
/// cref="T:System.Collections.IEnumerable{T}" />
|
||||
/// , has the default concurrency
|
||||
/// level, has the default initial capacity, and uses the default comparer for the item type.
|
||||
/// </summary>
|
||||
/// <param name="collection">
|
||||
/// The
|
||||
/// <see
|
||||
/// cref="T:System.Collections.IEnumerable{T}" />
|
||||
/// whose elements are copied to
|
||||
/// the new
|
||||
/// <see cref="ConcurrentHashSet{T}" />.
|
||||
/// </param>
|
||||
/// <exception cref="T:System.ArgumentNullException"><paramref name="collection" /> is a null reference.</exception>
|
||||
public ConcurrentHashSet(IEnumerable<T> collection)
|
||||
: this(collection, EqualityComparer<T>.Default)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ConcurrentHashSet{T}" />
|
||||
/// class that is empty, has the specified concurrency level and capacity, and uses the specified
|
||||
/// <see cref="T:System.Collections.Generic.IEqualityComparer{T}" />.
|
||||
/// </summary>
|
||||
/// <param name="comparer">
|
||||
/// The <see cref="T:System.Collections.Generic.IEqualityComparer{T}" />
|
||||
/// implementation to use when comparing items.
|
||||
/// </param>
|
||||
/// <exception cref="T:System.ArgumentNullException"><paramref name="comparer" /> is a null reference.</exception>
|
||||
public ConcurrentHashSet(IEqualityComparer<T> comparer)
|
||||
: this(DefaultConcurrencyLevel, DEFAULT_CAPACITY, true, comparer)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ConcurrentHashSet{T}" />
|
||||
/// class that contains elements copied from the specified
|
||||
/// <see
|
||||
/// cref="T:System.Collections.IEnumerable" />
|
||||
/// , has the default concurrency level, has the default
|
||||
/// initial capacity, and uses the specified
|
||||
/// <see cref="T:System.Collections.Generic.IEqualityComparer{T}" />.
|
||||
/// </summary>
|
||||
/// <param name="collection">
|
||||
/// The
|
||||
/// <see
|
||||
/// cref="T:System.Collections.IEnumerable{T}" />
|
||||
/// whose elements are copied to
|
||||
/// the new
|
||||
/// <see cref="ConcurrentHashSet{T}" />.
|
||||
/// </param>
|
||||
/// <param name="comparer">
|
||||
/// The <see cref="T:System.Collections.Generic.IEqualityComparer{T}" />
|
||||
/// implementation to use when comparing items.
|
||||
/// </param>
|
||||
/// <exception cref="T:System.ArgumentNullException">
|
||||
/// <paramref name="collection" /> is a null reference
|
||||
/// (Nothing in Visual Basic). -or-
|
||||
/// <paramref name="comparer" /> is a null reference (Nothing in Visual Basic).
|
||||
/// </exception>
|
||||
public ConcurrentHashSet(IEnumerable<T> collection, IEqualityComparer<T> comparer)
|
||||
: this(comparer)
|
||||
{
|
||||
if (collection is null)
|
||||
throw new ArgumentNullException(nameof(collection));
|
||||
|
||||
InitializeFromCollection(collection);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ConcurrentHashSet{T}" />
|
||||
/// class that contains elements copied from the specified <see cref="T:System.Collections.IEnumerable" />,
|
||||
/// has the specified concurrency level, has the specified initial capacity, and uses the specified
|
||||
/// <see cref="T:System.Collections.Generic.IEqualityComparer{T}" />.
|
||||
/// </summary>
|
||||
/// <param name="concurrencyLevel">
|
||||
/// The estimated number of threads that will update the
|
||||
/// <see cref="ConcurrentHashSet{T}" /> concurrently.
|
||||
/// </param>
|
||||
/// <param name="collection">
|
||||
/// The <see cref="T:System.Collections.IEnumerable{T}" /> whose elements are copied to the new
|
||||
/// <see cref="ConcurrentHashSet{T}" />.
|
||||
/// </param>
|
||||
/// <param name="comparer">
|
||||
/// The <see cref="T:System.Collections.Generic.IEqualityComparer{T}" /> implementation to use
|
||||
/// when comparing items.
|
||||
/// </param>
|
||||
/// <exception cref="T:System.ArgumentNullException">
|
||||
/// <paramref name="collection" /> is a null reference.
|
||||
/// -or-
|
||||
/// <paramref name="comparer" /> is a null reference.
|
||||
/// </exception>
|
||||
/// <exception cref="T:System.ArgumentOutOfRangeException">
|
||||
/// <paramref name="concurrencyLevel" /> is less than 1.
|
||||
/// </exception>
|
||||
public ConcurrentHashSet(int concurrencyLevel, IEnumerable<T> collection, IEqualityComparer<T> comparer)
|
||||
: this(concurrencyLevel, DEFAULT_CAPACITY, false, comparer)
|
||||
{
|
||||
if (collection is null)
|
||||
throw new ArgumentNullException(nameof(collection));
|
||||
if (comparer is null)
|
||||
throw new ArgumentNullException(nameof(comparer));
|
||||
|
||||
InitializeFromCollection(collection);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ConcurrentHashSet{T}" />
|
||||
/// class that is empty, has the specified concurrency level, has the specified initial capacity, and
|
||||
/// uses the specified <see cref="T:System.Collections.Generic.IEqualityComparer{T}" />.
|
||||
/// </summary>
|
||||
/// <param name="concurrencyLevel">
|
||||
/// The estimated number of threads that will update the
|
||||
/// <see cref="ConcurrentHashSet{T}" /> concurrently.
|
||||
/// </param>
|
||||
/// <param name="capacity">
|
||||
/// The initial number of elements that the
|
||||
/// <see
|
||||
/// cref="ConcurrentHashSet{T}" />
|
||||
/// can contain.
|
||||
/// </param>
|
||||
/// <param name="comparer">
|
||||
/// The <see cref="T:System.Collections.Generic.IEqualityComparer{T}" />
|
||||
/// implementation to use when comparing items.
|
||||
/// </param>
|
||||
/// <exception cref="T:System.ArgumentOutOfRangeException">
|
||||
/// <paramref name="concurrencyLevel" /> is less than 1. -or-
|
||||
/// <paramref name="capacity" /> is less than 0.
|
||||
/// </exception>
|
||||
/// <exception cref="T:System.ArgumentNullException"><paramref name="comparer" /> is a null reference.</exception>
|
||||
public ConcurrentHashSet(int concurrencyLevel, int capacity, IEqualityComparer<T> comparer)
|
||||
: this(concurrencyLevel, capacity, false, comparer)
|
||||
{
|
||||
}
|
||||
|
||||
private ConcurrentHashSet(
|
||||
int concurrencyLevel,
|
||||
int capacity,
|
||||
bool growLockArray,
|
||||
IEqualityComparer<T> comparer)
|
||||
{
|
||||
if (concurrencyLevel < 1)
|
||||
throw new ArgumentOutOfRangeException(nameof(concurrencyLevel));
|
||||
if (capacity < 0)
|
||||
throw new ArgumentOutOfRangeException(nameof(capacity));
|
||||
|
||||
// The capacity should be at least as large as the concurrency level. Otherwise, we would have locks that don't guard
|
||||
// any buckets.
|
||||
if (capacity < concurrencyLevel)
|
||||
capacity = concurrencyLevel;
|
||||
|
||||
var locks = new object[concurrencyLevel];
|
||||
for (var i = 0; i < locks.Length; i++)
|
||||
locks[i] = new();
|
||||
|
||||
var countPerLock = new int[locks.Length];
|
||||
var buckets = new Node[capacity];
|
||||
tables = new(buckets, locks, countPerLock);
|
||||
|
||||
_growLockArray = growLockArray;
|
||||
budget = buckets.Length / locks.Length;
|
||||
_comparer = comparer ?? throw new ArgumentNullException(nameof(comparer));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes all items from the <see cref="ConcurrentHashSet{T}" />.
|
||||
/// </summary>
|
||||
public void Clear()
|
||||
{
|
||||
var locksAcquired = 0;
|
||||
try
|
||||
{
|
||||
AcquireAllLocks(ref locksAcquired);
|
||||
|
||||
var newTables = new Tables(new Node[DEFAULT_CAPACITY], tables.Locks, new int[tables.CountPerLock.Length]);
|
||||
tables = newTables;
|
||||
budget = Math.Max(1, newTables.Buckets.Length / newTables.Locks.Length);
|
||||
}
|
||||
finally
|
||||
{
|
||||
ReleaseLocks(0, locksAcquired);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the <see cref="ConcurrentHashSet{T}" /> contains the specified
|
||||
/// item.
|
||||
/// </summary>
|
||||
/// <param name="item">The item to locate in the <see cref="ConcurrentHashSet{T}" />.</param>
|
||||
/// <returns>true if the <see cref="ConcurrentHashSet{T}" /> contains the item; otherwise, false.</returns>
|
||||
public bool Contains(T item)
|
||||
{
|
||||
var hashcode = _comparer.GetHashCode(item!);
|
||||
|
||||
// We must capture the _buckets field in a local variable. It is set to a new table on each table resize.
|
||||
var localTables = tables;
|
||||
|
||||
var bucketNo = GetBucket(hashcode, localTables.Buckets.Length);
|
||||
|
||||
// We can get away w/out a lock here.
|
||||
// The Volatile.Read ensures that the load of the fields of 'n' doesn't move before the load from buckets[i].
|
||||
var current = Volatile.Read(ref localTables.Buckets[bucketNo]);
|
||||
|
||||
while (current is not null)
|
||||
{
|
||||
if (hashcode == current.Hashcode && _comparer.Equals(current.Item, item))
|
||||
return true;
|
||||
|
||||
current = current.Next;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void ICollection<T>.Add(T item)
|
||||
=> Add(item);
|
||||
|
||||
void ICollection<T>.CopyTo(T[] array, int arrayIndex)
|
||||
{
|
||||
if (array is null)
|
||||
throw new ArgumentNullException(nameof(array));
|
||||
if (arrayIndex < 0)
|
||||
throw new ArgumentOutOfRangeException(nameof(arrayIndex));
|
||||
|
||||
var locksAcquired = 0;
|
||||
try
|
||||
{
|
||||
AcquireAllLocks(ref locksAcquired);
|
||||
|
||||
var count = 0;
|
||||
|
||||
for (var i = 0; i < tables.Locks.Length && count >= 0; i++)
|
||||
count += tables.CountPerLock[i];
|
||||
|
||||
if (array.Length - count < arrayIndex || count < 0) //"count" itself or "count + arrayIndex" can overflow
|
||||
{
|
||||
throw new ArgumentException(
|
||||
"The index is equal to or greater than the length of the array, or the number of elements in the set is greater than the available space from index to the end of the destination array.");
|
||||
}
|
||||
|
||||
CopyToItems(array, arrayIndex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
ReleaseLocks(0, locksAcquired);
|
||||
}
|
||||
}
|
||||
|
||||
bool ICollection<T>.Remove(T item)
|
||||
=> TryRemove(item);
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
=> GetEnumerator();
|
||||
|
||||
/// <summary>
|
||||
/// Returns an enumerator that iterates through the
|
||||
/// <see
|
||||
/// cref="ConcurrentHashSet{T}" />
|
||||
/// .
|
||||
/// </summary>
|
||||
/// <returns>An enumerator for the <see cref="ConcurrentHashSet{T}" />.</returns>
|
||||
/// <remarks>
|
||||
/// The enumerator returned from the collection is safe to use concurrently with
|
||||
/// reads and writes to the collection, however it does not represent a moment-in-time snapshot
|
||||
/// of the collection. The contents exposed through the enumerator may contain modifications
|
||||
/// made to the collection after <see cref="GetEnumerator" /> was called.
|
||||
/// </remarks>
|
||||
public IEnumerator<T> GetEnumerator()
|
||||
{
|
||||
var buckets = tables.Buckets;
|
||||
|
||||
for (var i = 0; i < buckets.Length; i++)
|
||||
{
|
||||
// The Volatile.Read ensures that the load of the fields of 'current' doesn't move before the load from buckets[i].
|
||||
var current = Volatile.Read(ref buckets[i]);
|
||||
|
||||
while (current is not null)
|
||||
{
|
||||
yield return current.Item;
|
||||
current = current.Next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the specified item to the <see cref="ConcurrentHashSet{T}" />.
|
||||
/// </summary>
|
||||
/// <param name="item">The item to add.</param>
|
||||
/// <returns>
|
||||
/// true if the items was added to the <see cref="ConcurrentHashSet{T}" />
|
||||
/// successfully; false if it already exists.
|
||||
/// </returns>
|
||||
/// <exception cref="T:System.OverflowException">
|
||||
/// The <see cref="ConcurrentHashSet{T}" />
|
||||
/// contains too many items.
|
||||
/// </exception>
|
||||
public bool Add(T item)
|
||||
=> AddInternal(item, _comparer.GetHashCode(item), true);
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to remove the item from the <see cref="ConcurrentHashSet{T}" />.
|
||||
/// </summary>
|
||||
/// <param name="item">The item to remove.</param>
|
||||
/// <returns>true if an item was removed successfully; otherwise, false.</returns>
|
||||
public bool TryRemove(T item)
|
||||
{
|
||||
var hashcode = _comparer.GetHashCode(item);
|
||||
while (true)
|
||||
{
|
||||
var localTables = tables;
|
||||
|
||||
GetBucketAndLockNo(hashcode,
|
||||
out var bucketNo,
|
||||
out var lockNo,
|
||||
localTables.Buckets.Length,
|
||||
localTables.Locks.Length);
|
||||
|
||||
lock (localTables.Locks[lockNo])
|
||||
{
|
||||
// If the table just got resized, we may not be holding the right lock, and must retry.
|
||||
// This should be a rare occurrence.
|
||||
if (localTables != tables)
|
||||
continue;
|
||||
|
||||
Node previous = null;
|
||||
for (var current = localTables.Buckets[bucketNo]; current is not null; current = current.Next)
|
||||
{
|
||||
Debug.Assert((previous is null && current == localTables.Buckets[bucketNo])
|
||||
|| previous!.Next == current);
|
||||
|
||||
if (hashcode == current.Hashcode && _comparer.Equals(current.Item, item))
|
||||
{
|
||||
if (previous is null)
|
||||
Volatile.Write(ref localTables.Buckets[bucketNo], current.Next);
|
||||
else
|
||||
previous.Next = current.Next;
|
||||
|
||||
localTables.CountPerLock[lockNo]--;
|
||||
return true;
|
||||
}
|
||||
|
||||
previous = current;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void InitializeFromCollection(IEnumerable<T> collection)
|
||||
{
|
||||
foreach (var item in collection)
|
||||
AddInternal(item, _comparer.GetHashCode(item), false);
|
||||
|
||||
if (budget == 0)
|
||||
budget = tables.Buckets.Length / tables.Locks.Length;
|
||||
}
|
||||
|
||||
private bool AddInternal(T item, int hashcode, bool acquireLock)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
var localTables = tables;
|
||||
GetBucketAndLockNo(hashcode,
|
||||
out var bucketNo,
|
||||
out var lockNo,
|
||||
localTables.Buckets.Length,
|
||||
localTables.Locks.Length);
|
||||
|
||||
var resizeDesired = false;
|
||||
var lockTaken = false;
|
||||
try
|
||||
{
|
||||
if (acquireLock)
|
||||
Monitor.Enter(localTables.Locks[lockNo], ref lockTaken);
|
||||
|
||||
// If the table just got resized, we may not be holding the right lock, and must retry.
|
||||
// This should be a rare occurrence.
|
||||
if (localTables != tables)
|
||||
continue;
|
||||
|
||||
// Try to find this item in the bucket
|
||||
Node previous = null;
|
||||
for (var current = localTables.Buckets[bucketNo]; current is not null; current = current.Next)
|
||||
{
|
||||
Debug.Assert((previous is null && current == localTables.Buckets[bucketNo])
|
||||
|| previous!.Next == current);
|
||||
if (hashcode == current.Hashcode && _comparer.Equals(current.Item, item))
|
||||
return false;
|
||||
|
||||
previous = current;
|
||||
}
|
||||
|
||||
// The item was not found in the bucket. Insert the new item.
|
||||
Volatile.Write(ref localTables.Buckets[bucketNo], new(item, hashcode, localTables.Buckets[bucketNo]));
|
||||
checked
|
||||
{
|
||||
localTables.CountPerLock[lockNo]++;
|
||||
}
|
||||
|
||||
//
|
||||
// If the number of elements guarded by this lock has exceeded the budget, resize the bucket table.
|
||||
// It is also possible that GrowTable will increase the budget but won't resize the bucket table.
|
||||
// That happens if the bucket table is found to be poorly utilized due to a bad hash function.
|
||||
//
|
||||
if (localTables.CountPerLock[lockNo] > budget)
|
||||
resizeDesired = true;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (lockTaken)
|
||||
Monitor.Exit(localTables.Locks[lockNo]);
|
||||
}
|
||||
|
||||
//
|
||||
// The fact that we got here means that we just performed an insertion. If necessary, we will grow the table.
|
||||
//
|
||||
// Concurrency notes:
|
||||
// - Notice that we are not holding any locks at when calling GrowTable. This is necessary to prevent deadlocks.
|
||||
// - As a result, it is possible that GrowTable will be called unnecessarily. But, GrowTable will obtain lock 0
|
||||
// and then verify that the table we passed to it as the argument is still the current table.
|
||||
//
|
||||
if (resizeDesired)
|
||||
GrowTable(localTables);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private static int GetBucket(int hashcode, int bucketCount)
|
||||
{
|
||||
var bucketNo = (hashcode & 0x7fffffff) % bucketCount;
|
||||
Debug.Assert(bucketNo >= 0 && bucketNo < bucketCount);
|
||||
return bucketNo;
|
||||
}
|
||||
|
||||
private static void GetBucketAndLockNo(
|
||||
int hashcode,
|
||||
out int bucketNo,
|
||||
out int lockNo,
|
||||
int bucketCount,
|
||||
int lockCount)
|
||||
{
|
||||
bucketNo = (hashcode & 0x7fffffff) % bucketCount;
|
||||
lockNo = bucketNo % lockCount;
|
||||
|
||||
Debug.Assert(bucketNo >= 0 && bucketNo < bucketCount);
|
||||
Debug.Assert(lockNo >= 0 && lockNo < lockCount);
|
||||
}
|
||||
|
||||
private void GrowTable(Tables localTables)
|
||||
{
|
||||
const int maxArrayLength = 0X7FEFFFFF;
|
||||
var locksAcquired = 0;
|
||||
try
|
||||
{
|
||||
// The thread that first obtains _locks[0] will be the one doing the resize operation
|
||||
AcquireLocks(0, 1, ref locksAcquired);
|
||||
|
||||
// Make sure nobody resized the table while we were waiting for lock 0:
|
||||
if (localTables != tables)
|
||||
// We assume that since the table reference is different, it was already resized (or the budget
|
||||
// was adjusted). If we ever decide to do table shrinking, or replace the table for other reasons,
|
||||
// we will have to revisit this logic.
|
||||
return;
|
||||
|
||||
// Compute the (approx.) total size. Use an Int64 accumulation variable to avoid an overflow.
|
||||
long approxCount = 0;
|
||||
for (var i = 0; i < localTables.CountPerLock.Length; i++)
|
||||
approxCount += localTables.CountPerLock[i];
|
||||
|
||||
//
|
||||
// If the bucket array is too empty, double the budget instead of resizing the table
|
||||
//
|
||||
if (approxCount < localTables.Buckets.Length / 4)
|
||||
{
|
||||
budget = 2 * budget;
|
||||
if (budget < 0)
|
||||
budget = int.MaxValue;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Compute the new table size. We find the smallest integer larger than twice the previous table size, and not divisible by
|
||||
// 2,3,5 or 7. We can consider a different table-sizing policy in the future.
|
||||
var newLength = 0;
|
||||
var maximizeTableSize = false;
|
||||
try
|
||||
{
|
||||
checked
|
||||
{
|
||||
// Double the size of the buckets table and add one, so that we have an odd integer.
|
||||
newLength = (localTables.Buckets.Length * 2) + 1;
|
||||
|
||||
// Now, we only need to check odd integers, and find the first that is not divisible
|
||||
// by 3, 5 or 7.
|
||||
while (newLength % 3 == 0 || newLength % 5 == 0 || newLength % 7 == 0)
|
||||
newLength += 2;
|
||||
|
||||
Debug.Assert(newLength % 2 != 0);
|
||||
|
||||
if (newLength > maxArrayLength)
|
||||
maximizeTableSize = true;
|
||||
}
|
||||
}
|
||||
catch (OverflowException)
|
||||
{
|
||||
maximizeTableSize = true;
|
||||
}
|
||||
|
||||
if (maximizeTableSize)
|
||||
{
|
||||
newLength = maxArrayLength;
|
||||
|
||||
// We want to make sure that GrowTable will not be called again, since table is at the maximum size.
|
||||
// To achieve that, we set the budget to int.MaxValue.
|
||||
//
|
||||
// (There is one special case that would allow GrowTable() to be called in the future:
|
||||
// calling Clear() on the ConcurrentHashSet will shrink the table and lower the budget.)
|
||||
budget = int.MaxValue;
|
||||
}
|
||||
|
||||
// Now acquire all other locks for the table
|
||||
AcquireLocks(1, localTables.Locks.Length, ref locksAcquired);
|
||||
|
||||
var newLocks = localTables.Locks;
|
||||
|
||||
// Add more locks
|
||||
if (_growLockArray && localTables.Locks.Length < MAX_LOCK_NUMBER)
|
||||
{
|
||||
newLocks = new object[localTables.Locks.Length * 2];
|
||||
Array.Copy(localTables.Locks, 0, newLocks, 0, localTables.Locks.Length);
|
||||
for (var i = localTables.Locks.Length; i < newLocks.Length; i++)
|
||||
newLocks[i] = new();
|
||||
}
|
||||
|
||||
var newBuckets = new Node[newLength];
|
||||
var newCountPerLock = new int[newLocks.Length];
|
||||
|
||||
// Copy all data into a new table, creating new nodes for all elements
|
||||
for (var i = 0; i < localTables.Buckets.Length; i++)
|
||||
{
|
||||
var current = localTables.Buckets[i];
|
||||
while (current is not null)
|
||||
{
|
||||
var next = current.Next;
|
||||
GetBucketAndLockNo(current.Hashcode,
|
||||
out var newBucketNo,
|
||||
out var newLockNo,
|
||||
newBuckets.Length,
|
||||
newLocks.Length);
|
||||
|
||||
newBuckets[newBucketNo] = new(current.Item, current.Hashcode, newBuckets[newBucketNo]);
|
||||
|
||||
checked
|
||||
{
|
||||
newCountPerLock[newLockNo]++;
|
||||
}
|
||||
|
||||
current = next;
|
||||
}
|
||||
}
|
||||
|
||||
// Adjust the budget
|
||||
budget = Math.Max(1, newBuckets.Length / newLocks.Length);
|
||||
|
||||
// Replace tables with the new versions
|
||||
tables = new(newBuckets, newLocks, newCountPerLock);
|
||||
}
|
||||
finally
|
||||
{
|
||||
// Release all locks that we took earlier
|
||||
ReleaseLocks(0, locksAcquired);
|
||||
}
|
||||
}
|
||||
|
||||
public int RemoveWhere(Func<T, bool> predicate)
|
||||
{
|
||||
var elems = this.Where(predicate);
|
||||
var removed = 0;
|
||||
foreach (var elem in elems)
|
||||
{
|
||||
if (TryRemove(elem))
|
||||
removed++;
|
||||
}
|
||||
|
||||
return removed;
|
||||
}
|
||||
|
||||
private void AcquireAllLocks(ref int locksAcquired)
|
||||
{
|
||||
// First, acquire lock 0
|
||||
AcquireLocks(0, 1, ref locksAcquired);
|
||||
|
||||
// Now that we have lock 0, the _locks array will not change (i.e., grow),
|
||||
// and so we can safely read _locks.Length.
|
||||
AcquireLocks(1, tables.Locks.Length, ref locksAcquired);
|
||||
Debug.Assert(locksAcquired == tables.Locks.Length);
|
||||
}
|
||||
|
||||
private void AcquireLocks(int fromInclusive, int toExclusive, ref int locksAcquired)
|
||||
{
|
||||
Debug.Assert(fromInclusive <= toExclusive);
|
||||
var locks = tables.Locks;
|
||||
|
||||
for (var i = fromInclusive; i < toExclusive; i++)
|
||||
{
|
||||
var lockTaken = false;
|
||||
try
|
||||
{
|
||||
Monitor.Enter(locks[i], ref lockTaken);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (lockTaken)
|
||||
locksAcquired++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ReleaseLocks(int fromInclusive, int toExclusive)
|
||||
{
|
||||
Debug.Assert(fromInclusive <= toExclusive);
|
||||
|
||||
for (var i = fromInclusive; i < toExclusive; i++)
|
||||
Monitor.Exit(tables.Locks[i]);
|
||||
}
|
||||
|
||||
private void CopyToItems(T[] array, int index)
|
||||
{
|
||||
var buckets = tables.Buckets;
|
||||
for (var i = 0; i < buckets.Length; i++)
|
||||
for (var current = buckets[i]; current is not null; current = current.Next)
|
||||
{
|
||||
array[index] = current.Item;
|
||||
index++; //this should never flow, CopyToItems is only called when there's no overflow risk
|
||||
}
|
||||
}
|
||||
|
||||
private sealed class Tables
|
||||
{
|
||||
public readonly Node[] Buckets;
|
||||
public readonly object[] Locks;
|
||||
|
||||
public volatile int[] CountPerLock;
|
||||
|
||||
public Tables(Node[] buckets, object[] locks, int[] countPerLock)
|
||||
{
|
||||
Buckets = buckets;
|
||||
Locks = locks;
|
||||
CountPerLock = countPerLock;
|
||||
}
|
||||
}
|
||||
|
||||
private sealed class Node
|
||||
{
|
||||
public readonly int Hashcode;
|
||||
public readonly T Item;
|
||||
|
||||
public volatile Node Next;
|
||||
|
||||
public Node(T item, int hashcode, Node next)
|
||||
{
|
||||
Item = item;
|
||||
Hashcode = hashcode;
|
||||
Next = next;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,185 +0,0 @@
|
||||
#nullable disable
|
||||
using Cloneable;
|
||||
using NadekoBot.Common.Yml;
|
||||
using SixLabors.ImageSharp.PixelFormats;
|
||||
using System.Globalization;
|
||||
using YamlDotNet.Core;
|
||||
using YamlDotNet.Serialization;
|
||||
|
||||
namespace NadekoBot.Common.Configs;
|
||||
|
||||
[Cloneable]
|
||||
public sealed partial class BotConfig : ICloneable<BotConfig>
|
||||
{
|
||||
[Comment(@"DO NOT CHANGE")]
|
||||
public int Version { get; set; } = 2;
|
||||
|
||||
[Comment(@"Most commands, when executed, have a small colored line
|
||||
next to the response. The color depends whether the command
|
||||
is completed, errored or in progress (pending)
|
||||
Color settings below are for the color of those lines.
|
||||
To get color's hex, you can go here https://htmlcolorcodes.com/
|
||||
and copy the hex code fo your selected color (marked as #)")]
|
||||
public ColorConfig Color { get; set; }
|
||||
|
||||
[Comment("Default bot language. It has to be in the list of supported languages (.langli)")]
|
||||
public CultureInfo DefaultLocale { get; set; }
|
||||
|
||||
[Comment(@"Style in which executed commands will show up in the console.
|
||||
Allowed values: Simple, Normal, None")]
|
||||
public ConsoleOutputType ConsoleOutputType { get; set; }
|
||||
|
||||
// [Comment(@"For what kind of updates will the bot check.
|
||||
// Allowed values: Release, Commit, None")]
|
||||
// public UpdateCheckType CheckForUpdates { get; set; }
|
||||
|
||||
// [Comment(@"How often will the bot check for updates, in hours")]
|
||||
// public int CheckUpdateInterval { get; set; }
|
||||
|
||||
[Comment(@"Do you want any messages sent by users in Bot's DM to be forwarded to the owner(s)?")]
|
||||
public bool ForwardMessages { get; set; }
|
||||
|
||||
[Comment(
|
||||
@"Do you want the message to be forwarded only to the first owner specified in the list of owners (in creds.yml),
|
||||
or all owners? (this might cause the bot to lag if there's a lot of owners specified)")]
|
||||
public bool ForwardToAllOwners { get; set; }
|
||||
|
||||
[Comment(@"When a user DMs the bot with a message which is not a command
|
||||
they will receive this message. Leave empty for no response. The string which will be sent whenever someone DMs the bot.
|
||||
Supports embeds. How it looks: https://puu.sh/B0BLV.png")]
|
||||
[YamlMember(ScalarStyle = ScalarStyle.Literal)]
|
||||
public string DmHelpText { get; set; }
|
||||
|
||||
[Comment(@"Only users who send a DM to the bot containing one of the specified words will get a DmHelpText response.
|
||||
Case insensitive.
|
||||
Leave empty to reply with DmHelpText to every DM.")]
|
||||
public List<string> DmHelpTextKeywords { get; set; }
|
||||
|
||||
[Comment(@"This is the response for the .h command")]
|
||||
[YamlMember(ScalarStyle = ScalarStyle.Literal)]
|
||||
public string HelpText { get; set; }
|
||||
|
||||
[Comment(@"List of modules and commands completely blocked on the bot")]
|
||||
public BlockedConfig Blocked { get; set; }
|
||||
|
||||
[Comment(@"Which string will be used to recognize the commands")]
|
||||
public string Prefix { get; set; }
|
||||
|
||||
[Comment(@"Toggles whether your bot will group greet/bye messages into a single message every 5 seconds.
|
||||
1st user who joins will get greeted immediately
|
||||
If more users join within the next 5 seconds, they will be greeted in groups of 5.
|
||||
This will cause %user.mention% and other placeholders to be replaced with multiple users.
|
||||
Keep in mind this might break some of your embeds - for example if you have %user.avatar% in the thumbnail,
|
||||
it will become invalid, as it will resolve to a list of avatars of grouped users.
|
||||
note: This setting is primarily used if you're afraid of raids, or you're running medium/large bots where some
|
||||
servers might get hundreds of people join at once. This is used to prevent the bot from getting ratelimited,
|
||||
and (slightly) reduce the greet spam in those servers.")]
|
||||
public bool GroupGreets { get; set; }
|
||||
|
||||
[Comment(@"Whether the bot will rotate through all specified statuses.
|
||||
This setting can be changed via .ropl command.
|
||||
See RotatingStatuses submodule in Administration.")]
|
||||
public bool RotateStatuses { get; set; }
|
||||
|
||||
public BotConfig()
|
||||
{
|
||||
var color = new ColorConfig();
|
||||
Color = color;
|
||||
DefaultLocale = new("en-US");
|
||||
ConsoleOutputType = ConsoleOutputType.Normal;
|
||||
ForwardMessages = false;
|
||||
ForwardToAllOwners = false;
|
||||
DmHelpText = @"{""description"": ""Type `%prefix%h` for help.""}";
|
||||
HelpText = @"{
|
||||
""title"": ""To invite me to your server, use this link"",
|
||||
""description"": ""https://discordapp.com/oauth2/authorize?client_id={0}&scope=bot&permissions=66186303"",
|
||||
""color"": 53380,
|
||||
""thumbnail"": ""https://i.imgur.com/nKYyqMK.png"",
|
||||
""fields"": [
|
||||
{
|
||||
""name"": ""Useful help commands"",
|
||||
""value"": ""`%bot.prefix%modules` Lists all bot modules.
|
||||
`%prefix%h CommandName` Shows some help about a specific command.
|
||||
`%prefix%commands ModuleName` Lists all commands in a module."",
|
||||
""inline"": false
|
||||
},
|
||||
{
|
||||
""name"": ""List of all Commands"",
|
||||
""value"": ""https://nadeko.bot/commands"",
|
||||
""inline"": false
|
||||
},
|
||||
{
|
||||
""name"": ""Nadeko Support Server"",
|
||||
""value"": ""https://discord.nadeko.bot/ "",
|
||||
""inline"": true
|
||||
}
|
||||
]
|
||||
}";
|
||||
var blocked = new BlockedConfig();
|
||||
Blocked = blocked;
|
||||
Prefix = ".";
|
||||
RotateStatuses = false;
|
||||
GroupGreets = false;
|
||||
DmHelpTextKeywords = new()
|
||||
{
|
||||
"help",
|
||||
"commands",
|
||||
"cmds",
|
||||
"module",
|
||||
"can you do"
|
||||
};
|
||||
}
|
||||
|
||||
// [Comment(@"Whether the prefix will be a suffix, or prefix.
|
||||
// For example, if your prefix is ! you will run a command called 'cash' by typing either
|
||||
// '!cash @Someone' if your prefixIsSuffix: false or
|
||||
// 'cash @Someone!' if your prefixIsSuffix: true")]
|
||||
// public bool PrefixIsSuffix { get; set; }
|
||||
|
||||
// public string Prefixed(string text) => PrefixIsSuffix
|
||||
// ? text + Prefix
|
||||
// : Prefix + text;
|
||||
|
||||
public string Prefixed(string text)
|
||||
=> Prefix + text;
|
||||
}
|
||||
|
||||
[Cloneable]
|
||||
public sealed partial class BlockedConfig
|
||||
{
|
||||
public HashSet<string> Commands { get; set; }
|
||||
public HashSet<string> Modules { get; set; }
|
||||
|
||||
public BlockedConfig()
|
||||
{
|
||||
Modules = new();
|
||||
Commands = new();
|
||||
}
|
||||
}
|
||||
|
||||
[Cloneable]
|
||||
public partial class ColorConfig
|
||||
{
|
||||
[Comment(@"Color used for embed responses when command successfully executes")]
|
||||
public Rgba32 Ok { get; set; }
|
||||
|
||||
[Comment(@"Color used for embed responses when command has an error")]
|
||||
public Rgba32 Error { get; set; }
|
||||
|
||||
[Comment(@"Color used for embed responses while command is doing work or is in progress")]
|
||||
public Rgba32 Pending { get; set; }
|
||||
|
||||
public ColorConfig()
|
||||
{
|
||||
Ok = Rgba32.ParseHex("00e584");
|
||||
Error = Rgba32.ParseHex("ee281f");
|
||||
Pending = Rgba32.ParseHex("faa61a");
|
||||
}
|
||||
}
|
||||
|
||||
public enum ConsoleOutputType
|
||||
{
|
||||
Normal = 0,
|
||||
Simple = 1,
|
||||
None = 2
|
||||
}
|
@@ -1,203 +0,0 @@
|
||||
#nullable disable
|
||||
using NadekoBot.Common.Yml;
|
||||
|
||||
namespace NadekoBot.Common;
|
||||
|
||||
public sealed class Creds : IBotCredentials
|
||||
{
|
||||
[Comment(@"DO NOT CHANGE")]
|
||||
public int Version { get; set; }
|
||||
|
||||
[Comment(@"Bot token. Do not share with anyone ever -> https://discordapp.com/developers/applications/")]
|
||||
public string Token { get; set; }
|
||||
|
||||
[Comment(@"List of Ids of the users who have bot owner permissions
|
||||
**DO NOT ADD PEOPLE YOU DON'T TRUST**")]
|
||||
public ICollection<ulong> OwnerIds { get; set; }
|
||||
|
||||
[Comment("Keep this on 'true' unless you're sure your bot shouldn't use privileged intents or you're waiting to be accepted")]
|
||||
public bool UsePrivilegedIntents { get; set; }
|
||||
|
||||
[Comment(@"The number of shards that the bot will running on.
|
||||
Leave at 1 if you don't know what you're doing.")]
|
||||
public int TotalShards { get; set; }
|
||||
|
||||
[Comment(
|
||||
@"Login to https://console.cloud.google.com, create a new project, go to APIs & Services -> Library -> YouTube Data API and enable it.
|
||||
Then, go to APIs and Services -> Credentials and click Create credentials -> API key.
|
||||
Used only for Youtube Data Api (at the moment).")]
|
||||
public string GoogleApiKey { get; set; }
|
||||
|
||||
[Comment(@"Settings for voting system for discordbots. Meant for use on global Nadeko.")]
|
||||
public VotesSettings Votes { get; set; }
|
||||
|
||||
[Comment(@"Patreon auto reward system settings.
|
||||
go to https://www.patreon.com/portal -> my clients -> create client")]
|
||||
public PatreonSettings Patreon { get; set; }
|
||||
|
||||
[Comment(@"Api key for sending stats to DiscordBotList.")]
|
||||
public string BotListToken { get; set; }
|
||||
|
||||
[Comment(@"Official cleverbot api key.")]
|
||||
public string CleverbotApiKey { get; set; }
|
||||
|
||||
[Comment(@"Redis connection string. Don't change if you don't know what you're doing.")]
|
||||
public string RedisOptions { get; set; }
|
||||
|
||||
[Comment(@"Database options. Don't change if you don't know what you're doing. Leave null for default values")]
|
||||
public DbOptions Db { get; set; }
|
||||
|
||||
[Comment(@"Address and port of the coordinator endpoint. Leave empty for default.
|
||||
Change only if you've changed the coordinator address or port.")]
|
||||
public string CoordinatorUrl { get; set; }
|
||||
|
||||
[Comment(
|
||||
@"Api key obtained on https://rapidapi.com (go to MyApps -> Add New App -> Enter Name -> Application key)")]
|
||||
public string RapidApiKey { get; set; }
|
||||
|
||||
[Comment(@"https://locationiq.com api key (register and you will receive the token in the email).
|
||||
Used only for .time command.")]
|
||||
public string LocationIqApiKey { get; set; }
|
||||
|
||||
[Comment(@"https://timezonedb.com api key (register and you will receive the token in the email).
|
||||
Used only for .time command")]
|
||||
public string TimezoneDbApiKey { get; set; }
|
||||
|
||||
[Comment(@"https://pro.coinmarketcap.com/account/ api key. There is a free plan for personal use.
|
||||
Used for cryptocurrency related commands.")]
|
||||
public string CoinmarketcapApiKey { get; set; }
|
||||
|
||||
// [Comment(@"https://polygon.io/dashboard/api-keys api key. Free plan allows for 5 queries per minute.
|
||||
// Used for stocks related commands.")]
|
||||
// public string PolygonIoApiKey { get; set; }
|
||||
|
||||
[Comment(@"Api key used for Osu related commands. Obtain this key at https://osu.ppy.sh/p/api")]
|
||||
public string OsuApiKey { get; set; }
|
||||
|
||||
[Comment(@"Optional Trovo client id.
|
||||
You should use this if Trovo stream notifications stopped working or you're getting ratelimit errors.")]
|
||||
public string TrovoClientId { get; set; }
|
||||
|
||||
[Comment(@"Obtain by creating an application at https://dev.twitch.tv/console/apps")]
|
||||
public string TwitchClientId { get; set; }
|
||||
|
||||
[Comment(@"Obtain by creating an application at https://dev.twitch.tv/console/apps")]
|
||||
public string TwitchClientSecret { get; set; }
|
||||
|
||||
[Comment(@"Command and args which will be used to restart the bot.
|
||||
Only used if bot is executed directly (NOT through the coordinator)
|
||||
placeholders:
|
||||
{0} -> shard id
|
||||
{1} -> total shards
|
||||
Linux default
|
||||
cmd: dotnet
|
||||
args: ""NadekoBot.dll -- {0}""
|
||||
Windows default
|
||||
cmd: NadekoBot.exe
|
||||
args: {0}")]
|
||||
public RestartConfig RestartCommand { get; set; }
|
||||
|
||||
public Creds()
|
||||
{
|
||||
Version = 5;
|
||||
Token = string.Empty;
|
||||
UsePrivilegedIntents = true;
|
||||
OwnerIds = new List<ulong>();
|
||||
TotalShards = 1;
|
||||
GoogleApiKey = string.Empty;
|
||||
Votes = new(string.Empty, string.Empty, string.Empty, string.Empty);
|
||||
Patreon = new(string.Empty, string.Empty, string.Empty, string.Empty);
|
||||
BotListToken = string.Empty;
|
||||
CleverbotApiKey = string.Empty;
|
||||
RedisOptions = "localhost:6379,syncTimeout=30000,responseTimeout=30000,allowAdmin=true,password=";
|
||||
Db = new()
|
||||
{
|
||||
Type = "sqlite",
|
||||
ConnectionString = "Data Source=data/NadekoBot.db"
|
||||
};
|
||||
|
||||
CoordinatorUrl = "http://localhost:3442";
|
||||
|
||||
RestartCommand = new();
|
||||
}
|
||||
|
||||
|
||||
public class DbOptions
|
||||
{
|
||||
[Comment(@"Database type. ""sqlite"", ""mysql"" and ""postgresql"" are supported.
|
||||
Default is ""sqlite""")]
|
||||
public string Type { get; set; }
|
||||
|
||||
[Comment(@"Database connection string.
|
||||
You MUST change this if you're not using ""sqlite"" type.
|
||||
Default is ""Data Source=data/NadekoBot.db""
|
||||
Example for mysql: ""Server=localhost;Port=3306;Uid=root;Pwd=my_super_secret_mysql_password;Database=nadeko""
|
||||
Example for postgresql: ""Server=localhost;Port=5432;User Id=postgres;Password=my_super_secret_postgres_password;Database=nadeko;""")]
|
||||
public string ConnectionString { get; set; }
|
||||
}
|
||||
|
||||
public sealed record PatreonSettings
|
||||
{
|
||||
public string ClientId { get; set; }
|
||||
public string AccessToken { get; set; }
|
||||
public string RefreshToken { get; set; }
|
||||
public string ClientSecret { get; set; }
|
||||
|
||||
[Comment(
|
||||
@"Campaign ID of your patreon page. Go to your patreon page (make sure you're logged in) and type ""prompt('Campaign ID', window.patreon.bootstrap.creator.data.id);"" in the console. (ctrl + shift + i)")]
|
||||
public string CampaignId { get; set; }
|
||||
|
||||
public PatreonSettings(
|
||||
string accessToken,
|
||||
string refreshToken,
|
||||
string clientSecret,
|
||||
string campaignId)
|
||||
{
|
||||
AccessToken = accessToken;
|
||||
RefreshToken = refreshToken;
|
||||
ClientSecret = clientSecret;
|
||||
CampaignId = campaignId;
|
||||
}
|
||||
|
||||
public PatreonSettings()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public sealed record VotesSettings
|
||||
{
|
||||
[Comment(@"top.gg votes service url
|
||||
This is the url of your instance of the NadekoBot.Votes api
|
||||
Example: https://votes.my.cool.bot.com")]
|
||||
public string TopggServiceUrl { get; set; }
|
||||
|
||||
[Comment(@"Authorization header value sent to the TopGG service url with each request
|
||||
This should be equivalent to the TopggKey in your NadekoBot.Votes api appsettings.json file")]
|
||||
public string TopggKey { get; set; }
|
||||
|
||||
[Comment(@"discords.com votes service url
|
||||
This is the url of your instance of the NadekoBot.Votes api
|
||||
Example: https://votes.my.cool.bot.com")]
|
||||
public string DiscordsServiceUrl { get; set; }
|
||||
|
||||
[Comment(@"Authorization header value sent to the Discords service url with each request
|
||||
This should be equivalent to the DiscordsKey in your NadekoBot.Votes api appsettings.json file")]
|
||||
public string DiscordsKey { get; set; }
|
||||
|
||||
public VotesSettings()
|
||||
{
|
||||
}
|
||||
|
||||
public VotesSettings(
|
||||
string topggServiceUrl,
|
||||
string topggKey,
|
||||
string discordsServiceUrl,
|
||||
string discordsKey)
|
||||
{
|
||||
TopggServiceUrl = topggServiceUrl;
|
||||
TopggKey = topggKey;
|
||||
DiscordsServiceUrl = discordsServiceUrl;
|
||||
DiscordsKey = discordsKey;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,34 +0,0 @@
|
||||
#nullable disable
|
||||
namespace NadekoBot;
|
||||
|
||||
public interface IBotCredentials
|
||||
{
|
||||
string Token { get; }
|
||||
string GoogleApiKey { get; }
|
||||
ICollection<ulong> OwnerIds { get; }
|
||||
bool UsePrivilegedIntents { get; }
|
||||
string RapidApiKey { get; }
|
||||
|
||||
Creds.DbOptions Db { get; }
|
||||
string OsuApiKey { get; }
|
||||
int TotalShards { get; }
|
||||
Creds.PatreonSettings Patreon { get; }
|
||||
string CleverbotApiKey { get; }
|
||||
RestartConfig RestartCommand { get; }
|
||||
Creds.VotesSettings Votes { get; }
|
||||
string BotListToken { get; }
|
||||
string RedisOptions { get; }
|
||||
string LocationIqApiKey { get; }
|
||||
string TimezoneDbApiKey { get; }
|
||||
string CoinmarketcapApiKey { get; }
|
||||
string TrovoClientId { get; }
|
||||
string CoordinatorUrl { get; set; }
|
||||
string TwitchClientId { get; set; }
|
||||
string TwitchClientSecret { get; set; }
|
||||
}
|
||||
|
||||
public class RestartConfig
|
||||
{
|
||||
public string Cmd { get; set; }
|
||||
public string Args { get; set; }
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user