From b61571bebfa8a4b22a0acb9c22939556a26ef93e Mon Sep 17 00:00:00 2001 From: Elliott Pardee Date: Tue, 13 Jan 2015 23:33:18 -0500 Subject: [PATCH] Beginning to refactor. --- bot.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/bot.go b/bot.go index 936073e..9d128d2 100755 --- a/bot.go +++ b/bot.go @@ -40,6 +40,15 @@ var dict = map[string]string{ "cls": "class", } +var argmap = map[string]int{ + ".set": 4, + ".print": 3, + ".mode": 1, + ".rmmode": 1, + ".dm": 1, + ".resetdm": 1, +} + func fillCharmap(nick string, cat string, item string, val string) { charmap = map[string]map[string]map[string]string { nick: map[string]map[string]string{ cat: map[string]string{ item: val, }, }, } } @@ -53,9 +62,13 @@ func (b *Bot) Command(nick string, msg string) { } } + if argmap[strings.Split(msg, " ")[0]] != 1 { return } + if argmap[strings.Split(msg, " ")[0]] != len(args) { return } + + fmt.Println("hi"); // TODO: Check if mode is enabled and if command can be applied. - if strings.HasPrefix(msg, ".set") && len(args) == 4 { + if strings.HasPrefix(msg, ".set") { if nick == dunmas { fillCharmap(args[0], args[1], args[2], args[3])