This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

LoReZ ShoutCast Script v2.1 announce in 2 channels, how?

Support & discussion of released scripts, and announcements of new releases.
Post Reply
s
starpossen
Op
Posts: 139
Joined: Tue Jan 10, 2006 1:08 am

LoReZ ShoutCast Script v2.1 announce in 2 channels, how?

Post by starpossen »

My bot sits on two channels, #radio and #starpossen, and As the topic says, I want this script to announce in #starpossen aswell, everuthing works nicely in #radio channel where it changes the topic when the stream goes off and online etc. wich is good, but the in #starpossen, I only want the bot to announce current song and Advertise for the stream, I dont know if this is possible, and I tried connecting to quakenet to get a hold of LoReZ but he seems to be offline.

the .cfg and the .tcl are below and unedited:

sc.cfg

Code: Select all

###############################################################################################################################
#                                                                                                                             # 
# LoReZ ShoutCast Script v2.1 (sc.tcl)                                                                                        #
# Email: lorez@bigvibez.com                                                                                                   #
# IRC: #bigvibez @ Quakenet                                                                                                   #
#                                                                                                                             #
# Please contact me if you notice any bugs                                                                                    #
#                                                                                                                             #
# Installation: Put the script and the config file into your scripts directory, add "source scripts/sc.tcl" to your eggdrop   #
#               config and rehash the bot. (http package is REQUIRED for this script to work)                                 #                                                                                              #
#                                                                                                                             #
###############################################################################################################################

###############################################################################################################################
#                                                START OF CONFIGURATION FOR SC.TCL                                            #
###############################################################################################################################

### Stream Settings ###

# A Description for your Stream
set sc::vars(desc) "My Radio"

# The IP Adress of your Stream
set sc::vars(ip) "192.168.1.1"

# The Port on which ShoutCast runs
set sc::vars(port) "8000"

# The Password of your Stream
set sc::vars(pass) "leet1337"

# The MIME encrypted Admin Password of your Stream (you can get it with mIRC by typing //echo -a $encode(admin:adminpassword,m)
set sc::vars(adpass) "YWRftaW46ddhm9yc3RhZ57HQ="

# The Channels on which the Bot shall react on Commands
set sc::vars(chans) "#myradio"

# The Intern Channel to which the Bot sends Wishes and Greets (if send Wishes and Greets to Intern Channel is activated)
set sc::vars(intern) "#myradio.intern"

# The File where the Data shall be stored
set sc::vars(file) "/home/user/eggdrop/scripts/sc.db"

# The Flag required for kicking the Source and un/setting the DJ
set sc::vars(flag) "D"

# The Trigger used for Commands
set sc::vars(trigger) "!sc:"


### General Settings ###

# Enable Public Commands (0 = No | 1 = Yes)
set sc::sets(pub) 1

# Enable Message Commands (0 = No | 1 = Yes)
set sc::sets(msg) 1

# Reply In Channel (0 = No | 1 = Yes)
set sc::sets(reply) 1

# Where to send Wishes and Greets (0 = DJ | 1 = Intern Channel)
set sc::sets(wishgreet) 1

# Announce Track Changes (0 = No | 1 = Yes)
set sc::sets(anntrack) 1

# Announce Bitrate Changes (0 = No | 1 = Yes)
set sc::sets(annbitrate) 1

# Announce Listener Count Changes (0 = No | 1 = Yes)
set sc::sets(annlist) 1

# Announce Peak Changes (0 = No | 1 = Yes)
set sc::sets(annpeak) 1

# Announce DJ Changes (0 = No | 1 = Yes)
set sc::sets(anndj) 1

# Announce when Stream goes on/offline (0 = No | 1 = Yes)
set sc::sets(ann) 1

# Advertise Stream (0 = No | 1 = Yes)
set sc::sets(adv) 1

# Advertise every X Minutes 
set sc::sets(advtime) 15

# Change Topic when Stream goes on/offline
set sc::sets(topchg) 1

# Change Topic when the DJ Changes
set sc::sets(djtopchg) 1

# Change Topic with Q Bot (QuakeNet)
set sc::sets(qtopic) 0

    
### Command and Text Settings ###

