File tree Expand file tree Collapse file tree 1 file changed +13
-11
lines changed Expand file tree Collapse file tree 1 file changed +13
-11
lines changed Original file line number Diff line number Diff line change @@ -75,26 +75,28 @@ var (
75
75
listenAddress = flag .String ("listen.address" , os .Getenv ("LISTEN_ADDRESS" ), "Address:Port to listen on." )
76
76
)
77
77
78
- func main () {
79
- flag .Parse ()
80
-
81
- if * whURL == "" {
78
+ func checkWhURL (whURL string ) {
79
+ if whURL == "" {
82
80
log .Fatalf ("Environment variable 'DISCORD_WEBHOOK' or CLI parameter 'webhook.url' not found." )
83
81
}
84
-
85
- if * listenAddress == "" {
86
- * listenAddress = defaultListenAddress
87
- }
88
-
89
- _ , err := url .Parse (* whURL )
82
+ _ , err := url .Parse (whURL )
90
83
if err != nil {
91
84
log .Fatalf ("The Discord WebHook URL doesn't seem to be a valid URL." )
92
85
}
93
86
94
87
re := regexp .MustCompile (`https://discord(?:app)?.com/api/webhooks/[0-9]{18}/[a-zA-Z0-9_-]+` )
95
- if ok := re .Match ([]byte (* whURL )); ! ok {
88
+ if ok := re .Match ([]byte (whURL )); ! ok {
96
89
log .Printf ("The Discord WebHook URL doesn't seem to be valid." )
97
90
}
91
+ }
92
+
93
+ func main () {
94
+ flag .Parse ()
95
+ checkWhURL (* whURL )
96
+
97
+ if * listenAddress == "" {
98
+ * listenAddress = defaultListenAddress
99
+ }
98
100
99
101
log .Printf ("Listening on: %s" , * listenAddress )
100
102
http .ListenAndServe (* listenAddress , http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
You can’t perform that action at this time.
0 commit comments