- Home»
- Cod sursa: shoutcast.tcl
shoutcast.tcl
shoutcast.tcl
oReZ ShoutCast Script v1.0 (with some code from domsen's shoutcast.tcl) Admin Commands: !sc:addserver !sc:delserver !sc:kicksource !sc:setdj !sc:unsetdj !sc:settext
| Postat de | Copyright | Categorie | Review user | Vizualizari | Data |
|---|---|---|---|---|---|
| btc | LoReZ | stats | Cod netestat | 425 | 2023-12-25 11:52:00 |
#################################################################################################
# #
# LoReZ ShoutCast Script v1.0 (with some code from domsen's shoutcast.tcl) #
# Email: lorez@zerol.de #
# IRC: #muenchen @ Quakenet #
# #
# Admin Commands: !sc:addserver !sc:delserver !sc:kicksource !sc:setdj !sc:unsetdj !sc:settext #
# Stream Commands: !sc:listserver !sc:dj !sc:listener !sc:playing !sc:peak !sc:bitrate #
# Stream Commands: !sc:title !sc:genre !sc:url !sc:irc !sc:icq !sc:aim #
# Stream Commands: !sc:info !sc:wish !sc:greet #
# #
# IMPORTANT: #
# Admin Commands work only if the user has the +D flag on your bot. #
# Read the Eggdrop FAQ if you dont how to give or change flags. #
# The <adminpass> variable in the !sc:addserver command is an encoded password. #
# To get it you have to use mIRC and type //echo -a $encode(admin:adminpass) #
# else the !sc:kicksource command wont work #
# #
# Type !sc:help for available commands #
# #
#################################################################################################
#################################################################################################
# START OF CONFIGURATION #
#################################################################################################
# Set the Channel where the bot is on and the script shall work ( ! ! ! M U S T B E S E T ! ! ! )
set radiochan "#radio"
# Setting some files ( ! ! ! M U S T B E S E T ! ! ! )
set radiofile "/home/user/eggdrop/scripts/radio.db"
set streamfile "/home/user/eggdrop/scripts/stream.db"
set peakfile "/home/user/eggdrop/scripts/streampeak.db"
set djfile "/home/user/eggdrop/scripts/dj.db"
# Set the URL that will displayed to others
set streamlink "http://stream.radio.de/listen.pls"
# Do you want to enable public message bot commands (O = off , 1 = on)
set scpublic 1
# Do you want to enable private message bot commands (O = off , 1 = on)
set scmessage 1
# Do you want the bot to reply in public message (O = off , 1 = on)
set scpubmsg 0
# Do you want to enable the bot to announce track changes (O = off , 1 = on)
set announcetrack 1
# Do you want to enable the bot to announce bitrtate changes (O = off , 1 = on)
set announcebitrate 1
# Do you want to enable the bot to announce listener changes (O = off , 1 = on)
set announcelistener 1
# Do you want to enable the bot to announce peak changes (O = off , 1 = on)
set announcepeak 1
# Do you want to enable the bot to announce if the stream goes on/offline (O = off , 1 = on)
set announce 1
# Do you want to enable the bot to advertise all 10mins in the channel (O = off , 1 = on)
set advertise 1
# Do you want to enable the bot to change the topic when stream goes on/offline or on DJ change (O = off , 1 = on)
set topicchange 1
# Setting up some texts ;) You can change them later using !sc:settext
# Variables are:
############################################################################################################################
# /sc_streamlink/ = Server URL /sc_port/ = Stream Port #
# /sc_ip/ = Stream IP /sc_desc/ = Stream Description #
# /sc_dj/ = DJ /sc_peak/ = Stream Peak #
# /sc_listener/ = Current Listener /sc_totlistener/ = Current Total Listener #
# /sc_serverpeak/ = Server Peak /sc_unique/ = Current Unique Listener #
# /sc_totunique/ = Current Total Unique Listener /sc_url/ = Stream URL #
# /sc_max/ = Maximum Listener /sc_totmax/ = Maximum Total Listener #
# /sc_bitrate/ = Bitrate /sc_title/ = Stream Title #
# /sc_genre/ = Stream Genre /sc_avgtime/ = Listen Average Time #
# /sc_irc/ = Stream IRC /sc_icq/ = Stream ICQ #
# /sc_aim/ = Stream AIM /sc_webhits/ = Server Webhits #
# /sc_streamhits/ = Server Streamhits /sc_version/ = Server Version #
# /sc_track/ = Current Track /sc_songurl/ = Song URL #
# /sc_oldbitrate/ = Old Bitrate (works only in bitratechangetext) #
############################################################################################################################
# The text which will be displayed every 10 minutes (only if advertise = 1)
set advertisetext "tune in @ /sc_streamlink/"
# The text that will be displayed when stream goes online (only if announce = 1)
set onlinetext "/sc_desc/ now online @ /sc_streamlink/ with /sc_dj/ at /sc_bitrate/kbps"
# The text that will be displayed when stream goes offline (only if announce = 1)
set offlinetext "/sc_title/ now offline"
# The text that will be displayed when stream is offline and a command is used. e.g. !sc:listener
set offlinetext2 "Stream currently offline"
# The topic that will be set when stream goes online (only if announce = 1 and topicchange = 1)
set onlinetopic "/sc_title/ now online @ /sc_streamlink/ with /sc_dj/ at /sc_bitrate/kbps :: !sc:help for Bot help"
# The topic that will be set when stream goes offline (only if announce = 1 and topicchange = 1)
set offlinetopic "/sc_title/ now offline :: !sc:help for Bot help"
# The text that will be displayed when someone types !sc:info
set infotext "Stream /sc_ip/:/sc_port/ running ShoutCast v./sc_version/. The Listener Peak is /sc_serverpeak/. Stream had /sc_webhits/ Webhits and /sc_streamhits/ Streamhits."
# The text that will be displayed when someone types !sc:playing
set playingtext "Now playing: /sc_track/"
# The text that will be displayed when someone types !sc:listener
set listenertext "Stream /sc_ip/:/sc_port/ : /sc_listener/ (/sc_unique/) of /sc_max/ listeners"
# The text that will be displayed when the listener count changes (only if announcelistener = 1)
set listenerchangetext "There are now /sc_totlistener/ (/sc_totunique/) of /sc_totmax/ people listening"
# The text that will be displayed when someone types !sc:bitrate
set bitratetext "Bitrate: /sc_bitrate/"
# The text that will be displayed when the bitrate changes (only if announcebitrate = 1)
set bitratechangetext "Bitrate changed: /sc_oldbitrate/ -> /sc_bitrate/"
# The text that will be displayed when someone types !sc:peak
set peaktext "Peak: /sc_peak/"
# The text that will be displayed when the peak changes (only if announcepeak = 1)
set peakchangetext "New peak: /sc_peak/"
# The text that will be displayed when no peak is set
set nopeaktext "No peak set"
# The text that will be displayed when someone types !sc:dj
set djtext "/sc_dj/ is on the set"
# The text that will be displayed when the dj changes
set djchangetext "/sc_dj/ is now on the set"
# The text that will be displayed when no dj is set
set nodjtext "No DJ available"
# The text that will be displayed when someone types !sc:title
set titletext "Title: /sc_title/"
# The text that will be displayed when someone types !sc:genre
set genretext "Genre: /sc_genre/"
# The text that will be displayed when someone types !sc:url
set urltext "URL: /sc_url/"
# The text that will be displayed when someone types !sc:irc
set irctext "IRC: /sc_irc/"
# The text that will be displayed when someone types !sc:icq
set icqtext "ICQ: /sc_icq/"
# The text that will be displayed when someone types !sc:aim
set aimtext "AIM: /sc_aim/"
#################################################################################################
# END OF CONFIGURATION #
#################################################################################################
#################################################################################################
# START OF CODE (EDIT NOTHING UNLESS YOU KNOW WHAT YOU DO) #
#################################################################################################
set offadvert 0
bind time - "* * * * *" sc:statuscheck
bind time - "?0 * * * *" sc:streamadvertise
bind nick - * sc:djnickchange
if {$scpublic == 1} {
bind pub oD !sc:addserver sc:pub:addserver
bind pub oD !sc:delserver sc:pub:delserver
bind pub oD !sc:kicksource sc:pub:kicksource
bind pub oD !sc:settext sc:pub:settext
bind pub D !sc:setdj sc:pub:setdj
bind pub D !sc:unsetdj sc:pub:unsetdj
bind pub - !sc:listserver sc:pub:listserver
bind pub - !sc:listener sc:pub:listener
bind pub - !sc:playing sc:pub:playing
bind pub - !sc:peak sc:pub:peak
bind pub - !sc:bitrate sc:pub:bitrate
bind pub - !sc:title sc:pub:title
bind pub - !sc:genre sc:pub:genre
bind pub - !sc:url sc:pub:url
bind pub - !sc:irc sc:pub:irc
bind pub - !sc:icq sc:pub:icq
bind pub - !sc:aim sc:pub:aim
bind pub - !sc:dj sc:pub:dj
bind pub - !sc:wish sc:pub:wish
bind pub - !sc:greet sc:pub:greet
bind pub - !sc:info sc:pub:info
bind pub - !sc:help sc:pub:help
}
if {$scmessage == 1} {
bind msg - !sc:help sc:msg:help
bind msg - !sc:info sc:msg:info
bind msg - !sc:greet sc:msg:greet
bind msg - !sc:wish sc:msg:wish
bind msg - !sc:dj sc:msg:dj
bind msg - !sc:aim sc:msg:aim
bind msg - !sc:icq sc:msg:icq
bind msg - !sc:irc sc:msg:irc
bind msg - !sc:url sc:msg:url
bind msg - !sc:genre sc:msg:genre
bind msg - !sc:title sc:msg:title
bind msg - !sc:bitrate sc:msg:bitrate
bind msg - !sc:peak sc:msg:peak
bind msg - !sc:playing sc:msg:playing
bind msg - !sc:listener sc:msg:listener
bind msg - !sc:listserver sc:msg:listserver
bind msg D !sc:unsetdj sc:msg:unsetdj
bind msg D !sc:setdj sc:msg:setdj
bind msg oD !sc:settext sc:msg:settext
bind msg oD !sc:kicksource sc:msg:kicksource
bind msg oD !sc:delserver sc:msg:delserver
bind msg oD !sc:addserver sc:msg:addserver
}
proc sc:pub:addserver { nick uhost hand chan args } {
global scpubmsg
if {$scpubmsg == 0} {
sc:addserver msg $nick $args
} else {
sc:addserver pub $nick $args
}
}
proc sc:msg:addserver { nick uhost hand args } {
sc:addserver msg $nick $args
}
proc sc:pub:delserver { nick uhost hand chan args } {
global scpubmsg
if {$scpubmsg == 0} {
sc:delserver msg $nick $args
} else {
sc:delserver pub $nick $args
}
}
proc sc:msg:delserver { nick uhost hand args } {
sc:delserver msg $nick $args
}
proc sc:pub:kicksource { nick uhost hand chan args } {
global scpubmsg
if {$scpubmsg == 0} {
sc:kicksource msg $nick $args
} else {
sc:kicksource pub $nick $args
}
}
proc sc:msg:kicksource { nick uhost hand args } {
sc:kicksource msg $nick $args
}
proc sc:pub:listserver { nick uhost hand chan args } {
global scpubmsg
if {$scpubmsg == 0} {
sc:listserver msg $nick
} else {
sc:listserver pub $nick
}
}
proc sc:msg:listserver { nick uhost hand args } {
sc:listserver msg $nick
}
proc sc:pub:listener { nick uhost hand chan args } {
global scpubmsg
if {$scpubmsg == 0} {
sc:listener msg $nick
} else {
sc:listener pub $nick
}
}
proc sc:msg:listener { nick uhost hand args } {
sc:listener msg $nick
}
proc sc:pub:playing { nick uhost hand chan args } {
global scpubmsg
if {$scpubmsg == 0} {
sc:playing msg $nick
} else {
sc:playing pub $nick
}
}
proc sc:msg:playing { nick uhost hand args } {
sc:playing msg $nick
}
proc sc:pub:bitrate { nick uhost hand chan args } {
global scpubmsg
if {$scpubmsg == 0} {
sc:bitrate msg $nick
} else {
sc:bitrate pub $nick
}
}
proc sc:msg:bitrate { nick uhost hand args } {
sc:bitrate msg $nick
}
proc sc:pub:title { nick uhost hand chan args } {
global scpubmsg
if {$scpubmsg == 0} {
sc:title msg $nick
} else {
sc:title pub $nick
}
}
proc sc:msg:title { nick uhost hand args } {
sc:title msg $nick
}
proc sc:pub:genre { nick uhost hand chan args } {
global scpubmsg
if {$scpubmsg == 0} {
sc:genre msg $nick
} else {
sc:genre pub $nick
}
}
proc sc:msg:genre { nick uhost hand args } {
sc:genre msg $nick
}
proc sc:pub:url { nick uhost hand chan args } {
global scpubmsg
if {$scpubmsg == 0} {
sc:url msg $nick
} else {
sc:url pub $nick
}
}
proc sc:msg:url { nick uhost hand args } {
sc:url msg $nick
}
proc sc:pub:irc { nick uhost hand chan args } {
global scpubmsg
if {$scpubmsg == 0} {
sc:irc msg $nick
} else {
sc:irc pub $nick
}
}
proc sc:msg:irc { nick uhost hand args } {
sc:irc msg $nick
}
proc sc:pub:icq { nick uhost hand chan args } {
global scpubmsg
if {$scpubmsg == 0} {
sc:icq msg $nick
} else {
sc:icq pub $nick
}
}
proc sc:msg:icq { nick uhost hand args } {
sc:icq msg $nick
}
proc sc:pub:aim { nick uhost hand chan args } {
global scpubmsg
if {$scpubmsg == 0} {
sc:aim msg $nick
} else {
sc:aim pub $nick
}
}
proc sc:msg:aim { nick uhost hand args } {
sc:aim msg $nick
}
proc sc:pub:peak { nick uhost hand chan args } {
global scpubmsg
if {$scpubmsg == 0} {
sc:peak msg $nick
} else {
sc:peak pub $nick
}
}
proc sc:msg:peak { nick uhost hand args } {
sc:peak msg $nick
}
proc sc:pub:dj { nick uhost hand chan args } {
global scpubmsg
if {$scpubmsg == 0} {
sc:dj msg $nick
} else {
sc:dj pub $nick
}
}
proc sc:msg:dj { nick uhost hand args } {
sc:dj msg $nick
}
proc sc:pub:setdj { nick uhost hand chan args } {
global scpubmsg
if {$scpubmsg == 0} {
sc:setdj msg $nick $args
} else {
sc:setdj pub $nick $args
}
}
proc sc:msg:setdj { nick uhost hand args } {
sc:setdj msg $nick $args
}
proc sc:pub:unsetdj { nick uhost hand chan args } {
global scpubmsg
if {$scpubmsg == 0} {
sc:unsetdj msg $nick
} else {
sc:unsetdj pub $nick
}
}
proc sc:msg:unsetdj { nick uhost hand args } {
sc:unsetdj msg $nick
}
proc sc:pub:wish { nick uhost hand chan args } {
global scpubmsg
if {$scpubmsg == 0} {
sc:wish msg $nick $args
} else {
sc:wish pub $nick $args
}
}
proc sc:msg:wish { nick uhost hand args } {
sc:wish msg $nick $args
}
proc sc:pub:greet { nick uhost hand chan args } {
global scpubmsg
if {$scpubmsg == 0} {
sc:greet msg $nick $args
} else {
sc:greet pub $nick $args
}
}
proc sc:msg:greet { nick uhost hand args } {
sc:greet msg $nick $args
}
proc sc:pub:info { nick uhost hand chan args } {
global scpubmsg
if {$scpubmsg == 0} {
sc:info msg $nick
} else {
sc:info pub $nick
}
}
proc sc:msg:info { nick uhost hand args } {
sc:info msg $nick
}
proc sc:pub:help { nick uhost hand chan args } {
global scpubmsg
if {$scpubmsg == 0} {
sc:help msg $nick
} else {
sc:help pub $nick
}
}
proc sc:msg:help { nick uhost hand args } {
sc:help msg $nick
}
proc sc:pub:settext { nick uhost hand chan args } {
global scpubmsg
if {$scpubmsg == 0} {
sc:settext msg $nick $args
} else {
sc:settext pub $nick $args
}
}
proc sc:msg:settext { nick uhost hand args } {
sc:settext msg $nick $args
}
proc sc:post { counter mode target intext } {
global streamfile peakfile djfile radiofile offlinetext2 offadvert streamlink
set temp [open $radiofile r]
gets $temp data
set status [lindex $data 0]
close $temp
set count 0
set totlist 0
set totunique 0
set totmax 0
if {[file exists $radiofile] == 1} {
set temp [open $radiofile r]
while { $count < $counter } {
gets $temp data
incr totlist [lindex $data 1]
incr totunique [lindex $data 3]
incr totmax [lindex $data 5]
incr count
}
close $temp
set count 0
}
if {[file exists $peakfile] == 1} {
set temp [open $peakfile r]
gets $temp peak
close $temp
}
if {[file exists $djfile] == 1} {
set temp [open $djfile r]
gets $temp dj
set djname [lindex $dj 1]
close $temp
}
if {[file exists $djfile] == 0} {
set djname "No DJ"
}
if {[file exists $streamfile] == 1} {
set temp [open $streamfile r]
set old [read $temp]
close $temp
}
if {($status == 1) || ($offadvert == 1)} {
if {[file exists $radiofile] == 1} {
set temp [open $radiofile r]
while { $count < $counter } {
set streamip [lindex [lindex $old $count] 0]
set streamport [lindex [lindex $old $count] 1]
set streamdesc [lrange [lindex $old $count] 4 end]
set text $intext
gets $temp data
regsub -all "/sc_streamlink/" $text "$streamlink" text
regsub -all "/sc_totlistener/" $text "$totlist" text
regsub -all "/sc_totunique/" $text "$totunique" text
regsub -all "/sc_totmax/" $text "$totmax" text
regsub -all "/sc_desc/" $text "$streamdesc" text
regsub -all "/sc_port/" $text "$streamport" text
regsub -all "/sc_ip/" $text "$streamip" text
regsub -all "/sc_dj/" $text "$djname" text
regsub -all "/sc_peak/" $text "$peak" text
regsub -all "/sc_listener/" $text "[lindex $data 1]" text
regsub -all "/sc_serverpeak/" $text "[lindex $data 2]" text
regsub -all "/sc_unique/" $text "[lindex $data 3]" text
regsub -all "/sc_url/" $text "[lindex $data 4]" text
regsub -all "/sc_max/" $text "[lindex $data 5]" text
regsub -all "/sc_bitrate/" $text "[lindex $data 6]" text
regsub -all "/sc_title/" $text "[lindex $data 7]" text
regsub -all "/sc_genre/" $text "[lindex $data 8]" text
regsub -all "/sc_avgtime/" $text "[lindex $data 9]" text
regsub -all "/sc_irc/" $text "[lindex $data 10]" text
regsub -all "/sc_icq/" $text "[lindex $data 11]" text
regsub -all "/sc_aim/" $text "[lindex $data 12]" text
regsub -all "/sc_webhits/" $text "[lindex $data 13]" text
regsub -all "/sc_streamhits/" $text "[lindex $data 14]" text
regsub -all "/sc_version/" $text "[lindex $data 15]" text
regsub -all "/sc_track/" $text "[lindex $data 16]" text
regsub -all "/sc_songurl/" $text "[lindex $data 17]" text
puthelp "$mode $target :$text"
incr count
}
close $temp
}
} else {
if {[file exists $radiofile] == 1} {
set temp [open $radiofile r]
while { $count < $counter } {
set streamip [lindex [lindex $old $count] 0]
set streamport [lindex [lindex $old $count] 1]
set streamdesc [lrange [lindex $old $count] 4 end]
set text $offlinetext2
gets $temp data
regsub -all "/sc_streamlink/" $text "$streamlink" text
regsub -all "/sc_totlistener/" $text "$totlist" text
regsub -all "/sc_totunique/" $text "$totunique" text
regsub -all "/sc_totmax/" $text "$totmax" text
regsub -all "/sc_desc/" $text "$streamdesc" text
regsub -all "/sc_port/" $text "$streamport" text
regsub -all "/sc_ip/" $text "$streamip" text
regsub -all "/sc_dj/" $text "$djname" text
regsub -all "/sc_peak/" $text "$peak" text
regsub -all "/sc_listener/" $text "[lindex $data 1]" text
regsub -all "/sc_serverpeak/" $text "[lindex $data 2]" text
regsub -all "/sc_unique/" $text "[lindex $data 3]" text
regsub -all "/sc_url/" $text "[lindex $data 4]" text
regsub -all "/sc_max/" $text "[lindex $data 5]" text
regsub -all "/sc_bitrate/" $text "[lindex $data 6]" text
regsub -all "/sc_title/" $text "[lindex $data 7]" text
regsub -all "/sc_genre/" $text "[lindex $data 8]" text
regsub -all "/sc_avgtime/" $text "[lindex $data 9]" text
regsub -all "/sc_irc/" $text "[lindex $data 10]" text
regsub -all "/sc_icq/" $text "[lindex $data 11]" text
regsub -all "/sc_aim/" $text "[lindex $data 12]" text
regsub -all "/sc_webhits/" $text "[lindex $data 13]" text
regsub -all "/sc_streamhits/" $text "[lindex $data 14]" text
regsub -all "/sc_version/" $text "[lindex $data 15]" text
regsub -all "/sc_track/" $text "[lindex $data 16]" text
regsub -all "/sc_songurl/" $text "[lindex $data 17]" text
incr count
}
close $temp
}
puthelp "privmsg $target :$text"
}
set offadvert 0
}
proc sc:shrink { calc number string start bl } {
return [expr [string first "$string" $bl $start] $calc $number]
}
proc sc:streamadvertise { nick uhost hand chan arg } {
global radiochan advertisetext announce radiofile
set temp [open $radiofile r]
gets $temp data
close $temp
if {($announce == 1) && ([lindex $data 0] == 1)} {
sc:post 1 privmsg $radiochan $advertisetext
}
}
proc sc:djnickchange { oldnick uhost hand chan newnick } {
global radiochan djfile
set temp [open $djfile r]
gets $temp dj
close $temp
set djname [lindex $dj 1]
set nickname [lindex $dj 0]
if {$nickname == $oldnick} {
set temp [open $djfile w+]
puts $temp "$newnick $djname"
close $temp
}
}
proc sc:kicksource { type nickname count } {
global streamfile
if {($count == "{}")} {
sc:post 1 privmsg $nickname "!kicksource <number>"
} else {
set temp [open $streamfile r]
set old [read $temp]
close $temp
set counter [expr $count -1]
set streamip [lindex [lindex $old $counter] 0]
set streamport [lindex [lindex $old $counter] 1]
set login "[lindex [lindex $old $counter] 3]"
putlog "$streamip $streamport $login"
set sock [socket $streamip $streamport]
puts $sock "GET /admin.cgi?mode=kicksrc HTTP/1.1"
puts $sock "User-Agent:Mozilla"
puts $sock "Host: $streamip"
puts $sock "Authorization: Basic $login"
puts $sock ""
flush $sock
sc:post 1 privmsg $nickname "Source kicked from $streamip:$streamport"
}
}
proc sc:settext { type nickname data } {
global radiochan streamfile advertisetext onlinetext offlinetext offlinetext2 onlinetopic offlinetopic infotext playingtext listenertext listenerchangetext bitratetext bitratechangetext peaktext peakchangetext nopeaktext djtext djchangetext nodjtext titletext genretext urltext irctext icqtext aimtext
if {($data == "{}")} {
puthelp "privmsg $nickname :!settext <texttype> <text>"
puthelp "privmsg $nickname :Texttypes: advertisetext onlinetext offlinetext offlinetext2 onlinetopic offlinetopic infotext playingtext listenertext listenerchangetext bitratetext"
puthelp "privmsg $nickname :Texttypes: bitratechangetext peaktext peakchangetext nopeaktext djtext djchangetext nodjtext titletext genretext urltext irctext icqtext aimtext"
puthelp "privmsg $nickname :Variables: /sc_streamlink/ /sc_port/ /sc_ip/ /sc_desc/ /sc_dj/ /sc_peak/ /sc_listener/ /sc_totlistener/ /sc_serverpeak/ /sc_unique/ /sc_totunique/ /sc_url/ /sc_max/ /sc_totmax/ /sc_bitrate/ /sc_title/ /sc_genre/"
puthelp "privmsg $nickname :Variables: /sc_avgtime/ /sc_irc/ /sc_icq/ /sc_aim/ /sc_webhits/ /sc_streamhits/ /sc_version/ /sc_track/ /sc_songurl/ /sc_oldbitrate/ (works only in bitratechangetext)"
} else {
set text [lindex [lindex $data 0] 0]
set texttype [lrange [lindex $data 0] 1 end]
set [lindex [lindex $data 0] 0] "$texttype"
puthelp "privmsg $nickname :Set $text to $texttype"
}
}
proc sc:addserver { type nickname data } {
global radiochan streamfile
if {[file exists $streamfile] == 0} {
set temp [open $streamfile a+]
close $temp
}
if {($data == "{}")} {
sc:post 1 privmsg $nickname "!addserver <ip> <port> <pass> <adminpass> <description>"
} else {
set temp [open $streamfile r]
set old [read $temp]
close $temp
set temp [open $streamfile w+]
puts $temp "[lrange $old 0 end] $data"
close $temp
set streamip [lindex [lindex $data 0] 0]
set streamport [lindex [lindex $data 0] 1]
sc:post 1 privmsg $nickname "Server $streamip:$streamport succesfully added"
}
}
proc sc:delserver { type nickname server } {
global radiochan streamfile
global radiochan streamfile
if {[file exists $streamfile] == 0} {
sc:post 1 privmsg $nickname "Noch keine Server hinzugefügt"
}
set servera [expr $server - 1]
if {$server == ""} {
sc:post 1 privmsg $nickname "!delserver <number>"
} else {
set temp [open $streamfile r]
set old [read $temp]
close $temp
set new [lreplace $old $servera $servera]
set temp [open $streamfile w+]
puts $temp [lrange $new 0 end]
close $temp
set streamip [lindex [lindex $old $servera] 0]
set streamport [lindex [lindex $old $servera] 1]
if {$type == "msg"} {
sc:post 1 privmsg $nickname "Server $streamip:$streamport succesfully deleted"
}
if {$type == "pub"} {
sc:post 1 privmsg $radiochan "Server $streamip:$streamport succesfully deleted"
}
}
}
proc sc:listserver { type nickname } {
global radiochan streamfile
if {[file exists $streamfile] == 0} {
sc:post 1 privmsg $nickname "Noch keine Server hinzugefügt"
}
set temp [open $streamfile r]
set old [read $temp]
close $temp
set count 0
while { $count < [llength $old] } {
set streamip [lindex [lindex $old $count] 0]
set streamport [lindex [lindex $old $count] 1]
if {$type == "msg"} {
sc:post 1 privmsg $nickname "Server #[expr $count + 1] $streamip:$streamport"
}
if {$type == "pub"} {
sc:post 1 privmsg $radiochan "Server #[expr $count + 1] $streamip:$streamport"
}
incr count
}
}
proc sc:listener { type nickname } {
global radiochan streamfile listenertext
set temp [open $streamfile r]
set old [read $temp]
close $temp
if {$type == "msg"} {
sc:post [llength $old] privmsg $nickname "$listenertext"
}
if {$type == "pub"} {
sc:post [llength $old] privmsg $radiochan "$listenertext"
}
}
proc sc:info { type nickname } {
global radiochan streamfile infotext
set temp [open $streamfile r]
set old [read $temp]
close $temp
if {$type == "msg"} {
sc:post [llength $old] privmsg $nickname "$infotext"
}
if {$type == "pub"} {
sc:post [llength $old] privmsg $radiochan "$infotext"
}
}
proc sc:playing { type nickname } {
global radiochan playingtext
if {$type == "msg"} {
sc:post 1 privmsg $nickname "$playingtext"
}
if {$type == "pub"} {
sc:post 1 privmsg $radiochan "$playingtext"
}
}
proc sc:bitrate { type nickname } {
global radiochan bitratetext
if {$type == "msg"} {
sc:post 1 privmsg $nickname "$bitratetext"
}
if {$type == "pub"} {
sc:post 1 privmsg $radiochan "$bitratetext"
}
}
proc sc:title { type nickname } {
global radiochan titletext
if {$type == "msg"} {
sc:post 1 privmsg $nickname "$titletext"
}
if {$type == "pub"} {
sc:post 1 privmsg $radiochan "$titletext"
}
}
proc sc:genre { type nickname } {
global radiochan genretext
if {$type == "msg"} {
sc:post 1 privmsg $nickname "$genretext"
}
if {$type == "pub"} {
sc:post 1 privmsg $radiochan "$genretext"
}
}
proc sc:url { type nickname } {
global radiochan urltext
if {$type == "msg"} {
sc:post 1 privmsg $nickname "$urltext"
}
if {$type == "pub"} {
sc:post 1 privmsg $radiochan "$urltext"
}
}
proc sc:irc { type nickname } {
global radiochan irctext
if {$type == "msg"} {
sc:post 1 privmsg $nickname "$irctext"
}
if {$type == "pub"} {
sc:post 1 privmsg $radiochan "$irctext"
}
}
proc sc:icq { type nickname } {
global radiochan icqtext
if {$type == "msg"} {
sc:post 1 privmsg $nickname "$icqtext"
}
if {$type == "pub"} {
sc:post 1 privmsg $radiochan "$icqtext"
}
}
proc sc:aim { type nickname } {
global radiochan aimtext
if {$type == "msg"} {
sc:post 1 privmsg $nickname "$aimtext"
}
if {$type == "pub"} {
sc:post 1 privmsg $radiochan "$aimtext"
}
}
proc sc:peak { type nickname } {
global radiochan peakfile nopeaktext peaktext
if {[file exists $peakfile] == 0} {
if {$type == "msg"} {
sc:post 1 privmsg $nickname "$nopeaktext"
}
if {$type == "pub"} {
sc:post 1 privmsg $radiochan "$nopeaktext"
}
} else {
if {$type == "msg"} {
sc:post 1 privmsg $nickname "$peaktext"
}
if {$type == "pub"} {
sc:post 1 privmsg $radiochan "$peaktext"
}
}
}
proc sc:dj { type nickname } {
global radiochan djfile nodjtext djtext
if {[file exists $djfile] == 0} {
if {$type == "msg"} {
sc:post 1 privmsg $nickname "$nodjtext"
}
if {$type == "pub"} {
sc:post 1 privmsg $radiochan "$nodjtext"
}
} else {
set temp [open $djfile r]
gets $temp dj
close $temp
if {$dj == ""} {
if {$type == "msg"} {
sc:post 1 privmsg $nickname "$nodjtext"
}
if {$type == "pub"} {
sc:post 1 privmsg $radiochan "$nodjtext"
}
} else {
if {$type == "msg"} {
sc:post 1 privmsg $nickname "$djtext"
}
if {$type == "pub"} {
sc:post 1 privmsg $radiochan "$djtext"
}
}
}
}
proc sc:unsetdj { type nickname } {
global radiochan djfile
if {[file exists $djfile] == 0} {
if {$type == "msg"} {
sc:post 1 privmsg $nickname "No DJ set"
}
if {$type == "pub"} {
sc:post 1 privmsg $radiochan "No DJ set"
}
} else {
set temp [open $djfile w+]
close $temp
if {$type == "msg"} {
sc:post 1 privmsg $nickname "DJ unset"
}
if {$type == "pub"} {
sc:post 1 privmsg $radiochan "DJ unset"
}
}
}
proc sc:setdj { type nickname djname } {
global radiochan djfile djchangetext onlinetopic topicchange
set temp [open $djfile w+]
if {$djname == "{}"} {
set djname $nickname
}
puts $temp "$nickname $djname"
close $temp
sc:post 1 privmsg $radiochan "$djchangetext"
if {$topicchange == 1} {
sc:post 1 topic $radiochan "$onlinetopic"
}
sc:post 1 privmsg $nickname "New DJ $djname"
}
proc sc:wish { type nickname wish } {
global radiochan djfile
if {[file exists $djfile] == 0} {
sc:post 1 privmsg $nickname "No DJ set"
} else {
set temp [open $djfile r]
gets $temp dj
close $temp
if {$dj == ""} {
sc:post 1 privmsg $nickname "No DJ set"
} else {
sc:post 1 privmsg [lindex $dj 0] "Wish by $nickname : $wish"
sc:post 1 privmsg $nickname "Wish has been sent"
}
}
}
proc sc:greet { type nickname wish } {
global radiochan djfile
if {[file exists $djfile] == 0} {
sc:post 1 privmsg $nickname "No DJ set"
} else {
set temp [open $djfile r]
gets $temp dj
close $temp
if {$dj == ""} {
sc:post 1 privmsg $nickname "No DJ set"
} else {
sc:post 1 privmsg [lindex $dj 0] "Greet by $nickname : $wish"
sc:post 1 privmsg $nickname "Greet has been sent"
}
}
}
proc sc:help { type nickname } {
puthelp "privmsg $nickname :Admin Commands: !sc:addserver !sc:delserver !sc:kicksource !sc:setdj !sc:unsetdj !sc:settext"
puthelp "privmsg $nickname :Stream Commands: !sc:listserver !sc:dj !sc:listener !sc:playing !sc:peak !sc:bitrate"
puthelp "privmsg $nickname :Stream Commands: !sc:title !sc:genre !sc:url !sc:irc !sc:icq !sc:aim"
puthelp "privmsg $nickname :Stream Commands: !sc:info !sc:wish !sc:greet"
}
proc sc:statuscheck { nick uhost hand chan arg } {
global offadvert radiochan streamfile radiofile djfile peakfile streamlink onlinetext offlinetext bitratechangetext playingtext listenerchangetext peakchangetext announce announcebitrate announcepeak announcetrack announcelistener topicchange offlinetopic onlinetopic
putlog "checking shoutcast servers"
set temp [open $streamfile r]
set old [read $temp]
close $temp
set listener1 0
set listener2 0
if {[file exists $radiofile] == 1} {
set temp [open $radiofile r]
set count 0
set listener 0
while {$count < [llength $old]} {
gets $temp data
if {$data != ""} {
set oldbitrate [lindex $data 6]
set oldtrack [lindex $data 16]
set oldstatus [lindex $data 0]
incr listener [lindex $data 1]
} else {
if {$count == 0} {
set oldbitrate 0
set oldtrack 0
set listener 0
set oldstatus 0
}
}
incr count
}
close $temp
} else {
set oldbitrate 0
set oldtrack 0
set listener 0
set oldstatus 0
}
set oldlistener $listener
set count 0
set temp [open $radiofile w+]
while { $count < [llength $old] } {
set streamip [lindex [lindex $old $count] 0]
set streamport [lindex [lindex $old $count] 1]
set streampass [lindex [lindex $old $count] 2]
if {[catch {set sock [socket $streamip $streamport] } sockerror]} {
putlog "error: $sockerror"
return 0} else {
puts $sock "GET /admin.cgi?pass=$streampass&mode=viewxml&page=0 HTTP/1.0"
puts $sock "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.9)"
puts $sock "Host: $streamip"
puts $sock "Connection: close"
puts $sock ""
flush $sock
while {[eof $sock] != 1} {
set bl [gets $sock]
if { [string first "standalone" $bl] != -1 } {
set streamstatus [string range $bl [sc:shrink + 14 "<STREAMSTATUS>" 0 $bl] [sc:shrink - 1 "</STREAMSTATUS>" 0 $bl]]
set repl1 [string range $bl [sc:shrink + 19 "<REPORTEDLISTENERS>" 0 $bl] [sc:shrink - 1 "</REPORTEDLISTENERS>" 0 $bl]]
set curhigh1 [string range $bl [sc:shrink + 15 "<PEAKLISTENERS>" 0 $bl] [sc:shrink - 1 "</PEAKLISTENERS>" 0 $bl]]
set currentl [string range $bl [sc:shrink + 18 "<CURRENTLISTENERS>" 0 $bl] [sc:shrink - 1 "</CURRENTLISTENERS>" 0 $bl]]
set surl [string range $bl [sc:shrink + 11 "<SERVERURL>" 0 $bl] [sc:shrink - 1 "</SERVERURL>" 0 $bl]]
set maxl1 [string range $bl [sc:shrink + 14 "<MAXLISTENERS>" 0 $bl] [sc:shrink - 1 "</MAXLISTENERS>" 0 $bl]]
set bitrate [string range $bl [sc:shrink + 9 "<BITRATE>" 0 $bl] [sc:shrink - 1 "</BITRATE>" 0 $bl]]
set stitle [string range $bl [sc:shrink + 13 "<SERVERTITLE>" 0 $bl] [sc:shrink - 1 "</SERVERTITLE>" 0 $bl]]
set sgenre [string range $bl [sc:shrink + 13 "<SERVERGENRE>" 0 $bl] [sc:shrink - 1 "</SERVERGENRE>" 0 $bl]]
if {$sgenre != ""} {set sgenre " ($sgenre)"}
set avgtime1 [string range $bl [sc:shrink + 13 "<AVERAGETIME>" 0 $bl] [sc:shrink - 1 "</AVERAGETIME>" 0 $bl]]
set irc [string range $bl [sc:shrink + 5 "<IRC>" 0 $bl] [sc:shrink - 1 "</IRC>" 0 $bl]]
if {$irc == 0} { set irc "N/A" }
set icq [string range $bl [sc:shrink + 5 "<ICQ>" 0 $bl] [sc:shrink - 1 "</ICQ>" 0 $bl]]
if {$icq == 0} { set icq "N/A" }
set aim [string range $bl [sc:shrink + 5 "<AIM>" 0 $bl] [sc:shrink - 1 "</AIM>" 0 $bl]]
if {$aim == 0} { set aim "N/A" }
set webhits1 [string range $bl [sc:shrink + 9 "<WEBHITS>" 0 $bl] [sc:shrink - 1 "</WEBHITS>" 0 $bl]]
set streamhits1 [string range $bl [sc:shrink + 12 "<STREAMHITS>" 0 $bl] [sc:shrink - 1 "</STREAMHITS>" 0 $bl]]
set version [string range $bl [sc:shrink + 9 "<VERSION>" 0 $bl] [sc:shrink - 1 "</VERSION>" 0 $bl]]
set cursong [string range $bl [sc:shrink + 11 "<SONGTITLE" 0 $bl] [sc:shrink - 1 "</SONGTITLE>" 0 $bl]]
set songurl [string range $bl [sc:shrink + 9 "<SONGURL>" 0 $bl] [sc:shrink - 1 "</SONGURL>" 0 $bl]]
regsub -all "<" $cursong "<" cursong
regsub -all ">" $cursong ">" cursong
regsub -all "&" $cursong "+" cursong
regsub -all """ $cursong "\"" cursong
regsub -all "'" $cursong "'" cursong
regsub -all "ÿ" $cursong "" cursong
regsub -all "´" $cursong "´" cursong
regsub -all "–" $cursong "-" cursong
regsub -all "ö" $cursong "ö" cursong
regsub -all "ä" $cursong "ä" cursong
regsub -all "ü" $cursong "ü" cursong
regsub -all "Ö" $cursong "Ö" cursong
regsub -all "Ä" $cursong "Ä" cursong
regsub -all "Ü" $cursong "Ü" cursong
regsub -all "ß" $cursong "ß" cursong
set data {}
lappend data $streamstatus
lappend data $repl1
lappend data $curhigh1
lappend data $currentl
lappend data $surl
lappend data $maxl1
lappend data $bitrate
lappend data $stitle
lappend data $sgenre
lappend data $avgtime1
lappend data $irc
lappend data $icq
lappend data $aim
lappend data $webhits1
lappend data $streamhits1
lappend data $version
lappend data $cursong
lappend data $songurl
incr listener1 $repl1
incr listener2 $currentl
puts $temp $data
}
}
close $sock
}
incr count
}
close $temp
if {($oldstatus != $streamstatus) && ($announce == 1)} {
if {$streamstatus == 1} {
sc:post 1 privmsg $radiochan "$onlinetext"
if {$topicchange == 1} {
sc:post 1 topic $radiochan "$onlinetopic"
}
} else {
set offadvert 1
sc:post 1 privmsg $radiochan "$offlinetext"
if {$topicchange == 1} {
set offadvert 1
sc:post 1 topic $radiochan "$offlinetopic"
}
}
}
if {($oldbitrate != $bitrate) && ($announcebitrate == 1) && ($streamstatus == 1)} {
regsub -all "/sc_oldbitrate/" $bitratechangetext "$oldbitrate" bitratechangetext1
sc:post 1 privmsg $radiochan "$bitratechangetext1"
}
if {($oldtrack != $cursong) && ($announcetrack == 1) && ($streamstatus == 1)} {
sc:post 1 privmsg $radiochan "$playingtext"
}
if {($oldlistener != $listener1) && ($announcelistener == 1) && ($streamstatus == 1)} {
sc:post [llength $old] privmsg $radiochan "$listenerchangetext"
}
if {($announcepeak == 1) && ($streamstatus == 1)} {
if {[file exists $peakfile] == 0} {
set temp [open $peakfile w+]
puts $temp $listener1
close $temp
sc:post 1 privmsg $radiochan "$peakchangetext"
} else {
set temp [open $peakfile r]
gets $temp data
close $temp
if {$listener1 > $data} {
set temp [open $peakfile w+]
puts $temp $listener1
close $temp
sc:post 1 privmsg $radiochan "$peakchangetext"
}
}
}
}
putlog "LoReZ-ShouTCasT-Script v1.0 successfully initialized"
#################################################################################################
# END OF CODE #
#################################################################################################
IRC Snippets