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