Skip to content

Auto Moderator

The Auto Moderator allows you to write custom rules that are run when a post is captured in your feed. We’ve collated below some useful information about how to use the tool. But the best way for you to familiarise yourself and get comfortable with it, is just to try it out. Give your Auto Moderator some simple rules to begin with and see how it looks. Then, you can start to get more creative as you learn.

Syntax is a term referring to the structure of code. An Auto Moderator rule is created using a block of YAML code with a fixed structure. In order to work, each rule needs to contain the properties name, conditions, and an event.

When you make a new rule, you give it a name. Then, you set some conditions to outline what situations it applies to. The event is the action the rule takes.

This is a sample block of YAML creating an example rule.

rules:
- name: Cat text posts
conditions:
all:
- fact: post_text
operator: includes
value: cat
event:
type: log

This code creates a rule called Cat text posts. The conditions block (which means the text underneath Conditions) outlines that the rule applies to all text posts that include the word ‘cat’. The event block instructs the rule to log that each relevant post was posted.

Here are some more examples of how you might define rules using the Auto Moderator:

This rule logs every post that comes through the feed. The line with the # sign at the front is a comment. It doesn’t affect how the code runs but is included so that you can keep track of what your rules are without having to think too much about the code itself. You don’t have to put them in if you don’t want to!

rules:
#This is a rule that will match any post captured, and then log that post. All posts have an id greater than 1.
- name: Log All Posts
conditions:
any:
- fact: id
operator: greaterThan
value: 1
event:
type: log

This rule removes posts that contain specific words (dog and fish, for the purposes of our example, but you can set whichever words you like).

rules:
# Match any post that includes either "dog" or "fish" as whole words.
# Uses the same logic as capturing feeds.
- name: Remove Dog and Fish
conditions:
any:
- fact: post_text
operator: includes
value:
- dog
- fish
event:
type: remove
Section titled “Example 3: Require Approval for External Links”

This rule requires manual approval for posts that contain external links. We’ve done this by setting up a condition where the action is triggered by a post containing ‘http’ which is typically in a URL. The embedded_link fact refers to a Bluesky link card.

rules:
# Match any post that has a link card
# Assuming all links will contain http
- name: Require Approval for External Links
conditions:
any:
- fact: embedded_link
operator: contains
value: http
event:
type: require-approval

Example 4: Automatically approve certain posts

Section titled “Example 4: Automatically approve certain posts”

This rule automatically approves posts if they include certain words. For example, if this feed were capturing posts about “dahlia” and “dahlias”, then we might want to automatically approve a post if it also contains any common gardening terms.

rules:
- name: Auto Approve
conditions:
any:
- fact: post_text
operator: includes
value:
- garden*
- flower
- seed*
- plant*
- grass
- bloom*
event:
type: approve

Example 5: Hiding replies from specific users

Section titled “Example 5: Hiding replies from specific users”

This rule will automatically hide posts that are Replies, if the person who is replying is a specific user. This might be useful if your feed captures all their posts normally, but you only want to show their Original and Quote posts.

rules:
- name: Hide replies by specific users
conditions:
all:
- fact: post_author_handle
operator: in
value:
- dailynous.com
- fact: reply_parent
operator: includes
value: "*"
event:
type: hide

Example 6: Automatically delete posts from users who block you

Section titled “Example 6: Automatically delete posts from users who block you”

This rule will try to download a post via your own Bluesky connection, as it is captured by your feed.

If the post cannot be seen by your user account, then it is likely that there is a blocking relationship between you and the post author: you have blocked them, or they have blocked you.

In either case, it is assumed that you do not want posts from that author in your feed, and Auto Moderator will then automatically hide it from your feed and label it as “Blocked by Auto Moderator”.

This behaviour is an intended side-effect of the download requested in the logging rule. You do not have to explicitly request that the post be hidden in your rule, only that a post is downloaded for testing.

rules:
# This will download the post via your own Bluesky API connection instead of our service connection
# If your connection is not able to see the post, it will be treated as "blocked"
# and be automatically removed from your feed regardless of any conditions
- name: Check not blocked
conditions:
any:
- fact: post_from_api
path: $.uri
operator: doesNotContain
value: "at://"
event:
type: log

Example 7: Hide quote posts if the post they quoted matches your feed exclusions

Section titled “Example 7: Hide quote posts if the post they quoted matches your feed exclusions”

By default, only the captured post is tested against your feed settings. The contents of the quoted post will not be considered.

We can create a rule that will check this for us though, combining both the quoted_post fact and the feed fact:

rules:
- name: Check quoted posts for exclusions
conditions:
all:
- fact: quoted_post
path: $.post_text
operator: includes
value:
fact: feed
path: $.excludes
# Also available:
# $.includes
# $.includes_requiring_approval
event:
type: hide

A fact is a piece of information about a post which your Auto Moderator rule looks at to determine whether a condition is met.

rules:
#This is a rule that will match any post captured, and then log that post. All posts have an id greater than 1.
- name: Log All Posts
conditions:
any:
- fact: id
operator: greaterThan
value: 1
event:
type: log

You can start to see all available facts by creating a logging rule such as the one above. In fact, you can copy and paste the block above to start logging all the posts that come through your feed. As posts come through the feed, they will appear in the Auto Moderator logs with a detailed record of all available facts.

In addition to this, there are a few more special facts that you can take advantage of:

fact: author_profile will download the profile of the author who created the post.

Using the path: option, you can then access information about the author such as their bio, and any labels they have applied. In the example below, we use the path $.description to check if the author of the post indicates that they are a NSFW account. The Auto Moderator will therefore hide any posts that were captured if the author has either 🔞 or the word “nsfw” in their bio.

rules:
- name: Hide NSFW authors
conditions:
any:
- fact: author_profile
path: $.description
operator: includes
value:
- 🔞
- nsfw
event:
type: hide

fact: is_post_in_feed allows you to determine if a given post is already in the feed or not. This could be useful if your feed captures posts and replies, but you don’t want to show the replies in your feed as well if the parent post is already in your feed.

rules:
- name: Remove replies if parent is also in feed
conditions:
all:
- fact: is_post_in_feed
params:
uri: reply_root
operator: equal
value: true
event:
type: hide

fact: is_post_in_feed will return true if the uri passed in params is currently in your feed. Otherwise it will return false. A post’s uri looks like this: at://did:plc:ihzif525llitrzvnb2qtu2t3/app.bsky.feed.post/3lg2g7ua2d22d