Skip to content

Commit

Permalink
Print clear error message when required env not provided
Browse files Browse the repository at this point in the history
  • Loading branch information
leafduo committed Mar 4, 2023
1 parent ffd8e4e commit 3c14595
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ func main() {
fmt.Printf("%+v\n", err)
}

if len(cfg.TelegramAPIToken) == 0 {
log.Panic("Telegram API token required, please set TELEGRAM_APITOKEN environment variable.")
}
if len(cfg.OpenAIAPIKey) == 0 {
log.Panic("OpenAI API key required, please set OPENAI_API_KEY environment variable.")
}

bot, err := tgbotapi.NewBotAPI(cfg.TelegramAPIToken)
if err != nil {
panic(err)
Expand Down

0 comments on commit 3c14595

Please sign in to comment.