Skip to content
This repository has been archived by the owner on Dec 25, 2024. It is now read-only.

Commit

Permalink
feat(humorAPI): set optionality HumorAPI integration
Browse files Browse the repository at this point in the history
  • Loading branch information
Wittano committed Apr 12, 2024
1 parent 2eb1b64 commit 9dbece6
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion bot/internal/joke/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"github.com/wittano/komputer/db"
"net/http"
"os"
"time"
)

Expand All @@ -29,7 +30,10 @@ func NewJokeDevService(globalCtx context.Context) GetService {
func NewHumorAPIService(globalCtx context.Context) GetService {
client := http.Client{Timeout: time.Second * 1}

return &HumorAPIService{client, true, globalCtx}
env, ok := os.LookupEnv(humorAPIKey)
active := ok || env != ""

return &HumorAPIService{client, active, globalCtx}
}

func NewDatabaseJokeService(database db.MongodbService) DatabaseJokeService {
Expand Down

0 comments on commit 9dbece6

Please sign in to comment.