Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;use /last to see the song the selected user is listening to
- ;use /lset to set the last.fm username
- ;by flyinv1490
- ; #: Modified by n0cht
- alias lset { set %luser $1 | echo -a $1 set as user }
- alias lfm {
- if %luser == $null { echo -a please set a username first. /lset <username> | halt }
- else {
- if ($1) { set %lf.chan $1 }
- else { set %lf.chan $active }
- }
- sockopen lastfm ws.audioscrobbler.com 80
- }
- on *:sockopen:lastfm: {
- if $sockerr > 0 { echo -a Error With Server. | sockclose lastfm }
- sockwrite -n $sockname GET /2.0/?method=user.getrecenttracks&user= $+ %luser $+ &api_key=ffa17ba0cdaf2817067b300a08c72196 HTTP/1.1
- sockwrite -n $sockname Host: ws.audioscrobbler.com
- sockwrite -n $sockname $crlf
- }
- on *:sockread:lastfm: {
- if $sockerr > 0 { echo -a Error With Server. | sockclose lastfm }
- sockread %lf.temp
- if (<error code="6">Invalid user name supplied</error> isin %lf.temp) { msg %lf.chan Error Username Does Not Exist | halt }
- if (</lfm> isin %lf.temp) { msg %lf.chan %luser is currently not listening to any music | sockclose lastfm | unset %lf.* }
- if (<artist isin %lf.temp) { set %lf.artist $nohtml(%lf.temp) }
- if (<name> isin %lf.temp) { set %lf.song $nohtml(%lf.temp) | me 12,15#07,15 %lf.artist - %lf.song | sockclose lastfm | unset %lf.* }
- }
- alias nohtml { var %x,%y = $regsub($1-,/(<[^>]+>)/g,$null,%x) | var %x = $replace(%x, ,$chr(32),°,$chr(176),°,$chr(176)) | return %x }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement