on *:SOCKOPEN:SongReq:{
[color:#006600];
; NICK <nickname>
;[/color]
sockwrite -n $sockname NICK $mnick
[color:#006600];
; USER <userid> <email host> <servername> <:full name/GCOS>
;[/color]
sockwrite -n $sockname USER $&
$+(",$readini($mircini,ident,userid),") $&
$+(",$gettok($emailaddr,2,64),") $&
$+(",%SongRequest.server,") $&
$+(:,$fullname)
[color:#006600];
; Let yourself know the socket was opened (server found).
;[/color]
echo $color(info2) -abflirt * Song Request: connected
}
on *:SOCKCLOSE:SongReq:{
[color:#006600];
; Report that the socket was closed by remote host.
;[/color]
echo $color(ctcp) -abflirt * Song Request: terminated by the server
[color:#006600];
; Request a retry.
;[/color]
SongRequest.Retry
}
alias SongRequest.Retry {
[color:#006600];
; Increment the retry counter
;[/color]
inc %SongRequest.retries
[color:#006600];
; Check to make sure we haven't gone over the maximum retries limit.
;[/color]
if (%SongRequest.retries <= SongRequest.maxretries) .timer 1 10 sockopen $sockname %SockRequest.server 6667
[color:#006600];
; Terminate the process if maximum retries is reached.
;[/color]
else echo $color(ctcp) -abflirt * Song Request: All ( $+ %SongRequest.maxretries $+ ) retries failed.
[color:#006600];
; Stop the script.
;[/color]
halt
}
on *:SOCKREAD:SongReq:{
[color:#006600];
; Check for a socket error, such as Connection reset by peer.
;[/color]
if ($sockerr > 0) {
[color:#006600];
; Report the error condition.
;[/color]
echo $color(info) -abflirt * Song Request: $+([,$sock($sockname).wserr,]) $sock($sockname).wsmsg
[color:#006600];
; Request a retry.
;[/color]
SongRequest.Retry
}
[color:#006600];
; Otherwise, prepare to read the data sent from the server.
;[/color]
var %1-
[color:#006600];
; Read the data sent by the server.
;[/color]
sockread %1-
[color:#006600];
; If there was data, process it.
;[/color]
while ($sockbr > 0) {
[color:#006600];
; Tokenize it so you can use $1, $2, etc.
;[/color]
tokenize 32 %1-
[color:#006600];
; Respond to the initial PING :from the server.
;[/color]
if (PING == $1) sockwrite -n $sockname PONG $remove($2,:)
[color:#006600];
; Respond correctly to VERSION requests.
;[/color]
elseif ($4 == :VERSION) {
sockwrite -n $sockname NOTICE $right($gettok($1,1,33),-1) :VERSION mIRC v6.03 Khaled Mardam-Bey
}
[color:#006600];
; Make sure you try at least 3 nicks in case your primary nick is taken.
;[/color]
elseif ($2 == 433) {
[color:#006600];
; If the primary nick was taken, try the alternate nick.
;[/color]
if ($4 == $mnick) sockwrite -n $sockname NICK $anick
[color:#006600];
; Or if the alternate nick was taken, try a modified primary nick.
;[/color]
elseif ($4 == $anick) sockwrite -n $sockname NICK $mnick $+ ``
[color:#006600];
; If all 3 nicks tries were unsuccessful, halt the script.
;[/color]
else {
[color:#006600];
; Report nicks in use and halt.
;[/color]
echo $color(ctcp) -abflirt * Song Request: all nicks in use
[color:#006600];
; Close the socket.
;[/color]
sockclose $sockname
[color:#006600];
; Halt the script.
;[/color]
halt
}
}
[color:#006600];
; Wait for the End of /MOTD command. Send the message, then close the socket.
;[/color]
elseif ($2 == 376) {
[color:#006600];
; Ask for the song.
;[/color]
sockwrite -n $sockname PRIVMSG CurrentDJ :Will you play Song/Artist %SongRequest.song
[color:#006600];
; Let yourself know the song was requested and the script got this far.
;[/color]
echo $color(info2) -abflirt * Song request sent: %SongRequest.song
[color:#006600];
; Get rid of the variables used by the script.
;[/color]
unset %SongRequest.*
[color:#006600];
; Close the socket.
;[/color]
sockclose $sockname
[color:#006600];
; Halt the script.
;[/color]
halt
}
sockread %1-
}
}
alias SongReq {
[color:#006600];
; Check for input.
;[/color]
if (!$1) {
[color:#006600];
; Report that no song was requested.
;[/color]
echo $color(ctcp) -abflirt * Song Request: No song requested
[color:#006600];
; Halt the script.
;[/color]
halt
}
[color:#006600];
; Here is where you set in the real server name you wish to connect to.
;[/color]
set -u600 %SongRequest.server [color:red]radio.shoutcastserver.com[/color]
[color:#006600];
; Here is where you set the maximum times you wish to retry the connection.
;[/color]
set -u600 %SongRequest.maxretries [color:red]5[/color]
[color:#006600];
; Save the song that is to be requested for use later.
;[/color]
set -u600 %SongRequest.song $1-
[color:#006600];
; Open the socket to the ShoutCast server
;[/color]
sockopen SongReq %SongRequest.server 6667
}