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: "Fetch current weather", }, }) }