diff options
| author | Horus3 | 2015-03-30 18:10:22 +0200 |
|---|---|---|
| committer | Horus3 | 2015-03-30 18:10:22 +0200 |
| commit | eddbcc31a45f5da8b9a67793dc43bb537e484d6a (patch) | |
| tree | 25bee74dce8ab64de3bed6bed66394f5780f144e /handler.go | |
| parent | 056dbb7a618b86c4c679f9856270f7fb00fa40b1 (diff) | |
| download | web2irc-eddbcc31a45f5da8b9a67793dc43bb537e484d6a.tar.gz | |
Better logging.
Diffstat (limited to 'handler.go')
| -rw-r--r-- | handler.go | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -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) } } |
