this repo has no description
0
fork

Configure Feed

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

automod: annotate rules with function types (#502)

As discussed; pretty straight-forward

authored by

bnewbold and committed by
GitHub
0590ced0 e711d4a7

+34
+4
automod/rules/gtube.go
··· 10 10 // https://en.wikipedia.org/wiki/GTUBE 11 11 var gtubeString = "XJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X" 12 12 13 + var _ automod.PostRuleFunc = GtubePostRule 14 + 13 15 func GtubePostRule(c *automod.RecordContext, post *appbsky.FeedPost) error { 14 16 if strings.Contains(post.Text, gtubeString) { 15 17 c.AddRecordLabel("spam") 16 18 } 17 19 return nil 18 20 } 21 + 22 + var _ automod.ProfileRuleFunc = GtubeProfileRule 19 23 20 24 func GtubeProfileRule(c *automod.RecordContext, profile *appbsky.ActorProfile) error { 21 25 if profile.Description != nil && strings.Contains(*profile.Description, gtubeString) {
+4
automod/rules/hashtags.go
··· 5 5 "github.com/bluesky-social/indigo/automod" 6 6 ) 7 7 8 + var _ automod.PostRuleFunc = BadHashtagsPostRule 9 + 8 10 // looks for specific hashtags from known lists 9 11 func BadHashtagsPostRule(c *automod.RecordContext, post *appbsky.FeedPost) error { 10 12 for _, tag := range ExtractHashtags(post) { ··· 16 18 } 17 19 return nil 18 20 } 21 + 22 + var _ automod.PostRuleFunc = TooManyHashtagsPostRule 19 23 20 24 // if a post is "almost all" hashtags, it might be a form of search spam 21 25 func TooManyHashtagsPostRule(c *automod.RecordContext, post *appbsky.FeedPost) error {
+2
automod/rules/identity.go
··· 9 9 "github.com/bluesky-social/indigo/automod/countstore" 10 10 ) 11 11 12 + var _ automod.IdentityRuleFunc = NewAccountRule 13 + 12 14 // triggers on first identity event for an account (DID) 13 15 func NewAccountRule(c *automod.AccountContext) error { 14 16 // need access to IndexedAt for this rule
+4
automod/rules/interaction.go
··· 9 9 10 10 var interactionDailyThreshold = 800 11 11 12 + var _ automod.RecordRuleFunc = InteractionChurnRule 13 + 12 14 // looks for accounts which do frequent interaction churn, such as follow-unfollow. 13 15 func InteractionChurnRule(c *automod.RecordContext) error { 14 16 did := c.Account.Identity.DID.String() ··· 36 38 } 37 39 return nil 38 40 } 41 + 42 + var _ automod.RecordRuleFunc = DeleteInteractionRule 39 43 40 44 func DeleteInteractionRule(c *automod.RecordContext) error { 41 45 did := c.Account.Identity.DID.String()
+6
automod/rules/keyword.go
··· 7 7 "github.com/bluesky-social/indigo/automod" 8 8 ) 9 9 10 + var _ automod.PostRuleFunc = KeywordPostRule 11 + 10 12 func KeywordPostRule(c *automod.RecordContext, post *appbsky.FeedPost) error { 11 13 for _, tok := range ExtractTextTokensPost(post) { 12 14 if c.InSet("bad-words", tok) { ··· 18 20 return nil 19 21 } 20 22 23 + var _ automod.ProfileRuleFunc = KeywordProfileRule 24 + 21 25 func KeywordProfileRule(c *automod.RecordContext, profile *appbsky.ActorProfile) error { 22 26 for _, tok := range ExtractTextTokensProfile(profile) { 23 27 if c.InSet("bad-words", tok) { ··· 28 32 } 29 33 return nil 30 34 } 35 + 36 + var _ automod.PostRuleFunc = ReplySingleKeywordPostRule 31 37 32 38 func ReplySingleKeywordPostRule(c *automod.RecordContext, post *appbsky.FeedPost) error { 33 39 if post.Reply != nil && !IsSelfThread(c, post) {
+4
automod/rules/misleading.go
··· 78 78 return false 79 79 } 80 80 81 + var _ automod.PostRuleFunc = MisleadingURLPostRule 82 + 81 83 func MisleadingURLPostRule(c *automod.RecordContext, post *appbsky.FeedPost) error { 82 84 // TODO: make this an InSet() config? 83 85 if c.Account.Identity.Handle == "nowbreezing.ntw.app" { ··· 99 101 } 100 102 return nil 101 103 } 104 + 105 + var _ automod.PostRuleFunc = MisleadingMentionPostRule 102 106 103 107 func MisleadingMentionPostRule(c *automod.RecordContext, post *appbsky.FeedPost) error { 104 108 // TODO: do we really need to route context around? probably
+2
automod/rules/private.go
··· 7 7 "github.com/bluesky-social/indigo/automod" 8 8 ) 9 9 10 + var _ automod.PostRuleFunc = AccountPrivateDemoPostRule 11 + 10 12 // dummy rule. this leaks PII (account email) in logs and should never be used in real life 11 13 func AccountPrivateDemoPostRule(c *automod.RecordContext, post *appbsky.FeedPost) error { 12 14 if c.Account.Private != nil {
+2
automod/rules/profile.go
··· 5 5 "github.com/bluesky-social/indigo/automod" 6 6 ) 7 7 8 + var _ automod.PostRuleFunc = AccountDemoPostRule 9 + 8 10 // this is a dummy rule to demonstrate accessing account metadata (eg, profile) from within post handler 9 11 func AccountDemoPostRule(c *automod.RecordContext, post *appbsky.FeedPost) error { 10 12 if c.Account.Profile.Description != nil && len(post.Text) > 5 && *c.Account.Profile.Description == post.Text {
+2
automod/rules/promo.go
··· 10 10 "github.com/bluesky-social/indigo/automod/countstore" 11 11 ) 12 12 13 + var _ automod.PostRuleFunc = AggressivePromotionRule 14 + 13 15 // looks for new accounts, with a commercial or donation link in profile, which directly reply to several accounts 14 16 // 15 17 // this rule depends on ReplyCountPostRule() to set counts
+4
automod/rules/replies.go
··· 10 10 "github.com/bluesky-social/indigo/automod/countstore" 11 11 ) 12 12 13 + var _ automod.PostRuleFunc = ReplyCountPostRule 14 + 13 15 // does not count "self-replies" (direct to self, or in own post thread) 14 16 func ReplyCountPostRule(c *automod.RecordContext, post *appbsky.FeedPost) error { 15 17 if post.Reply == nil || IsSelfThread(c, post) { ··· 34 36 35 37 // triggers on the N+1 post, so 6th identical reply 36 38 var identicalReplyLimit = 5 39 + 40 + var _ automod.PostRuleFunc = IdenticalReplyPostRule 37 41 38 42 // 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. 39 43 //