Handle special characters in event names (#1)

Co-authored-by: Layla <layla@layla.gg>
Reviewed-on: https://gitea.sumulayla.synology.me/layla/birdbot/pulls/1
This commit was merged in pull request #1.
This commit is contained in:
2023-06-10 04:24:57 -04:00
parent b98fc73ea1
commit 91a886a81e
2 changed files with 36 additions and 0 deletions

View File

@@ -22,6 +22,10 @@ func GenerateEventChannelName(eventName string, location string, dateTime time.T
city := GetCityFromLocation(location)
year := dateTime.Year()
// Remove special characters
eventName = regexp.MustCompile(`[^a-zA-Z0-9 ]+`).ReplaceAllString(eventName, "")
eventName = strings.Trim(eventName, " ")
channel := fmt.Sprint(month, "-", day, city, "-", eventName, "-", year)
channel = strings.ReplaceAll(channel, " ", "-")
channel = strings.ToLower(channel)