From c62ea5990561e3d396ca8a6b7bc904d2a4ef7333 Mon Sep 17 00:00:00 2001 From: Andreas Neue Date: Fri, 26 Feb 2016 22:14:21 +0100 Subject: [PATCH] Fix: modules.go added. --- modules/fuzzytime.go | 3 --- modules/modules.go | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 modules/modules.go diff --git a/modules/fuzzytime.go b/modules/fuzzytime.go index 38a09c3..4ce52cb 100644 --- a/modules/fuzzytime.go +++ b/modules/fuzzytime.go @@ -31,7 +31,6 @@ func fuzzytimeHandleMessage(m *irc.Message) { } func fuzzytimeShow() { - log.Println("timeshow") t := time.Now() h := t.Hour() tzcorrect := 1 @@ -66,9 +65,7 @@ func fuzzytimeShow() { default: s += fmt.Sprintf("%s Uhr\n", fuzzytimeSayHour(h+1)) } - log.Println("saying now:", s) SayCh <- fmt.Sprintf("*\n%s", s) - } func fuzzytimeSayHour(h int) string { diff --git a/modules/modules.go b/modules/modules.go new file mode 100644 index 0000000..ee61d66 --- /dev/null +++ b/modules/modules.go @@ -0,0 +1,35 @@ +// vi:ts=4:sts=4:sw=4:noet:tw=72 +// +// flokatirc +// +// Copyright (c) 2015,2016 Andreas Neue + +package modules + +import ( + "log" + "strings" + + "github.com/sorcix/irc" +) + +var ( + SayCh chan string + MsgHandlers = make(map[string]func(*irc.Message)) + ModParams = make(map[string]string) +) + +func Init(ch chan string, params string) { + SayCh = ch + for _, param := range strings.Split(params, "!") { + kv := strings.Split(param, ":") + ModParams[kv[0]] = kv[1] + log.Println(kv[0], kv[1]) + } +} + +func HandleMessage(m *irc.Message) { + for _, fn := range MsgHandlers { + fn(m) + } +}