Compare commits
535 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
381976d6af | ||
|
|
3faf4ca3dc | ||
|
|
2f35b82d5e | ||
|
|
c9d8bf637b | ||
|
|
027f4087e3 | ||
|
|
1b20122ffc | ||
|
|
5d53571ec0 | ||
|
|
b3df1b4d41 | ||
|
|
4abe8e07f3 | ||
|
|
9bb95106ba | ||
|
|
02414478bf | ||
|
|
8b0a582464 | ||
|
|
d1db5f4688 | ||
|
|
44f9389b69 | ||
|
|
71b2d0597d | ||
|
|
57cfcebe9f | ||
|
|
07ecc505ff | ||
|
|
81213686ce | ||
|
|
08735d505a | ||
|
|
1a62c752c1 | ||
|
|
6aa7367297 | ||
|
|
cf9583227c | ||
|
|
aa505ba3f2 | ||
|
|
a0182d89ca | ||
|
|
d46f0a5be8 | ||
|
|
4a55d35e14 | ||
|
|
1284051fe8 | ||
|
|
00680494a3 | ||
|
|
77856a6d97 | ||
|
|
b216cd08e1 | ||
|
|
052c1218c6 | ||
|
|
c2343683bb | ||
|
|
fcf718f1d0 | ||
|
|
77f848007a | ||
|
|
95216b3950 | ||
|
|
58a21e8d05 | ||
|
|
49ac8cda19 | ||
|
|
bc8be3608b | ||
|
|
1b69cd78bb | ||
|
|
e736379f85 | ||
|
|
c0e1a93fb4 | ||
|
|
bd35b06ebf | ||
|
|
f852e85234 | ||
|
|
661ae11e18 | ||
|
|
18c1ac0fd7 | ||
|
|
2fb503f09f | ||
|
|
7e5eeb71da | ||
|
|
84f2da8b6d | ||
|
|
be51f8ae43 | ||
|
|
f82d985eab | ||
|
|
aab014650a | ||
|
|
113ac3e10e | ||
|
|
afb6aad26d | ||
|
|
33b60825d9 | ||
|
|
b5202a33ac | ||
|
|
c02a2ad622 | ||
|
|
e9f08915a4 | ||
|
|
4b95ccd0ba | ||
|
|
567a2f0720 | ||
|
|
61ff402256 | ||
|
|
9158bda992 | ||
|
|
873f9d3c91 | ||
|
|
783ef5db53 | ||
|
|
f0cb5c1315 | ||
|
|
8e1b916ea4 | ||
|
|
4acf87eacd | ||
|
|
5dd5a32c51 | ||
|
|
207907881f | ||
|
|
44da276d41 | ||
|
|
6c98b6f995 | ||
|
|
cc0c3dfe61 | ||
|
|
b48d75fda3 | ||
|
|
2adf2d258d | ||
|
|
c55a1c6502 | ||
|
|
0011ff8853 | ||
|
|
4bbf871051 | ||
|
|
54755dc480 | ||
|
|
01f95a37e7 | ||
|
|
5ddad418b0 | ||
|
|
b5b2e88c1f | ||
|
|
194ded7be6 | ||
|
|
7ba375d702 | ||
|
|
9a4c38151f | ||
|
|
f8df6fc93f | ||
|
|
86a3b229cb | ||
|
|
ca3e8d7d80 | ||
|
|
5af4384871 | ||
|
|
47957e6ab9 | ||
|
|
7f1a404b4e | ||
|
|
1f64a56260 | ||
|
|
366cb2b629 | ||
|
|
b9b442ad1e | ||
|
|
81a1bdb446 | ||
|
|
1e4b369b1e | ||
|
|
7a34a7b531 | ||
|
|
b83bb6f998 | ||
|
|
3348af2780 | ||
|
|
04896a7363 | ||
|
|
d8003e049c | ||
|
|
b67a933084 | ||
|
|
d684ecc0ff | ||
|
|
9efd4751d8 | ||
|
|
9331c2a3c8 | ||
|
|
d6f7ce2441 | ||
|
|
ffd7033faf | ||
|
|
df5825d8df | ||
|
|
42c6ca7af5 | ||
|
|
1e94835f97 | ||
|
|
6230ef707d | ||
|
|
b290a4696d | ||
|
|
4c965f7215 | ||
|
|
ce990094a1 | ||
|
|
4196d2acb0 | ||
|
|
3150da8b4a | ||
|
|
655c82d5e1 | ||
|
|
73302b718e | ||
|
|
bbf91ceac0 | ||
|
|
67b793c2aa | ||
|
|
d635e5a65d | ||
|
|
8dc140a953 | ||
|
|
eaa9f627e2 | ||
|
|
16cb28cb72 | ||
|
|
fa450f9f8f | ||
|
|
1e76ca6c0e | ||
|
|
25b7ea497f | ||
|
|
2f93774346 | ||
|
|
e2f6a92a90 | ||
|
|
0ffddaac9e | ||
|
|
4ddf6ddf26 | ||
|
|
7f61c190ea | ||
|
|
fbf328d90f | ||
|
|
36c6f7f1b8 | ||
|
|
0379ad17b9 | ||
|
|
02ed9f91f9 | ||
|
|
9fcc3db7b2 | ||
|
|
65ea84a69d | ||
|
|
a4b8d3a8ef | ||
|
|
2692a5fecb | ||
|
|
192c1659a0 | ||
|
|
cc241e41f4 | ||
|
|
4bfb57a6cf | ||
|
|
b6dedae7a1 | ||
|
|
f2783bd7a4 | ||
|
|
2efe41eadd | ||
|
|
ebd60b9abe | ||
|
|
2a16df49a4 | ||
|
|
0d6841259b | ||
|
|
8c0755c8c2 | ||
|
|
5e1da5bc5d | ||
|
|
242c6a49b5 | ||
|
|
aa399c160e | ||
|
|
d7cab4092d | ||
|
|
0370e592f9 | ||
|
|
116d06733a | ||
|
|
22a8a694a7 | ||
|
|
2ed24eee11 | ||
|
|
8822d8520a | ||
|
|
9832292a5b | ||
|
|
7a86c722fa | ||
|
|
2ca4043c02 | ||
|
|
4da8a0b353 | ||
|
|
492ff78b13 | ||
|
|
64a0b0890d | ||
|
|
546daddd49 | ||
|
|
f91d81029f | ||
|
|
68ee1718e0 | ||
|
|
c0d19ede39 | ||
|
|
bb05d64428 | ||
|
|
1977c7317f | ||
|
|
6f784d5aa2 | ||
|
|
4b5c9b82e4 | ||
|
|
0315ad23ae | ||
|
|
da70753f42 | ||
|
|
d59f1b63d1 | ||
|
|
7542947029 | ||
|
|
2d02434e7e | ||
|
|
e2824ea94c | ||
|
|
1c94548947 | ||
|
|
2073e3f650 | ||
|
|
90b8f481ec | ||
|
|
9ad9092e9e | ||
|
|
12adfe9975 | ||
|
|
83dceddae8 | ||
|
|
99b46cb97f | ||
|
|
3ac07cb3e2 | ||
|
|
d7f08d4e27 | ||
|
|
338f393969 | ||
|
|
57e930ca8a | ||
|
|
af3b917b57 | ||
|
|
d01bcc53fe | ||
|
|
e2fe2b4745 | ||
|
|
785099b20c | ||
|
|
726ceb03d2 | ||
|
|
1c37771591 | ||
|
|
67aeaea5f1 | ||
|
|
a8ac4b8497 | ||
|
|
71571d3672 | ||
|
|
2799b6caeb | ||
|
|
e8f94ad1be | ||
|
|
9080c7bdf4 | ||
|
|
d418bf50eb | ||
|
|
5c8e73fee0 | ||
|
|
4411d1a413 | ||
|
|
c919532aac | ||
|
|
676a3917e7 | ||
|
|
522ba33377 | ||
|
|
3a18cc219f | ||
|
|
9cb5c4fe38 | ||
|
|
57700b5e76 | ||
|
|
52ae16be1c | ||
|
|
951fab1070 | ||
|
|
0fd57af67e | ||
|
|
3ad5b26be6 | ||
|
|
d20c2becc8 | ||
|
|
002bedf4b8 | ||
|
|
11d32de9c5 | ||
|
|
50303dfeb0 | ||
|
|
9b15c88547 | ||
|
|
4042305f49 | ||
|
|
ea9a867b3a | ||
|
|
ff2415b024 | ||
|
|
cf553cad59 | ||
|
|
1df9cd2b2a | ||
|
|
344dcc9879 | ||
|
|
9ddebeb7fd | ||
|
|
3451cd5d3a | ||
|
|
2fa2606950 | ||
|
|
fc24b05eb3 | ||
|
|
bfc7f8a508 | ||
|
|
5a6f6b2680 | ||
|
|
b7c314e9f5 | ||
|
|
24e9295aca | ||
|
|
0a1306130d | ||
|
|
942d4fb2f2 | ||
|
|
fd173b6a2f | ||
|
|
c039a13fe6 | ||
|
|
6d208b3daf | ||
|
|
65c159081e | ||
|
|
d250c30f14 | ||
|
|
c701e741af | ||
|
|
3051b4af4e | ||
|
|
8085e8ced6 | ||
|
|
749980abbe | ||
|
|
db83f1d0e7 | ||
|
|
77960ba186 | ||
|
|
03fc562643 | ||
|
|
9ef58dfd27 | ||
|
|
1ce415bcd5 | ||
|
|
e4a9e47d6a | ||
|
|
dc1a999376 | ||
|
|
61109fa4c0 | ||
|
|
95eaa66080 | ||
|
|
bda4d82191 | ||
|
|
69cb823203 | ||
|
|
ec41c2f8ef | ||
|
|
964f9f9225 | ||
|
|
870b0068e9 | ||
|
|
26a563def3 | ||
|
|
a3685b8c81 | ||
|
|
5710147291 | ||
|
|
e7732c5a55 | ||
|
|
ccee0ef6c0 | ||
|
|
2893f40ec5 | ||
|
|
b670ad73c4 | ||
|
|
6764995dfe | ||
|
|
11be4085be | ||
|
|
31a3ae9a6b | ||
|
|
339b85e30a | ||
|
|
f0eb1f040e | ||
|
|
5896623822 | ||
|
|
3c6bd9f1e4 | ||
|
|
af28ab5291 | ||
|
|
27786d9e6f | ||
|
|
dc25078b01 | ||
|
|
565c0ea34f | ||
|
|
8a6e67aaae | ||
|
|
5cbc669dfd | ||
|
|
2b39644202 | ||
|
|
3f1aeeb421 | ||
|
|
f4e5f1a22f | ||
|
|
c81703720b | ||
|
|
ed06213c62 | ||
|
|
402119d718 | ||
|
|
2e8f90c1a8 | ||
|
|
408c495d63 | ||
|
|
f469dad106 | ||
|
|
e9b76bc503 | ||
|
|
db2c7d40da | ||
|
|
cf909d49cc | ||
|
|
4fdbb354ec | ||
|
|
dfbea31120 | ||
|
|
1a4606ea74 | ||
|
|
44accf6043 | ||
|
|
ad0e3fee26 | ||
|
|
f9727f58a9 | ||
|
|
3feb1a3e73 | ||
|
|
dc1ef28653 | ||
|
|
ba32853264 | ||
|
|
c292da47df | ||
|
|
1436ae7452 | ||
|
|
c09a07a3db | ||
|
|
4f9c382da7 | ||
|
|
84ac0190c8 | ||
|
|
50dad431cf | ||
|
|
b91f287df0 | ||
|
|
78be8c6a54 | ||
|
|
70db28d81e | ||
|
|
4696f53a89 | ||
|
|
630801a5e8 | ||
|
|
27cb5cdb83 | ||
|
|
5a4faf686a | ||
|
|
e7fbd9baaf | ||
|
|
065014dc10 | ||
|
|
ed13840881 | ||
|
|
5c83d457f5 | ||
|
|
12daba0161 | ||
|
|
ebf7c00849 | ||
|
|
1dd9090088 | ||
|
|
dc2c35f822 | ||
|
|
d916ccfb6e | ||
|
|
5a10cf0f4d | ||
|
|
323833ebb6 | ||
|
|
ed234baf76 | ||
|
|
5a7738b5b2 | ||
|
|
66a63b1a74 | ||
|
|
fc3479fb8a | ||
|
|
b5557335dc | ||
|
|
9b5111aabf | ||
|
|
37f6878d54 | ||
|
|
5edc116b13 | ||
|
|
6c8bbdff1f | ||
|
|
1dde56c208 | ||
|
|
aba3989063 | ||
|
|
5c6a797703 | ||
|
|
5a236400f0 | ||
|
|
21efc3024d | ||
|
|
b2d0403150 | ||
|
|
298239039d | ||
|
|
8c33e44e3c | ||
|
|
a16d0ad0f0 | ||
|
|
5971ef7565 | ||
|
|
b62f7f7bb5 | ||
|
|
b137e8682b | ||
|
|
f19ac19b27 | ||
|
|
e667c29da2 | ||
|
|
bced882c75 | ||
|
|
8c738ecd49 | ||
|
|
828f4cf676 | ||
|
|
c70254061a | ||
|
|
8ce19a61f5 | ||
|
|
b01e2a98f9 | ||
|
|
b2a6ae440e | ||
|
|
554d7dd86e | ||
|
|
29c3924ab7 | ||
|
|
b61f99355f | ||
|
|
b7f78f5eb1 | ||
|
|
b561fa6b3c | ||
|
|
d82032073b | ||
|
|
935d983626 | ||
|
|
f6fb0dc877 | ||
|
|
3dd16bba79 | ||
|
|
c46fe6f128 | ||
|
|
074c3c7340 | ||
|
|
8cd8374bbe | ||
|
|
aa0541f09b | ||
|
|
eee166467d | ||
|
|
95b0e529e2 | ||
|
|
45be87a72a | ||
|
|
d632364c7d | ||
|
|
9e660214eb | ||
|
|
14340b3a65 | ||
|
|
b07402628e | ||
|
|
035283a596 | ||
|
|
cc46f00a22 | ||
|
|
27263928cd | ||
|
|
0f122466ad | ||
|
|
32cdb29515 | ||
|
|
fe311ced32 | ||
|
|
e41bea7e6b | ||
|
|
9d169cebf3 | ||
|
|
5551f2c63f | ||
|
|
ff3e704cdf | ||
|
|
caaeb2eefb | ||
|
|
8991797d35 | ||
|
|
aa95c26b2a | ||
|
|
11cc90e2d5 | ||
|
|
d11e511f67 | ||
|
|
a3708ca279 | ||
|
|
14d0417a25 | ||
|
|
f4103206db | ||
|
|
c9b1bfed40 | ||
|
|
7f764b4d99 | ||
|
|
fb7ddbba70 | ||
|
|
85b1d13718 | ||
|
|
7f2191a11a | ||
|
|
c4adf4f495 | ||
|
|
95d146a504 | ||
|
|
ccc8a0dab5 | ||
|
|
9b79bdbdd5 | ||
|
|
1f3d0b50a7 | ||
|
|
d8d409ae6b | ||
|
|
6b9852cc14 | ||
|
|
fbf627c971 | ||
|
|
b2077132cf | ||
|
|
f622c3ee03 | ||
|
|
ab83f3ed0c | ||
|
|
a021b503a0 | ||
|
|
d28714aacc | ||
|
|
7632a66250 | ||
|
|
bb6936d657 | ||
|
|
d4062b679a | ||
|
|
313ee0a9a3 | ||
|
|
7afc384d17 | ||
|
|
fea1f240dd | ||
|
|
1dba0e857f | ||
|
|
0966aa689f | ||
|
|
138e237fbc | ||
|
|
6b38ec1669 | ||
|
|
5cd415e300 | ||
|
|
7cdaa4bf25 | ||
|
|
280ddf583b | ||
|
|
4969cafc97 | ||
|
|
5f6e63542b | ||
|
|
bca9c96468 | ||
|
|
7569c06a36 | ||
|
|
88bafbc1ac | ||
|
|
a5acd6ec83 | ||
|
|
d93c8bdef2 | ||
|
|
8a32bd6485 | ||
|
|
425cbc4826 | ||
|
|
3a2d3f5047 | ||
|
|
ae20b85400 | ||
|
|
e993c5d376 | ||
|
|
80fabeac54 | ||
|
|
c001be9abf | ||
|
|
639a542fb2 | ||
|
|
9299258de0 | ||
|
|
59f8ac6dd4 | ||
|
|
f16155bb1f | ||
|
|
e2d2f73bb3 | ||
|
|
9ca5d6c8c2 | ||
|
|
4f9d1c1ca1 | ||
|
|
d8f673bd26 | ||
|
|
7e2068d82a | ||
|
|
176611dbf3 | ||
|
|
372bae0e03 | ||
|
|
6f35ec3705 | ||
|
|
a542d80c1d | ||
|
|
9dcf256aa1 | ||
|
|
da206f41ad | ||
|
|
550beb9baf | ||
|
|
3d99406f33 | ||
|
|
7f9adcef36 | ||
|
|
ab355977ba | ||
|
|
f24eb52697 | ||
|
|
60dbc42148 | ||
|
|
8667fcdef3 | ||
|
|
ec20445772 | ||
|
|
8d9fb29848 | ||
|
|
f7a7e817f9 | ||
|
|
e09cab6872 | ||
|
|
f1797f29fd | ||
|
|
4eae07f831 | ||
|
|
0293928a99 | ||
|
|
b56d6dbe7c | ||
|
|
42d269e28d | ||
|
|
8f60a1da53 | ||
|
|
f511be7c33 | ||
|
|
ebb426e696 | ||
|
|
63696b746e | ||
|
|
c07276a3be | ||
|
|
4a2297f5cd | ||
|
|
f8967d55c4 | ||
|
|
7e8745d226 | ||
|
|
e2efc85833 | ||
|
|
41038b9bcd | ||
|
|
9fe8c9568c | ||
|
|
9614f7a209 | ||
|
|
8dbaaf6798 | ||
|
|
c14ad6cb76 | ||
|
|
adda280dd3 | ||
|
|
15fd47bdb4 | ||
|
|
78b6d8b7b6 | ||
|
|
61bc63ccc5 | ||
|
|
05df8b7fe2 | ||
|
|
3cb7dffb90 | ||
|
|
d0aafc34b9 | ||
|
|
d2e1b5019f | ||
|
|
2a77c71645 | ||
|
|
780e5c185e | ||
|
|
38e2a4e69a | ||
|
|
7e0c34b6a3 | ||
|
|
e3ceb90d6f | ||
|
|
6977e3bcdf | ||
|
|
f382cddc2a | ||
|
|
99a5642bdf | ||
|
|
174d832ab0 | ||
|
|
3ee7586fe2 | ||
|
|
e2c724b4ae | ||
|
|
d581f19a36 | ||
|
|
48dea24bea | ||
|
|
5fc2a693a0 | ||
|
|
7be0722140 | ||
|
|
6ab9fe4bf4 | ||
|
|
5811af0342 | ||
|
|
3cc6b30e8b | ||
|
|
856112c2f6 | ||
|
|
ed2924264a | ||
|
|
e9394ccf2e | ||
|
|
dec72f95c6 | ||
|
|
d6bfd63deb | ||
|
|
d62ed3daf5 | ||
|
|
3bb9c2cee3 | ||
|
|
72f8d5d0f6 | ||
|
|
a1c508fc2c | ||
|
|
80c11b2c7f | ||
|
|
e6a2a86828 | ||
|
|
96749be571 | ||
|
|
6b7e8e7749 | ||
|
|
43b29432a2 | ||
|
|
ff84946068 | ||
|
|
7cdde99864 | ||
|
|
8eee1fe2e1 | ||
|
|
6fc09864f6 | ||
|
|
1510980ce3 | ||
|
|
56005f0f28 | ||
|
|
03b655515c | ||
|
|
edd874f356 | ||
|
|
7f13debe3b | ||
|
|
1565bdbf1a | ||
|
|
ec4cee8c77 | ||
|
|
c5b27628b0 | ||
|
|
79ee086efd | ||
|
|
b910b554e6 | ||
|
|
bee3935270 |
@@ -1,8 +1,24 @@
|
||||
Dockerfile
|
||||
.dockerignore
|
||||
.gitignore
|
||||
.git
|
||||
src/logs
|
||||
logs
|
||||
.github
|
||||
/docs/
|
||||
/node_modules/
|
||||
docs
|
||||
node_modules
|
||||
coverage
|
||||
.nyc_output
|
||||
.idea
|
||||
*.bak
|
||||
*.sqlite
|
||||
*.sqlite*
|
||||
*.json
|
||||
*.json5
|
||||
*.yaml
|
||||
*.yml
|
||||
*.env
|
||||
|
||||
# exceptions
|
||||
!heroku.yml
|
||||
!app.json
|
||||
!.nycrc.json
|
||||
!.mocharc.json
|
||||
!tsconfig.json
|
||||
!package*.json
|
||||
|
||||
2
.github/FUNDING.yml
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
github: [FoxxMD]
|
||||
custom: ["bitcoincash:qqmpsh365r8n9jhp4p8ks7f7qdr7203cws4kmkmr8q"]
|
||||
3
.github/push-hook-sample.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"ref": "refs/heads/edge"
|
||||
}
|
||||
@@ -1,4 +1,14 @@
|
||||
name: Publish Docker image to Dockerhub
|
||||
name: Publish Docker image to registries
|
||||
|
||||
# Builds image and tags based on the type of push event:
|
||||
# * branch push -> tag is branch name IE context-mod:edge
|
||||
# * release (tag) -> tag is release name IE context-mod:0.13.0
|
||||
#
|
||||
# Then pushes tagged images to multiple registries
|
||||
#
|
||||
# Based on
|
||||
# https://github.com/docker/build-push-action/blob/master/docs/advanced/push-multi-registries.md
|
||||
# https://github.com/docker/metadata-action
|
||||
|
||||
on:
|
||||
push:
|
||||
@@ -13,8 +23,12 @@ on:
|
||||
|
||||
jobs:
|
||||
push_to_registry:
|
||||
name: Push Docker image to Docker Hub
|
||||
name: Build and Push Docker image to registries
|
||||
runs-on: ubuntu-latest
|
||||
# https://docs.github.com/en/actions/security-guides/automatic-token-authentication#permissions-for-the-github_token
|
||||
permissions:
|
||||
packages: write
|
||||
contents: read
|
||||
steps:
|
||||
- name: Check out the repo
|
||||
uses: actions/checkout@v2
|
||||
@@ -25,12 +39,22 @@ jobs:
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
|
||||
- name: Login to GitHub Container Registry
|
||||
if: github.event_name != 'pull_request'
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.repository_owner }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Extract metadata (tags, labels) for Docker
|
||||
id: meta
|
||||
uses: docker/metadata-action@v3
|
||||
with:
|
||||
images: foxxmd/context-mod
|
||||
images: |
|
||||
foxxmd/context-mod
|
||||
ghcr.io/foxxmd/context-mod
|
||||
# generate Docker tags based on the following events/attributes
|
||||
tags: |
|
||||
type=raw,value=latest,enable=${{ endsWith(github.ref, 'master') }}
|
||||
@@ -40,7 +64,8 @@ jobs:
|
||||
latest=false
|
||||
|
||||
- name: Build and push Docker image
|
||||
uses: docker/build-push-action@v2
|
||||
if: ${{ !env.ACT }}
|
||||
uses: docker/build-push-action@v3
|
||||
with:
|
||||
context: .
|
||||
push: ${{ github.event_name != 'pull_request' }}
|
||||
15
.gitignore
vendored
@@ -336,6 +336,7 @@ web_modules/
|
||||
# dotenv environment variables file
|
||||
.env
|
||||
.env.test
|
||||
*.env
|
||||
|
||||
# parcel-bundler cache (https://parceljs.org/)
|
||||
.cache
|
||||
@@ -381,5 +382,17 @@ dist
|
||||
.pnp.*
|
||||
|
||||
**/src/**/*.js
|
||||
!src/Web/assets/public/yaml/*
|
||||
**/tests/**/*.js
|
||||
**/tests/**/*.map
|
||||
!src/Web/assets/**
|
||||
**/src/**/*.map
|
||||
/**/*.sqlite
|
||||
/**/*.bak
|
||||
*.yaml
|
||||
*.json5
|
||||
|
||||
!src/Schema/*.json
|
||||
!.github/push-hook-sample.json
|
||||
!docs/**/*.json5
|
||||
!docs/**/*.yaml
|
||||
!docs/**/*.json
|
||||
|
||||
3
.idea/redditcontextbot.iml
generated
@@ -2,10 +2,13 @@
|
||||
<module type="WEB_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/tests" isTestSource="true" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/temp" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/tmp" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/src/logs" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/coverage" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/.nyc_output" />
|
||||
</content>
|
||||
<content url="file://$MODULE_DIR$/node_modules" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
|
||||
4
.mocharc.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"require": ["./register.js", "source-map-support/register"],
|
||||
"reporter": "dot"
|
||||
}
|
||||
24
.nycrc.json
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"extends": "@istanbuljs/nyc-config-typescript",
|
||||
"exclude": [
|
||||
"node_modules/",
|
||||
"**/src/Schema/**",
|
||||
"**/src/Web/assets/**",
|
||||
"**/tests/**",
|
||||
"register.js",
|
||||
"**/src/**/*.d.ts"
|
||||
],
|
||||
"include": [
|
||||
"**/src/**/*.ts",
|
||||
"**/src/**/*.js",
|
||||
"**/src/**/*.js.map"
|
||||
],
|
||||
"extension": [
|
||||
".ts"
|
||||
],
|
||||
"reporter": [
|
||||
"text-summary",
|
||||
"html"
|
||||
],
|
||||
"report-dir": "./coverage"
|
||||
}
|
||||
116
Dockerfile
@@ -1,41 +1,133 @@
|
||||
FROM node:16-alpine3.14 as base
|
||||
FROM lsiobase/alpine:3.15 as base
|
||||
|
||||
ENV TZ=Etc/GMT
|
||||
|
||||
# borrowed from node/alpine:3.15
|
||||
# https://github.com/nodejs/docker-node/blob/main/16/alpine3.15/Dockerfile
|
||||
#
|
||||
# Start of node docker stuff
|
||||
#
|
||||
ENV NODE_VERSION 16.14.2
|
||||
|
||||
RUN apk add --no-cache \
|
||||
libstdc++ \
|
||||
&& apk add --no-cache --virtual .build-deps \
|
||||
curl \
|
||||
&& ARCH= && alpineArch="$(apk --print-arch)" \
|
||||
&& case "${alpineArch##*-}" in \
|
||||
x86_64) \
|
||||
ARCH='x64' \
|
||||
CHECKSUM="a6dc255e1ef1f20372306eec932b4a3648575c6d3024bcd685b8efc93dc95569" \
|
||||
;; \
|
||||
*) ;; \
|
||||
esac \
|
||||
&& if [ -n "${CHECKSUM}" ]; then \
|
||||
set -eu; \
|
||||
curl -fsSLO --compressed "https://unofficial-builds.nodejs.org/download/release/v$NODE_VERSION/node-v$NODE_VERSION-linux-$ARCH-musl.tar.xz"; \
|
||||
echo "$CHECKSUM node-v$NODE_VERSION-linux-$ARCH-musl.tar.xz" | sha256sum -c - \
|
||||
&& tar -xJf "node-v$NODE_VERSION-linux-$ARCH-musl.tar.xz" -C /usr/local --strip-components=1 --no-same-owner \
|
||||
&& ln -s /usr/local/bin/node /usr/local/bin/nodejs; \
|
||||
else \
|
||||
echo "Building from source" \
|
||||
# backup build
|
||||
&& apk add --no-cache --virtual .build-deps-full \
|
||||
binutils-gold \
|
||||
g++ \
|
||||
gcc \
|
||||
gnupg \
|
||||
libgcc \
|
||||
linux-headers \
|
||||
make \
|
||||
python3 \
|
||||
# gpg keys listed at https://github.com/nodejs/node#release-keys
|
||||
&& for key in \
|
||||
4ED778F539E3634C779C87C6D7062848A1AB005C \
|
||||
141F07595B7B3FFE74309A937405533BE57C7D57 \
|
||||
94AE36675C464D64BAFA68DD7434390BDBE9B9C5 \
|
||||
74F12602B6F1C4E913FAA37AD3A89613643B6201 \
|
||||
71DCFD284A79C3B38668286BC97EC7A07EDE3FC1 \
|
||||
8FCCA13FEF1D0C2E91008E09770F7A9A5AE15600 \
|
||||
C4F0DFFF4E8C1A8236409D08E73BC641CC11F4C8 \
|
||||
C82FA3AE1CBEDC6BE46B9360C43CEC45C17AB93C \
|
||||
DD8F2338BAE7501E3DD5AC78C273792F7D83545D \
|
||||
A48C2BEE680E841632CD4E44F07496B3EB3C1762 \
|
||||
108F52B48DB57BB0CC439B2997B01419BD92F80A \
|
||||
B9E2F5981AA6E0CD28160D9FF13993A75599653C \
|
||||
; do \
|
||||
gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$key" || \
|
||||
gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "$key" ; \
|
||||
done \
|
||||
&& curl -fsSLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION.tar.xz" \
|
||||
&& curl -fsSLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/SHASUMS256.txt.asc" \
|
||||
&& gpg --batch --decrypt --output SHASUMS256.txt SHASUMS256.txt.asc \
|
||||
&& grep " node-v$NODE_VERSION.tar.xz\$" SHASUMS256.txt | sha256sum -c - \
|
||||
&& tar -xf "node-v$NODE_VERSION.tar.xz" \
|
||||
&& cd "node-v$NODE_VERSION" \
|
||||
&& ./configure \
|
||||
&& make -j$(getconf _NPROCESSORS_ONLN) V= \
|
||||
&& make install \
|
||||
&& apk del .build-deps-full \
|
||||
&& cd .. \
|
||||
&& rm -Rf "node-v$NODE_VERSION" \
|
||||
&& rm "node-v$NODE_VERSION.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt; \
|
||||
fi \
|
||||
&& rm -f "node-v$NODE_VERSION-linux-$ARCH-musl.tar.xz" \
|
||||
&& apk del .build-deps \
|
||||
# smoke tests
|
||||
&& node --version \
|
||||
&& npm --version
|
||||
#
|
||||
# end of docker node stuff
|
||||
#
|
||||
|
||||
# vips required to run sharp library for image comparison
|
||||
RUN echo "http://dl-4.alpinelinux.org/alpine/v3.14/community" >> /etc/apk/repositories \
|
||||
&& apk --no-cache add vips
|
||||
|
||||
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
||||
|
||||
WORKDIR /usr/app
|
||||
ARG data_dir=/config
|
||||
VOLUME $data_dir
|
||||
ENV DATA_DIR=$data_dir
|
||||
|
||||
COPY docker/root/ /
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
FROM base as build
|
||||
|
||||
COPY package*.json ./
|
||||
COPY tsconfig.json .
|
||||
COPY --chown=abc:abc package*.json ./
|
||||
COPY --chown=abc:abc tsconfig.json .
|
||||
|
||||
RUN npm install
|
||||
|
||||
ADD . /usr/app
|
||||
COPY --chown=abc:abc . /app
|
||||
|
||||
RUN npm run build && rm -rf node_modules
|
||||
|
||||
FROM base as app
|
||||
|
||||
COPY --from=build /usr/app /usr/app
|
||||
COPY --from=build --chown=abc:abc /app /app
|
||||
|
||||
RUN npm install --production
|
||||
RUN npm install --production \
|
||||
&& npm cache clean --force \
|
||||
&& chown abc:abc node_modules \
|
||||
&& rm -rf node_modules/ts-node \
|
||||
&& rm -rf node_modules/typescript
|
||||
|
||||
ENV NPM_CONFIG_LOGLEVEL debug
|
||||
|
||||
ARG log_dir=/home/node/logs
|
||||
RUN mkdir -p $log_dir
|
||||
VOLUME $log_dir
|
||||
ENV LOG_DIR=$log_dir
|
||||
# can set database to use more performant better-sqlite3 since we control everything
|
||||
ENV DB_DRIVER=better-sqlite3
|
||||
|
||||
# NODE_ARGS are expanded after `node` command in the entrypoint IE "node {NODE_ARGS} src/index.js run"
|
||||
# by default enforce better memory mangement by limiting max long-lived GC space to 512MB
|
||||
ENV NODE_ARGS="--max_old_space_size=512"
|
||||
|
||||
ARG webPort=8085
|
||||
ENV PORT=$webPort
|
||||
EXPOSE $PORT
|
||||
|
||||
CMD [ "node", "src/index.js", "run" ]
|
||||
# convenience variable for more helpful error messages
|
||||
ENV IS_DOCKER=true
|
||||
|
||||
|
||||
93
README.md
@@ -1,38 +1,52 @@
|
||||
[](https://github.com/FoxxMD/context-mod/releases)
|
||||
[](https://opensource.org/licenses/MIT)
|
||||
[](https://hub.docker.com/r/foxxmd/context-mod)
|
||||
# ContextMod [](https://github.com/FoxxMD/context-mod/releases) [](https://opensource.org/licenses/MIT) [](https://hub.docker.com/r/foxxmd/context-mod)
|
||||
|
||||
<img src="/docs/logo.png" align="right"
|
||||
alt="ContextMod logo" width="180" height="176">
|
||||
|
||||
**Context Mod** (CM) is an event-based, [reddit](https://reddit.com) moderation bot built on top of [snoowrap](https://github.com/not-an-aardvark/snoowrap) and written in [typescript](https://www.typescriptlang.org/).
|
||||
|
||||
It is designed to help fill in the gaps for [automoderator](https://www.reddit.com/wiki/automoderator/full-documentation) in regard to more complex behavior with a focus on **user-history based moderation.**
|
||||
|
||||
An example of the above that Context Bot can do now:
|
||||
An example of the above that Context Bot can do:
|
||||
|
||||
> * On a new submission, check if the user has also posted the same link in **N** number of other subreddits within a timeframe/# of posts
|
||||
> * On a new submission or comment, check if the user has had any activity (sub/comment) in **N** set of subreddits within a timeframe/# of posts
|
||||
>
|
||||
>In either instance Context Bot can then perform any action a moderator can (comment, report, remove, lock, etc...) against that user, comment, or submission.
|
||||
|
||||
Some feature highlights:
|
||||
* Simple rule-action behavior can be combined to create any level of complexity in behavior
|
||||
* Server/client architecture
|
||||
Feature Highlights for **Moderators:**
|
||||
|
||||
* Complete bot **autonomy**. YAML config is [stored in your subreddit's wiki](/docs/subreddit/gettingStarted.md#setup-wiki-page) (like automoderator)
|
||||
* Simple rule-action behavior can be combined to create **complex behavior detection**
|
||||
* Support Activity filtering based on:
|
||||
* [Author criteria](/docs/subreddit/components/README.md#author-filter) (name, css flair/text, age, karma, moderator status, [Toolbox User Notes](https://www.reddit.com/r/toolbox/wiki/docs/usernotes), and more!)
|
||||
* [Activity state](/docs/subreddit/components/README.md#item-filter) (removed, locked, distinguished, etc...)
|
||||
* State of Subreddit Activity is in [Subreddit](/docs/subreddit/components/README.md#subreddit-filter) (nsfw, name, profile, etc...)
|
||||
* Rules and Actions support [named references](/docs/subreddit/components/README.md#named-rules) -- **write once, reference anywhere**
|
||||
* Powerful [logic control](/docs/subreddit/components/advancedConcepts/flowControl.md) (if, then, goto)
|
||||
* [Delay/re-process activities](/docs/subreddit/components/README.md#dispatch) using arbitrary rules
|
||||
* [**Image Comparisons**](/docs/imageComparison.md) via fingerprinting and/or pixel differences
|
||||
* [**Repost detection**](/docs/subreddit/components/repost) with support for external services (youtube, etc...)
|
||||
* Event notification via Discord
|
||||
* [**Web interface**](#web-ui-and-screenshots) for monitoring, administration, and oauth bot authentication
|
||||
* [**Placeholders**](/docs/subreddit/actionTemplating.md) (like automoderator) can be configured via a wiki page or raw text and supports [mustache](https://mustache.github.io) templating
|
||||
* [**Partial Configurations**](/docs/subreddit/components/README.md#partial-configurations) -- offload parts of your configuration to shared locations to consolidate logic between multiple subreddits
|
||||
* [Guest Access](/docs/subreddit/README.md#guest-access) enables collaboration and easier setup by allowing temporary access
|
||||
* [Toxic content prediction](/docs/subreddit/components/README.md#moderatehatespeechcom-predictions) using [moderatehatespeech.com](https://moderatehatespeech.com) machine learning model
|
||||
|
||||
Feature highlights for **Developers and Hosting (Operators):**
|
||||
|
||||
* [Server/client architecture](/docs/serverClientArchitecture.md)
|
||||
* Default/no configuration runs "All In One" behavior
|
||||
* Additional configuration allows web interface to connect to multiple servers
|
||||
* Each server instance can run multiple reddit accounts as bots
|
||||
* **Per-subreddit configuration** is handled by YAML (**like automoderator!**) or JSON stored in the subreddit wiki
|
||||
* Any text-based actions (comment, submission, message, usernotes, ban, etc...) can be configured via a wiki page or raw text and supports [mustache](https://mustache.github.io) [templating](/docs/actionTemplating.md)
|
||||
* History-based rules support multiple "valid window" types -- [ISO 8601 Durations](https://en.wikipedia.org/wiki/ISO_8601#Durations), [Day.js Durations](https://day.js.org/docs/en/durations/creating), and submission/comment count limits.
|
||||
* Support Activity skipping based on:
|
||||
* Author criteria (name, css flair/text, age, karma, moderator status, and [Toolbox User Notes](https://www.reddit.com/r/toolbox/wiki/docs/usernotes))
|
||||
* Activity state (removed, locked, distinguished, etc.)
|
||||
* Rules and Actions support named references (write once, reference anywhere)
|
||||
* [**Image Comparisons**](/docs/imageComparison.md) via fingerprinting and/or pixel differences
|
||||
* [**Repost detection**](/docs/examples/repost) with support for external services (youtube, etc...)
|
||||
* Global/subreddit-level **API caching**
|
||||
* Support for [Toolbox User Notes](https://www.reddit.com/r/toolbox/wiki/docs/usernotes) as criteria or Actions (writing notes)
|
||||
* Docker container support
|
||||
* Event notification via Discord
|
||||
* **Web interface** for monitoring, administration, and oauth bot authentication
|
||||
* Global/subreddit-level [**caching**](/docs/operator/caching.md) of Reddit APIs responses and CM results
|
||||
* [Database Persistence](/docs/operator/database.md) using SQLite, MySql, or Postgres
|
||||
* Audit trails for bot activity
|
||||
* Historical statistics
|
||||
* [Docker container support](/docs/operator/installation.md#docker-recommended)
|
||||
* Easy, UI-based [OAuth authentication](/docs/operator/addingBot.md) for adding Bots and moderator dashboard
|
||||
* Integration with [InfluxDB](https://www.influxdata.com) for detailed [time-series metrics](/docs/operator/database.md#influx) and a pre-built [Grafana](https://grafana.com) [dashboard](/docs/operator/database.md#grafana)
|
||||
|
||||
# Table of Contents
|
||||
|
||||
@@ -45,7 +59,7 @@ Some feature highlights:
|
||||
|
||||
Each subreddit using the RCB bot configures its behavior via their own wiki page.
|
||||
|
||||
When a monitored **Event** (new comment/submission, new modqueue item, etc.) is detected the bot runs through a list of **Checks** to determine what to do with the **Activity** from that Event. Each **Check** consists of :
|
||||
When a monitored **Activity** (new comment/submission, new modqueue item, etc.) is detected the bot runs through a list of [**Checks**](/docs/subreddit/components/README.md#checks) to determine what to do with the **Activity** from that Event. Each **Check** consists of :
|
||||
|
||||
#### Kind
|
||||
|
||||
@@ -53,11 +67,11 @@ Is this check for a submission or comment?
|
||||
|
||||
#### Rules
|
||||
|
||||
A list of **Rule** objects to run against the **Activity**. Triggered Rules can cause the whole Check to trigger and run its **Actions**
|
||||
A list of [**Rules**](/docs/subreddit/components/README.md#rules) to run against the **Activity**. Triggered Rules can cause the whole Check to trigger and run its **Actions**
|
||||
|
||||
#### Actions
|
||||
|
||||
A list of **Action** objects that describe what the bot should do with the **Activity** or **Author** of the activity (comment, remove, approve, etc.). The bot will run **all** Actions in this list.
|
||||
A list of [**Actions**](/docs/subreddit/components/README.md#actions) that describe what the bot should do with the **Activity** or **Author** of the activity (comment, remove, approve, etc.). The bot will run **all** Actions in this list.
|
||||
|
||||
___
|
||||
|
||||
@@ -67,7 +81,7 @@ When an Event occurs all Checks of that type are run in the order they were list
|
||||
|
||||
___
|
||||
|
||||
[Learn more about the RCB lifecycle and core concepts in the docs.](/docs#how-it-works)
|
||||
[Learn more about the RCB lifecycle and core concepts in the docs.](/docs/README.md#how-it-works)
|
||||
|
||||
## Getting Started
|
||||
|
||||
@@ -75,20 +89,20 @@ ___
|
||||
|
||||
This guide is for users who want to **run their own bot on a ContextMod instance.**
|
||||
|
||||
See the [Operator's Getting Started Guide](/docs/gettingStartedOperator.md)
|
||||
See the [Operator's Getting Started Guide](/docs/operator/gettingStarted.md)
|
||||
|
||||
#### Moderators
|
||||
|
||||
This guide is for **reddit moderators** who want to configure an existing CM bot to run on their subreddit.
|
||||
|
||||
See the [Moderator's Getting Started Guide](/docs/gettingStartedMod.md)
|
||||
See the [Moderator's Getting Started Guide](/docs/subreddit/gettingStarted.md)
|
||||
|
||||
## Configuration and Documentation
|
||||
|
||||
Context Bot's configuration can be written in YAML (like automoderator) or [JSON5](https://json5.org/). Its schema conforms to [JSON Schema Draft 7](https://json-schema.org/). Additionally, many **operator** settings can be passed via command line or environmental variables.
|
||||
|
||||
* For **operators** (running the bot instance) see the [Operator Configuration](/docs/operatorConfiguration.md) guide
|
||||
* For **moderators** consult the [app schema and examples folder](/docs/#configuration-and-usage)
|
||||
* For **operators** (running the bot instance) see the [Operator Configuration](/docs/operator/configuration.md) guide
|
||||
* For **moderators** consult the [app schema and examples folder](/docs/README.md#configuration-and-usage)
|
||||
|
||||
[**Check the full docs for in-depth explanations of all concepts and examples**](/docs)
|
||||
|
||||
@@ -108,19 +122,23 @@ CM comes equipped with a dashboard designed for use by both moderators and bot o
|
||||
* View **real-time logs** of what the bot is doing on your subreddit
|
||||
* **Run bot on any permalink**
|
||||
|
||||

|
||||

|
||||
|
||||
### Bot Setup/Authentication
|
||||
|
||||
A bot oauth helper allows operators to define oauth credentials/permissions and then generate unique, one-time invite links that allow moderators to authenticate their own bots without operator assistance. [Learn more about using the oauth helper.](docs/botAuthentication.md#cm-oauth-helper-recommended)
|
||||
A bot oauth helper allows operators to define oauth credentials/permissions and then generate unique, one-time invite links that allow moderators to authenticate their own bots without operator assistance. [Learn more about using the oauth helper.](docs/operator/addingBot.md#cm-oauth-helper-recommended)
|
||||
|
||||
Operator view/invite link generation:
|
||||
|
||||

|
||||

|
||||
|
||||
Moderator view/invite and authorization:
|
||||
|
||||

|
||||

|
||||
|
||||
A similar helper and invitation experience is available for adding **subreddits to an existing bot.**
|
||||
|
||||

|
||||
|
||||
### Configuration Editor
|
||||
|
||||
@@ -133,7 +151,14 @@ A built-in editor using [monaco-editor](https://microsoft.github.io/monaco-edito
|
||||
* Authenticated view loads subreddit configurations by simple link found on the subreddit dashboard
|
||||
* Switch schemas to edit either subreddit or operator configurations
|
||||
|
||||

|
||||

|
||||
|
||||
### [Grafana Dashboard](/docs/operator/database.md#grafana)
|
||||
|
||||
* Overall stats (active bots/subreddits, api calls, per second/hour/minute activity ingest)
|
||||
* Over time graphs for events, per subreddit, and for individual rules/check/actions
|
||||
|
||||

|
||||
|
||||
## License
|
||||
|
||||
|
||||
3
act.env.example
Normal file
@@ -0,0 +1,3 @@
|
||||
GITHUB_TOKEN=
|
||||
DOCKERHUB_USERNAME=
|
||||
DOCKER_PASSWORD=
|
||||
14
docker/root/etc/cont-init.d/10-config
Normal file
@@ -0,0 +1,14 @@
|
||||
#!/usr/bin/with-contenv bash
|
||||
|
||||
# used https://github.com/linuxserver/docker-plex as a template
|
||||
|
||||
# make data folder if not /config
|
||||
if [ ! -d "${DATA_DIR}" ]; then \
|
||||
mkdir -p "${DATA_DIR}"
|
||||
chown -R abc:abc /config
|
||||
fi
|
||||
|
||||
# permissions
|
||||
chown abc:abc \
|
||||
/config \
|
||||
/config/*
|
||||
9
docker/root/etc/services.d/node/run
Normal file
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/with-contenv bash
|
||||
|
||||
# used https://github.com/linuxserver/docker-plex as a template
|
||||
|
||||
# NODE_ARGS can be passed by ENV in docker command like "docker run foxxmd/context-mod -e NODE_ARGS=--optimize_for_size"
|
||||
|
||||
exec \
|
||||
s6-setuidgid abc \
|
||||
/usr/local/bin/node $NODE_ARGS /app/src/index.js run
|
||||
341
docs/README.md
@@ -5,104 +5,119 @@
|
||||
* [Getting Started](#getting-started)
|
||||
* [How It Works](#how-it-works)
|
||||
* [Concepts](#concepts)
|
||||
* [Event](#event)
|
||||
* [Activity](#activity)
|
||||
* [Run](#runs)
|
||||
* [Check](#checks)
|
||||
* [Rule](#rule)
|
||||
* [Examples](#available-rules)
|
||||
* [Available Rules](#available-rules)
|
||||
* [Rule Set](#rule-set)
|
||||
* [Examples](#rule-set-examples)
|
||||
* [Action](#action)
|
||||
* [Examples](#available-actions)
|
||||
* [Available Actions](#available-actions)
|
||||
* [Filters](#filters)
|
||||
* [Configuration and Usage](#configuration-and-usage)
|
||||
* [Common Resources](#common-resources)
|
||||
* [Activities `window`](#activities-window)
|
||||
* [Comparisons](#thresholds-and-comparisons)
|
||||
* [Activity Templating](/docs/actionTemplating.md)
|
||||
* [Image Comparisons](#image-comparisons)
|
||||
* [Best Practices](#best-practices)
|
||||
* [Named Rules](#named-rules)
|
||||
* [Rule Order](#rule-order)
|
||||
* [Caching](#caching)
|
||||
* FAQ
|
||||
|
||||
## Getting Started
|
||||
|
||||
Review **at least** the **How It Works** and **Concepts** below, then:
|
||||
|
||||
* For **Operators** (running a bot instance) refer to [**Operator Getting Started**](/docs/gettingStartedOperator.md) guide
|
||||
* For **Moderators** (configuring an existing bot for your subreddit) refer to the [**Moderator Getting Started**](/docs/gettingStartedMod.md) guide
|
||||
* For **Operators** (running a bot instance) refer to [**Operator Getting Started**](/docs/operator/gettingStarted.md) guide
|
||||
* For **Moderators** (configuring an existing bot for your subreddit) refer to the [**Moderator Getting Started**](/docs/subreddit/gettingStarted.md) guide
|
||||
|
||||
## How It Works
|
||||
|
||||
Where possible Context Mod (CM) uses the same terminology as, and emulates the behavior, of **automoderator** so if you are familiar with that much of this may seem familiar to you.
|
||||
|
||||
### Diagram
|
||||
|
||||
Expand the section below for a simplified flow diagram of how CM processes an incoming Activity. Then refer the text description of the diagram below as well as [Concepts](#Concepts) for descriptions of individual components.
|
||||
|
||||
<details>
|
||||
<summary>Diagram</summary>
|
||||
|
||||

|
||||
|
||||
</details>
|
||||
|
||||
CM's lifecycle looks like this:
|
||||
|
||||
#### 1) A new event in your subreddit is received by CM
|
||||
#### 1) A new Activity in your subreddit is received by CM
|
||||
|
||||
The events CM watches for are configured by you. These can be new modqueue/unmoderated items, submissions, or comments.
|
||||
The Activities CM watches for are configured by you. These can be new modqueue/unmoderated items, submissions, or comments.
|
||||
|
||||
#### 2) CM sequentially processes each Check in your configuration
|
||||
#### 2) CM sequentially processes each Run in your configuration
|
||||
|
||||
A [**Run**](#Runs) is made up of a set of [**Checks**](#Checks)
|
||||
|
||||
#### 3) CM sequentially processes each Check in the current Run
|
||||
|
||||
A **Check** is a set of:
|
||||
|
||||
* One or more **Rules** that define what conditions should **trigger** this Check
|
||||
* One or more **Actions** that define what the bot should do once the Check is **triggered**
|
||||
* One or more [**Rules**](#Rule) that define what conditions should **trigger** this Check
|
||||
* One or more [**Actions**](#Action) that define what the bot should do once the Check is **triggered**
|
||||
|
||||
#### 3) Each Check is processed, *in order*, until a Check is triggered
|
||||
#### 4) Each Check is processed, *in order*, until a Check is **triggered**
|
||||
|
||||
Once a Check is **triggered** no more Checks will be processed. This means all subsequent Checks in your configuration (in the order you listed them) are basically skipped.
|
||||
In CM's default configuration, once a Check is **triggered** no more Checks will be processed. This means all subsequent Checks in this Run (in the order you listed them) are skipped.
|
||||
|
||||
#### 4) All Actions from that Check are executed
|
||||
#### 5) All Actions from the triggered Check are executed
|
||||
|
||||
After all Actions are executed CM returns to waiting for the next Event.
|
||||
After all **Actions** from the triggered **Check** are executed CM begins processing the next **Run**
|
||||
|
||||
#### 6) Rinse and Repeat from #3
|
||||
|
||||
Until all Runs have been processed.
|
||||
|
||||
## Concepts
|
||||
|
||||
Core, high-level concepts regarding how CM works.
|
||||
|
||||
### Event
|
||||
|
||||
An **Event** refers to the [Activity](#activity) (Comment or Submission) CM receives to process as well as the results of processing that Activity.
|
||||
|
||||
### Activity
|
||||
|
||||
An Activity is a Comment or Submission from Reddit.
|
||||
|
||||
### Runs
|
||||
|
||||
A **Run** is made up of a set of **Checks** that represent a group of related behaviors the bot should check for or perform -- that are independent of any other behaviors the Bot should perform.
|
||||
|
||||
An example of Runs:
|
||||
|
||||
* A group of Checks that look for missing flairs on a user or a new submission and flair accordingly
|
||||
* A group of Checks that detect spam or self-promotion and then remove those activities
|
||||
|
||||
Both group of Checks are independent of each other (don't have any patterns or actions in common).
|
||||
|
||||
[Full Documentation for Runs](/docs/subreddit/components/README.md#runs)
|
||||
|
||||
### Checks
|
||||
|
||||
A **Check** is the main logical unit of behavior for the bot. It is equivalent to "if X then Y". A Check is comprised of:
|
||||
A **Check** is the main logical unit of behavior for the bot. It is equivalent to "if X then Y". A Check is composed of:
|
||||
|
||||
* One or more **Rules** that are tested against an **Activity**
|
||||
* One of more **Actions** that are performed when the **Rules** are satisfied
|
||||
|
||||
The bot's configuration can be made up of one or more **Checks** that are processed **in the order they are listed in the configuration.**
|
||||
A Run can be made up of one or more **Checks** that are processed **in the order they are listed in the Run.**
|
||||
|
||||
Once a Check is **triggered** (its Rules are satisfied and Actions performed) all subsequent Checks are skipped.
|
||||
|
||||
Some other important concepts regarding Checks:
|
||||
|
||||
* All Checks have a **kind** (defined in the configuration) that determine if they should run on **Submissions** or **Comments**
|
||||
* Checks have a **condition** property that determines when they are considered **triggered**
|
||||
* If the **condition** is `AND` then ALL of their **Rules** must be **triggered** for the Check to be **triggered**
|
||||
* If the **condition** is `OR` then if ANY **Rules** is triggered **triggered** then the Check is **triggered**
|
||||
|
||||
Examples of different types of Checks can be found in the [subreddit-ready examples.](/docs/examples/subredditReady)
|
||||
[Full Documentation for Checks](/docs/subreddit/components/README.md#checks)
|
||||
|
||||
### Rule
|
||||
|
||||
A **Rule** is some set of **criteria** (conditions) that are tested against an Activity (comment/submission), a User, or a User's history. A Rule is considered **triggered** when the **criteria** for that rule are found to be **true** for whatever is being tested against.
|
||||
|
||||
There are generally three main properties for a Rule:
|
||||
|
||||
* **Critiera** -- The conditions/values you want to test for.
|
||||
* **Activities Window** -- If applicable, the range of activities that the **criteria** will be tested against.
|
||||
* **Rule-specific options** -- Any number of options that modify how the **criteria** are tested.
|
||||
|
||||
CM has different **Rules** that can test against different types of behavior and aspects of a User, their history, and the Activity (submission/common) being checked.
|
||||
|
||||
#### Available Rules
|
||||
Find detailed descriptions of all the Rules, with examples, below:
|
||||
[Full Documentation for Rules](/docs/subreddit/components/README.md#rules)
|
||||
|
||||
* [Attribution](/docs/examples/attribution)
|
||||
* [Recent Activity](/docs/examples/recentActivity)
|
||||
* [Repeat Activity](/docs/examples/repeatActivity)
|
||||
* [History](/docs/examples/history)
|
||||
* [Author](/docs/examples/author)
|
||||
* [Regex](/docs/examples/regex)
|
||||
* [Repost](/docs/examples/repost)
|
||||
#### Available Rules
|
||||
|
||||
All available rules can be found in the [components documentation](/docs/subreddit/components/README.md#rules)
|
||||
|
||||
### Rule Set
|
||||
|
||||
@@ -112,34 +127,7 @@ Rule Sets can be used interchangeably with other **Rules** and **Rule Sets** in
|
||||
|
||||
They allow you to create more complex trigger behavior by combining multiple rules into one "parent rule".
|
||||
|
||||
It consists of:
|
||||
|
||||
* **condition** -- Under what condition should the Rule Set be considered triggered?
|
||||
* `AND` -- ALL Rules in the Rule Set must **trigger** in order for the Rule Set to **trigger.**
|
||||
* `OR` -- ANY Rule in the Rule Set that is **triggered** will trigger the whole Rule Set.
|
||||
* **rules** -- The **Rules** for the Rule Set.
|
||||
|
||||
Example
|
||||
|
||||
YAML
|
||||
```yaml
|
||||
condition: AND
|
||||
# rules are an array
|
||||
rules:
|
||||
- aRule
|
||||
```
|
||||
JSON
|
||||
```json5
|
||||
{
|
||||
"condition": "AND",
|
||||
"rules": [
|
||||
// all the rules go here
|
||||
]
|
||||
}
|
||||
```
|
||||
#### Rule Set Examples
|
||||
|
||||
* [**Detailed Example**](/docs/examples/advancedConcepts/ruleSets.json5)
|
||||
[Rule Sets Documentation](/docs/subreddit/components/README.md#rule-sets)
|
||||
|
||||
### Action
|
||||
|
||||
@@ -147,207 +135,28 @@ An **Action** is some action the bot can take against the checked Activity (comm
|
||||
|
||||
#### Available Actions
|
||||
|
||||
* Remove (Comment/Submission)
|
||||
* Flair (Submission)
|
||||
* Ban (User)
|
||||
* Approve (Comment/Submission)
|
||||
* Comment (Reply to Comment/Submission)
|
||||
* Lock (Comment/Submission)
|
||||
* Report (Comment/Submission)
|
||||
* [UserNote](/docs/examples/userNotes) (User, when /r/Toolbox is used)
|
||||
|
||||
For detailed explanation and options of what individual Actions can do [see the links in the `actions` property in the schema.](https://json-schema.app/view/%23/%23%2Fdefinitions%2FSubmissionCheckJson?url=https%3A%2F%2Fraw.githubusercontent.com%2FFoxxMD%2Fcontext-mod%2Fmaster%2Fsrc%2FSchema%2FApp.json)
|
||||
[Available Actions Documentation](/docs/subreddit/components/README.md#list-of-actions)
|
||||
|
||||
### Filters
|
||||
|
||||
**Checks, Rules, and Actions** all have two additional (optional) criteria "tests". These tests behave differently than rule/check triggers in that:
|
||||
**Runs, Checks, Rules, and Actions** all have two additional (optional) criteria "pre-tests". These tests are different from rules/checks in these ways:
|
||||
|
||||
* When they **pass** the thing being tested continues to process as usual
|
||||
* When they **fail** the thing being tested **is skipped, not failed.**
|
||||
* Filters test against the **current state** of the Activity, the Author of the Activity, or the Subreddit of the Activity -- rather than looking at history/context/etc...
|
||||
* Filter test results only determine if the Run, Check, Rule, or Action **should run** -- rather than triggering it
|
||||
* When the filter test **passes** the thing being tested continues to process as usual
|
||||
* When the filter test **fails** the thing being tested **fails**.
|
||||
|
||||
For **Checks** and **Actions** skipping means that the thing is not processed. The Action is not run, the Check is not triggered.
|
||||
|
||||
In the context of **Rules** (in a Check) skipping means the Rule does not get run BUT it does not fail. The Check will continue processing as if the Rule did not exist. However, if ALL Rules in a Check are skipped then the Check does "fail" (is not triggered).
|
||||
|
||||
#### Available Filters
|
||||
|
||||
##### Item Filter (`itemIs`)
|
||||
|
||||
This filter will test against the **state of the Activity currently being run.** Some criteria available to test against IE "Is the activity...":
|
||||
|
||||
* removed
|
||||
* nsfw
|
||||
* locked
|
||||
* stickied
|
||||
* deleted
|
||||
* etc...
|
||||
|
||||
The `itemIs` filter is made up of an array (list) of `State` criteria objects. **All** criteria in the array must pass for this filter to pass.
|
||||
|
||||
There are two different State criteria depending on what type of Activity is being tested:
|
||||
|
||||
* Submission -- [SubmissionState](https://json-schema.app/view/%23/%23%2Fdefinitions%2FSubmissionCheckJson/%23%2Fdefinitions%2FSubmissionState?url=https%3A%2F%2Fraw.githubusercontent.com%2FFoxxMD%2Fcontext-mod%2Fmaster%2Fsrc%2FSchema%2FApp.json)
|
||||
* Comment -- [CommentState](https://json-schema.app/view/%23/%23%2Fdefinitions%2FCommentCheckJson/%23%2Fdefinitions%2FCommentState?url=https%3A%2F%2Fraw.githubusercontent.com%2FFoxxMD%2Fcontext-mod%2Fmaster%2Fsrc%2FSchema%2FApp.json)
|
||||
|
||||
##### Author Filter (`authorIs`)
|
||||
|
||||
This filter will test against the **Author of the Activity currently being run.** Some criteria available to test against:
|
||||
|
||||
* account age
|
||||
* comment, link, and total karma
|
||||
* subreddit flair text/css
|
||||
* name
|
||||
* User Notes
|
||||
* verified
|
||||
* etc...
|
||||
|
||||
The `authorIs` filter is made up two (optional) lists of [`AuthorCriteria`](https://json-schema.app/view/%23/%23%2Fdefinitions%2FSubmissionCheckJson/%23%2Fdefinitions%2FAuthorOptions/%23%2Fdefinitions%2FAuthorCriteria?url=https%3A%2F%2Fraw.githubusercontent.com%2FFoxxMD%2Fcontext-mod%2Fmaster%2Fsrc%2FSchema%2FApp.json) criteria objects that define how the test behaves:
|
||||
|
||||
* `include` list -- If **any** `AuthorCriteria` from this list passes then the `authorIs` test passes
|
||||
* `exclude` list -- If **any** `AuthorCriteria` from this list **does not pass** then the `authorIs` test passes. **Note:** This property is ignored if `include` is also present IE you cannot use both properties at the same time.
|
||||
|
||||
Refer to the [app schema for `AuthorCriteria`](https://json-schema.app/view/%23/%23%2Fdefinitions%2FSubmissionCheckJson/%23%2Fdefinitions%2FAuthorOptions/%23%2Fdefinitions%2FAuthorCriteria?url=https%3A%2F%2Fraw.githubusercontent.com%2FFoxxMD%2Fcontext-mod%2Fmaster%2Fsrc%2FSchema%2FApp.json) for all available properties to test against.
|
||||
|
||||
Some examples of using `authorIs` can be found in the [Author examples.](/docs/examples/author)
|
||||
[Full Documentation for Filters](/docs/subreddit/components/README.md#filters)
|
||||
|
||||
## Configuration And Usage
|
||||
|
||||
* For **Operator/Bot maintainers** see **[Operation Configuration](/docs/operatorConfiguration.md)**
|
||||
* [CLI Usage](docs/operatorConfiguration.md#cli-usage)
|
||||
* For **Operator/Bot maintainers** see **[Operation Guide](/docs/operator/README.md)**
|
||||
* For **Moderators**
|
||||
* Refer to the [examples folder](/docs/examples) or the [subreddit-ready examples](/docs/examples/subredditReady)
|
||||
* as well as the [schema editor](https://json-schema.app/view/%23?url=https%3A%2F%2Fraw.githubusercontent.com%2FFoxxMD%2Fcontext-mod%2Fmaster%2Fsrc%2FSchema%2FApp.json) which has
|
||||
* Start with the [Subreddit/Moderator docs](/docs/subreddit/README.md) or [Moderator Getting Started guide](/docs/subreddit/gettingStarted.md)
|
||||
* Refer to the [Subreddit Components Documentation](/docs/subreddit/components) or the [subreddit-ready examples](/docs/subreddit/components/subredditReady)
|
||||
* as well as the [schema](https://json-schema.app/view/%23?url=https%3A%2F%2Fraw.githubusercontent.com%2FFoxxMD%2Fcontext-mod%2Fmaster%2Fsrc%2FSchema%2FApp.json) which has
|
||||
* fully annotated configuration data/structure
|
||||
* generated examples in json/yaml
|
||||
* built-in editor that automatically validates your config
|
||||
|
||||
## Common Resources
|
||||
|
||||
Technical information on recurring, common data/patterns used in CM.
|
||||
|
||||
### Activities `window`
|
||||
|
||||
Most **Rules** must define the **range of Activities (submissions and/or comments)** that will be used to check the criteria of the Rule. This range is defined wherever you see a `window` property in configuration.
|
||||
|
||||
Refer to the [Activities Window](/docs/activitiesWindow.md) documentation for a technical explanation with examples.
|
||||
|
||||
### Thresholds and Comparisons
|
||||
|
||||
Most rules/filters have criteria that require you to define a specific condition to test against. This can be anything from repeats of activities to account age.
|
||||
|
||||
In all of these scenarios the condition is defined using a subset of [comparison operators](https://www.codecademy.com/articles/fwd-js-comparison-logical) (very similar to how automoderator does things).
|
||||
|
||||
Available operators:
|
||||
|
||||
* `<` -- **less than** => `5 < 6` => 5 is less than 6
|
||||
* `>` -- **greater than** => `6 > 5` => 6 is greater than 5
|
||||
* `<=` -- **less than or equal to** => `5 <= 5` => 5 is less than **or equal to** 5
|
||||
* `>=` -- **greater than or equal to** => `5 >= 5` => 5 is greater than **or equal to** 5
|
||||
|
||||
In the context of a rule/filter comparison you provide the comparison **omitting** the value that is being tested. An example...
|
||||
|
||||
The RepeatActivity rule has a `threshold` comparison to test against the number of repeat activities it finds
|
||||
|
||||
* You want the rule to trigger if it finds **4 or more repeat activities**
|
||||
* The rule would be configured like this `"threshold": ">= 4"`
|
||||
|
||||
Essentially what this is telling the rule is `threshold: "x >= 4"` where `x` is the largest repeat of activities it finds.
|
||||
|
||||
#### Other Comparison Types
|
||||
|
||||
Other than comparison numeric values there are two other values that can be compared (depending on the criteria)
|
||||
|
||||
##### Percentages
|
||||
|
||||
Some criteria accept an optional **percentage** to compare against:
|
||||
|
||||
```
|
||||
"threshold": "> 20%"
|
||||
```
|
||||
|
||||
Refer to the individual rule/criteria schema to see what this percentage is comparing against.
|
||||
|
||||
##### Durations
|
||||
|
||||
Some criteria accept an optional **duration** to compare against:
|
||||
|
||||
```
|
||||
"threshold": "< 1 month"
|
||||
```
|
||||
|
||||
The duration value compares a time range from **now** to `duration value` time in the past.
|
||||
|
||||
Refer to [duration values in activity window documentation](/docs/activitiesWindow.md#duration-values) as well as the individual rule/criteria schema to see what this duration is comparing against.
|
||||
|
||||
### Image Comparisons
|
||||
|
||||
ContextMod implements two methods for comparing **image content**, perceptual hashing and pixel-to-pixel comparisons. Comparisons can be used to filter activities in some activities.
|
||||
|
||||
See [image comparison documentation](/docs/imageComparison.md) for a full reference.
|
||||
|
||||
## Best Practices
|
||||
|
||||
### Named Rules
|
||||
|
||||
All **Rules** in a subreddit's configuration can be assigned a **name** that can then be referenced from any other Check.
|
||||
|
||||
Create general-use rules so they can be reused and de-clutter your configuration. Additionally, CM will automatically cache the result of a rule so there is a performance and api usage benefit to re-using Rules.
|
||||
|
||||
See [ruleNameReuse.json5](/docs/examples/advancedConcepts/ruleNameReuse.json5) for a detailed configuration with annotations.
|
||||
|
||||
### Check Order
|
||||
|
||||
Checks are run in the order they appear in your configuration, therefore you should place your highest requirement/severe action checks at the top and lowest requirement/moderate actions at the bottom.
|
||||
|
||||
This is so that if an Activity warrants a more serious reaction that Check is triggered first rather than having a lower requirement check with less severe actions triggered and causing all subsequent Checks to be skipped.
|
||||
|
||||
* Attribution >50% AND Repeat Activity 8x AND Recent Activity in 2 subs => remove submission + ban
|
||||
* Attribution >20% AND Repeat Activity 4x AND Recent Activity in 5 subs => remove submission + flair user restricted
|
||||
* Attribution >20% AND Repeat Activity 2x => remove submission
|
||||
* Attribution >20% AND History comments <30% => remove submission
|
||||
* Attribution >15% => report
|
||||
* Repeat Activity 2x => report
|
||||
* Recent Activity in 3 subs => report
|
||||
* Author not vetted => flair new user submission
|
||||
|
||||
### Rule Order
|
||||
|
||||
The ordering of your Rules within a Check/RuleSet can have an impact on Check performance (speed) as well as API usage.
|
||||
|
||||
Consider these three rules:
|
||||
|
||||
* Rule A -- Recent Activity => 3 subreddits => last 15 submissions
|
||||
* Rule B -- Repeat Activity => last 3 days
|
||||
* Rule C -- Attribution => >10% => last 90 days or 300 submissions
|
||||
|
||||
The first two rules are lightweight in their requirements -- Rule A can be completed in 1 API call, Rule B potentially completed in 1 Api call.
|
||||
|
||||
However, depending on how active the Author is, Rule C will take *at least* 3 API calls just to get all activities (Reddit limit 100 items per call).
|
||||
|
||||
If the Check is using `AND` condition for its rules (default) then if either Rule A or Rule B fail then Rule C will never run. This means 3 API calls never made plus the time waiting for each to return.
|
||||
|
||||
**It is therefore advantageous to list your lightweight Rules first in each Check.**
|
||||
|
||||
### Caching
|
||||
|
||||
ContextMod implements caching functionality for:
|
||||
|
||||
* author history (`window` criteria in rules)
|
||||
* `authorIs` results
|
||||
* `content` that uses wiki pages (on Comment/Report/Ban Actions)
|
||||
* and User Notes
|
||||
|
||||
All of these use api requests so caching them reduces api usage.
|
||||
|
||||
Cached results can be re-used if the criteria in configuration is identical to a previously cached result. So...
|
||||
|
||||
* author history cache results are re-used if **`window` criteria on a Rule is identical to the `window` on another Rule** IE always use **7 Days** or always use **50 Items** for absolute counts.
|
||||
* `authorIs` criteria is identical to another `authorIs` elsewhere in configuration..
|
||||
* etc...
|
||||
|
||||
Re-use will result in less API calls and faster Check times.
|
||||
|
||||
PROTIP: You can monitor the re-use of cache in the `Cache` section of your subreddit on the web interface. See the tooltips in that section for a better breakdown of cache statistics.
|
||||
|
||||
## FAQ
|
||||
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
Actions that can submit text (Report, Comment) will have their `content` values run through a [Mustache Template](https://mustache.github.io/). This means you can insert data generated by Rules into your text before the Action is performed.
|
||||
|
||||
See here for a [cheatsheet](https://gist.github.com/FoxxMD/d365707cf99fdb526a504b8b833a5b78) and [here](https://www.tsmean.com/articles/mustache/the-ultimate-mustache-tutorial/) for a more thorough tutorial.
|
||||
|
||||
All Actions with `content` have access to this data:
|
||||
|
||||
```json5
|
||||
|
||||
{
|
||||
item: {
|
||||
kind: 'string', // the type of item (comment/submission)
|
||||
author: 'string', // name of the item author (reddit user)
|
||||
permalink: 'string', // a url to the item
|
||||
url: 'string', // if the item is a Submission then its URL (external for link type submission, reddit link for self-posts)
|
||||
title: 'string', // if the item is a Submission, then the title of the Submission,
|
||||
botLink: 'string' // a link to the bot's FAQ
|
||||
},
|
||||
rules: {
|
||||
// contains all rules that were run and are accessible using the name, lowercased, with all spaces/dashes/underscores removed
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
The properties of `rules` are accessible using the name, lower-cased, with all spaces/dashes/underscores. If no name is given `kind` is used as `name` Example:
|
||||
|
||||
```
|
||||
|
||||
"rules": [
|
||||
{
|
||||
"name": "My Custom-Recent Activity Rule", // mycustomrecentactivityrule
|
||||
"kind": "recentActivity"
|
||||
},
|
||||
{
|
||||
// name = repeatsubmission
|
||||
"kind": "repeatActivity",
|
||||
}
|
||||
]
|
||||
|
||||
```
|
||||
|
||||
**To see what data is available for individual Rules [consult the schema](#configuration) for each Rule.**
|
||||
|
||||
#### Quick Templating Tutorial
|
||||
|
||||
As a quick example for how you will most likely be using templating -- wrapping a variable in curly brackets, `{{variable}}`, will cause the variable value to be rendered instead of the brackets:
|
||||
|
||||
```
|
||||
|
||||
myVariable = 50;
|
||||
myOtherVariable = "a text fragment"
|
||||
template = "This is my template, the variable is {{myVariable}}, my other variable is {{myOtherVariable}}, and that's it!";
|
||||
|
||||
console.log(Mustache.render(template, {myVariable});
|
||||
// will render...
|
||||
"This is my template, the variable is 50, my other variable is a text fragment, and that's it!";
|
||||
|
||||
```
|
||||
|
||||
**Note: When accessing an object or its properties you must use dot notation**
|
||||
|
||||
```
|
||||
|
||||
const item = {
|
||||
aProperty: 'something',
|
||||
anotherObject: {
|
||||
bProperty: 'something else'
|
||||
}
|
||||
}
|
||||
const content = "My content will render the property {{item.aProperty}} like this, and another nested property {{item.anotherObject.bProperty}} like this."
|
||||
|
||||
```
|
||||
@@ -1,304 +0,0 @@
|
||||
# Activity Window
|
||||
|
||||
Most **Rules** have a `window` property somewhere within their configuration. This property defines the range of **Activities** (submission and/or comments) that should be retrieved for checking the criteria of the Rule.
|
||||
|
||||
As an example if you want to run an **Recent Activity Rule** to check if a user has had activity in /r/mealtimevideos you also need to define what range of activities you want to look at from that user's history.
|
||||
|
||||
## `window` property overview (tldr)
|
||||
|
||||
The value of `window` can be any of these types:
|
||||
|
||||
* `number` count of activities
|
||||
* `string` [duration](#duration-string-recommended) or [iso 8601](#an-iso-8601-duration-string)
|
||||
* [duration `object`](#duration-object)
|
||||
* [ActivityWindowCriteria `object`](#activitywindowcriteria)
|
||||
|
||||
Examples of all of the above
|
||||
|
||||
<details>
|
||||
|
||||
```yaml
|
||||
# count, last 100 activities
|
||||
window: 100
|
||||
|
||||
# duration, last 10 days
|
||||
window: 10 days
|
||||
|
||||
# duration object, last 2 months and 5 days
|
||||
window:
|
||||
months: 2
|
||||
days: 5
|
||||
|
||||
# iso 8601 string, last 15 minutes
|
||||
window: PT15M
|
||||
|
||||
# ActivityWindowCriteria, last 100 activities or 6 weeks of activities (whichever is found first)
|
||||
window:
|
||||
count: 100
|
||||
duration: 6 weeks
|
||||
```
|
||||
|
||||
```json5
|
||||
// count, last 100 activities
|
||||
{
|
||||
"window": 100
|
||||
}
|
||||
|
||||
// duration string, last 10 days
|
||||
{
|
||||
"window": "10 days"
|
||||
}
|
||||
|
||||
// duration object, last 2 months and 5 days
|
||||
{
|
||||
"window": {
|
||||
"months": 2,
|
||||
"days": 5,
|
||||
}
|
||||
}
|
||||
|
||||
// iso 8601 string, last 15 minutes
|
||||
{
|
||||
"window": "PT15M"
|
||||
}
|
||||
|
||||
// ActivityWindowCriteria, last 100 activities or 6 weeks of activities (whichever is found first)
|
||||
{
|
||||
"window": {
|
||||
"count": 100,
|
||||
"duration": "6 weeks"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
## Types of Ranges
|
||||
|
||||
There are two types of values that can be used when defining a range:
|
||||
|
||||
### Count
|
||||
|
||||
This is the **number** of activities you want to retrieve. It's straightforward -- if you want to look at the last 100 activities for a user you can use `100` as the value.
|
||||
|
||||
### Duration
|
||||
|
||||
A **duration of time** between which all activities will be retrieved. This is a **relative value** that calculates the actual range based on **the duration of time subtracted from when the rule is run.**
|
||||
|
||||
For example:
|
||||
|
||||
* Today is **July 15th**
|
||||
* You define a duration of **10 days**
|
||||
|
||||
Then the range of activities to be retrieved will be between **July 5th and July 15th** (10 days).
|
||||
|
||||
#### Duration Values
|
||||
|
||||
The value used to define the duration can be **any of these three types**:
|
||||
|
||||
##### Duration String (recommended)
|
||||
|
||||
A string consisting of
|
||||
|
||||
* A [Dayjs unit of time](https://day.js.org/docs/en/durations/creating#list-of-all-available-units)
|
||||
* The value of that unit of time
|
||||
|
||||
Examples:
|
||||
|
||||
* `9 days`
|
||||
* `14 hours`
|
||||
* `80 seconds`
|
||||
|
||||
You can ensure your string is valid by testing it [here.](https://regexr.com/61em3)
|
||||
|
||||
##### Duration Object
|
||||
|
||||
If you need to specify multiple units of time for your duration you can instead provide a [Dayjs duration **object**](https://day.js.org/docs/en/durations/creating#list-of-all-available-units) consisting of Dayjs unit-values.
|
||||
|
||||
Example
|
||||
|
||||
JSON
|
||||
```json
|
||||
{
|
||||
"days": 4,
|
||||
"hours": 6,
|
||||
"minutes": 20
|
||||
}
|
||||
```
|
||||
YAML
|
||||
```yaml
|
||||
window:
|
||||
days: 4
|
||||
hours: 6
|
||||
minutes: 20
|
||||
```
|
||||
|
||||
##### An ISO 8601 duration string
|
||||
|
||||
If you're a real nerd you can also use a [standard duration](https://en.wikipedia.org/wiki/ISO_8601#Durations)) string.
|
||||
|
||||
Examples
|
||||
|
||||
* `PT15M` (15 minutes)
|
||||
|
||||
Ensure your string is valid by testing it [here.](https://regexr.com/61em9)
|
||||
|
||||
## ActivityWindowCriteria
|
||||
|
||||
This is an object that lets you specify more granular conditions for your range.
|
||||
|
||||
The full object looks like this:
|
||||
|
||||
JSON
|
||||
```json
|
||||
{
|
||||
"count": 100,
|
||||
"duration": "10 days",
|
||||
"satisfyOn": "any",
|
||||
"subreddits": {
|
||||
"include": ["mealtimevideos","pooptimevideos"],
|
||||
"exclude": ["videos"]
|
||||
}
|
||||
}
|
||||
```
|
||||
YAML
|
||||
```yaml
|
||||
window:
|
||||
count: 100
|
||||
duration: 10 days
|
||||
satisfyOn: any
|
||||
subreddits:
|
||||
include:
|
||||
- mealtimevideos
|
||||
- pooptimevideos
|
||||
exclude:
|
||||
- videos
|
||||
```
|
||||
|
||||
### Specifying Range
|
||||
|
||||
You may use **one or both range properties.**
|
||||
|
||||
If both range properties are specified then the value `satisfyOn` determines how the final range is determined
|
||||
|
||||
|
||||
#### Using `"satisfyOn": "any"` (default)
|
||||
|
||||
If **any** then Activities will be retrieved until one of the range properties is met, **whichever occurs first.**
|
||||
|
||||
Example
|
||||
|
||||
JSON
|
||||
```json
|
||||
{
|
||||
"count": 80,
|
||||
"duration": "90 days",
|
||||
"satisfyOn": "any"
|
||||
}
|
||||
```
|
||||
YAML
|
||||
```yaml
|
||||
window:
|
||||
count: 80
|
||||
duration: 90 days
|
||||
satisfyOn: any
|
||||
```
|
||||
Activities are retrieved in chunks of 100 (or `count`, whichever is smaller)
|
||||
|
||||
* If 90 days of activities returns only 40 activities => returns 40 activities
|
||||
* If 80 activities is only 20 days of range => 80 activities
|
||||
|
||||
#### Using `"satisfyOn": "all"`
|
||||
|
||||
If **all** then both ranges must be satisfied. Effectively, whichever range produces the most Activities will be the one that is used.
|
||||
|
||||
Example
|
||||
|
||||
JSON
|
||||
```json
|
||||
{
|
||||
"count": 100,
|
||||
"duration": "90 days",
|
||||
"satisfyOn": "all"
|
||||
}
|
||||
```
|
||||
YAML
|
||||
```yaml
|
||||
window:
|
||||
count: 100
|
||||
duration: 90 days
|
||||
satisfyOn: all
|
||||
```
|
||||
Activities are retrieved in chunks of 100 (or `count`, whichever is smaller)
|
||||
|
||||
* If at 90 days of activities => 40 activities retrieved
|
||||
* continue retrieving results until 100 activities
|
||||
* so range is >90 days of activities
|
||||
* If at 100 activities => 20 days of activities retrieved
|
||||
* continue retrieving results until 90 days of range
|
||||
* so results in >100 activities
|
||||
|
||||
### Filtering Activities
|
||||
|
||||
You may filter retrieved Activities using an array of subreddits.
|
||||
|
||||
**Note:** Activities are filtered **before** range check is made so you will always end up with specified range (but may require more api calls if many activities are filtered out)
|
||||
|
||||
#### Include
|
||||
|
||||
Use **include** to specify which subreddits should be included from results
|
||||
|
||||
Example where only activities from /r/mealtimevideos and /r/modsupport will be returned
|
||||
|
||||
JSON
|
||||
```json
|
||||
{
|
||||
"count": 100,
|
||||
"duration": "90 days",
|
||||
"satisfyOn": "any",
|
||||
"subreddits": {
|
||||
"include": ["mealtimevideos","modsupport"]
|
||||
}
|
||||
}
|
||||
```
|
||||
YAML
|
||||
```yaml
|
||||
window:
|
||||
count: 100
|
||||
duruation: 90 days
|
||||
satisfyOn: any
|
||||
subreddits:
|
||||
include:
|
||||
- mealtimevideos
|
||||
- modsupport
|
||||
```
|
||||
|
||||
#### Exclude
|
||||
|
||||
Use **exclude** to specify which subreddits should NOT be in the results
|
||||
|
||||
Example where activities from /r/mealtimevideos and /r/modsupport will not be returned in results
|
||||
|
||||
JSON
|
||||
```json
|
||||
{
|
||||
"count": 100,
|
||||
"duration": "90 days",
|
||||
"satisfyOn": "any",
|
||||
"subreddits": {
|
||||
"exclude": ["mealtimevideos","modsupport"]
|
||||
}
|
||||
}
|
||||
```
|
||||
YAML
|
||||
```yaml
|
||||
window:
|
||||
count: 100
|
||||
duruation: 90 days
|
||||
satisfyOn: any
|
||||
subreddits:
|
||||
exclude:
|
||||
- mealtimevideos
|
||||
- modsupport
|
||||
```
|
||||
**Note:** `exclude` will be ignored if `include` is also present.
|
||||
@@ -1,109 +0,0 @@
|
||||
**Note:** This is for **bot operators.** If you are a subreddit moderator check out the **[Getting Started Guide](/docs/gettingStartedMod.md)**
|
||||
|
||||
Before you can start using your bot on reddit there are a few steps you must take:
|
||||
|
||||
* Create your bot account IE the reddit account that will be the "bot"
|
||||
* Create a Reddit application
|
||||
* Authenticate your bot account with the application
|
||||
|
||||
At the end of this process you will have this info:
|
||||
|
||||
* clientId
|
||||
* clientSecret
|
||||
* refreshToken
|
||||
* accessToken
|
||||
* redirectUri
|
||||
|
||||
**Note:** If you already have this information you can skip this guide **but make sure your redirect uri is correct if you plan on using the web interface.**
|
||||
|
||||
# Table Of Contents
|
||||
|
||||
* [Creating an Application](#create-application)
|
||||
* [Authenticate Your Bot](#authenticate-your-bot-account)
|
||||
* [Using CM OAuth Helper](#cm-oauth-helper-recommended)
|
||||
* [Using Aardvark OAuth Helper](#aardvark-oauth-helper)
|
||||
* [Provide Credentials to CM](#provide-credentials-to-cm)
|
||||
|
||||
# Create Application
|
||||
|
||||
Visit [your reddit preferences](https://www.reddit.com/prefs/apps) and at the bottom of the page go through the **create an(other) app** process.
|
||||
* Give it a **name**
|
||||
* Choose **web app**
|
||||
* If you know what you will use for **redirect uri** go ahead and use it, otherwise use **http://localhost:8085/callback**
|
||||
|
||||
Click **create app**.
|
||||
|
||||
Then write down your **Client ID, Client Secret, and Redirect Uri** somewhere (or keep this webpage open)
|
||||
|
||||
# Authenticate Your Bot Account
|
||||
|
||||
There are **two ways** you can authenticate your bot account. It is recommended to use the CM oauth helper.
|
||||
|
||||
## CM OAuth Helper (Recommended)
|
||||
|
||||
This method will use CM's built in oauth flow. It is recommended because it will ensure your bot is authenticated with the correct oauth permissions.
|
||||
|
||||
### Start CM with Client ID/Secret and Operator
|
||||
|
||||
Start the application and provide these to your configuration:
|
||||
|
||||
* **Client ID**
|
||||
* **Client Secret**
|
||||
* **Redirect URI**
|
||||
* **Operator**
|
||||
|
||||
It is important you define **Operator** because the auth route is **protected.** You must login to the application in order to access the route.
|
||||
|
||||
Refer to the [operator config guide](/docs/operatorConfiguration.md) if you need help with this.
|
||||
|
||||
Examples:
|
||||
|
||||
* CLI - `node src/index.js --clientId=myId --clientSecret=mySecret --redirectUri="http://localhost:8085/callback" --operator=FoxxMD`
|
||||
* Docker - `docker run -e "CLIENT_ID=myId" -e "CLIENT_SECRET=mySecret" -e "OPERATOR=FoxxMD" -e "REDIRECT_URI=http://localhost:8085/callback" foxxmd/context-mod`
|
||||
|
||||
### Create An Auth Invite
|
||||
|
||||
Then open the CM web interface (default is [http://localhost:8085](http://localhost:8085)) and login.
|
||||
|
||||
After logging in you should be automatically redirected the auth page. If you are not then visit [http://localhost:8085/auth/helper](http://localhost:8085/auth/helper))
|
||||
|
||||
Follow the directions in the helper to create an **auth invite link.** Open this link and then follow the directions to authenticate your bot. At the end of the process you will receive an **Access Token** and **Refresh Token**
|
||||
|
||||
## Aardvark OAuth Helper
|
||||
|
||||
This method should only be used if you cannot use the [CM OAuth Helper method](#cm-oauth-helper-recommended) because you cannot access the CM web interface.
|
||||
|
||||
* Visit [https://not-an-aardvark.github.io/reddit-oauth-helper/](https://not-an-aardvark.github.io/reddit-oauth-helper/) and follow the instructions given.
|
||||
* **Note:** You will need to update your **redirect uri.**
|
||||
* Input your **Client ID** and **Client Secret** in the text boxes with those names.
|
||||
* Choose scopes. **It is very important you check everything on this list or CM may not work correctly**
|
||||
* edit
|
||||
* flair
|
||||
* history
|
||||
* identity
|
||||
* modcontributors
|
||||
* modflair
|
||||
* modposts
|
||||
* modself
|
||||
* mysubreddits
|
||||
* read
|
||||
* report
|
||||
* submit
|
||||
* wikiread
|
||||
* wikiedit (if you are using Toolbox User Notes)
|
||||
* Click **Generate tokens**, you will get a popup asking you to approve access (or login) -- **the account you approve access with is the account that Bot will control.**
|
||||
* After approving an **Access Token** and **Refresh Token** will be shown at the bottom of the page. Save these to use with CM.
|
||||
|
||||
# Provide Credentials to CM
|
||||
|
||||
At the end of the last step you chose you should now have this information saved somewhere:
|
||||
|
||||
* clientId
|
||||
* clientSecret
|
||||
* refreshToken
|
||||
* accessToken
|
||||
* redirectUri
|
||||
|
||||
This is all the information you need to run your bot with CM.
|
||||
|
||||
Using these credentials follow the [operator config guide](/docs/operatorConfiguration.md) to finish setting up your CM instance.
|
||||
392
docs/development.md
Normal file
@@ -0,0 +1,392 @@
|
||||
TODO add more development sections...
|
||||
|
||||
# Developing/Testing Github Actions
|
||||
|
||||
Use [act](https://github.com/nektos/act) to run Github actions locally.
|
||||
|
||||
An example secrets file can be found in the project working directory at [act.env.example](act.env.example)
|
||||
|
||||
Modify [push-hook-sample.json](.github/push-hook-sample.json) to point to the local branch you want to run a `push` event trigger on, then run this command from the project working directory:
|
||||
|
||||
```bash
|
||||
act -e .github/push-hook-sample.json --secret-file act.env
|
||||
```
|
||||
|
||||
# Mocking Reddit API
|
||||
|
||||
Using [MockServer](https://www.mock-server.com/)
|
||||
|
||||
## Installation
|
||||
|
||||
https://www.mock-server.com/mock_server/running_mock_server.html
|
||||
|
||||
Easiest way is to install the [docker container](https://www.mock-server.com/mock_server/running_mock_server.html#pull_docker_image) ([from here](https://hub.docker.com/r/mockserver/mockserver))
|
||||
|
||||
Map port `1080:1080` -- acts as both the proxy port and the UI endpoint with the below URL:
|
||||
|
||||
```
|
||||
http(s)://localhost:1080/mockserver/dashboard
|
||||
```
|
||||
|
||||
In your [operator configuration](/docs/operator/operatorConfiguration.md) define a proxy for snoowrap at the top-level:
|
||||
|
||||
```yaml
|
||||
snoowrap:
|
||||
proxy: 'http://localhost:8010'
|
||||
#debug: true # optionally set debug to true to make snoowrap requests output to log
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
### Forwarding Requests (Monitoring Behavior)
|
||||
|
||||
This is what will make MockServer act as an actual **proxy server**. In this state CM will operate normally. In the MockServer UI you will be able to monitor all requests/responses made.
|
||||
|
||||
```HTTP
|
||||
PUT /mockserver/expectation HTTP/1.1
|
||||
Host: localhost:8010
|
||||
Content-Type: application/json
|
||||
Content-Length: 155
|
||||
|
||||
```
|
||||
|
||||
<details>
|
||||
<summary>CURL</summary>
|
||||
|
||||
```bash
|
||||
curl --location --request PUT 'http://localhost:8010/mockserver/expectation' \
|
||||
--header 'Content-Type: application/json' \
|
||||
--data-raw '{
|
||||
"httpRequest": {},
|
||||
"priority": 0,
|
||||
"httpForward": {
|
||||
"host": "oauth.reddit.com",
|
||||
"port": 443,
|
||||
"scheme": "HTTPS"
|
||||
}
|
||||
}'
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
### Mocking Network Issues
|
||||
|
||||
MockServer is a bit confusing and regex'ing for specific paths don't work well (for me??)
|
||||
|
||||
The lifecycle of a mock call I do:
|
||||
|
||||
* Make sure [forwarding](#forwarding-requests-monitoring-behavior) is set, to begin with
|
||||
* Breakpoint before the code you want to test with mocking
|
||||
* [Mock the network issue](#create-network-issue-behavior)
|
||||
* Once the mock behavior should be "done" then
|
||||
* [Clear all exceptions](#clearing-behavior)
|
||||
* Set [forwarding behavior](#forwarding-requests-monitoring-behavior) again
|
||||
|
||||
### Create Network Issue Behavior
|
||||
|
||||
#### All Responses return 403
|
||||
|
||||
<details>
|
||||
<summary>HTTP</summary>
|
||||
|
||||
```HTTP
|
||||
PUT /mockserver/expectation HTTP/1.1
|
||||
Host: localhost:8010
|
||||
Content-Type: application/json
|
||||
Content-Length: 1757
|
||||
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>CURL</summary>
|
||||
|
||||
```bash
|
||||
curl --location --request PUT 'http://localhost:8010/mockserver/expectation' \
|
||||
--header 'Content-Type: application/json' \
|
||||
--data-raw '{
|
||||
"id": "error",
|
||||
"httpRequest": {
|
||||
"path": ".*"
|
||||
},
|
||||
"priority": 1,
|
||||
"httpResponse": {
|
||||
"statusCode": 403,
|
||||
"reasonPhrase": "Forbidden",
|
||||
"headers": {
|
||||
"Connection": [
|
||||
"keep-alive"
|
||||
],
|
||||
"Content-Type": [
|
||||
"application/json; charset=UTF-8"
|
||||
],
|
||||
"x-ua-compatible": [
|
||||
"IE=edge"
|
||||
],
|
||||
"x-frame-options": [
|
||||
"SAMEORIGIN"
|
||||
],
|
||||
"x-content-type-options": [
|
||||
"nosniff"
|
||||
],
|
||||
"x-xss-protection": [
|
||||
"1; mode=block"
|
||||
],
|
||||
"expires": [
|
||||
"-1"
|
||||
],
|
||||
"cache-control": [
|
||||
"private, s-maxage=0, max-age=0, must-revalidate, no-store, max-age=0, must-revalidate"
|
||||
],
|
||||
"x-ratelimit-remaining": [
|
||||
"575.0"
|
||||
],
|
||||
"x-ratelimit-used": [
|
||||
"25"
|
||||
],
|
||||
"x-ratelimit-reset": [
|
||||
"143"
|
||||
],
|
||||
"X-Moose": [
|
||||
"majestic"
|
||||
],
|
||||
"Accept-Ranges": [
|
||||
"bytes"
|
||||
],
|
||||
"Date": [
|
||||
"Wed, 05 Jan 2022 14:37:37 GMT"
|
||||
],
|
||||
"Via": [
|
||||
"1.1 varnish"
|
||||
],
|
||||
"Vary": [
|
||||
"accept-encoding"
|
||||
],
|
||||
"Strict-Transport-Security": [
|
||||
"max-age=15552000; includeSubDomains; preload"
|
||||
],
|
||||
"Server": [
|
||||
"snooserv"
|
||||
],
|
||||
"X-Clacks-Overhead": [
|
||||
"GNU Terry Pratchett"
|
||||
]
|
||||
}
|
||||
}
|
||||
}'
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
#### All Responses Timeout
|
||||
|
||||
<details>
|
||||
<summary>HTTP</summary>
|
||||
|
||||
```HTTP
|
||||
PUT /mockserver/expectation HTTP/1.1
|
||||
Host: localhost:8010
|
||||
Content-Type: application/json
|
||||
Content-Length: 251
|
||||
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>CURL</summary>
|
||||
|
||||
```bash
|
||||
curl --location --request PUT 'http://localhost:8010/mockserver/expectation' \
|
||||
--header 'Content-Type: application/json' \
|
||||
--data-raw '{
|
||||
"id": "error",
|
||||
"httpRequest": {
|
||||
"path": ".*"
|
||||
},
|
||||
"priority": 1,
|
||||
"httpResponse": {
|
||||
"body": "should never receive this",
|
||||
"delay": {
|
||||
"timeUnit": "SECONDS",
|
||||
"value": 60
|
||||
}
|
||||
}
|
||||
}'
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
#### All Responses Drop After Delay (Connection Closed by Server)
|
||||
|
||||
<details>
|
||||
<summary>HTTP</summary>
|
||||
|
||||
```HTTP
|
||||
PUT /mockserver/expectation HTTP/1.1
|
||||
Host: localhost:8010
|
||||
Content-Type: application/json
|
||||
Content-Length: 234
|
||||
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>CURL</summary>
|
||||
|
||||
```bash
|
||||
curl --location --request PUT 'http://localhost:8010/mockserver/expectation' \
|
||||
--header 'Content-Type: application/json' \
|
||||
--data-raw '{
|
||||
"id": "error",
|
||||
"httpRequest": {
|
||||
"path": ".*"
|
||||
},
|
||||
"priority": 1,
|
||||
"httpError": {
|
||||
"dropConnection": true,
|
||||
"delay": {
|
||||
"timeUnit": "SECONDS",
|
||||
"value": 2
|
||||
}
|
||||
}
|
||||
}'
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
### Clearing Behavior
|
||||
|
||||
|
||||
```HTTP
|
||||
PUT /mockserver/clear?type=EXPECTATIONS HTTP/1.1
|
||||
Host: localhost:8010
|
||||
Content-Type: application/json
|
||||
Content-Length: 26
|
||||
|
||||
```
|
||||
|
||||
<details>
|
||||
<summary>CURL</summary>
|
||||
|
||||
```bash
|
||||
curl --location --request PUT 'http://localhost:8010/mockserver/clear?type=EXPECTATIONS' \
|
||||
--header 'Content-Type: application/json' \
|
||||
--data-raw '{
|
||||
"path": "/.*"
|
||||
}'
|
||||
```
|
||||
|
||||
</details>
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>CURL</summary>
|
||||
|
||||
```bash
|
||||
curl --location --request PUT 'http://localhost:8010/mockserver/expectation' \
|
||||
--header 'Content-Type: application/json' \
|
||||
--data-raw '{
|
||||
"id": "error",
|
||||
"httpRequest": {
|
||||
"path": ".*"
|
||||
},
|
||||
"priority": 1,
|
||||
"httpResponse": {
|
||||
"body": "should never receive this",
|
||||
"delay": {
|
||||
"timeUnit": "SECONDS",
|
||||
"value": 60
|
||||
}
|
||||
}
|
||||
}'
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
#### All Responses Drop After Delay (Connection Closed by Server)
|
||||
|
||||
<details>
|
||||
<summary>HTTP</summary>
|
||||
|
||||
```HTTP
|
||||
PUT /mockserver/expectation HTTP/1.1
|
||||
Host: localhost:8010
|
||||
Content-Type: application/json
|
||||
Content-Length: 234
|
||||
|
||||
{
|
||||
"id": "error",
|
||||
"httpRequest": {
|
||||
"path": ".*"
|
||||
},
|
||||
"priority": 1,
|
||||
"httpError": {
|
||||
"dropConnection": true,
|
||||
"delay": {
|
||||
"timeUnit": "SECONDS",
|
||||
"value": 2
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>CURL</summary>
|
||||
|
||||
```bash
|
||||
curl --location --request PUT 'http://localhost:8010/mockserver/expectation' \
|
||||
--header 'Content-Type: application/json' \
|
||||
--data-raw '{
|
||||
"id": "error",
|
||||
"httpRequest": {
|
||||
"path": ".*"
|
||||
},
|
||||
"priority": 1,
|
||||
"httpError": {
|
||||
"dropConnection": true,
|
||||
"delay": {
|
||||
"timeUnit": "SECONDS",
|
||||
"value": 2
|
||||
}
|
||||
}
|
||||
}'
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
### Clearing Behavior
|
||||
|
||||
|
||||
```HTTP
|
||||
PUT /mockserver/clear?type=EXPECTATIONS HTTP/1.1
|
||||
Host: localhost:8010
|
||||
Content-Type: application/json
|
||||
Content-Length: 26
|
||||
|
||||
{
|
||||
"path": "/user/.*"
|
||||
}
|
||||
```
|
||||
|
||||
<details>
|
||||
<summary>CURL</summary>
|
||||
|
||||
```bash
|
||||
curl --location --request PUT 'http://localhost:8010/mockserver/clear?type=EXPECTATIONS' \
|
||||
--header 'Content-Type: application/json' \
|
||||
--data-raw '{
|
||||
"path": "/.*"
|
||||
}'
|
||||
```
|
||||
|
||||
</details>
|
||||
@@ -1,29 +0,0 @@
|
||||
# Examples
|
||||
|
||||
This directory contains example of valid, ready-to-go configurations for Context Mod for the purpose of:
|
||||
|
||||
* showcasing what the bot can do
|
||||
* providing best practices for writing your configuration
|
||||
* providing generally useful configurations **that can be used immediately** or as a jumping-off point for your configuration
|
||||
|
||||
|
||||
|
||||
### Examples Overview
|
||||
|
||||
* Rules
|
||||
* [Attribution](/docs/examples/attribution)
|
||||
* [Recent Activity](/docs/examples/recentActivity)
|
||||
* [Repeat Activity](/docs/examples/repeatActivity)
|
||||
* [History](/docs/examples/history)
|
||||
* [Author](/docs/examples/author)
|
||||
* [Regex](/docs/examples/regex)
|
||||
* [Repost](/docs/examples/repost)
|
||||
* [Author and post flairs](/docs/examples/onlyfansFlair)
|
||||
* [Toolbox User Notes](/docs/examples/userNotes)
|
||||
* [Advanced Concepts](/docs/examples/advancedConcepts)
|
||||
* [Rule Sets](/docs/examples/advancedConcepts/ruleSets.json5)
|
||||
* [Name Rules](/docs/examples/advancedConcepts/ruleNameReuse.json5)
|
||||
* [Check Ordering](/docs/examples/advancedConcepts)
|
||||
* [Subreddit-ready examples](/docs/examples/subredditReady)
|
||||
|
||||
PROTIP: You can edit/build on examples by using the [schema editor.](https://json-schema.app/view/%23?url=https%3A%2F%2Fraw.githubusercontent.com%2FFoxxMD%2Fcontext-mod%2Fmaster%2Fsrc%2FSchema%2FApp.json)
|
||||
@@ -1,56 +0,0 @@
|
||||
### Named Rules
|
||||
|
||||
See **Rule Name Reuse Examples [YAML](/docs/examples/advancedConcepts/ruleNameReuse.yaml) | [JSON](/docs/examples/advancedConcepts/ruleNameReuse.json5)**
|
||||
|
||||
### Check Order
|
||||
|
||||
Checks are run in the order they appear in your configuration, therefore you should place your highest requirement/severe action checks at the top and lowest requirement/moderate actions at the bottom.
|
||||
|
||||
This is so that if an Activity warrants a more serious reaction that Check is triggered first rather than having a lower requirement check with less severe actions triggered and causing all subsequent Checks to be skipped.
|
||||
|
||||
* Attribution >50% AND Repeat Activity 8x AND Recent Activity in 2 subs => remove submission + ban
|
||||
* Attribution >20% AND Repeat Activity 4x AND Recent Activity in 5 subs => remove submission + flair user restricted
|
||||
* Attribution >20% AND Repeat Activity 2x => remove submission
|
||||
* Attribution >20% AND History comments <30% => remove submission
|
||||
* Attribution >15% => report
|
||||
* Repeat Activity 2x => report
|
||||
* Recent Activity in 3 subs => report
|
||||
* Author not vetted => flair new user submission
|
||||
|
||||
### Rule Sets
|
||||
|
||||
The `rules` array on a `Checks` can contain both `Rule` objects and `RuleSet` objects.
|
||||
|
||||
A **Rule Set** is a "nested" set of `Rule` objects with a passing condition specified. These allow you to create more complex trigger behavior by combining multiple rules.
|
||||
|
||||
See **ruleSets [YAML](/docs/examples/advancedConcepts/ruleSets.yaml) | [JSON](/docs/examples/advancedConcepts/ruleSets.json5)** for a complete example as well as consulting the [schema](https://json-schema.app/view/%23%2Fdefinitions%2FRuleSetJson?url=https%3A%2F%2Fraw.githubusercontent.com%2FFoxxMD%2Fcontext-mod%2Fmaster%2Fsrc%2FSchema%2FApp.json).
|
||||
|
||||
### Rule Order
|
||||
|
||||
The ordering of your Rules within a Check/RuleSet can have an impact on Check performance (speed) as well as API usage.
|
||||
|
||||
Consider these three rules:
|
||||
|
||||
* Rule A -- Recent Activity => 3 subreddits => last 15 submissions
|
||||
* Rule B -- Repeat Activity => last 3 days
|
||||
* Rule C -- Attribution => >10% => last 90 days or 300 submissions
|
||||
|
||||
The first two rules are lightweight in their requirements -- Rule A can be completed in 1 API call, Rule B potentially completed in 1 Api call.
|
||||
|
||||
However, depending on how active the Author is, Rule C will take *at least* 3 API calls just to get all activities (Reddit limit 100 items per call).
|
||||
|
||||
If the Check is using `AND` condition for its rules (default) then if either Rule A or Rule B fail then Rule C will never run. This means 3 API calls never made plus the time waiting for each to return.
|
||||
|
||||
**It is therefore advantageous to list your lightweight Rules first in each Check.**
|
||||
|
||||
### API Caching
|
||||
|
||||
Context Mod implements some basic caching functionality for **Author Activities** and wiki pages (on Comment/Report Actions).
|
||||
|
||||
**Author Activities** are cached for a subreddit-configurable amount of time (10 seconds by default). A cached activities set can be re-used if the **window on a Rule is identical to the window on another Rule**.
|
||||
|
||||
This means that when possible you should re-use window values.
|
||||
|
||||
IE If you want to check an Author's Activities for a time range try to always use **7 Days** or always use **50 Items** for absolute counts.
|
||||
|
||||
Re-use will result in less API calls and faster Check times.
|
||||
@@ -1,75 +0,0 @@
|
||||
{
|
||||
"checks": [
|
||||
{
|
||||
"name": "Auto Remove SP Karma",
|
||||
"description": "Remove submission because author has self-promo >10% and posted in karma subs recently",
|
||||
"kind": "submission",
|
||||
"rules": [
|
||||
// named rules can be referenced at any point in the configuration (where they occur does not matter)
|
||||
// and can be used in any Check
|
||||
// Note: rules do not transfer between subreddit configurations
|
||||
"freekarmasub",
|
||||
{
|
||||
"name": "attr10all",
|
||||
"kind": "attribution",
|
||||
"criteria": [
|
||||
{
|
||||
"threshold": "> 10%",
|
||||
"window": "90 days"
|
||||
},
|
||||
{
|
||||
"threshold": "> 10%",
|
||||
"window": 100
|
||||
}
|
||||
],
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
{
|
||||
"kind": "remove"
|
||||
},
|
||||
{
|
||||
"kind": "comment",
|
||||
"content": "Your submission was removed because you are over reddit's threshold for self-promotion and recently posted this content in a karma sub"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Free Karma On Submission Alert",
|
||||
"description": "Check if author has posted this submission in 'freekarma' subreddits",
|
||||
"kind": "submission",
|
||||
"rules": [
|
||||
{
|
||||
// rules can be re-used throughout a configuration by referencing them by name
|
||||
//
|
||||
// The rule name itself can only contain spaces, hyphens and underscores
|
||||
// The value used to reference it will have all of these removed, and lower-cased
|
||||
//
|
||||
// so to reference this rule use the value 'freekarmasub'
|
||||
"name": "Free_Karma-SUB",
|
||||
"kind": "recentActivity",
|
||||
"lookAt": "submissions",
|
||||
"useSubmissionAsReference":true,
|
||||
"thresholds": [
|
||||
{
|
||||
"threshold": ">= 1",
|
||||
"subreddits": [
|
||||
"DeFreeKarma",
|
||||
"FreeKarma4U",
|
||||
"FreeKarma4You",
|
||||
"upvote"
|
||||
]
|
||||
}
|
||||
],
|
||||
"window": "7 days"
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
{
|
||||
"kind": "report",
|
||||
"content": "Submission posted {{rules.freekarmasub.totalCount}} times in karma {{rules.freekarmasub.subCount}} subs over {{rules.freekarmasub.window}}: {{rules.freekarmasub.subSummary}}"
|
||||
}
|
||||
]
|
||||
},
|
||||
]
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
checks:
|
||||
- name: Auto Remove SP Karma
|
||||
description: >-
|
||||
Remove submission because author has self-promo >10% and posted in karma
|
||||
subs recently
|
||||
kind: submission
|
||||
rules:
|
||||
# named rules can be referenced at any point in the configuration (where they occur does not matter)
|
||||
# and can be used in any Check
|
||||
# Note: rules do not transfer between subreddit configurations
|
||||
- freekarmasub
|
||||
- name: attr10all
|
||||
kind: attribution
|
||||
criteria:
|
||||
- threshold: '> 10%'
|
||||
window: 90 days
|
||||
- threshold: '> 10%'
|
||||
window: 100
|
||||
actions:
|
||||
- kind: remove
|
||||
- kind: comment
|
||||
content: >-
|
||||
Your submission was removed because you are over reddit's threshold
|
||||
for self-promotion and recently posted this content in a karma sub
|
||||
- name: Free Karma On Submission Alert
|
||||
description: Check if author has posted this submission in 'freekarma' subreddits
|
||||
kind: submission
|
||||
rules:
|
||||
# rules can be re-used throughout a configuration by referencing them by name
|
||||
#
|
||||
# The rule name itself can only contain spaces, hyphens and underscores
|
||||
# The value used to reference it will have all of these removed, and lower-cased
|
||||
#
|
||||
# so to reference this rule use the value 'freekarmasub'
|
||||
- name: Free_Karma-SUB
|
||||
kind: recentActivity
|
||||
lookAt: submissions
|
||||
useSubmissionAsReference: true
|
||||
thresholds:
|
||||
- threshold: '>= 1'
|
||||
subreddits:
|
||||
- DeFreeKarma
|
||||
- FreeKarma4U
|
||||
- FreeKarma4You
|
||||
- upvote
|
||||
window: 7 days
|
||||
actions:
|
||||
- kind: report
|
||||
content: >-
|
||||
Submission posted {{rules.freekarmasub.totalCount}} times in karma
|
||||
{{rules.freekarmasub.subCount}} subs over
|
||||
{{rules.freekarmasub.window}}: {{rules.freekarmasub.subSummary}}
|
||||
@@ -1,84 +0,0 @@
|
||||
{
|
||||
"checks": [
|
||||
{
|
||||
"name": "Self Promo All or low comment",
|
||||
"description": "SP >10% of all activities or >10% of submissions with low comment engagement",
|
||||
"kind": "submission",
|
||||
"rules": [
|
||||
{
|
||||
// this attribution rule is looking at all activities
|
||||
//
|
||||
// we want want this one rule to trigger the check because >10% of all activity (submission AND comments) is a good requirement
|
||||
"name": "attr10all",
|
||||
"kind": "attribution",
|
||||
"criteria": [
|
||||
{
|
||||
"threshold": "> 10%",
|
||||
"window": "90 days"
|
||||
},
|
||||
{
|
||||
"threshold": "> 10%",
|
||||
"window": 100
|
||||
}
|
||||
],
|
||||
},
|
||||
{
|
||||
// this is a **Rule Set**
|
||||
//
|
||||
// it is made up of "nested" rules with a pass condition (AND/OR)
|
||||
// if the nested rules pass the condition then the Rule Set triggers the Check
|
||||
//
|
||||
// AND = all nested rules must be triggered to make the Rule Set trigger
|
||||
// AND = any of the nested Rules will be the Rule Set trigger
|
||||
"condition": "AND",
|
||||
// in this check we use an Attribution >10% on ONLY submissions, which is a lower requirement then the above attribution rule
|
||||
// and combine it with a History rule looking for low comment engagement
|
||||
// to make a "higher" requirement Rule Set our of two low requirement Rules
|
||||
"rules": [
|
||||
{
|
||||
"name": "attr20sub",
|
||||
"kind": "attribution",
|
||||
"criteria": [
|
||||
{
|
||||
"threshold": "> 10%",
|
||||
"thresholdOn": "submissions",
|
||||
"window": "90 days"
|
||||
},
|
||||
{
|
||||
"threshold": "> 10%",
|
||||
"thresholdOn": "submissions",
|
||||
"window": 100
|
||||
}
|
||||
],
|
||||
"lookAt": "media"
|
||||
},
|
||||
{
|
||||
"name": "lowOrOpComm",
|
||||
"kind": "history",
|
||||
"criteriaJoin": "OR",
|
||||
"criteria": [
|
||||
{
|
||||
"window": "90 days",
|
||||
"comment": "< 50%"
|
||||
},
|
||||
{
|
||||
"window": "90 days",
|
||||
"comment": "> 40% OP"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
{
|
||||
"kind": "remove"
|
||||
},
|
||||
{
|
||||
"kind": "comment",
|
||||
"content": "Your submission was removed because you are over reddit's threshold for self-promotion or exhibit low comment engagement"
|
||||
}
|
||||
]
|
||||
},
|
||||
],
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
checks:
|
||||
- name: Self Promo All or low comment
|
||||
description: >-
|
||||
SP >10% of all activities or >10% of submissions with low comment
|
||||
engagement
|
||||
kind: submission
|
||||
rules:
|
||||
# this attribution rule is looking at all activities
|
||||
#
|
||||
# we want want this one rule to trigger the check because >10% of all activity (submission AND comments) is a good requirement
|
||||
- name: attr10all
|
||||
kind: attribution
|
||||
criteria:
|
||||
- threshold: '> 10%'
|
||||
window: 90 days
|
||||
- threshold: '> 10%'
|
||||
window: 100
|
||||
# this is a RULE SET
|
||||
#
|
||||
# it is made up of "nested" rules with a pass condition (AND/OR)
|
||||
# if the nested rules pass the condition then the Rule Set triggers the Check
|
||||
#
|
||||
# AND = all nested rules must be triggered to make the Rule Set trigger
|
||||
# AND = any of the nested Rules will be the Rule Set trigger
|
||||
- condition: AND
|
||||
# in this check we use an Attribution >10% on ONLY submissions, which is a lower requirement then the above attribution rule
|
||||
# and combine it with a History rule looking for low comment engagement
|
||||
# to make a "higher" requirement Rule Set our of two low requirement Rules
|
||||
rules:
|
||||
- name: attr20sub
|
||||
kind: attribution
|
||||
criteria:
|
||||
- threshold: '> 10%'
|
||||
thresholdOn: submissions
|
||||
window: 90 days
|
||||
- threshold: '> 10%'
|
||||
thresholdOn: submissions
|
||||
window: 100
|
||||
lookAt: media
|
||||
- name: lowOrOpComm
|
||||
kind: history
|
||||
criteriaJoin: OR
|
||||
criteria:
|
||||
- window: 90 days
|
||||
comment: < 50%
|
||||
- window: 90 days
|
||||
comment: '> 40% OP'
|
||||
actions:
|
||||
- kind: remove
|
||||
- kind: comment
|
||||
content: >-
|
||||
Your submission was removed because you are over reddit's threshold
|
||||
for self-promotion or exhibit low comment engagement
|
||||
@@ -1,39 +0,0 @@
|
||||
{
|
||||
"checks": [
|
||||
{
|
||||
"name": "Self Promo Activities",
|
||||
"description": "Check if any of Author's aggregated submission origins are >10% of entire history",
|
||||
// check will run on a new submission in your subreddit and look at the Author of that submission
|
||||
"kind": "submission",
|
||||
"rules": [
|
||||
{
|
||||
"name": "attr10all",
|
||||
"kind": "attribution",
|
||||
// criteria defaults to OR -- so either of these criteria will trigger the rule
|
||||
"criteria": [
|
||||
{
|
||||
// threshold can be a percent or an absolute number
|
||||
"threshold": "> 10%",
|
||||
// The default is "all" -- calculate percentage of entire history (submissions & comments)
|
||||
// "thresholdOn": "all",
|
||||
|
||||
// look at last 90 days of Author's activities (comments and submissions)
|
||||
"window": "90 days"
|
||||
},
|
||||
{
|
||||
"threshold": "> 10%",
|
||||
// look at Author's last 100 activities (comments and submissions)
|
||||
"window": 100
|
||||
}
|
||||
],
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
{
|
||||
"kind": "report",
|
||||
"content": "{{rules.attr10all.largestPercent}}% of {{rules.attr10all.activityTotal}} items over {{rules.attr10all.window}}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
checks:
|
||||
- name: Self Promo Activities
|
||||
description: >-
|
||||
Check if any of Author's aggregated submission origins are >10% of entire
|
||||
history
|
||||
# check will run on a new submission in your subreddit and look at the Author of that submission
|
||||
kind: submission
|
||||
rules:
|
||||
- name: attr10all
|
||||
kind: attribution
|
||||
# criteria defaults to OR -- so either of these criteria will trigger the rule
|
||||
criteria:
|
||||
- threshold: '> 10%' # threshold can be a percent or an absolute number
|
||||
# The default is "all" -- calculate percentage of entire history (submissions & comments)
|
||||
#thresholdOn: all
|
||||
#
|
||||
# look at last 90 days of Author's activities (comments and submissions)
|
||||
window: 90 days
|
||||
- threshold: '> 10%'
|
||||
# look at Author's last 100 activities (comments and submissions)
|
||||
window: 100
|
||||
actions:
|
||||
- kind: report
|
||||
content: >-
|
||||
{{rules.attr10all.largestPercent}}% of
|
||||
{{rules.attr10all.activityTotal}} items over
|
||||
{{rules.attr10all.window}}
|
||||
@@ -1,24 +0,0 @@
|
||||
checks:
|
||||
- name: Self Promo Submissions
|
||||
description: >-
|
||||
Check if any of Author's aggregated submission origins are >10% of their
|
||||
submissions
|
||||
# check will run on a new submission in your subreddit and look at the Author of that submission
|
||||
kind: submission
|
||||
rules:
|
||||
- name: attr10sub
|
||||
kind: attribution
|
||||
# criteria defaults to OR -- so either of these criteria will trigger the rule
|
||||
criteria:
|
||||
- threshold: '> 10%' # threshold can be a percent or an absolute number
|
||||
thresholdOn: submissions # calculate percentage of submissions, rather than entire history (submissions & comments)
|
||||
window: 90 days # look at last 90 days of Author's activities (comments and submissions)
|
||||
- threshold: '> 10%'
|
||||
thresholdOn: submissions
|
||||
window: 100 # look at Author's last 100 activities (comments and submissions)
|
||||
actions:
|
||||
- kind: report
|
||||
content: >-
|
||||
{{rules.attr10sub.largestPercent}}% of
|
||||
{{rules.attr10sub.activityTotal}} items over
|
||||
{{rules.attr10sub.window}}
|
||||
@@ -1,40 +0,0 @@
|
||||
{
|
||||
"checks": [
|
||||
{
|
||||
"name": "Self Promo Submissions",
|
||||
"description": "Check if any of Author's aggregated submission origins are >10% of their submissions",
|
||||
// check will run on a new submission in your subreddit and look at the Author of that submission
|
||||
"kind": "submission",
|
||||
"rules": [
|
||||
{
|
||||
"name": "attr10sub",
|
||||
"kind": "attribution",
|
||||
// criteria defaults to OR -- so either of these criteria will trigger the rule
|
||||
"criteria": [
|
||||
{
|
||||
// threshold can be a percent or an absolute number
|
||||
"threshold": "> 10%",
|
||||
// calculate percentage of submissions, rather than entire history (submissions & comments)
|
||||
"thresholdOn": "submissions",
|
||||
|
||||
// look at last 90 days of Author's activities (comments and submissions)
|
||||
"window": "90 days"
|
||||
},
|
||||
{
|
||||
"threshold": "> 10%",
|
||||
"thresholdOn": "submissions",
|
||||
// look at Author's last 100 activities (comments and submissions)
|
||||
"window": 100
|
||||
}
|
||||
],
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
{
|
||||
"kind": "report",
|
||||
"content": "{{rules.attr10sub.largestPercent}}% of {{rules.attr10sub.activityTotal}} items over {{rules.attr10sub.window}}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
# Author
|
||||
|
||||
## Rule
|
||||
|
||||
The **Author** rule triggers if any [AuthorCriteria](https://json-schema.app/view/%23%2Fdefinitions%2FAuthorCriteria?url=https%3A%2F%2Fraw.githubusercontent.com%2FFoxxMD%2Fcontext-mod%2Fmaster%2Fsrc%2FSchema%2FApp.json) from a list are either **included** or **excluded**, depending on which property you put them in.
|
||||
|
||||
**AuthorCriteria** that can be checked:
|
||||
* name (u/userName)
|
||||
* author's subreddit flair text
|
||||
* author's subreddit flair css
|
||||
* author's subreddit mod status
|
||||
* [Toolbox User Notes](/docs/examples/userNotes)
|
||||
|
||||
The Author **Rule** is best used in conjunction with other Rules to short-circuit a Check based on who the Author is. It is easier to use a Rule to do this then to write **author filters** for every Rule (and makes Rules more re-useable).
|
||||
|
||||
Consult the [schema](https://json-schema.app/view/%23%2Fdefinitions%2FAuthorRuleJSONConfig?url=https%3A%2F%2Fraw.githubusercontent.com%2FFoxxMD%2Fcontext-mod%2Fmaster%2Fsrc%2FSchema%2FApp.json) for a complete reference of the rule's properties.
|
||||
|
||||
### Examples
|
||||
|
||||
* Basic examples
|
||||
* Flair new user Submission [YAML](/docs/examples/author/flairNewUserSubmission.yaml) | [JSON](/docs/examples/author/flairNewUserSubmission.json5) - If the Author does not have the `vet` flair then flair the Submission with `New User`
|
||||
* Flair vetted user Submission [YAML](/docs/examples/author/flairNewUserSubmission.yaml) | [JSON](/docs/examples/author/flairNewUserSubmission.json5) - If the Author does have the `vet` flair then flair the Submission with `Vetted`
|
||||
* Used with other Rules
|
||||
* Ignore vetted user [YAML](/docs/examples/author/flairNewUserSubmission.yaml) | [JSON](/docs/examples/author/flairNewUserSubmission.json5) - Short-circuit the Check if the Author has the `vet` flair
|
||||
|
||||
## Filter
|
||||
|
||||
All **Rules** and **Checks** have an optional `authorIs` property that takes an [AuthorOptions](https://json-schema.app/view/%23%2Fdefinitions%2FAuthorOptions?url=https%3A%2F%2Fraw.githubusercontent.com%2FFoxxMD%2Fcontext-mod%2Fmaster%2Fsrc%2FSchema%2FApp.json) object.
|
||||
|
||||
**This property works the same as the Author Rule except that:**
|
||||
* On **Rules** if all criteria fail the Rule is **skipped.**
|
||||
* If a Rule is skipped **it does not fail or pass** and so does not affect the outcome of the Check.
|
||||
* However, if all Rules on a Check are skipped the Check will fail.
|
||||
* On **Checks** if all criteria fail the Check **fails**.
|
||||
|
||||
### Examples
|
||||
|
||||
* Skip recent activity check based on author [YAML](/docs/examples/author/authorFilter.yaml) | [JSON](/docs/examples/author/authorFilter.json5) - Skip a Recent Activity check for a set of subreddits if the Author of the Submission has any set of flairs.
|
||||
@@ -1,69 +0,0 @@
|
||||
{
|
||||
"checks": [
|
||||
{
|
||||
"name": "Karma/Meme Sub Activity",
|
||||
"description": "Report on karma sub activity or meme sub activity if user isn't a memelord",
|
||||
// check will run on a new submission in your subreddit and look at the Author of that submission
|
||||
"kind": "submission",
|
||||
"rules": [
|
||||
{
|
||||
"name": "freekarma",
|
||||
"kind": "recentActivity",
|
||||
"lookAt": "submissions",
|
||||
"thresholds": [
|
||||
{
|
||||
"threshold": ">= 1",
|
||||
"subreddits": [
|
||||
"DeFreeKarma",
|
||||
"FreeKarma4U",
|
||||
]
|
||||
}
|
||||
],
|
||||
"window": "7 days"
|
||||
},
|
||||
{
|
||||
"name": "noobmemer",
|
||||
"kind": "recentActivity",
|
||||
// authors filter will be checked before a rule is run. If anything passes then the Rule is skipped -- it is not failed or triggered.
|
||||
// if *all* Rules for a Check are skipped due to authors filter then the Check will fail
|
||||
"authorIs": {
|
||||
// each property (include/exclude) can contain multiple AuthorCriteria
|
||||
// if any AuthorCriteria passes its test the Rule is skipped
|
||||
//
|
||||
// for an AuthorCriteria to pass all properties present on it must pass
|
||||
//
|
||||
// if "include" is present it will always run and exclude will be skipped
|
||||
// "include:" []
|
||||
"exclude": [
|
||||
// for this to pass the Author of the Submission must not have the flair "Supreme Memer" and have the name "user1" or "user2"
|
||||
{
|
||||
"flairText": ["Supreme Memer"],
|
||||
"names": ["user1","user2"]
|
||||
},
|
||||
{
|
||||
// for this to pass the Author of the Submission must not have the flair "Decent Memer"
|
||||
"flairText": ["Decent Memer"]
|
||||
}
|
||||
]
|
||||
},
|
||||
"lookAt": "submissions",
|
||||
"thresholds": [
|
||||
{
|
||||
"threshold": ">= 1",
|
||||
"subreddits": [
|
||||
"dankmemes",
|
||||
]
|
||||
}
|
||||
],
|
||||
"window": "7 days"
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
{
|
||||
"kind": "report",
|
||||
"content": "Author has posted in free karma sub, or in /r/dankmemes and does not have meme flair in this subreddit"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
checks:
|
||||
- name: Karma/Meme Sub Activity
|
||||
description: Report on karma sub activity or meme sub activity if user isn't a memelord
|
||||
# check will run on a new submission in your subreddit and look at the Author of that submission
|
||||
kind: submission
|
||||
rules:
|
||||
- name: freekarma
|
||||
kind: recentActivity
|
||||
lookAt: submissions
|
||||
thresholds:
|
||||
- threshold: '>= 1'
|
||||
subreddits:
|
||||
- DeFreeKarma
|
||||
- FreeKarma4U
|
||||
window: 7 days
|
||||
- name: noobmemer
|
||||
kind: recentActivity
|
||||
# authors filter will be checked before a rule is run. If anything passes then the Rule is skipped -- it is not failed or triggered.
|
||||
# if *all* Rules for a Check are skipped due to authors filter then the Check will fail
|
||||
authorIs:
|
||||
# each property (include/exclude) can contain multiple AuthorCriteria
|
||||
# if any AuthorCriteria passes its test the Rule is skipped
|
||||
#
|
||||
# for an AuthorCriteria to pass all properties present on it must pass
|
||||
#
|
||||
# if include is present it will always run and exclude will be skipped
|
||||
#-include:
|
||||
exclude:
|
||||
# for this to pass the Author of the Submission must not have the flair "Supreme Memer" and have the name "user1" or "user2"
|
||||
- flairText:
|
||||
- Supreme Memer
|
||||
names:
|
||||
- user1
|
||||
- user2
|
||||
# for this to pass the Author of the Submission must not have the flair "Decent Memer"
|
||||
- flairText:
|
||||
- Decent Memer
|
||||
lookAt: submissions
|
||||
thresholds:
|
||||
- threshold: '>= 1'
|
||||
subreddits:
|
||||
- dankmemes
|
||||
window: 7 days
|
||||
actions:
|
||||
- kind: report
|
||||
content: >-
|
||||
Author has posted in free karma sub, or in /r/dankmemes and does not
|
||||
have meme flair in this subreddit
|
||||
@@ -1,29 +0,0 @@
|
||||
{
|
||||
"checks": [
|
||||
{
|
||||
"name": "Flair New User Sub",
|
||||
"description": "Flair submission as sketchy if user does not have vet flair",
|
||||
// check will run on a new submission in your subreddit and look at the Author of that submission
|
||||
"kind": "submission",
|
||||
"rules": [
|
||||
{
|
||||
"name": "newflair",
|
||||
"kind": "author",
|
||||
// rule will trigger if Author does not have "vet" flair text
|
||||
"exclude": [
|
||||
{
|
||||
"flairText": ["vet"]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
{
|
||||
"kind": "flair",
|
||||
"text": "New User",
|
||||
"css": "orange"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
checks:
|
||||
- name: Flair New User Sub
|
||||
description: Flair submission as sketchy if user does not have vet flair
|
||||
# check will run on a new submission in your subreddit and look at the Author of that submission
|
||||
kind: submission
|
||||
rules:
|
||||
- name: newflair
|
||||
kind: author
|
||||
# rule will trigger if Author does not have "vet" flair text
|
||||
exclude:
|
||||
- flairText:
|
||||
- vet
|
||||
actions:
|
||||
- kind: flair
|
||||
text: New User
|
||||
css: orange
|
||||
@@ -1,29 +0,0 @@
|
||||
{
|
||||
"checks": [
|
||||
{
|
||||
"name": "Flair Vetted User Submission",
|
||||
"description": "Flair submission as Approved if user has vet flair",
|
||||
// check will run on a new submission in your subreddit and look at the Author of that submission
|
||||
"kind": "submission",
|
||||
"rules": [
|
||||
{
|
||||
"name": "newflair",
|
||||
"kind": "author",
|
||||
// rule will trigger if Author has "vet" flair text
|
||||
"include": [
|
||||
{
|
||||
"flairText": ["vet"]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
{
|
||||
"kind": "flair",
|
||||
"text": "Vetted",
|
||||
"css": "green"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
checks:
|
||||
- name: Flair Vetted User Submission
|
||||
description: Flair submission as Approved if user has vet flair
|
||||
# check will run on a new submission in your subreddit and look at the Author of that submission
|
||||
kind: submission
|
||||
rules:
|
||||
- name: newflair
|
||||
kind: author
|
||||
# rule will trigger if Author has "vet" flair text
|
||||
include:
|
||||
- flairText:
|
||||
- vet
|
||||
actions:
|
||||
- kind: flair
|
||||
text: Vetted
|
||||
css: green
|
||||
@@ -1,75 +0,0 @@
|
||||
{
|
||||
"checks": [
|
||||
{
|
||||
"name": "non-vetted karma/meme activity",
|
||||
"description": "Report if Author has SP and has recent karma/meme sub activity and isn't vetted",
|
||||
// check will run on a new submission in your subreddit and look at the Author of that submission
|
||||
"kind": "submission",
|
||||
"rules": [
|
||||
{
|
||||
// The Author Rule is best used in conjunction with other Rules --
|
||||
// instead of having to write an AuthorFilter for every Rule where you want to skip it based on Author criteria
|
||||
// you can write one Author Rule and make it fail on the required criteria
|
||||
// so that the check fails and Actions don't run
|
||||
"name": "nonvet",
|
||||
"kind": "author",
|
||||
"exclude": [
|
||||
{
|
||||
"flairText": ["vet"]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "attr10",
|
||||
"kind": "attribution",
|
||||
"criteria": [
|
||||
{
|
||||
"threshold": "> 10%",
|
||||
"window": "90 days"
|
||||
},
|
||||
{
|
||||
"threshold": "> 10%",
|
||||
"window": 100
|
||||
}
|
||||
],
|
||||
},
|
||||
{
|
||||
"name": "freekarma",
|
||||
"kind": "recentActivity",
|
||||
"lookAt": "submissions",
|
||||
"thresholds": [
|
||||
{
|
||||
"threshold": ">= 1",
|
||||
"subreddits": [
|
||||
"DeFreeKarma",
|
||||
"FreeKarma4U",
|
||||
]
|
||||
}
|
||||
],
|
||||
"window": "7 days"
|
||||
},
|
||||
{
|
||||
"name": "memes",
|
||||
"kind": "recentActivity",
|
||||
"lookAt": "submissions",
|
||||
"thresholds": [
|
||||
{
|
||||
"threshold": ">= 3",
|
||||
"subreddits": [
|
||||
"dankmemes",
|
||||
]
|
||||
}
|
||||
],
|
||||
"window": "7 days"
|
||||
}
|
||||
],
|
||||
// will NOT run if the Author for this Submission has the flair "vet"
|
||||
"actions": [
|
||||
{
|
||||
"kind": "report",
|
||||
"content": "Author has posted in free karma or meme subs recently"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
checks:
|
||||
- name: non-vetted karma/meme activity
|
||||
description: >-
|
||||
Report if Author has SP and has recent karma/meme sub activity and isn't
|
||||
vetted
|
||||
# check will run on a new submission in your subreddit and look at the Author of that submission
|
||||
kind: submission
|
||||
rules:
|
||||
# The Author Rule is best used in conjunction with other Rules --
|
||||
# instead of having to write an AuthorFilter for every Rule where you want to skip it based on Author criteria
|
||||
# you can write one Author Rule and make it fail on the required criteria
|
||||
# so that the check fails and Actions don't run
|
||||
- name: nonvet
|
||||
kind: author
|
||||
exclude:
|
||||
- flairText:
|
||||
- vet
|
||||
- name: attr10
|
||||
kind: attribution
|
||||
criteria:
|
||||
- threshold: '> 10%'
|
||||
window: 90 days
|
||||
- threshold: '> 10%'
|
||||
window: 100
|
||||
- name: freekarma
|
||||
kind: recentActivity
|
||||
lookAt: submissions
|
||||
thresholds:
|
||||
- threshold: '>= 1'
|
||||
subreddits:
|
||||
- DeFreeKarma
|
||||
- FreeKarma4U
|
||||
window: 7 days
|
||||
- name: memes
|
||||
kind: recentActivity
|
||||
lookAt: submissions
|
||||
thresholds:
|
||||
- threshold: '>= 3'
|
||||
subreddits:
|
||||
- dankmemes
|
||||
window: 7 days
|
||||
# will NOT run if the Author for this Submission has the flair "vet"
|
||||
actions:
|
||||
- kind: report
|
||||
content: Author has posted in free karma or meme subs recently
|
||||
@@ -1,30 +0,0 @@
|
||||
{
|
||||
"checks": [
|
||||
{
|
||||
"name": "Low Comment Engagement",
|
||||
"description": "Check if Author is submitting much more than they comment",
|
||||
// check will run on a new submission in your subreddit and look at the Author of that submission
|
||||
"kind": "submission",
|
||||
"rules": [
|
||||
{
|
||||
"name": "lowComm",
|
||||
"kind": "history",
|
||||
"criteria": [
|
||||
{
|
||||
// look at last 90 days of Author's activities
|
||||
"window": "90 days",
|
||||
// trigger if less than 30% of their activities in this time period are comments
|
||||
"comment": "< 30%"
|
||||
},
|
||||
]
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
{
|
||||
"kind": "report",
|
||||
"content": "Low engagement: comments were {{rules.lowcomm.commentPercent}} of {{rules.lowcomm.activityTotal}} over {{rules.lowcomm.window}}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
checks:
|
||||
- name: Low Comment Engagement
|
||||
description: Check if Author is submitting much more than they comment
|
||||
# check will run on a new submission in your subreddit and look at the Author of that submission
|
||||
kind: submission
|
||||
rules:
|
||||
- name: lowComm
|
||||
kind: history
|
||||
criteria:
|
||||
- comment: '< 30%'
|
||||
window:
|
||||
# get author's last 90 days of activities or 100 activities, whichever is less
|
||||
duration: 90 days
|
||||
count: 100
|
||||
# trigger if less than 30% of their activities in this time period are comments
|
||||
|
||||
actions:
|
||||
- kind: report
|
||||
content: >-
|
||||
Low engagement: comments were {{rules.lowcomm.commentPercent}} of
|
||||
{{rules.lowcomm.activityTotal}} over {{rules.lowcomm.window}}
|
||||
@@ -1,30 +0,0 @@
|
||||
{
|
||||
"checks": [
|
||||
{
|
||||
"name": "Engaging Own Content Only",
|
||||
"description": "Check if Author is mostly engaging in their own content only",
|
||||
// check will run on a new submission in your subreddit and look at the Author of that submission
|
||||
"kind": "submission",
|
||||
"rules": [
|
||||
{
|
||||
"name": "opOnly",
|
||||
"kind": "history",
|
||||
"criteria": [
|
||||
{
|
||||
// look at last 90 days of Author's activities
|
||||
"window": "90 days",
|
||||
// trigger if more than 60% of their activities in this time period are comments as OP
|
||||
"comment": "> 60% OP"
|
||||
},
|
||||
]
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
{
|
||||
"kind": "report",
|
||||
"content": "Selfish OP: {{rules.oponly.opPercent}} of {{rules.oponly.commentTotal}} comments over {{rules.oponly.window}} are as OP"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
checks:
|
||||
- name: Engaging Own Content Only
|
||||
description: Check if Author is mostly engaging in their own content only
|
||||
# check will run on a new submission in your subreddit and look at the Author of that submission
|
||||
kind: submission
|
||||
rules:
|
||||
- name: opOnly
|
||||
kind: history
|
||||
criteria:
|
||||
# trigger if more than 60% of their activities in this time period are comments as OP
|
||||
- comment: '> 60% OP'
|
||||
window:
|
||||
# get author's last 90 days of activities or 100 activities, whichever is less
|
||||
duration: 90 days
|
||||
count: 100
|
||||
|
||||
actions:
|
||||
- kind: report
|
||||
content: >-
|
||||
Selfish OP: {{rules.oponly.opPercent}} of
|
||||
{{rules.oponly.commentTotal}} comments over {{rules.oponly.window}}
|
||||
are as OP
|
||||
@@ -1,9 +0,0 @@
|
||||
# Flair users and submissions
|
||||
|
||||
Flair users and submissions based on certain keywords from submitter's profile.
|
||||
|
||||
Consult [User Flair schema](https://json-schema.app/view/%23%2Fdefinitions%2FUserFlairActionJson?url=https%3A%2F%2Fraw.githubusercontent.com%2FFoxxMD%2Fcontext-mod%2Fmaster%2Fsrc%2FSchema%2FApp.json) and [Submission Flair schema](https://json-schema.app/view/%23%2Fdefinitions%2FFlairActionJson?url=https%3A%2F%2Fraw.githubusercontent.com%2FFoxxMD%2Fcontext-mod%2Fmaster%2Fsrc%2FSchema%2FApp.json) for a complete reference of the rule's properties.
|
||||
|
||||
### Examples
|
||||
|
||||
* OnlyFans submissions [YAML](/docs/examples/onlyFansFlair/onlyFansFlair.yaml) | [JSON](/docs/examples/onlyfansFlair/onlyfansFlair.json5) - Check whether submitter has typical OF keywords in their profile and flair both author + submission accordingly.
|
||||
@@ -1,68 +0,0 @@
|
||||
{
|
||||
"checks": [
|
||||
{
|
||||
"name": "Flair OF submitters",
|
||||
"description": "Flair submission as OF if user does not have Verified flair and has certain keywords in their profile",
|
||||
"kind": "submission",
|
||||
"authorIs": {
|
||||
"exclude": [
|
||||
{
|
||||
"flairCssClass": ["verified"]
|
||||
}
|
||||
]
|
||||
},
|
||||
"rules": [
|
||||
{
|
||||
"name": "OnlyFans strings in description",
|
||||
"kind": "author",
|
||||
"include": [
|
||||
{
|
||||
"description": [
|
||||
"/(cashapp|allmylinks|linktr|onlyfans\\.com)/i",
|
||||
"/(see|check|my|view) (out|of|onlyfans|kik|skype|insta|ig|profile|links)/i",
|
||||
"my links",
|
||||
"$"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
{
|
||||
"name": "Set OnlyFans user flair",
|
||||
"kind": "userflair",
|
||||
"flair_template_id": "put-your-onlyfans-user-flair-id-here"
|
||||
},
|
||||
{
|
||||
"name":"Set OF Creator SUBMISSION flair",
|
||||
"kind": "flair",
|
||||
"flair_template_id": "put-your-onlyfans-post-flair-id-here"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
"name": "Flair posts of OF submitters",
|
||||
"description": "Flair submission as OnlyFans if submitter has OnlyFans userflair (override post flair set by submitter)",
|
||||
"kind": "submission",
|
||||
"rules": [
|
||||
{
|
||||
"name": "Include OF submitters",
|
||||
"kind": "author",
|
||||
"include": [
|
||||
{
|
||||
"flairCssClass": ["onlyfans"]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
{
|
||||
"name":"Set OF Creator SUBMISSION flair",
|
||||
"kind": "flair",
|
||||
"flair_template_id": "put-your-onlyfans-post-flair-id-here"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
checks:
|
||||
- name: Flair OF submitters
|
||||
description: Flair submission as OF if user does not have Verified flair and has
|
||||
certain keywords in their profile
|
||||
kind: submission
|
||||
authorIs:
|
||||
exclude:
|
||||
- flairCssClass:
|
||||
- verified
|
||||
rules:
|
||||
- name: OnlyFans strings in description
|
||||
kind: author
|
||||
include:
|
||||
- description:
|
||||
- '/(cashapp|allmylinks|linktr|onlyfans\.com)/i'
|
||||
- '/(see|check|my|view) (out|of|onlyfans|kik|skype|insta|ig|profile|links)/i'
|
||||
- my links
|
||||
- "$"
|
||||
actions:
|
||||
- name: Set OnlyFans user flair
|
||||
kind: userflair
|
||||
flair_template_id: put-your-onlyfans-user-flair-id-here
|
||||
- name: Set OF Creator SUBMISSION flair
|
||||
kind: flair
|
||||
flair_template_id: put-your-onlyfans-post-flair-id-here
|
||||
- name: Flair posts of OF submitters
|
||||
description: Flair submission as OnlyFans if submitter has OnlyFans userflair (override post flair set by submitter)
|
||||
kind: submission
|
||||
rules:
|
||||
- name: Include OF submitters
|
||||
kind: author
|
||||
include:
|
||||
- flairCssClass:
|
||||
- onlyfans
|
||||
actions:
|
||||
- name: Set OF Creator SUBMISSION flair
|
||||
kind: flair
|
||||
flair_template_id: put-your-onlyfans-post-flair-id-here
|
||||
@@ -1,10 +0,0 @@
|
||||
# Recent Activity
|
||||
|
||||
The **Recent Activity** rule can check if an Author has made any Submissions/Comments in a list of defined Subreddits.
|
||||
|
||||
Consult the [schema](https://json-schema.app/view/%23%2Fdefinitions%2FRecentActivityRuleJSONConfig?url=https%3A%2F%2Fraw.githubusercontent.com%2FFoxxMD%2Fcontext-mod%2Fmaster%2Fsrc%2FSchema%2FApp.json) for a complete reference of the rule's properties.
|
||||
|
||||
### Examples
|
||||
|
||||
* Free Karma Subreddits [YAML](/docs/examples/recentActivity/freeKarma.yaml) | [JSON](/docs/examples/recentActivity/freeKarma.json5) - Check if the Author has recently posted in any "free karma" subreddits
|
||||
* Submission in Free Karma Subreddits [YAML](/docs/examples/recentActivity/freeKarmaOnSubmission.yaml) | [JSON](/docs/examples/recentActivity/freeKarmaOnSubmission.json5) - Check if the Author has posted the Submission this check is running on in any "free karma" subreddits recently
|
||||
@@ -1,40 +0,0 @@
|
||||
{
|
||||
"checks": [
|
||||
{
|
||||
"name": "Free Karma Alert",
|
||||
"description": "Check if author has posted in 'freekarma' subreddits",
|
||||
// check will run on a new submission in your subreddit and look at the Author of that submission
|
||||
"kind": "submission",
|
||||
"rules": [
|
||||
{
|
||||
"name": "freekarma",
|
||||
"kind": "recentActivity",
|
||||
"useSubmissionAsReference": false,
|
||||
// when `lookAt` is not present this rule will look for submissions and comments
|
||||
// lookAt: "submissions"
|
||||
// lookAt: "comments"
|
||||
"thresholds": [
|
||||
{
|
||||
// for all subreddits, if the number of activities (sub/comment) is equal to or greater than 1 then the rule is triggered
|
||||
"threshold": ">= 1",
|
||||
"subreddits": [
|
||||
"DeFreeKarma",
|
||||
"FreeKarma4U",
|
||||
"FreeKarma4You",
|
||||
"upvote"
|
||||
]
|
||||
}
|
||||
],
|
||||
// will look at all of the Author's activities in the last 7 days
|
||||
"window": "7 days"
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
{
|
||||
"kind": "report",
|
||||
"content": "{{rules.freekarma.totalCount}} activities in karma {{rules.freekarma.subCount}} subs over {{rules.freekarma.window}}: {{rules.freekarma.subSummary}}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
checks:
|
||||
- name: Free Karma Alert
|
||||
description: Check if author has posted in 'freekarma' subreddits
|
||||
# check will run on a new submission in your subreddit and look at the Author of that submission
|
||||
kind: submission
|
||||
rules:
|
||||
- name: freekarma
|
||||
kind: recentActivity
|
||||
# // when lookAt is not present this rule will look for submissions and comments
|
||||
#lookAt: comments
|
||||
useSubmissionAsReference: false
|
||||
thresholds:
|
||||
# if the number of activities (sub/comment) found CUMULATIVELY in the subreddits listed is
|
||||
# equal to or greater than 1 then the rule is triggered
|
||||
- threshold: '>= 1'
|
||||
subreddits:
|
||||
- DeFreeKarma
|
||||
- FreeKarma4U
|
||||
- FreeKarma4You
|
||||
- upvote
|
||||
window: 7 days
|
||||
actions:
|
||||
- kind: report
|
||||
content: >-
|
||||
{{rules.freekarma.totalCount}} activities in karma
|
||||
{{rules.freekarma.subCount}} subs over {{rules.freekarma.window}}:
|
||||
{{rules.freekarma.subSummary}}
|
||||
@@ -1,41 +0,0 @@
|
||||
{
|
||||
"checks": [
|
||||
{
|
||||
"name": "Free Karma On Submission Alert",
|
||||
"description": "Check if author has posted this submission in 'freekarma' subreddits",
|
||||
// check will run on a new submission in your subreddit and look at the Author of that submission
|
||||
"kind": "submission",
|
||||
"rules": [
|
||||
{
|
||||
"name": "freekarmasub",
|
||||
"kind": "recentActivity",
|
||||
// rule will only look at Author's submissions in these subreddits
|
||||
"lookAt": "submissions",
|
||||
// rule will only look at Author's submissions in these subreddits that have the same content (link) as the submission this event was made on
|
||||
// In simpler terms -- rule will only check to see if the same link the author just posted is also posted in these subreddits
|
||||
"useSubmissionAsReference":true,
|
||||
"thresholds": [
|
||||
{
|
||||
// for all subreddits, if the number of activities (sub/comment) is equal to or greater than 1 then the rule is triggered
|
||||
"threshold": ">= 1",
|
||||
"subreddits": [
|
||||
"DeFreeKarma",
|
||||
"FreeKarma4U",
|
||||
"FreeKarma4You",
|
||||
"upvote"
|
||||
]
|
||||
}
|
||||
],
|
||||
// look at all of the Author's submissions in the last 7 days
|
||||
"window": "7 days"
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
{
|
||||
"kind": "report",
|
||||
"content": "Submission posted {{rules.freekarmasub.totalCount}} times in karma {{rules.freekarmasub.subCount}} subs over {{rules.freekarmasub.window}}: {{rules.freekarmasub.subSummary}}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
checks:
|
||||
- name: Free Karma On Submission Alert
|
||||
description: Check if author has posted this submission in 'freekarma' subreddits
|
||||
kind: submission
|
||||
rules:
|
||||
- name: freekarmasub
|
||||
kind: recentActivity
|
||||
# rule will only look at Author's submissions in these subreddits
|
||||
lookAt: submissions
|
||||
# rule will only look at Author's submissions in these subreddits that have the same content (link) as the submission this event was made on
|
||||
# In simpler terms -- rule will only check to see if the same link the author just posted is also posted in these subreddits
|
||||
useSubmissionAsReference: true
|
||||
thresholds:
|
||||
- threshold: '>= 1'
|
||||
subreddits:
|
||||
- DeFreeKarma
|
||||
- FreeKarma4U
|
||||
- FreeKarma4You
|
||||
- upvote
|
||||
window: 7 days
|
||||
actions:
|
||||
- kind: report
|
||||
content: >-
|
||||
Submission posted {{rules.freekarmasub.totalCount}} times in karma
|
||||
{{rules.freekarmasub.subCount}} subs over
|
||||
{{rules.freekarmasub.window}}: {{rules.freekarmasub.subSummary}}
|
||||
@@ -1,73 +0,0 @@
|
||||
{
|
||||
"checks": [
|
||||
{
|
||||
"name": "remove discord spam",
|
||||
"notifyOnTrigger": true,
|
||||
"description": "remove comments from users who are spamming discord links",
|
||||
"kind": "comment",
|
||||
"authorIs": {
|
||||
"exclude": [
|
||||
{
|
||||
"isMod": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"itemIs": [
|
||||
{
|
||||
"removed": false,
|
||||
"approved": false,
|
||||
}
|
||||
],
|
||||
"condition": "OR",
|
||||
"rules": [
|
||||
{
|
||||
// set to false if you want to allow comments with a discord link ONLY IF
|
||||
// the author doesn't have a history of spamming discord links
|
||||
// -- basically allows one-off/organic discord links
|
||||
"enable": true,
|
||||
"name": "linkOnlySpam",
|
||||
"kind": "regex",
|
||||
"criteria": [
|
||||
{
|
||||
"name": "only link",
|
||||
"regex": "/^.*(discord\\.gg\\/[\\w\\d]+)$/i",
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"condition": "AND",
|
||||
"rules": [
|
||||
{
|
||||
"name": "linkAnywhereSpam",
|
||||
"kind": "regex",
|
||||
"criteria": [
|
||||
{
|
||||
"name": "contains link anywhere",
|
||||
"regex": "/^.*(discord\\.gg\\/[\\w\\d]+).*$/i",
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "linkAnywhereHistoricalSpam",
|
||||
"kind": "regex",
|
||||
"criteria": [
|
||||
{
|
||||
"name": "contains links anywhere historically",
|
||||
"regex": "/^.*(discord\\.gg\\/[\\w\\d]+).*$/i",
|
||||
"totalMatchThreshold": ">= 3",
|
||||
"lookAt": "comments",
|
||||
"window": 10
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
{
|
||||
"kind": "remove"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
checks:
|
||||
- name: remove discord spam
|
||||
notifyOnTrigger: true
|
||||
description: remove comments from users who are spamming discord links
|
||||
kind: comment
|
||||
authorIs:
|
||||
exclude:
|
||||
- isMod: true
|
||||
itemIs:
|
||||
- removed: false
|
||||
approved: false
|
||||
condition: OR
|
||||
rules:
|
||||
- enable: true
|
||||
name: linkOnlySpam
|
||||
kind: regex
|
||||
criteria:
|
||||
- name: only link
|
||||
regex: '/^.*(discord\.gg\/[\w\d]+)$/i'
|
||||
- condition: AND
|
||||
rules:
|
||||
- name: linkAnywhereSpam
|
||||
kind: regex
|
||||
criteria:
|
||||
- name: contains link anywhere
|
||||
regex: '/^.*(discord\.gg\/[\w\d]+).*$/i'
|
||||
- name: linkAnywhereHistoricalSpam
|
||||
kind: regex
|
||||
criteria:
|
||||
- name: contains links anywhere historically
|
||||
regex: '/^.*(discord\.gg\/[\w\d]+).*$/i'
|
||||
totalMatchThreshold: '>= 3'
|
||||
lookAt: comments
|
||||
window: 10
|
||||
actions:
|
||||
- kind: remove
|
||||
@@ -1,30 +0,0 @@
|
||||
{
|
||||
"checks": [
|
||||
{
|
||||
"name": "Burstpost Spam",
|
||||
"description": "Check if Author is crossposting in short bursts",
|
||||
// check will run on a new submission in your subreddit and look at the Author of that submission
|
||||
"kind": "submission",
|
||||
"rules": [
|
||||
{
|
||||
"name": "burstpost",
|
||||
"kind": "repeatActivity",
|
||||
// will only look at Submissions in Author's history that contain the same content (link) as the Submission this check was initiated by
|
||||
"useSubmissionAsReference": true,
|
||||
// the number of non-repeat activities (submissions or comments) to ignore between repeat submissions
|
||||
"gapAllowance": 3,
|
||||
// if the Author has posted this Submission 6 times, ignoring 3 non-repeat activities between each repeat, then this rule will trigger
|
||||
"threshold": ">= 6",
|
||||
// look at all of the Author's submissions in the last 7 days
|
||||
"window": "7 days"
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
{
|
||||
"kind": "report",
|
||||
"content": "Author has burst-posted this link {{rules.burstpost.largestRepeat}} times over {{rules.burstpost.window}}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
checks:
|
||||
- name: Burstpost Spam
|
||||
description: Check if Author is crossposting in short bursts
|
||||
# check will run on a new submission in your subreddit and look at the Author of that submission
|
||||
kind: submission
|
||||
rules:
|
||||
- name: burstpost
|
||||
kind: repeatActivity
|
||||
# will only look at Submissions in Author's history that contain the same content (link) as the Submission this check was initiated by
|
||||
useSubmissionAsReference: true
|
||||
# the number of non-repeat activities (submissions or comments) to ignore between repeat submissions
|
||||
gapAllowance: 3
|
||||
# if the Author has posted this Submission 6 times, ignoring 3 non-repeat activities between each repeat, then this rule will trigger
|
||||
threshold: '>= 6'
|
||||
# look at all of the Author's submissions in the last 7 days or 100 submissions
|
||||
window:
|
||||
duration: 7 days
|
||||
count: 100
|
||||
actions:
|
||||
- kind: report
|
||||
content: >-
|
||||
Author has burst-posted this link {{rules.burstpost.largestRepeat}}
|
||||
times over {{rules.burstpost.window}}
|
||||
@@ -1,28 +0,0 @@
|
||||
{
|
||||
"checks": [
|
||||
{
|
||||
"name": "Crosspost Spam",
|
||||
"description": "Check if Author is spamming Submissions across subreddits",
|
||||
// check will run on a new submission in your subreddit and look at the Author of that submission
|
||||
"kind": "submission",
|
||||
"rules": [
|
||||
{
|
||||
"name": "xpostspam",
|
||||
"kind": "repeatActivity",
|
||||
// will only look at Submissions in Author's history that contain the same content (link) as the Submission this check was initiated by
|
||||
"useSubmissionAsReference": true,
|
||||
// if the Author has posted this Submission 5 times consecutively then this rule will trigger
|
||||
"threshold": ">= 5",
|
||||
// look at all of the Author's submissions in the last 7 days
|
||||
"window": "7 days"
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
{
|
||||
"kind": "report",
|
||||
"content": "Author has posted this link {{rules.xpostspam.largestRepeat}} times over {{rules.xpostspam.window}}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
checks:
|
||||
- name: Crosspost Spam
|
||||
description: Check if Author is spamming Submissions across subreddits
|
||||
# check will run on a new submission in your subreddit and look at the Author of that submission
|
||||
kind: submission
|
||||
rules:
|
||||
- name: xpostspam
|
||||
kind: repeatActivity
|
||||
# will only look at Submissions in Author's history that contain the same content (link) as the Submission this check was initiated by
|
||||
useSubmissionAsReference: true
|
||||
# if the Author has posted this Submission 5 times consecutively then this rule will trigger
|
||||
threshold: '>= 5'
|
||||
# look at all of the Author's submissions in the last 7 days
|
||||
window: 7 days
|
||||
actions:
|
||||
- kind: report
|
||||
content: >-
|
||||
Author has posted this link {{rules.xpostspam.largestRepeat}} times
|
||||
over {{rules.xpostspam.window}}
|
||||
@@ -1,42 +0,0 @@
|
||||
{
|
||||
"polling": ["newComm"],
|
||||
"checks": [
|
||||
{
|
||||
//
|
||||
// Stop users who spam the same comment many times
|
||||
//
|
||||
// Remove a COMMENT if the user has crossposted it at least 4 times in recent history
|
||||
//
|
||||
"name": "low xp comment spam",
|
||||
"description": "X-posted comment >=4x",
|
||||
"kind": "comment",
|
||||
"condition": "AND",
|
||||
"rules": [
|
||||
{
|
||||
"name": "xPostLow",
|
||||
"kind": "repeatActivity",
|
||||
"gapAllowance": 2,
|
||||
"threshold": ">= 4",
|
||||
"window": {
|
||||
"count": 50,
|
||||
"duration": "6 months"
|
||||
}
|
||||
},
|
||||
],
|
||||
"actions": [
|
||||
// remove this after confirming behavior is acceptable
|
||||
{
|
||||
"kind": "report",
|
||||
"content": "Remove=> Posted same comment {{rules.xpostlow.largestRepeat}}x times"
|
||||
},
|
||||
//
|
||||
//
|
||||
{
|
||||
"kind": "remove",
|
||||
// remove the line below after confirming behavior is acceptable
|
||||
"dryRun": true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
polling:
|
||||
- newComm
|
||||
checks:
|
||||
# Stop users who spam the same comment many times
|
||||
- name: low xp comment spam
|
||||
description: X-posted comment >=4x
|
||||
kind: comment
|
||||
condition: AND
|
||||
rules:
|
||||
- name: xPostLow
|
||||
kind: repeatActivity
|
||||
# number of "non-repeat" comments allowed between "repeat comments"
|
||||
gapAllowance: 2
|
||||
# greater or more than 4 repeat comments triggers this rule
|
||||
threshold: '>= 4'
|
||||
# retrieve either last 50 comments or 6 months' of history, whichever is less
|
||||
window:
|
||||
count: 50
|
||||
duration: 6 months
|
||||
actions:
|
||||
- kind: report
|
||||
enable: true
|
||||
content: 'Remove => Posted same comment {{rules.xpostlow.largestRepeat}}x times'
|
||||
- kind: remove
|
||||
enable: true
|
||||
@@ -1,77 +0,0 @@
|
||||
{
|
||||
"polling": ["unmoderated"],
|
||||
"checks": [
|
||||
{
|
||||
//
|
||||
// Stop users who post low-effort, crossposted spam
|
||||
//
|
||||
// Remove a SUBMISSION if the user has crossposted it at least 4 times in recent history AND
|
||||
// less than 50% of their activity is comments OR more than 40% of those comments are as OP (in the own submissions)
|
||||
//
|
||||
"name": "low xp spam and engagement",
|
||||
"description": "X-posted 4x and low comment engagement",
|
||||
"kind": "submission",
|
||||
"itemIs": [
|
||||
{
|
||||
"removed": false
|
||||
}
|
||||
],
|
||||
"condition": "AND",
|
||||
"rules": [
|
||||
{
|
||||
"name": "xPostLow",
|
||||
"kind": "repeatActivity",
|
||||
"gapAllowance": 2,
|
||||
"threshold": ">= 4",
|
||||
"window": {
|
||||
"count": 50,
|
||||
"duration": "6 months"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "lowOrOpComm",
|
||||
"kind": "history",
|
||||
"criteriaJoin": "OR",
|
||||
"criteria": [
|
||||
{
|
||||
"window": {
|
||||
"count": 100,
|
||||
"duration": "6 months"
|
||||
},
|
||||
"comment": "< 50%"
|
||||
},
|
||||
{
|
||||
"window": {
|
||||
"count": 100,
|
||||
"duration": "6 months"
|
||||
},
|
||||
"comment": "> 40% OP"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
// remove this after confirming behavior is acceptable
|
||||
{
|
||||
"kind": "report",
|
||||
"content": "Remove=>{{rules.xpostlow.largestRepeat}} X-P => {{rules.loworopcomm.thresholdSummary}}"
|
||||
},
|
||||
//
|
||||
//
|
||||
{
|
||||
"kind": "remove",
|
||||
// remove the line below after confirming behavior is acceptable
|
||||
"dryRun": true
|
||||
},
|
||||
// optionally remove "dryRun" from below if you want to leave a comment on removal
|
||||
// PROTIP: the comment is bland, you should make it better
|
||||
{
|
||||
"kind": "comment",
|
||||
"content": "Your submission has been removed because you cross-posted it {{rules.xpostlow.largestRepeat}} times and you have very low engagement outside of making submissions",
|
||||
"distinguish": true,
|
||||
"dryRun": true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
polling:
|
||||
- unmoderated
|
||||
checks:
|
||||
# stop users who post low-effort, crossposted spam submissions
|
||||
#
|
||||
# Remove a SUBMISSION if the user has crossposted it at least 4 times in recent history AND
|
||||
# less than 50% of their activity is comments OR more than 40% of those comments are as OP (in the own submissions)
|
||||
- name: low xp spam and engagement
|
||||
description: X-posted 4x and low comment engagement
|
||||
kind: submission
|
||||
itemIs:
|
||||
- removed: false
|
||||
condition: AND
|
||||
rules:
|
||||
- name: xPostLow
|
||||
kind: repeatActivity
|
||||
gapAllowance: 2
|
||||
threshold: '>= 4'
|
||||
window:
|
||||
count: 50
|
||||
duration: 6 months
|
||||
- name: lowOrOpComm
|
||||
kind: history
|
||||
criteriaJoin: OR
|
||||
criteria:
|
||||
- window:
|
||||
count: 100
|
||||
duration: 6 months
|
||||
comment: < 50%
|
||||
- window:
|
||||
count: 100
|
||||
duration: 6 months
|
||||
comment: '> 40% OP'
|
||||
actions:
|
||||
- kind: report
|
||||
enable: true
|
||||
content: >-
|
||||
Remove=>{{rules.xpostlow.largestRepeat}} X-P =>
|
||||
{{rules.loworopcomm.thresholdSummary}}
|
||||
- kind: remove
|
||||
enable: true
|
||||
- kind: comment
|
||||
enable: true
|
||||
content: >-
|
||||
Your submission has been removed because you cross-posted it
|
||||
{{rules.xpostlow.largestRepeat}} times and you have very low
|
||||
engagement outside of making submissions
|
||||
distinguish: true
|
||||
@@ -1,75 +0,0 @@
|
||||
{
|
||||
"polling": ["newComm"],
|
||||
"checks": [
|
||||
{
|
||||
"name": "ban discord only spammer",
|
||||
"description": "ban a user who spams only a discord link many times historically",
|
||||
"kind": "comment",
|
||||
"condition": "AND",
|
||||
"rules": [
|
||||
"linkOnlySpam",
|
||||
"linkAnywhereHistoricalSpam",
|
||||
],
|
||||
"actions": [
|
||||
{
|
||||
"kind": "remove"
|
||||
},
|
||||
{
|
||||
"kind": "ban",
|
||||
"content": "spamming discord links"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "remove discord spam",
|
||||
"description": "remove comments from users who only link to discord or mention discord link many times historically",
|
||||
"kind": "comment",
|
||||
"condition": "OR",
|
||||
"rules": [
|
||||
{
|
||||
"name": "linkOnlySpam",
|
||||
"kind": "regex",
|
||||
"criteria": [
|
||||
{
|
||||
"name": "only link",
|
||||
"regex": "/^.*(discord\\.gg\\/[\\w\\d]+)$/i",
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"condition": "AND",
|
||||
"rules": [
|
||||
{
|
||||
"name": "linkAnywhereSpam",
|
||||
"kind": "regex",
|
||||
"criteria": [
|
||||
{
|
||||
"name": "contains link anywhere",
|
||||
"regex": "/^.*(discord\\.gg\\/[\\w\\d]+).*$/i",
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "linkAnywhereHistoricalSpam",
|
||||
"kind": "regex",
|
||||
"criteria": [
|
||||
{
|
||||
"name": "contains links anywhere historically",
|
||||
"regex": "/^.*(discord\\.gg\\/[\\w\\d]+).*$/i",
|
||||
"totalMatchThreshold": ">= 3",
|
||||
"lookAt": "comments",
|
||||
"window": 10
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
{
|
||||
"kind": "remove"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
polling:
|
||||
- newComm
|
||||
checks:
|
||||
- name: ban discord only spammer
|
||||
description: ban a user who spams only a discord link many times historically
|
||||
kind: comment
|
||||
condition: AND
|
||||
rules:
|
||||
- linkOnlySpam
|
||||
- linkAnywhereHistoricalSpam
|
||||
actions:
|
||||
- kind: remove
|
||||
- kind: ban
|
||||
content: spamming discord links
|
||||
- name: remove discord spam
|
||||
description: >-
|
||||
remove comments from users who only link to discord or mention discord
|
||||
link many times historically
|
||||
kind: comment
|
||||
condition: OR
|
||||
rules:
|
||||
- name: linkOnlySpam
|
||||
kind: regex
|
||||
criteria:
|
||||
- name: only link
|
||||
# single quotes are required to escape special characters
|
||||
regex: '/^.*(discord\.gg\/[\w\d]+)$/i'
|
||||
- condition: AND
|
||||
rules:
|
||||
- name: linkAnywhereSpam
|
||||
kind: regex
|
||||
criteria:
|
||||
- name: contains link anywhere
|
||||
# single quotes are required to escape special characters
|
||||
regex: '/^.*(discord\.gg\/[\w\d]+).*$/i'
|
||||
- name: linkAnywhereHistoricalSpam
|
||||
kind: regex
|
||||
criteria:
|
||||
- name: contains links anywhere historically
|
||||
# single quotes are required to escape special characters
|
||||
regex: '/^.*(discord\.gg\/[\w\d]+).*$/i'
|
||||
totalMatchThreshold: '>= 3'
|
||||
lookAt: comments
|
||||
window: 10
|
||||
actions:
|
||||
- kind: remove
|
||||
@@ -1,138 +0,0 @@
|
||||
{
|
||||
"polling": [
|
||||
"unmoderated"
|
||||
],
|
||||
"checks": [
|
||||
{
|
||||
//
|
||||
// Stop users who post low-effort, crossposted spam
|
||||
//
|
||||
// Remove a SUBMISSION if the user has crossposted it at least 4 times in recent history AND
|
||||
// less than 50% of their activity is comments OR more than 40% of those comments are as OP (in the own submissions)
|
||||
//
|
||||
"name": "remove on low xp spam and engagement",
|
||||
"description": "X-posted 4x and low comment engagement",
|
||||
"kind": "submission",
|
||||
"itemIs": [
|
||||
{
|
||||
"removed": false
|
||||
}
|
||||
],
|
||||
"condition": "AND",
|
||||
"rules": [
|
||||
{
|
||||
"name": "xPostLow",
|
||||
"kind": "repeatActivity",
|
||||
"gapAllowance": 2,
|
||||
"threshold": ">= 4",
|
||||
"window": {
|
||||
"count": 50,
|
||||
"duration": "6 months"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "lowOrOpComm",
|
||||
"kind": "history",
|
||||
"criteriaJoin": "OR",
|
||||
"criteria": [
|
||||
{
|
||||
"window": {
|
||||
"count": 100,
|
||||
"duration": "6 months"
|
||||
},
|
||||
"comment": "< 50%"
|
||||
},
|
||||
{
|
||||
"window": {
|
||||
"count": 100,
|
||||
"duration": "6 months"
|
||||
},
|
||||
"comment": "> 40% OP"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
// remove this after confirming behavior is acceptable
|
||||
{
|
||||
"kind": "report",
|
||||
"content": "Remove=>{{rules.xpostlow.largestRepeat}} X-P => {{rules.loworopcomm.thresholdSummary}}"
|
||||
},
|
||||
//
|
||||
//
|
||||
{
|
||||
"kind": "remove",
|
||||
// remove the line below after confirming behavior is acceptable
|
||||
"dryRun": true
|
||||
},
|
||||
// optionally remove "dryRun" from below if you want to leave a comment on removal
|
||||
// PROTIP: the comment is bland, you should make it better
|
||||
{
|
||||
"kind": "comment",
|
||||
"content": "Your submission has been removed because you cross-posted it {{rules.xpostlow.largestRepeat}} times and you have very low engagement outside of making submissions",
|
||||
"distinguish": true,
|
||||
"dryRun": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
//
|
||||
// Remove submissions from users who have recent activity in freekarma subs within the last 50 activities or 6 months (whichever is less)
|
||||
//
|
||||
"name": "freekarma removal",
|
||||
"description": "Remove submission if user has used freekarma sub recently",
|
||||
"kind": "submission",
|
||||
"itemIs": [
|
||||
{
|
||||
"removed": false
|
||||
}
|
||||
],
|
||||
"condition": "AND",
|
||||
"rules": [
|
||||
{
|
||||
"name": "freekarma",
|
||||
"kind": "recentActivity",
|
||||
"window": {
|
||||
"count": 50,
|
||||
"duration": "6 months"
|
||||
},
|
||||
"useSubmissionAsReference": false,
|
||||
"thresholds": [
|
||||
{
|
||||
"subreddits": [
|
||||
"FreeKarma4U",
|
||||
"FreeKarma4You",
|
||||
"KarmaStore",
|
||||
"promote",
|
||||
"shamelessplug",
|
||||
"upvote"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
// remove this after confirming behavior is acceptable
|
||||
{
|
||||
"kind": "report",
|
||||
"content": "Remove=> {{rules.newtube.totalCount}} activities in freekarma subs"
|
||||
},
|
||||
//
|
||||
//
|
||||
{
|
||||
"kind": "remove",
|
||||
// remove the line below after confirming behavior is acceptable
|
||||
"dryRun": true
|
||||
},
|
||||
// optionally remove "dryRun" from below if you want to leave a comment on removal
|
||||
// PROTIP: the comment is bland, you should make it better
|
||||
{
|
||||
"kind": "comment",
|
||||
"content": "Your submission has been removed because you have recent activity in 'freekarma' subs",
|
||||
"distinguish": true,
|
||||
"dryRun": true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
polling:
|
||||
- unmoderated
|
||||
checks:
|
||||
# stop users who post low-effort, crossposted spam submissions
|
||||
#
|
||||
# Remove a SUBMISSION if the user has crossposted it at least 4 times in recent history AND
|
||||
# less than 50% of their activity is comments OR more than 40% of those comments are as OP (in the own submissions)
|
||||
- name: remove on low xp spam and engagement
|
||||
description: X-posted 4x and low comment engagement
|
||||
kind: submission
|
||||
itemIs:
|
||||
- removed: false
|
||||
condition: AND
|
||||
rules:
|
||||
- name: xPostLow
|
||||
kind: repeatActivity
|
||||
gapAllowance: 2
|
||||
threshold: '>= 4'
|
||||
window:
|
||||
count: 50
|
||||
duration: 6 months
|
||||
- name: lowOrOpComm
|
||||
kind: history
|
||||
criteriaJoin: OR
|
||||
criteria:
|
||||
- window:
|
||||
count: 100
|
||||
duration: 6 months
|
||||
comment: < 50%
|
||||
- window:
|
||||
count: 100
|
||||
duration: 6 months
|
||||
comment: '> 40% OP'
|
||||
actions:
|
||||
- kind: report
|
||||
enable: true
|
||||
content: >-
|
||||
Remove=>{{rules.xpostlow.largestRepeat}} X-P =>
|
||||
{{rules.loworopcomm.thresholdSummary}}
|
||||
- kind: remove
|
||||
enable: false
|
||||
- kind: comment
|
||||
enable: true
|
||||
content: >-
|
||||
Your submission has been removed because you cross-posted it
|
||||
{{rules.xpostlow.largestRepeat}} times and you have very low
|
||||
engagement outside of making submissions
|
||||
distinguish: true
|
||||
dryRun: true
|
||||
# Remove submissions from users who have recent activity in freekarma subs within the last 50 activities or 6 months (whichever is less)
|
||||
- name: freekarma removal
|
||||
description: Remove submission if user has used freekarma sub recently
|
||||
kind: submission
|
||||
itemIs:
|
||||
- removed: false
|
||||
condition: AND
|
||||
rules:
|
||||
- name: freekarma
|
||||
kind: recentActivity
|
||||
window:
|
||||
count: 50
|
||||
duration: 6 months
|
||||
useSubmissionAsReference: false
|
||||
thresholds:
|
||||
- subreddits:
|
||||
- FreeKarma4U
|
||||
- FreeKarma4You
|
||||
- KarmaStore
|
||||
- promote
|
||||
- shamelessplug
|
||||
- upvote
|
||||
actions:
|
||||
- kind: report
|
||||
enable: true
|
||||
content: 'Remove=> {{rules.newtube.totalCount}} activities in freekarma subs'
|
||||
- kind: remove
|
||||
enable: false
|
||||
- kind: comment
|
||||
enable: true
|
||||
content: >-
|
||||
Your submission has been removed because you have recent activity in
|
||||
'freekarma' subs
|
||||
distinguish: true
|
||||
dryRun: true
|
||||
@@ -1,64 +0,0 @@
|
||||
{
|
||||
"polling": [
|
||||
"unmoderated"
|
||||
],
|
||||
"checks": [
|
||||
{
|
||||
//
|
||||
// Remove submissions from users who have recent activity in freekarma subs within the last 50 activities or 6 months (whichever is less)
|
||||
//
|
||||
"name": "freekarma removal",
|
||||
"description": "Remove submission if user has used freekarma sub recently",
|
||||
"kind": "submission",
|
||||
"itemIs": [
|
||||
{
|
||||
"removed": false
|
||||
}
|
||||
],
|
||||
"condition": "AND",
|
||||
"rules": [
|
||||
{
|
||||
"name": "freekarma",
|
||||
"kind": "recentActivity",
|
||||
"window": {
|
||||
"count": 50,
|
||||
"duration": "6 months"
|
||||
},
|
||||
"useSubmissionAsReference": false,
|
||||
"thresholds": [
|
||||
{
|
||||
"subreddits": [
|
||||
"FreeKarma4U",
|
||||
"FreeKarma4You",
|
||||
"KarmaStore",
|
||||
"upvote"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
// remove this after confirming behavior is acceptable
|
||||
{
|
||||
"kind": "report",
|
||||
"content": "Remove=> {{rules.newtube.totalCount}} activities in freekarma subs"
|
||||
},
|
||||
//
|
||||
//
|
||||
{
|
||||
"kind": "remove",
|
||||
// remove the line below after confirming behavior is acceptable
|
||||
"dryRun": true,
|
||||
},
|
||||
// optionally remove "dryRun" from below if you want to leave a comment on removal
|
||||
// PROTIP: the comment is bland, you should make it better
|
||||
{
|
||||
"kind": "comment",
|
||||
"content": "Your submission has been removed because you have recent activity in 'freekarma' subs",
|
||||
"distinguish": true,
|
||||
"dryRun": true,
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
polling:
|
||||
- unmoderated
|
||||
checks:
|
||||
# Remove submissions from users who have recent activity in freekarma subs within the last 50 activities or 6 months (whichever is less)
|
||||
- name: freekarma removal
|
||||
description: Remove submission if user has used freekarma sub recently
|
||||
kind: submission
|
||||
itemIs:
|
||||
- removed: false
|
||||
condition: AND
|
||||
rules:
|
||||
- name: freekarma
|
||||
kind: recentActivity
|
||||
window:
|
||||
count: 50
|
||||
duration: 6 months
|
||||
useSubmissionAsReference: false
|
||||
thresholds:
|
||||
- subreddits:
|
||||
- FreeKarma4U
|
||||
- FreeKarma4You
|
||||
- KarmaStore
|
||||
- upvote
|
||||
actions:
|
||||
- kind: report
|
||||
enable: true
|
||||
content: 'Remove=> {{rules.newtube.totalCount}} activities in freekarma subs'
|
||||
- kind: remove
|
||||
enable: true
|
||||
- kind: comment
|
||||
enable: false
|
||||
content: >-
|
||||
Your submission has been removed because you have recent activity in
|
||||
'freekarma' subs
|
||||
distinguish: true
|
||||
@@ -1,104 +0,0 @@
|
||||
{
|
||||
"polling": [
|
||||
"unmoderated"
|
||||
],
|
||||
"checks": [
|
||||
{
|
||||
//
|
||||
// Stop users who make link submissions with a self-promotional agenda (with reddit's suggested 10% rule)
|
||||
// https://www.reddit.com/wiki/selfpromotion#wiki_guidelines_for_self-promotion_on_reddit
|
||||
//
|
||||
// Remove a SUBMISSION if the link comprises more than or equal to 10% of users history (100 activities or 6 months) OR
|
||||
//
|
||||
// if link comprises 10% of submission history (100 activities or 6 months)
|
||||
// AND less than 50% of their activity is comments OR more than 40% of those comments are as OP (in the own submissions)
|
||||
//
|
||||
"name": "Self-promo all AND low engagement",
|
||||
"description": "Self-promo is >10% for all or just sub and low comment engagement",
|
||||
"kind": "submission",
|
||||
"condition": "OR",
|
||||
"rules": [
|
||||
{
|
||||
"name": "attr",
|
||||
"kind": "attribution",
|
||||
"criteria": [
|
||||
{
|
||||
"threshold": ">= 10%",
|
||||
"window": {
|
||||
"count": 100,
|
||||
"duration": "6 months"
|
||||
},
|
||||
"domains": [
|
||||
"AGG:SELF"
|
||||
]
|
||||
}
|
||||
],
|
||||
},
|
||||
{
|
||||
"condition": "AND",
|
||||
"rules": [
|
||||
{
|
||||
"name": "attrsub",
|
||||
"kind": "attribution",
|
||||
"criteria": [
|
||||
{
|
||||
"threshold": ">= 10%",
|
||||
"thresholdOn": "submissions",
|
||||
"window": {
|
||||
"count": 100,
|
||||
"duration": "6 months"
|
||||
},
|
||||
"domains": [
|
||||
"AGG:SELF"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "lowOrOpComm",
|
||||
"kind": "history",
|
||||
"criteriaJoin": "OR",
|
||||
"criteria": [
|
||||
{
|
||||
"window": {
|
||||
"count": 100,
|
||||
"duration": "6 months"
|
||||
},
|
||||
"comment": "< 50%"
|
||||
},
|
||||
{
|
||||
"window": {
|
||||
"count": 100,
|
||||
"duration": "6 months"
|
||||
},
|
||||
"comment": "> 40% OP"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
{
|
||||
"kind": "report",
|
||||
"content": "{{rules.attr.largestPercent}}{{rules.attrsub.largestPercent}} of {{rules.attr.activityTotal}}{{rules.attrsub.activityTotal}} items ({{rules.attr.window}}{{rules.attrsub.window}}){{#rules.loworopcomm.thresholdSummary}} => {{rules.loworopcomm.thresholdSummary}}{{/rules.loworopcomm.thresholdSummary}}"
|
||||
},
|
||||
//
|
||||
//
|
||||
{
|
||||
"kind": "remove",
|
||||
// remove the line below after confirming behavior is acceptable
|
||||
"dryRun": true
|
||||
},
|
||||
// optionally remove "dryRun" from below if you want to leave a comment on removal
|
||||
// PROTIP: the comment is bland, you should make it better
|
||||
{
|
||||
"kind": "comment",
|
||||
"content": "Your submission has been removed it comprises 10% or more of your recent history ({{rules.attr.largestPercent}}{{rules.attrsub.largestPercent}}). This is against [reddit's self promotional guidelines.](https://www.reddit.com/wiki/selfpromotion#wiki_guidelines_for_self-promotion_on_reddit)",
|
||||
"distinguish": true,
|
||||
"dryRun": true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
polling:
|
||||
- unmoderated
|
||||
checks:
|
||||
#
|
||||
# Stop users who make link submissions with a self-promotional agenda (with reddit's suggested 10% rule)
|
||||
# https://www.reddit.com/wiki/selfpromotion#wiki_guidelines_for_self-promotion_on_reddit
|
||||
#
|
||||
# Remove a SUBMISSION if the link comprises more than or equal to 10% of users history (100 activities or 6 months) OR
|
||||
#
|
||||
# if link comprises 10% of submission history (100 activities or 6 months)
|
||||
# AND less than 50% of their activity is comments OR more than 40% of those comments are as OP (in the own submissions)
|
||||
#
|
||||
- name: Self-promo all AND low engagement
|
||||
description: Self-promo is >10% for all or just sub and low comment engagement
|
||||
kind: submission
|
||||
condition: OR
|
||||
rules:
|
||||
- name: attr
|
||||
kind: attribution
|
||||
criteria:
|
||||
- threshold: '>= 10%'
|
||||
window:
|
||||
count: 100
|
||||
duration: 6 months
|
||||
domains:
|
||||
- 'AGG:SELF'
|
||||
- condition: AND
|
||||
rules:
|
||||
- name: attrsub
|
||||
kind: attribution
|
||||
criteria:
|
||||
- threshold: '>= 10%'
|
||||
thresholdOn: submissions
|
||||
window:
|
||||
count: 100
|
||||
duration: 6 months
|
||||
domains:
|
||||
- 'AGG:SELF'
|
||||
- name: lowOrOpComm
|
||||
kind: history
|
||||
criteriaJoin: OR
|
||||
criteria:
|
||||
- window:
|
||||
count: 100
|
||||
duration: 6 months
|
||||
comment: < 50%
|
||||
- window:
|
||||
count: 100
|
||||
duration: 6 months
|
||||
comment: '> 40% OP'
|
||||
actions:
|
||||
- kind: report
|
||||
enable: true
|
||||
content: >-
|
||||
{{rules.attr.largestPercent}}{{rules.attrsub.largestPercent}} of
|
||||
{{rules.attr.activityTotal}}{{rules.attrsub.activityTotal}} items
|
||||
({{rules.attr.window}}{{rules.attrsub.window}}){{#rules.loworopcomm.thresholdSummary}}
|
||||
=>
|
||||
{{rules.loworopcomm.thresholdSummary}}{{/rules.loworopcomm.thresholdSummary}}
|
||||
- kind: remove
|
||||
enable: false
|
||||
- kind: comment
|
||||
enable: true
|
||||
content: >-
|
||||
Your submission has been removed it comprises 10% or more of your
|
||||
recent history
|
||||
({{rules.attr.largestPercent}}{{rules.attrsub.largestPercent}}). This
|
||||
is against [reddit's self promotional
|
||||
guidelines.](https://www.reddit.com/wiki/selfpromotion#wiki_guidelines_for_self-promotion_on_reddit)
|
||||
distinguish: true
|
||||
dryRun: true
|
||||
@@ -1,45 +0,0 @@
|
||||
{
|
||||
"checks": [
|
||||
{
|
||||
"name": "Self Promo Activities",
|
||||
"description": "Tag SP only if user does not have good contributor user note",
|
||||
// check will run on a new submission in your subreddit and look at the Author of that submission
|
||||
"kind": "submission",
|
||||
"rules": [
|
||||
{
|
||||
"name": "attr10all",
|
||||
"kind": "attribution",
|
||||
"author": {
|
||||
"exclude": [
|
||||
{
|
||||
// the key of the usernote type to look for https://github.com/toolbox-team/reddit-moderator-toolbox/wiki/Subreddit-Wikis%3A-usernotes#working-with-note-types
|
||||
// rule will not run if current usernote on Author is of type 'gooduser'
|
||||
"type": "gooduser"
|
||||
}
|
||||
]
|
||||
},
|
||||
"criteria": [
|
||||
{
|
||||
"threshold": "> 10%",
|
||||
"window": "90 days"
|
||||
},
|
||||
{
|
||||
"threshold": "> 10%",
|
||||
"window": 100
|
||||
}
|
||||
],
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
{
|
||||
"kind": "usernote",
|
||||
// the key of usernote type
|
||||
// https://github.com/toolbox-team/reddit-moderator-toolbox/wiki/Subreddit-Wikis%3A-usernotes#working-with-note-types
|
||||
"type": "spamwarn",
|
||||
// content is mustache templated as usual
|
||||
"content": "Self Promotion: {{rules.attr10all.titlesDelim}} {{rules.attr10sub.largestPercent}}%"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
checks:
|
||||
- name: Self Promo Activities
|
||||
description: Tag SP only if user does not have good contributor user note
|
||||
# check will run on a new submission in your subreddit and look at the Author of that submission
|
||||
kind: submission
|
||||
rules:
|
||||
- name: attr10all
|
||||
kind: attribution
|
||||
author:
|
||||
exclude:
|
||||
# the key of the usernote type to look for https://github.com/toolbox-team/reddit-moderator-toolbox/wiki/Subreddit-Wikis%3A-usernotes#working-with-note-types
|
||||
# rule will not run if current usernote on Author is of type 'gooduser'
|
||||
- type: gooduser
|
||||
criteria:
|
||||
- threshold: '> 10%'
|
||||
window: 90 days
|
||||
- threshold: '> 10%'
|
||||
window: 100
|
||||
actions:
|
||||
- kind: usernote
|
||||
# the key of usernote type
|
||||
# https://github.com/toolbox-team/reddit-moderator-toolbox/wiki/Subreddit-Wikis%3A-usernotes#working-with-note-types
|
||||
type: spamwarn
|
||||
# content is mustache templated
|
||||
content: >-
|
||||
Self Promotion: {{rules.attr10all.titlesDelim}}
|
||||
{{rules.attr10sub.largestPercent}}%
|
||||
@@ -1,36 +0,0 @@
|
||||
{
|
||||
"checks": [
|
||||
{
|
||||
"name": "Self Promo Activities",
|
||||
"description": "Check if any of Author's aggregated submission origins are >10% of entire history",
|
||||
// check will run on a new submission in your subreddit and look at the Author of that submission
|
||||
"kind": "submission",
|
||||
"rules": [
|
||||
{
|
||||
"name": "attr10all",
|
||||
"kind": "attribution",
|
||||
"criteria": [
|
||||
{
|
||||
"threshold": "> 10%",
|
||||
"window": "90 days"
|
||||
},
|
||||
{
|
||||
"threshold": "> 10%",
|
||||
"window": 100
|
||||
}
|
||||
],
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
{
|
||||
"kind": "usernote",
|
||||
// the key of usernote type
|
||||
// https://github.com/toolbox-team/reddit-moderator-toolbox/wiki/Subreddit-Wikis%3A-usernotes#working-with-note-types
|
||||
"type": "spamwarn",
|
||||
// content is mustache templated as usual
|
||||
"content": "Self Promotion: {{rules.attr10all.titlesDelim}} {{rules.attr10sub.largestPercent}}%"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
checks:
|
||||
- name: Self Promo Activities
|
||||
# check will run on a new submission in your subreddit and look at the Author of that submission
|
||||
description: >-
|
||||
Check if any of Author's aggregated submission origins are >10% of entire
|
||||
history
|
||||
kind: submission
|
||||
rules:
|
||||
- name: attr10all
|
||||
kind: attribution
|
||||
criteria:
|
||||
- threshold: '> 10%'
|
||||
window: 90 days
|
||||
- threshold: '> 10%'
|
||||
window: 100
|
||||
actions:
|
||||
- kind: usernote
|
||||
# the key of usernote type
|
||||
# https://github.com/toolbox-team/reddit-moderator-toolbox/wiki/Subreddit-Wikis%3A-usernotes#working-with-note-types
|
||||
type: spamwarn
|
||||
content: >-
|
||||
Self Promotion: {{rules.attr10all.titlesDelim}}
|
||||
{{rules.attr10sub.largestPercent}}%
|
||||
@@ -1,83 +0,0 @@
|
||||
This getting started guide is for **Operators** -- that is, someone who wants to run the actual software for a ContentMod bot. If you are a **Moderator** check out the [moderator getting started](/docs/gettingStartedMod.md) guide instead.
|
||||
|
||||
# Table of Contents
|
||||
|
||||
* [Installation](#installation)
|
||||
* [Docker](#docker-recommended)
|
||||
* [Locally](#locally)
|
||||
* [Heroku](#heroku-quick-deployhttpsherokucomabout)
|
||||
* [Bot Authentication](#bot-authentication)
|
||||
* [Instance Configuration](#instance-configuration)
|
||||
* [Run Your Bot and Start Moderating](#run-your-bot-and-start-moderating)
|
||||
|
||||
# Installation
|
||||
|
||||
In order to run a ContextMod instance you must first you must install it somewhere.
|
||||
|
||||
ContextMod can be run on almost any operating system but it is recommended to use Docker due to ease of deployment.
|
||||
|
||||
## Docker (Recommended)
|
||||
|
||||
PROTIP: Using a container management tool like [Portainer.io CE](https://www.portainer.io/products/community-edition) will help with setup/configuration tremendously.
|
||||
|
||||
### [Dockerhub](https://hub.docker.com/r/foxxmd/context-mod)
|
||||
|
||||
```
|
||||
foxxmd/context-mod:latest
|
||||
```
|
||||
|
||||
Adding **environmental variables** to your `docker run` command will pass them through to the app EX:
|
||||
```
|
||||
docker run -d -e "CLIENT_ID=myId" ... foxxmd/context-mod
|
||||
```
|
||||
|
||||
### Locally
|
||||
|
||||
Requirements:
|
||||
|
||||
* Typescript >=4.3.5
|
||||
* Node >=15
|
||||
|
||||
Clone this repository somewhere and then install from the working directory
|
||||
|
||||
```bash
|
||||
git clone https://github.com/FoxxMD/context-mod.git .
|
||||
cd context-mod
|
||||
npm install
|
||||
tsc -p .
|
||||
```
|
||||
|
||||
### [Heroku Quick Deploy](https://heroku.com/about)
|
||||
[](https://dashboard.heroku.com/new?template=https://github.com/FoxxMD/context-mod)
|
||||
|
||||
This template provides a **web** and **worker** dyno for heroku.
|
||||
|
||||
* **Web** -- Will run the bot **and** the web interface for ContextMod.
|
||||
* **Worker** -- Will run **just** the bot.
|
||||
|
||||
Be aware that Heroku's [free dyno plan](https://devcenter.heroku.com/articles/free-dyno-hours#dyno-sleeping) enacts some limits:
|
||||
|
||||
* A **Web** dyno will go to sleep (pause) after 30 minutes without web activity -- so your bot will ALSO go to sleep at this time
|
||||
* The **Worker** dyno **will not** go to sleep but you will NOT be able to access the web interface. You can, however, still see how Cm is running by reading the logs for the dyno.
|
||||
|
||||
If you want to use a free dyno it is recommended you perform first-time setup (bot authentication and configuration, testing, etc...) with the **Web** dyno, then SWITCH to a **Worker** dyno so it can run 24/7.
|
||||
|
||||
# Bot Authentication
|
||||
|
||||
Next you need to create a bot and authenticate it with Reddit. Follow the [bot authentication guide](/docs/botAuthentication.md) to complete this step.
|
||||
|
||||
# Instance Configuration
|
||||
|
||||
Finally, you must provide the credentials you received from the **Bot Authentication** step to the ContextMod instance you installed earlier. Refer to the [Operator Configuration](/docs/operatorConfiguration.md) guide to learn how this can be done as there are multiple approaches depending on how you installed the software.
|
||||
|
||||
Additionally, at this step you can also tweak many more settings and behavior concerning how your CM bot will operate.
|
||||
|
||||
# Run Your Bot and Start Moderating
|
||||
|
||||
Congratulations! You should now have a fully authenticated bot running on ContextMod software.
|
||||
|
||||
In order for your Bot to operate on reddit though it **must be a moderator in the subreddit you want it to run in.** This may be your own subreddit or someone else's.
|
||||
|
||||
**Note: ContextMod does not currently handle moderation invites automatically** and may never have this functionality. Due to the fact that many of its behaviors are api-heavy and that subreddits can control their own configuration the api and resource (cpu/memory) usage of a ContextMod instance can be highly variable. It therefore does not make sense to allow any/all subreddits to automatically have access to an instance through automatically accepting moderator invites. So...if you are planning to run a ContextMod instance for subreddits other than those you moderate you should establish solid trust with moderators of that subreddit as well as a solid line of communication in order to ensure their configurations can be tailored to best fit their needs and your resources.
|
||||
|
||||
Once you have logged in as your bot and manually accepted the moderator invite you will need to restart your ContextMod instance in order for these changes to take effect.
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
ContextMod supports comparing image content, for the purpose of detecting duplicates, with two different but complimentary systems. Image comparison behavior is available for the following rules:
|
||||
|
||||
* [Recent Activity](/docs/examples/recentActivity)
|
||||
* [Recent Activity](/docs/subreddit/components/recentActivity)
|
||||
* Repeat Activity (In-progress)
|
||||
|
||||
To enable comparisons reference the example below (at the top-level of your rule) and configure as needed:
|
||||
|
||||
BIN
docs/images/actionsEvents.png
Normal file
|
After Width: | Height: | Size: 36 KiB |
BIN
docs/images/botOperations.png
Normal file
|
After Width: | Height: | Size: 37 KiB |
BIN
docs/images/config/config.jpg
Normal file
|
After Width: | Height: | Size: 75 KiB |
BIN
docs/images/config/configUpdate.png
Normal file
|
After Width: | Height: | Size: 34 KiB |
BIN
docs/images/config/correctness.png
Normal file
|
After Width: | Height: | Size: 93 KiB |
BIN
docs/images/config/enable.png
Normal file
|
After Width: | Height: | Size: 84 KiB |
BIN
docs/images/config/errors.png
Normal file
|
After Width: | Height: | Size: 25 KiB |
BIN
docs/images/config/save.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
docs/images/config/syntax.png
Normal file
|
After Width: | Height: | Size: 44 KiB |
|
Before Width: | Height: | Size: 45 KiB After Width: | Height: | Size: 45 KiB |
BIN
docs/images/diagram-highlevel.jpg
Normal file
|
After Width: | Height: | Size: 111 KiB |
BIN
docs/images/editor.jpg
Normal file
|
After Width: | Height: | Size: 133 KiB |
BIN
docs/images/grafana.jpg
Normal file
|
After Width: | Height: | Size: 183 KiB |
BIN
docs/images/guests.jpg
Normal file
|
After Width: | Height: | Size: 38 KiB |
BIN
docs/images/logs.png
Normal file
|
After Width: | Height: | Size: 133 KiB |
BIN
docs/images/oauth-invite.jpg
Normal file
|
After Width: | Height: | Size: 137 KiB |
BIN
docs/images/oauth.jpg
Normal file
|
After Width: | Height: | Size: 158 KiB |
BIN
docs/images/runInput.png
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
docs/images/subredditInvite.jpg
Normal file
|
After Width: | Height: | Size: 141 KiB |
BIN
docs/images/subredditStatus.jpg
Normal file
|
After Width: | Height: | Size: 225 KiB |
BIN
docs/logo.png
Normal file
|
After Width: | Height: | Size: 18 KiB |
78
docs/operator/README.md
Normal file
@@ -0,0 +1,78 @@
|
||||
# Operator Guide
|
||||
|
||||
An **Operator** is the user **running the ContextMod software.**
|
||||
|
||||
They are responsible for configuring the software at a high-level and managing associated infrastructure such as:
|
||||
|
||||
* Creating cache/database servers and configuring their connections in CM
|
||||
* Provisioning the [Reddit Clients](#provisioning-a-reddit-client) needed to run bots and the CM UI
|
||||
* Providing [global-level configuration](/docs/operator/configuration.md) that affects general bot/subreddit behavior
|
||||
* Onboarding new bots/subreddits
|
||||
|
||||
# Table of Contents
|
||||
|
||||
* [Overview](#overview)
|
||||
* [Client-Server Architecture](/docs/serverClientArchitecture.md)
|
||||
* [Getting Started](/docs/operator/gettingStarted.md)
|
||||
* [Installation](/docs/operator/installation.md)
|
||||
* [Provisioning a Reddit Client](#provisioning-a-reddit-client)
|
||||
* [Configuration](/docs/operator/configuration.md)
|
||||
* [Adding A Bot](/docs/operator/addingBot.md)
|
||||
|
||||
# Overview
|
||||
|
||||
CM is composed of two applications that operate independently but are packaged together such that they act as one piece of software:
|
||||
|
||||
* **Server** -- Responsible for **running the bot(s)** and providing an API to retrieve information on and interact with them EX start/stop bot, reload config, retrieve operational status, etc.
|
||||
* **Client** -- Responsible for serving the **web interface** and handling the bot oauth authentication flow between operators and subreddits/bots.
|
||||
|
||||
Both applications authenticate, and are primarily operated, by using [Reddit's API through OAuth.](https://github.com/reddit-archive/reddit/wiki/OAuth2) The **Client** uses OAuth to verify the identity of moderators logging into the web interface. The **Server** uses oauth tokens to interact with Reddit's API and operate all the configured bots.
|
||||
|
||||
In its default mode of operation CM takes care of all the interaction between **Server** and **Client** for you so that you can effectively treat it as a monolithic application. Learn more about CM's architecture and other operation modes in the [Server-Client Architecture documentation.](/docs/serverClientArchitecture.md)
|
||||
|
||||
# [Getting Started](/docs/operator/gettingStarted.md)
|
||||
|
||||
The [Getting Started](/docs/operator/gettingStarted.md) guide serves as a straight-forward "how-to" for standing up a CM server from scratch with minimal explanation.
|
||||
|
||||
# [Installation](/docs/operator/installation.md)
|
||||
|
||||
CM has many installation options:
|
||||
|
||||
* Locally, from source, as a typescript project
|
||||
* Built/pulled from a Docker image hosted on Dockerhub
|
||||
* Deployed to Heroku with a Quick Deploy template (experimental)
|
||||
|
||||
Refer to the [Installation](/docs/operator/installation.md) docs for more information.
|
||||
|
||||
# Provisioning A Reddit Client
|
||||
|
||||
As mentioning in the [Overview](#overview), CM operates primarily using Reddit's API through OAuth. You must create a [Reddit Client](https://github.com/reddit-archive/reddit/wiki/OAuth2#getting-started) in order to interact with the API.
|
||||
|
||||
## Create Application
|
||||
|
||||
Visit [your reddit preferences](https://www.reddit.com/prefs/apps) and at the bottom of the page go through the **create an(other) app** process.
|
||||
|
||||
* Give it a **name**
|
||||
* Choose **web app**
|
||||
* If you know what you will use for **redirect uri** go ahead and use it, otherwise use `http://localhost:8085/callback`
|
||||
|
||||
Click **create app**.
|
||||
|
||||
Then write down your **Client ID, Client Secret, and Redirect Uri** somewhere
|
||||
|
||||
# [Configuration](/docs/operator/configuration.md)
|
||||
|
||||
The [Configuration](/docs/operator/configuration.md) documentation covers:
|
||||
|
||||
* How CM's configuration can be defined
|
||||
* How to create and define location for a config file
|
||||
* Running CM from the command line
|
||||
* Documentation for configuration on Bots, the web client, API, and more...
|
||||
|
||||
# [Adding A Bot](/docs/operator/addingBot.md)
|
||||
|
||||
The [Adding A Bot](/docs/operator/addingBot.md) documentation covers:
|
||||
|
||||
* What is a Bot?
|
||||
* What is needed to add a Bot to CM?
|
||||
* Different approaches to authenticating and adding a Bot to CM
|
||||
86
docs/operator/addingBot.md
Normal file
@@ -0,0 +1,86 @@
|
||||
# Table of Contents
|
||||
|
||||
* [What is a Bot?](#what-is-a-bot)
|
||||
* [Prerequisites](#Prerequisites)
|
||||
* [Adding a Bot to CM](#adding-a-bot-to-cm)
|
||||
* [Using CM OAuth Helper (Recommended)](#cm-oauth-helper-recommended)
|
||||
* [Using Aardvark OAuth Helper](#aardvark-oauth-helper)
|
||||
|
||||
# What is a Bot?
|
||||
|
||||
A **reddit bot** is composed of two components:
|
||||
|
||||
* A normal **reddit account** like `u/MyRedditAccount`
|
||||
* Software that performs actions **on behalf of that reddit account** using Reddit's API
|
||||
|
||||
There is nothing special about the account! What's special is how its used -- through the API *with bot software* like ContextMod.
|
||||
|
||||
# Prerequisites
|
||||
|
||||
These things need to be done before a Bot can be added to CM:
|
||||
|
||||
* [Provisioned a Reddit Client](/docs/operator/README.md#provisioning-a-reddit-client)
|
||||
* You or the person who controls the Bot account must have account credentials (username/password). Logging in to reddit is part of the setup process.
|
||||
* If the bot does not exist **create a reddit account for it.**
|
||||
* If the bot does exist make sure you are in communication with the owner of the account.
|
||||
|
||||
# Adding A Bot to CM
|
||||
|
||||
## CM OAuth Helper (Recommended)
|
||||
|
||||
This method will use CM's built in oauth flow. It is recommended because:
|
||||
|
||||
* It's easy!
|
||||
* Will ensure your bot is authenticated with the correct oauth permissions
|
||||
|
||||
### Start CM with the Minimum Configuration (Initial Setup)
|
||||
|
||||
If this is your **first time adding a bot** you must make sure you have
|
||||
|
||||
* done the [prerequisites](#prerequisites)
|
||||
* created a [minimum operator configuration](/docs/operator/configuration.md#minimum-config)
|
||||
* that specifies the client id/secret from provisioning your reddit client
|
||||
* specified **Operator Name** in the configuration
|
||||
|
||||
It is important you define **Operator Name** because the auth route is **protected.** You must login to CM's web interface in order to access the route.
|
||||
|
||||
### Create A Bot Invite
|
||||
|
||||
Open the CM web interface (default is [http://localhost:8085](http://localhost:8085)) and login with the reddit account specified in **Operator Name.**
|
||||
|
||||
If this is your first time setting up a bot you should be automatically redirected to the auth page. Otherwise, visit [http://localhost:8085/auth/helper](http://localhost:8085/auth/helper)
|
||||
|
||||
Follow the directions in the helper to create a **Bot Invite Link.**
|
||||
|
||||
### Onboard the Bot
|
||||
|
||||
Visit the **Bot Invite Link** while **logged in to reddit as the bot account** to begin the onboarding process. Refer to the [Onboarding Your Bot]() subreddit documentation for more information on this process.
|
||||
|
||||
At the end of the onboarding process the bot should be automatically added to your operator configuration. If there is an issue with automatically adding it then the oauth credentials will be displayed at the end of onboarding and can be [manually added to the configuration.](/docs/operator/configuration.md#manually-adding-a-bot)
|
||||
|
||||
## Aardvark OAuth Helper
|
||||
|
||||
This method should only be used if you cannot use the [CM OAuth Helper method.](#cm-oauth-helper-recommended)
|
||||
|
||||
* Visit [https://not-an-aardvark.github.io/reddit-oauth-helper/](https://not-an-aardvark.github.io/reddit-oauth-helper/) and follow the instructions given.
|
||||
* **Note:** You will need to update the **redirect uri** you set when [provisioning your reddit client.](/docs/operator/README.md#provisioning-a-reddit-client)
|
||||
* Input your **Client ID** and **Client Secret** in the text boxes with those names.
|
||||
* Choose scopes. **It is very important you check everything on this list or CM may not work correctly**
|
||||
* edit
|
||||
* flair
|
||||
* history
|
||||
* identity
|
||||
* modcontributors
|
||||
* modflair
|
||||
* modposts
|
||||
* modself
|
||||
* modnote
|
||||
* mysubreddits
|
||||
* read
|
||||
* report
|
||||
* submit
|
||||
* wikiread
|
||||
* wikiedit (if you are using Toolbox User Notes)
|
||||
* Click **Generate tokens**, you will get a popup asking you to approve access (or login) -- **the account you approve access with is the account that Bot will control.**
|
||||
* After approving an **Access Token** and **Refresh Token** will be shown at the bottom of the page. Use these to [manually add a bot to your operator configuration.](/docs/operator/configuration.md#manually-adding-a-bot)
|
||||
* After adding the bot you will need to restart CM.
|
||||
161
docs/operator/caching.md
Normal file
@@ -0,0 +1,161 @@
|
||||
# Table of Contents
|
||||
|
||||
* [Overview](#overview)
|
||||
* [What Is Cache?](#what-is-cache)
|
||||
* [How CM Uses Caching](#how-cm-uses-caching)
|
||||
* [Reddit API Calls](#reddit-api-calls)
|
||||
* [Rules and Filters](#rules-and-filters)
|
||||
* [Configuration](#configuration)
|
||||
* [Cache Provider](#cache-provider)
|
||||
|
||||
# Overview
|
||||
|
||||
**Caching** is a major factor in CM's performance and optimization of Reddit API usage. Leveraging caching effectively in your operator configuration and in individual subreddit configurations can make or break your CM instance.
|
||||
|
||||
### What Is Cache?
|
||||
|
||||
A **Cache** is a storage medium with high **write** and **read** speed that is generally used to store **temporary, but frequently accessed data.**
|
||||
|
||||
## How CM Uses Caching
|
||||
|
||||
CM primarily **caches** two types of data:
|
||||
|
||||
### Reddit API Calls
|
||||
|
||||
#### How Reddit's API Works
|
||||
|
||||
In order to communicate with Reddit to retrieve posts, comments, user information, etc... CM uses API calls. Each API call is composed of a
|
||||
|
||||
* **request** -- CM asks Reddit for certain information
|
||||
* **response** -- Reddit responds with the request information
|
||||
|
||||
[Reddit imposes an **api quota**](https://github.com/reddit-archive/reddit/wiki/API#rules) on every **individual account** using the API through an application. This quota is **600 requests per 10 minutes.** At the end of the 10 minutes period the quota is reset.
|
||||
|
||||
Additionally, some API calls have limits on how much data they can return. The most relevant of these is **user history can only be returned 100 activities (submission/comments) per API call**. EX if you want to get **500** activities from a user's history you will need to make **5** api calls.
|
||||
|
||||
#### Caching API Responses
|
||||
|
||||
In order to most effectively use the limited quota of API calls CM will **automatically cache API responses based on the "fingerprint" of the request sent.**
|
||||
|
||||
On an individual "item" basis that means these resources are always cached:
|
||||
|
||||
* General user information (name, karma, age, profile description, etc..)
|
||||
* General subreddit information (name, nsfw, quarantined, etc...)
|
||||
* Individually processed activities (comment body, is comment author op, submission title, reports, link, etc...)
|
||||
|
||||
Additionally (and most importantly), responses for **user history** are cached **based on what was requested**. Example "fingerprint":
|
||||
|
||||
* username
|
||||
* type of activities to retrieve (overview, only submissions, only comments)
|
||||
* range of activities to retrieve (last 100, last 6 months, etc...)
|
||||
|
||||
If the above "fingerprint" is used in three different Rules then
|
||||
|
||||
* First fingerprint appearance -> CM make API call and caches response
|
||||
* Second fingerprint appearance -> CM uses cached response
|
||||
* Third fingerprint appearance -> CM uses cached response
|
||||
|
||||
So only **one** API call is made even though the history is used three times.
|
||||
|
||||
It is therefore **important to re-use window criteria** wherever possible to take advantage of this caching.
|
||||
|
||||
### Rules and Filters
|
||||
|
||||
Once CM has processed a Rule or Filter (`itemIs` or `authorIs`) the results of that component is stored in cache. For Rules the result is stored for the lifecycle of the Activity being processed and then discarded. For Filters the result is stored for a short time in cache and can be re-used by other Activities.
|
||||
|
||||
Re-using Rules and Filters by either using the exact same configuration or by using **names** provides:
|
||||
|
||||
* A major performance benefit since these do not need to be re-calculated
|
||||
* A low-to-medium optimization on API caching, depending on what criteria are being tested.
|
||||
|
||||
In general re-use should always be a goal.
|
||||
|
||||
# Configuration
|
||||
|
||||
## Cache Provider
|
||||
|
||||
CM supports two cache **providers**. By default all providers use `memory`:
|
||||
|
||||
* `memory` -- in-memory (non-persistent) backend
|
||||
* Cache will be lost when CM is restarted/exits
|
||||
* `redis` -- [Redis](https://redis.io/) backend
|
||||
|
||||
Each `provider` object in configuration can be specified as:
|
||||
|
||||
* one of the above **strings** to use the **defaults settings** or
|
||||
* an **object** with keys to override default settings
|
||||
|
||||
[Refer to full documentation on cache providers in the schema](https://json-schema.app/view/%23/%23%2Fdefinitions%2FOperatorCacheConfig/%23%2Fdefinitions%2FCacheOptions?url=https%3A%2F%2Fraw.githubusercontent.com%2FFoxxMD%2Fcontext-mod%2Fmaster%2Fsrc%2FSchema%2FOperatorConfig.json)
|
||||
|
||||
Some examples:
|
||||
|
||||
```json5
|
||||
{
|
||||
"provider": {
|
||||
"store": "memory", // one of "memory" or "redis"
|
||||
"ttl": 60, // the default max age of a key in seconds
|
||||
"max": 500, // the maximum number of keys in the cache (for "memory" only)
|
||||
|
||||
// the below properties only apply to 'redis' provider
|
||||
"host": 'localhost',
|
||||
"port": 6379,
|
||||
"auth_pass": null,
|
||||
"db": 0,
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
YAML
|
||||
|
||||
```yaml
|
||||
provider:
|
||||
store: redis
|
||||
ttl: 60
|
||||
max: 500
|
||||
host: localhost
|
||||
port: 6379
|
||||
auth_pass: null
|
||||
db: 0
|
||||
```
|
||||
|
||||
Providers can be specified in multiple locations, with each more specific location overriding the parent-level config:
|
||||
|
||||
* top-level config
|
||||
* in individual bot configurations
|
||||
* in the web config
|
||||
|
||||
```yaml
|
||||
operator:
|
||||
name: example
|
||||
# top level
|
||||
caching:
|
||||
provider:
|
||||
...
|
||||
bots:
|
||||
- name: u/MyBot
|
||||
# overrides top level
|
||||
caching:
|
||||
provider:
|
||||
...
|
||||
web:
|
||||
# overrides top level
|
||||
caching:
|
||||
provider:
|
||||
...
|
||||
```
|
||||
|
||||
## Cache TTL
|
||||
|
||||
The **Time To Live (TTL)** -- how long data may live in the cache before "expiring" -- can be controlled indepedently for different data types. Sane defaults are provided for all types but tweaking these can improve API caching optimization depending on the subreddit's configuration (use case).
|
||||
|
||||
Each of these can be specified in the `caching` property. TTL is measured in seconds.
|
||||
|
||||
* `authorTTL` (default 60) -- user activity (overview, submissions, comments)
|
||||
* `commentTTL` (default 60) -- individually fetched comments
|
||||
* `submissionTTL` (default 60) -- individually fetched submissions
|
||||
* `filterCriteriaTTL` (default 60) -- filter results (`itemIs` and `authorIs`)
|
||||
* `selfTTL` (default 60) -- actions performed by the bot (creating comment reply, report). If action is in cache the bot ignores it if found during polling.
|
||||
* This helps prevent bot from reacting to things it did itself IE you don't want it to remove a comment because it reported the comment itself
|
||||
* `subredditTTL` (default 60) -- general information on fetched subreddit
|
||||
* `userNotesTTL` (default 300) -- Amount of time [Toolbox User Notes](https://www.reddit.com/r/toolbox/wiki/docs/usernotes) are cached
|
||||
* `wikiTTL` (default 300) -- Wiki pages used for content (in messages, reports, bans, etc...) are cached for this amount of time
|
||||
@@ -2,32 +2,23 @@ The **Operator** configuration refers to configuration used configure to the act
|
||||
from the **Subreddit** configuration that is defined in each Subreddit's wiki and determines the rules/actions for
|
||||
activities the Bot runs on.
|
||||
|
||||
**The full documentation** for all options in the operator configuration can be found [**here in the operator schema.**](https://json-schema.app/view/%23?url=https%3A%2F%2Fraw.githubusercontent.com%2FFoxxMD%2Fcontext-mod%2Fmaster%2Fsrc%2FSchema%2FOperatorConfig.json)
|
||||
|
||||
# Table of Contents
|
||||
|
||||
* [Minimum Required Configuration](#minimum-required-configuration)
|
||||
* [Defining Configuration](#defining-configuration)
|
||||
* [CLI Usage](#cli-usage)
|
||||
* [Minimum Configuration](#minimum-configuration)
|
||||
* [Bots](#bots)
|
||||
* [Examples](#example-configurations)
|
||||
* [Minimum Config](#minimum-config)
|
||||
* [Using Config Overrides](#using-config-overrides)
|
||||
* [Cache Configuration](#cache-configuration)
|
||||
|
||||
# Minimum Required Configuration
|
||||
|
||||
| property | Server And Web | Server Only | Web/Bot-Auth Only |
|
||||
|:--------------:|:------------------:|:------------------:|:------------------:|
|
||||
| `clientId` | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
|
||||
| `clientSecret` | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
|
||||
| `redirectUri` | :heavy_check_mark: | :x: | :heavy_check_mark: |
|
||||
| `refreshToken` | :heavy_check_mark: | :heavy_check_mark: | :x: |
|
||||
| `accessToken` | :heavy_check_mark: | :heavy_check_mark: | :x: |
|
||||
|
||||
Refer to the **[Bot Authentication guide](/docs/botAuthentication.md)** to retrieve credentials.
|
||||
* [Database Configuration](#database-configuration)
|
||||
|
||||
# Defining Configuration
|
||||
|
||||
CM can be configured using **any or all** of the approaches below. Note that **at each level ALL configuration values are
|
||||
optional** but the "required configuration" mentioned above must be available when all levels are combined.
|
||||
CM can be configured using **any or all** of the approaches below. **It is recommended to use FILE ([File Configuration](#file-configuration-recommended))**
|
||||
|
||||
Any values defined at a **lower-listed** level of configuration will override any values from a higher-listed
|
||||
configuration.
|
||||
@@ -35,18 +26,37 @@ configuration.
|
||||
* **ENV** -- Environment variables loaded from an [`.env`](https://github.com/toddbluhm/env-cmd) file (path may be
|
||||
specified with `--file` cli argument)
|
||||
* **ENV** -- Any already existing environment variables (exported on command line/terminal profile/etc.)
|
||||
* **FILE** -- Values specified in a JSON configuration file using the structure [in the schema](https://json-schema.app/view/%23?url=https%3A%2F%2Fraw.githubusercontent.com%2FFoxxMD%2Fcontext-mod%2Fmaster%2Fsrc%2FSchema%2FOperatorConfig.json)
|
||||
* **FILE** -- Values specified in a YAML/JSON configuration file using the structure [in the schema](https://json-schema.app/view/%23?url=https%3A%2F%2Fraw.githubusercontent.com%2FFoxxMD%2Fcontext-mod%2Fmaster%2Fsrc%2FSchema%2FOperatorConfig.json)
|
||||
* When reading the **schema** if the variable is available at a level of configuration other than **FILE** it will be
|
||||
noted with the same symbol as above. The value shown is the default.
|
||||
* **ARG** -- Values specified as CLI arguments to the program (see [ClI Usage](#cli-usage) below)
|
||||
|
||||
**Note:** When reading the **schema** if the variable is available at a level of configuration other than **FILE** it will be
|
||||
noted with the same symbol as above. The value shown is the default.
|
||||
## File Configuration (Recommended)
|
||||
|
||||
* To load a JSON configuration (for **FILE**) **from the command line** use the `-c` cli argument EX: `node src/index.js -c /path/to/JSON/config.json`
|
||||
* To load a JSON configuration (for **FILE**) **using an environmental variable** use `OPERATOR_CONFIG` EX: `OPERATOR_CONFIG=/path/to/JSON/config.json`
|
||||
Using a file has many benefits over using ARG or ENV:
|
||||
|
||||
[**See the Operator Config Schema here**](https://json-schema.app/view/%23?url=https%3A%2F%2Fraw.githubusercontent.com%2FFoxxMD%2Fcontext-mod%2Fmaster%2Fsrc%2FSchema%2FOperatorConfig.json)
|
||||
* CM can automatically update your configuration
|
||||
* CM can automatically add bots via the [CM OAuth Helper](/docs/operator/addingBot.md#cm-oauth-helper-recommended)
|
||||
* CM has a built-in configuration editor that can help you build and validate your configuration file
|
||||
* File config is **required** if adding multiple bots to CM
|
||||
|
||||
## Defining Multiple Bots or CM Instances
|
||||
### Specify File Location
|
||||
|
||||
By default CM will look for `config.yaml` or `config.json` in the `DATA_DIR` directory:
|
||||
|
||||
* [Local installation](/docs/operator/installation.md#locally) -- `DATA_DIR` is the root of your installation directory (same folder as `package.json`)
|
||||
* [Docker](/docs/operator/installation.md#docker-recommended) -- `DATA_DIR` is at `/config` in the container
|
||||
|
||||
The `DATA_DIR` directory can be changed by passing `DATA_DIR` as an environmental variable EX `DATA_DIR=/path/to/directory`
|
||||
|
||||
The name of the config file can be changed by passing `OPERATOR_CONFIG` as an environmental variable:
|
||||
|
||||
* As filename -- `OPERATOR_CONFIG=myConfig.yaml` -> CM looks for `/path/to/directory/myConfig.yaml`
|
||||
* As absolute path -- `OPERATOR_CONFIG=/a/path/myConfig.yaml` -> CM looks for `/a/path/myConfig.yaml`
|
||||
|
||||
[**Refer to the Operator Config File Schema for full documentation**](https://json-schema.app/view/%23?url=https%3A%2F%2Fraw.githubusercontent.com%2FFoxxMD%2Fcontext-mod%2Fmaster%2Fsrc%2FSchema%2FOperatorConfig.json)
|
||||
|
||||
### Defining Multiple Bots or CM Instances
|
||||
|
||||
One ContextMod instance can
|
||||
|
||||
@@ -112,6 +122,87 @@ Options:
|
||||
|
||||
</details>
|
||||
|
||||
# Minimum Configuration
|
||||
|
||||
The minimum configuration required to run CM assumes you have no bots and want to use CM to [add your first bot.](/docs/operator/addingBot.md#cm-oauth-helper-recommended)
|
||||
|
||||
You will need have this information available:
|
||||
|
||||
* From [provision a reddit client](/docs/operator/README.md#provisioning-a-reddit-client)
|
||||
* Client ID
|
||||
* Client Secret
|
||||
* Redirect URI (if different from default `http://localhost:8085/callback`)
|
||||
* Operator Name -- username of the reddit account you want to use to administer CM with
|
||||
|
||||
See the [**example minimum configuration** below.](#minimum-config)
|
||||
|
||||
This configuration can also be **generated** by CM if you start CM with **no configuration defined** and visit the web interface.
|
||||
|
||||
# Bots
|
||||
|
||||
Configured using the `bots` top-level property. Bot configuration can override and specify many more options than are available at the operator-level. Many of these can also set the defaults for each subreddit the bot runs:
|
||||
|
||||
* Of the subreddits this bot moderates, specify a subset of subreddits to run or exclude from running
|
||||
* default caching behavior
|
||||
* control the soft/hard api usage limits
|
||||
* Flow Control defaults
|
||||
* Filter Criteria defaults
|
||||
* default Polling behavior
|
||||
|
||||
[Full documentation for all bot instance options can be found in the schema.](https://json-schema.app/view/%23/%23%2Fdefinitions%2FBotInstanceJsonConfig?url=https%3A%2F%2Fraw.githubusercontent.com%2FFoxxMD%2Fcontext-mod%2Fmaster%2Fsrc%2FSchema%2FOperatorConfig.json)
|
||||
|
||||
## Adding A Bot
|
||||
|
||||
If you use the [CM OAuth Helper](/docs/operator/addingBot.md#cm-oauth-helper-recommended) and it works successfully then the configuration for the Bot will be automatically added.
|
||||
|
||||
### Manually Adding a Bot
|
||||
|
||||
Add a new *object* to the `bots` property at the top-level of your configuration. If `bots` does not exist create it now.
|
||||
|
||||
Minimum information required for a valid bot:
|
||||
|
||||
* Client Id
|
||||
* Client Secret
|
||||
* Refresh Token
|
||||
* Access Token
|
||||
|
||||
<details>
|
||||
<summary>Example</summary>
|
||||
|
||||
```yaml
|
||||
operator:
|
||||
name: YourRedditUsername
|
||||
|
||||
bots:
|
||||
- name: u/MyRedditBot # name is optional but highly recommend for readability in both config and web interface
|
||||
credentials:
|
||||
reddit:
|
||||
clientId: f4b4df1c7b2
|
||||
clientSecret: 34v5q1c56ub
|
||||
accessToken: 34_f1w1v4
|
||||
refreshToken: p75_1c467b2
|
||||
|
||||
web:
|
||||
credentials:
|
||||
clientId: f4b4df1c7b2
|
||||
clientSecret: 34v5q1c56ub
|
||||
redirectUri: 'http://localhost:8085/callback'
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
# Web Client
|
||||
|
||||
Configured using the `web` top-level property. Allows specifying settings related to:
|
||||
|
||||
* UI port
|
||||
* Database and caching connection, if different from global settings
|
||||
* Session max age and secret
|
||||
* Invite max age
|
||||
* Connections to CM API instances (if using multiple)
|
||||
|
||||
[Full documentation for all web settings can be found in the schema.](https://json-schema.app/view/%23/%23%2Fproperties%2Fweb?url=https%3A%2F%2Fraw.githubusercontent.com%2FFoxxMD%2Fcontext-mod%2Fmaster%2Fsrc%2FSchema%2FOperatorConfig.json)
|
||||
|
||||
# Example Configurations
|
||||
|
||||
## Minimum Config
|
||||
@@ -119,30 +210,37 @@ Options:
|
||||
Below are examples of the minimum required config to run the application using all three config approaches independently.
|
||||
|
||||
Using **FILE**
|
||||
|
||||
<details>
|
||||
|
||||
YAML
|
||||
See [Specify File Location](#specify-file-location) for where this file would be located.
|
||||
|
||||
YAML (`config.yaml`)
|
||||
|
||||
```yaml
|
||||
bots:
|
||||
- credentials:
|
||||
clientId: f4b4df1c7b2
|
||||
clientSecret: 34v5q1c56ub
|
||||
refreshToken: 34_f1w1v4
|
||||
accessToken: p75_1c467b2
|
||||
operator:
|
||||
name: YourRedditUsername
|
||||
web:
|
||||
credentials:
|
||||
clientId: f4b4df1c7b2
|
||||
clientSecret: 34v5q1c56ub
|
||||
redirectUri: 'http://localhost:8085/callback'
|
||||
```
|
||||
JSON
|
||||
|
||||
JSON (`config.json5`)
|
||||
|
||||
```json5
|
||||
{
|
||||
"bots": [
|
||||
{
|
||||
"credentials": {
|
||||
"clientId": "f4b4df1c7b2",
|
||||
"clientSecret": "34v5q1c56ub",
|
||||
"refreshToken": "34_f1w1v4",
|
||||
"accessToken": "p75_1c467b2"
|
||||
}
|
||||
"operator": {
|
||||
"name": "YourRedditUsername"
|
||||
},
|
||||
"web": {
|
||||
"credentials": {
|
||||
"clientId": "f4b4df1c7b2",
|
||||
"clientSecret": "34v5q1c56ub",
|
||||
"redirectUri": "http://localhost:8085/callback"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
@@ -153,10 +251,10 @@ Using **ENV** (`.env`)
|
||||
<details>
|
||||
|
||||
```
|
||||
OPERATOR=YourRedditUsername
|
||||
CLIENT_ID=f4b4df1c7b2
|
||||
CLIENT_SECRET=34v5q1c56ub
|
||||
REFRESH_TOKEN=34_f1w1v4
|
||||
ACCESS_TOKEN=p75_1c467b2
|
||||
REDIRECT_URI=http://localhost:8085/callback
|
||||
```
|
||||
|
||||
</details>
|
||||
@@ -166,7 +264,7 @@ Using **ARG**
|
||||
<details>
|
||||
|
||||
```
|
||||
node src/index.js run --clientId=f4b4df1c7b2 --clientSecret=34v5q1c56ub --refreshToken=34_f1w1v4 --accessToken=p75_1c467b2
|
||||
node src/index.js run --clientId=f4b4df1c7b2 --clientSecret=34v5q1c56ub --redirectUri=http://localhost:8085/callback
|
||||
```
|
||||
|
||||
</details>
|
||||
@@ -176,6 +274,7 @@ node src/index.js run --clientId=f4b4df1c7b2 --clientSecret=34v5q1c56ub --refres
|
||||
An example of using multiple configuration levels together IE all are provided to the application:
|
||||
|
||||
**FILE**
|
||||
|
||||
<details>
|
||||
|
||||
```json
|
||||
@@ -185,7 +284,9 @@ An example of using multiple configuration levels together IE all are provided t
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
YAML
|
||||
|
||||
```yaml
|
||||
logging:
|
||||
level: debug
|
||||
@@ -199,8 +300,6 @@ logging:
|
||||
|
||||
```
|
||||
CLIENT_SECRET=34v5q1c56ub
|
||||
REFRESH_TOKEN=34_f1w1v4
|
||||
ACCESS_TOKEN=p75_1c467b2
|
||||
SUBREDDITS=sub1,sub2,sub3
|
||||
PORT=9008
|
||||
```
|
||||
@@ -222,8 +321,6 @@ When all three are used together they produce these variables at runtime for the
|
||||
```
|
||||
clientId: f4b4df1c7b2
|
||||
clientSecret: 34v5q1c56ub
|
||||
refreshToken: 34_f1w1v4
|
||||
accessToken: accessToken
|
||||
subreddits: sub1
|
||||
port: 9008
|
||||
log level: debug
|
||||
@@ -236,6 +333,7 @@ See the [Architecture Docs](/docs/serverClientArchitecture.md) for more informat
|
||||
<details>
|
||||
|
||||
YAML
|
||||
|
||||
```yaml
|
||||
bots:
|
||||
- credentials:
|
||||
@@ -258,7 +356,9 @@ web:
|
||||
api:
|
||||
secret: localSecret
|
||||
```
|
||||
|
||||
JSON
|
||||
|
||||
```json5
|
||||
{
|
||||
"bots": [
|
||||
@@ -301,41 +401,8 @@ JSON
|
||||
|
||||
# Cache Configuration
|
||||
|
||||
CM implements two caching backend **providers**. By default all providers use `memory`:
|
||||
See the [Cache Configuration](/docs/operator/caching.md) documentation.
|
||||
|
||||
* `memory` -- in-memory (non-persistent) backend
|
||||
* `redis` -- [Redis](https://redis.io/) backend
|
||||
# Database Configuration
|
||||
|
||||
Each `provider` object in configuration can be specified as:
|
||||
|
||||
* one of the above **strings** to use the **defaults settings** or
|
||||
* an **object** with keys to override default settings
|
||||
|
||||
A caching object in the json configuration:
|
||||
|
||||
```json5
|
||||
{
|
||||
"provider": {
|
||||
"store": "memory", // one of "memory" or "redis"
|
||||
"ttl": 60, // the default max age of a key in seconds
|
||||
"max": 500, // the maximum number of keys in the cache (for "memory" only)
|
||||
|
||||
// the below properties only apply to 'redis' provider
|
||||
"host": 'localhost',
|
||||
"port": 6379,
|
||||
"auth_pass": null,
|
||||
"db": 0,
|
||||
}
|
||||
}
|
||||
```
|
||||
YAML
|
||||
```yaml
|
||||
provider:
|
||||
store: memory
|
||||
ttl: 60
|
||||
max: 500
|
||||
host: localhost
|
||||
port: 6379
|
||||
auth_pass: null
|
||||
db: 0
|
||||
```
|
||||
See the [Database Configuration](/docs/operator/database.md) documentation.
|
||||
188
docs/operator/database.md
Normal file
@@ -0,0 +1,188 @@
|
||||
# Overview
|
||||
|
||||
CM uses a database to store three types of data:
|
||||
|
||||
* **Recorded Events** -- an "audit" of how CM processed an Activity (Comment/Submission) and what actions it took based on the result of processing it (comment, report, remove, etc.)
|
||||
* Persistent Settings/Data
|
||||
* Settings like the last known state of a Subreddit's bot before the application exited
|
||||
* Web Client sessions and invites -- stuff that should survive a restart
|
||||
* Statistics
|
||||
* All-time and time-series high-level statistics like # of events, # of checks run, etc...
|
||||
|
||||
CM does NOT store subreddit configurations or any runtime alterations of these configurations. This is to keep configurations **portable** -- on principle, if you (a moderator) choose to use a different CM instance to run your subreddit's bot then it should not function differently.
|
||||
|
||||
# Providers
|
||||
|
||||
CM uses [TypeORM](https://typeorm.io/) as the database access layer and specifically supports three database types:
|
||||
|
||||
* SQLite -- using either [SQL.js](https://sql.js.org) or native SQLite through [better-sqlite3](https://github.com/JoshuaWise/better-sqlite3)
|
||||
* MySQL/MariaDB
|
||||
* Postgres
|
||||
|
||||
The database configuration is specified in the top-level `databaseConfig.connection` property in the operator configuration. EX:
|
||||
|
||||
```yaml
|
||||
operator:
|
||||
name: u/MyRedditAccount
|
||||
databaseConfig:
|
||||
connection:
|
||||
...
|
||||
```
|
||||
|
||||
## SQLite
|
||||
|
||||
When using a [local installation](/docs/installation.md#locally) the default database is `sqljs`, which requires no binary dependencies. When using [docker](/docs/operator/installation.md#docker-recommended) the default is `better-sqlite3`.
|
||||
|
||||
**NOTE:** It is **NOT RECOMMENDED** to use `sqljs` in a production environment for performance reasons. You should at least switch to `better-sqlite3` or preferably MySql/Postgres.
|
||||
|
||||
* [`sqljs` connection options](https://typeorm.io/data-source-options#sqljs-data-source-options)
|
||||
* [`better-sqlite3` connection options](https://typeorm.io/data-source-options#better-sqlite3-data-source-options)
|
||||
|
||||
For both sqlite types, if no database/location is specified, it will be created in the [`DATA_DIR` directory.](/docs/operator/configuration.md#specify-file-location)
|
||||
|
||||
If CM detects it cannot **read and write** to the database files, or directory if no files exist, it will fallback to using an in-memory database that will be lost when CM restarts. If you have trouble with r/w permissions and are using docker make sure [file permissions are correct for your mounted volume.](/docs/operator/installation.md#linux-host)
|
||||
|
||||
## MySQL/MariaDB
|
||||
|
||||
[MySQL/MariaDB connection options](https://typeorm.io/data-source-options#mysql--mariadb-data-source-options)
|
||||
|
||||
The `database` you specify should exist before using CM.
|
||||
|
||||
## Postgres
|
||||
|
||||
[Postgres connection options](https://typeorm.io/data-source-options#postgres--cockroachdb-data-source-options)
|
||||
|
||||
The `database` and `schema` you specify should exist before using CM.
|
||||
|
||||
# Migrations
|
||||
|
||||
CM implements database migrations. On startup it will check for any pending migrations. If the database doesn't exist (sqlite) or is empty or no tables conflict it will automatically execute migrations.
|
||||
|
||||
If there is any kind of conflict it will **pause startup** and display a prompt in the user interface to confirm migration execution. **You should always backup your database before running migrations.**
|
||||
|
||||
To force CM to always run migrations without confirmation set `force` to `true` in the `migrations` property within `databaseConfig`:
|
||||
|
||||
```yaml
|
||||
databaseConfig:
|
||||
migrations:
|
||||
force: true # always run migrations
|
||||
```
|
||||
|
||||
### SQLite
|
||||
|
||||
When using a SQLite driver CM can create automatic backups for you. Another prompt will be displayed on the migrations page in the web interface to make a copy of your database. You can make CM automatically backup and continue with migrations like so:
|
||||
|
||||
```yaml
|
||||
databaseConfig:
|
||||
migrations:
|
||||
continueOnAutomatedBackup: true # try to backup sqlite files automatically and continue with migrations if successful
|
||||
```
|
||||
|
||||
# Recorded Event Retention
|
||||
|
||||
The **Recorded Events** CM stores in the database can be controlled per subreddit. By default events will be stored indefinitely.
|
||||
|
||||
A **Retention Policy** is a metric to determine what "range" of Recorded Events CM should keep in the database. It can be either:
|
||||
|
||||
* A **number** -- The last X number of Recorded Events will be kept
|
||||
* EX `1000` -> Keep the last 1000 events and discard any others.
|
||||
* A **duration** -- A time period, starting from now until X `duration` in the past, for which events will be kept
|
||||
* EX `3 months` -> Keep all events created between now and 3 months ago. Anything older than 3 months ago will be discarded.
|
||||
|
||||
The Retention Policy can be specified at operator level, bot, subreddit *override*, and subreddit configuration level:
|
||||
|
||||
```yaml
|
||||
operator:
|
||||
name: u/MyRedditAccount
|
||||
databaseConfig:
|
||||
retention: '3 months' # each subreddit will retain 3 more of recorded events
|
||||
bots:
|
||||
# all subreddits this bot moderates will have 3 month retention
|
||||
- name: u/OneBotAccount
|
||||
credentials:
|
||||
...
|
||||
subreddits:
|
||||
overrides:
|
||||
- name: aSpecialSubredit
|
||||
databaseConfig:
|
||||
# overrides retention for THIS SUBBREDIT ONLY, will retain last 1000 events
|
||||
# -- also overrides any retention set in the subreddit's actual configuration
|
||||
retention: 1000
|
||||
|
||||
- name: u/TwoBotAccount
|
||||
credentials:
|
||||
...
|
||||
databaseConfig:
|
||||
retention: '1 month' # overrides top-level rentention for all subeddits this bot moderates
|
||||
```
|
||||
|
||||
In a subreddit's config:
|
||||
|
||||
```yaml
|
||||
polling:
|
||||
- unmoderated
|
||||
|
||||
# will retain last 2000 events
|
||||
# -- will override top-level operator retention or bot-specific retention
|
||||
# -- will NOT override a subreddit override specified in bot coniguration
|
||||
retention: 2000
|
||||
|
||||
runs:
|
||||
...
|
||||
```
|
||||
|
||||
# Influx
|
||||
|
||||
ContextMod supports writing detailed time-series data to [InfluxDB](https://www.influxdata.com/).
|
||||
|
||||
This data can be used to monitor the overall health, performance, and metrics for a ContextMod server. Currently, this data can **only be used by an Operator** as it requires access to the operator configuration and CM instance.
|
||||
|
||||
CM supports InfluxDB OSS > 2.3 or InfluxDB Cloud.
|
||||
|
||||
**Note:** This is an **advanced feature** and assumes you have enough technical knowledge to follow the documentation provided by each application to deploy and configure them. No support is guaranteed for installation, configuration, or use of Influx and Grafana.
|
||||
|
||||
## Supported Metrics
|
||||
|
||||
TBA
|
||||
|
||||
## Setup
|
||||
|
||||
### InfluxDB OSS
|
||||
|
||||
* Install [InfluxDB](https://docs.influxdata.com/influxdb/v2.3/install/)
|
||||
* [Configure InfluxDB using the UI](https://docs.influxdata.com/influxdb/v2.3/install/#set-up-influxdb-through-the-ui)
|
||||
* You will need **Username**, **Password**, **Organization Name**, and **Bucket Name** later for Grafana setup so make sure to record them somewhere
|
||||
* [Create a Token](https://docs.influxdata.com/influxdb/v2.3/security/tokens/create-token/) with enough permissions to write/read to the bucket you configured
|
||||
* After the token is created **view/copy the token** to clipboard by clicking the token name. You will need this for Grafana setup.
|
||||
|
||||
### ContextMod
|
||||
|
||||
Add the following block to the top-level of your operator configuration:
|
||||
|
||||
```yaml
|
||||
influxConfig:
|
||||
credentials:
|
||||
url: 'http://localhost:8086' # URL to your influx DB instance
|
||||
token: '9RtZ5YZ6bfEXAMPLENJsTSKg==' # token created in the previous step
|
||||
org: MyOrg # organization created in the previous step
|
||||
bucket: contextmod # name of the bucket created in the previous step
|
||||
```
|
||||
|
||||
## Grafana
|
||||
|
||||
A pre-built dashboard for [Grafana](https://grafana.com) can be imported to display overall metrics/stats using InfluxDB data.
|
||||
|
||||

|
||||
|
||||
* Create a new Data Source using **InfluxDB** type
|
||||
* Choose **Flux** for the **Query Language**
|
||||
* Fill in the details for **URL**, **Basic Auth Details** and **InfluxDB Details** using the data you created in the [Influx Setup step](#influxdb-oss)
|
||||
* Set **Min time interval** to `60s`
|
||||
* Click **Save and test**
|
||||
* Import Dashboard
|
||||
* **Browse** the Dashboard pane
|
||||
* Click **Import** and **upload** the [grafana dashboard json file](/docs/operator/grafana.json)
|
||||
* Chose the data source you created from the **InfluxDB CM** dropdown
|
||||
* Click **Import**
|
||||
|
||||
The dashboard can be filtered by **Bots** and **Subreddits** dropdowns at the top of the page to get more specific details.
|
||||