Skip to content

Commit

Permalink
Add a command for mattis room temperature
Browse files Browse the repository at this point in the history
see ro0mquy#40

Signed-off-by: Moritz Kick <[email protected]>
  • Loading branch information
Moritz Kick committed Nov 1, 2016
1 parent 8a38ff7 commit 18b62d7
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions plugins/temperatur.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
const (
hawo_address = "hawo.net:7337"
izibi_address = "http://tempi.0x4a42.net:7337/"
matti_address = "http://temp.notmatti.me"
)

type TemperaturPlugin struct {
Expand All @@ -34,6 +35,8 @@ func (q *TemperaturPlugin) Usage(cmd string) string {
return "prints the temperatur at HaWo"
case "it":
return "prints the temperatur at izibis home"
case "mt":
return "prints the temperatur at mattis home"
}
return ""
}
Expand All @@ -42,6 +45,7 @@ func (q *TemperaturPlugin) Register(ic *ircclient.IRCClient) {
q.ic = ic
q.ic.RegisterCommandHandler("ht", 0, 0, q)
q.ic.RegisterCommandHandler("it", 0, 0, q)
q.ic.RegisterCommandHandler("mt", 0, 0, q)
}

func (q *TemperaturPlugin) Unregister() {
Expand All @@ -58,6 +62,8 @@ func (q *TemperaturPlugin) ProcessCommand(cmd *ircclient.IRCCommand) {
q.ic.Reply(cmd, q.getHaWo())
case "it":
q.ic.Reply(cmd, q.getIzibi())
case "mt":
q.ic.Reply(cmd, q.getMatti())
}
}

Expand Down Expand Up @@ -114,3 +120,11 @@ func (q *TemperaturPlugin) getIzibi() string {

return fmt.Sprint("Aktuelle Temperatur vor izibis Fenster: ", aussen, "°C und in seinem Zimmer: ", innen, "°C")
}

func (q *TemperaturPlugin) getMatti() string {
answer, err := q.getHttp(matti_address)
if err != nil {
return "Error accessing \"" + matti_address + "\": " + err.Error()
}
return "Aktuelle Temperatur bei Matti: " + answer
}

0 comments on commit 18b62d7

Please sign in to comment.