summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2015-07-23 00:57:28 +0200
committerDimitri Sokolyuk <demon@dim13.org>2015-07-23 00:57:28 +0200
commit402c69945cdfb6000794b024237e44b6977acb81 (patch)
treee64a358f6b4f81e7c684dbb793851e0da4ede3f0
parentd3a67f46c6b0a8af985ed314a04183bcbb38f1d0 (diff)
Add urban dictionary
-rw-r--r--urban.go30
1 files changed, 30 insertions, 0 deletions
diff --git a/urban.go b/urban.go
new file mode 100644
index 0000000..7fd6575
--- /dev/null
+++ b/urban.go
@@ -0,0 +1,30 @@
+package main
+
+import (
+ "strings"
+
+ "dim13.org/urban"
+ irc "github.com/fluffle/goirc/client"
+)
+
+type Urban struct{ Command }
+
+func (_ Urban) Timeout() bool { return false }
+func (_ Urban) WithArgs(_ int) bool { return true }
+func (_ Urban) Handle(conn *irc.Conn, line *irc.Line) {
+ if q := strings.SplitN(line.Text(), " ", 2); len(q) == 2 {
+ if u, err := urban.QueryTop(q[1]); err != nil {
+ conn.Privmsg(line.Target(), err.Error())
+ } else {
+ conn.Privmsg(line.Target(), u.Definition)
+ }
+ }
+}
+
+func init() {
+ Register("urban", &Urban{
+ Command{
+ Help: "Perform urban dictionary search",
+ },
+ })
+}