kunt

golang IRC bot
git clone git://git.2f30.org/kunt
Log | Files | Refs | LICENSE

commit d8d5dc1df935c0dc33aee59b9743b21f1b24287a
parent 5cd2cdc57c4b26303e7f395b16740aa9b795a051
Author: sin <sin@2f30.org>
Date:   Fri, 10 May 2013 16:11:58 +0100

fix game command

Diffstat:
Msrc/kunt/TODO | 1-
Msrc/kunt/kunt.go | 19++++++++++++-------
2 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/src/kunt/TODO b/src/kunt/TODO @@ -7,7 +7,6 @@ Use json based configuration file Proper packaging/deploy script Logging !seen command -!game should be !game list by default Admin console using termbox 9p plugin system Include DJ info in radio plugin diff --git a/src/kunt/kunt.go b/src/kunt/kunt.go @@ -264,18 +264,23 @@ func cmdTodo(msg irc.Message) { func cmdGame(msg irc.Message) { text := msg.Args[1] if len(strings.Fields(text)) < 2 { - kunt.ircCtx.Privmsg(msg.Args[0], "Missing parameter for !game") - return - } - text = text[5:] - text = strings.TrimSpace(text) - switch text { - case "list": for _, str := range geng.List() { kunt.ircCtx.Privmsg(msg.Args[0], "[game] "+str) } return } + text = strings.TrimSpace(text[5:]) + found := false + for _, str := range geng.List() { + if str == text { + found = true + break + } + } + if !found { + kunt.ircCtx.Privmsg(msg.Args[0], "[game] game not found") + return + } gchan := make(chan irc.Message) geng.New(text, kunt.ircCtx, &gchan) time.Sleep(512 * time.Millisecond)