summaryrefslogtreecommitdiff
path: root/command.go
diff options
context:
space:
mode:
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