diff --git a/modules/markov.go b/modules/markov.go index ac07aa5..8a5fa84 100644 --- a/modules/markov.go +++ b/modules/markov.go @@ -79,46 +79,37 @@ func markovRun() { markovChain.Save(ModParams["markov-state-file"]) } }() - } func markovParseText(text string) string { messageRegex := regexp.MustCompile(`<([^>]+)>`) matches := messageRegex.FindAllStringSubmatch(text, -1) for _, matches2 := range matches { - if strings.HasPrefix(matches2[1], "http") || strings.HasPrefix(matches2[1], "mailto") { text = strings.Replace(text, matches2[0], "", -1) - } else if strings.HasPrefix(matches2[1], "@U") { parts := strings.SplitN(matches2[1], "|", 2) - if len(parts) == 2 { text = strings.Replace(text, matches2[0], "@"+parts[1], -1) } else { text = strings.Replace(text, matches2[0], "", -1) } - } else if strings.HasPrefix(matches2[1], "@") { text = strings.Replace(text, matches2[0], matches2[1], -1) - } else if strings.HasPrefix(matches2[1], "#") { parts := strings.SplitN(matches2[1], "|", 2) - if len(parts) == 2 { text = strings.Replace(text, matches2[0], "#"+parts[1], -1) } else { text = strings.Replace(text, matches2[0], "", -1) } - } } - text = strings.TrimSpace(text) - text = strings.Replace(text, "<", "<", -1) text = strings.Replace(text, ">", ">", -1) text = strings.Replace(text, "&", "&", -1) + text = strings.Replace(text, ",", " ", -1) return strings.ToLower(text) } diff --git a/modules/quiz.go b/modules/quiz.go index 707c111..8b79ec0 100644 --- a/modules/quiz.go +++ b/modules/quiz.go @@ -102,20 +102,24 @@ func quizPrintRanklist(ranklist map[string]int) { if len(ranklist) == 0 { return } + ranklistc := make(map[string]int, 0) + for k, v := range ranklist { + ranklistc[k] = v + } SayCh <- fmt.Sprintf("%s\nAktueller Punktestand:", "*") for { maxk := "" maxv := -1 - if len(ranklist) == 0 { + if len(ranklistc) == 0 { break } - for k, v := range ranklist { + for k, v := range ranklistc { if v > maxv { maxv = v maxk = k } } - delete(ranklist, maxk) + delete(ranklistc, maxk) SayCh <- fmt.Sprintf("%s\n%s: %d", "*", maxk, maxv) } }