summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2016-03-21 21:37:00 +0100
committerDimitri Sokolyuk <demon@dim13.org>2016-03-21 21:37:00 +0100
commitb22a54c2e97a5e68590352c86235a8da245d5311 (patch)
tree8361b912326bf8fa9bdb687752faba7895193be8
parent88d10d13ae0b30423452d1688f866bbc5318384e (diff)
Drop timeout
-rw-r--r--command.go21
1 files changed, 0 insertions, 21 deletions
diff --git a/command.go b/command.go
index 02f5f2a..45bbef0 100644
--- a/command.go
+++ b/command.go
@@ -10,7 +10,6 @@ import (
type Commander interface {
irc.Handler
- Timeout(string) bool
WithArgs(int) bool
Help() string
}
@@ -25,32 +24,12 @@ func Register(cmd string, f Commander) {
commands[cmd] = f
}
-const timeOut = time.Second
-
-func (v *Command) Timeout(nick string) bool {
- defer func() { v.lastCmd[nick] = time.Now() }()
- if v.lastCmd == nil {
- v.lastCmd = make(map[string]time.Time)
- }
- if last, ok := v.lastCmd[nick]; ok {
- if to := time.Since(last); to < timeOut {
- log.Println(nick, "timeout", to)
- return true
- }
- }
- return false
-}
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 line.Public() && c.Timeout(line.Nick) {
- log.Println("timeout", line.Nick)
- conn.Kick(*room, line.Nick, "timeout")
- return
- }
if c.WithArgs(len(f)) {
log.Println(line.Nick, f)
c.Handle(conn, line)