Moved bookmarks to a subdirectory

This commit is contained in:
2019-05-09 08:09:08 +09:00
parent ca1ed36e7b
commit 3923d6bfbf
4 changed files with 31 additions and 29 deletions

View File

@ -1,28 +1,39 @@
package main
import (
"regexp"
"fmt"
"io/ioutil"
"strings"
"unicode"
"github.com/akyoto/color"
"github.com/animenotifier/arn"
)
var flaggedWords = regexp.MustCompile("fuck|fucking|freaking|shit|bad|terrible|awful|wtf")
func main() {
color.Yellow("Showing user intros")
defer color.Green("Finished.")
defer arn.Node.Close()
data, _ := ioutil.ReadFile("bad-words-list.txt")
fullText := string(data)
badWords := strings.Split(fullText, ",")
for user := range arn.StreamUsers() {
if user.Introduction == "" {
continue
}
if flaggedWords.MatchString(user.Introduction) {
color.Cyan(user.Nick)
color.Red(user.Introduction)
for _, badWord := range badWords {
pos := strings.Index(user.Introduction, badWord)
if pos != -1 && (pos == 0 || !unicode.IsLetter(rune(user.Introduction[pos-1]))) && (pos+len(badWord) == len(user.Introduction) || !unicode.IsLetter(rune(user.Introduction[pos+len(badWord)]))) {
color.Cyan(user.Nick)
color.Red(badWord)
fmt.Println(user.Introduction)
break
}
}
}
}