forked from an/flokati
		
	added webhook token
This commit is contained in:
		
							parent
							
								
									2abfa3f5c3
								
							
						
					
					
						commit
						23f324ccad
					
				
					 1 changed files with 15 additions and 3 deletions
				
			
		| 
						 | 
				
			
			@ -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) {
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue