egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

help in sc.tcl

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
Sandzo
Voice


Joined: 28 Nov 2009
Posts: 1

PostPosted: Sat Nov 28, 2009 5:14 pm    Post subject: help in sc.tcl Reply with quote

Hallo,

I have a problem. I want to modify the script sc.tcl by LoReZ.

I want to leave the "!setdj" command out of the .tcl file. I've changed the trigger (in the .cfg file) when someone types "!dj" that the script shows on channel the dj name via the AIM of the shoutcast stream.

Quote:

# DJ Trigger
set sc::triggers(dj) "dj"
# Text when someone uses the DJ Trigger
set sc::texts(dj) "Trenutno program vodi %aim"



That wasn't a problem. But I have problems with the tcl script. I want the script use the AIM of the stream automatically as DJ and send the wishes and greets to this nick.

Quote:
###############################################################################################################################
# #
# 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 :Komande koje mozete koristiti:"
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 == "pjesma") || ($x == "pozdrav")) ? "$sc::triggers($x) <$x>" : "$sc::triggers($x)"}]}]"
}
}
}
set sc::offadv 1
putquick "privmsg $nick :Kraj liste"
}
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 Very HappyJ 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 :Niste ukucali naziv pjesme"
} 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 #
###############################################################################################################################



I don't know how and where I have to change sth. in the .tcl file.

I hope sb. can help me as fast as possible.

Thanks

Kind regards from Germany...
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber