1package rules
2
3import (
4 "strings"
5 "time"
6
7 appbsky "github.com/bluesky-social/indigo/api/bsky"
8 "github.com/bluesky-social/indigo/automod"
9 "github.com/bluesky-social/indigo/automod/helpers"
10)
11
12var _ automod.PostRuleFunc = NostrSpamPostRule
13
14// looks for new accounts, which frequently post the same type of content
15func NostrSpamPostRule(c *automod.RecordContext, post *appbsky.FeedPost) error {
16 if c.Account.Identity == nil || !helpers.AccountIsYoungerThan(&c.AccountContext, 2*24*time.Hour) {
17 return nil
18 }
19
20 // is this a bridged nostr account? if not, bail out
21 hdl := c.Account.Identity.Handle.String()
22 if !(strings.HasPrefix(hdl, "npub") && len(hdl) > 63 && strings.HasSuffix(hdl, ".brid.gy")) {
23 return nil
24 }
25
26 c.AddAccountFlag("nostr")
27
28 // only posts with dumb patterns (for now)
29 txt := strings.ToLower(post.Text)
30 if !c.InSet("trivial-spam-text", txt) {
31 return nil
32 }
33
34 // only accounts with empty profile (for now)
35 if c.Account.Profile.HasAvatar {
36 return nil
37 }
38
39 c.ReportAccount(automod.ReportReasonOther, "likely nostr spam account (also labeled; remove label if this isn't spam!)")
40 c.AddAccountLabel("!hide")
41 c.Notify("slack")
42 return nil
43}