# In the texts you can use these variables:
# %listeners %peak %max %unique %avgtime %genre %url %title %song %songurl %irc %icq %aim %webhits %streamhits %bitrate %content %version %ip %port %desc %lastsongs %djnick %dj %showname %status

# Stream Trigger
set sc::triggers(stream) "stream"
# Text when someone uses the Stream Trigger
set sc::texts(stream) "http://%ip:%port/listen.pls"

# Info Trigger
set sc::triggers(info) "info"
# Text when someone uses the Info Trigger
set sc::texts(info) "Stream %ip:%port running ShoutCast v.%version streaming %content. The Listener Peak is %peak (Average Time %avgtime). Stream had %webhits Webhits and %streamhits Streamhits."

# DJ Trigger
set sc::triggers(dj) "dj"
# Text when someone uses the DJ Trigger
set sc::texts(dj) "%dj is on the set"

# Song Trigger
set sc::triggers(song) "song"
# Text when someone uses the Song Trigger
set sc::texts(song) "Now playing: %song"

# Listener Trigger
set sc::triggers(list) "listener"
# Text when someone uses the Listener Trigger
set sc::texts(list) "Stream %ip:%port : %listeners (%unique) of %max listeners"

# Peak Trigger
set sc::triggers(peak) "peak"
# Text when someone uses the Peak Trigger
set sc::texts(peak) "Peak: %peak"

# Bitrate Trigger
set sc::triggers(bitrate) "bitrate"
# Text when someone uses the Bitrate Trigger
set sc::texts(bitrate) "Bitrate: %bitrate"

# Stream Title Trigger
set sc::triggers(title) "title"
# Text when someone uses the Stream Title Trigger
set sc::texts(title) "Title: %title"

# Stream Genre Trigger
set sc::triggers(genre) "genre"
# Text when someone uses the Stream Genre Trigger
set sc::texts(genre) "Genre: %genre"

# Stream URL Trigger
set sc::triggers(url) "url"
# Text when someone uses the Stream URL Trigger
set sc::texts(url) "URL: %url"

# Stream IRC Trigger
set sc::triggers(irc) "irc"
# Text when someone uses the Stream IRC Trigger
set sc::texts(irc) "IRC: %irc"

# Stream ICQ Trigger
set sc::triggers(icq) "icq"
# Text when someone uses the Stream ICQ Trigger
set sc::texts(icq) "ICQ: %icq"

# Stream AIM Trigger
set sc::triggers(aim) "aim"
# Text when someone uses the Stream AIM Trigger
set sc::texts(aim) "AIM: %aim"

# Last Songs Trigger
set sc::triggers(lsongs) "lastsongs"
# Text when someone uses the Last Songs Trigger
set sc::texts(lsongs) "Last Songs: %lastsongs"

### You can remove Commands by deleting or commenting a Trigger and a Text for the Command ###
### You can also add Commands by setting up a Trigger and a Text for the Command. E.g.: ###
# Homepage Trigger
# set sc::triggers(hp) "hp"
# Text when someone uses the Homepage Trigger
# set sc::texts(hp) "Homepage: www.myradio.com"

    
# Help Trigger
set sc::triggers(help) "help"

# Wish Trigger
set sc::triggers(wish) "wish"

# Greet Trigger
set sc::triggers(greet) "greet"

# Kick Trigger
set sc::triggers(kick) "kick"

# Set DJ Trigger
set sc::triggers(setdj) "setdj"

# Unset DJ Trigger
set sc::triggers(unsetdj) "unsetdj"


# Text that is advertised (if advertise Stream is activated)
set sc::texts(adv) "tune in @ http://%ip:%port/listen.pls"

# Text when Stream goes online (if announce when Stream goes on/offline is activated)
set sc::texts(on) "%desc now %status @ http://%ip:%port/listen.pls with %dj at %bitratekbps"

# Text when Stream goes offline (if announce when Stream goes on/offline is activated)
set sc::texts(off) "%title now offline"

# Text for the Topic when Stream goes online (if change Topic when Stream goes on/offline is activated)
set sc::texts(ontopic) "%title now online @ http://%ip:%port/listen.pls with %dj at %bitratekbps :: !sc:help for Bot help"

