summaryrefslogtreecommitdiff
path: root/command.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2015-09-21 23:27:29 +0200
committerDimitri Sokolyuk <demon@dim13.org>2015-09-21 23:27:29 +0200
commitdcec8549b4a91863d6f8820582bd757447a6b408 (patch)
tree1e4a4718e0ea6694308bd40a0857c531d89baa0b /command.go
parent3daaf1f4f28443dfb0439d1f8ced0b129fd89d76 (diff)
Move Help() into interface{}
Diffstat (limited to 'command.go')
-rw-r--r--command.go16
1 files changed, 6 insertions, 10 deletions
diff --git a/command.go b/command.go
index e4ee147..b2bdb59 100644
--- a/command.go
+++ b/command.go
@@ -1,7 +1,6 @@
package main
import (
- "fmt"
"log"
"strings"
"time"
@@ -11,15 +10,13 @@ import (
type Commander interface {
irc.Handler
- fmt.Stringer
Timeout(string) bool
WithArgs(int) bool
+ Help() string
}
type Command struct {
- Help string
- Arg string
- Last map[string]time.Time
+ last map[string]time.Time
}
var commands = make(map[string]Commander)
@@ -28,13 +25,12 @@ func Register(cmd string, f Commander) {
commands[cmd] = f
}
-func (v Command) String() string { return v.Help }
func (v *Command) Timeout(nick string) bool {
- defer func() { v.Last[nick] = time.Now() }()
- if v.Last == nil {
- v.Last = make(map[string]time.Time)
+ defer func() { v.last[nick] = time.Now() }()
+ if v.last == nil {
+ v.last = make(map[string]time.Time)
}
- if last, ok := v.Last[nick]; ok {
+ if last, ok := v.last[nick]; ok {
if to := time.Since(last); to < 5*time.Second {
log.Println(nick, "timeout", to)
return true