diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..dc94066 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,28 @@ +# Use the official Go 1.23 image for building the application +FROM golang:1.23-alpine AS builder + +# Set the working directory inside the container +WORKDIR /app + +# Copy the Go modules manifest and download dependencies +COPY go.mod go.sum ./ +RUN go mod download + +# Copy the rest of the application source code +COPY . . + +# Build the Go application from the appropriate directory inside 'cmd' +RUN go build -o discord-scores-bot ./cmd/main.go + +# Create a minimal runtime image +FROM alpine:latest +RUN apk --no-cache add ca-certificates + +# Set the working directory +WORKDIR /root/ + +# Copy the built Go binaries from the builder stage +COPY --from=builder /app/discord-scores-bot . + +# Run the bot (use separate Dockerfiles if needed for distinct deployments) +CMD ["./discord-scores-bot"] diff --git a/config/config.go b/config/config.go index ba1e69e..0b2a85a 100644 --- a/config/config.go +++ b/config/config.go @@ -1,6 +1,6 @@ package config -var BotToken = " " +var BotToken = "REDACTED" var CustomTeamNames = map[string]string{ "UGA": "Georgia", diff --git a/internal/clients/cfb/cfb.go b/internal/clients/cfb/cfb.go index da877a3..0dd14bf 100644 --- a/internal/clients/cfb/cfb.go +++ b/internal/clients/cfb/cfb.go @@ -7,6 +7,7 @@ import ( "log" "net/http" "strings" + "time" "unicode" ) @@ -32,6 +33,22 @@ type Team struct { } `json:"names"` } +// Convert time from Eastern to Central +func convertToCentralTime(easternTime string) (string, error) { + parsedTime, err := time.Parse("03:04PM ET", easternTime) + if err != nil { + return "", fmt.Errorf("error parsing time: %w", err) + } + + centralLocation, err := time.LoadLocation("America/Chicago") + if err != nil { + return "", fmt.Errorf("error loading Central Time location: %w", err) + } + + centralTime := parsedTime.In(centralLocation) + return centralTime.Format("03:04 PM"), nil +} + func GetGameInfo(teamName string) string { teamName = strings.TrimSpace(teamName) week := "" @@ -90,8 +107,13 @@ func GetGameInfo(teamName string) string { game.Game.Home.Names.Short, game.Game.Home.Score, period, game.Game.ContestClock) } else if game.Game.GameState == "pre" { - gameInfo = fmt.Sprintf("Upcoming: %s @ %s on %s at %s ET", - game.Game.Away.Names.Short, game.Game.Home.Names.Short, game.Game.StartDate, game.Game.StartTime) + centralTime, err := convertToCentralTime(game.Game.StartTime) + if err != nil { + log.Printf("Time conversion error: %v", err) + centralTime = game.Game.StartTime // Fall back to the original if conversion fails + } + gameInfo = fmt.Sprintf("Upcoming: %s @ %s on %s at %s CT", + game.Game.Away.Names.Short, game.Game.Home.Names.Short, game.Game.StartDate, centralTime) } else if game.Game.GameState == "final" { gameInfo = fmt.Sprintf("Final: %s: **%s** %s: **%s**", game.Game.Away.Names.Short, game.Game.Away.Score, @@ -108,4 +130,3 @@ func GetGameInfo(teamName string) string { return "No game found for the specified team." } -