From 460bac780774bb582153313d06f67f331d18506f Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Mon, 21 Mar 2016 21:46:14 +0100 Subject: Reduce interface --- command.go | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) (limited to 'command.go') diff --git a/command.go b/command.go index 45bbef0..4fb08a5 100644 --- a/command.go +++ b/command.go @@ -3,37 +3,27 @@ package main import ( "log" "strings" - "time" irc "github.com/fluffle/goirc/client" ) type Commander interface { irc.Handler - WithArgs(int) bool Help() string } -type Command struct { - lastCmd map[string]time.Time -} - var commands = make(map[string]Commander) func Register(cmd string, f Commander) { commands[cmd] = f } -func (_ Command) WithArgs(n int) bool { return n == 1 } - func Dispatch(conn *irc.Conn, line *irc.Line) { if f := strings.Fields(line.Text()); len(f) > 0 { cmd := strings.ToLower(f[0]) if c, ok := commands[cmd]; ok { - if c.WithArgs(len(f)) { - log.Println(line.Nick, f) - c.Handle(conn, line) - } + log.Println(line.Nick, f) + c.Handle(conn, line) } } } -- cgit v1.2.3