Skip to content

Commit

Permalink
add trivial spam text rule
Browse files Browse the repository at this point in the history
  • Loading branch information
bnewbold committed Sep 5, 2024
1 parent 0f54a07 commit 768fa44
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions automod/rules/all.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ func DefaultRules() automod.RuleSet {
HarassmentTargetInteractionPostRule,
HarassmentTrivialPostRule,
NostrSpamPostRule,
TrivialSpamPostRule,
},
ProfileRules: []automod.ProfileRuleFunc{
GtubeProfileRule,
Expand Down
25 changes: 25 additions & 0 deletions automod/rules/quick.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,28 @@ func NewAccountBotEmailRule(c *automod.AccountContext) error {
}
return nil
}

var _ automod.PostRuleFunc = TrivialSpamPostRule

// looks for new accounts, which frequently post the same type of content
func TrivialSpamPostRule(c *automod.RecordContext, post *appbsky.FeedPost) error {
if c.Account.Identity == nil || !AccountIsYoungerThan(&c.AccountContext, 8*24*time.Hour) {
return nil
}

// only posts with dumb patterns (for now)
txt := strings.ToLower(post.Text)
if !c.InSet("trivial-spam-text", txt) {
return nil
}

// only accounts with empty profile (for now)
if c.Account.Profile.HasAvatar {
return nil
}

c.ReportAccount(automod.ReportReasonOther, fmt.Sprintf("trivial spam account (also labeled; remove label if this isn't spam!)"))
c.AddAccountLabel("!hide")
c.Notify("slack")
return nil
}

0 comments on commit 768fa44

Please sign in to comment.