Advertisement
Wikked

Twitch LastFM

Oct 30th, 2014
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
mIRC 2.04 KB | None | 0 0
  1. on $*:text:/[!]lastfm( |$)/iS:*:{
  2.   if ($2 = !lastfm) { return }
  3.   if (!$2) {
  4.     if ($($+(%,lastfm,.,$nick),2) != $null) {
  5.       $np($($+(%,lastfm,.,$nick),2))
  6.       halt
  7.     }
  8.     else {
  9.       msg $chan $nick - Syntax $1 [username] :: To set your username permanently type $replace($1,lastfm,setlastfm) [username]
  10.       halt
  11.     }
  12.   }
  13.   $np($strip($2))
  14. }
  15. on $*:text:/[!]setlastfm( |$)/iS:*:{
  16.   set $+(%,lastfm,.,$nick) $iif($2,$2,$nick)
  17.   msg $chan $nick your associated Last.FM profile is now $($+(%,lastfm,.,$nick),2)
  18. }
  19. alias -l lastfm {
  20.   return $replace($1,&gt;,>,&lt;,<,&amp;,&)
  21. }
  22. on *:sockread:lastfm*:{
  23.   tokenize 96 $sock($sockname).mark
  24.   var %lf = $sockname
  25.   if ($sockerr) {
  26.     $2 $me is having difficulty reading the data from last.fm!
  27.     halt
  28.   }
  29.   sockread &lastfm
  30.   if ($regex([ [ $4 ] ],/<error code="6">(.*)</error></lfm>)) {
  31.     $2 $+($regml(1),!)
  32.     halt
  33.   }
  34.   elseif (nowplaying !isin [ [ $4 ] ]) {
  35.     $2 $1 isn't playing music right now!
  36.     sockclose %lf
  37.   }
  38.   else {
  39.     $2 Last.fm : $+($chr(9833),$chr(9834),$chr(9835)) $+($chr(2),$&
  40.       $lastfm($gettok($gettok([ [ $4 ] ],6,62),1,60)),$chr(2)) - $+($chr(2),$&
  41.       $lastfm($gettok($gettok([ [ $4 ] ],8,62),1,60)),$chr(2)) $&
  42.       $+($chr(9833),$chr(9835),$chr(9836))
  43.     sockclose %lf
  44.   }
  45. }
  46. on *:sockopen:lastfm*:{
  47.   tokenize 96 $sock($sockname).mark
  48.   if ($sockerr) {
  49.     $2 $me is having difficulty connecting to lastfm's website!
  50.     halt
  51.   }
  52.   $5 GET $+(/2.0/?method=user.getrecenttracks&user=,$1,&api_key=,$3) HTTP/1.1
  53.   $5 Host: $sock($sockname).addr
  54.   $5 Connection: close
  55.   $5
  56. }
  57. alias np {
  58.   if (!$1) {
  59.     .notice $iif($isid,$nick,$me) Please enter a user name! e.g. /np <UserName>
  60.     halt
  61.   }
  62.   var %lastfm $+(lastfm,$r(1,9999),$ticks,$network,$cid)
  63.   $+(sock,$iif($sock(%lastfm),close,open)) %lastfm ws.audioscrobbler.com 80
  64.   sockmark %lastfm $+($1,`,$iif($isid,.describe $iif(#,#,$nick),echo -at *),`,f6a3b7b12549aa211a6deec453c79417$&
  65.     ,`,$!bvar(&lastfm,1-).text,`,sockwrite -nt %lastfm)
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement