Fix: modules.go added.

This commit is contained in:
Andreas Neue 2016-02-26 22:14:21 +01:00
parent 44ee1cf628
commit c62ea59905
2 changed files with 35 additions and 3 deletions

View File

@ -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 {

35
modules/modules.go Normal file
View File

@ -0,0 +1,35 @@
// vi:ts=4:sts=4:sw=4:noet:tw=72
//
// flokatirc
//
// Copyright (c) 2015,2016 Andreas Neue <an@dnix.de>
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)
}
}