-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
39 lines (32 loc) · 786 Bytes
/
main.go
File metadata and controls
39 lines (32 loc) · 786 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package main
import (
"fmt"
"github.com/artem-lifshits/github_alert_bot/pkg/handlers"
"log"
"net/http"
"os"
"strconv"
"github.com/go-playground/webhooks/v6/github"
)
const (
path = "/webhooks"
)
func main() {
token := os.Getenv("TELEGRAM_APITOKEN")
channel := os.Getenv("TELEGRAM_CHANNEL")
chatId, err := strconv.ParseInt(channel, 10, 64)
if err != nil {
log.Fatal(err)
}
hook, err := github.New(github.Options.Secret(os.Getenv("GITHUB_SECRET")))
if err != nil {
log.Fatal("wrong secret addressed: %w", err)
}
newHook := handlers.NewHook(hook, token, chatId)
handlers.NewHandlers(newHook)
http.HandleFunc(path, handlers.WebhookCatcher)
err = http.ListenAndServe(":3535", nil)
if err != nil {
fmt.Printf("error occured on server: %s", err.Error())
}
}