### TCLLoader.tcl 2.0.1 smApj15u
#SUGGESTED
# PBinSrc.tcl fMrtKqyq
#LICENSE
# Copyright © 2013 Alberto Dietze "DoctorD90"
#
# 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, either version 3 of the License, or
# (at your option) any later version.
#
# 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.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Full GPLv3 Text: http://www.gnu.org/licenses/gpl.txt
#PATERNITY
#Coder: DoctorD90
#Network: irc.OnlineGamesNet.net
#Chan: #eHito
#Mail: [email protected]
#Script's List: www.EggTcl.tk
#PURPOSE
#Do not make crash bot if has been founded an error in a script and automatize adding scripts without editing anything more, but using 3 easy commands.
#USAGE
#Paste this script in your own eggdrop's scripts folder;
#write at the end of eggdrop's config 'source path/to/scripts/folder/TCLLoader.tcl'
#Then to manage scripts, paste scripts in your own eggdrop's scripts folder and
#use commands setted in SETTINGS section.
#Do not need more to append scripts at the end of your eggdrop's config file.
#SETTINGS
#Set path where scripts will be stored.
set tclldr(dir) "scripts/"
#Set query command to add scripts.
set tclldr(add) ".Scr+"
#Set query command to list scripts.
set tclldr(see) ".Scr"
#Set query command to del scripts.
set tclldr(del) ".Scr-"
#Set query command to un/comment scripts.
set tclldr(com) ".Scr#"
### DON'T EDIT ANYTHING BELOW ###
bind msg n $tclldr(add) msg_scradd
proc msg_scradd {nick uhost hand text} {
set text [split $text]
if {![llength $text]} {
putserv "PRIVMSG $nick :\002AddScript:\002 Script's Name Required."
return
}
set tclscr [lindex $text 0]
if {![file exists "${::tclldr(dir)}$tclscr"]} {
putserv "PRIVMSG $nick :\002AddScript:\002 $tclscr Not Found In $::tclldr(dir) Folder."
return
}
if {![file exists "${::tclldr(dir)}SCRIPTS.DAT"]} {
set fs [open "${::tclldr(dir)}SCRIPTS.DAT" w]
} else {
set fs [open "${::tclldr(dir)}SCRIPTS.DAT" a]
}
puts $fs "$tclscr"
close $fs
putserv "PRIVMSG $nick :\002$tclscr\002 Successfully Added."
putserv "PRIVMSG $nick :Rehashing..."
rehash
}
bind msg n $tclldr(see) msg_scrsee
proc msg_scrsee {nick uhost hand text} {
if {[file exists "${::tclldr(dir)}SCRIPTS.DAT"]} {
set lines [tclldr_get "${::tclldr(dir)}SCRIPTS.DAT"]
}
if {![info exists lines] || ![string length [string trim [join $lines]]]} {
set lines [list "\002Scripts:\002 No Script Listed."]
}
set n 0
foreach line $lines {
if {[string length [string trim $line]]} {
set line "-Empty-"
}
putserv "PRIVMSG $nick :$n) $line"
incr n
}
putserv "PRIVMSG $nick :*End*"
}
bind msg n $tclldr(del) msg_scrdel
proc msg_scrdel {nick uhost hand text} {
set text [split $text]
if {![llength $text]} {
putserv "PRIVMSG $nick :\002DelScript:\002 Script's Name or Line's Number Required."
return
}
set tclscr [lindex $text 0]
if {[file exists "${::tclldr(dir)}SCRIPTS.DAT"]} {
set lines [tclldr_get "${::tclldr(dir)}SCRIPTS.DAT"]
}
if {![info exists lines] || ![string length [string trim [join $lines]]]} {
putserv "PRIVMSG $nick :\002DelScripts:\002 No Script Listed."
return
}
set d [tclldr_search $tclscr $lines]
if {$d == "-1"} {
putserv "PRIVMSG $nick :\002DelScript:\002 No Script Founds In List."
return
}
tclldr_del [split $d] $lines
if {[string is integer -strict $tclscr]} {
set tclscr "Line \002$tclscr\002"
} else {
set tclscr "\002$tclscr\002"
}
putserv "PRIVMSG $nick :$tclscr Erased."
putserv "PRIVMSG $nick :Restarting..."
restart
}
bind msg n $tclldr(com) msg_scrcom
proc msg_scrcom {nick uhost hand text} {
set text [split $text]
if {![llength $text]} {
putserv "PRIVMSG $nick :\002DelScript:\002 Script's Name or Line's Number Required."
return
}
set tclscr [lindex $text 0]
if {[file exists "${::tclldr(dir)}SCRIPTS.DAT"]} {
set lines [tclldr_get "${::tclldr(dir)}SCRIPTS.DAT"]
}
if {![info exists lines] || ![string length [string trim [join $lines]]]} {
putserv "PRIVMSG $nick :\002DelScripts:\002 No Script Listed."
return
}
set c [tclldr_search $tclscr $lines]
if {$c == "-1"} {
putserv "PRIVMSG $nick :\002DelScript:\002 No Script Founds In List."
return
}
set c [split $c]
set scr [lindex $lines [lindex $c 0]]
tclldr_del $c $lines
if {[string index $scr 0] != "#"} {
set c 0
set scr "#$scr"
} else {
set c 1
set scr [string range $scr 1 end]
}
set fs [open "${::tclldr(dir)}SCRIPTS.DAT" a]
puts $fs $scr
close $fs
if {$c} {
putserv "PRIVMSG $nick :\002$scr\002 UnComment."
putserv "PRIVMSG $nick :Rehashing..."
rehash
} else {
putserv "PRIVMSG $nick :\002$scr\002 Comment."
putserv "PRIVMSG $nick :Restarting..."
restart
}
}
proc tclldr_get {file} {
set fs [open "$file"]
set lines [split [read -nonewline $fs] "\n"]
close $fs
return $lines
}
proc tclldr_search {text lines} {
if {![string is integer -strict $text]} {
set s [lsearch -all $lines "*$text"]
} else {
if {$text >= "0"} {
set s $text
} else {
set s "-1"
}
if {$text >= [llength $lines]} {
set s end
}
}
return $s
}
proc tclldr_del {d lines} {
set a 0
foreach l $d {
set n [expr {$l - $a}]
set lines [lreplace $lines $n $n]
incr a
}
set fs [open "${::tclldr(dir)}SCRIPTS.DAT" w]
puts $fs [join $lines "\n"]
close $fs
}
proc nown { } {
if {[handonchan $::owner]} {
set o [hand2nick $::owner]
} else {
set o $::owner
}
return $o
}
if {![file exists "${::tclldr(dir)}SCRIPTS.DAT"]} {
set tclfs [open "${::tclldr(dir)}SCRIPTS.DAT" w]
close $tclfs
unset tclfs
putlog "SCRIPTS.DAT Created."
putserv "PRIVMSG [nown] :SCRIPTS.DAT Created."
} else {
set tcllines [tclldr_get "${::tclldr(dir)}SCRIPTS.DAT"]
set l 0
if {[llength $lines]} {
foreach tclscr $tcllines {
if {[string length $tclscr] && [string index $tclscr 0] != "#"} {
if {[catch {source ${::tclldr(dir)}$tclscr} tclerr]} {
putlog "TCLError in ($l) $tclscr"
putserv "PRIVMSG [nown] :TCLError in ($l) \002$tclscr\002"
foreach err [split $tclerr "\n"] {
putlog "$err"
putserv "PRIVMSG [nown] :$err"
}
unset tclerr
} else {
putlog "$tclscr Successfully LOADED"
}
}
incr l
}
}
unset tcllines
putlog "***ALL SCRIPTS LOADED***"
putserv "NOTICE [nown] :***ALL SCRIPTS LOADED***"
}
###
putlog "TCLLoader.tcl LOADED"
Comments
0 B
|👍
/👎
0 B
|👍
/👎
0 B
|👍
/👎