Compare commits
26 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ba53233640 | ||
|
|
1ac7ad4724 | ||
|
|
2a282a0d6f | ||
|
|
fd5a92758d | ||
|
|
39daa11f2d | ||
|
|
dac6541e28 | ||
|
|
97906281e6 | ||
|
|
487f13f704 | ||
|
|
631e21452c | ||
|
|
4f3685a1f5 | ||
|
|
d2d945db2c | ||
|
|
910f7f79ef | ||
|
|
a11b667d5e | ||
|
|
885e3fa765 | ||
|
|
465c3c9acf | ||
|
|
161251a943 | ||
|
|
ce4cb96d9a | ||
|
|
c317f95953 | ||
|
|
d0e0515990 | ||
|
|
cdddd8de48 | ||
|
|
f598215d88 | ||
|
|
0c7218571c | ||
|
|
acc7c49e0e | ||
|
|
01839512d5 | ||
|
|
4680640b0c | ||
|
|
b813ebdd96 |
@@ -1,24 +1,8 @@
|
||||
Dockerfile
|
||||
.dockerignore
|
||||
.gitignore
|
||||
.git
|
||||
logs
|
||||
src/logs
|
||||
.github
|
||||
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
|
||||
/docs/
|
||||
/node_modules/
|
||||
|
||||
2
.github/FUNDING.yml
vendored
@@ -1,2 +0,0 @@
|
||||
github: [FoxxMD]
|
||||
custom: ["bitcoincash:qqmpsh365r8n9jhp4p8ks7f7qdr7203cws4kmkmr8q"]
|
||||
3
.github/push-hook-sample.json
vendored
@@ -1,3 +0,0 @@
|
||||
{
|
||||
"ref": "refs/heads/edge"
|
||||
}
|
||||
@@ -1,14 +1,4 @@
|
||||
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
|
||||
name: Publish Docker image to Dockerhub
|
||||
|
||||
on:
|
||||
push:
|
||||
@@ -23,12 +13,8 @@ on:
|
||||
|
||||
jobs:
|
||||
push_to_registry:
|
||||
name: Build and Push Docker image to registries
|
||||
name: Push Docker image to Docker Hub
|
||||
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
|
||||
@@ -39,22 +25,12 @@ 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
|
||||
ghcr.io/foxxmd/context-mod
|
||||
images: foxxmd/context-mod
|
||||
# generate Docker tags based on the following events/attributes
|
||||
tags: |
|
||||
type=raw,value=latest,enable=${{ endsWith(github.ref, 'master') }}
|
||||
@@ -64,8 +40,7 @@ jobs:
|
||||
latest=false
|
||||
|
||||
- name: Build and push Docker image
|
||||
if: ${{ !env.ACT }}
|
||||
uses: docker/build-push-action@v3
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
context: .
|
||||
push: ${{ github.event_name != 'pull_request' }}
|
||||
15
.gitignore
vendored
@@ -336,7 +336,6 @@ web_modules/
|
||||
# dotenv environment variables file
|
||||
.env
|
||||
.env.test
|
||||
*.env
|
||||
|
||||
# parcel-bundler cache (https://parceljs.org/)
|
||||
.cache
|
||||
@@ -382,17 +381,5 @@ dist
|
||||
.pnp.*
|
||||
|
||||
**/src/**/*.js
|
||||
**/tests/**/*.js
|
||||
**/tests/**/*.map
|
||||
!src/Web/assets/**
|
||||
!src/Web/assets/public/yaml/*
|
||||
**/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,13 +2,10 @@
|
||||
<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" />
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
{
|
||||
"require": ["./register.js", "source-map-support/register"],
|
||||
"reporter": "dot"
|
||||
}
|
||||
24
.nycrc.json
@@ -1,24 +0,0 @@
|
||||
{
|
||||
"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,133 +1,41 @@
|
||||
FROM lsiobase/alpine:3.15 as base
|
||||
FROM node:16-alpine3.14 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
|
||||
|
||||
ARG data_dir=/config
|
||||
VOLUME $data_dir
|
||||
ENV DATA_DIR=$data_dir
|
||||
|
||||
COPY docker/root/ /
|
||||
|
||||
WORKDIR /app
|
||||
WORKDIR /usr/app
|
||||
|
||||
FROM base as build
|
||||
|
||||
COPY --chown=abc:abc package*.json ./
|
||||
COPY --chown=abc:abc tsconfig.json .
|
||||
COPY package*.json ./
|
||||
COPY tsconfig.json .
|
||||
|
||||
RUN npm install
|
||||
|
||||
COPY --chown=abc:abc . /app
|
||||
ADD . /usr/app
|
||||
|
||||
RUN npm run build && rm -rf node_modules
|
||||
|
||||
FROM base as app
|
||||
|
||||
COPY --from=build --chown=abc:abc /app /app
|
||||
COPY --from=build /usr/app /usr/app
|
||||
|
||||
RUN npm install --production \
|
||||
&& npm cache clean --force \
|
||||
&& chown abc:abc node_modules \
|
||||
&& rm -rf node_modules/ts-node \
|
||||
&& rm -rf node_modules/typescript
|
||||
RUN npm install --production
|
||||
|
||||
ENV NPM_CONFIG_LOGLEVEL debug
|
||||
|
||||
# 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 log_dir=/home/node/logs
|
||||
RUN mkdir -p $log_dir
|
||||
VOLUME $log_dir
|
||||
ENV LOG_DIR=$log_dir
|
||||
|
||||
ARG webPort=8085
|
||||
ENV PORT=$webPort
|
||||
EXPOSE $PORT
|
||||
|
||||
# convenience variable for more helpful error messages
|
||||
ENV IS_DOCKER=true
|
||||
|
||||
CMD [ "node", "src/index.js", "run" ]
|
||||
|
||||
93
README.md
@@ -1,52 +1,38 @@
|
||||
# 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">
|
||||
[](https://github.com/FoxxMD/context-mod/releases)
|
||||
[](https://opensource.org/licenses/MIT)
|
||||
[](https://hub.docker.com/r/foxxmd/context-mod)
|
||||
|
||||
**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:
|
||||
An example of the above that Context Bot can do now:
|
||||
|
||||
> * 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.
|
||||
|
||||
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)
|
||||
Some feature highlights:
|
||||
* Simple rule-action behavior can be combined to create any level of complexity in behavior
|
||||
* Server/client architecture
|
||||
* 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
|
||||
* 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)
|
||||
* **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
|
||||
|
||||
# Table of Contents
|
||||
|
||||
@@ -59,7 +45,7 @@ Feature highlights for **Developers and Hosting (Operators):**
|
||||
|
||||
Each subreddit using the RCB bot configures its behavior via their own wiki page.
|
||||
|
||||
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 :
|
||||
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 :
|
||||
|
||||
#### Kind
|
||||
|
||||
@@ -67,11 +53,11 @@ Is this check for a submission or comment?
|
||||
|
||||
#### Rules
|
||||
|
||||
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**
|
||||
A list of **Rule** objects to run against the **Activity**. Triggered Rules can cause the whole Check to trigger and run its **Actions**
|
||||
|
||||
#### Actions
|
||||
|
||||
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.
|
||||
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.
|
||||
|
||||
___
|
||||
|
||||
@@ -81,7 +67,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/README.md#how-it-works)
|
||||
[Learn more about the RCB lifecycle and core concepts in the docs.](/docs#how-it-works)
|
||||
|
||||
## Getting Started
|
||||
|
||||
@@ -89,20 +75,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/operator/gettingStarted.md)
|
||||
See the [Operator's Getting Started Guide](/docs/gettingStartedOperator.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/subreddit/gettingStarted.md)
|
||||
See the [Moderator's Getting Started Guide](/docs/gettingStartedMod.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/operator/configuration.md) guide
|
||||
* For **moderators** consult the [app schema and examples folder](/docs/README.md#configuration-and-usage)
|
||||
* 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)
|
||||
|
||||
[**Check the full docs for in-depth explanations of all concepts and examples**](/docs)
|
||||
|
||||
@@ -122,23 +108,19 @@ 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/operator/addingBot.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/botAuthentication.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
|
||||
|
||||
@@ -151,14 +133,7 @@ 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
|
||||
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
GITHUB_TOKEN=
|
||||
DOCKERHUB_USERNAME=
|
||||
DOCKER_PASSWORD=
|
||||
@@ -1,14 +0,0 @@
|
||||
#!/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/*
|
||||
@@ -1,9 +0,0 @@
|
||||
#!/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
|
||||
339
docs/README.md
@@ -5,119 +5,104 @@
|
||||
* [Getting Started](#getting-started)
|
||||
* [How It Works](#how-it-works)
|
||||
* [Concepts](#concepts)
|
||||
* [Event](#event)
|
||||
* [Activity](#activity)
|
||||
* [Run](#runs)
|
||||
* [Check](#checks)
|
||||
* [Rule](#rule)
|
||||
* [Available Rules](#available-rules)
|
||||
* [Examples](#available-rules)
|
||||
* [Rule Set](#rule-set)
|
||||
* [Examples](#rule-set-examples)
|
||||
* [Action](#action)
|
||||
* [Available Actions](#available-actions)
|
||||
* [Examples](#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/operator/gettingStarted.md) guide
|
||||
* For **Moderators** (configuring an existing bot for your subreddit) refer to the [**Moderator Getting Started**](/docs/subreddit/gettingStarted.md) guide
|
||||
* 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
|
||||
|
||||
## 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 Activity in your subreddit is received by CM
|
||||
#### 1) A new event in your subreddit is received by CM
|
||||
|
||||
The Activities CM watches for are configured by you. These can be new modqueue/unmoderated items, submissions, or comments.
|
||||
The events CM watches for are configured by you. These can be new modqueue/unmoderated items, submissions, or comments.
|
||||
|
||||
#### 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
|
||||
#### 2) CM sequentially processes each Check in your configuration
|
||||
|
||||
A **Check** is a set of:
|
||||
|
||||
* 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**
|
||||
* 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**
|
||||
|
||||
#### 4) Each Check is processed, *in order*, until a Check is **triggered**
|
||||
#### 3) Each Check is processed, *in order*, until a Check is triggered
|
||||
|
||||
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.
|
||||
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.
|
||||
|
||||
#### 5) All Actions from the triggered Check are executed
|
||||
#### 4) All Actions from that Check are executed
|
||||
|
||||
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.
|
||||
After all Actions are executed CM returns to waiting for the next Event.
|
||||
|
||||
## 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 composed of:
|
||||
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:
|
||||
|
||||
* One or more **Rules** that are tested against an **Activity**
|
||||
* One of more **Actions** that are performed when the **Rules** are satisfied
|
||||
|
||||
A Run can be made up of one or more **Checks** that are processed **in the order they are listed in the Run.**
|
||||
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.**
|
||||
|
||||
Once a Check is **triggered** (its Rules are satisfied and Actions performed) all subsequent Checks are skipped.
|
||||
|
||||
[Full Documentation for Checks](/docs/subreddit/components/README.md#checks)
|
||||
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)
|
||||
|
||||
### 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.
|
||||
|
||||
[Full Documentation for Rules](/docs/subreddit/components/README.md#rules)
|
||||
|
||||
#### Available Rules
|
||||
Find detailed descriptions of all the Rules, with examples, below:
|
||||
|
||||
All available rules can be found in the [components documentation](/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)
|
||||
|
||||
### Rule Set
|
||||
|
||||
@@ -127,7 +112,34 @@ 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".
|
||||
|
||||
[Rule Sets Documentation](/docs/subreddit/components/README.md#rule-sets)
|
||||
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)
|
||||
|
||||
### Action
|
||||
|
||||
@@ -135,28 +147,207 @@ An **Action** is some action the bot can take against the checked Activity (comm
|
||||
|
||||
#### Available Actions
|
||||
|
||||
[Available Actions Documentation](/docs/subreddit/components/README.md#list-of-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)
|
||||
|
||||
### Filters
|
||||
|
||||
**Runs, Checks, Rules, and Actions** all have two additional (optional) criteria "pre-tests". These tests are different from rules/checks in these ways:
|
||||
**Checks, Rules, and Actions** all have two additional (optional) criteria "tests". These tests behave differently than rule/check triggers in that:
|
||||
|
||||
* 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**.
|
||||
* When they **pass** the thing being tested continues to process as usual
|
||||
* When they **fail** the thing being tested **is skipped, not failed.**
|
||||
|
||||
[Full Documentation for Filters](/docs/subreddit/components/README.md#filters)
|
||||
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)
|
||||
|
||||
## Configuration And Usage
|
||||
|
||||
* For **Operator/Bot maintainers** see **[Operation Guide](/docs/operator/README.md)**
|
||||
* For **Operator/Bot maintainers** see **[Operation Configuration](/docs/operatorConfiguration.md)**
|
||||
* [CLI Usage](docs/operatorConfiguration.md#cli-usage)
|
||||
* For **Moderators**
|
||||
* 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
|
||||
* 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
|
||||
* 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
|
||||
|
||||
|
||||
72
docs/actionTemplating.md
Normal file
@@ -0,0 +1,72 @@
|
||||
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."
|
||||
|
||||
```
|
||||
304
docs/activitiesWindow.md
Normal file
@@ -0,0 +1,304 @@
|
||||
# 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.
|
||||
109
docs/botAuthentication.md
Normal file
@@ -0,0 +1,109 @@
|
||||
**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.
|
||||
@@ -1,392 +0,0 @@
|
||||
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>
|
||||
28
docs/examples/README.md
Normal file
@@ -0,0 +1,28 @@
|
||||
# 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)
|
||||
* [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)
|
||||
56
docs/examples/advancedConcepts/README.md
Normal file
@@ -0,0 +1,56 @@
|
||||
### 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.
|
||||
75
docs/examples/advancedConcepts/ruleNameReuse.json5
Normal file
@@ -0,0 +1,75 @@
|
||||
{
|
||||
"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}}"
|
||||
}
|
||||
]
|
||||
},
|
||||
]
|
||||
}
|
||||
52
docs/examples/advancedConcepts/ruleNameReuse.yaml
Normal file
@@ -0,0 +1,52 @@
|
||||
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}}
|
||||
84
docs/examples/advancedConcepts/ruleSets.json5
Normal file
@@ -0,0 +1,84 @@
|
||||
{
|
||||
"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"
|
||||
}
|
||||
]
|
||||
},
|
||||
],
|
||||
}
|
||||
53
docs/examples/advancedConcepts/ruleSets.yaml
Normal file
@@ -0,0 +1,53 @@
|
||||
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
|
||||
@@ -10,5 +10,5 @@ Consult the [schema](https://json-schema.app/view/%23/%23%2Fdefinitions%2FCheckJ
|
||||
|
||||
### Examples
|
||||
|
||||
* Self Promotion as percentage of all Activities [YAML](/docs/subreddit/componentscomponents/attribution/redditSelfPromoAll.yaml) | [JSON](/docs/subreddit/componentscomponents/attribution/redditSelfPromoAll.json5) - Check if Author is submitting much more than they comment.
|
||||
* Self Promotion as percentage of Submissions [YAML](/docs/subreddit/components/attribution/redditSelfPromoSubmissionsOnly.yaml) | [JSON](/docs/examplesm/attribution/redditSelfPromoSubmissionsOnly.json5) - Check if any of Author's aggregated submission origins are >10% of their submissions
|
||||
* Self Promotion as percentage of all Activities [YAML](/docs/examples/attribution/redditSelfPromoAll.yaml) | [JSON](/docs/examples/attribution/redditSelfPromoAll.json5) - Check if Author is submitting much more than they comment.
|
||||
* Self Promotion as percentage of Submissions [YAML](/docs/examples/attribution/redditSelfPromoSubmissionsOnly.yaml) | [JSON](/docs/examplesm/attribution/redditSelfPromoSubmissionsOnly.json5) - Check if any of Author's aggregated submission origins are >10% of their submissions
|
||||
39
docs/examples/attribution/redditSelfPromoAll.json5
Normal file
@@ -0,0 +1,39 @@
|
||||
{
|
||||
"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}}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
27
docs/examples/attribution/redditSelfPromoAll.yaml
Normal file
@@ -0,0 +1,27 @@
|
||||
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}}
|
||||
24
docs/examples/attribution/redditSelfPromoSubmissionOnly.yaml
Normal file
@@ -0,0 +1,24 @@
|
||||
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}}
|
||||
@@ -0,0 +1,40 @@
|
||||
{
|
||||
"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}}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
38
docs/examples/author/README.md
Normal file
@@ -0,0 +1,38 @@
|
||||
# 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.
|
||||
69
docs/examples/author/authorFilter.json5
Normal file
@@ -0,0 +1,69 @@
|
||||
{
|
||||
"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"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
48
docs/examples/author/authorFilter.yaml
Normal file
@@ -0,0 +1,48 @@
|
||||
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
|
||||
29
docs/examples/author/flairNewUserSubmission.json5
Normal file
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"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"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
16
docs/examples/author/flairNewUserSubmission.yaml
Normal file
@@ -0,0 +1,16 @@
|
||||
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
|
||||
29
docs/examples/author/flairVettedUserSubmission.json5
Normal file
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"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"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
16
docs/examples/author/flairVettedUserSubmission.yaml
Normal file
@@ -0,0 +1,16 @@
|
||||
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
|
||||
75
docs/examples/author/ignoreVettedUser.json5
Normal file
@@ -0,0 +1,75 @@
|
||||
{
|
||||
"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"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
45
docs/examples/author/ignoreVettedUser.yaml
Normal file
@@ -0,0 +1,45 @@
|
||||
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,7 +1,6 @@
|
||||
# History
|
||||
|
||||
The **History** rule can check an Author's submission/comment statistics over a time period:
|
||||
|
||||
* Submission total or percentage of All Activity
|
||||
* Comment total or percentage of all Activity
|
||||
* Comments made as OP (commented in their own Submission) total or percentage of all Comments
|
||||
@@ -10,5 +9,5 @@ Consult the [schema](https://json-schema.app/view/%23%2Fdefinitions%2FHistoryJSO
|
||||
|
||||
### Examples
|
||||
|
||||
* Low Comment Engagement [YAML](/docs/subreddit/componentscomponents/history/lowEngagement.yaml) | [JSON](/docs/subreddit/componentscomponents/history/lowEngagement.json5) - Check if Author is submitting much more than they comment.
|
||||
* OP Comment Engagement [YAML](/docs/subreddit/componentscomponents/history/opOnlyEngagement.yaml) | [JSON](/docs/subreddit/componentscomponents/history/opOnlyEngagement.json5) - Check if Author is mostly engaging only in their own content
|
||||
* Low Comment Engagement [YAML](/docs/examples/history/lowEngagement.yaml) | [JSON](/docs/examples/history/lowEngagement.json5) - Check if Author is submitting much more than they comment.
|
||||
* OP Comment Engagement [YAML](/docs/examples/history/opOnlyEngagement.yaml) | [JSON](/docs/examples/history/opOnlyEngagement.json5) - Check if Author is mostly engaging only in their own content
|
||||
30
docs/examples/history/lowEngagement.json5
Normal file
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"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}}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
21
docs/examples/history/lowEngagement.yaml
Normal file
@@ -0,0 +1,21 @@
|
||||
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}}
|
||||
30
docs/examples/history/opOnlyEngagement.json5
Normal file
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"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"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
22
docs/examples/history/opOnlyEngagement.yaml
Normal file
@@ -0,0 +1,22 @@
|
||||
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
|
||||
10
docs/examples/recentActivity/README.md
Normal file
@@ -0,0 +1,10 @@
|
||||
# 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
|
||||
40
docs/examples/recentActivity/freeKarma.json5
Normal file
@@ -0,0 +1,40 @@
|
||||
{
|
||||
"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}}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
27
docs/examples/recentActivity/freeKarma.yaml
Normal file
@@ -0,0 +1,27 @@
|
||||
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}}
|
||||
41
docs/examples/recentActivity/freeKarmaOnSubmission.json5
Normal file
@@ -0,0 +1,41 @@
|
||||
{
|
||||
"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}}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
26
docs/examples/recentActivity/freeKarmaOnSubmission.yaml
Normal file
@@ -0,0 +1,26 @@
|
||||
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}}
|
||||
@@ -11,12 +11,12 @@ Which can then be used in conjunction with a [`window`](https://github.com/FoxxM
|
||||
|
||||
### Examples
|
||||
|
||||
* Trigger if regex matches against the current activity - [YAML](/docs/subreddit/componentscomponents/regex/matchAnyCurrentActivity.yaml) | [JSON](/docs/subreddit/componentscomponents/regex/matchAnyCurrentActivity.json5)
|
||||
* Trigger if regex matches 5 times against the current activity - [YAML](/docs/subreddit/componentscomponents/regex/matchThresholdCurrentActivity.yaml) | [JSON](/docs/subreddit/componentscomponents/regex/matchThresholdCurrentActivity.json5)
|
||||
* Trigger if regex matches against any part of a Submission - [YAML](/docs/subreddit/componentscomponents/regex/matchSubmissionParts.yaml) | [JSON](/docs/subreddit/componentscomponents/regex/matchSubmissionParts.json5)
|
||||
* Trigger if regex matches any of Author's last 10 activities - [YAML](/docs/subreddit/componentscomponents/regex/matchHistoryActivity.yaml) | [JSON](/docs/subreddit/componentscomponents/regex/matchHistoryActivity.json5)
|
||||
* Trigger if regex matches at least 3 of Author's last 10 activities - [YAML](/docs/subreddit/componentscomponents/regex/matchActivityThresholdHistory.json5) | [JSON](/docs/subreddit/componentscomponents/regex/matchActivityThresholdHistory.json5)
|
||||
* Trigger if there are 5 regex matches in the Author's last 10 activities - [YAML](/docs/subreddit/componentscomponents/regex/matchTotalHistoryActivity.yaml) | [JSON](/docs/subreddit/componentscomponents/regex/matchTotalHistoryActivity.json5)
|
||||
* Trigger if there are 5 regex matches in the Author's last 10 comments - [YAML](/docs/subreddit/componentscomponents/regex/matchSubsetHistoryActivity.yaml) | [JSON](/docs/subreddit/componentscomponents/regex/matchSubsetHistoryActivity.json5)
|
||||
* Remove comments that are spamming discord links - [YAML](/docs/subreddit/componentscomponents/regex/removeDiscordSpam.yaml) | [JSON](/docs/subreddit/componentscomponents/regex/removeDiscordSpam.json5)
|
||||
* Trigger if regex matches against the current activity - [YAML](/docs/examples/regex/matchAnyCurrentActivity.yaml) | [JSON](/docs/examples/regex/matchAnyCurrentActivity.json5)
|
||||
* Trigger if regex matches 5 times against the current activity - [YAML](/docs/examples/regex/matchThresholdCurrentActivity.yaml) | [JSON](/docs/examples/regex/matchThresholdCurrentActivity.json5)
|
||||
* Trigger if regex matches against any part of a Submission - [YAML](/docs/examples/regex/matchSubmissionParts.yaml) | [JSON](/docs/examples/regex/matchSubmissionParts.json5)
|
||||
* Trigger if regex matches any of Author's last 10 activities - [YAML](/docs/examples/regex/matchHistoryActivity.yaml) | [JSON](/docs/examples/regex/matchHistoryActivity.json5)
|
||||
* Trigger if regex matches at least 3 of Author's last 10 activities - [YAML](/docs/examples/regex/matchActivityThresholdHistory.json5) | [JSON](/docs/examples/regex/matchActivityThresholdHistory.json5)
|
||||
* Trigger if there are 5 regex matches in the Author's last 10 activities - [YAML](/docs/examples/regex/matchTotalHistoryActivity.yaml) | [JSON](/docs/examples/regex/matchTotalHistoryActivity.json5)
|
||||
* Trigger if there are 5 regex matches in the Author's last 10 comments - [YAML](/docs/examples/regex/matchSubsetHistoryActivity.yaml) | [JSON](/docs/examples/regex/matchSubsetHistoryActivity.json5)
|
||||
* Remove comments that are spamming discord links - [YAML](/docs/examples/regex/removeDiscordSpam.yaml) | [JSON](/docs/examples/regex/removeDiscordSpam.json5)
|
||||
* Differs from just using automod because this config can allow one-off/organic links from users who DO NOT spam discord links but will still remove the comment if the user is spamming them
|
||||
73
docs/examples/regex/removeDiscordSpam.json5
Normal file
@@ -0,0 +1,73 @@
|
||||
{
|
||||
"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"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
36
docs/examples/regex/removeDiscordSpam.yaml
Normal file
@@ -0,0 +1,36 @@
|
||||
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
|
||||
@@ -2,8 +2,6 @@
|
||||
|
||||
The **Repeat Activity** rule will check for patterns of repetition in an Author's Submission/Comment history. Consult the [schema](https://json-schema.app/view/%23%2Fdefinitions%2FRepeatActivityJSONConfig?url=https%3A%2F%2Fraw.githubusercontent.com%2FFoxxMD%2Fcontext-mod%2Fmaster%2Fsrc%2FSchema%2FApp.json) for a complete reference of the rule's properties.
|
||||
|
||||
To determine sameness it uses an average of [Dice's Coefficient](https://en.wikipedia.org/wiki/S%C3%B8rensen%E2%80%93Dice_coefficient), [Cosine Similarity](https://en.wikipedia.org/wiki/Cosine_similarity), and [Levenshtein Distance](https://en.wikipedia.org/wiki/Levenshtein_distance) weighted by the length of the content being compared (more weight for longer content).
|
||||
|
||||
## Tuning
|
||||
|
||||
The most critical properties for this Rule are **gapAllowance** and **lookAt**.
|
||||
@@ -47,5 +45,5 @@ With only `gapAllowance: 2` this rule **would trigger** because the the 1 and 2
|
||||
|
||||
## Examples
|
||||
|
||||
* Crosspost Spamming [JSON](/docs/subreddit/componentscomponents/repeatActivity/crosspostSpamming.json5) | [YAML](/docs/subreddit/componentscomponents/repeatActivity/crosspostSpamming.yaml) - Check if an Author is spamming their Submissions across multiple subreddits
|
||||
* Burst-posting [JSON](/docs/subreddit/componentscomponents/repeatActivity/burstPosting.json5) | [YAML](/docs/subreddit/componentscomponents/repeatActivity/burstPosting.yaml) - Check if Author is crossposting their Submissions in short bursts
|
||||
* Crosspost Spamming [JSON](/docs/examples/repeatActivity/crosspostSpamming.json5) | [YAML](/docs/examples/repeatActivity/crosspostSpamming.yaml) - Check if an Author is spamming their Submissions across multiple subreddits
|
||||
* Burst-posting [JSON](/docs/examples/repeatActivity/burstPosting.json5) | [YAML](/docs/examples/repeatActivity/burstPosting.yaml) - Check if Author is crossposting their Submissions in short bursts
|
||||
30
docs/examples/repeatActivity/burstPosting.json5
Normal file
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"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}}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
23
docs/examples/repeatActivity/burstPosting.yaml
Normal file
@@ -0,0 +1,23 @@
|
||||
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}}
|
||||
28
docs/examples/repeatActivity/crosspostSpamming.json5
Normal file
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"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}}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
19
docs/examples/repeatActivity/crosspostSpamming.yaml
Normal file
@@ -0,0 +1,19 @@
|
||||
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,6 +1,6 @@
|
||||
The **Repost** rule is used to find reposts for both **Submissions** and **Comments**, depending on what type of **Check** it is used on.
|
||||
|
||||
Note: This rule is for searching **all of Reddit** for reposts, as opposed to just the Author of the Activity being checked. If you only want to check for reposts by the Author of the Activity being checked you should use the [Repeat Activity](/docs/subreddit/componentscomponents/repeatActivity) rule.
|
||||
Note: This rule is for searching **all of Reddit** for reposts, as opposed to just the Author of the Activity being checked. If you only want to check for reposts by the Author of the Activity being checked you should use the [Repeat Activity](/docs/examples/repeatActivity) rule.
|
||||
|
||||
# TLDR
|
||||
|
||||
@@ -111,7 +111,7 @@ criteria:
|
||||
* **external** -- get items from the Submission's link source that may be reposted (currently implemented for **Comment Checks** only)
|
||||
* When the Submission link is for...
|
||||
* **Youtube** -- get top comments on video by replies/like count
|
||||
* **NOTE:** An **API Key** for the [Youtube Data API](https://developers.google.com/youtube/v3) must be provided for this facet to work. This can be provided by the operator alongside [bot credentials](/docs/operator/configuration.md) or in the top-level `credentials` property for a [subreddit configuration.](https://json-schema.app/view/%23?url=https%3A%2F%2Fraw.githubusercontent.com%2FFoxxMD%2Freddit-context-bot%2Fmaster%2Fsrc%2FSchema%2FApp.json)
|
||||
* **NOTE:** An **API Key** for the [Youtube Data API](https://developers.google.com/youtube/v3) must be provided for this facet to work. This can be provided by the operator alongside [bot credentials](/docs/operatorConfiguration.md) or in the top-level `credentials` property for a [subreddit configuration.](https://json-schema.app/view/%23?url=https%3A%2F%2Fraw.githubusercontent.com%2FFoxxMD%2Freddit-context-bot%2Fmaster%2Fsrc%2FSchema%2FApp.json)
|
||||
|
||||
### Facet Modifiers
|
||||
|
||||
@@ -17,25 +17,25 @@ All actions for these configurations are non-destructive in that:
|
||||
|
||||
### Remove submissions from users who have used 'freekarma' subs to bypass karma checks
|
||||
|
||||
[YAML](/docs/subreddit/componentscomponents/subredditReady/freekarma.yaml) | [JSON](/docs/subreddit/componentscomponents/subredditReady/freekarma.json5)
|
||||
[YAML](/docs/examples/subredditReady/freekarma.yaml) | [JSON](/docs/examples/subredditReady/freekarma.json5)
|
||||
|
||||
If the user has any activity (comment/submission) in known freekarma subreddits in the past (50 activities or 6 months) then remove the submission.
|
||||
|
||||
### Remove submissions from users who have crossposted the same submission 4 or more times
|
||||
|
||||
[YAML](/docs/subreddit/componentscomponents/subredditReady/crosspostSpam.yaml) | [JSON](/docs/subreddit/componentscomponents/subredditReady/crosspostSpam.yaml)
|
||||
[YAML](/docs/examples/subredditReady/crosspostSpam.yaml) | [JSON](/docs/examples/subredditReady/crosspostSpam.yaml)
|
||||
|
||||
If the user has crossposted the same submission in the past (50 activities or 6 months) 4 or more times in a row then remove the submission.
|
||||
|
||||
### Remove submissions from users who have crossposted or used 'freekarma' subs
|
||||
|
||||
[YAML](/docs/subreddit/componentscomponents/subredditReady/freeKarmaOrCrosspostSpam.yaml) | [JSON](/docs/subreddit/componentscomponents/subredditReady/freeKarmaOrCrosspostSpam.json5)
|
||||
[YAML](/docs/examples/subredditReady/freeKarmaOrCrosspostSpam.yaml) | [JSON](/docs/examples/subredditReady/freeKarmaOrCrosspostSpam.json5)
|
||||
|
||||
Will remove submission if either of the above two behaviors is detected
|
||||
|
||||
### Remove link submissions where the user's history is comprised of 10% or more of the same link
|
||||
|
||||
[YAML](/docs/subreddit/componentscomponents/subredditReady/selfPromo.yaml) | [JSON](/docs/subreddit/componentscomponents/subredditReady/selfPromo.json5)
|
||||
[YAML](/docs/examples/subredditReady/selfPromo.yaml) | [JSON](/docs/examples/subredditReady/selfPromo.json5)
|
||||
|
||||
If the link origin (youtube author, twitter author, etc. or regular domain for non-media links)
|
||||
|
||||
@@ -48,13 +48,13 @@ then remove the submission
|
||||
|
||||
### Remove comment if the user has posted the same comment 4 or more times in a row
|
||||
|
||||
[YAML](/docs/subreddit/componentscomponents/subredditReady/commentSpam.yaml) | [JSON](/docs/subreddit/componentscomponents/subredditReady/commentSpam.json5)
|
||||
[YAML](/docs/examples/subredditReady/commentSpam.yaml) | [JSON](/docs/examples/subredditReady/commentSpam.json5)
|
||||
|
||||
If the user made the same comment (with some fuzzy matching) 4 or more times in a row in the past (50 activities or 6 months) then remove the comment.
|
||||
|
||||
### Remove comment if it is discord invite link spam
|
||||
|
||||
[YAML](/docs/subreddit/componentscomponents/subredditReady/discordSpam.yaml) | [JSON](/docs/subreddit/componentscomponents/subredditReady/discordSpam.json5)
|
||||
[YAML](/docs/examples/subredditReady/discordSpam.yaml) | [JSON](/docs/examples/subredditReady/discordSpam.json5)
|
||||
|
||||
This rule goes a step further than automod can by being more discretionary about how it handles this type of spam.
|
||||
|
||||
42
docs/examples/subredditReady/commentSpam.json5
Normal file
@@ -0,0 +1,42 @@
|
||||
{
|
||||
"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
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
25
docs/examples/subredditReady/commentSpam.yaml
Normal file
@@ -0,0 +1,25 @@
|
||||
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
|
||||
77
docs/examples/subredditReady/crosspostSpam.json5
Normal file
@@ -0,0 +1,77 @@
|
||||
{
|
||||
"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
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
48
docs/examples/subredditReady/crosspostSpam.yaml
Normal file
@@ -0,0 +1,48 @@
|
||||
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
|
||||
75
docs/examples/subredditReady/discordSpam.json5
Normal file
@@ -0,0 +1,75 @@
|
||||
{
|
||||
"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"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
46
docs/examples/subredditReady/discordSpam.yaml
Normal file
@@ -0,0 +1,46 @@
|
||||
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
|
||||
138
docs/examples/subredditReady/freeKarmaOrCrosspostSpam.json5
Normal file
@@ -0,0 +1,138 @@
|
||||
{
|
||||
"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
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
84
docs/examples/subredditReady/freeKarmaOrCrosspostSpam.yaml
Normal file
@@ -0,0 +1,84 @@
|
||||
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
|
||||
64
docs/examples/subredditReady/freekarma.json5
Normal file
@@ -0,0 +1,64 @@
|
||||
{
|
||||
"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,
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
35
docs/examples/subredditReady/freekarma.yaml
Normal file
@@ -0,0 +1,35 @@
|
||||
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
|
||||
104
docs/examples/subredditReady/selfPromo.json5
Normal file
@@ -0,0 +1,104 @@
|
||||
{
|
||||
"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
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
71
docs/examples/subredditReady/selfPromo.yaml
Normal file
@@ -0,0 +1,71 @@
|
||||
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
|
||||
@@ -6,25 +6,15 @@ Context Mod supports reading and writing [User Notes](https://www.reddit.com/r/t
|
||||
|
||||
[Click here for the Toolbox Quickstart Guide](https://www.reddit.com/r/toolbox/wiki/docs/quick_start)
|
||||
|
||||
Valid Note Types:
|
||||
|
||||
* `gooduser`
|
||||
* `spamwatch`
|
||||
* `spamwarn`
|
||||
* `abusewarn`
|
||||
* `ban`
|
||||
* `permban`
|
||||
* `botban`
|
||||
|
||||
## Filter
|
||||
|
||||
User Notes are an additional criteria on [AuthorCriteria](https://json-schema.app/view/%23%2Fdefinitions%2FAuthorCriteria?url=https%3A%2F%2Fraw.githubusercontent.com%2FFoxxMD%2Fcontext-mod%2Fmaster%2Fsrc%2FSchema%2FApp.json) that can be used alongside other Author properties for both [filtering rules and in the AuthorRule.](/docs/subreddit/components/author/)
|
||||
User Notes are an additional criteria on [AuthorCriteria](https://json-schema.app/view/%23%2Fdefinitions%2FAuthorCriteria?url=https%3A%2F%2Fraw.githubusercontent.com%2FFoxxMD%2Fcontext-mod%2Fmaster%2Fsrc%2FSchema%2FApp.json) that can be used alongside other Author properties for both [filtering rules and in the AuthorRule.](/docs/examples/author/)
|
||||
|
||||
Consult the [schema](https://json-schema.app/view/%23%2Fdefinitions%2FUserNoteCriteria?url=https%3A%2F%2Fraw.githubusercontent.com%2FFoxxMD%2Fcontext-mod%2Fmaster%2Fsrc%2FSchema%2FApp.json) for a complete reference of the **UserNoteCriteria** object that can be used in AuthorCriteria.
|
||||
|
||||
### Examples
|
||||
|
||||
* Do not tag user with Good User note [JSON](/docs/subreddit/componentscomponents/userNotes/usernoteFilter.json5) | [YAML](/docs/subreddit/componentscomponents/userNotes/usernoteFilter.yaml)
|
||||
* Do not tag user with Good User note [JSON](/docs/examples/userNotes/usernoteFilter.json5) | [YAML](/docs/examples/userNotes/usernoteFilter.yaml)
|
||||
|
||||
## Action
|
||||
|
||||
@@ -33,4 +23,4 @@ A User Note can also be added to the Author of a Submission or Comment with the
|
||||
|
||||
### Examples
|
||||
|
||||
* Add note on user doing self promotion [JSON](/docs/subreddit/componentscomponents/userNotes/usernoteSP.json5) | [YAML](/docs/subreddit/componentscomponents/userNotes/usernoteSP.yaml)
|
||||
* Add note on user doing self promotion [JSON](/docs/examples/userNotes/usernoteSP.json5) | [YAML](/docs/examples/userNotes/usernoteSP.yaml)
|
||||
45
docs/examples/userNotes/usernoteFilter.json5
Normal file
@@ -0,0 +1,45 @@
|
||||
{
|
||||
"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}}%"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
27
docs/examples/userNotes/usernoteFilter.yaml
Normal file
@@ -0,0 +1,27 @@
|
||||
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}}%
|
||||
36
docs/examples/userNotes/usernoteSP.json5
Normal file
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"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}}%"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
23
docs/examples/userNotes/usernoteSP.yaml
Normal file
@@ -0,0 +1,23 @@
|
||||
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,5 +1,5 @@
|
||||
This getting started guide is for **reddit moderators** -- that is, someone who wants **an existing ContextMod bot to run on their subreddit.** If you are trying to run a ContextMod
|
||||
instance (software) please refer to the [operator getting started](/docs/operator/gettingStarted.md) guide.
|
||||
instance (software) please refer to the [operator getting started](/docs/gettingStartedOperator.md) guide.
|
||||
|
||||
# Table of Contents
|
||||
|
||||
@@ -34,7 +34,7 @@ If the Operator has communicated that **you should add a bot they control as a m
|
||||
|
||||
* Shared api quota among other moderated subreddits (not great for high-volume subreddits)
|
||||
|
||||
---
|
||||
___
|
||||
|
||||
Ensure that you are in communication with the **operator** of this bot. The bot **will only accept a moderator invitation if your subreddit has been whitelisted by the operator.** This is an intentional barrier to ensure moderators and the operator are familiar with their respective needs and have some form of trust.
|
||||
|
||||
@@ -55,7 +55,7 @@ If the operator has communicated that **they want to use a bot you control** thi
|
||||
|
||||
* **Dedicated API quota**
|
||||
* This is basically a requirement if your subreddit has high-volume activity and you plan on running checks on comments
|
||||
* More security guarantees since you control the account
|
||||
* More security guarantees since you control the account
|
||||
* **Note:** authenticating an account does NOT give the operator access to view or change the email/password for the account
|
||||
* Established history in your subreddit
|
||||
|
||||
@@ -63,7 +63,7 @@ If the operator has communicated that **they want to use a bot you control** thi
|
||||
|
||||
* You must have access to the credentials for the reddit account (bot)
|
||||
|
||||
---
|
||||
___
|
||||
|
||||
The **operator** will send you an **invite link** that you will use to authenticate your bot with the operator's application. Example link: `https://operatorsUrl.com/auth/invite?invite=4kf9n3o03ncd4nd`
|
||||
|
||||
@@ -81,7 +81,7 @@ The default location for this page is at `https://old.reddit.com/r/YOURSUBERDDIT
|
||||
|
||||
The bot automatically tries to create its configuration wiki page. You can find the result of this in the log for your subreddit in the web interface.
|
||||
|
||||
If this fails for some reason you can create the wiki page through the web interface by navigating to your subreddit's tab, opening the [built-in editor (click **View**)](/docs/images/configBox.png), and following the directions in **Create configuration for...** link found there.
|
||||
If this fails for some reason you can create the wiki page through the web interface by navigating to your subreddit's tab, opening the [built-in editor (click **View**)](/docs/screenshots/configBox.png), and following the directions in **Create configuration for...** link found there.
|
||||
|
||||
If neither of the above approaches work, or you do not wish to use the web interface, expand the section below for directions on how to manually setup the wiki page:
|
||||
|
||||
@@ -104,7 +104,7 @@ If you already have a configuration you may skip the below step and go directly
|
||||
|
||||
### Using an Example Config
|
||||
|
||||
Visit the [Examples](https://github.com/FoxxMD/context-mod/tree/master/docs/examples) folder to find various examples of individual rules or see the [subreddit-ready examples.](/docs/subreddit/components/subredditReady)
|
||||
Visit the [Examples](https://github.com/FoxxMD/context-mod/tree/master/docs/examples) folder to find various examples of individual rules or see the [subreddit-ready examples.](/docs/examples/subredditReady)
|
||||
|
||||
After you have found a configuration to use as a starting point:
|
||||
|
||||
@@ -117,13 +117,11 @@ After you have found a configuration to use as a starting point:
|
||||
CM comes equipped with a [configuration explorer](https://json-schema.app/view/%23?url=https%3A%2F%2Fraw.githubusercontent.com%2FFoxxMD%2Fcontext-mod%2Fmaster%2Fsrc%2FSchema%2FApp.json) to help you see all available options, with descriptions and examples, that can be used in your configuration.
|
||||
|
||||
To create or edit a configuration you should use **CM's buit-in editor** which features:
|
||||
|
||||
* syntax validation and formatting
|
||||
* full configuration validation with error highlighting, hints, and fixes
|
||||
* hover over properties to see documentation and examples
|
||||
|
||||
To use the editor either:
|
||||
|
||||
* [use your subreddit's built-in editor](#using-the-built-in-editor)
|
||||
* or use the public editor at https://cm.foxxmd.dev/config
|
||||
|
||||
@@ -136,7 +134,7 @@ PROTIP: Find an [example config](#using-an-example-config) to use as a starting
|
||||
In the web interface each subreddit's tab has access to the built-in editor. Use this built-in editor to automatically create, load, or save the configuration for that subreddit's wiki.
|
||||
|
||||
* Visit the tab for the subreddit you want to edit the configuration of
|
||||
* Open the [built-in editor by click **View**](/docs/images/configBox.png)
|
||||
* Open the [built-in editor by click **View**](/docs/screenshots/configBox.png)
|
||||
* Edit your configuration
|
||||
* Follow the directions on the **Save to r/..** link found at the top of the editor to automatically save your configuration
|
||||
|
||||
@@ -150,7 +148,7 @@ In the web interface each subreddit's tab has access to the built-in editor. Use
|
||||
|
||||
</details>
|
||||
|
||||
---
|
||||
___
|
||||
|
||||
The bot automatically checks for new configurations on your wiki page every 5 minutes. If your operator has the web interface accessible you may login there and force the config to update on your subreddit.
|
||||
|
||||
83
docs/gettingStartedOperator.md
Normal file
@@ -0,0 +1,83 @@
|
||||
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/subreddit/components/recentActivity)
|
||||
* [Recent Activity](/docs/examples/recentActivity)
|
||||
* Repeat Activity (In-progress)
|
||||
|
||||
To enable comparisons reference the example below (at the top-level of your rule) and configure as needed:
|
||||
|
||||
|
Before Width: | Height: | Size: 36 KiB |
|
Before Width: | Height: | Size: 37 KiB |
|
Before Width: | Height: | Size: 75 KiB |
|
Before Width: | Height: | Size: 34 KiB |
|
Before Width: | Height: | Size: 93 KiB |
|
Before Width: | Height: | Size: 84 KiB |
|
Before Width: | Height: | Size: 25 KiB |