Custom Filters
Filters replaces the Content Protection service that was deprecated in Unifier 3.8.0 (release 139).
The Filters service allows your Modifier to install Filters to a Unifier instance.
Base Filter code
All Filters must have this base code:
Adding Filters to your Modifier
Under the filters
key in plugin.json, add the filename/filepath of your Filter's code to the array.
The message data dictionary (message)
For each message being scanned by Filters, Unifier will provide the following data under the messages argument when it calls the check function:
author
(string): The message author's user IDbot
(boolean): Whether the message author is a bot or notwebhook_id
(string): The webhook ID of the message, if applicablecontent
(string): The message contentfiles
(integer): The number of files in the message
The Filter data dictionary (data)
For each Filter, Unifier stores some data such as data stored by the Filter and configuration values. Unifier will provide the following data under the data argument:
config
(dictionary): The configuration values of the Filterdata
(dictionary): Temporary data stored by the Filterglobal
(boolean): Whether the Filter is called because it was globally enabled (if this is false, it means it was called because it is enabled by the Room)
Responding to Filter calls
For every Filter call, Unifier will expect the Filter to return a FilterResult
object. This is available under utils.base_filter
.
The object's constructor requires the following positional arguments:
allowed
(boolean): Whether the message should be allowed or not
You may also provide the following optional keyword arguments:
data
(dictionary): Temporary Filter data to store to Unifier (there is no fixed format for this)message
(string): The message that should be shown to the user ifallowed
is False andshould_log
is Trueshould_log
(boolean): Whether the Filter trigger (i.e.allowed
is False) should be logged or notshould_contribute
(boolean): Whether the Filter trigger should contribute to the Automatic UAM threshold
Compatibility
Modifiers offering Emojis service should have a minimum Unifier release requirement of 144 or above.
Last updated