Skip to content

Commit

Permalink
replies rule: only new accounts (2 week window)
Browse files Browse the repository at this point in the history
  • Loading branch information
bnewbold committed Dec 19, 2023
1 parent 3debfdd commit 65c408e
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 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,23 @@ 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
}
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 65c408e

Please sign in to comment.