summaryrefslogtreecommitdiff
path: root/duck.go
diff options
context:
space:
mode:
Diffstat (limited to 'duck.go')
-rw-r--r--duck.go30
1 files changed, 30 insertions, 0 deletions
diff --git a/duck.go b/duck.go
new file mode 100644
index 0000000..83e4440
--- /dev/null
+++ b/duck.go
@@ -0,0 +1,30 @@
+package main
+
+import (
+ "strings"
+
+ "dim13.org/duck"
+ irc "github.com/fluffle/goirc/client"
+)
+
+type Duck struct{ Command }
+
+func (_ Duck) Timeout() bool { return false }
+func (_ Duck) WithArgs(_ int) bool { return true }
+func (_ Duck) Handle(conn *irc.Conn, line *irc.Line) {
+ if q := strings.SplitN(line.Text(), " ", 2); len(q) == 2 {
+ if a, err := duck.Abstract(q[1]); err != nil {
+ conn.Privmsg(line.Target(), err.Error())
+ } else {
+ conn.Privmsg(line.Target(), a)
+ }
+ }
+}
+
+func init() {
+ Register("define", &Duck{
+ Command{
+ Help: "Perform duckduckgo instant answer search",
+ },
+ })
+}