From f603c503f6073f6499b7d609ad29127009d0812d Mon Sep 17 00:00:00 2001 From: an Date: Sun, 22 Apr 2018 13:54:06 +0200 Subject: [PATCH] testing webhooks --- modules/webhook.go | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/modules/webhook.go b/modules/webhook.go index dda6503..2323267 100644 --- a/modules/webhook.go +++ b/modules/webhook.go @@ -12,9 +12,8 @@ import ( ) var ( - webhookPort = flag.String("webhook_port", "8080", "Webhook listener port") - webhookChan = flag.String("webhook_chan", "", "Channel to post into") - webhookToken = flag.String("webhook_token", "", "Token") + webhookPort = flag.String("webhook_port", "8080", "Webhook listener port") + webhookChan = flag.String("webhook_chan", "", "Channel to post into") ) func init() { @@ -24,10 +23,24 @@ func init() { func webhookRun() { xlog.Info("webhook listener started") - http.HandleFunc("/webhook/"+*webhookToken, webhookHandleHTTP) + http.HandleFunc("/webhook", webhookHandleHTTP) 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)