2022-10-29 05:08:17 +02:00
|
|
|
package core
|
|
|
|
|
2023-03-31 05:51:05 +02:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"regexp"
|
|
|
|
"strings"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/yeslayla/birdbot/common"
|
|
|
|
)
|
|
|
|
|
2022-10-29 05:08:17 +02:00
|
|
|
type Channel struct {
|
|
|
|
Name string
|
|
|
|
ID string
|
|
|
|
Verified bool
|
|
|
|
}
|
2023-03-31 05:51:05 +02:00
|
|
|
|
|
|
|
func GenerateEventChannelName(eventName string, location string, dateTime time.Time) string {
|
|
|
|
month := GetMonthPrefix(dateTime)
|
|
|
|
day := dateTime.Day()
|
|
|
|
city := GetCityFromLocation(location)
|
|
|
|
year := dateTime.Year()
|
|
|
|
|
|
|
|
channel := fmt.Sprint(month, "-", day, city, "-", eventName, "-", year)
|
|
|
|
channel = strings.ReplaceAll(channel, " ", "-")
|
|
|
|
channel = strings.ToLower(channel)
|
|
|
|
|
|
|
|
re, _ := regexp.Compile(`[^\w\-]`)
|
|
|
|
channel = re.ReplaceAllString(channel, "")
|
|
|
|
|
|
|
|
return channel
|
|
|
|
}
|
|
|
|
|
|
|
|
// GenerateChannel returns a channel object associated with an event
|
|
|
|
func GenerateChannel(event common.Event) *Channel {
|
|
|
|
|
|
|
|
channelName := GenerateEventChannelName(event.Name, event.Location, event.DateTime)
|
|
|
|
|
|
|
|
return &Channel{
|
|
|
|
Name: channelName,
|
|
|
|
Verified: false,
|
|
|
|
}
|
|
|
|
}
|