Kaynağa Gözat

Add files via upload

Florian 8 yıl önce
ebeveyn
işleme
25ed519f60

+ 283 - 0
BlackTools2.5/BlackTools/Modules/BT.Anunt.tcl

@@ -0,0 +1,283 @@
+#########################################################################
+##          BlackTools - The Ultimate Channel Control Script           ##
+##                    One TCL. One smart Eggdrop                       ##
+#########################################################################
+########################   ANUNT/ADVERT 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 anuntpublic {nick host hand chan arg} {
+global black lastbind
+	set type 0
+	set chan1 "$chan"
+	set who [lindex [split $arg] 0]
+	set message [join [lrange [split $arg] 1 end]]
+	set number [lindex [split $arg] 1]
+if {[regexp {^[&#]} $who] && [matchattr $hand nmo|M $who]} {
+	set chan "$who"
+	set who [lindex [split $arg] 1]
+	set message [join [lrange [split $arg] 2 end]]
+	set number [lindex [split $arg] 2]
+}
+	set return [blacktools:mychar $lastbind $hand]
+if {$return == "0"} {
+		return
+}
+	anunt:process $nick $host $hand $chan $chan1 $who $message $number $type
+}
+
+proc anunt:process {nick host hand chan chan1 who message number type} {
+global botnick black username
+	set cmd_status [btcmd:status $chan $hand "anunt" 0]
+if {$cmd_status == "1"} { 
+	return 
+}
+	set show_message $message
+	set num 0
+	set temp_num 0
+if {[matchattr $hand q]} { blacktools:tell $nick $host $hand $chan $chan1 gl.glsuspend none
+	return
+}
+if {[matchattr $hand -|q $chan]} { blacktools:tell $nick $host $hand $chan $chan1 gl.suspend none
+	return
+}
+if {$who == ""} {
+if {$type == "0"} {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr "anunt"
+}
+if {$type == "1"} {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr_nick "anunt"
+}
+if {$type == "2"} {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr_priv "anunt"
+}
+	return
+}
+
+if {![validchan $chan]} {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.novalidchan none
+	return
+}
+	switch $who {
+on {
+	setting:set $chan +anunt ""
+	blacktools:tell $nick $host $hand $chan $chan1 anunt.3 none
+foreach tmr [timers] {
+if {[string match "*anuntpublic:show*" [join [lindex $tmr 1]]]} {
+	return
+		}	
+	}
+	set return_time [time_return_minute $black(anunttime)]
+	timer $return_time anuntpublic:show
+}
+
+off {
+	setting:set $chan -anunt ""
+	blacktools:tell $nick $host $hand $chan $chan1 anunt.4 none
+}
+
+add {
+if {$message == ""} {
+if {$type == "0"} {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr "anunt"
+}
+if {$type == "1"} {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr_nick "anunt"
+}
+if {$type == "2"} {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr_priv "anunt"
+}
+	return
+}
+	
+	while {$temp_num == 0} {
+	set get [find:num $num $chan "ANUNT"]
+if {$get == "$num"} {
+	set num [expr $num + 1]
+	} else { set temp_num 1 }
+}
+	set file [open $black(add_file) a]
+	set encoded [encoding convertto utf-8 $message]
+	set enc_chan [encoding convertto utf-8 $chan]
+	puts $file "$enc_chan ANUNT $num $encoded"
+	close $file
+	blacktools:tell $nick $host $hand $chan $chan1 anunt.5 $num
+	blacktools:tell $nick $host $hand $chan $chan1 anunt.1 $show_message
+}
+list {
+	array set anuntlist [list]
+	set timestamp [clock format [clock seconds] -format {%Y%m%d%H%M%S}]
+	set temp "$black(tempdir)/anunt_temp.$timestamp"
+	set file [open $black(add_file) "r"]
+	set w [read -nonewline $file]
+	close $file
+	set data [split $w "\n"]
+foreach line $data {
+	set read_chan [lindex [split $line] 0]
+	set enc_chan [encoding convertfrom utf-8 $read_chan]
+	set read_type [lindex [split $line] 1]
+if {[string match -nocase $enc_chan $chan] && [string match -nocase $read_type "ANUNT"]} {
+	set msg_num [lindex [split $line] 2]
+	set message [join [lrange [split $line] 3 end]]
+lappend anuntlist($msg_num) $message
+	}
+}
+	set tempwrite [open $temp w]
+foreach msg [lsort -integer -increasing [array names anuntlist]] {
+	puts $tempwrite "$msg [join $anuntlist($msg)]"
+	}
+	close $tempwrite
+	set file [open $temp "r"]
+	set w [read -nonewline $file]
+	close $file
+	set data [split $w "\n"]
+	file delete $temp
+	module:getinfo $nick $host $hand $chan $chan1 $type $data "anunt" "0" $number
+}
+
+del {
+	
+if {![regexp {^[0-9]} $number]} {
+if {$type == "0"} {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr "anunt"
+}
+if {$type == "1"} {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr_nick "anunt"
+}
+if {$type == "2"} {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr_priv "anunt"
+}
+	return
+}
+	set ret [find:num $number $chan "ANUNT"]
+if {$ret == 0} { 
+	blacktools:tell $nick $host $hand $chan $chan1 anunt.13 $number
+	return
+}
+	set file [open $black(add_file) "r"]
+	set timestamp [clock format [clock seconds] -format {%Y%m%d%H%M%S}]
+	set temp "$black(tempdir)/anunt_temp.$timestamp"
+	set tempwrite [open $temp w]
+while {[gets $file line] != -1} {
+	set read_num [lindex [split $line] 2]
+	set read_chan [lindex [split $line] 0]
+	set enc_chan [encoding convertfrom utf-8 $read_chan]
+	set read_type [lindex [split $line] 1]
+if {[string equal $number $read_num] && [string equal -nocase $enc_chan $chan] && [string equal -nocase $read_type "ANUNT"]} {
+	continue
+} else {
+	puts $tempwrite $line
+		}	 
+    }
+	close $tempwrite
+	close $file
+    file rename -force $temp $black(add_file)
+
+	blacktools:tell $nick $host $hand $chan $chan1 anunt.10 $number
+		}
+	}
+}
+
+proc anuntpublic:show {} {
+global black
+	set return_time [time_return_minute $black(anunttime)]
+	set channels ""
+foreach chan [channels] {
+if {[validchan $chan]} {
+if {[setting:get $chan anunt]} {
+	lappend channels $chan
+		}
+	}
+}
+if {$channels != ""} {
+		anunt:time $channels 0
+		timer $return_time anuntpublic:show
+	}	 
+}
+
+proc anunt:time {channels counter} {
+	global black
+	set chan [lindex $channels $counter]
+	set cc [expr $counter + 1]
+if {$chan != ""} {
+	anunt:show $chan
+} 
+if {[lindex $channels $cc] == ""} {
+	return
+} else {
+	anunt:time $channels $cc
+	}
+}
+
+proc anunt:show {chan} {
+	global black
+if {[info exists black(lastaction:$chan)]} {
+	set unixtime [unixtime]
+	set return_time [time_return_minute $black(anunttime)]
+	set time [expr [expr [expr $return_time * $black(entry:shown)] * 60] + $unixtime]
+if {[expr $unixtime - $black(lastaction:$chan)] > [expr $time - $unixtime]} {
+	return
+	}
+} else { return }
+	set timestamp [clock format [clock seconds] -format {%Y%m%d%H%M%S}]
+	set temp_dir "$black(tempdir)/anunt_temp.$timestamp"
+if {![file exists $temp_dir]} {
+	set file [open $temp_dir w]
+	close $file
+}
+	set file [open $black(add_file) "r"]
+	set data [read -nonewline $file]
+	close $file
+if {$data != ""} {
+	set lines [split $data "\n"]
+	set file [open $temp_dir "a"]
+foreach line $lines {
+	set read_chan [lindex [split $line] 0]
+	set enc_chan [encoding convertfrom utf-8 $read_chan]
+	set read_type [lindex [split $line] 1]
+if {[string match -nocase $enc_chan $chan] && [string match -nocase $read_type "ANUNT"]} {
+	puts $file [lrange [split $line] 3 end]
+		}
+	}
+	close $file
+}
+	set file [open $temp_dir "r"]
+	set data [read -nonewline $file]
+	close $file
+if {$data != ""} {
+
+if {![info exists black(anuntshow:$chan)]} {
+	set black(anuntshow:$chan) 0
+}
+	set lines [split $data "\n"]
+	set line [lindex $lines $black(anuntshow:$chan)]
+	
+if {$line == ""} { 
+	set black(anuntshow:$chan) 0
+	set line [lindex $lines $black(anuntshow:$chan)]
+}
+	set split_line [split $line "~"]
+	set black(anuntshow:$chan) [expr $black(anuntshow:$chan) + 1]
+foreach mes $split_line {
+	set encoded [encoding convertto utf-8 $mes]
+	if {$black(anunthow) == "1"} {
+	puthelp "PRIVMSG $chan :\001ACTION [join $encoded]\001"
+} else { 
+	puthelp "PRIVMSG $chan :[join $encoded]"
+			}
+		}
+	}
+	file delete $temp_dir
+}
+
+##############
+#########################################################################
+##   END                                                               ##
+#########################################################################

+ 337 - 0
BlackTools2.5/BlackTools/Modules/BT.AutoBroadcast.tcl

@@ -0,0 +1,337 @@
+#########################################################################
+##          BlackTools - The Ultimate Channel Control Script           ##
+##                    One TCL. One smart Eggdrop                       ##
+#########################################################################
+########################   AUTOBROADCAST 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 broadcastpublic:module {nick host hand chan arg} {
+global black sdir lastbind
+	set chan1 "$chan"
+	set type 0
+	set who [lindex [split $arg] 0]
+	set message [join [lrange [split $arg] 1 end]]
+	set number [lindex [split $arg] 1]
+	set return [blacktools:mychar $lastbind $hand]
+if {$return == "0"} {
+		return
+}
+	broadcast:process $nick $host $hand $chan $chan1 $who $message $number $type
+}
+
+proc broadcast:process {nick host hand chan chan1 who message number type} {
+global botnick black username
+	set cmd_status [btcmd:status $chan $hand "bt" 0]
+if {$cmd_status == "1"} { 
+	return 
+}
+if {[matchattr $hand q]} { blacktools:tell $nick $host $hand $chan $chan1 gl.glsuspend none
+	return
+}
+if {[matchattr $hand -|q $chan]} { blacktools:tell $nick $host $hand $chan $chan1 gl.suspend none
+	return
+}
+	set show_message $message
+	set btnum 0
+	set lin 0
+	set temp_num 0
+	set sdir $black(status_file)
+if {$who == ""} {
+switch $type {
+	0 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr "bt"
+	}
+	1 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr_nick "bt"
+	}
+	2 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr_priv "bt"
+		}
+	}
+	return
+}
+
+switch [string tolower $who] {
+
+on {
+	set type1 "broadcastpublic:show ON"
+foreach tmr [timers] {
+if {[string match "*broadcastpublic:show*" [join [lindex $tmr 1]]]} {
+	blacktools:tell $nick $host $hand $chan $chan1 autobroadcast.3 none
+	return
+	}
+}
+	blacktools:tell $nick $host $hand $chan $chan1 autobroadcast.4 none
+	set file [open $sdir "r"]
+	set database [read -nonewline $file]
+	close $file
+	set data [split $database "\n"]
+foreach line $data {
+	set lin [expr $lin +1]
+	set who [lindex  [split $line] 0]
+	set stats [lindex [split $line] 1]
+if {[string match -nocase "broadcastpublic:show" $who]} {
+if {$line != ""} {
+	set num [expr $lin - 1]
+	set delete [lreplace $data $num $num]
+	set files [open $sdir "w"]
+	puts $files [join $delete "\n"]
+	close $files
+		}
+	}
+}
+	set file [open $sdir "r"]
+	set data [read -nonewline $file]
+	close $file
+if {$data == ""} {	
+	set files [open $sdir "w"]
+	close $files
+}
+	set file [open $sdir "a"]
+	puts $file "$type1"
+	close $file
+	timer $black(bttime) broadcastpublic:show
+	set broadcastpublic:show_running 1
+}
+
+off {
+	blacktools:tell $nick $host $hand $chan $chan1 autobroadcast.5 none
+	set type1 "broadcastpublic:show OFF"
+foreach tmr [timers] {
+if {[string match -nocase "*broadcastpublic:show*" [join [lindex $tmr 1]]]} {
+	killtimer [lindex $tmr 2]
+	}	
+}
+	set file [open $sdir "r"]
+	set database [read -nonewline $file]
+	close $file
+	set data [split $database "\n"]
+foreach line $data {
+	set lin [expr $lin +1]
+	set who [lindex  [split $line] 0]
+	set stats [lindex [split $line] 1]
+if {[string match -nocase "broadcastpublic:show" $who]} {
+if {$line != ""} {
+	set num [expr $lin - 1]
+	set delete [lreplace $data $num $num]
+	set files [open $sdir "w"]
+	puts $files [join $delete "\n"]
+	close $files
+		}	
+	}
+}
+	set file [open $sdir "r"]
+	set data [read -nonewline $file]
+	close $file
+if {$data == ""} {
+	set files [open $sdir "w"]
+	close $files
+}
+	set file [open $sdir "a"]
+	puts $file "$type1"
+	close $file
+if {[info exists broadcastpublic:show_running]} {
+	unset broadcastpublic:show_running
+	}
+}
+
+add {
+if {$message == ""} {
+switch $type {
+	0 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr "bt"
+	}
+	1 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr_nick "bt"
+	}
+	2 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr_priv "bt"
+		}
+	}
+	return
+}
+
+while {$temp_num == 0} {
+	set get [find:num $btnum "-" "AUTOBROADCAST"]
+if {$get == "$btnum"} {
+	set btnum [expr $btnum + 1]
+	} else { set temp_num 1 }
+}
+
+	set file [open $black(add_file) a]
+	set encoded [encoding convertto utf-8 $message]
+	puts $file "- AUTOBROADCAST $btnum $encoded"
+	close $file
+	blacktools:tell $nick $host $hand $chan $chan1 autobroadcast.6 $btnum
+	blacktools:tell $nick $host $hand $chan $chan1 autobroadcast.1 $show_message
+}
+
+list {
+	array set btlist [list]
+	set timestamp [clock format [clock seconds] -format {%Y%m%d%H%M%S}]
+	set temp "$black(tempdir)/bt_temp.$timestamp"
+	set file [open $black(add_file) "r"]
+	set w [read -nonewline $file]
+	close $file
+	set data [split $w "\n"]
+if {$data == ""} { blacktools:tell $nick $host $hand $chan $chan1 autobroadcast.8 none
+	return
+}
+foreach line $data {
+	set read_type [lindex [split $line] 1]
+if {[string equal -nocase $read_type "AUTOBROADCAST"]} {
+	set msg_num [lindex [split $line] 2]
+	set message [join [lrange [split $line] 3 end]]
+lappend btlist($msg_num) $message
+	}	
+}
+	set tempwrite [open $temp "w"]
+foreach msg [lsort -integer -increasing [array names btlist]] {
+	puts $tempwrite "$msg [join $btlist($msg)]"
+}
+	close $tempwrite
+	set file [open $temp "r"]
+	set w [read -nonewline $file]
+	close $file
+	set data [split $w "\n"]
+	file delete $temp
+	module:getinfo $nick $host $hand $chan $chan1 $type $data "autobroadcast" "0" $number
+}
+
+del {
+
+if {![regexp {^[0-9]} $number]} {
+switch $type {
+	0 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr "bt"
+	}
+	1 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr_nick "bt"
+	}
+	2 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr_priv "bt"
+		}
+	}
+	return
+}
+	set ret [find:num $number "-" "AUTOBROADCAST"]
+if {$ret == 0} { 
+	blacktools:tell $nick $host $hand $chan $chan1 autobroadcast.2 $number
+	return
+}
+	set file [open $black(add_file) "r"]
+	set timestamp [clock format [clock seconds] -format {%Y%m%d%H%M%S}]
+	set temp "$black(tempdir)/bt_temp.$timestamp"
+	set tempwrite [open $temp w]
+while {[gets $file line] != -1} {
+	set read_num [lindex [split $line] 2]
+	set read_type [lindex [split $line] 1]
+if {[string equal $number $read_num] && [string equal $read_type "AUTOBROADCAST"]} { 
+	continue
+} else {
+	puts $tempwrite $line
+		}	 
+    }
+	close $tempwrite
+	close $file
+    file rename -force $temp $black(add_file)
+	blacktools:tell $nick $host $hand $chan $chan1 autobroadcast.11 $number		
+		}
+	}
+}
+
+proc broadcastpublic:show {} {
+global black
+if {![info exists black(broadcast:count)]} {
+	set black(broadcast:count) 0
+}
+	set channels ""
+	set line ""
+	set file [open $black(add_file) "r"]
+	set timestamp [clock format [clock seconds] -format {%Y%m%d%H%M%S}]
+	set temp "$black(tempdir)/bt_temp.$timestamp"
+	set tempwrite [open $temp w]
+while {[gets $file line] != -1} {
+	set read_type [lindex [split $line] 1]
+if {[string equal $read_type "AUTOBROADCAST"]} { 
+	set read_message [lrange [split $line] 3 end]
+	puts $tempwrite $read_message
+	}
+}
+	close $tempwrite
+	close $file	
+
+	set file [open $temp "r"]
+	set w [read -nonewline $file]
+	close $file
+	set data [split $w "\n"]
+	
+if {$data != ""} {
+	set line [lindex $data $black(broadcast:count)]
+	
+if {$line == ""} {
+	set black(broadcast:count) 0
+	set line [lindex $data $black(broadcast:count)]
+}
+	set black(broadcast:count) [expr $black(broadcast:count) +1]
+	
+foreach chan [channels] {
+if {[validchan $chan] && [isdynamic $chan] && (![setting:get $chan silent])} {
+	lappend channels $chan
+			}
+		}
+	} else { file delete $temp }
+	file delete $temp
+if {$channels != "" && $line != ""} {
+		broadcast:act $channels 0 $line
+}
+	timer $black(bttime) broadcastpublic:show
+}
+
+proc broadcast:act {channels counter line} {
+	global black
+	set split_line [split $line "~"]
+	set chan [lindex $channels $counter]
+	set cc [expr $counter + 1]
+	set notshow 0
+if {$chan != ""} {
+if {[info exists black(lastaction:$chan)]} {
+	set unixtime [unixtime]
+	set return_time [time_return_minute $black(bttime)]
+	set time [expr [expr [expr $return_time * $black(entry:shown)] * 60] + $unixtime]
+if {[expr $unixtime - $black(lastaction:$chan)] > [expr $time - $unixtime]} {
+	set notshow 1
+	}
+}
+if {$notshow == "0"} {
+foreach mes $split_line {
+	set message [join [lrange [split $mes] 0 end]]
+	set encoded [encoding convertfrom utf-8 $message]
+if {$black(bthow) == "1"} {
+	puthelp "PRIVMSG $chan :\001ACTION [join $encoded]\001"
+} else { 
+	puthelp "PRIVMSG $chan :[join $encoded]"
+			}
+		}
+	}
+}
+
+if {[lindex $channels $cc] == ""} {
+	return 
+	} else {
+	utimer 5 [list broadcast:act $channels $cc $line]
+	}
+}
+
+##############
+#########################################################################
+##   END                                                               ##
+#########################################################################

+ 547 - 0
BlackTools2.5/BlackTools/Modules/BT.BadChan.tcl

@@ -0,0 +1,547 @@
+#########################################################################
+##          BlackTools - The Ultimate Channel Control Script           ##
+##                    One TCL. One smart Eggdrop                       ##
+#########################################################################
+###########################   BADCHAN 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 badchan:getlist {nick host hand chan chan1 type next} {
+	global black
+	set timestamp [clock format [clock seconds] -format {%Y%m%d%H%M%S}]
+	set temp "$black(tempdir)/badchan_temp.$timestamp"
+	array set badchanlist [list]
+	set file [open $black(add_file) "r"]
+	set w [read -nonewline $file]
+	close $file
+	set data [split $w "\n"]
+foreach line $data {
+	set read_chan [lindex [split $line] 0]
+	set enc_chan [encoding convertfrom utf-8 $read_chan]
+	set read_type [lindex [split $line] 1]
+if {[string match -nocase $enc_chan $chan] && [string match -nocase $read_type "BADCHAN"]} {
+	set msg_num [lindex [split $line] 2]
+	set bdchan [lindex [split $line] 3]
+	lappend badchanlist($msg_num) $bdchan
+	}
+}
+	set tempwrite [open $temp w]
+foreach msg [lsort -integer -increasing [array names badchanlist]] {
+	puts $tempwrite "$msg [join $badchanlist($msg)]"
+}
+	close $tempwrite
+	set file [open $temp "r"]
+	set w [read -nonewline $file]
+	close $file
+	set data [split $w "\n"]
+	file delete $temp
+if {[string equal -nocase $chan "GLOBAL"]} {
+	module:getinfo $nick $host $hand $chan $chan1 $type $data "badchan" "1" $next
+	} else {
+	module:getinfo $nick $host $hand $chan $chan1 $type $data "badchan" "0" $next
+	}
+}
+
+proc badchan:delchan {nick host hand chan chan1 number} {
+	global black
+	
+if {![regexp {^[0-9]} $number]} {
+	if {$type == "0"} {	
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr "badchan"
+}
+if {$type == "1"} {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr_nick "badchan"	
+}
+	return
+}
+	set ret [find:num $number $chan "BADCHAN"]
+if {$ret == 0} { 
+	blacktools:tell $nick $host $hand $chan $chan1 badchan.17 $number
+	return
+}
+	set file [open $black(add_file) "r"]
+	set timestamp [clock format [clock seconds] -format {%Y%m%d%H%M%S}]
+	set temp "$black(tempdir)/badchan_temp.$timestamp"
+	set tempwrite [open $temp w]
+while {[gets $file line] != -1} {
+	set read_num [lindex [split $line] 2]
+	set read_chan [lindex [split $line] 0]
+	set read_type [lindex [split $line] 1]
+	set enc_chan [encoding convertfrom utf-8 $read_chan]
+if {[string equal $number $read_num] && [string equal -nocase $chan $enc_chan] && [string equal -nocase $read_type "BADCHAN"]} {
+	continue
+} else {
+	puts $tempwrite $line
+		}	 
+    }
+	close $tempwrite
+	close $file
+    file rename -force $temp $black(add_file)
+if {[string equal -nocase $chan "GLOBAL"]} {
+	blacktools:tell $nick $host $hand $chan $chan1 badchan.19 $number	
+} else {
+	blacktools:tell $nick $host $hand $chan $chan1 badchan.18 $number
+	}
+}
+
+proc badchanpublic {nick host hand chan arg} {
+global black lastbind
+	set return [blacktools:mychar $lastbind $hand]
+if {$return == "0"} {
+		return
+}
+	set why [lindex [split $arg] 0]
+	set type1 0
+	set chan1 "$chan"
+	set bdchan [lindex [split $arg] 1]
+	set type [lindex [split $arg] 2]
+	set reason [join [lrange [split $arg] 2 end]]
+if {[string equal -nocase $type "global"]} {
+	set reason [join [lrange [split $arg] 3 end]]
+}
+if {[regexp {^[&#]} $why] && [matchattr $hand nm|M $why]} {
+	set chan "$why"
+	set why [lindex [split $arg] 1]
+	set bdchan [lindex [split $arg] 2]
+	set type [lindex [split $arg] 3]
+	set reason [join [lrange [split $arg] 3 end]]
+if {[string equal -nocase $type "global"]} {
+	set reason [join [lrange [split $arg] 4 end]]
+	}
+}
+	badchan:process $nick $host $hand $chan $chan1 $why $bdchan $type1 $type $reason
+}
+
+proc badchan:process {nick host hand chan chan1 why bdchan type1 type reason} {
+	global botnick black
+	set cmd_status [btcmd:status $chan $hand "badchan" 0]
+if {$cmd_status == "1"} { 
+	return 
+}
+if {[matchattr $hand q]} { blacktools:tell $nick $host $hand $chan $chan1 gl.glsuspend none
+	return
+}
+if {[matchattr $hand -|q $chan]} { blacktools:tell $nick $host $hand $chan $chan1 gl.suspend none
+	return
+}
+	set show_bdchan $bdchan
+	set cmd "badchan"
+	set num 0
+	set temp_num 0
+	set gl 0
+	set getlang [string tolower [setting:get $chan lang]]
+if {$getlang == ""} { set getlang "[string tolower $black(default_lang)]" }
+
+switch $why {
+	on {
+foreach tmr [timers] {
+if {[string match "*badchan:scantimer*" [join [lindex $tmr 1]]]} {
+if {[setting:get $chan antibadchan]} {
+	blacktools:tell $nick $host $hand $chan $chan1 badchan.43 none
+	return
+		} else {
+	setting:set $chan +antibadchan ""
+	blacktools:tell $nick $host $hand $chan $chan1 badchan.6 none
+	return
+		}
+	}	 
+}
+	set bscan_time [time_return_minute $black(badchan:scantime)]
+	timer $bscan_time badchan:scantimer
+	setting:set $chan +antibadchan ""
+	blacktools:tell $nick $host $hand $chan $chan1 badchan.6 none
+}
+
+off {
+	setting:set $chan -antibadchan ""
+	blacktools:tell $nick $host $hand $chan $chan1 badchan.8 none
+}
+
+add {
+if {![validchan $chan] && ![string equal -nocase $type "global"]} {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.novalidchan none
+	return
+}
+if {![regexp {^[&#]} $bdchan]} {
+switch $type1 {
+	0 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr "badchan"
+	}
+	1 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr_nick "badchan"
+	}
+	2 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr_priv "badchan"
+		}
+	}
+	return
+}
+	set findchan [prot:findbadchan $chan $bdchan]
+if {$findchan == "1"} {
+	blacktools:tell $nick $host $hand $chan $chan1 badchan.1 $show_bdchan
+	return
+}
+
+if {$reason == ""} {
+	set reason "$black(say.$getlang.badchan.5)"
+}
+	set reason [join [encoding convertto utf-8 $reason]]
+if {[matchattr $hand mn] && [string equal -nocase $type "global"]} {
+	set findchan [prot:findbadchan "GLOBAL" $bdchan]
+if {$findchan == "1"} {
+	blacktools:tell $nick $host $hand $chan $chan1 badchan.42 $show_bdchan
+	return
+}
+	while {$temp_num == 0} {
+	set get [find:num $num "GLOBAL" "BADCHAN"]
+if {$get == "$num"} {
+	set num [expr $num + 1]
+	} else { set temp_num 1 }
+}	
+	set file [open $black(add_file) a]
+	puts $file "GLOBAL BADCHAN $num $bdchan $reason"
+	close $file
+	set gl 1
+	blacktools:tell $nick $host $hand $chan $chan1 badchan.11  "$show_bdchan $num"
+	return
+} 
+	while {$temp_num == 0} {
+	set get [find:num $num $chan "BADCHAN"]
+if {$get == "$num"} {
+	set num [expr $num + 1]
+	} else { set temp_num 1 }
+}
+	set encoded [encoding convertto utf-8 $bdchan]
+	set enc_chan [encoding convertto utf-8 $chan]
+	set file [open $black(add_file) a]
+	puts $file "$enc_chan BADCHAN $num $encoded $reason"
+	close $file
+	set gl 0
+	blacktools:tell $nick $host $hand $chan $chan1 badchan.12  "$show_bdchan $num"
+}
+
+list {
+if {![validchan $chan] && ![string equal -nocase $bdchan "global"]} {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.novalidchan none
+	return
+}
+if {[string equal -nocase $bdchan "global"] && [matchattr $hand nm]} {
+	badchan:getlist $nick $host $hand "GLOBAL" $chan1 $type1 $type
+	return
+	}
+	badchan:getlist $nick $host $hand $chan $chan1 $type1 $bdchan
+}
+
+del {
+if {![validchan $chan] && ![string equal -nocase $type "global"]} {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.novalidchan none
+	return
+}
+if {![regexp {^[0-9]} $bdchan]} {
+switch $type1 {
+	0 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr "badchan"
+	}
+	1 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr_nick "badchan"
+	}
+	2 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr_priv "badchan"
+		}
+	}
+	return
+}
+if {[string equal -nocase $type "global"] && [matchattr $hand nm]} {
+	badchan:delchan $nick $host $hand "GLOBAL" $chan1 $bdchan
+	return
+}
+	badchan:delchan $nick $host $hand $chan $chan1 $bdchan
+}
+
+default {
+switch $type1 {
+	0 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr "badchan"
+	}
+	1 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr_nick "badchan"
+	}
+	2 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr_priv "badchan"
+		}
+	}
+	return
+		}
+	}
+}
+
+proc prot:findbadchan {chan word} {
+	global black
+	set found_it 0
+	set file [open $black(add_file) "r"]
+	set w [read -nonewline $file]
+	close $file
+	set data [split $w "\n"]
+foreach line $data {
+	set read_chan [lindex [split $line] 0]
+	set enc_chan [encoding convertfrom utf-8 $read_chan]
+	set read_type [lindex [split $line] 1]
+	set b [lindex [split $line] 3]
+	set enc_bchan [encoding convertfrom utf-8 $b]
+if {[string match -nocase $enc_chan $chan] && [string match -nocase $read_type "BADCHAN"] && [string equal -nocase $word $enc_bchan]} {
+	set found_it 1
+		}
+	}
+	return $found_it
+}
+
+proc badchanpublic:join {nick host hand chan} {
+	global black
+	set ::bad_chan $chan
+if {![validchan $chan]} { return }
+if {[matchattr $hand $black(exceptflags) $chan]} {
+	return
+}
+if {(![botisop $chan]) && (![setting:get $chan xonly])} { return }
+if {[isbotnick $nick]} { return }
+if {[setting:get $chan antibadchan]} {
+	utimer 5 [list putserv "WHOIS $nick"]
+	bind RAW - 319 badchan:execute
+	}
+}
+
+proc badchan:scantimer {} {
+	global black
+	set badchanscan_list ""
+foreach chan [channels] {
+if {[validchan $chan]} {
+if {[setting:get $chan antibadchan]} {
+foreach nick [chanlist $chan] {
+	set hand [nick2hand $nick]
+if {[isbotnick $nick]} { continue  }
+if {[matchattr $hand $black(exceptflags) $chan]} {
+	continue
+}
+	set bl_protect [blacktools:protect $nick $chan]
+if {$bl_protect == "1"} { continue }
+	set position [lsearch -exact [string tolower $badchanscan_list] "[string tolower $nick]:[string tolower $chan]"]
+if {$position < 0} {
+	lappend badchanscan_list "$nick:$chan"
+					}
+				}
+			}
+		}	
+	}
+if {$badchanscan_list != ""} {
+	badchan:scan $badchanscan_list
+	set bscan_time [time_return_minute $black(badchan:scantime)]
+	timer $bscan_time badchan:scantimer
+	}
+}
+
+proc badchan:scan {badchanlist} {
+	global black
+if {![info exists black(badchan:scan:counter)]} {
+	set black(badchan:scan:counter) 0 
+}
+	set person [lindex $badchanlist $black(badchan:scan:counter)]
+if {$person == ""} {
+	unset black(badchan:scan:counter)
+	return
+}
+	set black(badchan:scan:counter) [expr $black(badchan:scan:counter) + 1]
+	set split_person [split $person ":"]
+	set nick [lindex $split_person 0]
+	set channel [lindex $split_person 1]
+	set ::bad_chan $channel
+	putserv "WHOIS $nick"
+	bind RAW - 319 badchan:execute
+	utimer 10 [list badchan:scan $badchanlist]
+}
+
+proc badchan:execute {from keyword arguments } {
+global botnick badchan black
+	set chan $::bad_chan
+	set cmd "badchan"
+	set file_found 0
+	set chan1 $chan
+	set arguments [split $arguments]
+	set nick [string tolower [lindex $arguments 1]]
+	set channels [string tolower [lrange $arguments 2 end]]
+	set banmask [return_mask [return_host_num $cmd $chan] [getchanhost $nick $chan] $nick]
+	set getlang [string tolower [setting:get $chan lang]]
+if {$getlang == ""} { set getlang "[string tolower $black(default_lang)]" }
+if {![onchan $nick $chan]} {
+	return
+}
+	set bl_protect [blacktools:protect $nick $chan]
+if {$bl_protect == "1"} { return }
+
+	set file [open $black(add_file) "r"]
+	set database [read -nonewline $file]
+	set data [split $database "\n"]
+	close $file
+foreach line $data {
+	set mainchan [lindex [split $line] 0]
+	set read_type [lindex [split $line] 1]
+if {([string equal -nocase $chan $mainchan] || [string equal -nocase "GLOBAL" $mainchan]) && [string equal -nocase $read_type "BADCHAN"]} {
+		set readchan [lindex [split $line] 3]
+		set encoded [encoding convertfrom utf-8 $readchan]
+foreach c [join $channels] {
+	set ch [string trimleft $c ":@+"]
+if {[string match -nocase $encoded $ch]} {
+	set file_found 1
+	set reason [lrange [split $line] 4 end]
+	set badchan($banmask:$chan) $reason
+	set badchan(channels:$banmask:$chan) $encoded
+			}			
+		}
+	}
+}
+
+if {$file_found == "0"} {
+foreach defchan $black(badcchannels) {
+	set encoded [encoding convertfrom utf-8 $defchan]
+foreach c [join $channels] {
+	set ch [string trimleft $c ":@+"]
+if {[string match -nocase $encoded $ch]} {
+	set badchan(channels:$banmask:$chan) $encoded
+	set badchan($banmask:$chan) $black(say.$getlang.badchan.5)
+			}
+		}
+	}
+}
+
+if {[info exists badchan($banmask:$chan)]} {
+if {[string equal -nocase $badchan($banmask:$chan) $black(say.$getlang.badchan.5)]} {
+if {[setting:get $chan badchan-reason] != ""} {
+	set getreason [join [setting:get $chan badchan-reason]]
+} else {
+	set getreason $black(say.$getlang.badchan.5)
+	}
+} else {
+	set getreason [join $badchan($banmask:$chan)]
+}
+	
+if {[info exists badchan(checkagain:$banmask:$chan)]} {
+if {[info exists badchan($banmask:$chan)]} {
+	blacktools:banner:2 $nick "BADCHAN:[encoding convertto utf-8 $badchan(channels:$banmask:$chan)]" $chan $chan1 [getchanhost $nick $chan] "0"
+	unset badchan(checkagain:$banmask:$chan)
+	unset badchan($banmask:$chan)
+	unset badchan(channels:$banmask:$chan)
+	return
+}
+	unset badchan(checkagain:$banmask:$chan)
+	return
+	}
+}
+if {[info exists badchan($banmask:$chan)]} {
+if {[setting:get $chan badchan-bmethod] == "0" || [setting:get $chan badchan-bmethod] == ""} {
+	set bmethod $black(badcbanmethod)
+} else { set bmethod [setting:get $chan badchan-bmethod] }
+if {$bmethod == "2"} {
+	blacktools:banner:2 $nick "BADCHAN:[encoding convertto utf-8 $badchan(channels:$banmask:$chan)]" $chan $chan1 [getchanhost $nick $chan] "0"
+	unset badchan($banmask:$chan)
+	unset badchan(channels:$banmask:$chan)
+	return
+}
+	set replace(%badchans%) [join $badchan(channels:$banmask:$chan) ", "]
+	set get_message $black(say.$getlang.badchan.40)
+	set message [string map [array get replace] $get_message]
+	putquick "PRIVMSG $nick :\[$chan\] $message"
+	utimer 30 [list badchan:check:again $nick $chan]
+	unset badchan($banmask:$chan)
+	unset badchan(channels:$banmask:$chan)
+	set badchan(checkagain:$banmask:$chan) 1
+} else {
+if {[info exists badchan(checkagain:$banmask:$chan]} {
+	unset badchan(checkagain:$banmask:$chan
+}
+if {[info exists badchan($banmask:$chan)]} {
+	unset badchan($banmask:$chan)
+}
+if {[info exists badchan(channels:$banmask:$chan)]} {
+	unset badchan(channels:$banmask:$chan)
+		}
+	}
+	unbind RAW - 319 badchan:execute
+}
+
+proc badchan:check:again {nick chan} {
+	global black badchan
+	putserv "WHOIS $nick"
+	set ::bad_chan $chan
+	bind RAW - 319 badchan:execute
+}
+
+proc badchan:nickchange {nick host hand chan newnick} { 
+	global badchan
+	set found_time 0
+	set current_time ""
+foreach tmr [utimers] {
+if {[string match -nocase "*badchan:check:again $nick $chan*" [join [lindex $tmr 1]]]} {
+	set current_time [get:timer:time $nick $chan]
+	set found_time 1
+killutimer [lindex $tmr 2]
+	}
+}
+if {$found_time == "1"} {
+	utimer $current_time [list badchan:check:again $newnick $chan] 
+	}
+}
+
+proc badchan:split {nick host hand chan args} {
+	global badchan	
+	badchan:part $nick $host $hand $chan "none"
+}
+
+proc badchan:kick {nick host hand chan kicked reason} {
+	global badchan
+	badchan:part $kicked $host $hand $chan "none"	
+}
+
+proc badchan:part {nick host hand chan arg} {
+	global badchan
+if {![validchan $chan]} { return }
+	set banmask *!*@[lindex [split [getchanhost $nick $chan] "@"] 1]	
+foreach tmr [utimers] {
+if {[string match -nocase "*badchan:check:again $nick $chan*" [join [lindex $tmr 1]]]} {
+killutimer [lindex $tmr 2]
+	}
+}
+
+if {[info exists badchan(checkagain:$banmask:$chan)]} {
+	unset badchan(checkagain:$banmask:$chan)
+}
+
+if {[info exists badchan($banmask:$chan)]} {
+	unset badchan($banmask:$chan)
+}
+
+if {[info exists badchan(channels:$banmask:$chan)]} {
+	unset badchan(channels:$banmask:$chan)
+	}	
+}
+
+proc get:timer:time {nick chan} {
+	global scrabble
+	set time_left 0
+foreach tmr [utimers] {
+if {[string match -nocase "*badchan:check:again $nick $chan*" [join [lindex $tmr 1]]]} {
+	set time_left [lindex $tmr 0]
+	}
+}
+	return $time_left
+}
+
+##############
+#########################################################################
+##   END                                                               ##
+#########################################################################

+ 189 - 0
BlackTools2.5/BlackTools/Modules/BT.ChanLink.tcl

@@ -0,0 +1,189 @@
+#########################################################################
+##          BlackTools - The Ultimate Channel Control Script           ##
+##                    One TCL. One smart Eggdrop                       ##
+#########################################################################
+###########################   CHANLINK 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 linkpublic {nick host hand chan arg} {
+	global black lastbind
+	set type 0
+	set what [lindex [split $arg] 0]
+	set channels [lrange [split $arg] 0 end]
+	set delchan [lindex [split $arg] 1]
+	set chan1 $chan
+	set return [blacktools:mychar $lastbind $hand]
+if {$return == "0"} {
+		return
+}
+	link:process $nick $host $hand $chan $chan1 $type $what $channels $delchan
+}
+
+proc link:process {nick host hand chan chan1 type what channels delchan} {
+	global black
+	
+if {$what == ""} {
+		switch $type {
+	0 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr "link"
+	}
+	1 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr_nick "link"
+	}
+	2 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr_priv "link"
+		}
+	}
+}
+
+switch $what {
+
+list {
+	set return [link:show]
+if {$return == "0"} {
+	blacktools:tell $nick $host $hand $chan $chan1 chanlink.5 none
+	return
+}
+	blacktools:tell $nick $host $hand $chan $chan1 chanlink.3 [join $return]
+}
+
+reset {
+	link:reset
+	blacktools:tell $nick $host $hand $chan $chan1 chanlink.2 none
+}
+
+all {
+	link:set $what
+	blacktools:tell $nick $host $hand $chan $chan1 chanlink.4 none
+}
+
+del {
+if {![validchan $delchan]} {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.novalidchan none
+	return
+}
+	set return [link:del $delchan]
+if {$return == "1"} {
+	blacktools:tell $nick $host $hand $chan $chan1 chanlink.7 $delchan
+	} else {
+	blacktools:tell $nick $host $hand $chan $chan1 chanlink.8 $delchan
+	}
+}
+
+default {
+	set return [link:set $channels]
+	set split_return [split $return ":"]
+	set validchan [lindex $split_return 0]
+	set notvalid [lindex $split_return 1]
+if {$validchan != ""} {
+	blacktools:tell $nick $host $hand $chan $chan1 chanlink.1 [join $validchan]
+	}
+if {$notvalid != ""} {
+	blacktools:tell $nick $host $hand $chan $chan1 chanlink.6 $notvalid
+			}
+		}
+	}
+}
+
+proc link:show {} {
+	global black botnick
+	set return [link:get]
+if {$return == ""} {
+	return 0
+	}
+	return $return
+}
+
+proc link:set {channels} {
+	global black botnick
+	set validchan ""
+	set notvalid ""
+if {[string equal -nocase $channels "all"]} {
+	foreach chan [channels] {
+if {[setting:get $chan chanlink] == "0"} {
+	setting:set $chan +chanlink ""
+		}
+	}
+	return 1
+}
+foreach chan $channels {
+if {[validchan $chan]} {
+	lappend validchan $chan
+if {[setting:get $chan chanlink] == "0"} {
+	setting:set $chan +chanlink ""
+		}
+	} else {
+	lappend notvalid $chan
+	}
+}
+	return "$validchan:$notvalid"
+}
+
+proc link:reset {} {
+	global black botnick
+	foreach chan [channels] {
+if {[setting:get $chan chanlink]} {
+	setting:set $chan -chanlink ""
+		}
+	}
+}
+
+proc link:del {chan} {
+	global black
+if {[setting:get $chan chanlink]} {
+	setting:set $chan -chanlink ""
+	return 1
+	} else {	
+	return 0
+	}
+}
+
+proc link:get {} {
+	global black botnick
+	set channels ""
+foreach chan [channels] {
+if {[setting:get $chan chanlink]} {
+	lappend channels $chan
+		}
+	}
+	return $channels
+}
+
+proc link:status {chan} {
+	global black
+if {[setting:get $chan chanlink]} {	
+	return 1
+	} else {
+	return 0
+	}
+}
+
+proc link:chan:get {readchan} {
+	global black
+	set channels ""
+	set readchan [string tolower $readchan]
+if {[setting:get $readchan chanlink] == "0"} {
+	return ""
+}
+	foreach chan [string tolower [channels]] {
+if {[setting:get $chan chanlink]} {	
+if {$readchan != $chan} {
+	lappend channels $chan
+			}
+		}
+	}
+	return $channels
+}
+
+##############
+#########################################################################
+##   END                                                               ##
+#########################################################################

+ 156 - 0
BlackTools2.5/BlackTools/Modules/BT.CloneScan.tcl

@@ -0,0 +1,156 @@
+#########################################################################
+##          BlackTools - The Ultimate Channel Control Script           ##
+##                    One TCL. One smart Eggdrop                       ##
+#########################################################################
+###########################   CLONESCAN 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 clonescan:module {nick host hand chan arg} {
+	global black lastbind
+	set return [blacktools:mychar $lastbind $hand]
+if {$return == "0"} {
+		return
+}
+	set why [lindex [split $arg] 0]
+	set type 0
+if {[matchattr $hand nmo|M $chan] && ($why != "") && ![regexp {^[&#]} $why]} {
+	set chan1 "$chan"
+	set clone [join [lrange [split $arg] 1 end]]
+	set number [lindex [split $arg] 1]
+if {[regexp {^[&#]} $why]} {
+	set chan "$why"
+	set why [lindex [split $arg] 1]
+	set clone [join [lrange [split $arg] 2 end]]
+	set number [lindex [split $arg] 2]
+}
+	prot:module:process $nick $host $hand $chan $chan1 $why $clone $type $number "clonescan"
+	return
+}
+	set c [lindex [split $arg] 0]
+	set type 0
+	set chan1 "$chan"
+if {[regexp {^[&#]} $c] && [matchattr $hand nmo|M $c]} {
+	set chan "$c"
+}
+	scanner:process $nick $host $hand $chan $chan1 $type
+}
+
+proc scanner:process {nick host hand chan chan1 type} {
+global botnick black
+	set cmd_status [btcmd:status $chan $hand "clonescan" 0]
+if {$cmd_status == "1"} { 
+	return 
+}
+	array set clones [list]
+	if {$chan == ""} {
+switch $type {
+	0 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr "clonescan"
+	}
+	1 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr_nick "clonescan"
+	}
+	2 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr_priv "clonescan"
+		}
+	}
+	return 0
+}
+if {![validchan $chan]} {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.novalidchan none
+	return
+}
+if {![onchan $botnick $chan]} {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.notonchan none
+	return
+}
+	blacktools:tell $nick $host $hand $chan $chan1 clonescan.11 none
+	clonescan:act $chan $nick $hand $chan1 $type 0
+}
+
+proc clonescan:timer {} {
+	global black
+	set channels ""
+	set type 1
+foreach chan [channels] {
+if {[validchan $chan]} {
+if {[setting:get $chan clonescan]} {
+	lappend channels $chan
+			}
+		}
+	}
+if {$channels != ""} {
+	clonescan:act $channels "nick" "" "chan1" $type 0
+	set clonescan_time [time_return_minute $black(clonescantime)]
+	timer $clonescan_time clonescan:timer
+	}
+}
+
+proc clonescan:act {channels nick hand chan1 type counter} {
+	global black
+	set chan [lindex $channels $counter]
+	set cc [expr $counter + 1]
+	set found_clones 0
+	array set clones [list]
+if {$chan != ""} {
+	set replace(%chan%) $chan
+	set getlang [string tolower [setting:get $chan lang]]
+if {$getlang == ""} { set getlang "[string tolower $black(default_lang)]" }
+if {[setting:get $chan clonescan-maxclone] == "0" || [setting:get $chan clonescan-maxclone] == ""} {
+	set maxclone $black(maxclone)
+} else { set maxclone [setting:get $chan clonescan-maxclone] }
+if {$maxclone < "2"} { return }
+	putlog "\[BT\] Scaning for clones on $chan.."
+foreach user [chanlist $chan] {
+	set host [string tolower [lindex [split [getchanhost $user $chan] @] 1]]
+	set findword [prot:findword $chan "CLONESCAN-EXCEPT" $host]
+if {$findword == "1"} {
+	continue
+}
+if {[string match "*undernet.org*" $host]} {
+	continue
+}
+
+	set replace(%host%) $host
+	lappend clones($host) $user
+}
+foreach clone [array names clones] {
+	set userlist [join $clones($clone)]
+if {[llength [split $userlist]] >= $maxclone} {
+	set found_clones 1
+if {$type == "0"} {
+	blacktools:tell $nick "" $hand $chan $chan1 clonescan.10 "[llength [split $userlist]] $clone [join $clones($clone) ", "]"
+				}
+if {$type == "1"} {
+	set replace(%msg.1%) [llength [split $userlist]]
+	set replace(%msg.2%) $clone
+	set replace(%msg.7%) [join $clones($clone) ", "]
+	set replace(%chan%) $chan
+	set message [string map [array get replace] $black(say.$getlang.clonescan.10)]
+	putserv "NOTICE @$chan :$message"
+	set mask "*!*@$clone"
+	blacktools:banner:2 $nick "CLONESCAN" $chan $chan1 $mask "0"
+				}
+			} 
+		}	
+	}
+if {([lindex $channels $cc] != "") && ($type == "1")} {
+	utimer 5 [list clonescan:act $channels $nick $hand $chan1 $type $cc]
+		}
+if {($type == "0") && ($found_clones == "0")} {
+	blacktools:tell $nick "" $hand $chan $chan1 clonescan.2 none
+	}
+}
+
+##############
+#########################################################################
+##   END                                                               ##
+#########################################################################

+ 644 - 0
BlackTools2.5/BlackTools/Modules/BT.Egg.tcl

@@ -0,0 +1,644 @@
+#########################################################################
+##          BlackTools - The Ultimate Channel Control Script           ##
+##                    One TCL. One smart Eggdrop                       ##
+#########################################################################
+##############################   EGG 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 eggpublic {nick host hand chan arg} {
+	global black lastbind
+	set type [lindex [split $arg] 0]
+	set result [join [lrange [split $arg] 1 end]]
+	set chan1 $chan
+	set type2 0
+	set return [blacktools:mychar $lastbind $hand]
+if {$return == "0"} {
+		return
+}
+	egg:process $type $type2 $result $nick $hand $host $chan $chan1 
+}
+
+proc egg:show {what getinfo nick host hand chan chan1 type} {
+	global black
+	switch $type {
+	0 {
+	blacktools:tell $nick $host $hand $chan $chan1 egg.2 "$what $getinfo"
+	}
+	1 {
+	blacktools:tell $nick $host $hand $chan $chan1 egg.8 "$what $getinfo"
+	}
+	2 {
+	blacktools:tell $nick $host $hand $chan $chan1 egg.7 "$what $getinfo"
+		}
+	}
+}
+
+
+proc egg:process {type type2 result unick hand host chan chan1} {
+	global black config nick botnick
+	set cmd_status [btcmd:status $chan $hand "egg" 0]
+if {$cmd_status == "1"} { 
+	return 
+}
+	set tcl_config $black(tclconfig)
+
+if {$type == ""} {
+switch $type2 {
+	0 {
+	blacktools:tell $unick $host $hand $chan $chan1 gl.instr "egg"
+	}
+	1 {
+	blacktools:tell $unick $host $hand $chan $chan1 gl.instr_nick "egg"
+	}
+	2 {
+	blacktools:tell $unick $host $hand $chan $chan1 gl.instr_priv "egg"
+		}
+	}
+	return 0
+}
+
+switch [string tolower $type] {
+
+nick {
+	set result [string map [list \[ {\[} \] {\]} \? {\?} \\ {\\}] $result]
+if {$result == ""} {
+	set get_info [config:getinfo $config "set nick \"*\""]
+	egg:show $type $get_info $unick $host $hand $chan $chan1 $type2
+	return
+	}
+	set ::lastnick [config:getinfo $config "set nick \"*\""]
+	set error [config:save $config "set nick \"*\"" "set nick \"$result\""]
+	set result [string map [list {\[} \[ {\]} \] {\?} \? {\\} \\] $result]
+	set nick [join $result]
+if {$error == "0"} {
+	blacktools:tell $unick $host $hand $chan $chan1 egg.4 "nick"
+	return
+}
+	bind RAW - 432 check:validnickname
+	blacktools:tell $unick $host $hand $chan $chan1 egg.3 "nick"
+}
+
+realname {
+	set result [string map [list \[ {\[} \] {\]} \? {\?} \\ {\\}] $result]
+if {$result == ""} {
+	set get_info [config:getinfo $config "set realname \"*\""]
+	egg:show $type $get_info $unick $host $hand $chan $chan1 $type2
+	return
+	}
+	set error [config:save $config "set realname \"*\"" "set realname \"$result\""]
+if {$error == "0"} {
+	blacktools:tell $unick $host $hand $chan $chan1 egg.4 "realname"
+	return
+	}
+	blacktools:tell $unick $host $hand $chan $chan1 egg.3 "realname"
+}
+
+homechan {
+	set result [string map [list \[ {\[} \] {\]} \? {\?} \\ {\\}] $result]
+if {$result == ""} {
+	set get_info [config:getinfo $tcl_config "set black(homechan) \"*\""]
+	egg:show $type $get_info $unick $host $hand $chan $chan1 $type2
+	return
+	}
+	set error [config:save $tcl_config "set black(homechan) \"*\"" "set black(homechan) \"$result\""]
+if {$error == "0"} {
+	blacktools:tell $unick $host $hand $chan $chan1 egg.4 "mainchan"
+	return
+	}
+	blacktools:tell $unick $host $hand $chan $chan1 egg.3 "mainchan"
+}
+
+chanserv {
+if {$result == ""} {
+	set get_info [config:getinfo $tcl_config "set black(chanserv) \"*\""]
+	egg:show $type $get_info $unick $host $hand $chan $chan1 $type2
+	return
+	}
+	set error [config:save $tcl_config "set black(chanserv) \"*\"" "set black(chanserv) \"$result\""]
+if {$error == "0"} {
+	blacktools:tell $unick $host $hand $chan $chan1 egg.4 "chanserv"
+	return
+	}
+	blacktools:tell $unick $host $hand $chan $chan1 egg.3 "chanserv"
+}
+
+hostchanserv {
+if {$result == ""} {
+	set get_info [config:getinfo $tcl_config "set black(hostchanserv) \"*\""]
+	egg:show $type $get_info $unick $host $hand $chan $chan1 $type2
+	return
+	}
+	set error [config:save $tcl_config "set black(hostchanserv) \"*\"" "set black(hostchanserv) \"$result\""]
+if {$error == "0"} {
+	blacktools:tell $unick $host $hand $chan $chan1 egg.4 "hostchanserv"
+	return
+	}
+	blacktools:tell $unick $host $hand $chan $chan1 egg.3 "hostchanserv"
+}
+
+userlogin {
+	set result [string map [list \[ {\[} \] {\]} \? {\?} \\ {\\}] $result]
+if {$result == ""} {
+	set get_info [config:getinfo $tcl_config "set black(username) \"*\""]
+	egg:show $type $get_info $unick $host $hand $chan $chan1 $type2
+	return
+	}
+	set error [config:save $tcl_config "set black(username) \"*\"" "set black(username) \"$result\""]
+if {$error == "0"} {
+	blacktools:tell $unick $host $hand $chan $chan1 egg.4 "userlogin"
+	return
+	}
+	blacktools:tell $unick $host $hand $chan $chan1 egg.3 "userlogin"
+}
+
+userpass {
+	set result [string map [list \[ {\[} \] {\]} \? {\?} \\ {\\}] $result]
+if {$result == ""} {
+	set get_info [config:getinfo $tcl_config "set black(password) \"*\""]
+	egg:show $type $get_info $unick $host $hand $chan $chan1 $type2
+	return
+	}
+	set error [config:save $tcl_config "set black(password) \"*\"" "set black(password) \"$result\""]
+if {$error == "0"} {
+	blacktools:tell $unick $host $hand $chan $chan1 egg.4 "userpass"
+	return
+	}
+	blacktools:tell $unick $host $hand $chan $chan1 egg.3 "userpass"
+}
+
+add-mask {
+if {$result == ""} {
+	set get_info [config:getinfo $tcl_config "set black(hostadd) \"*\""]
+	egg:show $type $get_info $unick $host $hand $chan $chan1 $type2
+	return
+	}
+	set error [config:save $tcl_config "set black(hostadd) \"*\"" "set black(hostadd) \"$result\""]
+if {$error == "0"} {
+	blacktools:tell $unick $host $hand $chan $chan1 egg.4 "addmask"
+	return
+	}
+	blacktools:tell $unick $host $hand $chan $chan1 egg.3 "addmask"
+	rehash
+}
+
+user-expire {
+if {$result == ""} {
+	set get_info [config:getinfo $tcl_config "set black(user_expire_time) \"*\""]
+	egg:show $type $get_info $unick $host $hand $chan $chan1 $type2
+	return
+	}
+	set error [config:save $tcl_config "set black(user_expire_time) \"*\"" "set black(user_expire_time) \"$result\""]
+if {$error == "0"} {
+	blacktools:tell $unick $host $hand $chan $chan1 egg.4 "user-expire"
+	return
+	}
+	blacktools:tell $unick $host $hand $chan $chan1 egg.3 "user-expire"
+	rehash
+}
+
+cmdchar {
+if {$result == ""} {
+	set get_info [config:getinfo $tcl_config "set black(cmdchar) \"*\""]
+	egg:show $type $get_info $unick $host $hand $chan $chan1 $type2
+	return
+	}
+	set error [config:save $tcl_config "set black(cmdchar) \"*\"" "set black(cmdchar) \"$result\""]
+if {$error == "0"} {
+	blacktools:tell $unick $host $hand $chan $chan1 egg.4 "cmdchar"
+	return
+	}
+	blacktools:tell $unick $host $hand $chan $chan1 egg.3 "cmdchar"
+	rehash
+}
+
+defaultlang {
+if {$result == ""} {
+	set get_info [config:getinfo $tcl_config "set black(default_lang) \"*\""]
+	egg:show $type $get_info $unick $host $hand $chan $chan1 $type2
+	return
+	}
+	set found_lang 0
+	set get_lang_files [glob -directory "$black(dirname)/BlackTools/lang" "*lang.tcl"]
+foreach lang $get_lang_files {
+	set split_lang [split $lang "."]
+	set the_lang [lindex $split_lang 1]
+if {[string equal -nocase $result $the_lang]} {
+	set found_lang 1
+	}
+}
+if {$found_lang == 0} {
+	blacktools:tell $unick $host $hand $chan $chan1 egg.5 "defaultlang $result"
+	return
+}
+	set error [config:save $tcl_config "set black(default_lang) \"*\"" "set black(default_lang) \"$result\""]
+if {$error == "0"} {
+	blacktools:tell $unick $host $hand $chan $chan1 egg.4 "defaultlang"
+	return
+	}
+	blacktools:tell $unick $host $hand $chan $chan1 egg.3 "defaultlang"
+	rehash
+}
+
+defaultoutput {
+	set error ""
+if {$result == ""} {
+	set get_info [config:getinfo $tcl_config "set black(default_output) \"*\""]
+if {$get_info == "0"} { set get_info "NOTICE" } elseif {$get_info == "1"} { set get_info "CHAN" } elseif { $get_info == "2" } { set get_info "MSG" } 
+	egg:show $type $get_info $unick $host $hand $chan $chan1 $type2
+	return
+	}
+switch [string tolower $result] {
+	notice {
+	set error [config:save $tcl_config "set black(default_output) \"*\"" "set black(default_output) \"0\""]
+}
+	chan {
+	set error [config:save $tcl_config "set black(default_output) \"*\"" "set black(default_output) \"1\""]
+}
+
+	msg {
+	set error [config:save $tcl_config "set black(default_output) \"*\"" "set black(default_output) \"2\""]
+}
+	default {
+	switch $type2 {
+	0 {
+	blacktools:tell $unick $host $hand $chan $chan1 gl.instr "egg"
+	}
+	1 {
+	blacktools:tell $unick $host $hand $chan $chan1 gl.instr_nick "egg"
+	}
+	2 {
+	blacktools:tell $unick $host $hand $chan $chan1 gl.instr_priv "egg"
+			}
+		}
+	}
+}	
+	
+if {$error == "0"} {
+	blacktools:tell $unick $host $hand $chan $chan1 egg.4 "defaultoutput"
+	return
+	}
+	blacktools:tell $unick $host $hand $chan $chan1 egg.3 "defaultoutput"
+	rehash
+}
+
+floodmenuprot {
+if {$result == ""} {
+	set get_info [config:getinfo $tcl_config "set black(antiflood:cmd) \"*\""]
+	egg:show $type $get_info $unick $host $hand $chan $chan1 $type2
+	return
+	}
+	set error [config:save $tcl_config "set black(antiflood:cmd) \"*\"" "set black(antiflood:cmd) \"$result\""]
+if {$error == "0"} {
+	blacktools:tell $unick $host $hand $chan $chan1 egg.4 "floodmenuprot"
+	return
+	}
+	blacktools:tell $unick $host $hand $chan $chan1 egg.3 "floodmenuprot"
+}
+
+floodmsgprot {
+if {$result == ""} {
+	set get_info [config:getinfo $tcl_config "set black(msg:flood) \"*\""]
+	egg:show $type $get_info $unick $host $hand $chan $chan1 $type2
+	return
+	}
+	set error [config:save $tcl_config "set black(msg:flood) \"*\"" "set black(msg:flood) \"$result\""]
+if {$error == "0"} {
+	blacktools:tell $unick $host $hand $chan $chan1 egg.4 "floodmsgprot"
+	return
+	}
+	blacktools:tell $unick $host $hand $chan $chan1 egg.3 "floodmsgprot"
+}
+
+floodnotcprot {
+if {$result == ""} {
+	set get_info [config:getinfo $tcl_config "set black(notice:flood) \"*\""]
+	egg:show $type $get_info $unick $host $hand $chan $chan1 $type2
+	return
+	}
+	set error [config:save $tcl_config "set black(notice:flood) \"*\"" "set black(notice:flood) \"$result\""]
+if {$error == "0"} {
+	blacktools:tell $unick $host $hand $chan $chan1 egg.4 "floodnotcprot"
+	return
+	}
+	blacktools:tell $unick $host $hand $chan $chan1 egg.3 "floodnotcprot"
+}
+
+pagelimit {
+if {$result == ""} {
+	set get_info [config:getinfo $tcl_config "set black(modul:nr:entries) \"*\""]
+	egg:show $type $get_info $unick $host $hand $chan $chan1 $type2
+	return
+	}
+	set error [config:save $tcl_config "set black(modul:nr:entries) \"*\"" "set black(modul:nr:entries) \"$result\""]
+if {$error == "0"} {
+	blacktools:tell $unick $host $hand $chan $chan1 egg.4 "pagelimit"
+	return
+	}
+	blacktools:tell $unick $host $hand $chan $chan1 egg.3 "pagelimit"
+}
+
+away {
+	set result [string map [list \" {\"} \[ {\[} \] {\]} \? {\?} \\ {\\}] $result]
+if {$result == ""} {
+	set get_info [config:getinfo $tcl_config "set black(default_away) \"*\""]
+	egg:show $type $get_info $unick $host $hand $chan $chan1 $type2
+	return
+	}
+	set error [config:save $tcl_config "set black(default_away) \"*\"" "set black(default_away) \"$result\""]
+if {$error == "0"} {
+	blacktools:tell $unick $host $hand $chan $chan1 egg.4 "away"
+	return
+}
+	set result [string map [list {\[} \[ {\]} \] {\?} \? {\\} \\] $result]
+	blacktools:tell $unick $host $hand $chan $chan1 egg.3 "away"
+	putserv "AWAY :"
+	putserv "AWAY :$result"
+foreach tmr [timers] {
+if {[string match "*away:timer*" [join [lindex $tmr 1]]]} {
+	return
+		}	
+	}
+	timer 360 away:timer
+}
+
+quoteofday-showtime {
+	set found_timer 0
+	set return_time [time_return_minute $result]
+if {$return_time == "-1"} {
+	set return_time $black(quote:msgtime)
+	set return_time [time_return_minute $return_time]
+}
+if {$result == ""} {
+	set get_info [config:getinfo $tcl_config "set black(quote:msgtime) \"*\""]
+	egg:show $type $get_info $unick $host $hand $chan $chan1 $type2
+	return
+	}
+	set error [config:save $tcl_config "set black(quote:msgtime) \"*\"" "set black(quote:msgtime) \"$result\""]
+if {$error == "0"} {
+	blacktools:tell $unick $host $hand $chan $chan1 egg.4 "quoteofday-showtime"
+	return
+	}
+	blacktools:tell $unick $host $hand $chan $chan1 egg.3 "quoteofday-showtime"
+	foreach tmr [timers] {
+if {[string equal -nocase "quote:announce" [lindex $tmr 1]]} {
+	killtimer [lindex $tmr 2]
+	set found_timer 1
+			}	
+		}
+if {$found_timer == "1"} {
+	timer $return_time quote:announce
+}
+	rehash
+}
+
+anunt-showtime {
+	set found_timer 0
+	set return_time [time_return_minute $result]
+if {$return_time == "-1"} {
+	set return_time $black(anunttime)
+	set return_time [time_return_minute $return_time]
+}
+if {$result == ""} {
+	set get_info [config:getinfo $tcl_config "set black(anunttime) \"*\""]
+	egg:show $type $get_info $unick $host $hand $chan $chan1 $type2
+	return
+	}
+	set error [config:save $tcl_config "set black(anunttime) \"*\"" "set black(anunttime) \"$result\""]
+if {$error == "0"} {
+	blacktools:tell $unick $host $hand $chan $chan1 egg.4 "anunt-showtime"
+	return
+	}
+	blacktools:tell $unick $host $hand $chan $chan1 egg.3 "anunt-showtime"
+	foreach tmr [timers] {
+if {[string equal -nocase "anuntpublic:show" [lindex $tmr 1]]} {
+	killtimer [lindex $tmr 2]
+	set found_timer 1
+			}	
+		}
+if {$found_timer == "1"} {
+	timer $return_time anuntpublic:show
+}
+	rehash
+}
+
+clonescan-scantime {
+	set found_timer 0
+	set return_time [time_return_minute $result]
+if {$return_time == "-1"} {
+	set return_time $black(clonescantime)
+	set return_time [time_return_minute $return_time]
+}
+if {$result == ""} {
+	set get_info [config:getinfo $tcl_config "set black(clonescantime) \"*\""]
+	egg:show $type $get_info $unick $host $hand $chan $chan1 $type2
+	return
+	}
+	set error [config:save $tcl_config "set black(clonescantime) \"*\"" "set black(clonescantime) \"$result\""]
+if {$error == "0"} {
+	blacktools:tell $unick $host $hand $chan $chan1 egg.4 "clonescan-scantime"
+	return
+	}
+	blacktools:tell $unick $host $hand $chan $chan1 egg.3 "clonescan-scantime"
+	foreach tmr [timers] {
+if {[string equal -nocase "clonescan:timer" [lindex $tmr 1]]} {
+	killtimer [lindex $tmr 2]
+	set found_timer 1
+			}	
+		}
+if {$found_timer == "1"} {
+	timer $return_time clonescan:timer
+}
+	rehash
+}
+
+badchan-scantime {
+	set found_timer 0
+	set return_time [time_return_minute $result]
+if {$return_time == "-1"} {
+	set return_time $black(badchan:scantime)
+	set return_time [time_return_minute $return_time]
+}
+if {$result == ""} {
+	set get_info [config:getinfo $tcl_config "set black(badchan:scantime) \"*\""]
+	egg:show $type $get_info $unick $host $hand $chan $chan1 $type2
+	return
+	}
+	set error [config:save $tcl_config "set black(badchan:scantime) \"*\"" "set black(badchan:scantime) \"$result\""]
+if {$error == "0"} {
+	blacktools:tell $unick $host $hand $chan $chan1 egg.4 "badchan-scantime"
+	return
+	}
+	blacktools:tell $unick $host $hand $chan $chan1 egg.3 "badchan-scantime"
+	foreach tmr [timers] {
+if {[string equal -nocase "badchan:scantimer" [lindex $tmr 1]]} {
+	killtimer [lindex $tmr 2]
+	set found_timer 1
+			}	
+		}
+if {$found_timer == "1"} {
+	timer $return_time badchan:scantimer
+}
+	rehash
+}
+
+broadcast-showtime {
+	set found_timer 0
+	set return_time [time_return_minute $result]
+if {$return_time == "-1"} {
+	set return_time $black(bttime)
+	set return_time [time_return_minute $return_time]
+}
+if {$result == ""} {
+	set get_info [config:getinfo $tcl_config "set black(bttime) \"*\""]
+	egg:show $type $get_info $unick $host $hand $chan $chan1 $type2
+	return
+	}
+	set error [config:save $tcl_config "set black(bttime) \"*\"" "set black(bttime) \"$result\""]
+if {$error == "0"} {
+	blacktools:tell $unick $host $hand $chan $chan1 egg.4 "broadcast-time"
+	return
+	}
+	blacktools:tell $unick $host $hand $chan $chan1 egg.3 "broadcast-time"
+	foreach tmr [timers] {
+if {[string equal -nocase "broadcastpublic:show" [lindex $tmr 1]]} {
+	killtimer [lindex $tmr 2]
+	set found_timer 1
+			}	
+		}
+if {$found_timer == "1"} {
+	timer $return_time broadcastpublic:show
+}
+	rehash
+}
+
+idle-scantime {
+	set found_timer 0
+	set return_time [time_return_minute $result]
+if {$return_time == "-1"} {
+	set return_time $black(idleinterval)
+	set return_time [time_return_minute $return_time]
+}
+	
+if {$result == ""} {
+	set get_info [config:getinfo $tcl_config "set black(idleinterval) \"*\""]
+	egg:show $type $get_info $unick $host $hand $chan $chan1 $type2
+	return
+	}
+	set error [config:save $tcl_config "set black(idleinterval) \"*\"" "set black(idleinterval) \"$result\""]
+if {$error == "0"} {
+	blacktools:tell $unick $host $hand $chan $chan1 egg.4 "idle-scantime"
+	return
+	}
+	blacktools:tell $unick $host $hand $chan $chan1 egg.3 "idle-scantime"
+	foreach tmr [timers] {
+if {[string equal -nocase "idlewhois" [lindex $tmr 1]]} {
+	killtimer [lindex $tmr 2]
+	set found_timer 1
+			}	
+		}
+if {$found_timer == "1"} {
+	timer $return_time idlewhois
+}
+	rehash
+}
+
+antispam-cycletime {
+	set found_timer 0
+	set return_time [time_return_minute $result]
+if {$return_time == "-1"} {
+	set return_time $black(spamcycle)
+	set return_time [time_return_minute $return_time]
+}
+	
+if {$result == ""} {
+	set get_info [config:getinfo $tcl_config "set black(spamcycle) \"*\""]
+	egg:show $type $get_info $unick $host $hand $chan $chan1 $type2
+	return
+	}
+	set error [config:save $tcl_config "set black(spamcycle) \"*\"" "set black(spamcycle) \"$result\""]
+if {$error == "0"} {
+	blacktools:tell $unick $host $hand $chan $chan1 egg.4 "antispam-cycletime"
+	return
+	}
+	blacktools:tell $unick $host $hand $chan $chan1 egg.3 "antispam-cycletime"
+	foreach tmr [timers] {
+if {[string equal -nocase "antispam:protect:cycle" [lindex $tmr 1]]} {
+	killtimer [lindex $tmr 2]
+	set found_timer 1
+			}	
+		}
+if {$found_timer == "1"} {
+	timer $return_time antispam:protect:cycle
+}
+	rehash
+}
+
+chanremove-setting {	
+if {$result == ""} {
+	set get_info [config:getinfo $tcl_config "set black(chanremove_all) \"*\""]
+	egg:show $type $get_info $unick $host $hand $chan $chan1 $type2
+	return
+	}
+if {![regexp {^[12]} $result]} {
+	blacktools:tell $unick $host $hand $chan $chan1 egg.6 "chanremove-setting $result chanremove-setting"
+	return
+}
+	set error [config:save $tcl_config "set black(chanremove_all) \"*\"" "set black(chanremove_all) \"$result\""]
+if {$error == "0"} {
+	blacktools:tell $unick $host $hand $chan $chan1 egg.4 "chanremove-setting"
+	return
+	}
+	blacktools:tell $unick $host $hand $chan $chan1 egg.3 "chanremove-setting"
+	rehash
+}
+
+adduser-mask {	
+if {$result == ""} {
+	set get_info [config:getinfo $tcl_config "set black(addusermask) \"*\""]
+	egg:show $type $get_info $unick $host $hand $chan $chan1 $type2
+	return
+	}
+if {![regexp {^[12345]} $result]} {
+	blacktools:tell $unick $host $hand $chan $chan1 egg.6 "addusermask $result addusermask"
+	return
+}
+	set error [config:save $tcl_config "set black(addusermask) \"*\"" "set black(addusermask) \"$result\""]
+if {$error == "0"} {
+	blacktools:tell $unick $host $hand $chan $chan1 egg.4 "addusermask"
+	return
+	}
+	blacktools:tell $unick $host $hand $chan $chan1 egg.3 "addusermask"
+	rehash
+}
+
+login {
+if {[info exists black(logged)]} {
+	blacktools:tell $unick $host $hand $chan $chan1 login.2 "$black(chanserv)"
+	return
+}
+	putserv "PRIVMSG $black(hostchanserv) :login $black(username) $black(password)"
+   	putserv "MODE $botnick :$black(xmod)"
+
+if {[info exists black(notlogged)] || [info exists black(notlogged:failed)] || [info exists black(notlogged:invalid)]} {
+	blacktools:tell $unick $host $hand $chan $chan1 login.3 "$black(chanserv)"
+	}	
+}
+
+default {
+	blacktools:tell $unick $host $hand $chan $chan1 gl.instr "egg"
+		}
+	}
+}
+
+##############
+#########################################################################
+##   END                                                               ##
+#########################################################################

+ 370 - 0
BlackTools2.5/BlackTools/Modules/BT.Gag.tcl

@@ -0,0 +1,370 @@
+#########################################################################
+##          BlackTools - The Ultimate Channel Control Script           ##
+##                    One TCL. One smart Eggdrop                       ##
+#########################################################################
+#############################   GAG 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 gag:process {gagger time reason nick hand host chan chan1 type} {
+global botnick black
+	set cmd_status [btcmd:status $chan $hand "gag" 0]
+if {$cmd_status == "1"} { 
+	return 
+}	
+	set split_hand [split $hand ":"]
+	set gethand [lindex $split_hand 0]
+	set getlang [string tolower [setting:get $chan lang]]
+	set return_time [time_return_minute $time]
+	set counter 0
+	set num 0
+	set temp_num 0
+	set cmd "gag"
+	set show_gagger $gagger
+	set show_reason $reason
+if {$getlang == ""} { set getlang "[string tolower $black(default_lang)]" }
+	set handle [nick2hand $gagger]
+if {[matchattr $hand q]} { blacktools:tell $nick $host $hand $chan $chan1 gl.glsuspend none
+	return
+}
+if {[matchattr $hand -|q $chan]} { blacktools:tell $nick $host $hand $chan $chan1 gl.suspend none
+	return
+}
+if {$gagger == ""} {
+switch $type {
+	0 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr $cmd
+	}
+	1 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr_nick $cmd
+	}
+	2 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr_priv $cmd
+		}
+	}
+	return 0
+}
+if {![validchan $chan]} {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.novalidchan none
+	return
+}
+if {![onchan $botnick $chan]} {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.notonchan none
+	return
+}
+
+if {[matchattr $handle $black(exceptflags) $chan]} {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.noban none
+	return
+}
+
+if {[isbotnick $gagger]} {
+	return
+}
+
+if {![botisop $chan]} {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.noop none
+	return
+}
+
+if {[isop $gagger $chan]} {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.hasop none
+	return
+}
+if {[onchan $gagger $chan]} {
+    set mask [return_mask [return_host_num $cmd $chan] [getchanhost $gagger $chan] $gagger] 
+} else { 
+	set mask ""
+}
+
+if {[blacktools:isban $mask $chan] == "1"} {
+	blacktools:tell $nick $host $hand $chan $chan1 gag.4 $show_gagger
+	return
+}
+if {[blacktools:isgag $mask $chan] == "1"} {
+	blacktools:tell $nick $host $hand $chan $chan1 gag.3 $show_gagger
+	return
+}
+
+if {[string equal -nocase $gagger "-list"]} {
+foreach b [blacktools:gaglist $chan] {
+	set bhost [lindex [split $b] 2]
+	set counter [expr $counter + 1]
+	set mask [lindex [split $b] 2]
+	set expire [lindex [split $b] 4]
+	set created [lindex [split $b] 5]
+	set created [clock format $created -format %D-%H:%M:%S]
+	set breason [lrange [split $b] 8 end]
+	set bywho [lindex [split $b] 3]
+	set split_bywho [split $bywho ":"]
+	set handle [lindex [split $split_bywho] 0]
+	set type [lindex [split $split_bywho] 1]
+	set bywho "$handle\([string toupper $type]\)"
+if {$type != ""} {
+	set bywho "$handle\([string toupper $type]\)"
+} else { set bywho $handle }
+	set expire [return_time_2 $getlang [expr $expire - [unixtime]]]
+	blacktools:tell $nick $host $hand $chan $chan1 sb.4 "$mask $bywho $created $expire $breason"
+	}
+	blacktools:tell $nick $host $hand $chan $chan1 gag.2 none
+	return
+}
+	set split_hand [split $hand ":"]
+	set handle [lindex $split_hand 0]
+	set type [lindex $split_hand 1]
+if {($return_time > "20160" || $return_time == "0")  && [matchattr $handle -|OS $chan]} {
+	blacktools:tell $nick $host $hand $chan $chan1 gag.7 none
+	return
+}
+
+if {$return_time == "-1"} {
+	set return_time $black(gag_time)
+}
+	set return_time [time_return_minute $return_time]
+	
+if {$mask == ""} {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.usernotonchan $show_gagger
+	return
+}
+
+if {$show_reason == ""} {
+	set getreason [setting:get $chan gag-reason]
+if {$getreason == ""} {
+	set show_reason $black(say.$getlang.gag.6)
+	} else {
+	set show_reason $getreason
+	}
+}
+
+if {[isvoice $gagger $chan]} {
+	pushmode $chan -v $gagger
+}
+	set getlang [string tolower [setting:get $chan lang]]
+if {$getlang == ""} { set getlang "[string tolower $black(default_lang)]" }
+	set replace(%chan%) $chan
+	set replace(%time%) [return_time $getlang [expr [expr [unixtime] + [expr $return_time * 60]] - [unixtime]]]
+	set replace(%gagger%) $gagger
+	set gag_user_message [string map [array get replace] $black(say.$getlang.gag.10)]
+	set gag_chan_message [string map [array get replace] $black(say.$getlang.gag.11)]
+	putserv "PRIVMSG $chan :$gag_chan_message"
+	putserv "PRIVMSG $gagger :$gag_user_message"
+	pushmode $chan +b $mask
+while {$temp_num == 0} {
+	set get [blacktools:ban:find_id $num]
+if {$get == "$num"} {
+	set num [expr $num + 1]
+	} else { set temp_num 1 }
+}
+	blacktools:addban $nick $mask $hand $chan $chan1 $return_time "GAG" "0" "0" $show_reason "0" "" "" "" 0 $num
+
+	set backchan [join [setting:get $chan backchan]]
+if {$backchan == ""} { 
+	return
+}
+if {!([validchan $backchan]) || !([onchan $botnick $backchan])} {
+	return
+}
+	set bantime [time_return_minute $return_time]
+	set bantime [expr $bantime * 60]
+	set expire [return_time_2 $getlang $bantime]
+	
+	set replace(%banmask%) $mask
+	set replace(%bantime%) $expire
+	set replace(%reason%) $reason
+	set replace(%chan%) $chan
+	set replace(%nick%) $gethand
+	puthelp "PRIVMSG $backchan :[string map [array get replace] $black(say.$getlang.reportchan.2)]"
+}
+
+proc gagpublic {nick host hand chan arg} {
+global black lastbind
+	set return [blacktools:mychar $lastbind $hand]
+if {$return == "0"} {
+		return
+}
+	set gagger [lindex [split $arg] 0]
+	set time [lindex [split $arg] 1]
+	set reason [join [lrange [split $arg] 2 end]]
+	set type 0
+	set handle [nick2hand $gagger]
+	set chan1 "$chan"
+	set return_time [time_return_minute $time]
+if {$return_time == "-1"} {
+	set reason [join [lrange [split $arg] 1 end]]
+	set time [setting:get $chan gag-bantime]
+if {$time == ""} {
+	set time $black(gag:bantime)
+	}
+}
+if {[regexp {^[&#]} $gagger] && [matchattr $hand nmo|MASO $gagger]} {
+	set chan "$gagger"
+	set gagger [lindex [split $arg] 1]
+	set time [lindex [split $arg] 2]
+	set reason [join [lrange [split $arg] 3 end]]
+	set return_time [time_return_minute $time]
+if {$return_time == "-1"} {
+	set reason [join [lrange [split $arg] 2 end]]
+	set time [setting:get $chan gag-bantime]
+if {$time == ""} {
+	set time $black(gag:bantime)
+		}
+	}
+}
+foreach c [channels] {
+	set backchan [join [setting:get $c backchan]]
+if {[string match -nocase $chan $backchan]} {
+	set chan "$c"
+	}
+}
+
+if {$gagger != ""} {
+	gag:process $gagger $time $reason $nick "$hand:GAG" $host $chan $chan1 $type
+	} else { gag:process $gagger $time $reason $nick $hand $host $chan $chan1 $type }
+}
+
+
+proc gag:part {nick host hand chan arg} {
+	global black
+if {![validchan $chan]} {
+	return
+}
+	set uhost "$nick![getchanhost $nick $chan]"
+	gag:leave $nick $uhost $chan
+}
+
+proc gag:split {nick host hand chan args} {
+	global black
+if {![validchan $chan]} {
+	return
+}
+	set uhost "$nick![getchanhost $nick $chan]"
+	gag:leave $nick $uhost $chan
+}
+
+proc gag:kick {nick host hand chan kicked reason} {
+	global black
+if {![validchan $chan]} {
+	return
+}
+	set uhost "$kicked![getchanhost $kicked $chan]"
+	gag:leave $kicked $uhost $chan
+}
+
+proc gag:leave {nick host chan} {
+	global black
+if {![validchan $chan]} {
+	return
+}
+	foreach g [blacktools:gaglist $chan] {
+	set read_host [lindex [split $g] 3]
+if {[string match -nocase $read_host $host]} {
+		pushmode $chan -b $read_host
+		}
+	}
+}
+
+################################# ungag ###############################
+
+proc ungagpublic {nick host hand chan arg} {
+global black
+	set gagger [lindex [split $arg] 0]
+	set type 0
+	set chan1 "$chan"
+if {[regexp {^[&#]} $gagger] && [matchattr $hand nmo|MASO $chan]} {
+	set chan "$gagger"
+	set gagger [lindex [split $arg] 1]
+}
+foreach c [channels] {
+	set backchan [join [setting:get $c backchan]]
+if {[string match -nocase $chan $backchan]} {
+	set chan "$c"
+	}
+}
+if {$gagger != ""} {
+	ungag:process $gagger $nick $hand $host $chan $chan1 $type
+	} else { ungag:process $gagger $nick $hand $host $chan $chan1 $type }
+}
+
+proc ungag:process {gagger nick hand host chan chan1 type} {
+	global black
+	set cmd_status [btcmd:status $chan $hand "ungag" 0]
+if {$cmd_status == "1"} { 
+	return 
+}
+if {[matchattr $hand q]} { blacktools:tell $nick $host $hand $chan $chan1 gl.glsuspend none
+	return
+}
+if {[matchattr $hand -|q $chan]} { blacktools:tell $nick $host $hand $chan $chan1 gl.suspend none
+	return
+}
+	set show_gagger $gagger
+	set getlang [string tolower [setting:get $chan lang]]
+if {$getlang == ""} { set getlang "[string tolower $black(default_lang)]" }
+if {$gagger == ""} {
+switch $type {
+	0 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr "ungag"
+	}
+	1 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr_nick "ungag"
+	}
+	2 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr_priv "ungag"
+		}
+	}
+	return 0
+}
+
+if {![validchan $chan]} {
+	return
+}
+if {[onchan $gagger $chan]} {
+	 set mask [return_mask [return_host_num "gag" $chan] [getchanhost $gagger $chan] $gagger] 
+} else {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.usernotonchan $show_gagger
+	return
+}
+
+if {[blacktools:isgag $mask $chan] == "0"} {
+	blacktools:tell $nick $host $hand $chan $chan1 ungag.5 $show_gagger
+	return
+} else {
+	blacktools:delban $mask $chan "0" "1"
+if {[ischanban $mask $chan]} {
+	pushmode $chan -b $mask
+}
+	set replace(%chan%) $chan
+	set replace(%gagger%) $gagger
+	set ungag_user_message [string map [array get replace] $black(say.$getlang.ungag.7)]
+	set ungag_chan_message [string map [array get replace] $black(say.$getlang.ungag.8)]
+
+	putserv "PRIVMSG $gagger :$ungag_user_message"
+	putserv "PRIVMSG $chan :$ungag_chan_message"
+	}
+}
+
+proc gag:reban {nick host hand chan args} {
+global black
+	set bans [lindex $args 1]
+if {![botisop $chan]} { return }
+foreach user [chanlist $chan] {
+	set gethost "$user![getchanhost $user $chan]"
+if {[string match -nocase $bans $gethost]} {
+if {[blacktools:isgag $bans $chan] == "1"} {
+	pushmode $chan +b $bans
+			}
+		}
+	}
+}
+
+##############
+#########################################################################
+##   END                                                               ##
+#########################################################################

+ 153 - 0
BlackTools2.5/BlackTools/Modules/BT.GreetLeave.tcl

@@ -0,0 +1,153 @@
+#########################################################################
+##          BlackTools - The Ultimate Channel Control Script           ##
+##                    One TCL. One smart Eggdrop                       ##
+#########################################################################
+########################   GREET & LEAVE 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 greetpublic {nick host hand chan arg} {
+	global black lastbind
+	set who [lindex [split $arg] 0]
+	set modul "greet"
+	set type 0
+	set chan1 $chan
+	set greet [join [lrange [split $arg] 1 end]]
+if {[regexp {^[&#]} $who] && [matchattr $hand nmo|M $who]} {
+	set chan $who
+	set who [lindex [split $arg] 1]
+	set greet [join [lrange [split $arg] 2 end]]
+	}
+	set return [blacktools:mychar $lastbind $hand]
+if {$return == "0"} {
+		return
+}
+	othermodule:process $nick $host $hand $chan $chan1 $who $greet $type $modul	
+}
+
+proc leavepublic {nick host hand chan arg} {
+	global black lastbind
+	set who [lindex [split $arg] 0]
+	set modul "leave"
+	set type 0
+	set chan1 $chan
+	set leave [join [lrange [split $arg] 1 end]]
+if {[regexp {^[&#]} $who] && [matchattr $hand nmo|M $who]} {
+	set chan $who
+	set who [lindex [split $arg] 1]
+	set leave [join [lrange [split $arg] 2 end]]
+	}
+	set return [blacktools:mychar $lastbind $hand]
+if {$return == "0"} {
+		return
+}
+	othermodule:process $nick $host $hand $chan $chan1 $who $leave $type $modul	
+}
+
+proc greetpublic:join {nick host hand chan} {
+	global black
+if {[setting:get $chan greet]} {
+if {[info exists black(turnOnFlood:$chan)]} {
+	return
+}
+	set getgreet ""
+	set get_time [setting:get $chan jointime]
+if {$get_time == ""} { set jointime [unixtime] }
+	set replace(%nick%) $nick
+	set replace(%chan%) $chan
+	set replace(%count%) [setting:get $chan joincount]
+	set replace(%time%) [clock format $get_time -format %D-%H:%M:%S]
+	set greet_method [string toupper [setting:get $chan greet-method]]
+if {$greet_method == ""} {
+	set greet_method $black(greet:method)
+}
+	set file [open $black(join_file) r]
+while {[gets $file line] != -1} {
+	set read_modul [lindex [split $line] 0]
+	set read_chan [lindex [split $line] 1]
+	set enc_chan [encoding convertfrom utf-8 $read_chan]
+if {[string equal -nocase $read_modul "greet"] && [string equal -nocase $chan $enc_chan]} {	
+	set read_msg [lrange [split $line] 2 end]
+	set getgreet [encoding convertfrom utf-8 $read_msg]
+	}
+}
+	close $file
+if {$getgreet != ""} {
+	set split_greet [split $getgreet "~"]
+	foreach line $split_greet {
+	set line [string map [array get replace] $line]
+if {$greet_method == "NOTICE"} {
+	putserv "NOTICE $nick :[join $line]"
+				} else { putserv "PRIVMSG $nick :[join $line]" }
+			}
+		}
+	}
+}
+
+proc leavepublic:part {nick host hand chan args} {
+	global black
+	set number [scan $black(leaveflood) %\[^:\]]
+	set time [scan $black(leaveflood) %*\[^:\]:%s]
+	if {[isbotnick $nick]} { return }
+if {[setting:get $chan leave]} {
+	set getleave ""
+foreach tmr [utimers] {
+if {[string match "*black(leaveflood:$chan)*" [join [lindex $tmr 1]]]} {
+	killutimer [lindex $tmr 2]
+	}
+}
+if {[info exists black(leavestopped:$chan)]} {
+	return
+}
+
+if {![info exists black(leaveflood:$chan)]} { 
+	set black(leaveflood:$chan) 0 
+}
+	set black(leaveflood:$chan) [expr $black(leaveflood:$chan) + 1]
+	utimer $time [list unset black(leaveflood:$chan)]
+
+if {$black(leaveflood:$chan) >= $number} {
+	set black(leavestopped:$chan) 1
+	utimer 60 [list unset black(leavestopped:$chan)]
+	return
+}
+	set replace(%nick%) $nick
+	set replace(%chan%) $chan
+	set leave_method [string toupper [setting:get $chan leave-method]]
+if {$leave_method == ""} {
+	set leave_method "NOTICE"
+}
+	set file [open $black(join_file) r]
+while {[gets $file line] != -1} {
+	set read_modul [lindex [split $line] 0]
+	set read_chan [lindex [split $line] 1]
+	set enc_chan [encoding convertfrom utf-8 $read_chan]
+if {[string equal -nocase $read_modul "leave"] && [string equal -nocase $chan $enc_chan]} {	
+	set read_msg [lrange [split $line] 2 end]
+	set getleave [encoding convertfrom utf-8 $read_msg]
+	}
+}
+	close $file
+if {$getleave != ""} {
+	set split_leave	[split $getleave "~"]
+	foreach line $split_leave {
+	set line [string map [array get replace] $line]
+if {$leave_method == "NOTICE"} {
+	putserv "NOTICE $nick :[join $line]"
+				} else { putserv "PRIVMSG $nick :[join $line]" }
+			}
+		}
+	}
+}
+
+##############
+#########################################################################
+##   END                                                               ##
+#########################################################################

+ 238 - 0
BlackTools2.5/BlackTools/Modules/BT.GuestNick.tcl

@@ -0,0 +1,238 @@
+#########################################################################
+##          BlackTools - The Ultimate Channel Control Script           ##
+##                    One TCL. One smart Eggdrop                       ##
+#########################################################################
+###########################   GUESTNICK 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 guestnickpublic {nick host hand chan arg} {
+	global black lastbind
+	set who [lindex [split $arg] 0]
+	set modul "guestnick"
+	set type 0
+	set chan1 $chan
+	set gnick [join [lrange [split $arg] 1 end]]
+	set number [lindex [split $arg] 1]
+if {[regexp {^[&#]} $who] && [matchattr $hand nmo|M $who]} {
+	set who [lindex [split $arg] 1]
+	set gnick [join [lrange [split $arg] 2 end]]
+	set number [lindex [split $arg] 2]
+	}
+	set return [blacktools:mychar $lastbind $hand]
+if {$return == "0"} {
+		return
+}
+	guestnick:process $nick $host $hand $chan $chan1 $who $gnick $type $number $modul	
+}
+
+proc guestnick:process {nick host hand chan chan1 who gnick type number modul} {
+	global black
+	set num 0
+	set temp_num 0
+	set cmd_status [btcmd:status $chan $hand "guestnick" 0]
+if {$cmd_status == "1"} { 
+	return 
+}
+if {[matchattr $hand q]} { 
+	blacktools:tell $nick $host $hand $chan $chan1 gl.glsuspend none
+	return
+}
+if {[matchattr $hand -|q $chan]} { 
+	blacktools:tell $nick $host $hand $chan $chan1 gl.suspend none
+	return
+}
+
+if {![validchan $chan]} {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr $modul
+	return
+}
+
+switch $who {
+
+	on {
+	setting:set $chan +guestnick ""
+	blacktools:tell $nick $host $hand $chan $chan1 guestnick.1 none
+}
+	off {
+	setting:set $chan -guestnick ""
+	blacktools:tell $nick $host $hand $chan $chan1 guestnick.2 none
+}
+	add {
+if {$gnick == ""} {
+switch $type {
+	0 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr "guestnick"
+	}
+	1 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr_nick "guestnick"
+	}
+	2 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr_priv "guestnick"
+		}
+	}
+	return
+}
+
+	set findword [prot:findword $chan "GUESTNICK" $gnick]
+if {$findword == "1"} {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.wordexists $gnick
+	return
+}
+
+while {$temp_num == 0} {
+	set get [find:num $num $chan "GUESTNICK"]
+if {$get == "$num"} {
+	set num [expr $num + 1]
+	} else { set temp_num 1 }
+}
+	set file [open $black(add_file) a]
+	set enc_chan [encoding convertto utf-8 $chan]
+	puts $file "$enc_chan GUESTNICK $num $gnick"
+	close $file
+	blacktools:tell $nick $host $hand $chan $chan1 guestnick.3 "$gnick $num"
+}
+del {
+
+if {![regexp {^[0-9]} $number]} {
+switch $type {
+	0 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr "guestnick"
+	}
+	1 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr_nick "guestnick"
+	}
+	2 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr_priv "guestnick"
+		}
+	}
+	return
+}
+	set ret [find:num $number $chan "GUESTNICK"]
+if {$ret == 0} { 
+	blacktools:tell $nick $host $hand $chan $chan1 guestnick.5 $number
+	return
+}
+	set file [open $black(add_file) "r"]
+	set timestamp [clock format [clock seconds] -format {%Y%m%d%H%M%S}]
+	set temp "$black(tempdir)/bt_temp.$timestamp"
+	set tempwrite [open $temp w]
+while {[gets $file line] != -1} {
+	set read_num [lindex [split $line] 2]
+	set read_type [lindex [split $line] 1]
+	set read_chan [lindex [split $line] 0]
+	set enc_chan [encoding convertfrom utf-8 $read_chan]
+if {[string equal $number $read_num] && [string equal $read_type "GUESTNICK"] && [string equal $enc_chan $chan]} { 
+	continue
+} else {
+	puts $tempwrite $line
+		}	 
+    }
+	close $tempwrite
+	close $file
+    file rename -force $temp $black(add_file)
+	blacktools:tell $nick $host $hand $chan $chan1 guestnick.4 $number		
+}
+
+list {
+	array set nicklist [list]
+	set timestamp [clock format [clock seconds] -format {%Y%m%d%H%M%S}]
+	set temp "$black(tempdir)/nick_temp.$timestamp"
+	set file [open $black(add_file) "r"]
+	set w [read -nonewline $file]
+	close $file
+	set data [split $w "\n"]
+foreach line $data {
+	set read_chan [lindex [split $line] 0]
+	set enc_chan [encoding convertfrom utf-8 $read_chan]
+	set read_type [lindex [split $line] 1]
+if {[string match -nocase $enc_chan $chan] && [string match -nocase $read_type "GUESTNICK"]} {
+	set msg_num [lindex [split $line] 2]
+	set message [lrange [split $line] 3 end]
+lappend nicklist($msg_num) $message
+	}
+}
+	set tempwrite [open $temp w]
+foreach msg [lsort -integer -increasing [array names nicklist]] {
+	puts $tempwrite "$msg [join $nicklist($msg)]"
+	}
+	close $tempwrite
+	set file [open $temp "r"]
+	set w [read -nonewline $file]
+	close $file
+	set data [split $w "\n"]
+	file delete $temp
+	module:getinfo $nick $host $hand $chan $chan1 $type $data "guestnick" "0" $number
+		}
+default {
+switch $type {
+	0 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr "guestnick"
+	}
+	1 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr_nick "guestnick"
+	}
+	2 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr_priv "guestnick"
+				}
+			}
+		}		
+	}	
+}
+
+proc guestnick:module {nick host hand chan} {
+	global black
+if {![validchan $chan]} {
+		return
+}
+if {[setting:get $chan guestnick]} {
+if {[info exists black(turnOnFlood:$chan)]} {
+	return
+}
+	set getlang [string tolower [setting:get $chan lang]]
+if {$getlang == ""} { set getlang "[string tolower $black(default_lang)]" }
+	set method [setting:get $chan guestnick-msgmethod]
+if {$method == ""} {
+	set method $black(guestnick:msgmethod)
+}
+	set file [open $black(add_file) r]
+while {[gets $file line] != -1} {
+	set read_chan [lindex [split $line] 0]
+	set read_type [lindex [split $line] 1]
+	set read_msg [lrange [split $line] 3 end]
+if {[string equal -nocase $read_chan $chan] && [string equal -nocase $read_type "GUESTNICK"] && [string match -nocase $read_msg $nick]} {
+	set replace(%nick%) $nick
+	set replace(%chan%) $chan
+	set message [setting:get $chan guestnick-message]
+if {$message == ""} {
+	set message $black(say.$getlang.guestnick.10)
+}
+	set message [string map [array get replace] $message]
+	switch [string tolower $method] {
+	chan {
+	putserv "PRIVMSG $chan :$message"
+	}	
+	privmsg {
+	putserv "PRIVMSG $nick :$message"
+	}
+	notice {
+	putserv "NOTICE $nick :$message"
+	}
+				}
+			}
+		}
+	close $file
+	}
+}
+
+##############
+#########################################################################
+##   END                                                               ##
+#########################################################################

+ 277 - 0
BlackTools2.5/BlackTools/Modules/BT.Idle.tcl

@@ -0,0 +1,277 @@
+#########################################################################
+##          BlackTools - The Ultimate Channel Control Script           ##
+##                    One TCL. One smart Eggdrop                       ##
+#########################################################################
+#############################   IDLE 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 antidlepublic {nick host hand chan arg} {
+global black lastbind
+	set type 0
+	set chan1 "$chan"	
+	set why [lindex [split $arg] 0]
+	set user [lindex [split $arg] 1]
+	set host [lindex [split $arg] 2]
+if {[regexp {^[&#]} $why] && [matchattr $hand nmo|M $why]} {
+	set chan "$why"
+	set why [lindex [split $arg] 1]
+	set user [lindex [split $arg] 2]
+	set host [lindex [split $arg] 3]
+}
+	set return [blacktools:mychar $lastbind $hand]
+if {$return == "0"} {
+		return
+}
+	antidle:process $why $type $user $host $nick $hand $chan $chan1
+}
+
+proc antidle:process {why type user host nick hand chan chan1} {
+global botnick black
+	set show_user $user
+	set flag "-|+f"
+	set handle [nick2hand $user]
+if {[matchattr $hand q]} { 
+	blacktools:tell $nick $host $hand $chan $chan1 gl.glsuspend none
+	return
+}
+if {[matchattr $hand -|q $chan]} { 
+	blacktools:tell $nick $host $hand $chan $chan1 gl.suspend none
+	return
+}
+if {($why == "") && ($type == "0")} {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr "idle"
+	return
+}
+if {($why == "") && ($type == "1")} {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr_nick "idle"
+	return
+}
+if {($why == "") && ($type == "2")} {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr_priv "idle"
+	return
+}
+if {![validchan $chan]} {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.novalidchan none
+	return
+}
+
+if {![onchan $botnick $chan]} {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.notonchan none
+	return
+}
+
+switch $why {
+
++o {
+	setting:set $chan +idleop ""
+	blacktools:tell $nick $host $hand $chan $chan1 idle.11 none
+foreach tmr [timers] {
+if {[string match "*antidle:module*" [join [lindex $tmr 1]]]} {
+	return
+	}	 
+}
+	set idle_time [time_return_minute $black(idleinterval)]
+	timer $idle_time antidle:module
+}
+-o {
+	setting:set $chan -idleop ""
+	blacktools:tell $nick $host $hand $chan $chan1 idle.12 none
+}
++v {
+	setting:set $chan +idlevoice ""
+	blacktools:tell $nick $host $hand $chan $chan1 idle.14 none
+foreach tmr [timers] {
+if {[string match "*antidle:module*" [join [lindex $tmr 1]]]} {
+	return
+	}	 
+}
+	set idle_time [time_return_minute $black(idleinterval)]
+	timer $idle_time antidle:module
+}
+-v {
+	setting:set $chan -idlevoice ""
+	blacktools:tell $nick $host $hand $chan $chan1 idle.15 none
+}
+
+add {
+
+if {$user == ""} {
+if {$type == "0"} {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr "idle"
+	return
+}
+if {$type == "1"} {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr_nick "idle"
+}
+	return
+}
+
+if {[onchan $user $chan]} {
+	set getuser [nick2hand $user]
+if {$getuser != "*"} {
+	set user $getuser
+	}
+}
+
+if {[validuser $user]} { 
+	chattr $user $flag $chan	
+	blacktools:tell $nick $host $hand $chan $chan1 idle.18 $show_user
+} else {
+	
+	set hosts [getchanhost $user $chan]
+	set uhost "*!*@[lindex [split $hosts @] 1]"
+	adduser $user $uhost
+	chattr $user $flag $chan
+	blacktools:tell $nick $host $hand $chan $chan1 idle.19 "$show_user $uhost"
+	}
+}
+
+list {
+	set list [userlist "-|f" $chan]
+	blacktools:tell $nick $host $hand $chan $chan1 idle.20 "none"
+if {$list == ""} {set list "NONE"}
+	blacktools:tell $nick $host $hand $chan $chan1 idle.21 "$list"
+}
+
+del {
+
+if {$user == ""} {
+if {$type == "0"} {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr "idle"
+	return
+}
+if {$type == "1"} {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr_nick "idle"
+}
+	return
+}
+
+if {[onchan $user $chan]} {
+	set getuser [nick2hand $user]
+if {$getuser != "*"} {
+	set user $getuser
+	}
+}
+
+if {![validuser $user]} { 
+	blacktools:tell $nick $host $hand $chan $chan1 idle.22 "$show_user"
+	return
+}
+
+if {![matchattr $user "-|f" $chan]} {
+	blacktools:tell $nick $host $hand $chan $chan1 idle.23 "$show_user"
+	return
+}
+	chattr $user -|-f $chan
+	blacktools:tell $nick $host $hand $chan $chan1 idle.24 "$show_user"
+}
+
+default {
+	
+if {$type == "0"} {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr "idle"
+	return
+}
+if {$type == "1"} {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr_nick "idle"
+			}
+		}
+	}
+}
+
+proc antidle:module {} {
+	global black
+	set channels ""
+foreach chan [channels] {
+if {[setting:get $chan idleop] || [setting:get $chan idlevoice]} {
+	lappend channels $chan
+		}
+	}
+if {$channels != ""} {
+	idlewhois $channels 0
+	set idle_time [time_return_minute $black(idleinterval)]
+	timer $idle_time antidle:module
+	} else {
+	return
+	}
+}
+
+proc idlewhois {channels counter} {
+global black botnick
+	set chan [lindex $channels $counter]
+	set cc [expr $counter + 1]
+if {$chan != ""} {
+	black:check:idle $chan
+	utimer 30 [list idlewhois $channels $cc] 
+} else {
+	return
+	}
+}
+
+proc black:check:idle {chan} {
+	global black
+	putlog "\[BT\] Scanning for idle on $chan"
+	set black(idle_chan) $chan
+foreach user [chanlist $chan] { 
+	set handle [nick2hand $user]
+if {[isop $user $chan] || [isvoice $user $chan]} { 
+if {![isbotnick $user]} { 
+	putserv "WHOIS $user $user"
+				}
+			}
+		}
+	bind raw - 317 idleprocespublic
+}
+
+proc idleprocespublic {nick int arg} {
+global black
+	set nick [string tolower [lindex [split $arg] 1]]
+	set handle [nick2hand $nick]
+	set idler [string tolower [lindex [split $arg] 2]]
+	set minutesidle [expr $idler / 60]
+	set chan $black(idle_chan)
+if {[onchan $nick $chan]} {
+	set idlevoicetime [setting:get $chan idlevoicemax]
+if {$idlevoicetime == ""} { set idlevoicetime "$black(idlevoicemax)" }
+	set idleoptime [setting:get $chan idleopmax]
+if {$idleoptime == ""} { set idleoptime "$black(idleopmax)" }
+if {![info exists black(voiceonmsg:$nick:$chan)]} {
+if {[setting:get $chan idlevoice]} {
+if {![matchattr $handle "-|gf" $chan]} {
+if {$minutesidle > $idlevoicetime} {
+if {[setting:get $chan xonly]} {
+	putserv "PRIVMSG $black(chanserv) :devoice $chan $nick"
+} else {
+	pushmode $chan -v $nick
+			}
+		}
+	}
+}
+
+if {[setting:get $chan idleop]} {
+if {![matchattr $handle "-|af" $chan]} {
+if {$minutesidle > $idleoptime} {
+if {[setting:get $chan xonly]} {
+	putserv "PRIVMSG $black(chanserv) :deop $chan $nick"
+} else {
+	pushmode $chan -o $nick
+						}
+					}
+				}
+			}
+		}
+	}
+}
+
+##############
+#########################################################################
+##   END                                                               ##
+#########################################################################

+ 168 - 0
BlackTools2.5/BlackTools/Modules/BT.Limit.tcl

@@ -0,0 +1,168 @@
+#########################################################################
+##          BlackTools - The Ultimate Channel Control Script           ##
+##                    One TCL. One smart Eggdrop                       ##
+#########################################################################
+#############################   LIMIT 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 limitpublic {nick host hand chan arg} {
+global black lastbind
+	set why [lindex [split $arg] 0]
+	set lm [lindex [split $arg] 1]
+	set type 0
+	set chan1 "$chan"
+if {[regexp {^[&#]} $why] && [matchattr $hand nmo|M $why]} {
+	set chan "$why"
+	set why [lindex [split $arg] 1]
+	set lm [lindex [split $arg] 2]
+}
+	set return [blacktools:mychar $lastbind $hand]
+if {$return == "0"} {
+		return
+}
+	limit:process $nick $host $hand $chan $chan1 $why $lm $type
+}
+
+proc limit:process {nick host hand chan chan1 why lm type} {
+global botnick black
+	set cmd_status [btcmd:status $chan $hand "limit" 0]
+if {$cmd_status == "1"} { 
+	return 
+}
+if {[matchattr $hand q]} { blacktools:tell $nick $host $hand $chan $chan1 gl.glsuspend none
+	return
+}
+if {[matchattr $hand -|q $chan]} { blacktools:tell $nick $host $hand $chan $chan1 gl.suspend none
+	return
+}
+if {$why == ""} {
+	switch $type {
+	0 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr "limit"
+	}
+	1 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr_nick "limit"
+	}
+	2 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr_priv "limit"
+		}
+	}
+	return
+}
+
+if {![validchan $chan]} {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.novalidchan none
+	return
+}
+
+if {![onchan $botnick $chan]} {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.notonchan none
+	return
+}
+	set usersnum [llength [chanlist $chan]]
+	set setnum [setting:get $chan blacklimit]
+	
+    switch $why {
+
+on {
+	set limt [setting:get $chan limit-default]
+	setting:set $chan +limit ""
+	blacktools:tell $nick $host $hand $chan $chan1 limit.5 none
+if {[regexp {^[0-9]} $limt] && ($limt != "0")} { 
+	putserv "MODE $chan +l [expr $usersnum + $limt]"
+} else {
+	putserv "MODE $chan +l [expr $usersnum + $black(limit:default)]"
+	setting:set $chan limit-default $black(limit:default)
+	blacktools:tell $nick $host $hand $chan $chan1 limit.6 none
+	}
+	foreach tmr [timers] {
+if {[string match "*limit:timer*" [join [lindex $tmr 1]]]} {
+	return
+		}	 
+	}
+	timer 1 limit:timer
+}
+off {
+	setting:set $chan -limit ""
+	blacktools:tell $nick $host $hand $chan $chan1 limit.7 none
+	putquick "MODE $chan -l"
+}
+
+set {
+if {![regexp {^[0-9]} $lm]} {
+	if {$type == "0"} {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr "limit"
+}
+if {$type == "1"} {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr_nick "limit"
+}
+	return
+}
+if {$lm < 2} { blacktools:tell $nick $host $hand $chan $chan1 limit.9 none
+	set lm [expr $lm + 1]
+	setting:set $chan limit-default 2
+	putserv "MODE $chan +l [expr $usersnum + $lm]"
+	blacktools:tell $nick $host $hand $chan $chan1 limit.10 none
+	return
+}
+if {$lm > 500} { blacktools:tell $nick $host $hand $chan $chan1 limit.11 none
+	return
+}
+	setting:set $chan limit-default $lm
+	blacktools:tell $nick $host $hand $chan $chan1 limit.12 $lm
+	putserv "MODE $chan +l [expr $usersnum + $lm]"
+		}
+	}
+}
+
+proc limit:timer {} {
+	global black
+		set channels ""
+foreach chan [channels] {
+if {[setting:get $chan limit]} {
+	lappend channels $chan
+		}
+	}
+if {$channels != ""} {
+	limit:act $channels 0
+	timer 1 limit:timer
+	} 
+}
+
+proc limit:act {channels counter} {
+	global black
+	set chan [lindex $channels $counter]
+	set cc [expr $counter + 1]
+if {$chan != ""} {
+	set usersnum [llength [chanlist $chan]]
+	set setnum [setting:get $chan limit-default]
+if {$setnum == "0" || $setnum == ""} { set setnum $black(limit:default) }
+if {![botisop $chan]} { return }
+	set chanmode [getchanmode $chan]
+if {[string match "*l*" "$chanmode"]} {
+	set lim [lindex $chanmode 1]
+} else { set lim "0" }
+if {$usersnum > $lim} { set dif [expr $usersnum - $lim] } else { set dif [expr $lim - $usersnum] }
+if {($dif >= $setnum) || ($dif <= $setnum)} {
+	puthelp "MODE $chan +l [expr $usersnum + $setnum]"
+		}	
+	}
+if {[lindex $channels $cc] == ""} {
+	return
+	} else {
+	utimer 5 [list limit:act $channels $cc]
+	}
+}
+
+##############
+#########################################################################
+##   END                                                               ##
+#########################################################################

+ 530 - 0
BlackTools2.5/BlackTools/Modules/BT.Next.tcl

@@ -0,0 +1,530 @@
+#########################################################################
+##          BlackTools - The Ultimate Channel Control Script           ##
+##                    One TCL. One smart Eggdrop                       ##
+#########################################################################
+#############################   NEXT 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 black:next:join {nick host hand chan} {
+		global black
+		set counter 0
+		set time [unixtime]
+		set handle [nick2hand $nick]
+		set lang [setting:get $chan lang]
+if {$lang == ""} { set lang [string tolower $black(default_lang)] }
+if {[setting:get $chan next]} {
+if {[matchattr $handle $black(exceptflags) $chan]} { 
+	pushmode $chan +v $nick
+	return
+}
+if {[isbotnick $nick]} { 
+	black:next:joincheck $chan
+	return
+}
+if {[info exists black(next:$chan:list)]} {
+if {[lsearch -exact [string tolower [split $black(next:$chan:list)]]  [string tolower $nick]] == -1} {
+	set black(next:$chan:list) "$black(next:$chan:list) $nick"
+	set black(next:$chan:$nick:time) $time
+	}
+} else {
+	set black(next:$chan:list) $nick
+	set black(next:$chan:$nick:time) $time
+}
+	set counter [llength [split $black(next:$chan:list)]]
+	set backchan [setting:get $chan next-backchan]
+	set replace(%counter%) $counter
+	set replace(%nick%) $nick
+	set replace(%chan%) $chan
+	set message [string map [array get replace] $black(say.$lang.next.6)]
+if {($backchan != "") && [validchan $backchan]} {
+	puthelp "NOTICE $backchan :$message"
+} else {
+	puthelp "NOTICE @$chan :$message"
+}
+	set message [string map [array get replace] $black(say.$lang.next.1)]
+	puthelp "NOTICE $nick :$message"
+	}
+}
+
+proc black:next:clear:all {nick chan mode} {
+	global black
+if {[info exists black(next:$chan:list)]} {
+if {[lsearch -exact [string tolower [split $black(next:$chan:list)]]  [string tolower $nick]] > -1} {
+	set position [lsearch -exact [string tolower [split $black(next:$chan:list)]] [string tolower $nick]]
+	set black(next:$chan:list) [join [lreplace [split $black(next:$chan:list)] $position $position]]
+	}
+}
+if {$mode == "0"} {
+if {[info exists black(next:$chan:served)]} {
+if {[lsearch -exact [string tolower [split $black(next:$chan:served)]]  [string tolower $nick]] > -1} {
+	set position [lsearch -exact [string tolower [split $black(next:$chan:served)]] [string tolower $nick]]
+	set black(next:$chan:served) [join [lreplace [split $black(next:$chan:served)] $position $position]]
+		}
+	}
+}
+
+if {[info exists black(next:$chan:$nick:time)]} {
+	unset black(next:$chan:$nick:time)
+}
+
+if {[info exists black(next:$chan:served)]} {
+if {$black(next:$chan:served) == ""} {
+	unset black(next:$chan:served)	
+		}	
+	}
+if {[info exists black(next:$chan:list)]} {
+if {$black(next:$chan:list) == ""} {
+	unset black(next:$chan:list)	
+		}	
+	}
+}
+
+proc black:next:clear {nick chan} {
+	global black
+if {[info exists black(next:$chan:list)]} {
+if {[lsearch -exact [string tolower [split $black(next:$chan:list)]]  [string tolower $nick]] > -1} {
+	set position [lsearch -exact [string tolower [split $black(next:$chan:list)]] [string tolower $nick]]
+	set black(next:$chan:list) [join [lreplace [split $black(next:$chan:list)] $position $position]]
+	}
+}
+if {[info exists black(next:$chan:$nick:time)]} {	
+	unset black(next:$chan:$nick:time)
+	}
+}
+
+proc black:next:joincheck {chan} {
+global black
+if {[info exists black(next:$chan:list)]} {
+foreach user $black(next:$chan:list) {
+if {(![onchan $user $chan]) || [isop $user $chan]} {
+	black:next:clear:all $user $chan 0
+			}
+		}
+	}
+}
+
+proc black:next:part {nick host hand chan arg} {
+	global black
+if {![validchan $chan]} { return }
+if {[setting:get $chan next]} {
+if {![info exists black(next:$chan:list)] && ![info exists black(next:$chan:served)]} {
+	return
+}
+	black:next:clear:all $nick $chan 0
+	}
+}
+
+proc black:next:sign {nick host hand chan arg} {
+	global black
+if {[setting:get $chan next]} {
+if {![info exists black(next:$chan:list)] && ![info exists black(next:$chan:served)]} {
+	return
+		}
+	black:next:clear:all $nick $chan 0
+	}
+}
+
+proc black:next:split {nick host hand chan args} {
+	global black
+if {[setting:get $chan next]} {
+if {![info exists black(next:$chan:list)] && ![info exists black(next:$chan:served)]} {
+	return
+		}
+	black:next:clear:all $nick $chan 0
+	}
+}
+
+proc black:next:kick {nick host hand chan kicked arg} {
+	global black
+if {[setting:get $chan next]} {
+if {![info exists black(next:$chan:list)] && ![info exists black(next:$chan:served)]} {
+	return
+		}
+	black:next:clear:all $kicked $chan 0
+	}
+}
+
+proc black:next:mode {nick host hand chan moded mod_nick} {
+	global black
+if {[setting:get $chan next]} {
+if {($moded == "+v") || ($moded == "+o")} {	
+if {![info exists black(next:$chan:list)] && ![info exists black(next:$chan:served)]} {
+	return
+			}
+	black:next:clear:all $mod_nick $chan 1
+		}
+	}
+}
+
+proc black:next:chnick {nick host hand chan newnick} {
+global black
+if {![validchan $chan]} {
+	return
+}
+if {[setting:get $chan next]} {
+if {[info exists black(next:$chan:served)]} {
+if {[lsearch -exact [string tolower [split $black(next:$chan:served)]]  [string tolower $nick]] > -1} {
+	set position [lsearch -exact [string tolower [split $black(next:$chan:served)]] [string tolower $nick]]
+	set black(next:$chan:served) [join [lreplace [split $black(next:$chan:served)] $position $position]]
+	set black(next:$chan:served) [linsert $black(next:$chan:served) $position $newnick]
+	} 
+}
+if {[info exists black(next:$chan:list)]} {
+if {[lsearch -exact [string tolower [split $black(next:$chan:list)]]  [string tolower $nick]] > -1} {
+	set position [lsearch -exact [string tolower [split $black(next:$chan:list)]] [string tolower $nick]]
+	set black(next:$chan:list) [join [lreplace [split $black(next:$chan:list)] $position $position]]
+	set black(next:$chan:list) [linsert $black(next:$chan:list) $position $newnick]
+	set black(next:$chan:$newnick:time) $black(next:$chan:$nick:time)
+			}
+		}
+	}
+}
+
+proc nextpublic:cmd {nick host hand chan arg} {
+	global black lastbind
+	set option [lindex [split $arg] 0]
+	set chan1 $chan
+	set return [blacktools:mychar $lastbind $hand]
+if {$return == "0"} {
+		return
+}
+foreach c [channels] {
+	set backchan [join [setting:get $c next-backchan]]
+if {[string match -nocase $chan $backchan]} {
+	set chan "$c"
+		}
+	}
+		nextpublic:process $nick $host $hand $chan $chan1 $option
+}
+
+proc nextpublic:process {nick host hand chan chan1 option} {
+	global black
+if {![setting:get $chan next]} {	
+	return
+}
+	set cmd_status [btcmd:status $chan $hand "next" 0]
+if {$cmd_status == "1"} { 
+	return 
+}
+if {$option != ""} {
+
+switch -exact -- [string tolower $option] {
+
+list  {
+	set counter 0
+
+if {![info exists black(next:$chan:list)]} {
+	blacktools:tell $nick $host $hand $chan $chan1 next.8 none
+	return
+}
+if {$black(next:$chan:list) == ""} {
+	blacktools:tell $nick $host $hand $chan $chan1 next.8 none
+	return
+}
+	blacktools:tell $nick $host $hand $chan $chan1 next.7 none
+foreach name [split $black(next:$chan:list)] {
+if {$name != ""} {
+	set get_hand [nick2hand $name]
+if {![matchattr $get_hand $black(exceptflags) $chan]} { 	
+	set counter [expr $counter + 1]
+	lappend field_name "\#$counter $name "
+		}
+	}
+}
+if {![info exists field_name]} {
+	blacktools:tell $nick $host $hand $chan $chan1 next.8 none
+	return
+}
+	blacktools:tell $nick $host $hand $chan $chan1 next.9 [join $field_name]
+		}
+	}
+	return
+}
+
+if {![info exists black(next:$chan:list)]} {
+	blacktools:tell $nick $host $hand $chan $chan1 next.8 none
+	return
+}
+
+if {[llength [split $black(next:$chan:list)]] < 0} {
+	blacktools:tell $nick $host $hand $chan $chan1 next.8 none
+	return
+}
+	set current_nick [lindex [split [concat $black(next:$chan:list)]] 0]
+
+	set backchan [join [setting:get $chan next-backchan]]
+	set lang [setting:get $chan lang]
+if {$lang == ""} { set lang [string tolower $black(default_lang)] }
+	set replace(%current%) $current_nick
+	set replace(%nick%) $nick
+	set replace(%hand%) $hand
+	set message [string map [array get replace] $black(say.$lang.next.11)]
+
+if {($backchan != "") && [validchan $backchan]} {	
+	puthelp "PRIVMSG $backchan :$message"
+}
+	set time [return_time $lang [expr [unixtime] - $black(next:$chan:$current_nick:time)]]
+	set message_1 [string map [array get replace] $black(say.$lang.next.2)]
+	puthelp "NOTICE $current_nick :$message_1"
+	blacktools:tell $nick $host $hand $chan $chan1 next.3 "$current_nick $time"
+	black:next:clear $current_nick $chan
+if {[setting:get $chan xonly] && [onchan $black(chanserv) $chan]} {
+	putserv "PRIVMSG $black(chanserv) :voice $chan $current_nick"
+} else {
+	putserv "MODE $chan +v $current_nick"
+}
+	
+if {[info exists black(next:$chan:served)]} {
+if {[lsearch -exact [string tolower [split $black(next:$chan:served)]] [string tolower $current_nick]] == -1} {
+	set black(next:$chan:served) "$black(next:$chan:served) $current_nick"
+			}	
+		} else {
+	set black(next:$chan:served) $current_nick
+	}
+}
+
+proc helpedpublic:cmd {nick host hand chan arg} {
+	global black lastbind
+	set user [lindex [split $arg] 0]
+	set type 0
+	set chan1 $chan
+	set return [blacktools:mychar $lastbind $hand]
+if {$return == "0"} {
+		return
+}
+foreach c [channels] {
+	set backchan [join [setting:get $c next-backchan]]
+if {[string match -nocase $chan $backchan]} {
+	set chan "$c"
+	}
+}
+	helpedpublic:process $nick $host $hand $chan $chan1 $user $type
+}
+
+proc helpedpublic:process {nick host hand chan chan1 user type} {
+	global black
+	set cmd_status [btcmd:status $chan $hand "helped" 0]
+if {$cmd_status == "1"} { 
+	return 
+}
+	set show_user [split $user]
+	set handle [nick2hand $user]
+	set entry_find 0
+if {![setting:get $chan next]} {
+	return
+}
+if {[isbotnick $user]} { return }
+
+if {[matchattr $handle $black(exceptflags) $chan]} { 
+	return
+}	
+if {$user == ""} {
+switch $type {
+	0 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr "helped"
+	}
+	1 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr_nick "helped"
+	}
+	2 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr_priv "helped"
+		}
+	}
+	return
+}
+if {![onchan $user $chan]} { 
+	blacktools:tell $nick $host $hand $chan $chan1 gl.usernotonchan $show_user	
+	return
+}
+
+if {[info exists black(next:$chan:list)]} {
+if {([lsearch -exact [string tolower [split $black(next:$chan:list)]] [string tolower $user]] > -1)} {
+	blacktools:tell $nick $host $hand $chan $chan1 next.13 $show_user
+	return
+	}	
+} 
+
+if {[info exists black(next:$chan:served)]} {
+if {[lsearch -exact [string tolower [split $black(next:$chan:served)]]  [string tolower $user]] > -1} {
+	set entry_find 1
+	set position [lsearch -exact [string tolower [split $black(next:$chan:served)]] [string tolower $user]]
+	set black(next:$chan:served) [join [lreplace [split $black(next:$chan:served)] $position $position]]
+		}	
+	} else { 
+	blacktools:tell $nick $host $hand $chan $chan1 next.14 $show_user
+	return
+}
+if {$entry_find == "0"} {
+	blacktools:tell $nick $host $hand $chan $chan1 next.14 $show_user
+	return
+}
+	set backchan [setting:get $chan next-backchan]
+	set lang [setting:get $chan lang]
+if {$lang == ""} { set lang [string tolower $black(default_lang)] }
+	set replace(%current%) $user
+	set replace(%nick%) $nick
+	set replace(%hand%) $hand
+	set replace(%chan%) $chan
+	set message [string map [array get replace] $black(say.$lang.next.15)]
+if {($backchan != "") && [validchan $backchan]} {	
+	puthelp "PRIVMSG $backchan :$message"
+}
+if {[isvoice $user $chan]} {
+if {[setting:get $chan xonly] && [onchan $black(chanserv) $chan]} {
+	putserv "PRIVMSG $black(chanserv) :devoice $chan $user"
+} else {
+	putserv "MODE $chan -v $user"
+	}
+}
+	set message_1 [string map [array get replace] $black(say.$lang.next.4)]
+	puthelp "NOTICE $user :$message_1"
+}
+
+
+proc noidlepublic:cmd {nick host hand chan arg} {
+	global black lastbind
+	set user [lindex [split $arg] 0]
+	set type 0
+	set chan1 $chan
+	set return [blacktools:mychar $lastbind $hand]
+if {$return == "0"} {
+		return
+}
+foreach c [channels] {
+	set backchan [join [setting:get $c next-backchan]]
+if {[string match -nocase $chan $backchan]} {
+	set chan "$c"
+		}
+	}
+	noidlepublic:process $nick $host $hand $chan $chan1 $user $type
+}
+
+proc noidlepublic:process {nick host hand chan chan1 user type} {
+	global black
+if {![setting:get $chan next]} {
+	return
+}
+	set cmd_status [btcmd:status $chan $hand "noidle" 0]
+if {$cmd_status == "1"} { 
+	return 
+}
+	set show_user $user
+	set handle [nick2hand $user]
+if {![setting:get $chan next]} {
+	return
+}	
+if {[isbotnick $user]} { return }
+
+if {[matchattr $handle $black(exceptflags) $chan]} { 
+	return
+}	
+if {$user == ""} {
+switch $type {
+	0 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr "noidle"
+	}
+	1 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr_nick "noidle"
+	}
+	2 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr_priv "noidle"
+		}
+	}
+	return
+}
+
+if {![onchan $user $chan]} {
+	blacktools:tell:h $nick $host $hand $chan $chan1 gl.usernotonchan $user
+	return
+}
+
+if {[info exists black(next:$chan:list)]} {
+if {([lsearch -exact [string tolower [split $black(next:$chan:list)]]  [string tolower $user]] > -1)} {
+	blacktools:tell:h $nick $host $hand $chan $chan1 next.13 $user
+	return
+	}	
+}
+if {[info exists black(next:$chan:served)]} {
+if {([lsearch -exact [string tolower [split $black(next:$chan:served)]] [string tolower $user]] > -1)} {
+	blacktools:tell:h $nick $host $hand $chan $chan1 next.17 $user
+	return
+	}
+}
+	blacktools:banner:2 $user "NEXT" $chan $chan1 [getchanhost $user $chan] "0"
+}
+
+proc skippublic:cmd {nick host hand chan arg} {
+	global black lastbind
+	set user [lindex [split $arg] 0]
+	set chan1 $chan
+	set type 0
+	set return [blacktools:mychar $lastbind $hand]
+if {$return == "0"} {
+		return
+}
+foreach c [channels] {
+	set backchan [setting:get $c next-backchan]
+if {[string match -nocase $chan $backchan] && [setting:get $c next]} {
+	set chan "$c"
+		}
+	}
+	skippublic:process $nick $host $hand $chan $chan1 $user $type
+}
+
+proc skippublic:process {nick host hand chan chan1 user type} {
+	global black
+if {![setting:get $chan next]} {
+	return
+}
+	set cmd_status [btcmd:status $chan $hand "skip" 0]
+if {$cmd_status == "1"} { 
+	return 
+}
+if {$user == ""} {
+switch $type {
+	0 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr "skip"
+	}
+	1 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr_nick "skip"
+	}
+	2 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr_priv "skip"
+		}
+	}
+	return
+}
+
+if {![onchan $user $chan]} {
+	blacktools:tell:h $nick $host $hand $chan $chan1 gl.usernotonchan $user
+	return
+}
+
+if {[info exists black(next:$chan:list)]} {
+if {[lsearch -exact [string tolower [split $black(next:$chan:list)]]  [string tolower $user]] > -1} {
+	set position [lsearch -exact [string tolower [split $black(next:$chan:list)]]  [string tolower $user]]
+	set black(next:$chan:list) [join [lreplace [split $black(next:$chan:list)] $position $position]]
+	set black(next:$chan:list) "$black(next:$chan:list) $user"
+	} else {
+	blacktools:tell:h $nick $host $hand $chan $chan1 next.14 $user
+	return
+}
+	} else {
+	blacktools:tell $nick $host $hand $chan $chan1 next.8 none
+	return
+}
+	blacktools:tell:h $nick $host $hand $chan $chan1 next.19 $user
+}
+
+##############
+#########################################################################
+##   END                                                               ##
+#########################################################################

+ 518 - 0
BlackTools2.5/BlackTools/Modules/BT.Notes.tcl

@@ -0,0 +1,518 @@
+#########################################################################
+##          BlackTools - The Ultimate Channel Control Script           ##
+##                    One TCL. One smart Eggdrop                       ##
+#########################################################################
+#############################   NOTES 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 notepublic {nick host hand chan arg} {
+	global black lastbind
+	set who [lindex [split $arg] 0]
+	set note [lrange [split $arg] 0 end]
+	set number [lindex [split $arg] 1]
+	set user_send [lindex [split $arg] 1]
+	set note_send [lrange [split $arg] 2 end]
+	set type 0
+	set chan1 $chan
+if {[regexp {^[&#]} $who] && [matchattr $hand nmo|AOMV $who]} {
+	set chan $who
+	set who [lindex [split $arg] 1]
+	set note [lrange [split $arg] 1 end]
+	set number [lindex [split $arg] 2]
+	set user_send [lindex [split $arg] 2]
+	set note_send [lrange [split $arg] 3 end]
+	}
+	set return [blacktools:mychar $lastbind $hand]
+if {$return == "0"} {
+		return
+}
+	note:process $nick $host $hand $chan $chan1 $who $note $user_send $note_send $number $type
+}
+
+proc note:process {nick host hand chan chan1 who note user_send note_send number type} {
+	global black
+	set cmd_status [btcmd:status $chan $hand "note" 0]
+if {$cmd_status == "1"} { 
+	return 
+}
+if {[setting:get $chan note]} {
+if {[matchattr $hand q]} { blacktools:tell $nick $host $hand $chan $chan1 gl.glsuspend none
+	return
+}
+if {[matchattr $hand -|q $chan]} { blacktools:tell $nick $host $hand $chan $chan1 gl.suspend none
+	return
+}
+	set getlang [string tolower [getuser $hand XTRA OUTPUT_LANG]]
+if {$getlang == ""} { set getlang "[string tolower $black(default_lang)]" }
+switch $who {
+
+list {
+	set notes_total 0
+	array set listlist [list]
+	set timestamp [clock format [clock seconds] -format {%Y%m%d%H%M%S}]
+	set temp "$black(tempdir)/list_temp.$timestamp"
+	set file [open $black(notes_file) "r"]
+while {[gets $file line] != -1} {
+	set handle [lindex [split $line] 4]
+	set readtype [lindex [split $line] 0]
+if {[string equal -nocase $handle $hand] && [string equal -nocase $readtype "LIST"]} {
+	set notes_total [expr $notes_total + 1]
+	set num [lindex [split $line] 2]
+	set readnote [lrange [split $line] 6 end]
+if {[llength [lrange [split $line] 6 end]] > 7	} {
+	set readnote [lrange [split $line] 6 13]
+	set readnote "$readnote .."
+}
+	set encoded [encoding convertfrom utf-8 $readnote]
+	lappend listlist($num) [join "$encoded"]
+	}
+}
+	close $file
+	set tempwrite [open $temp w]
+foreach note [lsort -integer -increasing [array names listlist]] {
+	puts $tempwrite [join "$note $listlist($note)"]
+	}
+	close $tempwrite
+	set file [open $temp "r"]
+	set w [read -nonewline $file]
+	close $file
+	set data [split $w "\n"]
+	file delete $temp
+if {$notes_total == "0"} {
+	blacktools:tell $nick $host $hand $chan $chan1 notes.13 none
+	return
+}
+	blacktools:tell $nick $host $hand $chan $chan1 notes.14 "$notes_total"
+	module:getinfo $nick $host $hand $chan $chan1 $type $data "noteslist" "0" $number
+}
+
+inbox {
+	set notes_read 0
+	set notes_total 0
+	set notes_unread ""
+	array set inboxlist [list]
+	set timestamp [clock format [clock seconds] -format {%Y%m%d%H%M%S}]
+	set temp "$black(tempdir)/inbox_temp.$timestamp"
+	set file [open $black(notes_file) "r"]
+while {[gets $file line] != -1} {
+	set handle [lindex [split $line] 4]
+	set readtype [lindex [split $line] 0]
+if {[string equal -nocase $handle $hand] && [string equal -nocase $readtype "INBOX"]} {
+	set notes_total [expr $notes_total + 1]
+	set num [lindex [split $line] 2]
+	set readnote [lrange [split $line] 7 end]
+	set readit [lindex [split $line] 3]
+if {$readit == "0"} {
+	set notes_read [expr $notes_read + 1]
+	lappend notes_unread $num
+}
+if {[llength $readnote] > 7	} {
+	set readnote [lrange [split $line] 7 14]
+	set readnote "$readnote .."
+}
+	set encoded [encoding convertfrom utf-8 $readnote]
+if {$readit == "0"} {
+	lappend inboxlist($num) "$black(say.$getlang.notes.10) [join $encoded]"
+		} else {
+	lappend inboxlist($num) "$black(say.$getlang.notes.9) [join $encoded]"
+		}
+	}
+}
+	close $file
+	set tempwrite [open $temp w]
+foreach note [lsort -integer -increasing [array names inboxlist]] {
+	puts $tempwrite [join "$note $inboxlist($note)"]
+	}
+	close $tempwrite
+	set file [open $temp "r"]
+	set w [read -nonewline $file]
+	close $file
+	set data [split $w "\n"]
+	file delete $temp
+if {$notes_unread != ""} {
+	blacktools:tell $nick $host $hand $chan $chan1 notes.11 "$notes_read $notes_total $notes_unread"
+} else {
+	blacktools:tell $nick $host $hand $chan $chan1 notes.12 "$notes_read $notes_total"
+}
+if {$notes_total == "0"} {
+	return
+}
+	module:getinfo $nick $host $hand $chan $chan1 $type $data "notesinbox" "0" $number
+}
+
+del {
+if {[string equal -nocase $number "all"]} {
+	set delall [notes:delall $hand]
+	blacktools:tell $nick $host $hand $chan $chan1 notes.15 none
+	return
+}
+	set status [notes:del $number $hand]
+if {$status == "1"} {
+	blacktools:tell $nick $host $hand $chan $chan1 notes.8 $number
+	} else { blacktools:tell $nick $host $hand $chan $chan1 notes.4 $number 
+	return
+	}
+}
+
+read {
+	if {![regexp {^[0-9]} $number]} {
+	switch $type {
+	0 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr "note"
+	}
+	1 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr_nick "note"
+	}
+	2 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr_priv "note"
+		}
+	}
+	return
+}
+	set ret [find:note:num $number]
+	set found_note 0
+if {$ret == 0} { 
+	blacktools:tell $nick $host $hand $chan $chan1 notes.4 $number
+	return
+}
+	set file [open $black(notes_file) "r"]
+while {[gets $file line] != -1} {
+	set num [lindex [split $line] 2]
+	set handle [lindex [split $line] 4]
+if {[string equal -nocase $handle $hand] && [string equal -nocase $number $num]} {
+	set found_note 1
+	set readtype [lindex [split $line] 0]
+	set time [lindex [split $line] 5]
+	set time [clock format $time -format %D]
+	set sender [lindex [split $line] 6]
+if {$readtype == "LIST"} {
+	set readnote [lrange [split $line] 6 end]
+} else {
+	set readnote [lrange [split $line] 7 end]
+}
+	continue
+	}
+}
+	close $file
+if {$found_note == 0} { 
+	blacktools:tell $nick $host $hand $chan $chan1 notes.4 $number
+	return
+
+}
+	set split_note [split $readnote "~"]
+if {$readtype == "LIST"} {
+	blacktools:tell $nick $host $hand $chan $chan1 notes.5 "$number $readtype $time"
+foreach line $split_note {
+	set encoded [encoding convertfrom utf-8 $line]
+	blacktools:tell $nick $host $hand $chan $chan1 notes.6 "[join $encoded]"
+	}
+} else {
+	blacktools:tell $nick $host $hand $chan $chan1 notes.7 "$number $readtype $sender $time"
+foreach line $split_note {	
+	set encoded [encoding convertfrom utf-8 $line]
+	blacktools:tell $nick $host $hand $chan $chan1 notes.6 "[join $encoded]"
+		}
+	}
+	notes:read $number $hand
+}
+
+send {
+	set num_user 0
+	set sent_user 0
+	set invalid_user ""
+if {$user_send == ""} {
+	switch $type {
+	0 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr "note"
+	}
+	1 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr_nick "note"
+	}
+	2 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr_priv "note"
+		}
+	}
+	return
+}
+if {[llength $note_send] == "0"} {
+	switch $type {
+	0 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr "note"
+	}
+	1 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr_nick "note"
+	}
+	2 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr_priv "note"
+		}
+	}
+	return
+}
+	set split_usersend [split $user_send ","]
+foreach user $split_usersend {
+if {[onchan $user $chan] && ![validuser $user]} {
+	set user [nick2hand $user]
+}
+	set num_user [expr $num_user + 1]
+if {[validuser $user]} {
+	set sent_user [expr $sent_user + 1]
+	set black(notes:announce:$user) 1
+	set return [notes:add $nick $host $user "DB" "INBOX" $note_send $hand 0]
+		} else {
+	lappend invalid_user $user
+		}
+	}
+if {$invalid_user == ""} {
+	blacktools:tell $nick $host $hand $chan $chan1 notes.2 "$sent_user $num_user"
+	} else {
+	blacktools:tell $nick $host $hand $chan $chan1 notes.3 "$sent_user $num_user $invalid_user"
+	}
+}
+
+default {
+if {$who == ""} {
+	set notes_read 0
+	set notes_total 0
+	set notes_unread ""
+		array set inboxlist [list]
+	set timestamp [clock format [clock seconds] -format {%Y%m%d%H%M%S}]
+	set temp "$black(tempdir)/inbox_temp.$timestamp"
+	set file [open $black(notes_file) "r"]
+while {[gets $file line] != -1} {
+	set handle [lindex [split $line] 4]
+	set readtype [lindex [split $line] 0]
+if {[string equal -nocase $handle $hand] && [string equal -nocase $readtype "INBOX"]} {
+	set notes_total [expr $notes_total + 1]
+	set num [lindex [split $line] 2]
+	set readnote [lrange [split $line] 7 end]
+	set readit [lindex [split $line] 3]
+if {$readit == "0"} {
+	set notes_read [expr $notes_read + 1]
+	lappend notes_unread $num
+		}
+	}
+}
+	close $file
+if {$notes_unread != ""} {
+	blacktools:tell $nick $host $hand $chan $chan1 notes.11 "$notes_read $notes_total $notes_unread"
+	blacktools:tell $nick $host $hand $chan $chan1 notesinbox.13 "none"
+} else {
+	blacktools:tell $nick $host $hand $chan $chan1 notes.12 "$notes_read $notes_total"
+}
+	return
+}
+	set return [notes:add $nick $host $hand "DB" "LIST" $note "" 0]
+	blacktools:tell $nick $host $hand $chan $chan1 notes.1 $return
+			}
+		}
+	}
+}
+
+proc notes:del {num hand} {
+	global black
+	set found_it 0
+	set file [open $black(notes_file) "r"]
+	set timestamp [clock format [clock seconds] -format {%Y%m%d%H%M%S}]
+	set temp "$black(tempdir)/notes_temp.$timestamp"
+	set tempwrite [open $temp w]
+while {[gets $file line] != -1} {
+	set read_num [lindex [split $line] 2]
+	set handle [lindex [split $line] 4]
+if {[string equal $num $read_num] && [string equal $handle $hand]} {
+	set found_it 1
+	continue
+} else {
+	puts $tempwrite $line
+		}	 
+    }
+	close $tempwrite
+	close $file
+    file rename -force $temp $black(notes_file)
+	
+	return $found_it
+}
+
+proc notes:delall {hand} {
+	global black
+	set found_it 0
+	set file [open $black(notes_file) "r"]
+	set timestamp [clock format [clock seconds] -format {%Y%m%d%H%M%S}]
+	set temp "$black(tempdir)/notes_temp.$timestamp"
+	set tempwrite [open $temp w]
+while {[gets $file line] != -1} {
+	set type [lindex [split $line] 0]
+	set handle [lindex [split $line] 4]
+if {[string equal $handle $hand] && [string equal $type "INBOX"]} {
+	set found_it [expr $found_it + 1]
+	continue
+} else {
+	puts $tempwrite $line
+		}	 
+    }
+	close $tempwrite
+	close $file
+    file rename -force $temp $black(notes_file)
+	return $found_it
+}
+
+proc notes:read {num hand} {
+	global black
+	set read_it 0
+	set file [open $black(notes_file) "r"]
+	set timestamp [clock format [clock seconds] -format {%Y%m%d%H%M%S}]
+	set temp "$black(tempdir)/notes_temp.$timestamp"
+	set tempwrite [open $temp w]
+while {[gets $file line] != -1} {
+	set read_num [lindex [split $line] 2]
+	set handle [lindex [split $line] 4]
+	set read_type [lindex [split $line] 0]
+	set readit [lindex [split $line] 3]
+if {[string equal $num $read_num] && [string equal $handle $hand] && [string equal -nocase $read_type "INBOX"] && ($readit == "0")} {
+	set db [lindex [split $line] 1]
+	set readtype [lindex [split $line] 0]
+	set readnum [lindex [split $line] 2]
+	set read_it 1
+	set time [lindex [split $line] 5]
+	set readhandle [lindex [split $line] 4]
+	set readsender [lindex [split $line] 6]
+	set readnote [join [lrange [split $line] 7 end]]
+	continue
+} else {
+	puts $tempwrite $line
+		}	 
+    }
+	close $tempwrite
+	close $file
+    file rename -force $temp $black(notes_file)
+if {$read_it == "1"} {	
+	set file [open $black(notes_file) "a"]
+	puts $file "$readtype $db $readnum $read_it $readhandle $time $readsender $readnote"
+	close $file
+}
+	return $read_it
+}
+
+proc notes:add {nick host handle chan type note sender read} {
+	global black
+	set type [string toupper $type]
+	set temp_num 0
+	set num 0
+	set time [unixtime]
+	
+	while {$temp_num == 0} {
+	set get [find:note:num $num]
+if {$get == "$num"} {
+	set num [expr $num + 1]
+	} else { set temp_num 1 }
+}
+	set file [open $black(notes_file) a]
+	set encoded [encoding convertto utf-8 $note]
+if {$type == "LIST"} {
+	puts $file "$type $chan $num $read $handle $time [join $encoded]"
+}
+if {$type == "INBOX"} {
+	puts $file "$type $chan $num $read $handle $time $sender [join $encoded]"
+}
+	close $file
+	return $num
+}
+
+proc notes:announce:pub {nick host hand chan arg} {
+	global black
+	set found_access 0
+	set hand [nick2hand $nick]
+foreach c [channels] {
+if {[matchattr $hand nmo|MAOV $c]} {
+	set found_access 1
+	}
+}
+if {$found_access == "1"} {
+
+if {[info exists black(notes:announce:$hand)]} {
+if {$black(notes:announce:$hand) == "0"} {
+	return
+	}
+} else { return }
+	set chan1 $chan
+	set notes_read 0
+	set notes_total 0
+	set notes_unread ""
+	array set inboxlist [list]
+	set timestamp [clock format [clock seconds] -format {%Y%m%d%H%M%S}]
+	set temp "$black(tempdir)/inbox_temp.$timestamp"
+	set file [open $black(notes_file) "r"]
+while {[gets $file line] != -1} {
+	set handle [lindex [split $line] 4]
+	set readtype [lindex [split $line] 0]
+if {[string equal -nocase $handle $hand] && [string equal -nocase $readtype "INBOX"]} {
+	set notes_total [expr $notes_total + 1]
+	set num [lindex [split $line] 2]
+	set readnote [join [lrange [split $line] 7 end]]
+	set readit [lindex [split $line] 3]
+if {$readit == "0"} {
+	set notes_read [expr $notes_read + 1]
+	lappend notes_unread $num
+		}
+	}
+}
+	close $file
+if {$notes_unread != ""} {
+	blacktools:tell $nick $host $hand $chan $chan1 notes.11 "$notes_read $notes_total $notes_unread"
+	blacktools:tell $nick $host $hand $chan $chan1 notes.16 "none"
+	set black(notes:announce:$hand) 0
+		}
+	}
+}
+
+proc notes:announce {nick host hand chan} {
+	global black
+	set hand [nick2hand $nick]
+if {[matchattr $hand nmo|AOVM $chan]} {
+if {[info exists black(notes:announce:$hand)]} {
+	if {$black(notes:announce:$hand) == "0"} {
+	return
+	}
+} else { return }
+	set chan1 $chan
+	set notes_read 0
+	set notes_total 0
+	set notes_unread ""
+	array set inboxlist [list]
+	set timestamp [clock format [clock seconds] -format {%Y%m%d%H%M%S}]
+	set temp "$black(tempdir)/inbox_temp.$timestamp"
+	set file [open $black(notes_file) "r"]
+while {[gets $file line] != -1} {
+	set handle [lindex [split $line] 4]
+	set readtype [lindex [split $line] 0]
+if {[string equal -nocase $handle $hand] && [string equal -nocase $readtype "INBOX"]} {
+	set notes_total [expr $notes_total + 1]
+	set num [lindex [split $line] 2]
+	set readnote [lrange [split $line] 7 end]
+	set readit [lindex [split $line] 3]
+if {$readit == "0"} {
+	set notes_read [expr $notes_read + 1]
+	lappend notes_unread $num
+		}
+	}
+}
+	close $file
+if {$notes_unread != ""} {
+	blacktools:tell $nick $host $hand $chan $chan1 notes.11 "$notes_read $notes_total $notes_unread"
+	blacktools:tell $nick $host $hand $chan $chan1 notes.16 "none"
+	set black(notes:announce:$hand) 0
+		}
+	}
+}
+
+##############
+#########################################################################
+##   END                                                               ##
+#########################################################################

+ 180 - 0
BlackTools2.5/BlackTools/Modules/BT.Private.tcl

@@ -0,0 +1,180 @@
+#########################################################################
+##          BlackTools - The Ultimate Channel Control Script           ##
+##                    One TCL. One smart Eggdrop                       ##
+#########################################################################
+###########################   PRIVATE 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 privatepublic {nick host hand chan arg} {
+global black lastbind
+	set type 0
+	set chan1 "$chan"
+	set why [lindex [split $arg] 0]
+	set user [lindex [split $arg] 1]
+if {[regexp {^[&#]} $why] && [matchattr $hand nmo|M $why]} {
+	set chan "$why"
+	set why [lindex [split $arg] 1]
+	set user [lindex [split $arg] 2]
+}
+	set return [blacktools:mychar $lastbind $hand]
+if {$return == "0"} {
+		return
+}
+	private:process $nick $host $hand $chan $chan1 $why $user $type
+}
+
+proc private:process {nick host hand chan chan1 why user type} {
+global botnick black
+	set cmd_status [btcmd:status $chan $hand "private" 0]
+if {$cmd_status == "1"} { 
+	return 
+}
+if {[matchattr $hand q]} { blacktools:tell $nick $host $hand $chan $chan1 gl.glsuspend none
+	return
+}
+if {[matchattr $hand -|q $chan]} { blacktools:tell $nick $host $hand $chan $chan1 gl.suspend none
+	return
+}
+	set flags "-|P"
+	set cmd "private"
+	set show_user $user
+
+if {$why == ""} {
+switch $type {
+	0 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr "private"
+	}
+	1 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr_nick "private"
+	}
+	2 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr_priv "private"
+		}
+	}
+	return
+}
+    switch $why {
+	
+add {
+if {($user == "") && ($type == "0")} {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr $cmd
+	return
+}
+if {($user == "") && ($type == "1")} {
+		blacktools:tell $nick $host $hand $chan $chan1 gl.instr_nick $cmd
+	return
+}
+if {[onchan $user $chan]} {
+	set getuser [nick2hand $user]
+if {$getuser != "*"} {
+	set user $getuser
+	}
+}
+
+if {[validuser $user]} {
+if {[matchattr $user $flags $chan]} {
+	blacktools:tell $nick $host $hand $chan $chan1 private.10 $show_user
+	return
+}
+	chattr $user $flags $chan
+	blacktools:tell $nick $host $hand $chan $chan1 private.7 $show_user
+} else {
+	set hosts [getchanhost $user $chan]
+	set uhost [return_mask $black(addusermask) $hosts $user]
+	
+	if {[userlist] != ""} {
+foreach usr [userlist] {
+	set hst [getuser $usr hosts]
+foreach hhost $hst {
+if {[string match -nocase $hhost $uhost] && (![string match -nocase $usr $user])} {
+	blacktools:tell $nick $host $hand $chan $chan1 add.5 $usr
+	set user $usr
+	set show_user $usr
+			}
+		}
+	}
+}
+
+if {[validuser $user]} {
+	chattr $user $flags $chan
+	blacktools:tell $nick $host $hand $chan $chan1 private.7 $show_user
+	return
+}
+	adduser $user $uhost
+	chattr $user $flags $chan
+	blacktools:tell $nick $host $hand $chan $chan1 private.8 "$show_user $uhost"
+	}
+}
+
+del {
+if {($user == "") && ($type == "0")} {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr $cmd
+	return
+}
+if {($user == "") && ($type == "1")} {
+		blacktools:tell $nick $host $hand $chan $chan1 gl.instr_nick $cmd
+	return
+}
+if {[onchan $user $chan]} {
+	set getuser [nick2hand $user]
+if {$getuser != "*"} {
+	set user $getuser
+	}
+}
+
+if {[validuser $user]} {
+if {[matchattr $user $flags $chan]} {
+	chattr $user -|-P $chan
+	blacktools:tell $nick $host $hand $chan $chan1 private.9 $show_user
+} else { blacktools:tell $nick $host $hand $chan $chan1 private.6 $show_user
+		}
+	} else { blacktools:tell $nick $host $hand $chan $chan1 gl.nomem none }
+}
+
+list {
+	set list [join [userlist $flags $chan]]
+if {$list == ""} { set list "NONE" }
+	blacktools:tell $nick $host $hand $chan $chan1 private.11 none
+	blacktools:tell $nick $host $hand $chan $chan1 private.5 $list
+}
+
+default {
+if {$type == "0"} {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr $cmd
+	return
+}
+if {$type == "1"} {
+		blacktools:tell $nick $host $hand $chan $chan1 gl.instr_nick $cmd
+	return
+			}
+		}
+	}
+}
+
+proc private:module {nick host hand chan} {
+global black botnick
+	set handle [nick2hand $nick]
+if {![validchan $chan]} {
+	return
+}
+	set chan1 $chan
+if {[setting:get $chan private]} {
+if {[matchattr $handle nmo|oMASOVP $chan]} { 
+	return 
+}
+	blacktools:banner:2 $nick "PRIVATE" $chan $chan1 $host "0"
+	}
+}
+
+##############
+#########################################################################
+##   END                                                               ##
+#########################################################################

+ 438 - 0
BlackTools2.5/BlackTools/Modules/BT.Quote.tcl

@@ -0,0 +1,438 @@
+#########################################################################
+##          BlackTools - The Ultimate Channel Control Script           ##
+##                    One TCL. One smart Eggdrop                       ##
+#########################################################################
+#############################   QUOTE 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 quote:announce {} {
+	global black
+	set return_time [time_return_minute $black(quote:msgtime)]
+	set channels ""
+foreach chan [channels] {
+if {[validchan $chan]} {
+if {[setting:get $chan quoteofday]} {
+	lappend channels $chan
+		}
+	}
+}
+if {$channels != ""} {
+		quote:time $channels 0
+		timer $return_time quote:announce
+	}	 
+}
+
+proc quote:time {channels counter} {
+	global black
+	set chan [lindex $channels $counter]
+	set cc [expr $counter + 1]
+if {$chan != ""} {
+	quoteofday:show $chan
+} 
+if {[lindex $channels $cc] == ""} {
+	return
+} else {
+	quote:time $channels $cc
+	}
+}
+
+proc quoteofday:show {chan} {
+	global black  botnick
+	set getlang [string tolower [setting:get $chan lang]]
+if {$getlang == ""} { set getlang "[string tolower $black(default_lang)]" }
+	set timestamp [clock format [clock seconds] -format {%Y%m%d%H%M%S}]
+	set temp_dir "$black(tempdir)/quote_temp.$timestamp"
+	set day [clock format [clock seconds] -format {%d}]
+	set file [open $black(quote_file) "r"]
+	set temp [open $temp_dir "a"]
+while {[gets $file line] != -1} {
+	set read_chan [lindex [split $line] 0]
+	set enc_chan [encoding convertfrom utf-8 $read_chan]
+if {[string match -nocase $enc_chan $chan]} {
+	set quote [join [lrange [split $line] 6 end]]
+	set gettime [lindex [split $line] 4]
+	set getday [clock format $gettime -format %d]
+if {$getday == $day} {
+	puts $temp $quote
+		}
+	}
+}
+	close $temp
+	close $file
+	set file [open $temp_dir "r"]
+	set data [read -nonewline $file]
+	close $file
+if {$data != ""} {
+if {![info exists black(quoteshow:$chan)]} {
+	set black(quoteshow:$chan) 0
+}
+	set lines [split $data "\n"]
+	set line [lindex $lines $black(quoteshow:$chan)]
+	
+if {$line == ""} {
+	set black(quoteshow:$chan) 0
+	set line [lindex $lines $black(quoteshow:$chan)]
+}
+	set black(quoteshow:$chan) [expr $black(quoteshow:$chan) + 1]
+	set encoded [encoding convertfrom utf-8 $line]
+	set replace(%msg%) $encoded
+	set message [join [string map [array get replace] $black(say.$getlang.quote.16)]]
+	set split_message [split $message "~"]
+if {[onchan $botnick $chan]} {
+if {$black(quote:outtype) == "1"} {
+	putserv "PRIVMSG $chan :\001ACTION $black(say.$getlang.quote.12)\001"
+} else {
+	putserv "PRIVMSG $chan :$black(say.$getlang.quote.12)"
+}
+foreach mes $split_message {
+if {$black(quote:outtype) == "1"} {
+	putserv "PRIVMSG $chan :\001ACTION \"$mes\"\001"
+} else { 
+	putserv "PRIVMSG $chan :\"$mes\""
+			}
+		}
+	}
+}
+	file delete $temp_dir
+}
+
+proc quotepublic {nick host hand chan arg} {
+	global black lastbind
+	set otherchan 0
+	set return [blacktools:mychar $lastbind $hand]
+if {$return == "0"} {
+		return
+}
+	set who [lindex [split $arg] 0]
+	set next [lindex [split $arg] 1]
+	set quote [join [lrange [split $arg] 0 end]]
+if {$who == "*"} {
+	set who [lindex [split $arg] 1]
+	set quote [join [lrange [split $arg] 0 end]]
+}
+if {[regexp {^[\[]} $who]} {
+	set who [lindex [split $arg] 1]
+	set quote [join [lrange [split $arg] 0 end]]
+if {$who == "*"} {
+	set who [lindex [split $arg] 2]
+	set quote [join [lrange [split $arg] 0 end]]
+	}
+}
+	set type 0
+	set chan1 $chan
+if {[regexp {^[&#]} $who] && [matchattr $hand nmo|AOMV $who]} {
+	set otherchan 1
+	set chan "$who"
+	set who [lindex [split $arg] 1]
+	set next [lindex [split $arg] 2]
+	set quote [join [lrange [split $arg] 1 end]]
+if {$who == "*"} {
+	set who [lindex [split $arg] 2]
+	set quote [join [lrange [split $arg] 1 end]]
+}
+if {[regexp {^[\[]} $who]} {
+	set who [lindex [split $arg] 2]
+	set quote [join [lrange [split $arg] 1 end]]
+if {$who == "*"} {
+	set who [lindex [split $arg] 3]
+	set quote [join [lrange [split $arg] 1 end]]
+		}
+	}
+}
+if {$otherchan == "1"} {
+	quote:process $nick $host $hand $chan $chan1 $type $who $quote [lrange [split $arg] 1 end] $next
+	} else {
+	quote:process $nick $host $hand $chan $chan1 $type $who $quote [lrange [split $arg] 0 end] $next
+	}
+}
+
+proc quote:process {nick host hand chan chan1 type who quote arg next} {
+	global black
+	set cmd_status [btcmd:status $chan $hand "q" 0]
+if {$cmd_status == "1"} { 
+	return 
+}
+if {[setting:get $chan quote]} {
+	set show_who $who
+if {[matchattr $hand q]} { blacktools:tell $nick $host $hand $chan $chan1 gl.glsuspend none
+	return
+}
+if {[matchattr $hand -|q $chan]} { blacktools:tell $nick $host $hand $chan $chan1 gl.suspend none
+	return
+}
+switch $who {
+	list {
+if {[matchattr $hand nmo|M $chan]} {
+	array set nicklist [list]
+	set getlang [string tolower [getuser $hand XTRA OUTPUT_LANG]]
+if {$getlang == ""} { set getlang "[string tolower $black(default_lang)]" }
+	set timestamp [clock format [clock seconds] -format {%Y%m%d%H%M%S}]
+	set temp "$black(tempdir)/quote_temp.$timestamp"
+	set file [open $black(quote_file) "r"]
+while {[gets $file line] != -1} {
+	set read_chan [lindex [split $line] 0]
+	set enc_chan [encoding convertfrom utf-8 $read_chan]
+	set read_type [lindex [split $line] 1]
+if {[string match -nocase $enc_chan $chan]} {
+	set msg_num [lindex [split $line] 2]
+	set by_who [lindex [split $line] 3]
+	set quote [join [lrange [split $line] 6 end]]
+lappend nicklist($msg_num) "$quote :: $black(say.$getlang.quote.15) $by_who"
+		}
+	}
+	close $file
+	set tempwrite [open $temp w]
+foreach msg [lsort -integer -increasing [array names nicklist]] {
+	puts $tempwrite "$msg [join $nicklist($msg)]"
+}
+	close $tempwrite
+	set file [open $temp "r"]
+	set w [read -nonewline $file]
+	close $file
+	set data [split $w "\n"]
+	file delete $temp
+	module:getinfo $nick $host $hand $chan $chan1 $type $data "quote" "0" $next
+	}
+}
+
+del {
+if {[matchattr $hand nmo|M $chan]} {
+if {![regexp {^[0-9]} $next]} {
+switch $type {
+	0 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr "quote"
+	}
+	1 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr_nick "quote"
+	}
+	2 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr_priv "quote"
+		}
+	}
+	return
+}
+	set ret [find:q:num $next $chan]
+if {$ret == 0} { 
+	blacktools:tell $nick $host $hand $chan $chan1 quote.13 $next
+	return
+}
+	set file [open $black(quote_file) "r"]
+	set timestamp [clock format [clock seconds] -format {%Y%m%d%H%M%S}]
+	set temp "$black(tempdir)/quote_temp.$timestamp"
+	set tempwrite [open $temp w]
+while {[gets $file line] != -1} {
+	set read_num [lindex [split $line] 2]
+	set read_chan [lindex [split $line] 0]
+	set enc_chan [encoding convertfrom utf-8 $read_chan]
+if {[string equal $next $read_num] && [string equal -nocase $enc_chan $chan]} { 
+	continue
+} else {
+	puts $tempwrite $line
+		}	 
+    }
+	close $tempwrite
+	close $file
+    file rename -force $temp $black(quote_file)
+	blacktools:tell $nick $host $hand $chan $chan1 quote.10 $next
+	}
+}
+	default {
+	if {[llength [split $arg]] > 1} {
+	set ret_num [quote:add $nick $host $chan $who $quote]
+	blacktools:tell $nick $host $hand $chan $chan1 quote.1 $ret_num
+}
+if {[llength [split $arg]] == 1} {
+	quote:show $nick $host $hand $chan $chan1 $type $show_who
+}
+if {[llength [split $arg]] == 0} {
+	quote:rand $nick $host $hand $chan $chan1 $type $show_who 
+				}
+			}
+		}
+	}
+}
+
+proc quote:rand {nick host hand chan chan1 type who} {
+	global black
+	set total [quote:total $chan]
+	set length [llength $total]
+if {$length > 0} {
+	set random [expr int(rand()*$length)] 
+    set quote [lindex $total $random]
+	set file [open $black(quote_file) "r"]
+while {[gets $file line] != -1} {
+	set read_chan [lindex [split $line] 0]
+	set num [lindex [split $line] 2]
+	set enc_chan [encoding convertfrom utf-8 $read_chan]
+if {[string equal -nocase $chan $enc_chan] && [string equal -nocase $quote $num]} {
+	set time [lindex [split $line] 4]
+	set time [clock format $time -format %D]
+	set readquote [join [lrange [split $line] 6 end]]
+	set encoded [encoding convertfrom utf-8 $readquote]
+	continue
+			}			
+		}
+	}
+	close $file
+	blacktools:tell $nick $host $hand $chan $chan1 quote.3 "$quote $time"
+	set split_encoded [split $encoded "~"]
+	foreach enc $split_encoded {
+	blacktools:tell $nick $host $hand $chan $chan1 quote.19 $enc
+	}
+}
+
+proc quote:show {nick host hand chan chan1 type who} {
+	global black
+	set quote_numbers ""
+	set find_num 0
+	set found_quote 0
+	set show_who $who
+if {[regexp {^[0-9]} $who]} {
+	set quote_num $who
+	set find_num 1
+} else {
+	set quote_list [quote:count $who $chan]
+	set length [llength $quote_list]
+if {$length > 0} {
+	set found_quote 1
+}
+	set random [expr int(rand()*$length)] 
+    set quote [lindex $quote_list $random]
+	set split_quote [split $quote ":"]
+	set quote_num [lindex $split_quote 0]
+	set quote_show [lindex $split_quote 1]
+foreach q $quote_list {
+	set q_split [split $q ":"]
+	set q_num [lindex $q_split 0]
+if {$quote_num != $q_num} {
+	lappend quote_numbers \#$q_num
+			}
+		}
+if {$found_quote == "0"} {
+	blacktools:tell $nick $host $hand $chan $chan1 quote.11 none
+	return
+	}
+}
+	set file [open $black(quote_file) "r"]
+while {[gets $file line] != -1} {
+	set read_chan [lindex [split $line] 0]
+	set num [lindex [split $line] 2]
+	set enc_chan [encoding convertfrom utf-8 $read_chan]
+if {[string equal -nocase $chan $enc_chan] && [string equal -nocase $quote_num $num]} {
+	set found_quote 1
+	set time [lindex [split $line] 4]
+	set time [clock format $time -format %D]
+	set readquote [join [lrange [split $line] 6 end]]
+	set encoded [encoding convertfrom utf-8 $readquote]
+	continue
+			}			
+		}
+	close $file
+if {$found_quote == "0"} {
+	blacktools:tell $nick $host $hand $chan $chan1 quote.11 none
+	return
+}
+if {$find_num == "0"} {
+	blacktools:tell:h $nick $host $hand $chan $chan1 quote.4 "$quote_show/$length $show_who $time"
+}
+	set split_encoded [split $encoded "~"]
+foreach enc $split_encoded {
+	blacktools:tell $nick $host $hand $chan $chan1 quote.17 "$quote_num $enc"
+	}
+if {$quote_numbers != ""} {
+	blacktools:tell $nick $host $hand $chan $chan1 quote.18 $quote_numbers
+	}
+}
+
+proc quote:total {chan} {
+	global black
+	set nums ""
+	set file [open $black(quote_file) "r"]
+while {[gets $file line] != -1} {
+	set read_chan [lindex [split $line] 0]
+	set enc_chan [encoding convertfrom utf-8 $read_chan]
+if {[string equal -nocase $chan $enc_chan]} {
+	set read_num [lindex [split $line] 2]
+	lappend nums $read_num
+		}	
+	}
+	close $file
+	return $nums
+}
+
+proc quote:count {who chan} {
+	global black
+	set q_count 0
+	set return ""
+	set found_nick 0
+	set found_quote 0
+	set file [open $black(quote_file) "r"]
+while {[gets $file line] != -1} {
+	set read_chan [lindex [split $line] 0]
+	set read_who [lindex [split $line] 5]
+	set read_who [string map { "<" ""
+								">" ""
+								"@" ""
+								"+" ""
+										} $read_who]
+										
+	set enc_chan [encoding convertfrom utf-8 $read_chan]
+	set read_who [string map [list \[ {\[} \] {\]} \? {\?} \\ {\\}] $read_who]
+if {[string equal -nocase $chan $enc_chan] && [string match -nocase $read_who $who]} { 
+	set found_nick 1
+	set q_count [expr $q_count + 1]
+	set num [lindex [split $line] 2]
+	set return "$return $num:$q_count"
+		}
+	}
+	close $file
+if {$found_nick == "0"} {
+	set file [open $black(quote_file) "r"]
+while {[gets $file line] != -1} {
+	set read_chan [lindex [split $line] 0]
+	set readquote [lrange [split $line] 6 end]
+	set enc_chan [encoding convertfrom utf-8 $read_chan]
+if {[string equal -nocase $chan $enc_chan] && ([lsearch -exact $readquote $who] > -1)} { 
+	set found_quote 1
+	set q_count [expr $q_count + 1]
+	set num [lindex [split $line] 2]
+	set return "$return $num:$q_count"
+		}
+	}
+		close $file
+}
+	return $return
+}
+	
+proc quote:add {nick host chan who quote} {
+	global black
+	set temp_num 0
+	set num 0
+	set time [unixtime]
+	
+	while {$temp_num == 0} {
+	set get [find:q:num $num $chan]
+if {$get == "$num"} {
+	set num [expr $num + 1]
+	} else { set temp_num 1 }
+}
+	set file [open $black(quote_file) a]
+	set enc_chan [encoding convertto utf-8 $chan]
+	set encoded [encoding convertto utf-8 $quote]
+	puts $file "$enc_chan QUOTE $num $nick $time $who $encoded"
+	close $file
+	return $num
+}
+
+##############
+#########################################################################
+##   END                                                               ##
+#########################################################################

+ 285 - 0
BlackTools2.5/BlackTools/Modules/BT.SecureMode.tcl

@@ -0,0 +1,285 @@
+#########################################################################
+##          BlackTools - The Ultimate Channel Control Script           ##
+##                    One TCL. One smart Eggdrop                       ##
+#########################################################################
+###########################   SECUREMODE 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 securemode:findexcept {chan host} {
+	global black
+	set found_it 0
+	set file [open $black(add_file) "r"]
+	set w [read -nonewline $file]
+	close $file
+	set data [split $w "\n"]
+foreach line $data {
+	set read_chan [lindex [split $line] 0]
+	set enc_chan [encoding convertfrom utf-8 $read_chan]
+if {[string equal -nocase $enc_chan $chan]} {
+	set read_type [lindex [split $line] 1]
+if {[string equal -nocase $read_type "SECUREMODE-EXCEPT"]} {
+	set read_host [lindex [split $line] 3]
+	set real_read_host [string map [list \[ {\[} \] {\]} \? {\?} \\ {\\}] $read_host]
+if {[string match -nocase $host $real_read_host] || [string match -nocase $real_read_host $host]} {
+	set found_it 1
+				}
+			}
+		}
+	}
+	return $found_it
+}
+
+proc securemode:module {nick host hand chan arg} {
+	global black lastbind
+	set type 0
+	set chan1 "$chan"
+	set why [lindex [split $arg] 0]
+	set except [join [lrange [split $arg] 1 end]]
+	set number [lindex [split $arg] 1]
+if {[regexp {^[&#]} $why] && [matchattr $hand nmo|M $why]} {
+	set chan "$why"
+	set why [lindex [split $arg] 1]
+	set except [join [lrange [split $arg] 2 end]]
+	set number [lindex [split $arg] 2]
+}
+	set return [blacktools:mychar $lastbind $hand]
+if {$return == "0"} {
+		return
+}
+	prot:module:process $nick $host $hand $chan $chan1 $why $except $type $number "securemode"
+}
+
+proc securemode:kickremove {nick host hand chan kicked reason} {
+	global black
+	set host [getchanhost $kicked $chan]
+if {[setting:get $chan securemode]} {
+	set chanmode [getchanmode $chan]
+if {[string match -nocase "*D*" $chanmode] && [string match -nocase "*m*" $chanmode]} {
+if {[info exists black(secure:$chan:allowlist)]} {
+if {[lsearch -exact [string tolower $black(secure:$chan:allowlist)] [string tolower $host]] > -1} {
+	set position [lsearch -exact [string tolower $black(secure:$chan:allowlist)] [string tolower $host]]
+	set black(secure:$chan:allowlist) [lreplace $black(secure:$chan:allowlist) $position $position]
+				}
+if {[info exists black(secure:$chan:list)]} {
+if {[lsearch -exact [string tolower $black(secure:$chan:list)]  [string tolower $kicked]] > -1} {
+	set position [lsearch -exact [string tolower $black(secure:$chan:list)] [string tolower $kicked]]
+	set black(secure:$chan:list) [lreplace $black(secure:$chan:list) $position $position]
+					}
+				}	
+			}
+		}
+	}
+}
+
+proc secured:allowlist:reset {minute hour day month year} {
+	global black
+foreach chan [channels] {
+if {[validchan $chan]} {
+if {[info exists black(secure:$chan:allowlist)]} {
+	unset black(secure:$chan:allowlist)
+			}
+		}
+	}		
+}
+
+proc securemode:timer {} {
+	global black botnick
+	set channels ""
+	set secure_act 0
+foreach chan [channels] {
+if {[setting:get $chan securemode]} {
+	lappend channels $chan
+if {[onchan $botnick $chan]} {
+	set chanmode [getchanmode $chan]
+if {[string match -nocase "*D*" $chanmode] && [string match -nocase "*m*" $chanmode]} {
+	set secure_act 1
+			}
+		}	
+	}
+}
+if {$channels == ""} {
+	return
+}
+if {$secure_act == "1"} {
+	securemode:act $channels 0
+}
+	utimer 30 [list securemode:timer]
+}
+
+proc securemode:reply {nick host hand chan mod who} {
+	global black
+if {[setting:get $chan securemode]} {
+	set getlang [string tolower [setting:get $chan lang]]
+if {$getlang == ""} { set getlang "[string tolower $black(default_lang)]" }
+if {[string match "*+D*" $mod]} {
+	set replace(%chan%) $chan
+	putserv "PRIVMSG $chan :[string map [array get replace] $black(say.$getlang.securemode.10)]"
+}
+if {[string match "*-D*" $mod]} {
+	set replace(%chan%) $chan
+	putserv "PRIVMSG $chan :[string map [array get replace] $black(say.$getlang.securemode.11)]"
+		}
+	}
+}
+
+proc securemode:act {channels counter} {
+	global black
+
+if {$channels == ""} {
+	return
+}
+	set chan [lindex $channels $counter]
+	set cc [expr $counter + 1]
+if {$chan != ""} {
+	securemode:raw $chan
+} else {
+	return
+}
+	utimer 5 [list securemode:act $channels $cc]
+}
+
+proc securemode:raw {chan} {
+	global black
+	putquick "NAMES -d $chan"
+	set ::securechan $chan
+	bind RAW - 355 get:nameslist
+	bind RAW - 366 end:nameslist
+}
+
+proc get:nameslist {from keyword arguments} {
+	global black
+	set found_it 0
+	set chan $::securechan
+	set split_arg [split $arguments ":"]
+	set names [lindex $split_arg 1]
+if {[info exists black(secure:$chan:list)]} {
+foreach entry $black(secure:$chan:list) {
+if {[lsearch -exact [string tolower [split $names]] [string tolower $entry]] < 0} {
+	set position [lsearch -exact [string tolower $black(secure:$chan:list)] [string tolower $entry]]
+	set black(secure:$chan:list) [lreplace $black(secure:$chan:list) $position $position]
+if {[info exists black(securecode:$entry:$chan)]} {
+	unset black(securecode:$entry:$chan)
+			}
+		}
+	}
+}
+if {[info exists black(secure:$chan:list)]} {
+if {[llength $black(secure:$chan:list)] == "0"} {
+	unset black(secure:$chan:list)
+	}
+}
+	secure:gethost $names $chan 0
+}
+
+proc end:nameslist {from keyword arguments} {
+	global black
+	check:if:bind "get:nameslist" "355"
+	check:if:bind "end:nameslist" "366"
+}
+
+proc secure:gethost {names chan counter} {
+	global black
+	set name [lindex [split $names] $counter]
+	set cc [expr $counter + 1]
+if {$name != ""} {
+	securemode:gethost:raw $name $chan
+} else {
+	return
+}
+	utimer 3 [list secure:gethost $names $chan $cc]
+}
+
+proc securemode:gethost:raw {name chan} {
+	global black
+	putserv "USERHOST :$name"
+	set ::shchan $chan
+	set ::shnick $name
+	bind RAW - 302 get:securemode:host
+}
+
+proc get:securemode:host {from keyword arguments} {
+	global black botnick
+	set is_allowed 0
+	set has_access 0
+	set securemode_activ 0
+	set hosts [lindex [split $arguments] 1]
+	set hostname [lindex [split $hosts "="] 1]
+	regsub {^[-+]} $hostname "" mask
+	set nick $::shnick
+	set except_mask "$nick!$mask"
+	set chan $::shchan
+if {[setting:get $chan securemode]} {
+	set chanmode [getchanmode $chan]
+if {[string match -nocase "*D*" $chanmode] && [string match -nocase "*m*" $chanmode]} {
+	set securemode_activ 1
+	}
+}
+if {$securemode_activ == "0"} {
+	return
+}
+	set replace(%botnick%) $botnick
+	set replace(%chan%) $chan
+	set lang [setting:get $chan lang]
+if {$lang == ""} { set lang [string tolower $black(default_lang)] }
+	set getaccess [finduser $except_mask]
+if {[matchattr $getaccess $black(exceptflags) $chan]} {
+if {[setting:get $chan xonly] && [onchan $black(chanserv) $chan]} {
+	putserv "PRIVMSG $black(chanserv) :voice $chan $nick"
+		} else {
+	putserv "MODE $chan +v $nick"
+	}
+	return
+}
+if {[securemode:findexcept $chan $except_mask] == "1"} { 
+	if {[setting:get $chan xonly] && [onchan $black(chanserv) $chan]} {
+	putserv "PRIVMSG $black(chanserv) :voice $chan $nick"
+		} else {
+	putserv "MODE $chan +v $nick"
+	}
+	return
+}
+if {[info exists black(secure:$chan:allowlist)]} {
+if {[setting:get $chan strictsecured] == "" || [setting:get $chan strictsecured] == "0"} {
+if {[lsearch -exact [string tolower $black(secure:$chan:allowlist)]  [string tolower $mask]] > -1} {
+	set is_allowed 1
+if {[setting:get $chan xonly] && [onchan $black(chanserv) $chan]} {
+	putserv "PRIVMSG $black(chanserv) :voice $chan $nick"
+		} else {
+	putserv "MODE $chan +v $nick"
+		}
+	}
+	if {$is_allowed == "1"} {
+	return
+		}
+	}
+}
+if {[info exists black(secure:$chan:list)]} {
+if {[lsearch -exact [string tolower $black(secure:$chan:list)]  [string tolower $nick]] < 0} {
+	set black(securecode:$nick:$chan) [string toupper [bot:setcode]]
+	set replace(%msg.1%) $black(securecode:$nick:$chan)
+	set message [string map [array get replace] $black(say.$lang.securemode.1)]
+	putserv "PRIVMSG $nick :$message"
+	lappend black(secure:$chan:list) $nick
+	}
+} else {
+	set black(securecode:$nick:$chan) [string toupper [bot:setcode]]
+	set replace(%msg.1%) $black(securecode:$nick:$chan)
+	set message [string map [array get replace] $black(say.$lang.securemode.1)]
+	putserv "PRIVMSG $nick :$message"
+	lappend black(secure:$chan:list) $nick
+}
+	check:if:bind "get:securemode:host" "302"
+}
+
+##############
+#########################################################################
+##   END                                                               ##
+#########################################################################

+ 920 - 0
BlackTools2.5/BlackTools/Modules/BT.Seen.tcl

@@ -0,0 +1,920 @@
+#########################################################################
+##          BlackTools - The Ultimate Channel Control Script           ##
+##                    One TCL. One smart Eggdrop                       ##
+#########################################################################
+#############################   SEEN 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 seen:get_lastmessage {nick host hand chan arg} {
+	global black username
+	set seen_lastmessage_dir $black(seen_details)
+	set host "*!$host"
+	set time [unixtime]
+	set no_staytime 0
+	set arg [join [split $arg]]
+	set type "LASTMSG"
+	set found_entry 0
+	set lin 0
+	set found_entry 0
+if {![validchan $chan]} { return }
+if {![setting:get $chan seen] && ![setting:get $chan seenlastmsg]} {
+	return
+}
+if {![file exists $seen_lastmessage_dir]} {
+	set file [open $seen_lastmessage_dir w]
+	close $file
+}
+	set file [open $seen_lastmessage_dir "r"]
+	set database [read -nonewline $file]
+	close $file	
+	set data [split $database "\n"]
+foreach line $data {
+	set lin [expr $lin +1]
+	set hostentry [lindex [split $line] 3]
+	set chanentry [lindex [split $line] 1]
+if {[string equal -nocase $host $hostentry] && [string match -nocase $chanentry $chan]} {
+	set userentry [lindex  [split $line] 2]
+	set found_entry 1
+	set who "LASTMSG $chanentry $userentry $hostentry $time $arg"
+if {$line != ""} {
+	set num [expr $lin - 1]
+	set delete [lreplace $data $num $num]
+	set files [open $seen_lastmessage_dir "w"]
+	puts $files [join $delete "\n"]
+	close $files
+			}
+		}
+	}
+if {$found_entry == "1"} {
+	
+	set file [open $seen_lastmessage_dir "r"]
+	set data [read -nonewline $file]
+	close $file
+if {$data == ""} {
+	set files [open $seen_lastmessage_dir "w"]
+	close $files
+}
+	set file [open $seen_lastmessage_dir "a"]
+	puts $file $who
+	close $file
+	} else {
+	set who "LASTMSG $chan $nick $host $time $arg"
+	set file [open $seen_lastmessage_dir "a"]
+	puts $file $who
+	close $file
+	}
+}
+
+
+proc seen:save:2 {nick chan host type time staytimer reason} {
+	global black
+	set seendir $black(seen_file)
+	set lin 0
+	set j 0
+	set who "$type $chan $nick $host $time $staytimer $reason"
+	set details ""
+	set file [open $seendir "r"]
+	set database [read -nonewline $file]
+	close $file
+	set data [split $database "\n"]
+foreach line $data {
+	set lin [expr $lin +1]
+	set userentry [lindex  [split $line] 2]
+	set chanentry [lindex [split $line] 1]
+if {[string equal -nocase $userentry $nick] && [string match -nocase $chanentry $chan]} {
+	set joined [lindex [split $line] 0]
+if {$joined == "JOIN"} {
+	set j [lindex [split $line] 4]
+if {![regexp {^[0-9]} $j] || ($j == "")} {
+	set j 0
+	}
+}
+	set who "$type $chan $nick $host $time $j $reason"
+if {$line != ""} {
+	set num [expr $lin - 1]
+	set delete [lreplace $data $num $num]
+	set files [open $seendir "w"]
+	puts $files [join $delete "\n"]
+	close $files
+		}
+	}
+}
+	set file [open $seendir "r"]
+	set data [read -nonewline $file]
+	close $file
+if {$data == ""} {
+	set files [open $seendir "w"]
+	close $files
+}
+	set file [open $seendir "a"]
+	puts $file "$who"
+	close $file
+}
+
+proc seen:save:1 {nick chan host type time staytimer} {
+	global black
+	set seendir $black(seen_file)
+	set lin 0
+	set who "$type $chan $nick $host $time $staytimer NONE"
+	set file [open $seendir "r"]
+	set database [read -nonewline $file]
+	close $file	
+	set data [split $database "\n"]
+foreach line $data {
+	set lin [expr $lin +1]
+	set userentry [lindex  [split $line] 2]
+	set chanentry [lindex [split $line] 1]
+if {[string equal -nocase $userentry $nick] && [string match -nocase $chanentry $chan]} {
+if {$line != ""} {
+	set num [expr $lin - 1]
+	set delete [lreplace $data $num $num]
+	set files [open $seendir "w"]
+	puts $files [join $delete "\n"]
+	close $files
+		}
+	
+	}
+}
+	set file [open $seendir "r"]
+	set data [read -nonewline $file]
+	close $file
+if {$data == ""} {
+	set files [open $seendir "w"]
+	close $files
+}
+	set file [open $seendir "a"]
+	puts $file "$who"
+	close $file
+}
+
+
+proc seen:join {nick host hand chan} {
+global botnick black
+	set seendir $black(seen_file)
+if {![file exists $seendir]} {
+	set file [open $seendir w]
+	close $file
+}
+if {![validchan $chan]} { return }
+if {![setting:get $chan seen]} {
+	return
+}
+
+if {[setting:get $chan seenreply]} {
+	seen:reply:src $nick $host $chan
+}
+
+if {[isbotnick $nick]} { return }
+	set time [unixtime]
+	set host "*!$host"
+	set type "JOIN"
+	set staytimer "0"
+	seen:save:1 $nick $chan $host $type $time $staytimer
+}
+
+
+proc seen:part {nick host hand chan arg} {
+global botnick black
+	set seendir $black(seen_file)
+if {![file exists $seendir]} {
+	set file [open $seendir w]
+	close $file
+}
+if {![validchan $chan]} { return }
+if {![setting:get $chan seen]} {
+	return
+}
+	set time [unixtime]
+	set staytimer "0"
+	set type "PART"
+	set reason [join [lrange [split $arg] 0 end]]
+if {$reason == ""} { set reason "N/A" }
+	set host "*!$host"
+if {[isbotnick $nick]} { return }
+	seen:save:2 $nick $chan $host $type $time $staytimer $reason
+}
+
+proc seen:sign {nick host hand chan arg} {
+	global botnick black
+	set seendir $black(seen_file)
+if {![file exists $seendir]} {
+	set file [open $seendir w]
+	close $file
+}
+if {![validchan $chan]} { return }
+if {![setting:get $chan seen]} {
+	return 0
+}
+	set time [unixtime]
+	set staytimer "0"
+	set type "SIGN"
+	set host "*!$host"
+	set reason [join [lrange [split $arg] 0 end]]
+if {$reason == ""} { set reason "N/A" }
+if {[isbotnick $nick]} { return }
+	seen:save:2 $nick $chan $host $type $time $staytimer $reason
+}
+
+
+proc seen:kick {nick host hand chan kicked reason} {
+global botnick black
+	set seendir $black(seen_file)
+if {![file exists $seendir]} {
+	set file [open $seendir w]
+	close $file
+}
+if {![validchan $chan]} { return }
+if {![setting:get $chan seen]} {
+	return
+}	
+	set lin 0
+	set j 0
+	set time [unixtime]
+	set hosted [getchanhost $kicked $chan]
+	set hosted "*!$hosted"
+	set reason [join [lrange [split $reason] 1 end]]
+if {$reason == ""} { set reason "No Reason" }
+if {[isbotnick $kicked]} { return }
+	set who "KICK $chan $kicked $hosted $time 0 $reason"
+	set file [open $seendir "r"]
+	set database [read -nonewline $file]
+	close $file
+	set data [split $database "\n"]
+foreach line $data {
+	set lin [expr $lin +1]
+	set userentry [lindex [split $line] 2]
+	set chanentry [lindex [split $line] 1]
+if {[string equal -nocase $kicked $userentry] && [string match -nocase $chanentry $chan]} {
+	set joined [lindex [split $line] 0]
+if {$joined == "JOIN"} {
+	set j [lindex [split $line] 4]
+if {![regexp {^[0-9]} $j] || ($j == "")} {
+	set j 0
+	}
+}
+	set who "KICK $chan $kicked $hosted $time $j $reason"
+if {$line != ""} {
+	set num [expr $lin - 1]
+	set delete [lreplace $data $num $num]
+	set files [open $seendir "w"]
+	puts $files [join $delete "\n"]
+	close $files
+		}	
+	}
+}
+	set file [open $seendir "r"]
+	set data [read -nonewline $file]
+	close $file
+if {$data == ""} {
+	set files [open $seendir "w"]
+	close $files
+}
+	set file [open $seendir "a"]
+	puts $file "$who"
+	close $file
+}
+
+
+proc seen:split {nick host hand chan args} {
+global botnick black
+	set seendir $black(seen_file)
+if {![file exists $seendir]} {
+	set file [open $seendir w]
+	close $file
+}
+if {![validchan $chan]} { return }
+if {![setting:get $chan seen]} {
+	return
+}
+	set time [unixtime]	
+	set staytimer "0"
+	set type "SPLIT"
+	set host "*!$host"	
+	set reason [join [lrange [split $args] 0 end]]
+if {[isbotnick $nick]} { return }
+	seen:save:2 $nick $chan $host $type $time $staytimer $reason
+}
+
+
+proc seen:changenick {nick host hand chan newnick} {
+global botnick black
+	set seendir $black(seen_file)
+if {![file exists $seendir]} {
+	set file [open $seendir w]
+	close $file
+}
+if {![validchan $chan]} { return }
+if {![setting:get $chan seen]} {
+	return
+}
+	set time [unixtime]
+	set host "*!$host"
+	set staytimer "0"
+	set type "NICKCHANGE"
+if {[isbotnick $nick]} { return }
+	seen:save:2 $nick $chan $host $type $time $staytimer $newnick
+}
+
+proc seenpublic {nick host hand chan arg} {
+global black lastbind
+	set type 0
+	set chan1 "$chan"
+	set isbackchan ""
+	set what [lindex [split $arg] 0]
+if {[regexp {^[&#]} $what] && [matchattr $hand nmo|MAOV $chan]} {
+	set chan1 "$chan"
+	set chan "$what"
+	set what [lindex [split $arg] 1]
+}
+	set return [blacktools:mychar $lastbind $hand]
+if {$return == "0"} {
+		return
+}
+foreach c [channels] {
+	set backchan [join [setting:get $c backchan]]
+if {[string equal -nocase $backchan $chan]} {
+	set isbackchan $c
+	set chan1 $chan
+	}
+}
+if {$isbackchan != ""} {
+	seen:process $nick $host $hand $isbackchan $chan1 $what $type
+	} else {
+	seen:process $nick $host $hand $chan $chan1 $what $type
+	}
+}
+
+proc seen:process {nick host hand chan chan1 what type} {
+global black botnick
+	set cmd_status [btcmd:status $chan $hand "seen" 0]
+if {$cmd_status == "1"} { 
+	return 
+}
+	set seendir $black(seen_file)
+	set test ""
+	set test_host ""
+	set show_nick $nick
+if {![matchattr $hand nmo]} {
+if {![validchan $chan]} {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.novalidchan none
+	return
+	}
+}
+
+if {![setting:get $chan seen]} {
+	return
+}
+
+if {[string match -nocase "*prv*" $host]} {
+	set split_host [split $host ":"]
+	set the_host [lindex $split_host 0]
+	set host [lindex $split_host 1]
+} else {
+	set the_host $host
+}
+
+	set number [scan $black(seenflood) %\[^:\]]
+	set timer [scan $black(seenflood) %*\[^:\]:%s]
+	set i 0
+	
+if {$what == ""} {
+	switch $type {
+	0 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr "seen"
+	}
+	1 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr_nick "seen"
+	}
+	2 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr_priv "seen"
+		}
+	}
+	return
+}
+
+if {![validchan $chan]} {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.novalidchan none
+	return
+}
+
+if {![matchattr $hand nmo]} {
+foreach tmr [utimers] {
+if {[string match "*remove:seenflood:host $the_host $chan*" [join [lindex $tmr 1]]]} {
+	killutimer [lindex $tmr 2]
+	}
+}
+
+if {![info exists black(flood:$the_host:$chan)]} { 
+	set black(flood:$the_host:$chan) 0 
+}
+	incr black(flood:$the_host:$chan)
+	utimer $timer [list remove:seenflood:host $the_host $chan]
+
+if {$black(flood:$the_host:$chan) >= "$number"} {
+	blacktools:tell $nick $host $hand $chan $chan1 seen.5 none
+	return
+}
+
+if {[string equal -nocase $what $nick] && ($chan1 == $chan)} { blacktools:tell $nick $host $hand $chan $chan1 seen.6 $nick
+	return
+	}
+}
+
+if {[string equal -nocase $what $botnick]} {
+	blacktools:tell $nick $host $hand $chan $chan1 seen.4 $show_nick
+	return
+}
+	
+if {[onchan $what $chan]} {
+	blacktools:tell $nick $host $hand $chan $chan1 seen.7 $what
+if {[setting:get $chan seenreply]} {
+	set read_time [clock format [unixtime] -format %D-%H:%M:%S]
+	blacktools:tell $what "prv" "" $chan $chan1 seen.39 "$what $show_nick!$host $read_time"
+	}
+	return
+}
+	set file [open $seendir "r"]
+	set database [read -nonewline $file]
+	close $file
+	set data [split $database "\n"]
+	set what [string map [list \[ {\[} \] {\]} \? {\?} \\ {\\}] $what]
+if {[matchattr $hand nmo]} {
+if {[regexp {\!} $what]} {
+	set test_host [lsearch -all [string tolower $data] [string tolower "* *#* * $what *"]]
+} else {
+if {[regexp -- {^[a-zA-Z\|\[\]`^\{\}][a-zA-Z0-9\-_\|\[\]`^\{\}\\]*$} $what]} {
+	seen:add_whosearch $nick $host $what $chan
+	}
+	set test [lsearch -all [string tolower $data] [string tolower "* *#* $what *"]]
+}
+} else {
+if {[regexp {\!} $what]} {
+	set test_host [lsearch -all [string tolower $data] [string tolower "* $chan * $what *"]]
+	} else {
+if {[regexp -- {^[a-zA-Z\|\[\]`^\{\}][a-zA-Z0-9\-_\|\[\]`^\{\}\\]*$} $what]} {
+	seen:add_whosearch $nick $host $what $chan
+		}
+	set test [lsearch -all [string tolower $data] [string tolower "* $chan $what *"]]
+	}
+}
+if {[string length $test] > 0} {
+foreach i $test {
+	set line [lindex $data $i]
+if {$line != ""} {
+	set userentry [lindex [split $line] 2]
+	set readhost [string map {"~" ""} [lindex [split $line] 3]]
+	set chanentry [lindex [split $line] 1]
+if {[info exists entry]} {
+if {[lsearch -exact [string tolower "$i:$userentry:$readhost"] [string tolower $entry]] == "-1"} {	
+	lappend entry "$i:$userentry:$readhost"
+					}
+				} else { lappend entry "$i:$userentry:$readhost" }
+			}
+		}
+	}
+
+if {[string length $test_host] > 0 && [string length $test] == 0} {
+foreach j $test_host {
+	set line [lindex $data $j]
+if {$line != ""} {
+	set userentry [lindex [split $line] 2]
+	set readhost [string map {"~" ""} [lindex [split $line] 3]]
+	set chanentry [lindex [split $line] 1]
+if {[info exists entry]} {
+if {[lsearch -exact [string tolower "$j:$userentry:$readhost"] [string tolower $entry]] == "-1"} {
+	lappend entry "$j:$userentry:$readhost"
+				}
+			} else { lappend entry "$j:$userentry:$readhost" }
+		}
+	}
+}
+
+if {[info exists entry]} {
+	set split_entry [split $entry ":"]
+	set get_host [lindex [split $split_entry] 2]
+	set get_line [lindex [split $split_entry] 0]
+	set get_nick [lindex [split $split_entry] 1]
+}
+
+#checking other entries
+if {[info exists get_host]} {
+if {[string length $test_host] < 1} {
+if {[matchattr $hand nmo]} {
+	set test [lsearch -all [string tolower $data] [string tolower "* *#* * $get_host *"]]
+} else {
+	set test [lsearch -all [string tolower $data] [string tolower "* $chan * $get_host *"]]
+}
+	foreach k $test {
+	if {$k != $get_line} {
+	set line [lindex $data $k]
+	set userentry [lindex [split $line] 2]
+	set readhost [string map {"~" ""} [lindex [split $line] 3]]
+if {[info exists entry]} {
+if {[lsearch -exact [string tolower "$k:$userentry:$readhost"] [string tolower $entry]] == "-1"} {
+	lappend entry "$k:$userentry:$readhost"
+					}					
+				} else { lappend entry "$k:$userentry:$readhost" }	
+			} 	
+		}
+	}
+}
+#
+if {[info exists entry]} {
+	seen:reply $entry $nick $hand $chan $chan1 $data "1" $host
+	} else {
+	blacktools:tell $nick $host $hand $chan $chan1 seen.18 $what
+	}
+}
+
+proc seen:add_whosearch {who host searched chan} {
+	global black
+	set search_time [unixtime]
+	set timestamp [clock format [clock seconds] -format {%Y%m%d%H%M%S}]
+	set temp "$black(tempdir)/seen_temp.$timestamp"
+	set addline "LASTSRC $chan $who $host $search_time $searched"
+	set file [open $black(seen_details) "r"]
+	set tempwrite [open $temp w]
+while {[gets $file line] != -1} {
+	set read_type [lindex [split $line] 0]
+	set read_chan [lindex [split $line] 1]
+	set enc_chan [encoding convertfrom utf-8 $read_chan]
+	set read_who [lindex [split $line] 3]
+	set read_src [lindex [split $line] 5]
+if {[string equal -nocase $read_type "LASTSRC"] && [string equal -nocase $chan $enc_chan] && [string equal -nocase $host $read_who] && [string equal -nocase $searched $read_src]} { 
+	continue
+		} else {
+	puts $tempwrite $line
+		}	
+	}
+	puts $tempwrite $addline
+	close $tempwrite
+	close $file
+    file rename -force $temp $black(seen_details)
+}
+
+proc seen:reply:src {nick host chan} {
+	global black
+	set chan1 $chan
+	set file [open $black(seen_details) "r"]	
+while {[gets $file line] != -1} {
+	set read_type [lindex [split $line] 0]
+	set read_chan [lindex [split $line] 1]
+	set enc_chan [encoding convertfrom utf-8 $read_chan]
+	set read_src [lindex [split $line] 5]
+if {[string equal -nocase $read_type "LASTSRC"] && [string equal -nocase $chan $enc_chan] && [string equal -nocase $read_src $nick]} {
+	set read_who [lindex [split $line] 2]
+	set read_who_h [lindex [split $line] 3]
+	set read_time [lindex [split $line] 4]
+	set read_time [clock format $read_time -format %D-%H:%M:%S]
+	blacktools:tell $nick "prv" "" $chan $chan1 seen.39 "$read_who $read_who_h $read_time"
+	seen:reply:remove $read_src $chan
+		}	
+	}
+	close $file
+}
+
+proc seen:reply:remove {nick chan} {
+	global black
+	set timestamp [clock format [clock seconds] -format {%Y%m%d%H%M%S}]
+	set temp "$black(tempdir)/seen_temp.$timestamp"
+	set file [open $black(seen_details) "r"]
+	set tempwrite [open $temp w]
+while {[gets $file line] != -1} {
+	set read_type [lindex [split $line] 0]
+	set read_chan [lindex [split $line] 1]
+	set enc_chan [encoding convertfrom utf-8 $read_chan]
+	set read_src [lindex [split $line] 5]
+if {[string equal -nocase $read_type "LASTSRC"] && [string equal -nocase $chan $enc_chan] && [string equal -nocase $nick $read_src]} { 
+	continue
+		} else {
+	puts $tempwrite $line
+		}	
+	}
+	close $tempwrite
+	close $file
+    file rename -force $temp $black(seen_details)
+}
+
+proc seen:getlastmsg {what chan nick host hand chan1} {
+global black username
+	set seendirlastmsg $black(seen_details)
+	set test_lastmsg_host ""
+	set test_lastmsg_nick ""
+	set file [open $seendirlastmsg "r"]
+	set database [read -nonewline $file]
+	close $file
+	set data [split $database "\n"]
+if {$database != ""} {
+	set test_lastmsg_nick [lsearch -all [string tolower $data] [string tolower "* *#* $what *"]]
+if {[regexp {\!} $what]} {
+	set test_lastmsg_host [lsearch -all [string tolower $data] [string tolower "* *#* * $what *"]]
+}
+	} else { return 0 }
+if {[llength $test_lastmsg_nick] < 1 && [llength $test_lastmsg_host] < 1} {
+	return 0
+}
+
+foreach i $test_lastmsg_nick {
+	set line [lindex $data $i]
+if {$line != ""} {
+	set userentry [lindex [split $line] 2]
+	set readhost [lindex [split $line] 3]
+if {[info exists entry]} {
+if {[lsearch -exact [string tolower "$i:$userentry:$readhost"] [string tolower $entry]] == "-1"} {	
+	lappend entry "$i:$userentry:$readhost"
+					}
+				} else { lappend entry "$i:$userentry:$readhost" }
+			}
+		}
+
+if {[string length $test_lastmsg_host] > 0 && [string length $test_lastmsg_nick] == 0} {
+foreach j $test_lastmsg_host {
+	set line [lindex $data $j]
+if {$line != ""} {
+	set userentry [lindex [split $line] 2]
+	set readhost [lindex [split $line] 3]
+if {[info exists entry]} {
+if {[lsearch -exact [string tolower "$j:$userentry:$readhost"] [string tolower $entry]] == "-1"} {
+	lappend entry "$j:$userentry:$readhost"
+					}
+				} else { lappend entry "$j:$userentry:$readhost" }
+			}
+		}
+	}
+
+if {[info exists entry]} {
+	set split_entry [split $entry ":"]
+	set get_host [lindex [split $split_entry] 2]
+	set get_line [lindex [split $split_entry] 0]
+	set get_nick [lindex [split $split_entry] 1]
+} else { return 0 }
+
+#checking other entries
+	
+if {[string length $test_lastmsg_host] < 1} {
+if {[string length $test_lastmsg_nick] == 1} {
+	set test [lsearch -all [string tolower $data] [string tolower "* * * $get_host *"]]
+	foreach k $test {
+	if {$k != $get_line} {
+	set line [lindex $data $k]
+	set userentry [lindex [split $line] 2]
+	set readhost [lindex [split $line] 3]
+if {[info exists entry]} {
+if {[lsearch -exact [string tolower "$k:$userentry:$readhost"] [string tolower $entry]] == "-1"} {
+	lappend entry "$k:$userentry:$readhost"
+					}					
+				} else { lappend entry "$k:$userentry:$readhost" }	
+			} 	
+		}
+	}
+}
+	seen:reply $entry $nick $hand $chan $data "1" $host
+}
+
+proc seen:reply {entry nick hand chan chan1 data lastmsg prv} {
+global black
+	array set seensort [list]
+	set getlang [string tolower [getuser $hand XTRA OUTPUT_LANG]]
+if {$getlang == ""} { set getlang "[string tolower $black(default_lang)]" }
+	set other_entry ""
+	set split_entry [join [split $entry " "]]
+foreach n $split_entry {
+if {$n != ""} {
+	set split_entry [split $n ":"]
+	set line_num [lindex $split_entry 0]
+	set data_line [lindex $data $line_num] 
+	set tm [lindex [split $data_line] 4]
+	set seensort($tm) $line_num
+	}
+}
+	foreach line [lsort -integer -decreasing -unique [array names seensort]] {
+	lappend top_seenlist $seensort($line)
+}
+	set split_seenlist [split $top_seenlist " "]
+	set first_entry_num [lindex $split_seenlist 0]
+	set first_entry [lindex $data $first_entry_num]
+	set first_entry [lindex [split $first_entry] 2]
+	set chanentry [lindex [split $data_line] 1]
+	set host [lindex [split $data_line] 3]
+	set jointime [lindex [split $data_line] 5]
+	set newnick [lindex [split $data_line] 6]
+	set reason [join [lrange [split $data_line] 6 end]]
+	set uhost $host
+	set host [string trim $host "*!~"]
+	set tm [lindex [split $data_line] 4]
+	set type [lindex [split $data_line] 0]
+	set lmsg [join [lrange [split $data_line] 5 end]]
+	
+if {[llength $entry] > 1} {
+	set other_entries [lrange $split_seenlist 1 end]
+	
+foreach n $other_entries {
+if {$n != ""} {
+	set other_entry_line [lindex $data $n]
+	set other_entry_line [lindex [split $other_entry_line] 2]
+	lappend other_entry $other_entry_line
+	}
+}
+	set all_entries  "$first_entry [join $other_entry]"
+} else {
+	set all_entries "$first_entry"
+}   
+	set all_entries [concat [join [lsort -unique [split $all_entries]]]]
+	set entry_count [llength [concat [split $all_entries]]]
+if {!([regexp {^[0-9]} $jointime]) || ($jointime == "")} {
+	set jointime 0
+	set reason [join [lrange [split $line] 5 end]]
+}
+
+if {$reason == ""} { set reason "N/A" }
+
+if {$entry_count >= 10} {
+	set all_entries "$first_entry"
+}
+
+	set output [return_time $getlang [expr [unixtime] - $tm]]
+	set staytime [expr [unixtime] - $jointime]
+	set staytime [return_time $getlang [expr $tm - $jointime]]
+	set time [clock format $tm -format %D-%H:%M:%S]
+	
+	set replace(%latest%) $first_entry
+	set replace(%num%) $entry_count
+	set replace(%entry%) "$all_entries"
+	set replace(%host%) "$host"
+	set replace(%output%) "$output"
+	set replace(%date%) "($time)"
+	set replace(%newnick%) "$newnick"
+	set replace(%userentry%) "$first_entry"
+	set replace(%chan%) "$chanentry"
+	set replace(%reason%) "$reason"
+	set replace(%staytime%) "$staytime"
+	set replace(%lastmsg%) "$lmsg"
+if {$jointime == "0"} { set staymsg "[string map [array get replace] $black(say.$getlang.seen.8)]"
+	set replace(%staymsg%) "$staymsg"
+} else {
+	set staymsg "[string map [array get replace] $black(say.$getlang.seen.9)]"
+	set replace(%staymsg%) "$staymsg"
+}
+
+if {$lastmsg == "1"} {
+	if {$entry_count > 1} {
+	set reply "[string map [array get replace] $black(say.$getlang.seen.30)]"
+
+	} else {
+	set reply "[string map [array get replace] $black(say.$getlang.seen.29)]"
+	}
+}
+
+if {$entry_count > 1} {
+	set found_many 1
+if {$type == "PART"} {
+if {$entry_count >= 10} {
+	set reply "[string map [array get replace] $black(say.$getlang.seen.33)]"
+} else {
+	set reply "[string map [array get replace] $black(say.$getlang.seen.21)]"
+	}
+}
+if {$type == "SIGN"} {
+if {$entry_count >= 10} {
+	set reply "[string map [array get replace] $black(say.$getlang.seen.34)]"
+	} else {
+	set reply "[string map [array get replace] $black(say.$getlang.seen.22)]"
+	}
+}
+if {$type == "JOIN"} {
+if {[onchan $first_entry $chanentry]} {
+	set nowon "[string map [array get replace] $black(say.$getlang.seen.19)]"
+	set replace(%nowon%) "$nowon"
+} else { 
+	set nowon "[string map [array get replace] $black(say.$getlang.seen.20)]"
+	set replace(%nowon%) "$nowon"
+}
+if {$entry_count >= 10} {
+	set reply "[string map [array get replace] $black(say.$getlang.seen.35)]"
+} else {
+	set reply "[string map [array get replace] $black(say.$getlang.seen.23)]"
+	}
+}
+if {$type == "SPLIT"} {
+if {$entry_count >= 10} {
+	set reply "[string map [array get replace] $black(say.$getlang.seen.36)]"
+} else {
+	set reply "[string map [array get replace] $black(say.$getlang.seen.24)]"
+	}
+}
+if {$type == "KICK"} {
+if {$entry_count >= 10} {
+	set reply "[string map [array get replace] $black(say.$getlang.seen.37)]"
+} else {
+	set reply "[string map [array get replace] $black(say.$getlang.seen.25)]"
+	}
+}
+if {$type == "NICKCHANGE"} {
+if {[onchan $newnick $chanentry]} { 
+	set nowon "[string map [array get replace] $black(say.$getlang.seen.10)]"
+	set replace(%nowon%) "$nowon"
+} else {
+	set nowon "[string map [array get replace] $black(say.$getlang.seen.11)]"
+	set replace(%nowon%) "$nowon"
+}
+if {$entry_count >= 10} {
+	set reply "[string map [array get replace] $black(say.$getlang.seen.38)]"
+} else {
+	set reply "[string map [array get replace] $black(say.$getlang.seen.26)]"
+		}
+	}
+} else {
+
+if {$type == "PART"} {
+	set reply "[string map [array get replace] $black(say.$getlang.seen.12)]"
+}
+if {$type == "SIGN"} {
+	set reply "[string map [array get replace] $black(say.$getlang.seen.13)]"
+
+}
+if {$type == "JOIN"} {
+if {[onchan $first_entry $chanentry]} { 
+	set nowon "[string map [array get replace] $black(say.$getlang.seen.19)]"
+	set replace(%nowon%) "$nowon"
+} else { 
+	set nowon "[string map [array get replace] $black(say.$getlang.seen.11)]"
+	set replace(%nowon%) "$nowon"
+}
+	set reply "[string map [array get replace] $black(say.$getlang.seen.14)]"
+}
+if {$type == "SPLIT"} {
+	set reply "[string map [array get replace] $black(say.$getlang.seen.15)]"
+}
+if {$type == "KICK"} {
+	set reply "[string map [array get replace] $black(say.$getlang.seen.16)]"
+}
+if {$type == "NICKCHANGE"} {
+if {[onchan $newnick $chanentry]} { 
+	set nowon "[string map [array get replace] $black(say.$getlang.seen.10)]"
+	set replace(%nowon%) "$nowon"
+} else {
+	set nowon "[string map [array get replace] $black(say.$getlang.seen.11)]"
+	set replace(%nowon%) "$nowon"
+}
+	set reply "[string map [array get replace] $black(say.$getlang.seen.17)]"
+			}
+		}
+if {[string equal -nocase $prv "prv"]} {
+	blacktools:tell $nick "prv" $hand $chan $nick seen.27 $reply
+	seenreply:all $nick $uhost $hand $chan $nick $chanentry $first_entry "prv"
+} else {	
+	blacktools:tell $nick $host $hand $chan $chan1 seen.27 $reply
+	seenreply:all $nick $uhost $hand $chan $chan1 $chanentry $first_entry ""
+}
+	}
+
+	
+proc seenreply:all {nick host hand chan chan1 chanentry first_entry prv} {
+global black username
+	set first_entry [join [split $first_entry]]
+	set seendirlastmsg $black(seen_details)
+	set getlang [string tolower [getuser $hand XTRA OUTPUT_LANG]]
+if {$getlang == ""} { set getlang "[string tolower $black(default_lang)]" }
+if {[setting:get $chanentry seenlastmsg]} {
+	set file [open $seendirlastmsg "r"]
+	set database [read -nonewline $file]
+	close $file
+	set data [split $database "\n"]
+	
+if {$database != ""} {
+	set test_reply [lsearch -all [string tolower $data] [string tolower "* $chanentry * $host *"]]
+	if {[llength $test_reply] > 0} {
+	set line [lindex $data $test_reply]
+	set userentry [lindex [split $line] 2]
+	set gettime [lindex [split $line] 4]
+	set output [return_time $getlang [expr [unixtime] - $gettime]]
+	set replace(%output%) "$output"
+	set replace(%userentry%) "$userentry"
+	set replace(%chan%) "$chanentry"
+	set replace(%host%) "$host"
+	set replace(%lastmsg%) [join [lrange [split $line] 5 end]]
+	set reply "[string map [array get replace] $black(say.$getlang.seen.32)]"
+if {[string equal -nocase $prv "prv"]} {
+	set host "$prv"
+}
+	
+	blacktools:tell $nick $host $hand $chan $chan1 seen.27 $reply
+		} else {
+	blacktools:tell $nick $host $hand $chan $chan1 seen.31 [split $first_entry]
+			}
+		}
+	}	
+}
+	
+##############
+#########################################################################
+##   END                                                               ##
+#########################################################################

+ 326 - 0
BlackTools2.5/BlackTools/Modules/BT.TCL.tcl

@@ -0,0 +1,326 @@
+#########################################################################
+##          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                                                               ##
+#########################################################################

+ 149 - 0
BlackTools2.5/BlackTools/Modules/BT.Timer.tcl

@@ -0,0 +1,149 @@
+#########################################################################
+##          BlackTools - The Ultimate Channel Control Script           ##
+##                    One TCL. One smart Eggdrop                       ##
+#########################################################################
+#############################   TIMER 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 timerpublic {nick host hand chan arg} {
+	global black lastbind
+	set chan1 $chan
+	set cmd [lindex [split $arg] 0]
+	set pid [lindex [split $arg] 1]
+	set timer_args [join [lrange [split $arg] 2 end]]
+	set type 0
+	set return [blacktools:mychar $lastbind $hand]
+if {$return == "0"} {
+		return
+}
+	timer:process $nick $host $hand $chan $chan1 $cmd $pid $timer_args $type
+}
+
+proc timer:process {nick host hand chan chan1 cmd pid timer_args type} {
+	global black
+	set counter 0
+if {[matchattr $hand q]} { blacktools:tell $nick $host $hand $chan $chan1 gl.glsuspend none
+	return
+}
+if {[matchattr $hand -|q $chan]} { blacktools:tell $nick $host $hand $chan $chan1 gl.suspend none
+	return
+}
+if {$cmd == ""} {
+switch $type {
+	0 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr "timer"
+	}
+	1 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr_nick "timer"
+	}
+	2 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr_priv "timer"
+		}
+	}
+	return
+}
+switch [string tolower $cmd] {
+	list {
+	blacktools:tell $nick $host $hand $chan $chan1 timer.1 none
+foreach tmr [timers] {
+	set counter [expr $counter + 1]
+	set time [lindex $tmr 0]
+	set process [join [lindex $tmr 1]]
+	set pid [lindex $tmr 2]
+	blacktools:tell $nick $host $hand $chan $chan1 timer.2 "$counter $pid $time $process"
+		}
+foreach tmr [utimers] {
+	set counter [expr $counter + 1]
+	set time [lindex $tmr 0]
+	set process [join [lindex $tmr 1]]
+	set pid [lindex $tmr 2]
+	blacktools:tell $nick $host $hand $chan $chan1 timer.3 "$counter $pid $time $process"
+			}
+	blacktools:tell $nick $host $hand $chan $chan1 timer.4 none		
+		}
+		
+kill {
+	set found_pid 0
+if {$pid == ""} {
+switch $type {
+	0 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr "timer"
+	}
+	1 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr_nick "timer"
+	}
+	2 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr_priv "timer"
+		}
+	}
+	return
+}
+
+foreach tmr [timers] {
+	set getpid [lindex $tmr 2]
+if {[string equal -nocase $getpid $pid]} {
+	set found_pid 1
+	killtimer $getpid
+	break
+				}
+			}
+foreach tmr [utimers] {
+	set getpid [lindex $tmr 2]
+if {[string equal -nocase $getpid $pid]} {
+	set found_pid 1
+	killutimer $getpid
+	break
+				}
+			}
+if {$found_pid == "1"} {
+	blacktools:tell $nick $host $hand $chan $chan1 timer.5 $pid
+			} else {
+	blacktools:tell $nick $host $hand $chan $chan1 timer.6 $pid
+		}
+	}
+start {		
+	set return_time [time_return_minute $pid]
+	set found_timer 0
+if {$timer_args == "" || $return_time == "-1"} {
+switch $type {
+	0 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr "timer"
+	}
+	1 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr_nick "timer"
+	}
+	2 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr_priv "timer"
+		}
+	}
+	return
+}
+
+foreach tm [timers] {
+	set process [join [lindex $tm 1]]
+if {[string equal -nocase $process [lindex [split $timer_args] 0]]} {
+	set found_timer 1
+	}
+}
+if {$found_timer == "1"} {
+	blacktools:tell $nick $host $hand $chan $chan1 timer.8 none
+	return
+}
+	set check_timer [timer $return_time $timer_args]
+	blacktools:tell $nick $host $hand $chan $chan1 timer.7 $check_timer
+		}
+	}
+}
+
+##############
+#########################################################################
+##   END                                                               ##
+#########################################################################

+ 404 - 0
BlackTools2.5/BlackTools/Modules/BT.TopWords.tcl

@@ -0,0 +1,404 @@
+#########################################################################
+##          BlackTools - The Ultimate Channel Control Script           ##
+##                    One TCL. One smart Eggdrop                       ##
+#########################################################################
+###########################   TOPWORDS 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 topwords:delexcept {user nick host hand chan chan1} {
+	global black
+	set user [join $user]
+	set show_user [split $user]	
+if {[onchan $user $chan]} {
+	set getuser [nick2hand $user]
+if {$getuser != "*"} {
+	set user $getuser
+	}
+}
+
+if {![validuser $user]} { 
+	blacktools:tell $nick $host $hand $chan $chan1 gl.nomem none
+	return
+}
+
+if {![matchattr $user "-|w" $chan]} {
+	blacktools:tell $nick $host $hand $chan $chan1 topwords.20 "$show_user"
+	return
+}
+	chattr $user -|-w $chan
+	blacktools:tell $nick $host $hand $chan $chan1 topwords.21 "$show_user"
+}
+
+proc topwords:addexcept {user nick host hand chan chan1} {
+	global black
+	set user [join $user]
+	set show_user [split $user]
+if {![onchan $user $chan]} {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.usernotonchan $show_user
+	return
+}
+	set mask [return_mask [return_host_num "topwords" $chan] [getchanhost $user $chan] $user]
+	
+if {[validuser $user]} {
+	set user $user
+} else {
+if {[nick2hand $user] == "*"} {
+	set user $user
+	} else {
+	set user [nick2hand $user]
+	}	
+}
+foreach usr [userlist] {
+	set hst [getuser $usr hosts]
+foreach hhost $hst {
+if {[string match -nocase $hhost $mask] && (![string match -nocase $usr $user])} {
+	blacktools:tell $nick $host $hand $chan $chan1 add.5 [split $usr]
+	set user $usr
+	set show_user [split $usr]
+		}
+	}
+}
+
+if {[validuser $user]} {
+if {[matchattr $user -|w $chan]} {
+	blacktools:tell $nick $host $hand $chan $chan1 topwords.17 $show_user
+	return
+}
+	chattr $user -|+w $chan
+	blacktools:tell $nick $host $hand $chan $chan1 topwords.15 $show_user
+} else {
+	adduser $user $mask
+	chattr $user -|+w $chan
+	blacktools:tell $nick $host $hand $chan $chan1 topwords.16 "$show_user $mask"
+	}
+}
+
+proc topwords {nick host hand chan arg} {
+global black lastbind
+	set next [lindex [split $arg] 0]
+	set cmd ""
+	set type 0
+	set chan1 "$chan"
+	set return [blacktools:mychar $lastbind $hand]
+if {$return == "0"} {
+		return
+}
+if {[string equal -nocase $next "reset"] && [matchattr $hand nmo|M $chan]} {
+	set cmd "reset"
+}
+if {[string equal -nocase $next "total"]} {
+	set next [lindex [split $arg] 1]
+	set cmd "total"
+}
+if {[string equal -nocase $next "add"] && [matchattr $hand nmo|M $next]} {
+	set next [lindex [split $arg] 1]
+	set cmd "add"
+}
+if {[string equal -nocase $next "del"] && [matchattr $hand nmo|M $next]} {
+	set next [lindex [split $arg] 1]
+	set cmd "del"
+}
+if {[regexp {^[&#]} $next] && [matchattr $hand nmo|MAOV $next]} {
+	set chan $next
+	set next [lindex [split $arg] 1]
+if {[string equal -nocase $next "reset"] && [matchattr $hand nmo|M $next]} {
+	set cmd "reset"
+}
+if {[string equal -nocase $next "total"]} {
+	set next [lindex [split $arg] 2]
+	set cmd "total"
+	}
+if {[string equal -nocase $next "add"] && [matchattr $hand nmo|M $next]} {
+	set next [lindex [split $arg] 2]
+	set cmd "add"
+	}
+if {[string equal -nocase $next "del"] && [matchattr $hand nmo|M $next]} {
+	set next [lindex [split $arg] 2]
+	set cmd "del"
+	}
+}
+	topwords:process $nick $host $hand $chan $chan1 $cmd $type $next
+}
+
+proc topwords:process {nick host hand chan chan1 cmd type next} {
+global botnick black
+	set cmd_status [btcmd:status $chan $hand "topwords" 0]
+if {$cmd_status == "1"} { 
+	return 
+}
+if {[matchattr $hand q]} { blacktools:tell $nick $host $hand $chan $chan1 gl.glsuspend none
+	return
+}
+if {[matchattr $hand -|q $chan]} { blacktools:tell $nick $host $hand $chan $chan1 gl.suspend none
+	return
+}
+if {![validchan $chan]} {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.novalidchan none
+	return
+}
+
+if {[string equal -nocase $next "list"]} {
+	set list [userlist "-|w" $chan]
+	blacktools:tell $nick $host $hand $chan $chan1 topwords.18 "none"
+if {$list == ""} {set list "NONE"}
+	blacktools:tell $nick $host $hand $chan $chan1 topwords.19 "$list"
+	return
+}
+
+if {[string equal -nocase $cmd "del"]} {
+if {$next == ""} {
+switch $type {
+	0 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr "topwords"
+	}
+	1 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr_nick "topwords"
+	}
+	2 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr_priv "topwords"
+		}
+	}
+	return
+}
+	topwords:delexcept $next $nick $host $hand $chan $chan1
+	return
+}
+
+if {[string equal -nocase $cmd "add"]} {
+if {$next == ""} {
+switch $type {
+	0 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr "topwords"
+	}
+	1 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr_nick "topwords"
+	}
+	2 {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.instr_priv "topwords"
+		}
+	}
+	return
+}
+	topwords:addexcept $next $nick $host $hand $chan $chan1
+	return
+}
+if {[string equal -nocase $cmd "reset"]} {
+	set reset [topwords:reset $chan]
+if {$reset == "1"} {
+	blacktools:tell $nick $host $hand $chan $chan1 topwords.8 none
+} else {
+	blacktools:tell $nick $host $hand $chan $chan1 topwords.10 none
+}
+return
+}
+	array set topwordslist [list]
+	set timestamp [clock format [clock seconds] -format {%Y%m%d%H%M%S}]
+	set temp "$black(tempdir)/topwords_temp.$timestamp"
+	set counter 0
+	set file [open $black(topwords_file) "r"]
+	set w [read -nonewline $file]
+	close $file
+	set data [split $w "\n"]
+foreach line $data {
+	set read_chan [lindex [split $line] 0]
+	set enc_chan [encoding convertfrom utf-8 $read_chan]
+if {[string match -nocase $enc_chan $chan]} {
+if {$cmd == "total"} {
+	set words_count [lindex [split $line] 4]
+} else {
+	set words_count [lindex [split $line] 5]
+}
+	set read_time [lindex [split $line] 31]
+	set read_nick [lindex [split $line] 1]
+if {$words_count > 0} {
+lappend topwordslist($words_count) $read_nick:$read_time
+		}
+	}
+}
+	set tempwrite [open $temp w]
+	set latestuser ""
+	set latesttime 0
+foreach words [lsort -integer -decreasing [array names topwordslist]] {
+	set counter [expr $counter + 1]
+foreach user $topwordslist($words) {
+	set split_user [split $user ":"]
+	set theuser [lindex $split_user 0]
+	set thetime [lindex $split_user 1]
+if {$thetime > $latesttime} {
+	set latesttime $thetime
+	set latestuser $theuser
+} else {
+	set latesttime $latesttime
+	set latestuser $theuser
+	}
+}
+	puts $tempwrite "$latestuser $words $counter"
+	}
+	close $tempwrite
+	set file [open $temp "r"]
+	set w [read -nonewline $file]
+	close $file
+	set data [split $w "\n"]
+	file delete $temp
+if {$w == ""} {
+if {$cmd == "total"} {
+	blacktools:tell $nick $host $hand $chan $chan1 topwords.7 none
+} else {
+	blacktools:tell $nick $host $hand $chan $chan1 topwords.14 none
+}
+	return
+}
+if {$cmd == "total"} {
+	module:getinfo $nick $host $hand $chan $chan1 $type $data "topwords:total" "0" $next
+} else {
+	module:getinfo $nick $host $hand $chan $chan1 $type $data "topwords" "0" $next
+	}
+}
+
+proc topwords:module {nick host hand chan arg} {
+	global black
+	set arg [split $arg]
+	set mask [return_mask [return_host_num "topwords" $chan] $host $nick]
+	set handle [nick2hand $nick]
+if {[setting:get $chan topwords]} {
+
+if {[isbotnick $nick]} {
+	return
+}
+if {[validuser $handle]} {
+if {[matchattr $handle -|w $chan]} {
+	return
+	}
+}
+if {[setting:get $chan accessonly]} {
+if {![validuser $hand]} {
+	return
+}
+if {![matchattr $hand $black(exceptflags) $chan]} {
+	return
+	}
+}
+	set time [unixtime]
+	set list_hours {00:0 01:0 02:0 03:0 04:0 05:0 06:0 07:0 08:0 09:0 10:0 11:0 12:0 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0 22:0 23:0}
+	set found_entry 0
+	set h_counter 0
+	set h [clock format $time -format %H]
+	set file [open $black(topwords_file) "r"]
+	set timestamp [clock format [clock seconds] -format {%Y%m%d%H%M%S}]
+	set temp "$black(tempdir)/topwords_temp.$timestamp"
+	set tempwrite [open $temp w]
+while {[gets $file line] != -1} {
+	set read_chan [lindex [split $line] 0]
+	set read_host [lindex [split $line] 2]
+	set real_read_host [string map [list \[ {\[} \] {\]} \? {\?} \\ {\\}] $read_host]
+	set enc_chan [encoding convertfrom utf-8 $read_chan]
+if {[string equal -nocase $enc_chan $chan] && [string equal -nocase $real_read_host $mask]} {
+	set found_entry 1
+	set nr_letter [lindex [split $line] 3]
+	set nr_words [lindex [split $line] 4]
+	set words_today [lindex [split $line] 5]
+	set nr_lines [lindex [split $line] 6]
+	set hours [lrange [split $line] 7 30]
+foreach hour $hours {
+	set split_hour [split $hour ":"]
+	set the_hour [lindex $split_hour 0]
+	set counter [lindex $split_hour 1]
+if {$the_hour == $h} {
+	set h_counter $counter
+	}
+}
+	continue
+} else {
+	puts $tempwrite $line
+		}
+    }
+	set chars [string length [string map {" " ""} $arg]]
+	set words [llength $arg]
+	set lines 1
+if {$found_entry == "1"} {
+	set list_hours2 [topwords:return_hours $h_counter $h $hours]
+	puts $tempwrite "$chan $nick $mask [expr $nr_letter + $chars] [expr $nr_words + $words] [expr $words_today + $words] [expr $nr_lines + $lines] $list_hours2 $time"
+	} else {
+	set list_hours2 [topwords:return_hours 0 $h $list_hours]
+	puts $tempwrite "$chan $nick $mask $chars $words $words $lines $list_hours2 $time"
+}
+	close $tempwrite
+	close $file
+    file rename -force $temp $black(topwords_file)
+	}
+}
+
+proc topwords:module:me {nick host hand chan keyword arg} {
+global black
+	topwords:module $nick $host $hand $chan $arg
+}
+
+proc topwords:reset {chan} {
+	global black
+	set found_entry 0
+	set file [open $black(topwords_file) "r"]
+	set timestamp [clock format [clock seconds] -format {%Y%m%d%H%M%S}]
+	set temp "$black(tempdir)/topwords_temp.$timestamp"
+	set tempwrite [open $temp w]
+while {[gets $file line] != -1} {
+	set read_chan [lindex [split $line] 0]
+	set enc_chan [encoding convertfrom utf-8 $read_chan]
+if {[string equal -nocase $chan $enc_chan]} {
+	set found_entry 1
+	continue
+		} else {
+	puts $tempwrite $line	
+		}
+	}
+		close $tempwrite
+		close $file
+		file rename -force $temp $black(topwords_file)
+	return $found_entry
+}
+
+proc topwords:day:reset {minute hour day month year} {
+	global black
+	set file [open $black(topwords_file) "r"]
+	set timestamp [clock format [clock seconds] -format {%Y%m%d%H%M%S}]
+	set temp "$black(tempdir)/topwords_temp.$timestamp"
+	set tempwrite [open $temp w]
+while {[gets $file line] != -1} {
+	set chan [lindex [split $line] 0]
+	set nick [lindex [split $line] 1]
+	set host [lindex [split $line] 2]
+	set time [lindex [split $line] 31]
+	set nr_letter [lindex [split $line] 3]
+	set nr_words [lindex [split $line] 4]
+	set words_today [lindex [split $line] 5]
+	set nr_lines [lindex [split $line] 6]
+	set hours [lrange [split $line] 7 30]
+	puts $tempwrite "$chan $nick $host $nr_letter $nr_words 0 $nr_lines $hours $time"
+	}
+	close $tempwrite
+	close $file
+    file rename -force $temp $black(topwords_file)
+}
+
+proc topwords:return_hours {num hour hours} {
+	global black
+	set thehours $hours
+if {[lsearch -glob $thehours "$hour:*"] > -1} {
+	set position [lsearch -glob $thehours "$hour:*"]
+	set thehours [lreplace $thehours $position $position]
+	set thehours [linsert $thehours $position "$hour:[expr $num + 1]"]
+	}
+	return $thehours
+}
+
+##############
+#########################################################################
+##   END                                                               ##
+#########################################################################

