Relax the DISCORD_WEBHOOK requirements, it can be any URL.

and if it does not match the discord regex it prints a warning
but lets things go ahead, this is handy for debugging and
canary subdomains of discord.

H/T to Tom Bowditch who discovered the latter part
This commit is contained in:
Ben Cartwright-Cox
2020-12-02 12:13:13 +00:00
parent 462a419eed
commit ff1f9273cb
+7 -1
View File
@@ -8,6 +8,7 @@ import (
"io/ioutil"
"log"
"net/http"
"net/url"
"os"
"regexp"
"strings"
@@ -86,9 +87,14 @@ func main() {
*listenAddress = defaultListenAddress
}
_, err := url.Parse(*whURL)
if err != nil {
log.Fatalf("The Discord WebHook URL doesn't seem to be a valid URL.")
}
re := regexp.MustCompile(`https://discord(?:app)?.com/api/webhooks/[0-9]{18}/[a-zA-Z0-9_-]+`)
if ok := re.Match([]byte(*whURL)); !ok {
log.Fatalf("The Discord WebHook URL doesn't seem to be valid.")
log.Printf("The Discord WebHook URL doesn't seem to be valid.")
}
log.Printf("Listening on: %s", *listenAddress)