# Text for the Topic when Stream goes offline (if change Topic when Stream goes on/offline is activated)
set sc::texts(offtopic) "%title now offline :: !sc:help for Bot help"

# Text for the Topic when the DJ changes (if change Topic when DJ changes is activated)
set sc::texts(djtopic) "%title now online @ http://%ip:%port/listen.pls with %dj (%djnick) and his Show %showname at %bitratekbps :: !sc:help for Bot help"

# Text when a new Song is playing (if announce when Track changes is activated)
set sc::texts(songchg) "New Track playing: %song"

# Text when the Listener Count changes (if announce when Listener Count changes is activated)
set sc::texts(listchg) "There are now %listeners (%unique) of %max people listening"

# Text when the Bitrate Changes (if announce when Bitrate changes is activated)
set sc::texts(bitratechg) "Bitrate changed to %bitrate"

# Text when the Peak changes (if announce when Peak changes is activated)
set sc::texts(peakchg) "New Peak: %peak"

# Text when the DJ changes (if announce when DJ changes is activated)
set sc::texts(djchg) "%dj is now on the set"

# Text when Stream is offline and someone uses a Command
set sc::texts(offcmd) "Stream currently offline"
    
###############################################################################################################################
#                                                 END OF CONFIGURATION FOR SC.TCL                                             #
###############################################################################################################################
sc.tcl

Code: Select all

###############################################################################################################################
#                                                                                                                             # 
# LoReZ ShoutCast Script v2.1 (sc.tcl)                                                                                        #
# Email: lorez@bigvibez.com                                                                                                   #
# IRC: #bigvibez @ Quakenet                                                                                                   #
#                                                                                                                             #
# Please contact me if you notice any bugs                                                                                    #
#                                                                                                                             #
# Installation: Put the script and the config file into your scripts directory, add "source scripts/sc.tcl" to your eggdrop   #
#               config and rehash the bot. (http package is REQUIRED for this script to work)                                 #                                                                                              #
#                                                                                                                             #
###############################################################################################################################

###############################################################################################################################
#                                                          START OF TCL CODE                                                  #
###############################################################################################################################

package require http
namespace eval sc {
    variable vars
    variable sets
    variable triggers
    variable texts
    variable offadv 0
    source scripts/sc.cfg
    proc init {} {
	set start [clock clicks]
	set sc::offadv 0
	bind time - "* * * * *" sc::check
	bind nick - * sc::nick
	foreach x [array names sc::triggers] {
	    if {$sc::sets(pub) == 1} {
		bind pub [expr {($x == "kick") || ($x == "setdj") || ($x == "unsetdj") ? "$sc::vars(flag)" : "-"}] $sc::vars(trigger)$sc::triggers($x) "sc::pub $x"
	    }
	    if {$sc::sets(msg) == 1} {
		bind msg [expr {($x == "kick") || ($x == "setdj") || ($x == "unsetdj") ? "$sc::vars(flag)" : "-"}] $sc::vars(trigger)$sc::triggers($x) "sc::msg $x"
	    }
	}
	if {$sc::sets(adv) == 1} {
	    timer $sc::sets(advtime) "sc::post privmsg none all {$sc::texts(adv)}"
	}
	putlog "sc.tcl v2.1 by LoReZ successfully initialized in [expr {([clock clicks]-$start)/1000.0}]ms"	
    }
    proc pub {text nick uhost hand chan args} {
	if {([lsearch -exact [string tolower $sc::vars(chans)] [string tolower $chan]] != -1) || ($sc::vars(chans) == "")} {
	    sc::cmd $text $nick $chan $args
	}
    }
    proc msg {text nick uhost hand args} {
	sc::cmd $text $nick none $args
    }
    proc nick {nick uhost hand chan newnick} {
	set tmp [open $sc::vars(file) r]
	gets $tmp streamdata
	gets $tmp songdata
	gets $tmp djdata
	close $tmp
	if {$nick == [lindex $djdata 0]} {
	    set tmp [open $sc::vars(file) w+]
	    puts $tmp $streamdata
	    puts $tmp $songdata
	    puts $tmp "$newnick [expr {([lindex $djdata 1] == $nick) ? $newnick : [lindex $djdata 1]}] [lrange $djdata 2 end]"
	    close $tmp
	    if {([lindex $djdata 1] == $nick) && ($sc::sets(djtopchg) == 1)} {
		sc::post topic none all "$sc::texts(djtopic)"
	    }
	}	    
    }
    proc cmd {text nick chan args} {
	if {[file exists $sc::vars(file)] != 1} {
	    sc::check * * * * *
	}
	set tmp [open $sc::vars(file) r]
	gets $tmp streamdata
	gets $tmp songdata
	gets $tmp djdata
	close $tmp
	switch -exact $text {
	    help {
		set sc::offadv 1
		putquick "privmsg $nick :Available Commands:"
		foreach x [array names sc::triggers] {
		    if {$x != "help"} {
			if {(([matchattr [nick2hand $nick $chan] +$sc::vars(flag) $chan] != 1) && ($x != "kick") && ($x != "setdj") && ($x != "unsetdj")) || ([matchattr [nick2hand $nick $chan] +$sc::vars(flag) $chan] == 1)} {
			    set sc::offadv 1
			    putquick "privmsg $nick :$sc::vars(trigger)[expr {($x == "setdj") ? "$sc::triggers($x) <djname> <showname>" : [expr {(($x == "wish") || ($x == "greet")) ? "$sc::triggers($x) <$x>" : "$sc::triggers($x)"}]}]"  
			}
		    }
		}
		set sc::offadv 1
		putquick "privmsg $nick :End of Commands"
	    }
	    kick {
		putquick "privmsg $nick :Source successfully kicked"
		if {[lindex $streamdata 15] == 1} {
		    set sock [socket $sc::vars(ip) $sc::vars(port)]
		    puts $sock "GET /admin.cgi?mode=kicksrc HTTP/1.1"
		    puts $sock "User-Agent:Mozilla"
		    puts $sock "Host: $sc::vars(ip)"
		    puts $sock "Authorization: Basic $sc::vars(adpass)"
		    puts $sock ""
		    flush $sock
		}
	    }
	    setdj {
		putquick "privmsg $nick :New DJ set"
		if {[lindex $streamdata 15] == 1} {
		    set tmp [open $sc::vars(file) w+]
		    puts $tmp $streamdata
		    puts $tmp $songdata
		    puts $tmp "$nick [expr {([lindex $args 0] == "{}") ? $nick : [lindex [lindex $args 0] 0]}] [lrange [lindex $args 0] 1 end]"
		    close $tmp
		    if {$sc::sets(anndj) == 1} {
			sc::post privmsg none all "$sc::texts(djchg)"
		    }
		    if {$sc::sets(djtopchg) == 1} {
			sc::post topic none all "$sc::texts(djtopic)"
		    }
		}
	    }
	    unsetdj {
		putquick "privmsg $nick :DJ unset"
		if {[lindex $streamdata 15] == 1} {
		    set tmp [open $sc::vars(file) w+]
		    puts $tmp $streamdata
		    puts $tmp $songdata
		    puts $tmp "none none none"
		    close $tmp
		    if {$sc::sets(anndj) == 1} {
			sc::post privmsg none all "$sc::texts(djchg)"
		    }
		    if {$sc::sets(djtopchg) == 1} {
			sc::post topic none all "$sc::texts(ontopic)"
		    }
		}
	    }
	    default {
		if {($text != "wish") && ($text != "greet")} {
		    sc::post privmsg $nick $chan "$sc::texts($text)"
		} else {
		    if {[lindex $streamdata 15] == 1} {
			if {([lindex $args 0] == "{}")} {
			putquick "privmsg $nick :Nothing specified"
			} else {
			    if {[lindex $djdata 1] == "none"} {
				putquick "privmsg $sc::vars(intern) :[string totitle $text] by $nick: $args"
			    } else {
				putquick "privmsg [expr {($sc::sets(wishgreet) == 1) ? $sc::vars(intern) : [lindex $djdata 0]}] :[string totitle $text] by $nick: $args"
				putquick "privmsg $nick :[string totitle $text] sent to [expr {($sc::sets(wishgreet) == 1) ? $sc::vars(intern) : [lindex $djdata 0]}]"				    
			    }
			}
		    } else {
			sc::post privmsg $nick none "$sc::texts(offcmd)"
		    }
		}
	    }
	}
	putlog "sc.tcl v2.1 $nick used $sc::vars(trigger)$sc::triggers($text)"
    }           
    proc check {min hour day month year} {
	set start [clock clicks]
	if {[file exists $sc::vars(file)] == 1} {
	    set tmp [open $sc::vars(file) r]
	    gets $tmp olddata
	    gets $tmp songdata
	    gets $tmp djdata
	    close $tmp
	} else {
	    set olddata "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0"
	    set djdata "none none none"
	}
	http::config -useragent "Mozilla 5.0"
	set con [http::geturl http://$sc::vars(ip):$sc::vars(port)/admin.cgi?pass=$sc::vars(pass)&mode=viewxml&page=0 -timeout 10000]
	set urldata [http::data $con]
	http::cleanup $con 
	foreach {y z} {21 ! 22 \" 23 # 24 \$ 25 % 26 + 27 ' 28 \( 29 \) 2A * 2B + 2C , 2E . 2F / 3A : 3B \; 3C < 3D = 3E > 3F ? 40 @ 5B \[ 5C \\ 5D \] 5F _ 60 ` C0 À C1 Á C2 Â C3 Ã C4 Ä C5 Å C6 Æ C7 Ç C8 È C9 É CA Ê CB Ë CC Ì CD Í CE Î CF Ï D1 Ñ D2 Ò D3 Ó D4 Ô D5 Õ D6 Ö D9 Ù DA Ú DB Û DC Ü DD Ý DF ß E0 à E1 á E2 â E3 ã E4 ä E5 å E6 æ E7 ç E8 è E9 é EA ê EB ë EC ì ED í EE î EF ï F0 ð F1 ñ F2 ò F3 ó F4 ô F5 õ F6 ö F9 ù FA ú FB û FC ü FD ý FE þ FF ÿ} {
	    regsub -all "&#x$y;" $urldata "$z" urldata 
	}
	regsub -all ".*<SHOUTCASTSERVER>" $urldata "" data1
	regsub -all "<WEBDATA>.*" $data1 "" data1
	regsub -all ".*<SONGHISTORY>" $urldata "\{" data2
	regsub -all "</SONGHISTORY>.*" $data2 " \}" data2
	set x 0
	foreach y {CURRENTLISTENERS PEAKLISTENERS MAXLISTENERS REPORTEDLISTENERS AVERAGETIME SERVERGENRE SERVERURL SERVERTITLE SONGTITLE SONGURL IRC ICQ AIM WEBHITS STREAMHITS STREAMSTATUS BITRATE CONTENT VERSION SONG PLAYEDAT TITLE} {
	    if {$x < 19} {
		regsub -all ".*<$y>" $data1 "" data10
		regsub -all "</$y>.*" $data10 "" data10
		lappend streamdata [expr {(($data10 == "0") || ($data10 == "")) && ([string match -nocase *listeners "$y"] != 1) && ([string match -nocase *hits "$y"] != 1) && ([string match -nocase *time "$y"] != 1) ? "N/A" : $data10}]
	    }
	    if {$x > 18} {
		regsub -all "<$y>" $data2 "\{" data2
		regsub -all "</$y>" $data2 "\} " data2
	    }
	    incr x
	}
	set tmp [open $sc::vars(file) w+]
	puts $tmp $streamdata
	puts $tmp $data2
	puts $tmp $djdata
	close $tmp
	if {[lindex $olddata 15] != [lindex $streamdata 15]} {
	    if { ($sc::sets(ann) == 1)} {
		set sc::offadv [expr {([lindex $streamdata 15] == 1) ? 0 : 1}]
		sc::post privmsg none all "[expr {([lindex $streamdata 15] == 1) ? $sc::texts(on) : $sc::texts(off)}]"
	    }
	    if {$sc::sets(topchg) == 1} {
		set sc::offadv [expr {([lindex $streamdata 15] == 1) ? 0 : 1}]
		sc::post topic none all "[expr {([lindex $streamdata 15] == 1) ? $sc::texts(ontopic) : $sc::texts(offtopic)}]"
	    }
	}
	foreach {x y z} {8 anntrack songchg 0 annlist listchg 1 annpeak peakchg 16 annbitrate bitratechg} {
	    if {([lindex $olddata $x] != [lindex $streamdata $x]) && ($sc::sets($y) == 1)} {
		sc::post privmsg all all "$sc::texts($z)"
	    }
	}
	putlog "sc.tcl v2.1 received information from $sc::vars(ip):$sc::vars(port) in [expr {([clock clicks]-$start)/1000.0}]ms"
    }              
    proc post {mode nick chan text} {
	set tmp [open $sc::vars(file) r]
	gets $tmp streamdata
	gets $tmp songdata
	gets $tmp djdata
	close $tmp
	if {([lindex $streamdata 15] == 1) || ($sc::offadv == 1)} {
	    foreach x [lindex $songdata 0] {
		append lastsongs "[lindex $x 1] :: "
	    }
	    lappend streamdata $sc::vars(ip) $sc::vars(port) $sc::vars(desc) ":: $lastsongs" [expr {(([lindex $djdata 0] == "none") || ([lindex $djdata 0] == "{}") || ([lindex $djdata 0] == "")) ? "No DJ" : [lindex $djdata 0]}] [expr {(([lindex $djdata 1] == "none") || ([lindex $djdata 1] == "{}") || ([lindex $djdata 1] == "")) ? "No DJ" : [lindex $djdata 1]}] [expr {(([lindex $djdata 2] == "none") || ([lindex $djdata 2] == "{}") || ([lindex $djdata 2] == "")) ? "No Show" : [lrange $djdata 2 end]}] [expr {([lindex $streamdata 15] == 1) ? "online" : "offline"}]
	    set x 0
	    foreach y {listeners peak max unique avgtime genre url title song songurl irc icq aim webhits streamhits streamstatus bitrate content version ip port desc lastsongs djnick dj showname status} {
		regsub -all "%$y" $text "[lindex $streamdata $x]" text
		incr x
	    }
	    if {$mode == "topic"} {
		foreach chans [channels] {
		    if {$sc::vars(chans) == ""} {
			if {$sc::sets(qtopic) == 1} {
			    putquick "privmsg TheQBot@CServe.quakenet.org :SETTOPIC $chans $text"
			} else {
			    putquick "$mode $chans :$text"
			}
		    } else {
			if {([lsearch -exact [string tolower $sc::vars(chans)] [string tolower $chans]] != -1)} {
			    if {$sc::sets(qtopic) == 1} {
				putquick "privmsg TheQBot@CServe.quakenet.org :SETTOPIC $chans $text"
			    } else {
				putquick "$mode $chans :$text"
			    }
			}		
		    }
		}
	    } else {
		if {($sc::sets(reply) != 1) || ($chan == "none")} {
		    putquick "$mode $nick :$text"
		}
		if {(($sc::sets(reply) == 1) && ($chan != "none")) || ($chan == "all")} {
		    foreach chans [channels] {
			if {$sc::vars(chans) == ""} {
			    putquick "$mode $chans :$text"
			} else {
			    if {([lsearch -exact [string tolower $sc::vars(chans)] [string tolower $chans]] != -1)} {
				putquick "$mode $chans :$text"
			    }
			}
		    }
		}
	    }
	} else {
	    putquick "$mode [expr {((($sc::sets(reply) != 1) || ($chan == "none")) && ($chan != "all")) ? $nick : $chan}] :$sc::texts(offcmd)"
	}
	set sc::offadv 0
    }
    sc::init
}

###############################################################################################################################
#                                                           END OF TCL CODE                                                   #
###############################################################################################################################
Z
ZzozZ
Voice
Posts: 10
Joined: Sat Nov 13, 2010 6:42 pm

Post by ZzozZ »

How can i set dj ?? PLS HELP
I'm trying to write !sc:djset nick but no result :/
F
Felix2003
Voice
Posts: 24
Joined: Fri Feb 06, 2009 8:19 pm

Post by Felix2003 »

did you set your flag in the bot to allow yourself to set dj?

set sc::vars(flag) "D"

so in the bot type .chattr yournick +D

then try setting DJ
Post Reply