summaryrefslogtreecommitdiff
path: root/handler.go
diff options
context:
space:
mode:
Diffstat (limited to 'handler.go')
-rw-r--r--handler.go11
1 files changed, 10 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)
}
}