it works now

This commit is contained in:
Jack Merrill 2024-08-30 18:37:26 -04:00
parent b70572e47a
commit ce78455131
4 changed files with 26 additions and 22 deletions

View File

@ -1,7 +1,7 @@
##### Stage 1 ##### ##### Stage 1 #####
### Use golang:1.18 as base image for building the application ### Use golang:1.18 as base image for building the application
FROM golang:1.19 as builder FROM golang:1.23 as builder
### Create new directly and set it as working directory ### Create new directly and set it as working directory
RUN mkdir -p /app RUN mkdir -p /app

View File

@ -7,10 +7,12 @@ app = "hampbot"
primary_region = "bos" primary_region = "bos"
[build] [build]
[build.args]
GO_VERSION = "1.23.0"
build-target = "runner" build-target = "runner"
[http_service] [http_service]
auto_stop_machines = true auto_stop_machines = "stop"
auto_start_machines = true auto_start_machines = true
min_machines_running = 1 min_machines_running = 1
processes = ["app"] processes = ["app"]

View File

@ -41,11 +41,18 @@ func Run(session *discordgo.Session) {
panic(err) panic(err)
} }
var todaysMenu *Meal if menu == nil {
panic("menu is nil")
}
for i, v := range *menu { refMenu := *menu
if v.Date == time.Now().Format("1/2/2006") {
todaysMenu = &(*menu)[i] var todaysMenu Meal
todaysDate := time.Now().Format("1/2/2006")
for i, v := range refMenu {
if v.Date == todaysDate {
todaysMenu = refMenu[i]
break break
} }
} }
@ -80,12 +87,15 @@ func Run(session *discordgo.Session) {
}) })
// Send the Menu to the channel // Send the Menu to the channel
_, err = session.ChannelMessageSendEmbed("1016558809667350528", &discordgo.MessageEmbed{ _, err = session.ChannelMessageSendEmbed("1142231837331181678", &discordgo.MessageEmbed{
Title: fmt.Sprintf("🍕 **Menu for %s**", (*menu)[0].Date), Title: fmt.Sprintf("🍕 **Menu for %s**", todaysMenu.Date),
Fields: fields, Fields: fields,
Color: 0x00ff00, Color: 0x00ff00,
}) })
if err != nil {
panic(err)
}
} }
func ParseWebsite() (*string, error) { func ParseWebsite() (*string, error) {

18
main.go
View File

@ -149,9 +149,12 @@ func main() {
log.Fatal(err) log.Fatal(err)
} }
dcMenuJob, err := s.NewJob(gocron.DailyJob(1, gocron.NewAtTimes(gocron.NewAtTime(8, 0, 0))), gocron.NewTask(func() { dcMenuJob, err := s.NewJob(
gocron.DailyJob(1, gocron.NewAtTimes(gocron.NewAtTime(8, 0, 0))),
gocron.NewTask(func() {
dcmenu.Run(session) dcmenu.Run(session)
})) }),
)
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
@ -166,15 +169,4 @@ func main() {
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
// block until you are ready to shut down
select {
case <-time.After(time.Minute):
}
// when you're done, shut it down
err = s.Shutdown()
if err != nil {
// handle error
}
} }