Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #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 Station
- set streamname "Radio Linuxerz"
- #IP of the Icecast server.
- set streamip "91.121.134.23"
- #Port that Icecast is using, default is 8000.
- set streamport "8000"
- #Main channel for the radio bot.
- set radiochan "#linuxerz"
- #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 ""
- #URL/Link to the stream for listening. This is what listeners need to click to tune in.
- set streamurl "http://radio.linuxerz.org"
- #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 Message
- #set 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. #
- ###########################################################################
- # Binds
- #bind pub - "%commands" showcommands
- #Shows a list of all commands
- #bind pub - "%help" showcommands
- #same as %commands
- #bind pub - "!sonando" statuscheck
- #Displays the status of the stream
- #bind pub - "%listeners" listenercheck
- #Reports how many listeners there are
- #bind pub - "%request" request
- #Allows users to request songs
- #bind msg - "request" request_pm
- #Allows users to make requests via pm
- #bind msg - "djon" dj_on
- #turns on dj status
- #bind pub - "%djoff" dj_off
- #turns off dj status
- #bind msg - "djoff" dj_off_pm
- #turns off dj status
- #bind pub - "%fadvert" forceadvertise
- #Forces an advertising message to be sent
- #bind pub - "%version" iceversion
- #Displays the Ice2.tcl version
- # Varible Resets
- set ice2version "1.01 - 07.12.10"
- set streamstatus "0"
- set djnickname ""
- set dj ""
- set oldsong ""
- set newsong ""
- set newlistener ""
- set oldlistener "1"
- 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 %commands
- proc showcommands {nick uhost hand chan arg} {
- global ice2version streamname botnick dj
- if {$dj == "$nick" && $arg != ""} {
- putserv "notice $arg :>>> $botnick Commands - $ice2version<<<"
- putserv "notice $arg :%status >>> Displays stream's status. If online it shows the song."
- putserv "notice $arg :%request (artist+track) >>> Sends a Request for a future song."
- putserv "notice $arg :/msg $botnick request (artist+track) >>> Sends a Request for a future song by PM."
- }
- if {$dj != "$nick"} {
- set arg ""
- putserv "notice $nick :>>> $botnick Commands - $ice2version<<<"
- putserv "notice $nick :%status >>> Displays the stream's status. If online it shows the song."
- putserv "notice $nick :%request (artist+track) >>> Sends a Request for a future song."
- putserv "notice $nick :/msg $botnick request (artist+track) >>> Sends a Request for a future song by PM."
- }
- }
- # Turns on and off Advertising. Also lets you set the interval: !advertise X
- proc 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 :Aviso OFF"
- } else {
- set enableadvertise "1"
- if {$arg == ""} {
- putserv "PRIVMSG $chan :Aviso ON. Frecuencia cambiada a $adtimer minutes."
- } else {
- set adtimer $arg
- putserv "privmsg $chan :Aviso ON. Frequencia cambiada a $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
- }
- proc sonandoc {} {
- if {$newstatus == "1" && $oldstatus == "1"} {
- utimer $onlinetimer [list statuscheck]
- if {$newsong != $oldsong && $newsong != ">inbetween" && $newsong != ">inbetween1" && $newsong != ">inbetween2" && $newsong != ">what$
- putserv "PRIVMSG $radiochan :Esta Sonando $streamname: $newsong @ $streamurl"
- set oldsong "$newsong"
- }
- }
- }
- # Messages that are displayed when Advertising is enabled.
- proc advertise {} {
- global radiochan streamstatus otherchan enableadvertise adtimer forceadsent streamurl streamname
- if {$streamstatus != "0" && $enableadvertise == "1"} {
- putserv "PRIVMSG $radiochan :$streamname actualmente esta transmitiendo en vivo! Escuchar en @ $streamurl"
- putserv "PRIVMSG $otherchan :$streamname actualmente esta transmitiendo en vivo! Escuchar en @ $streamurl"
- if {$forceadsent == "0"} {timer $adtimer [list advertise]} else {set forceadsent "0"}
- return 1
- }
- return 0
- }
- # Forces the advertising messages to appear
- proc forceadvertise {nick uhost hand chan arg} {
- global streamstatus enableadvertise forceadsent
- if {$streamstatus == "0"} {
- putserv "noticia $nick :El Stream no esta al-aire. No se puede avisar."
- return 0
- } else {
- if {$enableadvertise == "0"} {
- putserv "notice $nick :Aviso no esta activado."
- return 0
- } else {
- set forceadsent "1"
- set forceadvertised [advertise]
- if {$forceadvertised == "1"} {
- putserv "notice $nick :Terminado!"
- } else {
- putserv "notice $nick :Mensaje de aviso no se envio"
- }
- }
- }
- }
- # 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" && $oldstatus == "0"} {
- timer $offlinetimer [list statuscheck]
- }
- if {$newstatus == "1" && $oldstatus == "0"} {
- putserv "PRIVMSG $radiochan :$streamname esta al-aire Click para escuchar: $streamurl"
- putlog "(RADIO) On-Air detected."
- utimer $onlinetimer [list statuscheck]
- if {$enableadvertise == "1"} {
- putserv "PRIVMSG $otherchan :$streamname esta al-aire Click para escuchar: $streamurl"
- }
- }
- if {$newstatus == "0" && $oldstatus == "1"} {
- putserv "PRIVMSG $radiochan :$streamname esta nuevamente fuera de linea."
- set oldlistener "0"
- set sessionpeak "0"
- if {$enableadvertise == "1"} {
- putserv "PRIVMSG $otherchan :$streamname esta fuera de linea."
- }
- putlog "(RADIO) Fuera de Linea detectado."
- timer $offlinetimer [list statuscheck]
- }
- if {$newstatus == "1" && $oldstatus == "1"} {
- utimer $onlinetimer [list statuscheck]
- if {$newsong != $oldsong && $newsong != ">inbetween" && $newsong != ">inbetween1" && $newsong != ">inbetween2" && $newsong != ">whatutalkinbout" && $newsong != ">tmsradio80sintro"} {
- putserv "PRIVMSG $radiochan :Esta Sonando $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=/latam.ogg 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 "</tr>" $songdata1]
- set songdata2 [string range $songdata1 0 $location2]
- set songdata3 [string range $songdata2 42 9999]
- set location3 [string first "</td>" $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 "</tr>" $countdata1]
- set countdata2 [string range $countdata1 0 $llocation2]
- set countdata3 [string range $countdata2 39 9999]
- set llocation3 [string first "</td>" $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 != "" && $dj == "$nick" && $arg != ""} {putserv "notice $arg :La cancion actual es |$newsong| @ $streamurl"}
- if {$newsong != "" && $dj != "$nick"} {
- putserv "noticia $nick :La cancion actual es |$newsong| @ $streamurl"
- }
- } else {putserv "noticia $nick :$streamname esta fuera de linea."
- }
- }
- # /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 "noticia $nick :No hay ningun escucha para $streamname :(."
- } elseif {$newlistener =="1"} {
- putserv "noticia $nick :hay 1 escucha en $streamname."
- } else {
- putserv "noticia $nick :Hay $newlistener escuchas en $streamname."
- }
- } else {
- putserv "noticia $nick :$streamname no esta al-aire."
- }
- }
- # %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 "noticia $nick :No puedes solitar ninguna!"
- return 0
- } else {
- putserv "privmsg $dj :REQUEST($nick) => $arg"
- putserv "noticia $nick :Su peticion fue enviada a $dj. Muchas Gracias."
- return 0
- }
- } else {
- putserv "noticia $nick :No Hay ningun Dj en linea para aceptar peticiones."
- 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 "noticia $nick :No puedes solicitar ninguna!!"
- return 0
- } else {
- putserv "privmsg $dj :REQUEST($nick) => $arg"
- putserv "noticia $nick :Su peticion fue enviada a $dj. Muchas Gracias."
- return 0
- }
- } else {
- putserv "noticia $nick :No Hay ningun Dj en linea para aceptar peticiones."
- return 0
- }
- }
- # /msg $botnick djon [password]: Turns DJ on for user
- proc dj_on {nick uhost hand arg} {
- global dj radiochan
- if {$dj == ""} {
- if {$arg == ""} {putserv "privmsg $nick :Necesita escribir su contraseña"
- 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 "noticia $nick :$dj ya esta activo. &dj necesita desloguearse antes de logearse."
- return 0
- }
- }
- # %djoff: Turns DJ off for user
- proc dj_off {nick uhost hand chan arg} {
- global dj radiochan
- if {$dj != $nick} {
- putserv "noticia $nick :No eres el DJ actual o debes cambiar el nick para ser uno."
- } else {
- putserv "PRIVMSG $radiochan :$dj se deslogueo y no acepta peticiones."
- set dj ""
- putserv "noticia $nick :Su DJ'ness esta desactivado"
- }
- }
- # /msg $botnick djoff: Turns DJ off for user
- proc dj_off_pm {nick uhost hand arg} {
- global dj radiochan
- if {$dj != $nick} {
- putserv "noticia $nick :No eres el DJ actual o debes cambiar el nick para ser uno."
- } else {
- putserv "PRIVMSG $radiochan :$dj se deslogueo y no acepta peticiones."
- set dj ""
- putserv "noticia $nick :Su DJ'ness esta desactivado"
- }
- }
- # !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 "noticia $nick :Soy $botnick arrancando Ice2.tcl Version $ice2version Por Tido, Henkes, y Sircrazy."
- }
- }
- putlog "Ice2 Version $ice2version Por Tido, Henkes, y Sircrazy esta cargando :)"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement