1package rules
2
3import (
4 appbsky "github.com/bluesky-social/indigo/api/bsky"
5 "github.com/bluesky-social/indigo/automod"
6 "github.com/bluesky-social/indigo/automod/keyword"
7)
8
9var _ automod.PostRuleFunc = AccountDemoPostRule
10
11// this is a dummy rule to demonstrate accessing account metadata (eg, profile) from within post handler
12func AccountDemoPostRule(c *automod.RecordContext, post *appbsky.FeedPost) error {
13 if c.Account.Profile.Description != nil && len(post.Text) > 5 && *c.Account.Profile.Description == post.Text {
14 c.AddRecordFlag("own-profile-description")
15 c.Notify("slack")
16 }
17 return nil
18}
19
20func CelebSpamProfileRule(c *automod.RecordContext, profile *appbsky.ActorProfile) error {
21 anyElon := false
22 anyMusk := false
23 if profile.DisplayName != nil {
24 tokens := keyword.TokenizeText(*profile.DisplayName)
25 for _, tok := range tokens {
26 if tok == "elon" {
27 anyElon = true
28 }
29 if tok == "musk" {
30 anyMusk = true
31 }
32 }
33 }
34 if anyElon && anyMusk {
35 c.AddRecordFlag("profile-elon-musk")
36 c.ReportAccount(automod.ReportReasonSpam, "possible Elon Musk impersonator")
37 return nil
38 }
39 return nil
40}
41
42var _ automod.ProfileRuleFunc = CelebSpamProfileRule