summaryrefslogtreecommitdiff
path: root/duck.go
blob: 7900cc0f3d659d0e9109d72c94aa190a735eb485 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package main

import (
	"strings"

	"dim13.org/duck"
	irc "github.com/fluffle/goirc/client"
)

type Duck struct{}

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.Notice(line.Target(), err.Error())
		} else {
			conn.Notice(line.Target(), a)
		}
	}
}

func (Duck) String() string {
	return "Perform duckduckgo instant answer search"
}

func init() {
	Register("define", &Duck{})
}