hope you can help..
Here it is, updated.. as of September 2022
Here it is, updated..
Code: Select all
#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 "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 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 - "%status" status
#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
bind pub n| !radio radio_off
#Radio on and off
# Varible Resets
set 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 %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 the 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 :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" && $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 appear
proc 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" && $oldstatus == "0"} {
timer $offlinetimer [list statuscheck]
}
if {$newstatus == "1" && $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" && $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" && $oldstatus == "1"} {
utimer $onlinetimer [list statuscheck]
if {$newsong != $oldsong && $newsong != ">inbetween" && $newsong != ">inbetween1" && $newsong != ">inbetween2" && $newsong != ">whatutalkinbout" && $newsong != ">tmsradio80sintro"} {
if {![info exists ::radio_off]} {
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 "</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 :The current song is |$newsong| @ $streamurl"}
if {$newsong != "" && $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 X: sends requests to the DJ.
proc request {nick uhost hand chan arg} {
if {[too_many $nick $uhost $hand $arg]} { return 0 }
global dj radiochan
if {$dj == ""} {
putserv "PRIVMSG $chan :Sorry, there isn't a LIVE 4DJ1 logged in at the moment to take requests."
} else {
if {$arg == ""} {
putserv "notice $nick :You didn't request anything!"
} else {
putserv "privmsg $dj :REQUEST($nick)=> $arg"
putserv "PRIVMSG $chan : Thanks for the request 「 3 $nick 1 」, will be played soon. "
}
}
}
# /msg $botnick request X: sends a message to dj about the request that was made.
proc request_pm {nick uhost hand arg} {
if {[too_many $nick $uhost $hand $arg]} { return 0 }
global dj
if {$dj != ""} {
if {$arg == ""} {putserv "notice $nick :You didn't request anything!"
return 0
} else {
putserv "privmsg $dj :REQUEST($nick) => $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 user
proc 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. &dj needs to sign off before you can log in."
return 0
}
}
# %djoff: Turns DJ off for user
proc 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 user
proc 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."
}
}
# script on/off bind and proc
proc radio_off {nick uhost hand chan arg} {
set opt [string tolower [lindex [split $arg] 0]]
if {$opt eq "off"} {
if {[info exists ::radio_off]} {
putserv "PRIVMSG $chan :Icecast2 script is already Off."
} else {
set ::radio_off 1
putserv "PRIVMSG $chan :Icecast2 script is now Off."
}
} elseif {$opt eq "on"} {
if {![info exists ::radio_off]} {
putserv "PRIVMSG $chan :Icecast2 script is already On."
} else {
unset ::radio_off
putserv "PRIVMSG $chan :Icecast2 script is now On."
}
} else {
if {[info exists ::radio_off]} {
putserv "PRIVMSG $chan :Icecast2 script is Off. To enable, use: !radio on"
} else {
putserv "PRIVMSG $chan :Icecast2 script is On. To disable, use: !radio off"
}
}
return 0
}
proc too_many {nick uhost hand arg} {
global toomany
set nk [string tolower $nick]
set ut [unixtime]
set nowls [list]
if {[info exists toomany($nk)]} {
foreach expire $toomany($nk) {
if {$ut < $expire} { lappend nowls $expire }
}
}
set toomany($nk) $nowls
if {[llength $nowls] >= 2} {
putserv "notice $nick :No more than 2 requests in 15 minutes!"
return 1
}
lappend toomany($nk) [expr {$ut + (60 * 15)}]
return 0
}
bind cron - {*} expire_too_many
proc expire_too_many {mn hr da mo wd} {
global toomany
set ut [unixtime]
foreach {aname avalue} [array get toomany] {
set nowls [list]
foreach expire $avalue {
if {$ut < $expire} { lappend nowls $expire }
}
if {[llength $avalue] >= 2 && [llength $nowls] < 2 && [onchan $aname]} {
putserv "notice $aname :You may make another request."
}
if {![llength $nowls]} { unset toomany($aname)
} else { set toomany($aname) $nowls }
}
}
putlog "Ice2 Version $ice2version by Tido, Henkes, and Sircrazy is loaded! :)"
anyone please help, the script is working fine. but need to add something in regards for requesting a song.
every person can request 2 songs at the same time only, and then after sometime maybe around 15min-20min, she/he can again request 2 songs.
thank you for helping ...