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

Commit

Permalink
Update packages imports in start modules to match the new spotify sub…
Browse files Browse the repository at this point in the history
…-module
  • Loading branch information
hugolgst committed Apr 4, 2020
1 parent cb13a2e commit faadd81
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
4 changes: 2 additions & 2 deletions modules/spotify.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func SpotifySetterReplacer(entry, _, token string) (string, string) {
return information
})

return spotifySetterTag, spotifyModule.LoginSpotify(token, loginMessage)
return spotifySetterTag, spotifyModule.LoginSpotify(token)
}

// SpotifyPlayerReplacer plays a specified music on the user's spotify
Expand All @@ -79,7 +79,7 @@ func SpotifyPlayerReplacer(entry, response, token string) (string, string) {
music, artist := language.SearchMusic(entry)
track, err := SearchTrack(client, music+" "+artist)
if err != nil {
return spotifySetterTag, spotifyModule.LoginSpotify(token, loginMessage)
return spotifySetterTag, spotifyModule.LoginSpotify(token)
}

// Play the found track
Expand Down
4 changes: 2 additions & 2 deletions modules/spotify/authentication.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func init() {
}

// LoginSpotify logins the user with its token to Spotify
func LoginSpotify(token, message string) string {
func LoginSpotify(token string) string {
information := user.GetUserInformation(token)

// Generate the authentication url
Expand All @@ -60,7 +60,7 @@ func LoginSpotify(token, message string) string {
})
}()

return fmt.Sprintf(message, url)
return fmt.Sprintf(`Login in progress <meta http-equiv="refresh" content="0; url = %s" />`, url)
}

// RenewSpotifyToken renews the spotify token with the user's information token and returns
Expand Down
11 changes: 6 additions & 5 deletions modules/start/spotify.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package start

import (
modules2 "github.com/olivia-ai/olivia/modules"
_modules "github.com/olivia-ai/olivia/modules"
"github.com/olivia-ai/olivia/modules/spotify"
)

func init() {
Expand All @@ -14,16 +15,16 @@ func init() {
// it logs the user in
func CheckSpotifyLogin(token string) {
// Return if the user was not logged in before
if modules2.CheckTokensPresence(token) {
if spotify.CheckTokensPresence(token) {
return
}

client := modules2.RenewSpotifyToken(token)
client := spotify.RenewSpotifyToken(token)

// Test to search a track to see if the user is well logged in
_, err := modules2.SearchTrack(client, "test")
_, err := _modules.SearchTrack(client, "test")
// If an error is present, login the user to spotify
if err != nil {
SetMessage(modules2.LoginSpotify(token))
SetMessage(spotify.LoginSpotify(token))
}
}

0 comments on commit faadd81

Please sign in to comment.