This repository contains a script for blocking / removing posts containing media with certain hash-tags and blocking their authors.
When running a small or single user mastodon instance you often use relays to get content to your instance and increase reachability of your posts.
This sadly increases the amount of content that reaches your instance from federated instances you may not want to host or spread.
See the blog post for more details.
- it searches for all posts containing defined hashtags and media attachements
- if the author of the post is not exempt (see below) they'll get suspended, and their data deleted.
This script can be run in single user, or multi user mode, which can be defined through the multiUserMode
flag in ./config.sh
, and the option you choose will determine which users are exempt from suspension and deletion:
multiUserMode=false
: In this mode your own account, as well as any accounts you personally follow are exempt from suspension and deletion. If you are running this against a multi user instance, this may cause accounts on your own instance to be deleted, as well as accounts followed by other users on your own instance, so it's probably only suitable for single user instances.multiUserMode=true
: In this mode any accounts on your instance, as well as any accounts followed by accounts on your instance are exempt from suspension and deletion. This is probably the better setup for most people.
You can either run this locally on your machine, or as a GitHub Action:
Regardless of how you wish to run your script, you first need to register a new application in your mastodon instance:
- Preferences > Development > New Application
- give it a nice name
- enable
read:account
,admin:write:accounts
, andadmin:read:accounts
- Save
- Copy the value of
Your access token
If you wish to run this as a GitHub action:
- Fork this repository
- Adjust the settings in
./config.sh
for your need - Create an Actions Secret called
ACCESS_TOKEN
, and supply the token generated above:- Go to Settings > Secrets and Variables > Actions
- Click New Repository Secret
- Supply the Name and Secret
- Finally go to the 'Actions' tab and enable the action.
Honestly, if you want to run this locally, you are probably better of using the original script, as it's a self-contained version, but if you do want run this version locally you could:
- copy the script on your machine
- Adjust the settings in
./config.sh
for your need - setup a cronjob that would run
bash /path/to/repo/block_hashtags.sh "{ACCESS_TOKEN}"
Both the idea and the original implementation are based on @[email protected]'s script.
Find me on my Mastodon instance at @[email protected].