Skip to content

Commit

Permalink
small rule tweaks (#489)
Browse files Browse the repository at this point in the history
  • Loading branch information
bnewbold authored Dec 21, 2023
2 parents 76f332e + 129e97e commit 4ee9720
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion automod/rules/mentions.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

var _ automod.PostRuleFunc = DistinctMentionsRule

var mentionHourlyThreshold = 20
var mentionHourlyThreshold = 40

// DistinctMentionsRule looks for accounts which mention an unusually large number of distinct accounts per period.
func DistinctMentionsRule(evt *automod.RecordEvent, post *appbsky.FeedPost) error {
Expand Down
19 changes: 14 additions & 5 deletions automod/rules/replies.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package rules

import (
"time"
"unicode/utf8"

appbsky "github.com/bluesky-social/indigo/api/bsky"
Expand Down Expand Up @@ -31,6 +32,7 @@ func ReplyCountPostRule(evt *automod.RecordEvent, post *appbsky.FeedPost) error
return nil
}

// triggers on the N+1 post, so 6th identical reply
var identicalReplyLimit = 5

// Looks for accounts posting the exact same text multiple times. Does not currently count the number of distinct accounts replied to, just counts replies at all.
Expand All @@ -41,18 +43,25 @@ func IdenticalReplyPostRule(evt *automod.RecordEvent, post *appbsky.FeedPost) er
return nil
}

// short reply? ignore it
// increment first. use a specific period (IncrementPeriod()) to reduce the number of counters (one per unique post text)
period := automod.PeriodDay
bucket := evt.Account.Identity.DID.String() + "/" + HashOfString(post.Text)
evt.IncrementPeriod("reply-text", bucket, period)

// don't action short replies, or accounts more than two weeks old
if utf8.RuneCountInString(post.Text) <= 10 {
return nil
}
if evt.Account.Private != nil {
age := time.Since(evt.Account.Private.IndexedAt)
if age > 2*7*24*time.Hour {
return nil
}
}

// use a specific period (IncrementPeriod()) to reduce the number of counters (one per unique post text)
period := automod.PeriodDay
bucket := evt.Account.Identity.DID.String() + "/" + HashOfString(post.Text)
if evt.GetCount("reply-text", bucket, period) >= identicalReplyLimit {
evt.AddAccountFlag("multi-identical-reply")
}

evt.IncrementPeriod("reply-text", bucket, period)
return nil
}

0 comments on commit 4ee9720

Please sign in to comment.