| grand_parent | parent | title |
|---|---|---|
Subreddit Configuration |
In Depth |
Filters |
Filters are an additional channel for determining if an Event should be processed by ContextMod. They differ from Rules in several key ways:
- Runs, Checks, Rules, and Actions can all have Filters
- Filters test against the current state of the Activity (or its Author) being processed, 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.
A Filter has these properties:
include-- An optional list of Filter Criteria. If any passes the filter passes.exclude-- An optional list of Filter Criteria. All must NOT pass for the filter to pass. Ignored ifincludeis present.excludeCondition-- A condition that determines how the list of Filter Criteria are tested together
A criteria is some property of a thing (Activity or Author) can be tested, and what the expected outcome is EX:
age: '> 2 months' => Author is older than 2 months
Filter Criteria is one of more criteria combined together to form a set of conditions that must all be true together for the Filter Criteria to be true EX
age: '> 2 months'
verified: trueThe above Filter Criteria is true if:
- the Author's account is older than 2 months AND
- they have a verified email
Generically, a "full" Filter looks like this:
include: #optional
- name: AFilterCriteria
criteria:
#...
#...one or more Filter Criteria
exclude: #optional
#...one or more Filter Criteria
excludeCondition: OR or ANDBut for convenience a Filter's shape can be simplified with a few assumptions:
When a Filter is an object, the object is assumed to be a Filter Criteria which is used in include
itemIs:
approved: falseWhen a Filter is a list, the list is assumed to be a list of Filter Criteria and used in include
itemIs:
- approved: false
filtered: false
- is_self: trueThere are two types of Filter. Both types have the same "shape" in the configuration with the differences between them being:
- what they are testing on
- what criteria are available to test
Test the Author of an Activity. See Schema documentation for all possible Author Criteria
See Mod Actions/Notes documentation.
See UserNotes documentation
Test for properties of an Activity:
Test for properties of the Subreddit an Activity belongs to. See Schema documentation
Named Filters work the same as Named Rules and Named Actions:
Filter Criteria may be given a name. A named Filter Criteria can re-used anywhere in the configuration regardless of location. This is done by:
- specifying a name on a Filter Criteria once EX:
name: MyFilterCriteria - using the Filter Criteria name in place of a Filter Criteria object
runs:
- name: MyFirstRun
checks:
- name: MyFirstCheck
kind: submission
itemIs:
- MyFilterCriteria
rules:
#...
actions:
#...
- name: MySecondCheck
kind: submission
itemIs:
include:
- name: MyFilterCriteria
criteria:
approved: false
rules:
#...
actions:
#...Below are examples of where filters can be used
runs:
# this run will only be processed if author is a contributor
- name: MyRun
authorIs:
- isContributor: true
checks:
# - ...runs:
- name: MyRun
checks:
# check will only be processed if author is a contributor
- name: MyCheck
kind: submission
authorIs:
- isContributor: true
rules:
# ...
actions:
# ...runs:
- name: MyRun
checks:
- name: MyCheck
kind: submission
rules:
# rule will only run if author is a contributor
- name: MyFirstRule
kind: recentActivity
authorIs:
- isContributor: true
thresholds:
# ...
actions:
# ...runs:
- name: MyRun
checks:
- name: MyCheck
kind: submission
rules:
- name: MyFirstRule
# ...
actions:
# action will only run if author is a contributor
- kind: approve
authorIs:
- isContributor: trueruns:
- name: MyRun
checks:
# Check will only process if author is a contributor AND submission is not approved
- name: MyCheck
kind: submission
authorIs:
- isContributor: true
itemIs:
- approved: false
rules:
# ...
actions:
# ...Below are examples of how filters can be structured using filter shapes
runs:
- name: MyRun
checks:
- name: MyCheck
kind: submission
# check is only processed if submission is not approved AND not marked as nsfw
itemIs:
approved: false
over_18: false
rules:
# ...
actions:
# ...runs:
- name: MyRun
checks:
- name: MyCheck
kind: submission
# check is only processed if submission is EITHER:
# -> not approved AND not marked as nsfw
# -> not approved AND marked as nsfw AND has flair text 'Mildly NSFW;
itemIs:
# each '-' denotes a NEW set of criteria
- approved: false
over_18: false
- link_flair_text: Mildly NSFW
over_18: true
approved: false
rules:
# ...
actions:
# ...runs:
- name: MyRun
checks:
- name: MyCheck
kind: submission
# check is only processed if submission is EITHER:
# -> not approved AND not marked as nsfw
# -> not approved AND marked as nsfw AND has flair text 'Mildly NSFW;
itemIs:
include:
- approved: false
over_18: false
- link_flair_text: Mildly NSFW
over_18: true
approved: false
rules:
# ...
actions:
# ...runs:
- name: MyRun
checks:
- name: MyCheck
kind: submission
# check is only processed if submission is NOT approved
itemIs:
exclude:
- approved: true
rules:
# ...
actions:
# ...runs:
- name: MyRun
checks:
- name: MyCheck
kind: submission
# check is only processed if submission is:
# -> not approved AND not marked as nsfw
itemIs:
include:
- name: sfwNotApproved
criteria:
- approved: false
over_18: false
rules:
# ...
actions:
# ...# author's account is less than 30 days old AND has less than 30 comment karma
authorIs:
include:
- name: newUser
criteria:
age: < 30 days
commentKarma: < 30# author's account is less than 30 days old AND has less than 30 comment karma AND has 'nsfw' in their account name
authorIs:
include:
- name: newUser
criteria:
age: < 30 days
commentKarma: < 30
name: '/nsfw/i'authorIs:
include:
- description:
- '/Add Me On Snapchat/i'
- '/Add my snapchat/i'
- '/Dm me for content/i'
- '/Will Verify/i'Useful when CM should not run if the author is from a list of users or a moderator
authorIs:
excludeCondition: AND
exclude:
# will not run if user is a mod or is automoderator
- isMod: true
# will not run if the user is in the list below
- name:
- User1
- User2
- User3itemIs:
- removed: false
approved: false
op: falseitemIs:
- is_self: true
link_flair_text: false