summaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorHorus32015-03-11 15:42:44 +0100
committerHorus32015-03-11 15:42:44 +0100
commit502899e07bbc23398fbcadf7a5e15624855bf877 (patch)
tree857b0391982906954a5047a013c6be4c1d324827 /main.go
downloadweb2irc-502899e07bbc23398fbcadf7a5e15624855bf877.tar.gz
Initial commit.
Diffstat (limited to 'main.go')
-rw-r--r--main.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/main.go b/main.go
new file mode 100644
index 0000000..bd3552a
--- /dev/null
+++ b/main.go
@@ -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)
+}