v0.1.0
nsfwbot Image Moderation Bot for Matrix v0.1.0
This is the initial release of nsfwbot, a Matrix bot plugin designed to detect NSFW (Not Safe For Work) content in images posted in Matrix chat rooms.
When an image is detected and analyzed, nsfwbot
will reply to the message with something like:
mxc://matrix.org/abcd1234 in https://matrix.to/#/!roomid:matrix.org/$eventid?via=matrix.org appears NSFW with score 87.93%
If multiple images are detected in a text message:
- mxc://matrix.org/abcd1234 in https://matrix.to/#/!roomid:matrix.org/$eventid?via=matrix.org appears SFW with score 2.45%
- mxc://matrix.org/efgh5678 in https://matrix.to/#/!roomid:matrix.org/$eventid?via=matrix.org appears NSFW with score 94.82%
This plugin leverages the nsfwdetection model to analyse images and return a classification result, indicating whether the content is likely to be NSFW or SFW (Safe For Work).
The plugin currently only replies with a summary of the results, but future updates are planned to include moderation actions such as automatically redacting, or flagging unwanted images to a nominated moderation room.
Unfortunately, the nsfwdetection Python module does not currently run on Alpine Linux, which is the base image for the official Maubot Docker container, so I have built a Debian Bookworm variant of Maubot that is a drop-in replacement. It already has the necessary modules installed, the only real downside is that it's bigger than the standard Alpine version - simply drop ghcr.io/tcpipuk/maubot:debian
into your Docker/Kubernetes configuration if you want to use it.
Currently it provides a config option to specify the "via" server list you want to use. Typically this would just contain the server the bot is running on, but you may wish to add more for reliability - these are the servers that anyone clicking the link (who is not currently in the room) will attempt to use to download the room from.