this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

automod rule tweaks: slurs, follow ratio, celeb impersonation (#634)

authored by

bnewbold and committed by
GitHub
b0cfa26f 65fc1854

+56 -4
+2
automod/rules/all.go
··· 29 29 GtubeProfileRule, 30 30 BadWordProfileRule, 31 31 BotLinkProfileRule, 32 + CelebSpamProfileRule, 32 33 }, 33 34 RecordRules: []automod.RecordRuleFunc{ 34 35 InteractionChurnRule, ··· 43 44 BadWordHandleRule, 44 45 BadWordDIDRule, 45 46 NewAccountBotEmailRule, 47 + CelebSpamIdentityRule, 46 48 }, 47 49 BlobRules: []automod.BlobRuleFunc{ 48 50 //BlobVerifyRule,
+16 -2
automod/rules/identity.go
··· 9 9 "github.com/bluesky-social/indigo/automod/countstore" 10 10 ) 11 11 12 - var _ automod.IdentityRuleFunc = NewAccountRule 13 - 14 12 // triggers on first identity event for an account (DID) 15 13 func NewAccountRule(c *automod.AccountContext) error { 16 14 // need access to IndexedAt for this rule ··· 47 45 } 48 46 return nil 49 47 } 48 + 49 + var _ automod.IdentityRuleFunc = NewAccountRule 50 + 51 + func CelebSpamIdentityRule(c *automod.AccountContext) error { 52 + 53 + hdl := c.Account.Identity.Handle.String() 54 + if strings.Contains(hdl, "elon") && strings.Contains(hdl, "musk") { 55 + c.AddAccountFlag("handle-elon-musk") 56 + c.ReportAccount(automod.ReportReasonSpam, "possible Elon Musk impersonator") 57 + return nil 58 + } 59 + 60 + return nil 61 + } 62 + 63 + var _ automod.IdentityRuleFunc = CelebSpamIdentityRule
+1 -1
automod/rules/interaction.go
··· 40 40 } 41 41 // just generic bulk following 42 42 followRatio := float64(c.Account.FollowersCount) / float64(c.Account.FollowsCount) 43 - if created > interactionDailyThreshold && c.Account.FollowsCount > 2000 && followRatio < 0.1 { 43 + if created > interactionDailyThreshold && c.Account.FollowsCount > 2000 && followRatio < 0.2 { 44 44 c.Logger.Info("bulk-follower", "created-today", created) 45 45 c.AddAccountFlag("bulk-follower") 46 46 c.ReportAccount(automod.ReportReasonSpam, fmt.Sprintf("bulk following: %d follows today (so far)", created))
+12 -1
automod/rules/keyword.go
··· 11 11 ) 12 12 13 13 func BadWordPostRule(c *automod.RecordContext, post *appbsky.FeedPost) error { 14 + isJapanese := false 15 + for _, lang := range post.Langs { 16 + if lang == "ja" || strings.HasPrefix(lang, "ja-") { 17 + isJapanese = true 18 + } 19 + } 14 20 for _, tok := range ExtractTextTokensPost(post) { 15 21 word := keyword.SlugIsExplicitSlur(tok) 16 22 // used very frequently in a reclaimed context 17 - if word != "" && word != "faggot" && word != "tranny" { 23 + if word != "" && word != "faggot" && word != "tranny" && word != "coon" && !(word == "kike" && isJapanese) { 18 24 c.AddRecordFlag("bad-word-text") 19 25 c.ReportRecord(automod.ReportReasonRude, fmt.Sprintf("possible bad word in post text or alttext: %s", word)) 20 26 //c.Notify("slack") ··· 23 29 // de-pluralize 24 30 tok = strings.TrimSuffix(tok, "s") 25 31 if c.InSet("worst-words", tok) { 32 + // skip this specific term, if used in a Japanese language post 33 + if isJapanese && tok == "kike" { 34 + continue 35 + } 36 + 26 37 c.AddRecordFlag("bad-word-text") 27 38 c.ReportRecord(automod.ReportReasonRude, fmt.Sprintf("possible bad word in post text or alttext: %s", tok)) 28 39 //c.Notify("slack")
+25
automod/rules/profile.go
··· 3 3 import ( 4 4 appbsky "github.com/bluesky-social/indigo/api/bsky" 5 5 "github.com/bluesky-social/indigo/automod" 6 + "github.com/bluesky-social/indigo/automod/keyword" 6 7 ) 7 8 8 9 var _ automod.PostRuleFunc = AccountDemoPostRule ··· 15 16 } 16 17 return nil 17 18 } 19 + 20 + func 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 + 42 + var _ automod.ProfileRuleFunc = CelebSpamProfileRule