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 (
7575 listenAddress = flag .String ("listen.address" , os .Getenv ("LISTEN_ADDRESS" ), "Address:Port to listen on." )
7676)
7777
78- func main () {
79- flag .Parse ()
80-
81- if * whURL == "" {
78+ func checkWhURL (whURL string ) {
79+ if whURL == "" {
8280 log .Fatalf ("Environment variable 'DISCORD_WEBHOOK' or CLI parameter 'webhook.url' not found." )
8381 }
84-
85- if * listenAddress == "" {
86- * listenAddress = defaultListenAddress
87- }
88-
89- _ , err := url .Parse (* whURL )
82+ _ , err := url .Parse (whURL )
9083 if err != nil {
9184 log .Fatalf ("The Discord WebHook URL doesn't seem to be a valid URL." )
9285 }
9386
9487 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 {
9689 log .Printf ("The Discord WebHook URL doesn't seem to be valid." )
9790 }
91+ }
92+
93+ func main () {
94+ flag .Parse ()
95+ checkWhURL (* whURL )
96+
97+ if * listenAddress == "" {
98+ * listenAddress = defaultListenAddress
99+ }
98100
99101 log .Printf ("Listening on: %s" , * listenAddress )
100102 http .ListenAndServe (* listenAddress , http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
You can’t perform that action at this time.
0 commit comments