From 8d26e2b35de91131a49505e2d178556c3017b76f Mon Sep 17 00:00:00 2001 From: Elliott Pardee Date: Mon, 12 Jan 2015 18:48:59 -0500 Subject: [PATCH] making Command() less ugly --- bot.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/bot.go b/bot.go index 3e18bfa..936073e 100755 --- a/bot.go +++ b/bot.go @@ -56,6 +56,7 @@ func (b *Bot) Command(nick string, msg string) { // TODO: Check if mode is enabled and if command can be applied. if strings.HasPrefix(msg, ".set") && len(args) == 4 { + if nick == dunmas { fillCharmap(args[0], args[1], args[2], args[3]) fmt.Println("[cmd] set - " + args[0] + "'s " + args[2] + "in " + args[1] + " is set to " + args[3] + ".") @@ -64,10 +65,14 @@ func (b *Bot) Command(nick string, msg string) { fmt.Println("[cmd] set - " + args[0] + "'s " + args[2] + " in " + args[1] + " is set to " + args[3] + ".") b.Say(nick + " used override, it's super effective!") } + } else if strings.HasPrefix(msg, ".print") && len(args) == 3 { + fmt.Println("[cmd] print - " + args[0] + "'s " + args[2] + " in " + args[1] + ".") b.Say(args[0] + "'s " + args[2] + " is set to " + charmap[args[0]][args[1]][args[2]] + ".") + } else if strings.HasPrefix(msg, ".mode") && len(args) == 1 { + if stringInSlice(args[0], rulemod) { fmt.Println("[cmd] mode - change to " + args[0] + " failed, already set to true") b.Say(args[0] + " is already set to true.") @@ -75,14 +80,18 @@ func (b *Bot) Command(nick string, msg string) { fmt.Println("[cmd] mode - " + args[0]) b.Say(args[0] + " is now enabled.") } + } else if strings.HasPrefix(msg, ".rmmode") && len(args) == 1 { + if removeItemInSlice(args[0], rulemod) { fmt.Println("[cmd] rmmode - " + args[0]) b.Say(args[0] + " has been removed from the list of modes.") } else { b.Say(args[0] + " isn't in the list of modes.") } + } else if strings.HasPrefix(msg, ".dm") && len(args) == 1 { + if len(dunmas) == 0 { dunmas = args[0] fmt.Println("[cmd] dm - " + dunmas) @@ -90,13 +99,18 @@ func (b *Bot) Command(nick string, msg string) { } else { b.Say("dm has already been set, the current DM is " + dunmas) } + } else if msg == ".resetdm" && (nick == dunmas || stringInSlice(nick, admins)) { + dunmas = "" fmt.Println("[cmd] resetdm") b.Say("dm has been reset") + } else if msg == ".quit" && stringInSlice(nick, admins) { + fmt.Println("[cmd] shutdown from " + nick) os.Exit(1) + } }