diff options
| author | Horus3 | 2015-03-11 15:42:44 +0100 |
|---|---|---|
| committer | Horus3 | 2015-03-11 15:42:44 +0100 |
| commit | 502899e07bbc23398fbcadf7a5e15624855bf877 (patch) | |
| tree | 857b0391982906954a5047a013c6be4c1d324827 /main.go | |
| download | web2irc-502899e07bbc23398fbcadf7a5e15624855bf877.tar.gz | |
Initial commit.
Diffstat (limited to 'main.go')
| -rw-r--r-- | main.go | 31 |
1 files changed, 31 insertions, 0 deletions
@@ -0,0 +1,31 @@ +package main + +import ( + "github.com/gorilla/mux" + "github.com/thoj/go-ircevent" + "log" + "net/http" + "os" +) + +var con = irc.IRC(os.Getenv("WEB2IRC_IRC_NICK"), os.Getenv("WEB2IRC_IRC_REAL_NAME")) + +func main() { + checkConfig() + + err := con.Connect(os.Getenv("WEB2IRC_IRC_SERVER") + ":" + os.Getenv("WEB2IRC_IRC_SERVER_PORT")) + if err != nil { + log.Fatal(err) + } + r := mux.NewRouter() + r.HandleFunc("/", IndexHandler) + r.HandleFunc("/webhook", WebhookHandler).Methods("POST") + r.HandleFunc("/webhook", WebhookFailureHandler) + + http.Handle("/", r) + + ip := os.Getenv("WEB2IRC_HTTP_IP") + port := os.Getenv("WEB2IRC_HTTP_PORT") + + http.ListenAndServe(ip+":"+port, nil) +} |
