Skip to content

Commit

Permalink
yet more rule tweaks (#745)
Browse files Browse the repository at this point in the history
  • Loading branch information
bnewbold committed Sep 5, 2024
2 parents 2462d58 + 768fa44 commit 5f33e2c
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 5 deletions.
1 change: 1 addition & 0 deletions automod/rules/all.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ func DefaultRules() automod.RuleSet {
HarassmentTargetInteractionPostRule,
HarassmentTrivialPostRule,
NostrSpamPostRule,
TrivialSpamPostRule,
},
ProfileRules: []automod.ProfileRuleFunc{
GtubeProfileRule,
Expand Down
9 changes: 6 additions & 3 deletions automod/rules/interaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
)

var interactionDailyThreshold = 800
var followsDailyThreshold = 3000

var _ automod.RecordRuleFunc = InteractionChurnRule

Expand All @@ -26,6 +27,7 @@ func InteractionChurnRule(c *automod.RecordContext) error {
c.AddAccountFlag("high-like-churn")
c.ReportAccount(automod.ReportReasonSpam, fmt.Sprintf("interaction churn: %d likes, %d unlikes today (so far)", created, deleted))
c.Notify("slack")
return nil
}
case "app.bsky.graph.follow":
c.Increment("follow", did)
Expand All @@ -37,14 +39,15 @@ func InteractionChurnRule(c *automod.RecordContext) error {
c.AddAccountFlag("high-follow-churn")
c.ReportAccount(automod.ReportReasonSpam, fmt.Sprintf("interaction churn: %d follows, %d unfollows today (so far)", created, deleted))
c.Notify("slack")
return nil
}
// just generic bulk following
followRatio := float64(c.Account.FollowersCount) / float64(c.Account.FollowsCount)
if created > interactionDailyThreshold && c.Account.FollowsCount > 2000 && followRatio < 0.2 {
if created > followsDailyThreshold {
c.Logger.Info("bulk-follower", "created-today", created)
c.AddAccountFlag("bulk-follower")
c.ReportAccount(automod.ReportReasonSpam, fmt.Sprintf("bulk following: %d follows today (so far)", created))
//c.Notify("slack")
c.Notify("slack")
return nil
}
}
return nil
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
}
10 changes: 8 additions & 2 deletions automod/rules/replies.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ func ReplyCountPostRule(c *automod.RecordContext, post *appbsky.FeedPost) error
// var identicalReplyLimit = 6
// TODO: bumping temporarily
var identicalReplyLimit = 20
var identicalReplyActionLimit = 75

var _ automod.PostRuleFunc = IdenticalReplyPostRule

Expand Down Expand Up @@ -71,7 +72,12 @@ func IdenticalReplyPostRule(c *automod.RecordContext, post *appbsky.FeedPost) er
count := c.GetCount("reply-text", bucket, period)
if count >= identicalReplyLimit {
c.AddAccountFlag("multi-identical-reply")
c.ReportAccount(automod.ReportReasonRude, fmt.Sprintf("possible spam (new account, %d identical reply-posts today)", count))
c.ReportAccount(automod.ReportReasonSpam, fmt.Sprintf("possible spam (new account, %d identical reply-posts today)", count))
c.Notify("slack")
}
if count >= identicalReplyActionLimit && utf8.RuneCountInString(post.Text) > 100 {
c.ReportAccount(automod.ReportReasonRude, fmt.Sprintf("likely spam/harassment (new account, %d identical reply-posts today), actioned (remove label urgently if account is ok)", count))
c.AddAccountLabel("!warn")
c.Notify("slack")
}

Expand Down Expand Up @@ -115,7 +121,7 @@ func IdenticalReplyPostSameParentRule(c *automod.RecordContext, post *appbsky.Fe

// TODO: bumping temporarily
// var youngReplyAccountLimit = 12
var youngReplyAccountLimit = 30
var youngReplyAccountLimit = 200
var _ automod.PostRuleFunc = YoungAccountDistinctRepliesRule

func YoungAccountDistinctRepliesRule(c *automod.RecordContext, post *appbsky.FeedPost) error {
Expand Down

0 comments on commit 5f33e2c

Please sign in to comment.