All pastes #832108 Raw Edit

irctunes

public text v1 · immutable
#832108 ·published 2007-12-25 20:21 UTC
rendered paste body
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; iRCTunes for mIRC v2.3                          ;
; Author: Peter Powell (petpow@thegeeklord.net)   ;
; License: GNU General Public License v3.0        ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
on *:START: {
  if ($exists($shortfn($scriptdir) $+ irctunes.ini) == $true) {
    if ($ini($shortfn($scriptdir) $+ irctunes.ini,settings,theme) == 0) { writeini -n $shortfn($scriptdir) $+ irctunes.ini settings theme [DESCRIBE] is listening to $!chr(2) $!+ ' $!+ $!itunesinfo(track) $!+ ' $!+ $!chr(15) by $!chr(2) $!+ $!itunesinfo(artist) $!+ $!chr(15) [ $!+ $!asctime($itunesinfo(seclength),n:ss) $!+ / $!+ $!itunesinfo(size) $!+ mb/ $!+ $!itunesinfo(bitrate) $!+ kbps] }
    if ($itsettings(autoconn) == true) { .comopen irctunes iTunes.Application }
    if ($itsettings(checkupdate) == true) { .timerupd 1 5 itunes checkupdate }
  }
  else {
    writeini -n $shortfn($scriptdir) $+ irctunes.ini script n0 on *:START: $chr(123)
    writeini -n $shortfn($scriptdir) $+ irctunes.ini script n1 .unload -rs $!shortfn($script)
    writeini -n $shortfn($scriptdir) $+ irctunes.ini script n2 echo -a Error: you may not load this irctunes.ini
    writeini -n $shortfn($scriptdir) $+ irctunes.ini script n3 $chr(125)
    writeini -n $shortfn($scriptdir) $+ irctunes.ini settings theme [DESCRIBE] is listening to $!chr(2) $!+ ' $!+ $!itunesinfo(track) $!+ ' $!+ $!chr(15) by $!chr(2) $!+ $!itunesinfo(artist) $!+ $!chr(15) [ $!+ $!asctime($itunesinfo(seclength),n:ss) $!+ / $!+ $!itunesinfo(size) $!+ mb/ $!+ $!itunesinfo(bitrate) $!+ kbps]
    writeini -n $shortfn($scriptdir) $+ irctunes.ini settings checkupdate true
    writeini -n $shortfn($scriptdir) $+ irctunes.ini settings autoconn true
    writeini -n $shortfn($scriptdir) $+ irctunes.ini settings demand false
    writeini -n $shortfn($scriptdir) $+ irctunes.ini settings dcc false
    writeini -n $shortfn($scriptdir) $+ irctunes.ini settings popup false
    writeini -n $shortfn($scriptdir) $+ irctunes.ini settings demand false
    writeini -n $shortfn($scriptdir) $+ irctunes.ini settings support false
    .comopen irctunes iTunes.Application
  }
  echo -a iRCTunes $itversion for mIRC has been loaded - to view a list of commands type /itunes help :)
}
on *:UNLOAD: {
  if ($com(irctunes)) { .comclose irctunes }
  if ($exists($shortfn($scriptdir) $+ irctunes.ini)) { .rename $shortfn($scriptdir) $+ irctunes.ini $+($shortfn($scriptdir),irctunes-old-,$ctime,.ini)  }
  echo -a iRCTunes $itversion for mIRC unloaded :(
}
on *:EXIT: {
  remini $shortfn($scriptdir) $+ irctunes.ini temp
}
on *:TEXT:!itunes*:#: {
  if ($itsettings(demand) == true) {
    if (!$com(irctunes)) { .notice $nick [iRCTunes] iTunes is currently disconnected }
    else { .notice $nick [iRCTunes] I am listening to $chr(2) $+ ' $+ $itunesinfo(track) $+ ' $+ $chr(15) by $chr(2) $+ $itunesinfo(artist) $+ $chr(15) from the album $chr(2) $+ $itunesinfo(album) $+ $chr(15) }
  }
  else { .notice $nick [iRCTunes] iRCTunes on demand is currently disabled }
}
on *:TEXT:!getsong*:#: {
  if ($itsettings(dcc) == true) { .notice $nick iRCTunes DCC request accepted - preparing to send file $nopath($itunesinfo(location)) | .timerdcc $+ $rand(1,100) 1 $rand(2,7) .dcc send $nick $itunesinfo(shortlocation) }
}
on *:JOIN:#scripts: {
  if ($network == MoofSpeak) && ($itsettings(support) == true) { 
    describe #scripts requires help for iRCTunes for mIRC $itversion running on Windows $os with mIRC $version
    writeini -n $shortfn($scriptdir) $+ irctunes.ini settings support false 
  }
}
ctcp *:irctunes: { 
  notice $nick I use iRCTunes $itversion for mIRC by Peter Powell of MoofSpeak Scripts (irctunes.sf.net) 
}
ctcp *:getsong: {
  if ($itsettings(dcc) == true) { .notice $nick iRCTunes DCC request accepted - preparing to send file $nopath($itunesinfo(location)) | .timerdcc $+ $rand(1,100) 1 $rand(2,7) .dcc send $nick $itunesinfo(shortlocation) }
  else { .notice $nick [iRCTunes] I currently have my iRCTunes DCC Server disabled }
}
ctcp *:itunes: {
  if ($itsettings(demand) == true) {
    if (!$com(irctunes)) { .notice $nick [iRCTunes] iTunes is currently disconnected }
    else { .notice $nick [iRCTunes] I am listening to $chr(2) $+ ' $+ $itunesinfo(track) $+ ' $+ $chr(15) by $chr(2) $+ $itunesinfo(artist) $+ $chr(15) from the album $chr(2) $+ $itunesinfo(album) $+ $chr(15) }
  }
  else { .notice $nick [iRCTunes] iRCTunes on Demand is currently disabled }
}
menu channel,query {
  iRCTunes $itversion
  .Announce Track :itunes show
  .iTunes on Demand:itunes demand
  .Advertise iRCTunes:itunes advertise
  .Restart iRCTunes:itunes restart
  .-
  .iRCTunes !commands
  ..!itunes:msg $active !itunes
  ..!getsong:msg $active !getsong
}
menu nicklist {
  iRCTunes $itversion
  .CTCP iTunes:ctcp $$1 itunes
  .CTCP iRCTunes:ctcp $$1 irctunes
  .CTCP GetSong:ctcp $$1 getsong
}
menu menubar {
  iRCTunes $itversion
  .iTunes Controls
  ..Next track:itunes next
  ..Pause track:itunes pause
  ..Play track:itunes play
  ..Previous track:itunes prev
  ..Rewind track:itunes rewind
  ..Stop track:itunes stop
  .iRCTunes Controls
  ..About iRCTunes:itunes about
  ..Advertise iRCTunes:itunes advertise
  ..Automatic broadcast track:itunes autobroadcast
  ..Automatic showto track:itunes autoshowto $active
  ..Automatically check for updates:itunes acheckupdate
  ..Broadcast track:itunes broadcast
  ..Check for updates:itunes checkupdate
  ..Control popup:itunes popup
  ..Find track info:itunes info
  ..Get iRCTunes COM status:itunes status
  ..iRCTunes DCC Server:itunes dcc
  ..iRCTunes on Demand:itunes demand
  ..iRCTunes theme manager:itunes themes
  ..iTunes autoconnect:itunes autoconn
  ..Restart iRCTunes:itunes restart
  ..Send song to clipboard:itunes clipboard
  ..Send song to editbox:itunes editbox
  ..Send track:itunes sendtrack
  ..Show current theme:itunes theme
  ..Show track:itunes show
  ..Showto track:itunes showto $active
  ..Theme help:itunes themehelp
  .Help and Support
  ..Main Help:itunes help
  ..Theme Help:itunes themehelp
  ..External Support
  ...WWW:itunes website
  ...Live Support:itunes support
}
alias itunes {
  if ($1 == $null) { echo -a 03Error: you need to enter a command - See "/itunes help" for all of the commands }
  elseif ($1 == help) {
    echo -a  ==iRCTunes $itversion for mIRC Help==                      
    echo -a  /itunes about - Displays script information
    echo -a  /itunes acheckupdate - Toggle on & off auto update checking on startup
    echo -a  /itunes advertise - Posts script information to current active channel
    echo -a  /itunes autobroadcast - Toggles on & off automatically broadcasting track
    echo -a  /itunes autoconn - Toggle on & off auto connecting to iTunes on startup
    echo -a  /itunes autoshowto - Toggles on & off automatically showing track to a specified channel
    echo -a  /itunes broadcast - Displays playing track in all open windows
    echo -a  /itunes checkupdate - Checks to see if there is a new version of iRCTunes
    echo -a  /itunes clipboard - Sends your current song's information to the clipboard
    echo -a  /itunes dcc - Toggles on/off iRCTunes DCC Server 
    echo -a  /itunes demand - Toggles on/off iTunes On Demand 
    echo -a  /itunes editbox - Sends your current song's information to the editbox
    echo -a  /itunes help - Displays this help menu
    echo -a  /itunes info - Displays information for current track
    echo -a  /itunes next - Moves iTunes to next track
    echo -a  /itunes pause - Pauses playing track
    echo -a  /itunes play - Start playing track current track in iTunes
    echo -a  /itunes popup - Opens a dialog for quick iRCTunes use
    echo -a  /itunes prev - Move iTunes to previous track
    echo -a  /itunes restart - Restart the iTunes System
    echo -a  /itunes rewind - Rewind your current playing track
    echo -a  /itunes sendtrack - sends the current track to a specified user
    echo -a  /itunes show - Displays playing track to current active window
    echo -a  /itunes showto - Displays playing track to a specified channel
    echo -a  /itunes status - Display iTunes playing status
    echo -a  /itunes stop - Stop playing track current track in iTunes
    echo -a  /itunes support - Connects you to MoofSpeak IRC for support
    echo -a  /itunes theme - Shows the current iRCTunes theme
    echo -a  /itunes themehelp - Shows more help for custom themes
    echo -a  /itunes themes - Starts the iRCTunes theme editor
    echo -a  /itunes website - Opens the iRCTunes website
    echo -a  Copyright 2007 Peter Powell of MoofSpeak Scripts
  }
  elseif ($1 == themehelp) {
    echo -a ==iRCTunes $itversion for mIRC Theming Help==
    echo -a The variables you can use in themes are:
    echo -a ^ALBUM^  - Returns the album of your current track
    echo -a ^ARTIST^ - Returns the artist of your current track
    echo -a ^BITRATE^ - Returns the bitrate of your current track
    echo -a ^BPM^ - Returns the beats per minute of your track
    echo -a ^GENRE^ - Returns the genre of your current track
    echo -a ^GRAPHRATING^ - Returns the rating of your current track (graph format)
    echo -a ^LENGTH^ - Returns the formatted length of your current track
    echo -a ^LOCATION^ - Returns the long location of your current track
    echo -a ^PLAYCOUNT^ - Returns the play count of your current track
    echo -a ^RATING^ - Returns the rating of your current track
    echo -a ^SECLENGTH^ - Returns the length in seconds of your current track
    echo -a ^SHORTLOCATION^ - Returns the short location of your current track
    echo -a ^SIZE^ - Returns the size in megabytes of your current track
    echo -a ^TRACK^ - Returns the name of your current track
    echo -a (+) - Removes the space between the previous and next variable
    echo -a TIME(duration,format) - Returns the duration in the format specified
    echo -a (BOLD) - Inserts a bold character (ASCII character 2)
    echo -a (/BOLD) - Inserts a bold end character (ASCII character 15)
    echo -a Copyright 2007 Peter Powell of MoofSpeak Scripts
  }
  elseif ($1 == website) { run http://irctunes.sf.net/mirc/ }
  elseif ($1 == popup) { dialog -mdieo it_popup it_popup }
  elseif ($1 == info) {  dialog -mdieo it_trackinfo it_trackinfo }
  elseif ($1 == about) { dialog -mdieo it_about it_about }
  elseif ($1 == themes) { dialog -mdieo it_theming it_theming }
  elseif ($1 == theme) { echo -a 04Current Theme: $itcurrtheme }
  elseif ($1 == status) { 
    if (!$com(irctunes)) { echo -a COM Status: iRCTunes is disconnected from iTunes }
    elseif ($com(irctunes)) { echo -a COM Status: iRCTunes is connected to iTunes }
  }  
  elseif ($1 == sendtrack) { 
    if ($2) { dcc send $2 $itunesinfo(shortlocation) }
    else { dcc send $?="Enter the nickname of the person you would like to send your current track to" $itunesinfo(shortlocation) }
  }
  elseif ($1 == rewind) {
    var %it.comresult $com(irctunes,Rewind,3)
    if (!$com(irctunes)) { .comopen irctunes iTunes.Application }
    if ($comerr) { silentrestart | itunes rewind }
    if (%it.comresult == 0) { echo -a 03Error: Please ensure that iTunes is open and connected (/itunes status) }
  }
  elseif ($1 == show) {
    tokenize 32 $itsettings(theme)
    if ($1 == [DESCRIBE]) { .scid $scid($activecid) describe $active $2- }
    else { .scid $scid($activecid) msg $active $itsettings(theme) }
  }
  elseif ($1 == showto) {
    if ($2) {
      var %trgt $2
      tokenize 32 $itsettings(theme)
      if ($1 == [DESCRIBE]) { .scid $scid($activecid) describe %trgt $2- }
      else { .scid $activecid msg %trgt $itsettings(theme) }
    }
    else echo -a Syntax: /itunes showto #channel_name
  }
  elseif ($1 == broadcast) { 
    tokenize 32 $itsettings(theme)
    if ($1 == [DESCRIBE]) { .scid -at1 ame $2- }
    else { .scid -at1 amsg $itsettings(theme) }
  }
  elseif ($1 == demand) { 
    if ($itsettings(demand) == false) { writeini -n $shortfn($scriptdir) $+ irctunes.ini settings demand true | scid -at1 ame has now enabled iTunes On Demand - type !itunes or /ctcp $me itunes to see what song i am currently playing in iTunes [iRCTunes] }
    elseif ($itsettings(demand) == true) { writeini -n $shortfn($scriptdir) $+ irctunes.ini settings demand false | scid -at1 ame now has disabled iTunes On Demand [iRCTunes] }
  }
  elseif ($1 == autoconn) { 
    if ($itsettings(autoconn) == true) { writeini -n $shortfn($scriptdir) $+ irctunes.ini settings autoconn false | echo -a iRCTunes will no longer connect to iTunes on startup (not recommended) | echo -a To re-enable this type /itunes autoconn (recommended) }
    elseif ($itsettings(autoconn) == false) { writeini -n $shortfn($scriptdir) $+ irctunes.ini settings autoconn true | echo -a iRCTunes will now connect to iTunes on startup (recommended) | echo -a To disable this type /itunes autoconn (not recommended) }
  }
  elseif ($1 == dcc) { 
    if ($itsettings(dcc) == false) { writeini -n $shortfn($scriptdir) $+ irctunes.ini settings dcc true | scid -at1 ame has now enabled their iRCTunes DCC Server - type !getsong or /ctcp $me getsong to get a copy of the song i am currently playing in iTunes [iRCTunes] }
    elseif ($itsettings(dcc) == true) { writeini -n $shortfn($scriptdir) $+ irctunes.ini settings dcc false | scid -at1 ame has now disabled their iRCTunes DCC Server [iRCTunes] }
  }
  elseif ($1 == checkupdate) {
    if ($sock(it_chkupdate)) { sockclose it_chkupdate }
    .sockopen it_chkupdate irctunes.sourceforge.net 80
  }
  elseif ($1 == acheckupdate) {
    if ($itsettings(checkupdate) == false) { itsettings checkupdate true | echo -a Automatic update checking now enabled (recommended) }
    elseif ($itsettings(checkupdate) == true) { itsettings checkupdate false | echo -a Automatic update checking now disabled (not recommended) }
  }
  elseif ($1 == clipboard) { clipboard [iRCTunes] Track: $itunesinfo(track) $+ , Artist: $itunesinfo(artist) $+ , Album: $itunesinfo(album) | echo -a 04Track information sent to the clipboard }
  elseif ($1 == editbox) { editbox [iRCTunes] Track: $itunesinfo(track) $+ , Artist: $itunesinfo(artist) $+ , Album: $itunesinfo(album) | echo -a 04Track information sent to the editbox }
  elseif ($1 == advertise) { scid $activecid describe $active uses iRCTunes $itversion for mIRC by Peter Powell of MoofSpeak Scripts (irctunes.sf.net) }
  elseif ($1 == showabout) { echo -a The /itunes showabout command has been renamed to /itunes advertise }
  elseif ($1 == autobroadcast) {
    if ($timer(ast)) { .timerast off | echo -a iRCTunes detected that autoshowto was enabled and has disabled it to prevent conflicts }
    if ($timer(abc)) { .timerabc off | echo -a iRCTunes will now no longer send an automatic np message to all channels }
    elseif (!$timer(abc)) { .ittemp lastlocb $itunesinfo(shortlocation) | .timerabc 0 10 abcast | echo -a iRCTunes will now send an automatic np message to all channels every time your track changes }
  }
  elseif ($1 == autoshowto) {
    if ($timer(abc)) { .timerabc off | echo -a iRCTunes detected that autobroadcast was enabled and has disabled it to prevent conflicts }
    if ($timer(ast)) { .timerast off | unset %it.shwtochn | echo -a iRCTunes will now no longer send an automatic np message to your specified channel }
    elseif (!$timer(ast)) { 
      if ($2) { ittemp lastlocs $itunesinfo(shortlocation) | .timerast 0 10 .scid $scid($activecid) ashowto $2 | echo -a iRCTunes will now send an automatic np message to $$2 every time your track changes }
      else echo -a Syntax: /itunes autoshowto #channel-name
    }
  }
  elseif ($1 == support) {
    writeini -n $shortfn($scriptdir) $+ irctunes.ini settings support true
    server -m irc.moofspeak.net -j #scripts
    echo -a Now Connecting you to the MoofSpeak IRC Network for Live Support
    echo -a An automatic support message will be sent to the help channel on connection
  }
  elseif ($1 == restart) { 
    echo -a Restarting iRCTunes connection..
    if ($com(irctunes)) { .comclose irctunes | .timerco 1 1 .comopen irctunes iTunes.Application }
    else { .comopen irctunes iTunes.Application }
    .timer1 1 2 echo -a iRCTunes has now restarted
  }
  elseif ($1 == play) {
    var %it.comresult $com(irctunes,Play,3)
    if (!$com(irctunes)) { .comopen irctunes iTunes.Application }
    if ($comerr) { silentrestart | itunes play }
    if (%it.comresult == 0) { echo -a 03Error: Please ensure that iTunes is open and connected (/itunes status) }
  }
  elseif ($1 == pause) {
    var %it.comresult $com(irctunes,Pause,3)
    if (!$com(irctunes)) { .comopen irctunes iTunes.Application }
    if ($comerr) { silentrestart | itunes play }
    if (%it.comresult == 0) { echo -a 03Error: Please ensure that iTunes is open and connected (/itunes status) }
  }
  elseif ($1 == stop) {
    var %it.comresult $com(irctunes,Stop,3)
    if (!$com(irctunes)) { .comopen irctunes iTunes.Application }
    if ($comerr) { silentrestart | itunes stop }
    if (%it.comresult == 0) { echo -a 03Error: Please ensure that iTunes is open and connected (/itunes status) }
  }
  elseif ($1 == next) {
    var %it.comresult $com(irctunes,NextTrack,3)
    if (!$com(irctunes)) { .comopen irctunes iTunes.Application }
    if ($comerr) { silentrestart | itunes next }
    if (%it.comresult == 0) { echo -a 03Error: Please ensure that iTunes is open and connected (/itunes status) }
  }
  elseif ($1 == prev) {
    var %it.comresult $com(irctunes,PreviousTrack,3)
    if (!$com(irctunes)) { .comopen irctunes iTunes.Application }
    if ($comerr) { silentrestart | itunes prev }
    if (%it.comresult == 0) { echo -a 03Error: Please ensure that iTunes is open and connected (/itunes status) }
  }
  else {
    echo -a Error: " $+ $1- $+ " is an unknown command
  }
}
alias itunesinfo {
  if (!$com(irctunes)) .comopen irctunes iTunes.Application
  if ($com(CurrentTrack)) .comclose CurrentTrack
  .echo -q $com(irctunes,CurrentTrack,3,dispatch* CurrentTrack) 
  if ($comerr) { silentrestart | return COM Error }
  if (!$com(CurrentTrack)) { silentrestart | return COM Error }
  if ($1 == track) {
    .echo -q $com(CurrentTrack,Name,3) 
    if ($com(CurrentTrack).result == $null) return Unknown Track
    var %it.track $com(CurrentTrack).result
    return %it.track
  }
  elseif ($1 == artist) {
    .echo -q $com(CurrentTrack,Artist,3) 
    if ($com(CurrentTrack).result == $null) return Unknown Artist
    var %it.artist $com(CurrentTrack).result
    return %it.artist
  }
  elseif ($1 == album) {
    .echo -q $com(CurrentTrack,Album,3) 
    if ($com(CurrentTrack).result == $null) return Unknown Album
    var %it.album $com(CurrentTrack).result
    return %it.album
  }
  elseif ($1 == bitrate) {
    .echo -q $com(CurrentTrack,BitRate,3) 
    if ($com(CurrentTrack).result == $null) return Unknown Bitrate
    var %it.bitrate $com(CurrentTrack).result
    return %it.bitrate
  }
  elseif ($1 == playcount) {
    .echo -q $com(CurrentTrack,PlayedCount,3) 
    if ($com(CurrentTrack).result == $null) return Unknown Playcount
    var %it.playcount $com(CurrentTrack).result
    return %it.playcount
  }
  elseif ($1 == rating) {
    .echo -q $com(CurrentTrack,Rating,3) 
    if ($com(CurrentTrack).result == $null) return Unknown Rating
    var %it.rating $com(CurrentTrack).result
    if (%it.rating == 0) { var %it.fullrating Unrated }
    else { var %it.fullrating %it.rating }
    return %it.fullrating
  }
  elseif ($1 == graphrating) {
    .echo -q $com(CurrentTrack,Rating,3) 
    if ($com(CurrentTrack).result == $null) return Unknown Rating
    var %it.graphrating $com(CurrentTrack).result
    if (%it.graphrating == 0) { var %it.fullgraphrating [UNRATED] }
    elseif (%it.graphrating == 20) { var %it.fullgraphrating [*....] }
    elseif (%it.graphrating == 40) { var %it.fullgraphrating [**...] }
    elseif (%it.graphrating == 60) { var %it.fullgraphrating [***..] }
    elseif (%it.graphrating == 80) { var %it.fullgraphrating [****.] }
    elseif (%it.graphrating == 100) { var %it.fullgraphrating [*****] }
    return %it.fullgraphrating
  }
  elseif ($1 == length) {
    .echo -q $com(CurrentTrack,Duration,3) 
    if ($com(CurrentTrack).result == $null) return Unknown Length
    var %it.duration $duration($com(CurrentTrack).result)
    return %it.duration
  }
  elseif ($1 == seclength) {
    .echo -q $com(CurrentTrack,Duration,3) 
    if ($com(CurrentTrack).result == $null) return Unknown Length
    var %it.duration $com(CurrentTrack).result
    return %it.duration
  }
  elseif ($1 == genre) {
    .echo -q $com(CurrentTrack,Genre,3) 
    if ($com(CurrentTrack).result == $null) return Unknown Genre
    var %it.genre $com(CurrentTrack).result
    return %it.genre
  }
  elseif ($1 == bpm) {
    .echo -q $com(CurrentTrack,BPM,3) 
    if ($com(CurrentTrack).result == $null) return Unknown BPM
    var %it.bpm $com(CurrentTrack).result
    return %it.bpm
  }
  elseif ($1 == location) {
    .echo -q $com(CurrentTrack,Location,3) 
    if ($com(CurrentTrack).result == $null) return Unknown Location
    var %it.location $com(CurrentTrack).result
    return %it.location
  }
  elseif ($1 == shortlocation) {
    .echo -q $com(CurrentTrack,Location,3) 
    if ($com(CurrentTrack).result == $null) return Unknown Location
    var %it.location2 $com(CurrentTrack).result
    var %it.shortlocation $shortfn(%it.location2)
    return %it.shortlocation
  }
  elseif ($1 == size) {
    .echo -q $com(CurrentTrack,Size,3) 
    if ($com(CurrentTrack).result == $null) return Unknown Size
    var %it.size $left($calc($com(CurrentTrack).result / 1048576),4)
    return %it.size
  }
  elseif ($1 == location2) {
    return $itunesinfo(shortlocation)
  }
  elseif ($1 == rating2) {
    return $itunesinfo(graphrating)
  }
  elseif ($1 == length2) {
    return $itunesinfo(seclength)
  }
}
alias itversion { 
  return v2.3
}
alias itnumversion { 
  return 2.3.0
}
alias itsettings {
  if ($isid == $true) return $readini($shortfn($scriptdir) $+ irctunes.ini, settings, $1)
  else writeini $shortfn($scriptdir) $+ irctunes.ini settings $$1 $$2-
}
alias ittemp {
  if ($isid == $true) return $readini($shortfn($scriptdir) $+ irctunes.ini, temp, $1)
  else writeini $shortfn($scriptdir) $+ irctunes.ini temp $$1 $$2 $3-
}
alias irctunes {
  echo -a 03Error: did you mean to type /itunes $1- $+ ?
}
alias itparsetheme {
  if ($1 == read2code) { 
    return $replace($2,^ALBUM^,$!itunesinfo(album),^ARTIST^,$!itunesinfo(artist),^BITRATE^,$!itunesinfo(bitrate),^BPM^,$!itunesinfo(bpm),^GENRE^,$!itunesinfo(genre),^LENGTH^,$!itunesinfo(length),^SECLENGTH^,$!itunesinfo(seclength),^LOCATION^,$!itunesinfo(location),^SHORTLOCATION^,$!itunesinfo(shortlocation),^PLAYCOUNT^,$!itunesinfo(playcount),^RATING^,$!itunesinfo(rating),^GRAPHRATING^,$!itunesinfo(graphrating),^SIZE^,$!itunesinfo(size),^TRACK^,$!itunesinfo(track),(+),$!+,TIME,$!asctime,(BOLD),$!chr(2),(/BOLD),$!chr(15))
  }
  elseif ($1 == code2read) {
    return $replace($2,$eval($!itunesinfo(album),0),^ALBUM^,$!itunesinfo(artist),^ARTIST^,$!itunesinfo(bitrate),^BITRATE^,$!itunesinfo(bpm),^BPM^,$!itunesinfo(genre),^GENRE^,$!itunesinfo(length),^LENGTH^,$!itunesinfo(seclength),^SECLENGTH^,$!itunesinfo(location),^LOCATION^,$!itunesinfo(shortlocation),^SHORTLOCATION^,$!itunesinfo(playcount),^PLAYCOUNT^,$!itunesinfo(rating),^RATING^,$!itunesinfo(graphrating),^GRAPHRATING^,$!itunesinfo(size),^SIZE^,$!itunesinfo(track),^TRACK^,$!+,(+),$!asctime,TIME,$!chr(2),(BOLD),$!chr(15),(/BOLD))
  }
}
alias -l itcurrtheme { 
  return $itparsetheme(code2read,$readini($shortfn($scriptdir) $+ irctunes.ini, n, settings, theme)) 
}
alias -l abcast {
  if ($ittemp(lastlocb) != $itunesinfo(shortlocation)) { itunes broadcast | ittemp lastlocb $itunesinfo(shortlocation) }
}
alias -l ashowto {
  if ($ittemp(lastlocs) != $itunesinfo(shortlocation)) { itunes showto $1 | ittemp lastlocs $itunesinfo(shortlocation) }
}
alias -l silentrestart {
  if ($com(irctunes)) { .timercc 1 1 .comclose irctunes | .timerco 1 2 .comopen irctunes iTunes.Application }
  else { .timerco 1 2 .comopen irctunes iTunes.Application }
}
on *:SOCKOPEN:it_chkupdate: {
  if ($sockerr) { echo -a 04WARNING: There was a problem connecting to the iRCTunes update server while checking for updates | halt }
  .sockwrite -n $sockname GET /updater/mirc.php?v=2 HTTP/1.1
  .sockwrite -n $sockname Host: irctunes.sourceforge.net $+ $crlf $+ $crlf
}
on *:SOCKREAD:it_chkupdate:{
  if ($sockerr) { echo -a 04WARNING: There was a problem reading from the iRCTunes update server while checking for updates | halt }
  var %isck
  sockread -f %isck
  tokenize 32 %isck
  if ($1 = LATEST_VERSION) { writeini -n $shortfn($scriptdir) $+ irctunes.ini updater version $2- }
  elseif ($1 == LATEST_NUMVERSION) { writeini -n $shortfn($scriptdir) $+ irctunes.ini updater numversion $2- }
  elseif ($1 == LATEST_INFO) { writeini -n $shortfn($scriptdir) $+ irctunes.ini updater information $2- }
  elseif ($1 == LATEST_LINK) { writeini -n $shortfn($scriptdir) $+ irctunes.ini updater link $2- }
  elseif ($1 == END_OF_FILE) { .sockclose $sockname 
    if ($readini($shortfn($scriptdir) $+ irctunes.ini, updater, numversion) == $itnumversion) { echo -a You are using the latest version of iRCTunes for mIRC $chr(40) $+ $itversion $+ $chr(41) | remini $shortfn($scriptdir) $+ irctunes.ini updater }
    elseif ($readini($shortfn($scriptdir) $+ irctunes.ini, updater, numversion) < $itnumversion) { echo -a You are using a version that is newer than the latest version of iRCTunes for mIRC $chr(40) $+ $itversion $+ $chr(41) | remini $shortfn($scriptdir) $+ irctunes.ini updater }
    elseif ($readini($shortfn($scriptdir) $+ irctunes.ini, updater, numversion) > $itnumversion) { echo -a 04You are using an older version of iRCTunes for mIRC - Your Version: $itversion $+ , Latest Version: $readini($shortfn($scriptdir) $+ irctunes.ini, updater, version) | dialog -mdrieo it_newver it_newver }
    else { echo -a 03An error occurred while reading the update information - to find out the latest version please go to http://irctunes.sf.net/mirc/download.php | remini $shortfn($scriptdir) $+ irctunes.ini updater }
  }
}
dialog -l it_trackinfo {
  title "Track Information"
  size -1 -1 140 93
  option dbu
  text "iRCTunes :: Track Information", 2, 0 0 140 8, center
  text Name: $itunesinfo(track), 1, 2 9 138 8
  text Artist: $itunesinfo(artist), 5, 2 17 138 8
  text Album: $itunesinfo(album), 6, 2 25 138 8
  text Bitrate: $itunesinfo(bitrate), 7, 2 33 138 8
  text Playcount: $itunesinfo(playcount), 8, 2 41 138 8
  text Rating: $itunesinfo(rating), 9, 2 49 138 8
  text Length: $itunesinfo(length), 10, 2 57 138 8
  text Genre: $itunesinfo(genre), 11, 2 65 138 8
  text BPM: $itunesinfo(bpm), 12, 2 73 138 8
  button "OK", 3, 119 82 20 10, ok cancel
  text "iRCTunes :: irctunes.sf.net", 4, 0 83 119 8, disable center
}
dialog -l it_theming {
  title "iRCTunes :: Theme Manager v2.1"
  size -1 -1 200 106
  option dbu
  box "Theme Manager v2.1", 1, 1 1 198 104
  button * $me is listening to 'TRACK' by ARTIST [LENGTH / SIZE / BITRATE], 2, 5 10 190 12
  button * $me iTunes: [TRACK | ARTIST | ALBUM], 3, 5 22 190 12
  button * $me iTunes: TRACK - ARTIST, 4, 5 34 190 12
  button iRCTunes :: TRACK - ARTIST - ALBUM, 5, 5 58 190 12
  button iTunes np: $chr(91) TRACK / ARTIST / ALBUM $chr(93), 6, 5 46 190 12
  button iNP: TRACK - ARTIST [iRCTunes], 7, 5 70 190 12
  edit $itcurrtheme, 8, 6 82 188 10, autohs
  text "iRCTunes :: irctunes.sf.net", 11, 5 95 110 8, disable center
  button "Cancel", 12, 155 93 40 10, cancel
  button "Save", 13, 115 93 40 10, ok
}
dialog it_newver {
  title "iRCTunes :: Update Notifier"
  size -1 -1 180 68
  option dbu
  text "The iRCTunes updater found the following update available for download:", 1, 1 1 178 8
  text "Current iRCTunes version:", 2, 2 10 65 8
  text "Latest iRCTunes version:", 3, 2 19 65 8
  text "Latest version information:", 4, 2 28 65 8
  text $itversion, 5, 69 10 110 8
  text $itlatestversion, 6, 69 19 110 8
  text $itimportantinfo, 7, 69 28 110 30
  button "Download Update", 8, 1 37 66 10
  button "Remind me later", 9, 1 47 66 10
  button "Disable checker and close", 10, 1 57 66 10, ok cancel
  text "iRCTunes :: irctunes.sf.net", 11, 69 59 110 8, disable center
}
dialog -l it_about {
  title "iRCTunes :: About"
  size -1 -1 130 86
  option dbu
  text "Name:", 1, 2 9 20 8
  text iRCTunes $itversion for mIRC, 2, 22 9 108 8
  text "PetPow @ irc.moofspeak.net #scripts", 3, 22 25 108 8
  text "Author: Peter Powell <petpow@thegeeklord.net>", 4, 2 17 128 8
  text "About iRCTunes for mIRC", 5, 0 0 130 8, center
  text "About:", 6, 2 33 20 8
  text "iRCTunes is a plugin for mIRC that allows you to completely control iTunes. Using a series of commands, you can quickly and easily export the now playing info to IRC or even, with commands like Play, Pause and Rewind, you can control iTunes from mIRC.", 7, 22 33 108 40
  text "iRCTunes :: irctunes.sf.net", 8, 0 76 93 8, disable center
  button "OK", 9, 93 74 37 12, ok cancel
}
on *:DIALOG:it_popup:INIT:*: {
  if ($timer(abc)) { did -a it_popup 13 [E] Auto Broadcast Track }
  else { did -a it_popup 13 [D] Auto Broadcast Track }
  if ($timer(ast)) { did -a it_popup 12 [E] Auto Show Track to Chan }
  else { did -a it_popup 12 [D] Auto Show Track to Chan }
  if ($itsettings(dcc) = true) { did -a it_popup 17 [E] iRCTunes DCC Server }
  else { did -a it_popup 17 [D] iRCTunes DCC Server }
  if ($itsettings(demand) = true) { did -a it_popup 18 [E] iTunes on Demand }
  else { did -a it_popup 18 [D] iTunes on Demand }
}

dialog -l it_popup {
  title "iRCTunes :: Popup"
  size -1 -1 150 172
  option dbu
  text "iTunes Controls", 1, 0 0 150 8, center
  button "Play", 2, 1 7 74 10
  button "Pause", 3, 75 7 74 10
  button "Previous", 4, 1 17 74 10
  button "Next", 5, 75 17 74 10
  button "Rewind", 6, 1 27 74 10
  button "Stop", 7, 75 27 74 10
  text "iRCTunes Controls", 8, 1 37 150 8, center
  button "About iRCTunes", 9, 1 54 74 10
  button "Auto Update Checker", 10, 75 144 74 10
  button "Auto Connect to iTunes", 11, 1 144 74 10
  button "Auto Show Track to Chan", 12, 75 44 74 10
  button "Auto Broadcast Track", 13, 1 44 74 10
  button "Broadcast Track", 14, 75 54 74 10
  button "Check for Updates", 15, 1 64 74 10
  button "Send Track Info to Clipboard", 16, 75 64 74 10
  button "iRCTunes DCC Server", 17, 1 74 74 10
  button "iTunes on Demand", 18, 75 74 74 10
  button "iTunes Track Information", 19, 1 84 74 10
  button "Restart iRCTunes", 20, 75 84 74 10
  button "Send Track via DCC", 21, 1 94 74 10
  button "Show Track", 22, 75 94 74 10
  button "Advertise iRCTunes", 23, 1 104 74 10
  button "Show Track to Chan", 24, 75 104 74 10
  button "iRCTunes COM Status", 25, 1 114 74 10
  button "iRCTunes Support", 26, 75 114 74 10
  button "Show Now Playing Theme", 27, 1 124 74 10
  button "iRCTunes Theme Manager", 28, 75 124 74 10
  button "iRCTunes Main Help", 29, 1 134 74 10
  button "iRCTunes Theming Help", 30, 75 134 74 10
  button "Send Track Info to Editbox", 31, 1 154 74 10
  button "Open iRCTunes Website", 32, 74 154 74 10
  text "iRCTunes - irctunes.sf.net", 33, 0 165 150 8, disable center
}
on *:DIALOG:it_popup:SCLICK:2: itunes play
on *:DIALOG:it_popup:SCLICK:3: itunes pause
on *:DIALOG:it_popup:SCLICK:4: itunes prev
on *:DIALOG:it_popup:SCLICK:5: itunes next
on *:DIALOG:it_popup:SCLICK:6: itunes rewind
on *:DIALOG:it_popup:SCLICK:7: itunes stop
on *:DIALOG:it_popup:SCLICK:9: itunes about
on *:DIALOG:it_popup:SCLICK:10: itunes acheckupdate
on *:DIALOG:it_popup:SCLICK:11: itunes autoconn
on *:DIALOG:it_popup:SCLICK:12: itunes autoshowto $active
on *:DIALOG:it_popup:SCLICK:13: itunes autobroadcast
on *:DIALOG:it_popup:SCLICK:14: itunes broadcast
on *:DIALOG:it_popup:SCLICK:15: itunes checkupdate
on *:DIALOG:it_popup:SCLICK:16: itunes clipboard
on *:DIALOG:it_popup:SCLICK:17: itunes dcc
on *:DIALOG:it_popup:SCLICK:18: itunes demand
on *:DIALOG:it_popup:SCLICK:19: itunes info
on *:DIALOG:it_popup:SCLICK:20: itunes restart
on *:DIALOG:it_popup:SCLICK:21: itunes sendtrack
on *:DIALOG:it_popup:SCLICK:22: itunes show
on *:DIALOG:it_popup:SCLICK:23: itunes advertise
on *:DIALOG:it_popup:SCLICK:24: itunes showto $active
on *:DIALOG:it_popup:SCLICK:25: itunes status
on *:DIALOG:it_popup:SCLICK:26: itunes support
on *:DIALOG:it_popup:SCLICK:27: itunes theme
on *:DIALOG:it_popup:SCLICK:28: itunes themes
on *:DIALOG:it_popup:SCLICK:29: itunes help
on *:DIALOG:it_popup:SCLICK:30: itunes themehelp
on *:DIALOG:it_popup:SCLICK:31: itunes editbox
on *:DIALOG:it_popup:SCLICK:32: itunes website
on *:DIALOG:it_newver:SCLICK:8: { run $readini($shortfn($scriptdir) $+ irctunes.ini, updater, link) | dialog -x it_newver }
on *:DIALOG:it_newver:SCLICK:9: { dialog -x it_newver | .timeriupd 1 7200 itunes checkupdate }
on *:DIALOG:it_newver:SCLICK:10: { dialog -x it_newver | itsettings checkupdate false | echo -a iRCTunes has disabled automatic update checking }
on *:DIALOG:it_newver:close:*: { remini $shortfn($scriptdir) $+ irctunes.ini updater }
alias -l itlatestversion { return $readini($shortfn($scriptdir) $+ irctunes.ini, updater, version) }
alias -l itimportantinfo { return $readini($shortfn($scriptdir) $+ irctunes.ini, updater, information) }
on *:DIALOG:it_theming:SCLICK:2: did -o it_theming 8 1 $itparsetheme(code2read,[DESCRIBE] is listening to $!chr(2) $!+ ' $!+ ^TRACK^ $!+ ' $!+ $!chr(15) by $!chr(2) $!+ ^ARTIST^ $!+ $!chr(15) [ $!+ $!asctime(^SECLENGTH^,n:ss) $!+ / $!+ ^SIZE^ $!+ mb/ $!+ ^BITRATE^ $!+ kbps])
on *:DIALOG:it_theming:SCLICK:3: did -o it_theming 8 1 $itparsetheme(code2read,[DESCRIBE] iTunes: $!chr(91) $!+ ^TRACK^ $!+ $eval(|,0) $!+ ^ARTIST^ $!+ $eval(|,0) $!+ ^ALBUM^ $!+ $!chr(93))
on *:DIALOG:it_theming:SCLICK:4: did -o it_theming 8 1 $itparsetheme(code2read,[DESCRIBE] iTunes: ^TRACK^ - ^ARTIST^)
on *:DIALOG:it_theming:SCLICK:5: did -o it_theming 8 1 $itparsetheme(code2read,iRCTunes :: ^TRACK^ - ^ARTIST^ - ^ALBUM^)
on *:DIALOG:it_theming:SCLICK:6: did -o it_theming 8 1 $itparsetheme(code2read,iTunes np: $!chr(91) $!+ ^TRACK^ $!+ / $!+ ^ARTIST^ $!+ / $!+ ^ALBUM^ $!+ $!chr(93))
on *:DIALOG:it_theming:SCLICK:7: did -o it_theming 8 1 $itparsetheme(code2read,iNP: ^TRACK^ - ^ARTIST^ [iRCTunes])
on *:DIALOG:it_theming:SCLICK:13: itsettings theme $itparsetheme(read2code,$did(it_theming, 8).text)