package main

import (
	"log"
	"strings"
)

func initBadWords() {
	key := "config:badwords"
	count, _ := rdb.SCard(ctx, key).Result()

	if count == 0 {
		log.Println("Lade Default Badwords...")
		defaults := []string{"admin", "root", "hitler", "nazi", "sex", "fuck", "shit", "ass"}
		for _, w := range defaults {
			rdb.SAdd(ctx, key, w)
		}
	}
}

func containsBadWord(name string) bool {
	badwords, _ := rdb.SMembers(ctx, "config:badwords").Result()

	lowerName := strings.ToLower(name)

	for _, word := range badwords {
		if word == "" {
			continue
		}
		if strings.Contains(lowerName, strings.ToLower(word)) {
			return true
		}
	}
	return false
}
