From 5d2392bc5ef2185a3940a587337da2f5772def9a Mon Sep 17 00:00:00 2001 From: Andreas Neue Date: Sat, 21 Jan 2017 18:20:57 +0100 Subject: [PATCH] modules/nickserv.go: removed, modules/quiz.go: sorted ranklist --- Makefile | 3 +++ modules/nickserv.go | 20 -------------------- modules/quiz.go | 19 +++++++++++++++++-- 3 files changed, 20 insertions(+), 22 deletions(-) delete mode 100644 modules/nickserv.go diff --git a/Makefile b/Makefile index bb65274..7d9e777 100644 --- a/Makefile +++ b/Makefile @@ -9,6 +9,9 @@ build: genversion genbuilddate test build-win: test genversion GOOS=windows GOARCH=amd64 go build -v -o flokatirc.exe flokatirc +docker: build + ./dockerbuild.sh + genversion: ./genversion.sh diff --git a/modules/nickserv.go b/modules/nickserv.go deleted file mode 100644 index ea90c9e..0000000 --- a/modules/nickserv.go +++ /dev/null @@ -1,20 +0,0 @@ -// vi:ts=4:sts=4:sw=4:noet:tw=72 - -package modules - -import ( - "fmt" - "time" -) - -func init() { - RunFuncs["nickserv"] = nickservRun -} - -func nickservRun() { - pass := ModParams["nickserv-pass"] - email := ModParams["nickserv-email"] - time.Sleep(10 * time.Second) - SayCh <- fmt.Sprintf("%s\n%s %s %s", "N", "REGISTER", pass, email) - SayCh <- fmt.Sprintf("%s\n%s %s", "N", "IDENTIFY", pass) -} diff --git a/modules/quiz.go b/modules/quiz.go index 79cfdc2..707c111 100644 --- a/modules/quiz.go +++ b/modules/quiz.go @@ -99,9 +99,24 @@ func quizRun() { } func quizPrintRanklist(ranklist map[string]int) { + if len(ranklist) == 0 { + return + } SayCh <- fmt.Sprintf("%s\nAktueller Punktestand:", "*") - for k, v := range ranklist { - SayCh <- fmt.Sprintf("%s\n%s: %d", "*", k, v) + for { + maxk := "" + maxv := -1 + if len(ranklist) == 0 { + break + } + for k, v := range ranklist { + if v > maxv { + maxv = v + maxk = k + } + } + delete(ranklist, maxk) + SayCh <- fmt.Sprintf("%s\n%s: %d", "*", maxk, maxv) } }