Skip to content

Commit

Permalink
Add dayi command
Browse files Browse the repository at this point in the history
  • Loading branch information
rcy committed Jul 18, 2024
1 parent e5b08bb commit 6effa5a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ func addHandlers(b *bot.Bot) {
b.Handle(`^!pipehealth\b`, handlers.AnonStatus)
b.Handle(`(https?://\S+)`, handlers.Link)
b.Handle(`^!day\b`, day.NationalDay)
b.Handle(`^!dayi\b`, day.Dayi)
b.Handle(`^!week`, day.NationalWeek)
b.Handle(`^!month`, day.NationalMonth)
b.Handle(`^!refs`, day.NationalRefs)
Expand Down
11 changes: 10 additions & 1 deletion handlers/day/day.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,21 @@ func dayImage(cmd string) (*image.GeneratedImage, error) {
prompt := fmt.Sprintf("a scene incorporating themes from: %s", strings.Join(days, ","))
gi, err := image.Generate(context.Background(), prompt)
if err != nil {
return nil, err
return nil, fmt.Errorf("prompt: %s: %w", prompt, err)
}

return gi, nil
}

func Dayi(params bot.HandlerParams) error {
img, err := dayImage(dayCmd)
if err != nil {
return err
}
params.Privmsgf(params.Target, "Today's image: %s", img.URL())
return nil
}

func Image(params bot.HandlerParams) error {
prompt := params.Matches[1]
gi, err := image.Generate(context.Background(), prompt)
Expand Down

0 comments on commit 6effa5a

Please sign in to comment.