summaryrefslogtreecommitdiff
path: root/command.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2015-07-21 17:39:50 +0200
committerDimitri Sokolyuk <demon@dim13.org>2015-07-21 17:39:50 +0200
commit6dd926817d0fc77fdeeb5aea0c5ad156d5007c4e (patch)
treea5d1d33643775901f5e9fd974d5d3f0c993177da /command.go
parent21d7bc6362f18e4a02380b5d763ead1d78495bbf (diff)
Split more
Diffstat (limited to 'command.go')
-rw-r--r--command.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/command.go b/command.go
index 1dcb9f1..5c973b6 100644
--- a/command.go
+++ b/command.go
@@ -3,6 +3,7 @@ package main
import (
"fmt"
"log"
+ "strings"
"time"
irc "github.com/fluffle/goirc/client"
@@ -37,3 +38,15 @@ func (v *Command) Timeout() bool {
return true
}
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)) && !(line.Public() && c.Timeout()) {
+ log.Println(line.Nick, f)
+ go c.Handle(conn, line)
+ }
+ }
+ }
+}