https://github.com/mikedilger/gossip/blob/master/filter.example.rhai
- - - - - -
This is a sample spam filtering script for the gossip nostr
client. The language is called Rhai, details are at:
https:rhai.rs/book/
For gossip to find your spam filtering script, put it in your
gossip profile directory. See
https:docs.rs/dirs/latest/dirs/fn.data_dir.html
to find the base directory. A subdirectory "gossip" is your
gossip data directory which for most people is their profile
directory too. (Note: if you use a GOSSIP_PROFILE, you'll need
to put it one directory deeper into that profile directory).
This filter is used to filter out and refuse to process incoming
events as they flow in from relays, and also to filter which
events get displayed in certain circumstances. It is only run on
feed-displayable event kinds, and only events by authors you are
not following. In case of error, nothing is filtered.
You must define a function called 'filter' which returns one of
these constant values:
DENY (the event is filtered out)
ALLOW (the event is allowed through)
MUTE (the event is filtered out, and the author is
automatically muted)
Your script will be provided the following:
caller - a string that is one of "Process", "Thread",
"Inbox" or "Global" indicating which part of
the code is running your script
content - the event content as a string
id - the event ID, as a hex string
kind - the event kind as an integer
muted - if the author is in your mute list
name - if we have it, the name of the author (or your
petname), else an empty string
nip05valid - whether nip05 is valid for the author, as a
boolean
pow - the Proof of Work on the event
pubkey - the event author public key, as a hex string
seconds_known - the number of seconds that the author of the
event has been known to gossip
spamsafe - true only if the event came in from a relay
marked as SpamSafe during Process (even if the
global setting for SpamSafe is off)