+ 89 - 0
BlackTools2.5/BlackTools/Modules/BT.Topic.tcl

@@ -0,0 +1,89 @@
+#########################################################################
+##          BlackTools - The Ultimate Channel Control Script           ##
+##                    One TCL. One smart Eggdrop                       ##
+#########################################################################
+#############################   TOPIC 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 topic:autotopic {nick host hand chan} {
+	global black
+if {![validchan $chan]} { return }
+if {[setting:get $chan autotopic]} {
+	utimer 5 [list  topic:join:act $chan]
+	}
+}
+
+proc topic:join:act {chan} {
+	global black
+if {![botisop $chan]} {
+	return
+}
+	set gettopic ""
+	set file [open $black(join_file) r]
+while {[gets $file line] != -1} {
+	set read_modul [lindex [split $line] 0]
+	set read_chan [lindex [split $line] 1]
+if {[string equal -nocase $read_modul "topic"] && [string equal -nocase $chan $read_chan]} {	
+	set read_msg [lrange [split $line] 2 end]
+	set gettopic [encoding convertfrom utf-8 $read_msg]
+	}
+}
+	close $file
+if {$gettopic != ""} {
+	set chantopic [topic $chan]
+if {$chantopic != $gettopic} {
+	set url [setting:get $chan url]
+if {$url != ""} {
+	putserv "TOPIC $chan :[join $gettopic] ($url)"
+			} else { putserv "TOPIC $chan :[join $gettopic]" }
+		}
+	}
+}
+
+proc topic:return {chan} {
+	global black
+	set gettopic ""
+	set file [open $black(join_file) r]
+while {[gets $file line] != -1} {
+	set read_modul [lindex [split $line] 0]
+	set read_chan [lindex [split $line] 1]
+if {[string equal -nocase $read_modul "topic"] && [string equal -nocase $chan $read_chan]} {	
+	set read_msg [lrange [split $line] 2 end]
+	set gettopic [encoding convertfrom utf-8 $read_msg]
+		}
+	}
+	close $file
+	return $gettopic
+}
+
+proc topicpublic {nick host hand chan arg} {
+	global black lastbind
+	set who [lindex [split $arg] 0]
+	set modul "topic"
+	set type 0
+	set chan1 $chan
+	set topic [join [lrange [split $arg] 1 end]]
+if {[regexp {^[&#]} $who] && [matchattr $hand nmo|M $who]} {
+	set chan $who
+	set who [lindex [split $arg] 1]
+	set topic [join [lrange [split $arg] 2 end]]
+	}
+	set return [blacktools:mychar $lastbind $hand]
+if {$return == "0"} {
+		return
+}
+	othermodule:process $nick $host $hand $chan $chan1 $who $topic $type $modul	
+}
+
+##############
+#########################################################################
+##   END                                                               ##
+#########################################################################

+ 115 - 0
BlackTools2.5/BlackTools/Modules/BT.VoiceMe.tcl

@@ -0,0 +1,115 @@
+#########################################################################
+##          BlackTools - The Ultimate Channel Control Script           ##
+##                    One TCL. One smart Eggdrop                       ##
+#########################################################################
+###########################   VOICEME 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 voiceme:join {nick host hand chan} {
+	global black
+if {[isbotnick $nick]} {
+if {[setting:get $chan voiceme]} {
+	utimer 30 [list voiceme:check:valid $chan]	
+		}
+	}	
+}
+
+proc voiceme:mode {nick host hand chan mod who} {
+	global black
+if {[setting:get $chan voiceme]} {
+if {$mod == "+m"} {
+foreach tmr [utimers] {
+if {[string match -nocase "*voiceme:check:valid $chan*" [join [lindex $tmr 1]]]} {
+	killutimer [lindex $tmr 2]
+		}
+	}
+	utimer 30 [list voiceme:check:valid $chan]
+}
+if {$mod == "-m"} {
+	foreach tmr [utimers] {
+if {[string match -nocase "*voiceme:check:nomod $chan*" [join [lindex $tmr 1]]]} {
+	killutimer [lindex $tmr 2]
+		}
+	}
+	utimer 15 [list voiceme:check:nomod $chan]
+		}
+	}
+}
+
+proc voiceme:check:nomod {chan} {
+	global black botnick
+	set getlang [string tolower [setting:get $chan lang]]
+if {$getlang == ""} { set getlang "[string tolower $black(default_lang)]" }
+	set chanmode [getchanmode $chan]
+if {[string match "*m*" $chanmode]} {
+	return
+}
+if {[info exists black(voiceme:stat:$chan)]} {
+	set replace(%chan%) $chan
+	set replace(%botnick%) $botnick
+	puthelp "PRIVMSG $chan :[string map [array get replace] $black(say.$getlang.voiceme.2)]"
+if {[info exists black(voiceme:stat:$chan)]} {
+	unset black(voiceme:stat:$chan)
+		}
+	}
+}
+
+proc voiceme:check:valid {chan} {
+	global black botnick
+	set getlang [string tolower [setting:get $chan lang]]
+if {$getlang == ""} { set getlang "[string tolower $black(default_lang)]" }
+	set replace(%chan%) $chan
+	set replace(%botnick%) $botnick
+	set replace(%chanserv%) $black(chanserv)
+	set chanmode [getchanmode $chan]
+if {[info exists black(voiceme:stat:$chan)]} {
+	return
+}
+if {[string match "*m*" $chanmode]} {
+	set black(voiceme:stat:$chan) 1
+	puthelp "PRIVMSG $chan :[string map [array get replace] $black(say.$getlang.voiceme.1)]"
+	set voicemsg_time [time_return_minute $black(voiceme:msgtime)]
+	timer $voicemsg_time voiceme:showmsg_timer
+	}
+}
+
+proc voiceme:showmsg_timer {} {
+	global black botnick
+	set found_entry 0
+	set voicemsg_time [time_return_minute $black(voiceme:msgtime)]
+foreach chan [channels] {
+if {[setting:get $chan voiceme]} {
+	set getlang [string tolower [setting:get $chan lang]]
+	set replace(%botnick%) $botnick
+	set replace(%chanserv%) $black(chanserv)
+if {$getlang == ""} { set getlang "[string tolower $black(default_lang)]" }
+	set replace(%chan%) $chan
+if {![info exists black(voiceme:stat:$chan)]} {
+	continue
+			} else {
+	puthelp "PRIVMSG $chan :[string map [array get replace] $black(say.$getlang.voiceme.1)]"
+	set found_entry 1
+			}
+		} else {
+if {[info exists black(voiceme:stat:$chan)]} {		
+	unset black(voiceme:stat:$chan)	
+			}
+		}
+	}
+if {$found_entry == "1"} {
+	timer $voicemsg_time voiceme:showmsg_timer
+	}
+}
+
+##############
+#########################################################################
+##   END                                                               ##
+#########################################################################

+ 205 - 0
BlackTools2.5/BlackTools/Modules/BT.VoiceOnMsg.tcl

@@ -0,0 +1,205 @@
+#########################################################################
+##          BlackTools - The Ultimate Channel Control Script           ##
+##                    One TCL. One smart Eggdrop                       ##
+#########################################################################
+###########################   VOICEONMSG 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 voiceonmsg:public:me {nick host hand chan keyword arg} {
+	global black
+	voiceonmsg:public $nick $host $hand $chan $arg
+}
+
+proc voiceonmsg:public {nick host hand chan arg} {
+	global black
+if {![validchan $chan]} {
+	return
+}
+if {[setting:get $chan voiceonmsg]} {
+if {![info exists black(voiceonmsg:list:$chan)]} {
+	set black(voiceonmsg:list:$chan) ""
+}
+	set host "$nick"
+if {[isvoice $nick $chan]} { return }
+if {[isop $nick $chan]} { return }
+if {![botisop $chan]} { return }
+if {![info exists black(voiceonmsg:$host:$chan)]} {
+if {[lsearch -exact [string tolower $black(voiceonmsg:list:$chan)]  [string tolower $host]] == -1} {
+	lappend black(voiceonmsg:list:$chan) $host
+}
+	set black(voiceonmsg:$host:$chan) 1
+	utimer 300 [list voiceonmsg:remove $host $chan]
+	return
+}
+if {[lsearch -exact [string tolower $black(voiceonmsg:list:$chan)]  [string tolower $host]] == -1} {
+	lappend black(voiceonmsg:list:$chan) $host
+}
+	set current_count $black(voiceonmsg:$host:$chan)
+	set black(voiceonmsg:$host:$chan) [expr $current_count + 1]
+	
+foreach tmr [utimers] {
+if {[string match "*voiceonmsg:remove:expire $host $chan*" [join [lindex $tmr 1]]]} {
+	killutimer [lindex $tmr 2]
+			}	
+		}
+	utimer 300 [list voiceonmsg:remove:expire $host $chan]
+	set linenum [setting:get $chan voiceonmsg-linenum]
+if {$linenum == ""} {
+	set linenum $black(voiceonmsg:linenum)
+}
+if {$black(voiceonmsg:$host:$chan) >= $linenum} {
+	utimer 2 [list pushmode $chan +v $nick]
+	voiceonmsg:remove $host $chan
+		}
+	}
+}
+
+proc voiceonmsg:remove {host chan} {
+	global black
+	foreach tmr [utimers] {
+if {[string match "*voiceonmsg:remove:expire $host $chan*" [join [lindex $tmr 1]]]} {
+	killutimer [lindex $tmr 2]
+		}
+if {[string match "*voiceonmsg:remove $host $chan*" [join [lindex $tmr 1]]]} {
+	killutimer [lindex $tmr 2]
+		}
+	}
+}
+
+proc voiceonmsg:remove:the_list {h chan} {
+	global black
+if {[info exists black(voiceonmsg:list:$chan)]} {
+if {[lsearch -exact [string tolower $black(voiceonmsg:list:$chan)] [string tolower $h]] > -1} {
+	set position [lsearch -exact [string tolower $black(voiceonmsg:list:$chan)] [string tolower $h]]
+	set black(voiceonmsg:list:$chan) [lreplace $black(voiceonmsg:list:$chan) $position $position]
+		}
+	}
+}
+
+proc voiceonmsg:remove:expire {host chan} {
+	global black
+	foreach tmr [utimers] {
+if {[string match "*voiceonmsg:remove:expire $host $chan*" [join [lindex $tmr 1]]]} {
+	killutimer [lindex $tmr 2]
+		}
+	}
+
+if {[info exists black(voiceonmsg:$host:$chan)]} {
+	unset black(voiceonmsg:$host:$chan)
+	}
+}
+
+proc voiceonmsg:changenick {nick host hand chan newnick} {
+	global black
+if {![validchan $chan]} {
+	return
+}
+if {[setting:get $chan voiceonmsg]} {
+if {[info exists black(voiceonmsg:list:$chan)] && $black(voiceonmsg:list:$chan) != ""} {
+	set h $nick
+if {[lsearch -exact [string tolower $black(voiceonmsg:list:$chan)] [string tolower $h]] > -1} {
+	set position [lsearch -exact [string tolower $black(voiceonmsg:list:$chan)] [string tolower $h]]
+	set black(voiceonmsg:list:$chan) [lreplace $black(voiceonmsg:list:$chan) $position $position]
+			}
+	lappend black(voiceonmsg:list:$chan) $newnick
+if {[info exists black(voiceonmsg:$h:$chan)]} {
+	set black(voiceonmsg:$newnick:$chan) $black(voiceonmsg:$h:$chan)
+	unset black(voiceonmsg:$h:$chan)
+			}
+		}
+	}
+}
+
+proc voiceonmsg:part {nick host hand chan arg} {
+	global black
+	voiceonmsg:remove:expire $nick $chan
+	voiceonmsg:remove:the_list $nick $chan
+}
+
+proc voiceonmsg:split {nick host hand chan args} {
+	global black
+	voiceonmsg:remove:expire $nick $chan
+	voiceonmsg:remove:the_list $nick $chan
+}
+
+proc voiceonmsg:kick {nick host hand chan kicked reason} {
+	global black
+	voiceonmsg:remove:expire $kicked $chan
+	voiceonmsg:remove:the_list $kicked $chan
+}
+
+proc voiceonmsg:timer {} {
+	global black
+	set channels ""
+foreach chan [channels] {
+if {[setting:get $chan voiceonmsg]} {
+	lappend channels $chan
+		}
+	}
+if {$channels != ""} {
+	voiceonmsg:act $channels 0
+	timer 1 voiceonmsg:timer
+	}
+}
+
+proc voiceonmsg:act {channels counter} {
+	global black
+	set chan [lindex $channels $counter]
+	set cc [expr $counter + 1]
+if {[info exists black(voiceonmsg:list:$chan)] && $black(voiceonmsg:list:$chan) != ""} {
+foreach nick [chanlist $chan] {
+	set h $nick
+	set position [lsearch -exact [string tolower $black(voiceonmsg:list:$chan)] [string tolower $h]]
+if {$position > -1} {
+	set handle [nick2hand $nick $chan]
+if {![matchattr $handle "-|gf" $chan]} {
+	set idletime [setting:get $chan voiceonmsg-idletime]
+if {$idletime == ""} {
+	set idletime $black(voiceonmsg:idletime)
+}
+	set idletime [time_return_minute $idletime]
+if {[getchanidle $nick $chan] >= $idletime} {
+if {[isvoice $nick $chan]} {
+	utimer 2 [list pushmode $chan -v $nick]
+			}	
+	voiceonmsg:remove:expire $h $chan
+	voiceonmsg:remove:the_list $h $chan
+		}
+	}
+} else {
+
+if {![info exists black(voiceonmsg:$h:$chan)]} {
+	voiceonmsg:remove:the_list $h $chan
+		} else {	
+	voiceonmsg:remove:expire $h $chan
+	voiceonmsg:remove:the_list $h $chan
+				}
+			}
+		}
+	}
+if {[lindex $channels $cc] == ""} {
+	return
+	} else {
+	voiceonmsg:act $channels $cc
+	}
+}
+
+proc remove:flood:join {chan} {
+	global black
+if {[info exists black(countflood:join:$chan)]} {
+	unset black(countflood:join:$chan)
+	}
+}
+
+##############
+#########################################################################
+##   END                                                               ##
+#########################################################################