summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHorus32015-03-30 18:10:22 +0200
committerHorus32015-03-30 18:10:22 +0200
commiteddbcc31a45f5da8b9a67793dc43bb537e484d6a (patch)
tree25bee74dce8ab64de3bed6bed66394f5780f144e
parent056dbb7a618b86c4c679f9856270f7fb00fa40b1 (diff)
downloadweb2irc-eddbcc31a45f5da8b9a67793dc43bb537e484d6a.tar.gz
Better logging.
-rw-r--r--handler.go11
-rw-r--r--main.go2
2 files changed, 12 insertions, 1 deletions
diff --git a/handler.go b/handler.go
index e0d40b8..4124b08 100644
--- a/handler.go
+++ b/handler.go
@@ -7,6 +7,7 @@ import (
)
func IndexHandler(w http.ResponseWriter, r *http.Request) {
+ log.Println("Wrong URL.")
w.WriteHeader(400)
w.Write([]byte("Wrong URL."))
}
@@ -22,19 +23,27 @@ func WebhookHandler(w http.ResponseWriter, r *http.Request) {
var hook Webhook
err := decoder.Decode(&hook)
if err != nil {
- log.Print(err)
+ log.Print("Wrong JSON.", err)
w.WriteHeader(400)
w.Write([]byte("Wrong JSON."))
return
}
if hook.Join != "" {
+ log.Println("Joining #" + hook.Join)
con.Join("#" + hook.Join)
+
+ log.Println("Sending private message to " + hook.Join + ": " + hook.Message)
con.Privmsg("#"+hook.Join, hook.Message)
+
+ log.Println("Leaving #" + hook.Join)
con.Part("#" + hook.Join)
+
if hook.Target != "" {
+ log.Println("Sending private message to " + hook.Target + ": " + hook.Message)
con.Privmsg(hook.Target, hook.Message)
}
} else {
+ log.Println("Sending private message to " + hook.Target + ": " + hook.Message)
con.Privmsg(hook.Target, hook.Message)
}
}
diff --git a/main.go b/main.go
index df8cd25..242e364 100644
--- a/main.go
+++ b/main.go
@@ -19,6 +19,7 @@ func main() {
}
con.AddCallback("001", func(e *irc.Event) {
if fjoin := os.Getenv("WEB2IRC_IRC_JOIN"); fjoin != "" {
+ log.Println("Joining channel #" + fjoin)
con.Join("#" + fjoin)
}
})
@@ -33,5 +34,6 @@ func main() {
ip := os.Getenv("WEB2IRC_HTTP_IP")
port := os.Getenv("WEB2IRC_HTTP_PORT")
+ log.Println("Listening on " + ip + ":" + port)
http.ListenAndServe(ip+":"+port, nil)
}