<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
	<link rel="self" type="application/atom+xml" href="https://forum.eggheads.org/app.php/feed/topic/21120" />

	<title>egghelp/eggheads community</title>
	<subtitle>Discussion of eggdrop bots, shell accounts and tcl scripts.</subtitle>
	<link href="https://forum.eggheads.org/index.php" />
	<updated>2022-03-05T20:22:54-04:00</updated>

	<author><name><![CDATA[egghelp/eggheads community]]></name></author>
	<id>https://forum.eggheads.org/app.php/feed/topic/21120</id>

		<entry>
		<author><name><![CDATA[roughnecks]]></name></author>
		<updated>2022-03-05T20:22:54-04:00</updated>

		<published>2022-03-05T20:22:54-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=110967#p110967</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=110967#p110967"/>
		<title type="html"><![CDATA[A parser/reporter script for icecast2 servers: need fixing]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=110967#p110967"><![CDATA[
Hello,<br><br>this is the script I'm talking about:<br><br>######################################################################<br>#What is this:<br>#Ice2.tcl is a parser/reporter script for Icecast2 internet radio stations. It's slightly similar to Domsen's<br># shoutcast1.03.tcl script except this is for Icecast2 servers and not Shoutcast servers. It tells members of<br># a room if the stream is online, what artist-song it is playing, how many listeners there are, what the<br># stream url is, and various other tidbits.<br>#<br>#Ice2.tcl was origionally created by Tido to work with The Jedi Academy's (<a href="http://www.thejediacademy.net" class="postlink">www.thejediacademy.net</a>) Icecast2 server.<br># It has now been adapted by Sircrazy to work with any Icecast2 Version 2.3.2 with (linux/freebsd) with Ogg Vorbis <br># and MP3 encoding.It is completely dependent on the output of Icecast2's status.xsl, so if that is changed the script<br># will not work.<br><br>------------------------------------------------------------------------------------<br><br>New Icecast is version 2.4.4, while the script supports 2.3.2<br>I believe the parser is not working anymore, because I have setup the script, also adding the mount point as specified, but the bot always says stream's offline (while I'm listening to it).<br><br>This is the script download URL: <a href="https://www.tclarchive.org/download.php?id=1667" class="postlink">https://www.tclarchive.org/download.php?id=1667</a><br><br>I'll paste it down here too, not sure if it's ok tho..<br><br><div class="codebox"><p>Code: </p><pre><code>#Tido's Modified Icecast2 Script#Heavily Modified by Sircrazy#Version 1.01#July 12, 2010#######################################################################This program is free software; you can redistribute it and/or modify#it under the terms of the GNU General Public License as published by#the Free Software Foundation; version 2 of the License.##This program is distributed in the hope that it will be useful,#but WITHOUT ANY WARRANTY; without even the implied warranty of#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the#GNU General Public License for more details.#######################################################################Credits:#Influenced by Domsen's shoutcast1.03.tcl#Special thanks to the TCL MAN files :D#Special Release updated by Sircrazy#######################################################################Change these varibles to the one for your stream/bot/channel#Name of Radio Stationset streamname "EDIT THIS"#IP of the Icecast server.set streamip "MAKE SURE IT IS THE IP"#Port that Icecast is using, default is 8000.set streamport "EDIT THIS"#Main channel for the radio bot.set radiochan "#EDIT THIS"#Other channel that the bot can advertise to. Bot must be in this channel for this to work. Ice2.tcl only# sends stream advertisements to this channel and does not send song info.set otherchan "EDIT THIS OR REMOVE THIS TEXT"#URL/Link to the stream for listening. This is what listeners need to click to tune in.set streamurl "http://ssh.shellium.org/~sircrazy/sircrazy.m3u"#How often the bot checks the stream when it knows it is down in minutes. Recommend 1 minute.set offlinetimer "1"#How often the bot checks the stream when it knows it is online in seconds. Recommend 15 seconds.set onlinetimer "15"#Default interval for how often the bot advertises (in minutes). You want to set it to something that isn't# pure spammage.set adtimer "30"#Enables advertising set to the above frequency. 1 for ON and 0 for OFF. This reminds people that the stream# is online.set enableadvertise "1"#Enables Special Announcement, 1 for ON and 0 for OFF. Special announcements are displayed every 720 minutes.# This feature of the script is very undeveloped and I don't recommend using it.set specialannounce "0"#Special Announcement Messageset announcemsg "SPECIAL ANNOUNCEMENT! On Novemeber 26th @ Midnight GMT, JA Radio will be ON-AIR with a show featuring some exclusive live tracks from some of our favorite bands! Click here for more info: http://www.thejediacademy.net/forums_detail_page.php?f_id=13532"############################################################################  Don't edit past this stuff unless you're Tido, Henkes, or Sircrazy :P  ##       Except Line 387 where you need to add DJs and Line 281 where      ##                    you need to put your mount point.                    ############################################################################# Bindsbind pub - "%commands" showcommands#Shows a list of all commandsbind pub - "%help" showcommands#same as %commandsbind pub - "%status" status#Displays the status of the streambind pub - "%listeners" listenercheck#Reports how many listeners there arebind pub - "%request" request#Allows users to request songsbind msg - "request" request_pm#Allows users to make requests via pmbind msg - "djon" dj_on#turns on dj statusbind pub - "%djoff" dj_off#turns off dj statusbind msg - "djoff" dj_off_pm#turns off dj statusbind pub - "%fadvert" forceadvertise#Forces an advertising message to be sentbind pub - "%version" iceversion#Displays the Ice2.tcl version# Varible Resetsset ice2version "1.01 - 07.12.10"set streamstatus "0"set djnickname ""set dj ""set oldsong ""set newsong ""set newlistener ""set oldlistener "0"set forceadsent "0"set sessionpeak "0"# Check to make sure StatusCheck timer isn't running when bot rehashes.if {![info exists statuscheck_running]} {  timer $offlinetimer [list statuscheck]  set statuscheck_running 1}# Check to make sure Special Announce timer isn't running when bot rehashes.if {![info exists specialannounce_running]} {  if {$specialannounce == "1"} {    timer 720 [list specialmessage]    set specialannounce_running 1  }}# Check to make sure Advertise timer isn't running when bot rehashes.if {![info exists adtimer_running]} {  if {$enableadvertise == "1"} {    timer $adtimer [list advertise]    set adtimer_running 1  }}# Output for %help or %commandsproc showcommands {nick uhost hand chan arg} {  global ice2version streamname botnick dj  if {$dj == "$nick" &amp;&amp; $arg != ""} {    putserv "notice $arg :&gt;&gt;&gt; $botnick Commands - $ice2version&lt;&lt;&lt;"    putserv "notice $arg :%status &gt;&gt;&gt; Displays the stream's status. If online it shows the song."    putserv "notice $arg :%request (artist+track) &gt;&gt;&gt; Sends a Request for a future song."    putserv "notice $arg :/msg $botnick request (artist+track) &gt;&gt;&gt; Sends a Request for a future song by PM."  }  if {$dj != "$nick"} {    set arg ""    putserv "notice $nick :&gt;&gt;&gt; $botnick Commands - $ice2version&lt;&lt;&lt;"    putserv "notice $nick :%status &gt;&gt;&gt; Displays the stream's status. If online it shows the song."    putserv "notice $nick :%request (artist+track) &gt;&gt;&gt; Sends a Request for a future song."    putserv "notice $nick :/msg $botnick request (artist+track) &gt;&gt;&gt; Sends a Request for a future song by PM."  }}# Turns on and off Advertising. Also lets you set the interval: !advertise Xproc toggle_advertise {nick uhost hand chan arg} {  global radiochan enableadvertise adtimer  if {$enableadvertise == "1"} {    set enableadvertise "0"    set timerinfo [gettimerid]    killtimer $timerinfo    putserv "PRIVMSG $chan :Advertising OFF"  } else {    set enableadvertise "1"    if {$arg == ""} {      putserv "PRIVMSG $chan :Advertising ON. Frequency set to $adtimer minutes."    } else {      set adtimer $arg      putserv "privmsg $chan :Advertising ON. Frequency changed to $adtimer minutes."      timer $adtimer [list advertise]    }  }}# Function that finds out the ID of the advertising timer.proc gettimerid {} {    set adtimerinfo [timers]    set loc1 [string first "advertise" $adtimerinfo]    set loc1 [expr $loc1 + 10]    set str1 [string range $adtimerinfo $loc1 999]    set endloc [string first "\}" $str1]    set endloc [expr $endloc -1]    set timerinfo [string range $str1 0 $endloc]    return $timerinfo}# Messages that are displayed when Advertising is enabled.proc advertise {} {  global radiochan streamstatus otherchan enableadvertise adtimer forceadsent streamurl streamname  if {$streamstatus != "0" &amp;&amp; $enableadvertise == "1"} {    putserv "PRIVMSG $radiochan :$streamname is currently broadcasting live! Listen in @ $streamurl"    putserv "PRIVMSG $otherchan :$streamname is currently broadcasting live! Listen in @ $streamurl"    if {$forceadsent == "0"} {timer $adtimer [list advertise]} else {set forceadsent "0"}    return 1  }  return 0}# Forces the advertising messages to appearproc forceadvertise {nick uhost hand chan arg} {  global streamstatus enableadvertise forceadsent  if {$streamstatus == "0"} {    putserv "notice $nick :The stream isn't on-air. Unable to advertise."    return 0  } else {    if {$enableadvertise == "0"} {      putserv "notice $nick :Advertising isn't enabled."      return 0    } else {      set forceadsent "1"      set forceadvertised [advertise]      if {$forceadvertised == "1"} {        putserv "notice $nick :Done!"      } else {        putserv "notice $nick :Advertising message was not sent!"      }    }  }}# Special Announcement Message.proc specialmessage {} {  global radiochan specialannounce announcemsg  putserv "PRIVMSG $radiochan : $announcemsg"  timer 720 [list specialmessage]  return 0}# StatusCheck# Function that takes the information from Icecast_Online and creates the proper responses.proc statuscheck {} {  global radiochan streamstatus newsong oldsong newlistener oldlistener sessionpeak dj enableadvertise otherchan onlinetimer offlinetimer streamurl streamname  if {$streamstatus == "0"} {    set oldstatus "0"  } else {    set oldstatus "1"  }  set newstatus "[icecast_online]"  if {$newstatus =="0" &amp;&amp; $oldstatus == "0"} {    timer $offlinetimer [list statuscheck]  }  if {$newstatus == "1" &amp;&amp; $oldstatus == "0"} {    putserv "PRIVMSG $radiochan :$streamname is now ON-AIR!! Click to listen: $streamurl"    putlog "(RADIO) On-Air detected."    utimer $onlinetimer [list statuscheck]    if {$enableadvertise == "1"} {      putserv "PRIVMSG $otherchan :$streamname is now ON-AIR!! Click to listen: $streamurl"    }  }  if {$newstatus == "0" &amp;&amp; $oldstatus == "1"} {    putserv "PRIVMSG $radiochan :$streamname is now off-air."    set oldlistener "0"    set sessionpeak "0"    if {$enableadvertise == "1"} {      putserv "PRIVMSG $otherchan :$streamname is now off-air."    }    putlog "(RADIO) Off-Air detected."    timer $offlinetimer [list statuscheck]  }  if {$newstatus == "1" &amp;&amp; $oldstatus == "1"} {    utimer $onlinetimer [list statuscheck]    if {$newsong != $oldsong &amp;&amp; $newsong != "&gt;inbetween" &amp;&amp; $newsong != "&gt;inbetween1" &amp;&amp; $newsong != "&gt;inbetween2" &amp;&amp; $newsong != "&gt;whatutalkinbout" &amp;&amp; $newsong != "&gt;tmsradio80sintro"} {      putserv "PRIVMSG $radiochan :Now playing on $streamname: $newsong @ $streamurl"      set oldsong "$newsong"    }  }}  # Icecast_Online# This is the HTTP Parser that gathers the various data from the status.xsl file.proc icecast_online { } {  global streamip streamport streamstatus newsong newlistener  set pagedata ""  if {[catch {set sock [socket $streamip $streamport] } sockerror]} {    putlog "error: $sockerror"    return 0  } else {    puts $sock "GET /status.xsl?mount=/sircrazy HTTP/1.1"    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]} { append pagedata "[read $sock]" }  }  if {[string match *streamdata* $pagedata] == 1} {    set streamstatus "1"    set songlocation [string first "Current Song:" $pagedata]    set songdata1 [string range $pagedata $songlocation 99999]    set location2 [string first "&lt;/tr&gt;" $songdata1]    set songdata2 [string range $songdata1 0 $location2]    set songdata3 [string range $songdata2 42 9999]    set location3 [string first "&lt;/td&gt;" $songdata3]    set location3 [expr $location3 - 1]    set newsong [string range $songdata3 0 $location3]    set llocation [string first "Listeners:" $pagedata]    set countdata1 [string range $pagedata $llocation 99999]    set llocation2 [string first "&lt;/tr&gt;" $countdata1]    set countdata2 [string range $countdata1 0 $llocation2]    set countdata3 [string range $countdata2 39 9999]    set llocation3 [string first "&lt;/td&gt;" $countdata3]    set llocation3 [expr $llocation3 - 1]    set newlistener [string range $countdata3 0 $llocation3]    close $sock    return 1      } else {    set streamstatus "0"    close $sock    return 0  }}# %status function. Diplays the current status of the stream.proc status {nick uhost hand chan arg} {  global dj radiochan newsong newlistener streamstatus streamurl streamname  if {$streamstatus == 1} {    if {$newsong != "" &amp;&amp;  $dj == "$nick" &amp;&amp; $arg != ""} {putserv "notice $arg :The current song is |$newsong| @ $streamurl"}    if {$newsong != "" &amp;&amp;  $dj != "$nick"} {      putserv "notice $nick :The current song is |$newsong| @ $streamurl"    }   } else {putserv "notice $nick :$streamname is currently offline."    }}# /msg %botnick listeners: displays how many current listeners there are.proc listenercheck {nick uhost hand arg} {  global newlistener radiochan streamstatus streamname  if {$streamstatus == "1"} {    if {$newlistener == "0"} {      putserv "notice $nick :There aren't any listeners tuned into $streamname :(."    } elseif {$newlistener =="1"} {      putserv "notice $nick :There is 1 listener tuned into $streamname."    } else {      putserv "notice $nick :There are $newlistener listeners tuned into $streamname."    }  } else {    putserv "notice $nick :$streamname isn't on-air."  }}# %request: sends a message to dj about the request that was made.proc request {nick uhost hand chan arg} {  global dj  if {$dj != ""} {    if {$arg == ""} {putserv "notice $nick :You didn't request anything!"    return 0    } else {      putserv "privmsg $dj :REQUEST($nick) =&gt; $arg"      putserv "notice $nick :Your request was sent to $dj. Thank you!"      return 0      }  } else {    putserv "notice $nick :There is no DJ online taking requests."    return 0  }}# /msg $botnick request X: sends a message to dj about the request that was made.proc request_pm {nick uhost hand arg} {  global dj  if {$dj != ""} {    if {$arg == ""} {putserv "notice $nick :You didn't request anything!"    return 0    } else {      putserv "privmsg $dj :REQUEST($nick) =&gt; $arg"      putserv "notice $nick :Your request was sent to $dj. Thank you!"      return 0      }  } else {    putserv "notice $nick :There is no DJ online taking requests."    return 0  }}# /msg $botnick djon [password]: Turns DJ on for userproc dj_on {nick uhost hand arg} {  global dj radiochan  if {$dj == ""} {    if {$arg == ""} {putserv "privmsg $nick :You must enter your password"      return 0    } else {# This is a Test DJ Entry. the $arg here is the password.# You can have as many of these as you want, just paste# them directly under one another, within the else { }.#      if {$arg == "Test"} {#        set dj "$nick"#        putserv "PRIVMSG $nick :You are logged in as $dj."#        putserv "PRIVMSG $radiochan :$dj is now rocking the turntables and accepting requests via %request, enjoy."#        return 0#      }    }  }  if {$dj != ""} {    putsrv "notice $nick :$dj is already active. &amp;dj needs to sign off before you can log in."    return 0  }}# %djoff: Turns DJ off for userproc dj_off {nick uhost hand chan arg} {  global dj radiochan  if {$dj != $nick} {    putserv "notice $nick :You are not the current DJ or you changed your nickname since becoming one."  } else {    putserv "PRIVMSG $radiochan :$dj is signing off and no longer accepting requests."    set dj ""    putserv "notice $nick :Your DJ'ness has been deactivated"  }}# /msg $botnick djoff: Turns DJ off for userproc dj_off_pm {nick uhost hand arg} {  global dj radiochan  if {$dj != $nick} {    putserv "notice $nick :You are not the current DJ or you changed your nickname since becoming one."  } else {    putserv "PRIVMSG $radiochan :$dj is signing off and no longer accepting requests."    set dj ""    putserv "notice $nick :Your DJ'ness has been deactivated"  }}# !version: displays the current version of the Ice2.tcl script.proc iceversion {nick host hand chan arg} {   global ice2version radiochan botnick   if {$chan == $radiochan} {     putserv "notice $nick :I am $botnick running Ice2.tcl Version $ice2version by Tido, Henkes, and Sircrazy."   }}putlog "Ice2 Version $ice2version by Tido, Henkes, and Sircrazy is loaded! :)"</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10207">roughnecks</a> — Sat Mar 05, 2022 8:22 pm</p><hr />
]]></content>
	</entry>
	</feed>
