Code: Select all
if {($chan != $radiochans) || ($chan != $adminchans)}{
Code: Select all
if {($chan != $radiochans) || ($chan != $adminchans)} {
Code: Select all
set allowedchans "#chan #chan.admin"
bind * !stats stats_run
proc stats_run {nick uhost hand chan rest} {
global streamip streamport streampass allowedchans
if {(([lsearch -exact [string tolower $allowedchans] [string tolower $chan]] != -1)||($allowedchans == "*"))} {
if {[catch {set sock [socket $streamip $streamport] } sockerror]} {
putlog "error: $sockerror"
return 0
} else {
blabla....
Code: Select all
--- Code Cut ---
Code: Select all
proc shrink { calc number string start bl} { return [expr [string first "$string" $bl $start] $calc $number] }
Code: Select all
set allowedchans "#linod"
set streamip ""
set streamport "9000"
set streampass ""
bind pub * !stats stats_run
# Basic Edit Functions
proc shrink { calc number string start bl} { return [expr [string first "$string" $bl $start] $calc $number] }
#Command Functions
proc stats_run {nick uhost hand chan rest} {
global streamip streamport streampass allowedchans
if {(([lsearch -exact [string tolower $allowedchans] [string tolower $chan]] != -1)||($allowedchans == "*"))} {
if {[catch {set sock [socket $streamip $streamport] } sockerror]} {
putlog "error: $sockerror"
return 0
} else {
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
putlog "debug 01 $chan"
while {[eof $sock] != 1} {
set bl [gets $sock]
if { [string first "standalone" $bl] != -1 } {
set streamstatus [string range $bl [shrink + 14 "<STREAMSTATUS>" 0 $bl] [shrink - 1 "</STREAMSTATUS>" 0 $bl]]
}
}
close $sock
}
if { $streamstatus == "1" } {
putlog "shoutcast: $nick asked for serverstats from $chan"
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
putlog "debug 02 $chan"
while {[eof $sock] != 1} {
putlog "debug 03 $chan"
set bl [gets $sock]
putlog "debug 04 $chan"
if { [string first "standalone" $bl] != -1 } {
putlog "Generating info"
set streamstatus [string range $bl [shrink + 14 "<STREAMSTATUS>" 0 $bl] [shrink - 1 "</STREAMSTATUS>" 0 $bl]]
set repl [string range $bl [shrink + 19 "<REPORTEDLISTENERS>" 0 $bl] [shrink - 1 "</REPORTEDLISTENERS>" 0 $bl]]
set curhigh [string range $bl [shrink + 15 "<PEAKLISTENERS>" 0 $bl] [shrink - 1 "</PEAKLISTENERS>" 0 $bl]]
set currentl [string range $bl [shrink + 18 "<CURRENTLISTENERS>" 0 $bl] [shrink - 1 "</CURRENTLISTENERS>" 0 $bl]]
set surl [string range $bl [shrink + 11 "<SERVERURL>" 0 $bl] [shrink - 1 "</SERVERURL>" 0 $bl]]
set maxl [string range $bl [shrink + 14 "<MAXLISTENERS>" 0 $bl] [shrink - 1 "</MAXLISTENERS>" 0 $bl]]
set bitrate [string range $bl [shrink + 9 "<BITRATE>" 0 $bl] [shrink - 1 "</BITRATE>" 0 $bl]]
set stitle [string range $bl [shrink + 13 "<SERVERTITLE>" 0 $bl] [shrink - 1 "</SERVERTITLE>" 0 $bl]]
set sgenre [string range $bl [shrink + 13 "<SERVERGENRE>" 0 $bl] [shrink - 1 "</SERVERGENRE>" 0 $bl]]
if {$sgenre != ""} {set sgenre " ($sgenre)"}
set avgtime [string range $bl [shrink + 13 "<AVERAGETIME>" 0 $bl] [shrink - 1 "</AVERAGETIME>" 0 $bl]]
set irc [string range $bl [shrink + 5 "<IRC>" 0 $bl] [shrink - 1 "</IRC>" 0 $bl]]
set webhits [string range $bl [shrink + 9 "<WEBHITS>" 0 $bl] [shrink - 1 "</WEBHITS>" 0 $bl]]
set streamhits [string range $bl [shrink + 12 "<STREAMHITS>" 0 $bl] [shrink - 1 "</STREAMHITS>" 0 $bl]]
set version [string range $bl [shrink + 9 "<VERSION>" 0 $bl] [shrink - 1 "</VERSION>" 0 $bl]]
}
close $sock
}
}
putchan $chan "$stitle$sgenre is online, running shoutcast $version and streaming at $bitrate kbps, your dj is $dj. please visit $surl"
putchan $chan "$stitle$sgenre is online, running shoutcast $version and streaming at $bitrate kbps, your dj is $dj. please visit $surl"
putchan $chan "there are currently $repl unique people listening, the listener maximum is $maxl, our user peak was at $curhigh listeners."
putchan $chan "the average user is listening $avgtime seconds, our stream had $webhits webhits and $streamhits streamhits."
putchan $chan "you can contact the team by irc on $irc"
} else {
return 0
}
}
}
}