diff options
| author | Bobby <[email protected]> | 2025-03-27 11:15:30 +0530 |
|---|---|---|
| committer | Bobby <[email protected]> | 2025-03-27 11:15:30 +0530 |
| commit | c99fc2609921d082c682b7d20865dfb87f9481ca (patch) | |
| tree | 84203b02594f3ec8a5ee6c25730f719775c4bb60 | |
| parent | 1b85141b94f6ebcc429708b4bdeef4e2d2265650 (diff) | |
| download | ai-c99fc2609921d082c682b7d20865dfb87f9481ca.tar.xz ai-c99fc2609921d082c682b7d20865dfb87f9481ca.zip | |
Added support for streaming URL
| -rw-r--r-- | .env.example | 3 | ||||
| -rw-r--r-- | config/config.go | 12 | ||||
| -rw-r--r-- | types/bot.go | 1 |
3 files changed, 11 insertions, 5 deletions
diff --git a/.env.example b/.env.example index 5e9f24c..66faf26 100644 --- a/.env.example +++ b/.env.example @@ -3,4 +3,5 @@ YOUTUBE_API_KEY= SPOTIFY_CLIENT_ID= SPOTIFY_CLIENT_SECRET= ACTIVITY= # Activity Type is of type int, 1: Playing, 2: Listening, 3: Watching, 4: Streaming -ACTIVITY_MESSAGE=
\ No newline at end of file +ACTIVITY_MESSAGE= +ACTIVITY_URL= # Only required for Streaming
\ No newline at end of file diff --git a/config/config.go b/config/config.go index e9f08b5..e3fc5e4 100644 --- a/config/config.go +++ b/config/config.go @@ -32,6 +32,7 @@ func init() { YoutubeAPIKey: getEnv("YOUTUBE_API_KEY"), Activity: types.ActivityType(getIntEnv("ACTIVITY")), ActivityMessage: getEnv("ACTIVITY_MESSAGE"), + ActivityURL: getEnv("ACTIVITY_URL"), } if Config.DiscordToken == "" { @@ -50,20 +51,23 @@ func init() { logger.Log("Unable to read YouTube API key. environment variable YOUTUBE_API_KEY is required", logOptions) } + logOptions.Level = types.Warn + logOptions.Fatal = false if Config.Activity == 0 { - logOptions.Level = types.Warn - logOptions.Fatal = false logger.Log("Activity message is empty or not set. Defaulting to PLAYING", logOptions) Config.Activity = types.PLAYING } if Config.ActivityMessage == "" { - logOptions.Level = types.Warn - logOptions.Fatal = false logger.Log("Activity message is empty or not set. Defaulting to empty string", logOptions) Config.ActivityMessage = "" } + if Config.Activity == types.STREAMING && Config.ActivityURL == "" { + logger.Log("Activity URL is empty or not set. Defaulting to empty string", logOptions) + Config.ActivityURL = "" + } + logOptions.Level = types.Success logOptions.Fatal = false logger.Log("Config loaded successfully", logOptions) diff --git a/types/bot.go b/types/bot.go index 417aecc..2f6adf3 100644 --- a/types/bot.go +++ b/types/bot.go @@ -16,4 +16,5 @@ type BotConfig struct { YoutubeAPIKey string Activity ActivityType ActivityMessage string + ActivityURL string } |
