From 23f324ccadba041246f473963ea373fbbc0a4d81 Mon Sep 17 00:00:00 2001 From: an Date: Sun, 22 Apr 2018 13:40:15 +0200 Subject: [PATCH] added webhook token --- modules/webhook.go | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/modules/webhook.go b/modules/webhook.go index e79080b..a76946d 100644 --- a/modules/webhook.go +++ b/modules/webhook.go @@ -7,6 +7,7 @@ import ( "flag" "fmt" "net/http" + "strings" "git.dnix.de/an/xlog" ) @@ -27,6 +28,20 @@ func webhookRun() { xlog.Fatal("%v", http.ListenAndServe(":"+*webhookPort, nil)) } +func webhookHandleMessage(m *Message) { + tok := strings.Split(m.Text, " ") + if len(tok) < 1 { + return + } + switch tok[0] { + case "!webhook-add": + if len(tok) > 1 { + http.HandleFunc("/webhook/"+tok[1], webhookHandleHTTP) + } + default: + } +} + func webhookHandleHTTP(w http.ResponseWriter, r *http.Request) { data := make(map[string]interface{}) err := json.NewDecoder(r.Body).Decode(&data) @@ -42,6 +57,3 @@ func webhookHandleHTTP(w http.ResponseWriter, r *http.Request) { } } } - -func webhookHandleMessage(m *Message) { -}