From 47655b3e663d4172126e757f752be775f00b70a1 Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Sat, 23 Sep 2017 14:04:00 -0400 Subject: [PATCH] Mark Mastodon clients as bot --- bots/bots.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/bots/bots.go b/bots/bots.go index 809efc3..7b50986 100644 --- a/bots/bots.go +++ b/bots/bots.go @@ -3,6 +3,8 @@ // incrementing the view count. package bots +import "strings" + var bots = map[string]bool{ "ABACHOBot/8.14 (Windows NT 6.1 1.5; ko;)": true, "AddThis.com robot tech.support@clearspring.com": true, @@ -215,11 +217,20 @@ var bots = map[string]bool{ "Y!J-ASR/0.1 crawler (http://www.yahoo-help.jp/app/answers/detail/p/595/a_id/42716/)": true, } +var botPrefixes = []string{ + "http.rb/2.2.2 (Mastodon", +} + // IsBot returns whether or not the provided User-Agent string is a known bot // or crawler. func IsBot(ua string) bool { if _, ok := bots[ua]; ok { return true } + for _, p := range botPrefixes { + if strings.HasPrefix(ua, p) { + return true + } + } return false }