this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

automod: mentions spike rule (#482)

Introduce a simple new rule for detecting and flagging spikes of
mentions within a period.

authored by

bnewbold and committed by
GitHub
998c0669 23f022e2

+39
+1
automod/rules/all.go
··· 19 19 ReplySingleKeywordPostRule, 20 20 AggressivePromotionRule, 21 21 IdenticalReplyPostRule, 22 + DistinctMentionsRule, 22 23 }, 23 24 ProfileRules: []automod.ProfileRuleFunc{ 24 25 GtubeProfileRule,
+38
automod/rules/mentions.go
··· 1 + package rules 2 + 3 + import ( 4 + appbsky "github.com/bluesky-social/indigo/api/bsky" 5 + "github.com/bluesky-social/indigo/automod" 6 + ) 7 + 8 + var _ automod.PostRuleFunc = DistinctMentionsRule 9 + 10 + var mentionHourlyThreshold = 20 11 + 12 + // DistinctMentionsRule looks for accounts which mention an unusually large number of distinct accounts per period. 13 + func DistinctMentionsRule(evt *automod.RecordEvent, post *appbsky.FeedPost) error { 14 + did := evt.Account.Identity.DID.String() 15 + 16 + // Increment counters for all new mentions in this post. 17 + var newMentions bool 18 + for _, facet := range post.Facets { 19 + for _, feature := range facet.Features { 20 + mention := feature.RichtextFacet_Mention 21 + if mention == nil { 22 + continue 23 + } 24 + evt.IncrementDistinct("mentions", did, mention.Did) 25 + newMentions = true 26 + } 27 + } 28 + 29 + // If there were any new mentions, check if it's gotten spammy. 30 + if !newMentions { 31 + return nil 32 + } 33 + if mentionHourlyThreshold <= evt.GetCountDistinct("mentions", did, automod.PeriodHour) { 34 + evt.AddAccountFlag("high-distinct-mentions") 35 + } 36 + 37 + return nil 38 + }