Reputation: 1
I'm having a issue with my mIRC script. Im trying to create a channel trigger !lfm the results will show the Artist, Genre, Plays
; Set your Last.fm API key here
alias SetAPIKey {
return API_KEY
}
on *:TEXT:.lfm *:#: {
; Store the artist name from the message
var %artist = $2
; Get the API key from a separate function
var %apiKey = $SetAPIKey()
; Open the connection to Last.fm
LastFMOpen %artist %apiKey
}
; Handle socket errors
alias sockError {
if ($sockerr) {
notice $nick 04ERROR: $sock($sockname).wsmsg
return
}
}
; Open the connection to Last.fm
alias LastFMOpen {
var %artist = $1
var %apiKey = $2
sockclose get.connectLastFm
sockopen -ea get.connectLastFm ws.audioscrobbler.com 443
}
on *:sockopen:get.connectLastFm:{
$sockError
sockwrite -n $sockname GET /2.0/?method=artist.getinfo&artist= $+ %artist $+ &api_key=API_KEY&format=json
sockwrite -n $sockname Host: ws.audioscrobbler.com
sockwrite -n $sockname
}
on *:sockread:get.connectLastFm:{
sockread -f %line
msg $chan [Artist Name: ]-[ Genre: ]-[ Plays: ]-
unset %line
}
I tried changing the socket events and got no luck. I do have a current active API number to use
Upvotes: 0
Views: 64
Reputation: 1
var %apiKey = $SetAPIKey()
this part
var %apiKey = $SetAPIKey
Substitute as and
sockwrite -n $sockname GET /2.0/?method=artist.getinfo&artist= $+ %artist $+ &api_key=API_KEY&format=json
sockwrite -n $sockname GET /2.0/?method=artist.getinfo&artist= $+ %artist $+ &api_key=API_KEY&format=json HTTP/1.1
Upvotes: 0