Skip to content

Commit 3bcc3d7

Browse files
committed
Merge branch 'edge'
2 parents 296f1c8 + c9d8bf6 commit 3bcc3d7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+3837
-317
lines changed

README.md

+6
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ Feature Highlights for **Moderators:**
3131
* [**Web interface**](#web-ui-and-screenshots) for monitoring, administration, and oauth bot authentication
3232
* [**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
3333
* [**Partial Configurations**](/docs/subreddit/components/README.md#partial-configurations) -- offload parts of your configuration to shared locations to consolidate logic between multiple subreddits
34+
* [Guest Access](/docs/subreddit/README.md#guest-access) enables collaboration and easier setup by allowing temporary access
35+
* [Toxic content prediction](/docs/subreddit/components/README.md#moderatehatespeechcom-predictions) using [moderatehatespeech.com](https://moderatehatespeech.com) machine learning model
3436

3537
Feature highlights for **Developers and Hosting (Operators):**
3638

@@ -134,6 +136,10 @@ Moderator view/invite and authorization:
134136

135137
![Invite View](docs/images/oauth-invite.jpg)
136138

139+
A similar helper and invitation experience is available for adding **subreddits to an existing bot.**
140+
141+
![Subreddit Invite View](docs/images/subredditInvite.jpg)
142+
137143
### Configuration Editor
138144

139145
A built-in editor using [monaco-editor](https://microsoft.github.io/monaco-editor/) makes editing configurations easy:

docs/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ An **Action** is some action the bot can take against the checked Activity (comm
152152

153153
* For **Operator/Bot maintainers** see **[Operation Guide](/docs/operator/README.md)**
154154
* For **Moderators**
155+
* Start with the [Subreddit/Moderator docs](/docs/subreddit/README.md) or [Moderator Getting Started guide](/docs/subreddit/gettingStarted.md)
155156
* Refer to the [Subreddit Components Documentation](/docs/subreddit/components) or the [subreddit-ready examples](/docs/subreddit/components/subredditReady)
156157
* 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
157158
* fully annotated configuration data/structure

docs/images/editor.jpg

7.89 KB
Loading

docs/images/guests.jpg

38.4 KB
Loading

docs/images/oauth-invite.jpg

-11.7 KB
Loading

docs/images/oauth.jpg

-68.1 KB
Loading

docs/images/subredditInvite.jpg

141 KB
Loading

docs/images/subredditStatus.jpg

-254 KB
Loading

docs/subreddit/README.md

+95
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
This section is for **reddit moderators**. It covers how to use a CM bot for your subreddit.
2+
3+
If you are trying to run a ContextMod instance (the actual software) please refer to the [operator section](/docs/operator/README.md).
4+
5+
# Table of Contents
6+
7+
* [Overview](#overview)
8+
* [Your Relationship to CM](#your-relationship-to-cm)
9+
* [Operator](#operator)
10+
* [Your Bot](#your-bot)
11+
* [Getting Started](#getting-started)
12+
* [Accessing The Bot](#accessing-the-bot)
13+
* [Editing The Bot](#editing-the-bot)
14+
* [Configuration](#configuration)
15+
* [Guest Access](#guest-access)
16+
17+
# Overview
18+
19+
The Context Mod **software** can manage multiple **bots** (reddit accounts used as bots, like `/u/MyCMBot`). Each bot can manage (run) multiple **subreddits** which is determined by the subreddits the account is a moderator of.
20+
21+
You, the moderator of a subreddit a CM bot runs in, can access/manage the Bot using the CM software's [web interface](/docs/images/subredditStatus.jpg) and control its behavior using the [web editor.](/docs/images/editor.jpg)
22+
23+
## Your Relationship to CM
24+
25+
It is important to understand the relationship between you (the moderator), the bot, and the operator (the person running the CM software).
26+
27+
The easiest way to think about this is in relation to how you use Automoderator and interact with Reddit as a moderator. As an analogy:
28+
29+
### Operator
30+
31+
The operator is the person running the actual server/machine the Context Mod software is on.
32+
33+
They are best thought of as **Reddit:**
34+
35+
* Mostly hands-off when it comes to the bot and interacting with your subreddit
36+
* You must interact with Reddit first before you can use automoderator (login, create a subreddit, etc...)
37+
38+
Unlike reddit, though, there is a greater level of trust required between you and the Operator because what you make the Bot do ultimately affects the Operator since they are the ones actually running your Bot and making API calls to reddit.
39+
40+
### Your Bot
41+
42+
Your bot is like an **invite-only version of Automoderator**:
43+
44+
* Unlike automoderator, you **must** interact with the Operator in order to get the bot working. It is not public for anyone to use.
45+
* Like automoderator, you **must** create a [configuration](/docs/subreddit/components/README.md) for it do anything.
46+
* The bot does not come pre-configured for you. It is a blank slate and requires user input to be useful.
47+
* Also like automoderator, you are **entirely in control of the bot.**
48+
* You can start, stop, and edit its behavior at any time without needing to communicate with the Operator.
49+
* CM provides you _tools_, different ways the Bot can detect patterns in your subreddit/users as well as actions it can, and you can decide to use them however you want.
50+
* Your bot is **only accessible to moderators of your subreddit.**
51+
52+
# Getting Started
53+
54+
The [Getting Started](/docs/subreddit/gettingStarted.md) guide lays out the steps needed to go from nothing to a working Bot. If you are a moderator new to Context Mod this is where you want to begin.
55+
56+
# Accessing The Bot
57+
58+
All bot management and editing is done through the [web interface.](/docs/images/subredditStatus.jpg) The URL used for accessing this interface is given to you by the **Operator** once they have agreed to host your bot/subreddit.
59+
60+
NOTE: This interface is **only access to moderators of your subreddit** and [guests.](#guest-access) You must login to the web interface **with your moderator account** in order to access it.
61+
62+
A **guided tour** that helps show how to manage the bot at a high-level is available on the web interface by clicking the **Help** button in the top-right of the page.
63+
64+
## Editing The Bot
65+
66+
Find the [editor in the web interface](/docs/webInterface.md#editingupdating-your-config) to access the built-in editor for the bot.
67+
68+
[The editor](/docs/images/editor.jpg) should be your all-in-one location for viewing and editing your bot's behavior. **It is equivalent to Automoderator's editor page.**
69+
70+
The editor features:
71+
72+
* syntax validation and highlighting
73+
* configuration auto-complete and documentation (hover over properties)
74+
* built-in validation using Microsoft Word "squiggly lines" indicators and an error list at the bottom of the window
75+
* built-in saving (at the top of the window)
76+
77+
# Configuration
78+
79+
Use the [Configuration Reference](/docs/subreddit/components/README.md) to learn about all the different components available for building a CM configuration.
80+
81+
Additionally, refer to [How It Works](/docs/README.md#how-it-works) and [Core Concepts](/docs/README.md#concepts) to learn the basic of CM configuration.
82+
83+
After you have the basics under your belt you could use the [subreddit-reddit example configurations](/docs/subreddit/components/subredditReady) to familiarize yourself with a complete configuration and ways to use CM.
84+
85+
# Guest Access
86+
87+
CM supports **Guest Access**. Reddit users who are given Guest Access to your bot are allowed to access the web interface even though they are not moderators.
88+
89+
Additionally, they can edit the subreddit's config using the bot. If a Guest edits your config their username will be mentioned in the wiki page edit reason.
90+
91+
Guests can do everything a regular mod can except view/add/remove Guest. They can be removed at any time or set with an expiration date that their access is removed on.
92+
93+
**Guests are helpful if you are new to CM and know reddit users that can help you get started.**
94+
95+
[Add guests from the Subreddit tab in the main interface.](/docs/images/guests.jpg)

docs/subreddit/components/README.md

+7
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ This list is not exhaustive. [For complete documentation on a subreddit's config
2222
* [Regex](#regex)
2323
* [Repost](#repost)
2424
* [Sentiment Analysis](#sentiment-analysis)
25+
* [Toxic Content Prediction](#moderatehatespeechcom-predictions)
2526
* [Rule Sets](#rule-sets)
2627
* [Actions](#actions)
2728
* [Named Actions](#named-actions)
@@ -377,6 +378,12 @@ This rule is for searching **all of Reddit** for reposts, as opposed to just the
377378

378379
The **Sentiment Rule** is used to determine the overall emotional intent (negative, neutral, positive) of a Submission or Comment by analyzing the actual text content of the Activity.
379380

381+
### ModerateHateSpeech.com Predictions
382+
383+
[**Full Documentation**](/docs/subreddit/components/mhs)
384+
385+
ContextMod integrates with [moderatehatespeech.com](https://moderatehatespeech.com/) (MHS) [toxic content machine learning model](https://moderatehatespeech.com/framework/) through their API. This rule sends an Activity's content (title or body) to MHS which returns a prediction on whether the content is toxic and actionable by a moderator. Their model is [specifically trained for reddit content.](https://www.reddit.com/r/redditdev/comments/xdscbo/updated_bot_backed_by_moderationoriented_ml_for/)
386+
380387
# Rule Sets
381388

382389
The `rules` list on a `Check` can contain both `Rule` objects and `RuleSet` objects.

docs/subreddit/components/advancedConcepts/ruleSets.json5

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
// if the nested rules pass the condition then the Rule Set triggers the Check
3232
//
3333
// AND = all nested rules must be triggered to make the Rule Set trigger
34-
// AND = any of the nested Rules will be the Rule Set trigger
34+
// OR = any of the nested Rules will be the Rule Set trigger
3535
"condition": "AND",
3636
// in this check we use an Attribution >10% on ONLY submissions, which is a lower requirement then the above attribution rule
3737
// and combine it with a History rule looking for low comment engagement

docs/subreddit/components/advancedConcepts/ruleSets.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ runs:
2222
# if the nested rules pass the condition then the Rule Set triggers the Check
2323
#
2424
# AND = all nested rules must be triggered to make the Rule Set trigger
25-
# AND = any of the nested Rules will be the Rule Set trigger
25+
# OR = any of the nested Rules will be the Rule Set trigger
2626
- condition: AND
2727
# in this check we use an Attribution >10% on ONLY submissions, which is a lower requirement then the above attribution rule
2828
# and combine it with a History rule looking for low comment engagement
+165
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
# Table of Contents
2+
3+
* [Overview](#overview)
4+
* [MHS Predictions](#mhs-predictions)
5+
* [Flagged](#flagged)
6+
* [Confidence](#confidence)
7+
* [Usage](#usage)
8+
* [Minimal/Default Config](#minimaldefault-config)
9+
* [Full Config](#full-config)
10+
* [Historical Matching](#historical-matching)
11+
* [Examples](#examples)
12+
13+
# Overview
14+
15+
[moderatehatespeech.com](https://moderatehatespeech.com/) (MHS) is a [non-profit initiative](https://moderatehatespeech.com/about/) to identify and fight toxic and hateful content online using programmatic technology such as machine learning models.
16+
17+
They offer a [toxic content prediction model](https://moderatehatespeech.com/framework/) specifically trained on and for [reddit content](https://www.reddit.com/r/redditdev/comments/xdscbo/updated_bot_backed_by_moderationoriented_ml_for/) as well as partnering [directly with subreddits.](https://moderatehatespeech.com/research/subreddit-program/).
18+
19+
Context Mod leverages their [API](https://moderatehatespeech.com/docs/) for toxic content predictions in the **MHS Rule.**
20+
21+
The **MHS Rule** sends an Activity's content (title or body) to MHS which returns a prediction on whether the content is toxic and actionable by a moderator.
22+
23+
## MHS Predictions
24+
25+
MHS's toxic content predictions return two indicators about the content it analyzed. Both are available as test conditions in ContextMod.
26+
27+
### Flagged
28+
29+
MHS returns a straight "Toxic or Normal" **flag** based on how it classifies the content.
30+
31+
Example
32+
33+
* `Normal` - "I love those pineapples"
34+
* `Toxic` - "why are we having all these people from shithole countries coming here"
35+
36+
### Confidence
37+
38+
MHS returns how **confident** it is of the flag classification on a scale of 0 to 100.
39+
40+
Example
41+
42+
"why are we having all these people from shithole countries coming here"
43+
44+
* Flag = `Toxic`
45+
* Confidence = `97.12` -> The model is 97% confident the content is `Toxic`
46+
47+
# Usage
48+
49+
**An MHS Api Key is required to use this Rule**. An API Key can be acquired, for free, by creating an account at [moderatehatespeech.com](https://moderatehatespeech.com).
50+
51+
The Key can be provided by the bot's Operator in the [bot config credentials](https://json-schema.app/view/%23/%23%2Fdefinitions%2FBotInstanceJsonConfig/%23%2Fdefinitions%2FBotCredentialsJsonConfig?url=https%3A%2F%2Fraw.githubusercontent.com%2FFoxxMD%2Fcontext-mod%2Fedge%2Fsrc%2FSchema%2FOperatorConfig.json) or in the subreddit's config in the top-level `credentials` property like this:
52+
53+
```yaml
54+
credentials:
55+
mhs:
56+
apiKey: 'myMHSApiKey'
57+
58+
# the rest of your config below
59+
polling:
60+
# ...
61+
runs:
62+
# ...
63+
```
64+
65+
### Minimal/Default Config
66+
67+
ContextMod provides a reasonable default configuration for the MHS Rule if you do not wish to configure it yourself. The default configuration will trigger the rule if the MHS prediction:
68+
69+
* flags as `toxic`
70+
* with `90% or greater` confidence
71+
72+
Example
73+
74+
```yaml
75+
rules:
76+
- kind: mhs
77+
78+
# rest of your rules here...
79+
```
80+
81+
### Full Config
82+
83+
84+
| Property | Type | Description | Default |
85+
|--------------|---------|-------------------------------------------------------------------------------------------|---------|
86+
| `flagged` | boolean | Test whether content is flagged as toxic (true) or normal (false) | `true` |
87+
| `confidence` | string | Comparison against a number 0 to 100 representing how confident MHS is in the prediction | `>= 90` |
88+
| `testOn` | array | Which parts of the Activity to send to MHS. Options: `title` and/or `body` | `body` |
89+
90+
Example
91+
92+
```yaml
93+
rules:
94+
- kind: mhs
95+
criteria:
96+
flagged: true # triggers if MHs flags the content as toxic AND
97+
confidence: '> 66' # MHS is 66% or more confident in its prediction
98+
testOn: # send the body of the activity to the MHS prediction service
99+
- body
100+
```
101+
102+
#### Historical Matching
103+
104+
Like the [Sentiment](/docs/subreddit/components/sentiment#historical) and [Regex](/docs/subreddit/components/regex#historical) rules CM can also use MHS predictions to check content from the Author's history.
105+
106+
Example
107+
108+
```yaml
109+
rules:
110+
- kind: mhs
111+
# ...same config as above but can include below...
112+
historical:
113+
mustMatchCurrent: true # if true then CM will not check author's history unless current Activity matches MHS prediction criteria
114+
totalMatching: '> 1' # comparison for how many activities in history must match to trigger the rule
115+
window: 10 # specify the range of activities to check in author's history
116+
criteria: #... if specified, overrides parent-level criteria
117+
```
118+
119+
# Examples
120+
121+
Report if MHS flags as toxic
122+
123+
```yaml
124+
rules:
125+
- kind: mhs
126+
actions:
127+
- kind: report
128+
content: 'MHS flagged => {{rules.mhs.summary}}'
129+
```
130+
131+
Report if MHS flags as toxic with 95% confidence
132+
133+
```yaml
134+
rules:
135+
- kind: mhs
136+
confidence: '>= 95'
137+
actions:
138+
- kind: report
139+
content: 'MHS flagged => {{rules.mhs.summary}}'
140+
```
141+
142+
Report if MHS flags as toxic and at least 3 recent activities in last 10 from author's history are also toxic
143+
144+
```yaml
145+
rules:
146+
- kind: mhs
147+
historical:
148+
window: 10
149+
mustMatchCurrent: true
150+
totalMatching: '>= 3'
151+
actions:
152+
- kind: report
153+
content: 'MHS flagged => {{rules.mhs.summary}}'
154+
```
155+
156+
Approve if MHS flags as NOT toxic with 95% confidence
157+
158+
```yaml
159+
rules:
160+
- kind: mhs
161+
confidence: '>= 95'
162+
flagged: false
163+
actions:
164+
- kind: approve
165+
```

docs/subreddit/components/subredditReady/freekarma.json5

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
// remove this after confirming behavior is acceptable
4444
{
4545
"kind": "report",
46-
"content": "Remove=> {{rules.newtube.totalCount}} activities in freekarma subs"
46+
"content": "Remove=> {{rules.freekarma.totalCount}} activities in freekarma subs"
4747
},
4848
//
4949
//

docs/subreddit/components/subredditReady/freekarma.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ runs:
2525
actions:
2626
- kind: report
2727
enable: true
28-
content: 'Remove=> {{rules.newtube.totalCount}} activities in freekarma subs'
28+
content: 'Remove=> {{rules.freekarma.totalCount}} activities in freekarma subs'
2929
- kind: remove
3030
enable: true
3131
- kind: comment

0 commit comments

Comments
 (0)