######################################################################### ## BlackTools - The Ultimate Channel Control Script ## ## One TCL. One smart Eggdrop ## ######################################################################### ############################### TCL ################################# ######################################################################### ## ## ## BlackTools : http://blacktools.tclscripts.net ## ## Bugs report : http://www.tclscripts.net/ ## ## Online Help : irc://irc.undernet.org/tcl-help ## ## #TCL-HELP / UnderNet ## ## You can ask in english or romanian ## ## ## ######################################################################### proc tclpublic {nick host hand chan arg} { global black config lastbind set type 0 set chan1 "$chan" set the_script [lindex [split $arg] 1] set who [lindex [split $arg] 0] set return [blacktools:mychar $lastbind $hand] if {$return == "0"} { return } tcl:process $nick $host $hand $chan $chan1 $type $the_script $who } proc tcl:process {nick host hand chan chan1 type the_script who} { global black config set cmd_status [btcmd:status $chan $hand "tcl" 0] if {$cmd_status == "1"} { return } set current_tcl "" set tcl_exists 0 if {$who == ""} { if {$type == "0"} { blacktools:tell $nick $host $hand $chan $chan1 gl.instr "tcl" } if {$type == "1"} { blacktools:tell $nick $host $hand $chan $chan1 gl.instr_nick "tcl" } if {$type == "2"} { blacktools:tell $nick $host $hand $chan $chan1 gl.instr_priv "tcl" } return } switch $who { wget { if {$the_script == ""} { if {$type == "0"} { blacktools:tell $nick $host $hand $chan $chan1 gl.instr "tcl" } if {$type == "1"} { blacktools:tell $nick $host $hand $chan $chan1 gl.instr_nick "tcl" } if {$type == "2"} { blacktools:tell $nick $host $hand $chan $chan1 gl.instr_priv "tcl" } return } if {![string match -nocase "*.tcl" $the_script]} { if {$type == "0"} { blacktools:tell $nick $host $hand $chan $chan1 gl.instr "tcl" } if {$type == "1"} { blacktools:tell $nick $host $hand $chan $chan1 gl.instr_nick "tcl" } if {$type == "2"} { blacktools:tell $nick $host $hand $chan $chan1 gl.instr_priv "tcl" } return } set split_thescript [split $the_script "/"] foreach s $split_thescript { if {[string match -nocase "*.tcl" $s]} { if {[check:if:valid $s] == "1"} { set current_tcl $s set tcl_exists 1 } else { set current_tcl $s } } } if {$tcl_exists == "1"} { blacktools:tell $nick $host $hand $chan $chan1 tcl.21 $s return } set wget [catch {exec wget $the_script -P $black(dirname)/ 2>/dev/null} wget_stat] if {[string match -nocase "*exited abnormally*" $wget_stat]} { blacktools:tell $nick $host $hand $chan $chan1 tcl.19 $current_tcl return } putserv "PRIVMSG $chan :$wget_stat" blacktools:tell $nick $host $hand $chan $chan1 tcl.20 $current_tcl } list { set scripts "" set file [open "$config" r] set w [read -nonewline $file] close $file set data [split $w "\n"] foreach line $data { if {[string match -nocase "source $black(dirname)/*" $line]} { set the_split [split $line "/"] set the_script [lindex $the_split 1] lappend scripts $the_script } } blacktools:tell $nick $host $hand $chan $chan1 tcl.1 none foreach txt [wordwrap [join $scripts ", "] 350 ,] { blacktools:tell $nick $host $hand $chan $chan1 tcl.17 $txt } } load { if {$the_script == ""} { if {$type == "0"} { blacktools:tell $nick $host $hand $chan $chan1 gl.instr "tcl" } if {$type == "1"} { blacktools:tell $nick $host $hand $chan $chan1 gl.instr_nick "tcl" } if {$type == "2"} { blacktools:tell $nick $host $hand $chan $chan1 gl.instr_priv "tcl" } return } set black(tcl_load) [catch {source "$black(dirname)/$the_script"} black(tcl_load_error)] if {$black(tcl_load) == "1"} { blacktools:tell $nick $host $hand $chan $chan1 tcl.3 "$the_script [split $black(tcl_load_error)]" return } set file [open "$config" r] set w [read -nonewline $file] close $file set counter -1 set data [split $w "\n"] set tcl_position -1 set found_it 0 foreach line $data { if {[string match -nocase "source $black(dirname)/*" $line]} { set the_split [split $line "/"] set script [lindex $the_split 1] if {[string equal -nocase $script $the_script]} { set found_it 1 } } } if {$found_it == 1} { blacktools:tell $nick $host $hand $chan $chan1 tcl.4 $the_script return } set file [open "$config" a] puts $file "source $black(dirname)/$the_script" close $file rehash blacktools:tell $nick $host $hand $chan $chan1 tcl.5 $the_script } unload { if {$the_script == ""} { if {$type == "0"} { blacktools:tell $nick $host $hand $chan $chan1 gl.instr "tcl" } if {$type == "1"} { blacktools:tell $nick $host $hand $chan $chan1 gl.instr_nick "tcl" } if {$type == "2"} { blacktools:tell $nick $host $hand $chan $chan1 gl.instr_priv "tcl" } return } if {[string match -nocase "*BlackTools*" $the_script]} { blacktools:tell $nick $host $hand $chan $chan1 tcl.18 none return } set file [open "$config" r] set w [read -nonewline $file] close $file set counter -1 set data [split $w "\n"] set tcl_position -1 set found_it 0 foreach line $data { set counter [expr $counter + 1] if {[string match -nocase "*source $black(dirname)/*" $line]} { set the_split [split $line "/"] set script [lindex $the_split 1] if {[string equal -nocase $script $the_script]} { set found_it 1 set tcl_position $counter } } } if {$found_it == 0} { blacktools:tell $nick $host $hand $chan $chan1 tcl.7 $the_script return } set delete [lreplace $data $tcl_position $tcl_position] set file [open "$config" "w"] puts $file [join $delete "\n"] close $file rehash blacktools:tell $nick $host $hand $chan $chan1 tcl.8 $the_script } all { set the_files [glob -directory $black(dirname) "*.tcl"] set counter 0 set current_tcl "" foreach file $the_files { set counter [expr $counter + 1] } blacktools:tell $nick $host $hand $chan $chan1 tcl.9 $counter set counter 0 foreach file $the_files { set counter [expr $counter + 1] set split_file [split $file "/"] set the_file [lindex $split_file 1] set status [check:if:load $the_file] if {$counter < 30} { if {$status == "1"} { lappend current_tcl "\002$the_file\002" } else { lappend current_tcl $the_file } } } foreach txt [wordwrap [join $current_tcl ", "] 350 ,] { blacktools:tell $nick $host $hand $chan $chan1 tcl.17 $txt } } info { if {$the_script == ""} { if {$type == "0"} { blacktools:tell $nick $host $hand $chan $chan1 gl.instr "tcl" } if {$type == "1"} { blacktools:tell $nick $host $hand $chan $chan1 gl.instr_nick "tcl" } if {$type == "2"} { blacktools:tell $nick $host $hand $chan $chan1 gl.instr_priv "tcl" } return } set status_valid [check:if:valid $the_script] set status [check:if:load $the_script] if {$status_valid == "0"} { blacktools:tell $nick $host $hand $chan $chan1 tcl.12 $the_script return } if {$status == "0"} { blacktools:tell $nick $host $hand $chan $chan1 tcl.13 $the_script } else { blacktools:tell $nick $host $hand $chan $chan1 tcl.14 $the_script } } default { if {$type == "0"} { blacktools:tell $nick $host $hand $chan $chan1 gl.instr "tcl" } if {$type == "1"} { blacktools:tell $nick $host $hand $chan $chan1 gl.instr_nick "tcl" } if {$type == "2"} { blacktools:tell $nick $host $hand $chan $chan1 gl.instr_priv "tcl" } return } } } proc check:if:valid {tcl} { global black set the_files [glob -directory $black(dirname) "*.tcl"] foreach file $the_files { set split_file [split $file "/"] set the_file [lindex $split_file 1] if {[string equal -nocase $tcl $the_file]} { return 1 } } return 0 } proc check:if:load {tcl} { global black config set file [open "$config" r] set w [read -nonewline $file] close $file set data [split $w "\n"] set found_it 0 foreach line $data { if {[string match -nocase "source $black(dirname)/*" $line]} { set the_split [split $line "/"] set script [lindex $the_split 1] if {[string equal -nocase $script $tcl]} { set found_it 1 } } } if {$found_it == 1} { return 1 } else { return 0 } } ############## ######################################################################### ## END ## #########################################################################