Merge remote-tracking branch 'upstream/master'

This commit is contained in:
da
2016-03-14 22:53:51 +01:00
12 changed files with 64 additions and 51 deletions
+6 -5
View File
@@ -10,12 +10,13 @@ import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
"strconv"
"strings"
"time"
"code.dnix.de/an/xlog"
"github.com/sorcix/irc"
)
@@ -71,8 +72,8 @@ type WeatherObject struct {
func init() {
MsgHandlers["weather"] = weatherHandleMessage
log.Println("Initializing weather module")
go weatherConfig()
xlog.Info("Weather module initialized")
}
func weatherConfig() {
@@ -105,19 +106,19 @@ func getWeather(query string) {
q := owmQueryURLPrefix + query + owmQueryURLSuffix + owmQueryAPIKey
r, err := http.Get(q)
if err != nil {
log.Println(err)
xlog.Error(err.Error())
SayCh <- fmt.Sprintf("*\n%s", weatherPrefix+err.Error())
} else {
re, err := ioutil.ReadAll(r.Body)
if err != nil {
log.Println(err)
xlog.Error(err.Error())
SayCh <- fmt.Sprintf("*\n%s", weatherPrefix+err.Error())
} else {
defer r.Body.Close()
var wo WeatherObject
err := json.Unmarshal(re, &wo)
if err != nil {
log.Println(err)
xlog.Error(err.Error())
SayCh <- fmt.Sprintf("*\n%s", weatherPrefix+err.Error())
} else {
var description string