Mark Mastodon clients as bot

This commit is contained in:
Matt Baer
2017-09-23 14:04:00 -04:00
parent d38bfb4ae9
commit 47655b3e66
+11
View File
@@ -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
}