From 46bddd57c07e133c0c728ac342e7077dbe126a36 Mon Sep 17 00:00:00 2001 From: bryan newbold Date: Thu, 4 Apr 2024 13:50:35 -0700 Subject: [PATCH] celebrity spam / impersonation flagging --- automod/rules/all.go | 2 ++ automod/rules/identity.go | 18 ++++++++++++++++-- automod/rules/profile.go | 25 +++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 2 deletions(-) diff --git a/automod/rules/all.go b/automod/rules/all.go index c734deec..88e2cf36 100644 --- a/automod/rules/all.go +++ b/automod/rules/all.go @@ -29,6 +29,7 @@ func DefaultRules() automod.RuleSet { GtubeProfileRule, BadWordProfileRule, BotLinkProfileRule, + CelebSpamProfileRule, }, RecordRules: []automod.RecordRuleFunc{ InteractionChurnRule, @@ -43,6 +44,7 @@ func DefaultRules() automod.RuleSet { BadWordHandleRule, BadWordDIDRule, NewAccountBotEmailRule, + CelebSpamIdentityRule, }, BlobRules: []automod.BlobRuleFunc{ //BlobVerifyRule, diff --git a/automod/rules/identity.go b/automod/rules/identity.go index 80f8011b..c203d169 100644 --- a/automod/rules/identity.go +++ b/automod/rules/identity.go @@ -9,8 +9,6 @@ import ( "github.com/bluesky-social/indigo/automod/countstore" ) -var _ automod.IdentityRuleFunc = NewAccountRule - // triggers on first identity event for an account (DID) func NewAccountRule(c *automod.AccountContext) error { // need access to IndexedAt for this rule @@ -47,3 +45,19 @@ func NewAccountRule(c *automod.AccountContext) error { } return nil } + +var _ automod.IdentityRuleFunc = NewAccountRule + +func CelebSpamIdentityRule(c *automod.AccountContext) error { + + hdl := c.Account.Identity.Handle.String() + if strings.Contains(hdl, "elon") && strings.Contains(hdl, "musk") { + c.AddAccountFlag("handle-elon-musk") + c.ReportAccount(automod.ReportReasonSpam, "possible Elon Musk impersonator") + return nil + } + + return nil +} + +var _ automod.IdentityRuleFunc = CelebSpamIdentityRule diff --git a/automod/rules/profile.go b/automod/rules/profile.go index 2c580bad..0ad674d7 100644 --- a/automod/rules/profile.go +++ b/automod/rules/profile.go @@ -3,6 +3,7 @@ package rules import ( appbsky "github.com/bluesky-social/indigo/api/bsky" "github.com/bluesky-social/indigo/automod" + "github.com/bluesky-social/indigo/automod/keyword" ) var _ automod.PostRuleFunc = AccountDemoPostRule @@ -15,3 +16,27 @@ func AccountDemoPostRule(c *automod.RecordContext, post *appbsky.FeedPost) error } return nil } + +func CelebSpamProfileRule(c *automod.RecordContext, profile *appbsky.ActorProfile) error { + anyElon := false + anyMusk := false + if profile.DisplayName != nil { + tokens := keyword.TokenizeText(*profile.DisplayName) + for _, tok := range tokens { + if tok == "elon" { + anyElon = true + } + if tok == "musk" { + anyMusk = true + } + } + } + if anyElon && anyMusk { + c.AddRecordFlag("profile-elon-musk") + c.ReportAccount(automod.ReportReasonSpam, "possible Elon Musk impersonator") + return nil + } + return nil +} + +var _ automod.ProfileRuleFunc = CelebSpamProfileRule -- 2.51.2