summaryrefslogtreecommitdiff
path: root/weather.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2015-09-20 16:48:35 +0200
committerDimitri Sokolyuk <demon@dim13.org>2015-09-20 16:48:35 +0200
commit28d101636212e8e539512916c4587ea8bf657ddb (patch)
tree99f465941219ff12b3dc4192387cefeeab160d3c /weather.go
parentb0f17fc12e0d3698cfa872d13a74f2c3aecbea62 (diff)
Add weather
Diffstat (limited to 'weather.go')
-rw-r--r--weather.go30
1 files changed, 30 insertions, 0 deletions
diff --git a/weather.go b/weather.go
new file mode 100644
index 0000000..30c9be9
--- /dev/null
+++ b/weather.go
@@ -0,0 +1,30 @@
+package main
+
+import (
+ "fmt"
+ "strings"
+
+ "dim13.org/weather"
+ irc "github.com/fluffle/goirc/client"
+)
+
+type Weather struct{ Command }
+
+func (_ Weather) WithArgs(_ int) bool { return true }
+func (_ Weather) Handle(conn *irc.Conn, line *irc.Line) {
+ if q := strings.SplitN(line.Text(), " ", 2); len(q) == 2 {
+ if c, err := weather.ByCityName(q[1]); err != nil {
+ conn.Notice(line.Target(), err.Error())
+ } else {
+ conn.Notice(line.Target(), fmt.Sprint(c))
+ }
+ }
+}
+
+func init() {
+ Register("weather", &Weather{
+ Command{
+ Help: "Fertch current weather",
+ },
+ })
+}