فهرست منبع

Add files via upload

Florian 8 سال پیش
والد
کامیت
926bcc60c0

+ 272 - 0
BlackTools2.5.2/Modules/BT.Anunt.tcl

@@ -0,0 +1,272 @@
+#########################################################################
+##          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/	                       ##
+##   GitHub page : https://github.com/tclscripts/BlackToolS-TCL-script ##
+##   Online Help : irc://irc.undernet.org/tcl-help 	               ##
+##                 #TCL-HELP / UnderNet                                ##
+##                 You can ask in english or romanian                  ##
+##					                               ##
+#########################################################################
+
+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
+if {[setting:get $chan anunt-showtime] != ""} {
+	set time [setting:get $chan anunt-showtime]
+		} else {
+	set time $black(anunttime)
+		}
+	set scan_time [time_return_minute $time]
+	set black(anunt:$chan:timer_start) $scan_time
+}
+
+off {
+	setting:set $chan -anunt ""
+	blacktools:tell $nick $host $hand $chan $chan1 anunt.4 none
+if {[info exists black(anunt:$chan:timer_start)]} {
+	unset black(anunt:$chan:timer_start)
+	}
+if {[info exists black(anunt:counter:$chan)]} {
+	unset black(anunt:counter:$chan)
+	}
+}
+
+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 size [file size $black(add_file)]
+	set data [split [read $file $size] \n]
+	close $file
+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 {chans} {
+global black
+	set channels ""
+foreach chan $chans {
+if {[validchan $chan]} {
+	lappend channels $chan
+	}
+}
+if {$channels != ""} {
+		anunt:time $channels 0
+	}
+}
+
+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 total_anunt 0
+	set unixtime [unixtime]
+if {[setting:get $chan anunt-showtime] != ""} {
+	set return_time [time_return_minute [setting:get $chan anunt-showtime]]
+} else {
+	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 size [file size $black(add_file)]
+	set data [split [read $file $size] \n]
+	close $file
+if {$data != ""} {
+	set file [open $temp_dir "a"]
+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"]} {
+	puts $file [lrange [split $line] 3 end]
+	set total_anunt [expr $total_anunt + 1]
+		}
+	}
+	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 \[$black(anuntshow:$chan)/$total_anunt\] [join $encoded]\001"
+} else { 
+	puthelp "PRIVMSG $chan :\[$black(anuntshow:$chan)/$total_anunt\] [join $encoded]"
+			}
+		}
+	}
+	file delete $temp_dir
+}
+
+##############
+#########################################################################
+##   END                                                               ##
+#########################################################################

+ 314 - 0
BlackTools2.5.2/Modules/BT.AutoBroadcast.tcl

@@ -0,0 +1,314 @@
+#########################################################################
+##          BlackTools - The Ultimate Channel Control Script           ##
+##                    One TCL. One smart Eggdrop                       ##
+#########################################################################
+########################   AUTOBROADCAST TCL   ##########################
+#########################################################################
+##						                       ##
+##   BlackTools  : http://blacktools.tclscripts.net	               ##
+##   Bugs report : http://www.tclscripts.net/	                       ##
+##   GitHub page : https://github.com/tclscripts/BlackToolS-TCL-script ##
+##   Online Help : irc://irc.undernet.org/tcl-help 	               ##
+##                 #TCL-HELP / UnderNet                                ##
+##                 You can ask in english or romanian                  ##
+##					                               ##
+#########################################################################
+
+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 {
+	blacktools:tell $nick $host $hand $chan $chan1 autobroadcast.4 none
+	set type1 "broadcastpublic:show ON"
+	set file [open $black(status_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 who [lindex  [split $line] 0]
+	set stats [lindex [split $line] 1]]
+if {[string match -nocase "broadcastpublic:show" $who]} { 
+	continue
+} else {
+	puts $tempwrite $line
+		}	 
+    }
+	close $tempwrite
+	close $file
+    file rename -force $temp $black(status_file)
+	
+	set file [open $black(status_file) "a"]
+	puts $file "$type1"
+	close $file
+	set scan_time [time_return_minute $black(bttime)]
+	set black(broadcast:timer_start) $scan_time
+}
+
+off {
+	blacktools:tell $nick $host $hand $chan $chan1 autobroadcast.5 none
+	set file [open $black(status_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 who [lindex  [split $line] 0]
+	set stats [lindex [split $line] 1]]
+if {[string match -nocase "broadcastpublic:show" $who]} { 
+	continue
+} else {
+	puts $tempwrite $line
+		}
+    }
+	close $tempwrite
+	close $file
+    file rename -force $temp $black(status_file)
+	
+if {[info exists black(broadcast:timer_start)]} {
+	unset black(broadcast:timer_start)
+	}
+if {[info exists black(broadcast:counter)]} {
+	unset black(broadcast:counter)
+	}
+}
+
+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 size [file size $black(add_file)]
+	set data [split [read $file $size] \n]
+	close $file
+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 broadcast:check {} {
+	global black
+	set file [open $black(status_file) r]
+	set size [file size $black(status_file)]
+	set data [split [read $file $size] \n]
+	close $file
+	set broadcast_act 0
+if {$data != ""} {
+foreach line $data {
+	set type [lindex [split $line] 0]
+	set stats [lindex [split $line] 1]
+if {[string equal -nocase $type "broadcastpublic:show"] && [string equal -nocase $stats "ON"]} {
+	set broadcast_act 1
+			}
+		}
+	}
+	return $broadcast_act
+}
+
+proc broadcastpublic:show {} {
+global black
+if {![info exists black(broadcast:count)]} {
+	set black(broadcast:count) 0
+}
+	set channels ""
+	set file [open $black(add_file) r]
+	set size [file size $black(add_file)]
+	set data [split [read $file $size] \n]
+	close $file
+	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]
+foreach line $data {
+	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	
+
+	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
+	}
+}
+
+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
+	}
+} else { 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 \[AUTO\] [join $encoded]\001"
+} else { 
+	puthelp "PRIVMSG $chan :\[AUTO\] [join $encoded]"
+			}
+		}
+	}
+}
+if {[lindex $channels $cc] == ""} {
+	return 
+	} else {
+	utimer 5 [list broadcast:act $channels $cc $line]
+	}
+}
+
+##############
+#########################################################################
+##   END                                                               ##
+#########################################################################

+ 606 - 0
BlackTools2.5.2/Modules/BT.BadChan.tcl

@@ -0,0 +1,606 @@
+#########################################################################
+##          BlackTools - The Ultimate Channel Control Script           ##
+##                    One TCL. One smart Eggdrop                       ##
+#########################################################################
+###########################   BADCHAN TCL   #############################
+#########################################################################
+##						                       ##
+##   BlackTools  : http://blacktools.tclscripts.net	               ##
+##   Bugs report : http://www.tclscripts.net/	                       ##
+##   GitHub page : https://github.com/tclscripts/BlackToolS-TCL-script ##
+##   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 userlang [getuser $hand XTRA OUTPUT_LANG]
+if {$userlang == ""} { set userlang "[string tolower $black(default_lang)]" }
+	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 size [file size $black(add_file)]
+	set data [split [read $file $size] \n]
+	close $file
+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]
+if {[regexp {^[+]} $bdchan]} {
+	set text [black:color:set $hand $black(say.$userlang.gl.protexcept)]
+	lappend badchanlist($msg_num) [string map {"+" ""} $bdchan] \[$text\]	
+} else {
+	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 timestamp [clock format [clock seconds] -format {%Y%m%d%H%M%S}]
+	set temp "$black(tempdir)/badchan_temp.$timestamp"
+	set file [open $black(add_file) r]
+	set size [file size $black(add_file)]
+	set data [split [read $file $size] \n]
+	close $file
+	set tempwrite [open $temp w]
+foreach line $data {
+if {$line != ""} {
+	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
+    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 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 {
+	setting:set $chan +antibadchan ""
+	blacktools:tell $nick $host $hand $chan $chan1 badchan.6 none
+	if {[setting:get $chan badchan-scantime] != ""} {
+	set time [setting:get $chan badchan-scantime]
+		} else {
+	set time $black(badchan:scantime)
+		}
+	set scan_time [time_return_minute $time]
+	set black(badchan:$chan:timer_start) $scan_time
+}
+
+off {
+	setting:set $chan -antibadchan ""
+	blacktools:tell $nick $host $hand $chan $chan1 badchan.8 none
+if {[info exists black(badchan:$chan:timer_start)]} {
+	unset black(badchan:$chan:timer_start)
+	}
+if {[info exists black(badchan:counter:$chan)]} {
+	unset black(badchan:counter:$chan)
+	}
+}
+
+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
+if {[regexp {^[+]} $bdchan]} {
+	blacktools:tell $nick $host $hand $chan $chan1 badchan.45  "[string map {"+" ""} $bdchan] $num"
+} else {
+	blacktools:tell $nick $host $hand $chan $chan1 badchan.12  "$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 size [file size $black(add_file)]
+	set data [split [read $file $size] \n]
+	close $file
+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] && ![regexp {^[+]} $read_chan] && ![regexp {^[+]} $word]} {
+	set found_it 1
+		} elseif {[string match -nocase $enc_chan $chan] && [string match -nocase $read_type "BADCHAN"] && [string equal -nocase $word $enc_bchan] && [regexp {^[+]} $read_chan] && [regexp {^[+]} $word]} {
+	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 {channels} {
+	global black
+	set badchanscan_list ""
+foreach chan $channels {
+if {[validchan $chan]} {
+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
+	}
+}
+
+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 show_nick [lindex $arguments 1]
+	set channels [string tolower [lrange $arguments 2 end]]
+	set text [join [check:badchan:except $channels $chan]]
+	set banmask [return_mask [return_host_num $cmd $chan [getchanhost $nick $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 size [file size $black(add_file)]
+	set data [split [read $file $size] \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 $text {
+	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) $ch
+	break
+			}			
+		}
+	}
+}
+
+if {$file_found == "0"} {
+foreach defchan $black(badcchannels) {
+	set encoded [encoding convertfrom utf-8 $defchan]
+foreach c $text {
+	set ch [string trimleft $c ":@+"]
+	set ch [check:except $ch $chan $black(badcchannels) $black(exceptchannels) "BADCHAN"]
+if {[string match -nocase $encoded $ch]} {
+	set badchan(channels:$banmask:$chan) $ch
+	set badchan($banmask:$chan) $black(say.$getlang.badchan.5)
+	break
+			}
+		}
+	}
+}
+
+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"
+	who:chan $chan
+if {[setting:get $chan showbadchan]} {
+	set replace(%nick%) $show_nick
+	set replace(%chans%) $badchan(channels:$banmask:$chan)
+	set mes [string map [array get replace] $black(say.$getlang.badchan.44)]
+	putserv "NOTICE @$chan :$mes"
+}
+	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"
+	who:chan $chan
+if {[setting:get $chan showbadchan]} {
+	set replace(%nick%) $nick
+	set replace(%chans%) $badchan(channels:$banmask:$chan)
+	set text [black:color:set "" $black(say.$getlang.badchan.44)]
+	set text [join $text]
+	set mes [string map [array get replace] $text]
+	putserv "NOTICE @$chan :$mes"
+}
+	unset badchan($banmask:$chan)
+	unset badchan(channels:$banmask:$chan)
+	return
+}
+	set replace(%badchans%) [join $badchan(channels:$banmask:$chan) ", "]
+	set text [black:color:set "" $black(say.$getlang.badchan.40)]
+	set reply [join $text]
+if {[setting:get $chan badchan-banwait] == ""} {
+	set wait_time $black(badcbanwait)
+	utimer $black(badcbanwait) [list badchan:check:again $nick $chan]
+} else {
+	set wait_time [setting:get $chan badchan-banwait]
+	utimer $wait_time [list badchan:check:again $nick $chan]
+}
+	set replace(%time%) $wait_time
+	set message [string map [array get replace] $reply]
+	putquick "PRIVMSG $nick :\[$chan\] $message"
+	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 black
+	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
+}
+
+
+proc check:badchan:except {text chan} {
+	global black
+	set counter_word 0
+	set counter_except 0
+	set found_it 0
+foreach word $text {
+	set w [string trimleft $word ":@+"]
+foreach ex $black(exceptchannels) {
+if {[string match -nocase $ex $w] || [string match -nocase $w $ex]} {
+	set position [lsearch -exact [string tolower $text] [string tolower $word]]
+if {$position > -1} {
+	set text [lreplace $text $position $position]
+			}
+		}
+	}	
+}
+	set file [open $black(add_file) r]
+	set size [file size $black(add_file)]
+	set data [split [read $file $size] \n]
+	close $file
+foreach line $data {
+if {$line != ""} {
+	set channel [lindex [split $line] 0]
+	set getype [lindex [split $line] 1]
+	set badchan [lindex [split $line] 3]
+if {[string equal -nocase "BADCHAN" $getype] && [regexp {^[+]} $badchan]} {
+if {[string equal -nocase $channel $chan] } {
+	set badchan [string map {"+" ""} $badchan]
+foreach word $text {
+	set w [string trimleft $word ":@+"]
+if {[string match -nocase $badchan $w] || [string match -nocase $w $badchan]} {
+	set position [lsearch -exact [string tolower $text] [string tolower $word]]
+if {$position > -1} {
+	set text [lreplace $text $position $position]
+						}
+					}
+				}
+			}
+		}
+	}
+}
+	return $text
+}
+
+##############
+#########################################################################
+##   END                                                               ##
+#########################################################################

+ 176 - 0
BlackTools2.5.2/Modules/BT.ChanLink.tcl

@@ -0,0 +1,176 @@
+#########################################################################
+##          BlackTools - The Ultimate Channel Control Script           ##
+##                    One TCL. One smart Eggdrop                       ##
+#########################################################################
+###########################   CHANLINK TCL   ############################
+#########################################################################
+##						                       ##
+##   BlackTools  : http://blacktools.tclscripts.net	               ##
+##   Bugs report : http://www.tclscripts.net/	                       ##
+##   GitHub page : https://github.com/tclscripts/BlackToolS-TCL-script ##
+##   Online Help : irc://irc.undernet.org/tcl-help 	               ##
+##                 #TCL-HELP / UnderNet                                ##
+##                 You can ask in english or romanian                  ##
+##					                               ##
+#########################################################################
+
+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                                                               ##
+#########################################################################

+ 131 - 0
BlackTools2.5.2/Modules/BT.CloneScan.tcl

@@ -0,0 +1,131 @@
+#########################################################################
+##          BlackTools - The Ultimate Channel Control Script           ##
+##                    One TCL. One smart Eggdrop                       ##
+#########################################################################
+###########################   CLONESCAN TCL   ###########################
+#########################################################################
+##						                       ##
+##   BlackTools  : http://blacktools.tclscripts.net	               ##
+##   Bugs report : http://www.tclscripts.net/	                       ##
+##   GitHub page : https://github.com/tclscripts/BlackToolS-TCL-script ##
+##   Online Help : irc://irc.undernet.org/tcl-help 	               ##
+##                 #TCL-HELP / UnderNet                                ##
+##                 You can ask in english or romanian                  ##
+##					                               ##
+#########################################################################
+
+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 {chans} {
+	global black
+	set type 1
+foreach chan $chans {
+if {[validchan $chan]} {
+	lappend channels $chan
+		}
+	}
+if {$channels != ""} {
+	clonescan:act $channels "nick" "" "chan1" $type 0
+	}
+}
+
+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
+	set found_mask ""
+	set theclones ""
+	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 }
+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
+	lappend found_mask $clone
+	lappend theclones $clones($clone)
+if {$type == "0"} {
+	blacktools:tell $nick "" $hand $chan $chan1 clonescan.10 "[llength [split $userlist]] $clone [join $clones($clone) ", "]"
+		}
+	}
+}
+if {$found_clones == "1"} {
+if {$type == "1"} {
+	set replace(%msg.1%) [llength [split $theclones]]
+	set replace(%msg.2%) $found_mask
+	set replace(%msg.7%) [join $theclones " ,"]
+	set replace(%chan%) $chan
+	set text [black:color:set "" $black(say.$getlang.clonescan.10)]
+	set message [string map [array get replace] $text]
+	putserv "NOTICE @$chan :$message"
+foreach m $found_mask {
+	set mask "*!*@$found_mask"
+	blacktools:banner:2 $nick "CLONESCAN" $chan $chan1 $mask "0"
+}
+	who:chan $chan
+		}
+	}
+}
+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                                                               ##
+#########################################################################

+ 398 - 0
BlackTools2.5.2/Modules/BT.Egg.tcl

@@ -0,0 +1,398 @@
+#########################################################################
+##          BlackTools - The Ultimate Channel Control Script           ##
+##                    One TCL. One smart Eggdrop                       ##
+#########################################################################
+##############################   EGG TCL   ##############################
+#########################################################################
+##						                       						   ##
+##   BlackTools  : http://blacktools.tclscripts.net	               	   ##
+##   Bugs report : http://www.tclscripts.net/	                       ##
+##   GitHub page : https://github.com/tclscripts/BlackToolS-TCL-script ##
+##   Online Help : irc://irc.undernet.org/tcl-help 	               	   ##
+##                 #TCL-HELP / UnderNet                                ##
+##                 You can ask in english or romanian                  ##
+##					                               					   ##
+#########################################################################
+
+proc egg:setting_check {setting} {
+	global black
+	set settings "nick realname away homechan chanserv hostchanserv userlogin userpass chanremove-setting add-mask add-defaultmask user-expire banmethod-expire broadcast-showtime cmdchar defaultlang defaultoutput floodmenuprot userfloodmsgprot massfloodmsgprot massfloodsilencetime floodnotcprot pagelimit"
+if {[lsearch -exact [string tolower $settings] [string tolower $setting]] < 0} {
+	return 0
+	} else { return 1 }
+}
+
+proc egg:process {unick host hand chan chan1 setting result} {
+	global black config nick botnick
+	set tcl_config $black(tclconfig)
+	
+switch [string tolower $setting] {
+
+nick {
+	set result [string map [list \[ {\[} \] {\]} \? {\?} \\ {\\}] $result]
+	set return [config:getinfo $config "set nick \"*\""]
+if {[string equal -nocase $return $result]} {
+	return 2
+}
+	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"} {
+	return 0
+}
+	bind RAW - 432 check:validnickname
+	return 1
+}
+
+realname {
+	set result [string map [list \[ {\[} \] {\]} \? {\?} \\ {\\}] $result]
+	set return [config:getinfo $config "set realname \"*\""]
+if {[string equal -nocase $return $result]} {
+	return 2
+}
+	set error [config:save $config "set realname \"*\"" "set realname \"$result\""]
+if {$error == "0"} {
+	return 0
+	}
+	return 1
+}
+
+homechan {
+	set result [string map [list \[ {\[} \] {\]} \? {\?} \\ {\\}] $result]
+	set return [config:getinfo $tcl_config "set black(homechan) \"*\""]
+if {[string equal -nocase $return $result]} {
+	return 2
+}
+	set error [config:save $tcl_config "set black(homechan) \"*\"" "set black(homechan) \"$result\""]
+if {$error == "0"} {
+	return 0
+	}
+	return 1
+}
+
+chanserv {
+	set return [config:getinfo $tcl_config "set black(chanserv) \"*\""]
+if {[string equal -nocase $return $result]} {
+	return 2
+}
+	set error [config:save $tcl_config "set black(chanserv) \"*\"" "set black(chanserv) \"$result\""]
+if {$error == "0"} {
+	return 0
+	}
+	return 1
+}
+
+hostchanserv {
+	set return [config:getinfo $tcl_config "set black(hostchanserv) \"*\""]
+if {[string equal -nocase $return $result]} {
+	return 2
+}
+	set error [config:save $tcl_config "set black(hostchanserv) \"*\"" "set black(hostchanserv) \"$result\""]
+if {$error == "0"} {
+	return 0
+	}
+	return 1
+}
+
+userlogin {
+	set result [string map [list \[ {\[} \] {\]} \? {\?} \\ {\\}] $result]
+	set return [config:getinfo $tcl_config "set black(username) \"*\""]
+if {[string equal -nocase $return $result]} {
+	return 2
+}
+	set error [config:save $tcl_config "set black(username) \"*\"" "set black(username) \"$result\""]
+if {$error == "0"} {
+	return 0
+	}
+	return 1
+}
+
+userpass {
+	set result [string map [list \[ {\[} \] {\]} \? {\?} \\ {\\}] $result]
+	set return [config:getinfo $tcl_config "set black(password) \"*\""]
+if {[string equal -nocase $return $result]} {
+	return 2
+}
+	set error [config:save $tcl_config "set black(password) \"*\"" "set black(password) \"$result\""]
+if {$error == "0"} {
+	return 0
+	}
+	return 1
+}
+
+add-defaultmask {
+	set return [config:getinfo $tcl_config "set black(hostadd) \"*\""]
+if {[string equal -nocase $return $result]} {
+	return 2
+}
+	set error [config:save $tcl_config "set black(hostadd) \"*\"" "set black(hostadd) \"$result\""]
+if {$error == "0"} {
+	return 0
+	}
+	rehash 
+	return 1
+}
+
+broadcast-showtime {
+	set return [config:getinfo $tcl_config "set black(bttime) \"*\""]
+if {[string equal -nocase $return $result]} {
+	return 2
+}
+	set error [config:save $tcl_config "set black(bttime) \"*\"" "set black(bttime) \"$result\""]
+if {$error == "0"} {
+	return 0
+	}
+	rehash 
+	return 1
+if {[info exists black(broadcast:timer_start)]} {
+	set scan_time [time_return_minute $result]
+	set black(broadcast:timer_start) $scan_time
+	}
+if {[info exists black(broadcast:counter)]} {
+	set black(broadcast:counter) 0
+	}
+}
+
+user-expire {
+	set return [config:getinfo $tcl_config "set black(user_expire_time) \"*\""]
+if {[string equal -nocase $return $result]} {
+	return 2
+}
+	set error [config:save $tcl_config "set black(user_expire_time) \"*\"" "set black(user_expire_time) \"$result\""]
+if {$error == "0"} {
+	return 0
+	}
+	rehash
+	return 1
+}
+
+banmethod-expire {
+	set return [config:getinfo $tcl_config "set black(banmethod_memory_time) \"*\""]
+if {[string equal -nocase $return $result]} {
+	return 2
+}
+	set error [config:save $tcl_config "set black(banmethod_memory_time) \"*\"" "set black(banmethod_memory_time) \"$result\""]
+if {$error == "0"} {
+	return 0
+	}
+if {[info exists black(banmethod_rem:timer_start)]} {
+	set black(banmethod_rem:timer_start) [time_return_minute $result]
+}
+if {[info exists black(banmethod_rem:counter)]} {
+	set black(banmethod_rem:counter) 0
+}
+	rehash
+	return 1
+}
+
+cmdchar {
+	set return [config:getinfo $tcl_config "set black(cmdchar) \"*\""]
+if {[string equal -nocase $return $result]} {
+	return 2
+}
+	set error [config:save $tcl_config "set black(cmdchar) \"*\"" "set black(cmdchar) \"$result\""]
+if {$error == "0"} {
+	return 0 
+	}
+	rehash
+	return 1
+}
+
+defaultlang {
+	set return [config:getinfo $tcl_config "set black(default_lang) \"*\""]
+if {[string equal -nocase $return $result]} {
+	return 2
+}
+	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"} {
+	return 0
+	}
+	rehash
+	return 1
+}
+
+defaultoutput {
+	set return [config:getinfo $tcl_config "set black(default_output) \"*\""]
+switch $return {
+	0 {
+if {[string equal -nocase $result "notice"]} {
+	return 2
+}	
+	}
+		
+	1 {
+if {[string equal -nocase $result "chan"]} {
+	return 2
+}			
+	}
+		
+	2 {
+if {[string equal -nocase $result "msg"]} {
+	return 2
+		}	
+	}
+}
+	set error ""
+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 {
+	return 0
+	}
+}
+	
+if {$error == "0"} {
+	return 0
+	}
+	rehash 
+	return 1
+}
+
+floodmenuprot {
+	set return [config:getinfo $tcl_config "set black(antiflood:cmd) \"*\""]
+if {[string equal -nocase $return $result]} {
+	return 2
+}
+	set error [config:save $tcl_config "set black(antiflood:cmd) \"*\"" "set black(antiflood:cmd) \"$result\""]
+if {$error == "0"} {
+	return 0
+	}
+	return 1
+}
+
+userfloodmsgprot {
+	set return [config:getinfo $tcl_config "set black(msg:flood) \"*\""]
+if {[string equal -nocase $return $result]} {
+	return 2
+}
+	set error [config:save $tcl_config "set black(msg:flood) \"*\"" "set black(msg:flood) \"$result\""]
+if {$error == "0"} {
+	return 0
+	}
+	return 1
+}
+
+massfloodmsgprot {
+	set return [config:getinfo $tcl_config "set black(mass:msg:flood) \"*\""]
+if {[string equal -nocase $return $result]} {
+	return 2
+}
+	set error [config:save $tcl_config "set black(mass:msg:flood) \"*\"" "set black(mass:msg:flood) \"$result\""]
+if {$error == "0"} {
+	return 0
+	}
+	return 1
+}
+
+massfloodsilencetime {
+	set return [config:getinfo $tcl_config "set black(mass:msg:silence_time) \"*\""]
+if {[string equal -nocase $return $result]} {
+	return 2
+}
+	set error [config:save $tcl_config "set black(mass:msg:silence_time) \"*\"" "set black(mass:msg:silence_time) \"$result\""]
+if {$error == "0"} {
+	return 0
+	}
+	return 1
+}
+
+floodnotcprot {
+	set return [config:getinfo $tcl_config "set black(notice:flood) \"*\""]
+if {[string equal -nocase $return $result]} {
+	return 2
+}
+	set error [config:save $tcl_config "set black(notice:flood) \"*\"" "set black(notice:flood) \"$result\""]
+if {$error == "0"} {
+	return 0
+	}
+	return 1
+}
+
+pagelimit {
+	set return [config:getinfo $tcl_config "set black(modul:nr:entries) \"*\""]
+if {[string equal -nocase $return $result]} {
+	return 2
+}
+	set error [config:save $tcl_config "set black(modul:nr:entries) \"*\"" "set black(modul:nr:entries) \"$result\""]
+if {$error == "0"} {
+	return 0
+	}
+	return 1
+}
+
+away {
+	set return [config:getinfo $tcl_config "set black(default_away) \"*\""]
+if {[string equal -nocase $return $result]} {
+	return 2
+}
+	set result [string map [list \" {\"} \[ {\[} \] {\]} \? {\?} \\ {\\}] $result]
+	set error [config:save $tcl_config "set black(default_away) \"*\"" "set black(default_away) \"$result\""]
+if {$error == "0"} {
+	return 0
+}
+	set result [string map [list {\[} \[ {\]} \] {\?} \? {\\} \\] $result]
+	putserv "AWAY :"
+	putserv "AWAY :$result"
+	return 1
+}
+
+chanremove-setting {
+	set return [config:getinfo $tcl_config "set black(chanremove_all) \"*\""]
+if {[string equal -nocase $return $result]} {
+	return 2
+}
+if {![regexp {^[12]} $result]} {
+	return 0
+}
+	set error [config:save $tcl_config "set black(chanremove_all) \"*\"" "set black(chanremove_all) \"$result\""]
+if {$error == "0"} {
+	return 0
+	}
+	rehash
+	return 1
+}
+
+add-mask {
+	set return [config:getinfo $tcl_config "set black(hostdefaultadd) \"*\""]
+if {[string equal -nocase $return $result]} {
+	return 2
+}
+if {![regexp {^[12345]} $result]} {
+	return 0
+}
+	set error [config:save $tcl_config "set black(hostdefaultadd) \"*\"" "set black(hostdefaultadd) \"$result\""]
+if {$error == "0"} {
+	return 0
+	}
+	rehash
+	return 1
+		}
+	}
+}
+
+##############
+#########################################################################
+##   END                                                               ##
+#########################################################################

+ 314 - 0
BlackTools2.5.2/Modules/BT.Gag.tcl

@@ -0,0 +1,314 @@
+#########################################################################
+##          BlackTools - The Ultimate Channel Control Script           ##
+##                    One TCL. One smart Eggdrop                       ##
+#########################################################################
+#############################   GAG TCL   ###############################
+#########################################################################
+##						                       ##
+##   BlackTools  : http://blacktools.tclscripts.net	               ##
+##   Bugs report : http://www.tclscripts.net/	                       ##
+##   GitHub page : https://github.com/tclscripts/BlackToolS-TCL-script ##
+##   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]] [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 text1 [black:color:set "" $black(say.$getlang.gag.10)]
+	set text2 [black:color:set "" $black(say.$getlang.gag.11)]
+	set reply1 [join $text1]
+	set reply2 [join $text2]
+	set gag_user_message [string map [array get replace] $reply1]
+	set gag_chan_message [string map [array get replace] $reply2]
+	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]
+if {$reason == ""} { set reason "N/A" }	
+	set replace(%banmask%) $mask
+	set replace(%bantime%) $expire
+	set replace(%reason%) $reason
+	set replace(%chan%) $chan
+	set replace(%nick%) $gethand
+	set text [black:color:set "" $black(say.$getlang.reportchan.2)]
+	set reply [join $text]
+	puthelp "PRIVMSG $backchan :[string map [array get replace] $reply]"
+}
+
+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 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 textgagger [black:color:set "" $black(say.$getlang.ungag.7)]
+	set textchan [black:color:set "" $black(say.$getlang.ungag.8)]
+	set reply1 [join $textgagger]
+	set reply2 [join $textchan]
+	set ungag_user_message [string map [array get replace] $reply1]
+	set ungag_chan_message [string map [array get replace] $reply2]
+
+	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                                                               ##
+#########################################################################

+ 119 - 0
BlackTools2.5.2/Modules/BT.GreetLeave.tcl

@@ -0,0 +1,119 @@
+#########################################################################
+##          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/	                       ##
+##   GitHub page : https://github.com/tclscripts/BlackToolS-TCL-script ##
+##   Online Help : irc://irc.undernet.org/tcl-help 	               ##
+##                 #TCL-HELP / UnderNet                                ##
+##                 You can ask in english or romanian                  ##
+##					                               ##
+#########################################################################
+
+proc greetpublic:join {nick host hand chan} {
+	global black
+if {[setting:get $chan greet]} {
+if {[isbotnick $nick]} { return }
+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(%countchan%) $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]} {
+if {[isbotnick $nick]} { return }
+	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                                                               ##
+#########################################################################

+ 221 - 0
BlackTools2.5.2/Modules/BT.GuestNick.tcl

@@ -0,0 +1,221 @@
+#########################################################################
+##          BlackTools - The Ultimate Channel Control Script           ##
+##                    One TCL. One smart Eggdrop                       ##
+#########################################################################
+###########################   GUESTNICK TCL   ###########################
+#########################################################################
+##						                       ##
+##   BlackTools  : http://blacktools.tclscripts.net	               ##
+##   Bugs report : http://www.tclscripts.net/	                       ##
+##   GitHub page : https://github.com/tclscripts/BlackToolS-TCL-script ##
+##   Online Help : irc://irc.undernet.org/tcl-help 	               ##
+##                 #TCL-HELP / UnderNet                                ##
+##                 You can ask in english or romanian                  ##
+##					                               ##
+#########################################################################
+
+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 text [black:color:set "" $message]
+	set reply [join $text]
+	set message [string map [array get replace] $reply]
+	switch [string tolower $method] {
+	chan {
+	putserv "PRIVMSG $chan :$message"
+	}	
+	privmsg {
+	putserv "PRIVMSG $nick :$message"
+	}
+	notice {
+	putserv "NOTICE $nick :$message"
+	}
+				}
+			}
+		}
+	close $file
+	}
+}
+
+##############
+#########################################################################
+##   END                                                               ##
+#########################################################################

+ 309 - 0
BlackTools2.5.2/Modules/BT.Idle.tcl

@@ -0,0 +1,309 @@
+#########################################################################
+##          BlackTools - The Ultimate Channel Control Script           ##
+##                    One TCL. One smart Eggdrop                       ##
+#########################################################################
+#############################   IDLE TCL   ##############################
+#########################################################################
+##						                       ##
+##   BlackTools  : http://blacktools.tclscripts.net	               ##
+##   Bugs report : http://www.tclscripts.net/	                       ##
+##   GitHub page : https://github.com/tclscripts/BlackToolS-TCL-script ##
+##   Online Help : irc://irc.undernet.org/tcl-help 	               ##
+##                 #TCL-HELP / UnderNet                                ##
+##                 You can ask in english or romanian                  ##
+##					                               ##
+#########################################################################
+
+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 [string tolower $why] {
+
++o {
+	antidle:set $chan
+	setting:set $chan +idleop ""
+	blacktools:tell $nick $host $hand $chan $chan1 idle.11 none
+}
+-o {
+	setting:set $chan -idleop ""
+	blacktools:tell $nick $host $hand $chan $chan1 idle.12 none
+	antidle:unset $chan
+}
+-ho {
+	setting:set $chan -idlehalfop ""
+	blacktools:tell $nick $host $hand $chan $chan1 idle.26 none
+	antidle:unset $chan
+}
++v {
+	antidle:set $chan
+	setting:set $chan +idlevoice ""
+	blacktools:tell $nick $host $hand $chan $chan1 idle.14 none
+}
++ho {
+	antidle:set $chan
+	setting:set $chan +idlehalfop ""
+	blacktools:tell $nick $host $hand $chan $chan1 idle.25 none
+}
+-v {
+	setting:set $chan -idlevoice ""
+	blacktools:tell $nick $host $hand $chan $chan1 idle.15 none
+	antidle:unset $chan
+}
+
+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:unset {chan} {
+	global black
+	set idle_activ 0
+	set options {idleop idlevoice idlehalfop}
+foreach option $options {
+	if {[setting:get $chan $option]} {
+	set idle_activ 1
+	}
+}
+if {$idle_activ == "0"} {
+if {[info exists black(idle:$chan:timer_start)]} {
+	unset black(idle:$chan:timer_start)
+			}
+if {[info exists black(idle:counter:$chan)]} {
+	unset black(idle:counter:$chan)
+		}
+	}	
+}
+
+proc antidle:set {chan} {
+	global black
+	set idle_activ 0
+	set options {idleop idlevoice idlehalfop}
+foreach option $options {
+	if {[setting:get $chan $option]} {
+	set idle_activ 1
+	}
+}
+
+if {$idle_activ == "0"} {
+if {[setting:get $chan idle-scantime] != ""} {
+	set time [setting:get $chan idle-scantime]
+		} else {
+	set time $black(idleinterval)
+		}
+	set scan_time [time_return_minute $time]
+	set black(idle:$chan:timer_start) $scan_time
+	}
+}
+
+proc antidle:module {chans} {
+	global black
+	set channels ""
+foreach chan $chans {
+if {[validchan $chan]} {
+	lappend channels $chan
+		}
+	}
+if {$channels != ""} {
+	idlewhois $channels 0
+	}
+}
+
+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
+	set ::idle_chan $chan
+foreach user [chanlist $chan] {
+	set handle [nick2hand $user]
+if {[isop $user $chan] || [isvoice $user $chan] || [ishalfop $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 $::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)" }
+	set idlehalfoptime [setting:get $chan idlehalfopmax]
+if {$idlehalfoptime == ""} { set idlehalfoptime "$black(idlehalfopmax)" }
+	set idlevoicetime [time_return_minute $idlevoicetime]
+	set idleoptime [time_return_minute $idleoptime]
+	set idlehalfoptime [time_return_minute $idlehalfoptime]
+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] && [onchan $black(chanserv) $chan]} {
+	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] && [onchan $black(chanserv) $chan]} {
+	putserv "PRIVMSG $black(chanserv) :deop $chan $nick"
+} else {
+	pushmode $chan -o $nick
+						}
+					}
+				}
+			}
+if {[setting:get $chan idlehalfop]} {
+if {![matchattr $handle "-|f" $chan]} {
+if {$minutesidle > $idlehalfoptime} {
+if {[setting:get $chan xonly] && [onchan $black(chanserv) $chan]} {
+	return
+} else {
+	pushmode $chan -h $nick
+						}
+					}
+				}
+			}
+		}
+	}
+}
+
+##############
+#########################################################################
+##   END                                                               ##
+#########################################################################

+ 154 - 0
BlackTools2.5.2/Modules/BT.Limit.tcl

@@ -0,0 +1,154 @@
+#########################################################################
+##          BlackTools - The Ultimate Channel Control Script           ##
+##                    One TCL. One smart Eggdrop                       ##
+#########################################################################
+#############################   LIMIT TCL   #############################
+#########################################################################
+##						                       ##
+##   BlackTools  : http://blacktools.tclscripts.net	               ##
+##   Bugs report : http://www.tclscripts.net/	                       ##
+##   GitHub page : https://github.com/tclscripts/BlackToolS-TCL-script ##
+##   Online Help : irc://irc.undernet.org/tcl-help 	               ##
+##                 #TCL-HELP / UnderNet                                ##
+##                 You can ask in english or romanian                  ##
+##					                               ##
+#########################################################################
+
+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]]
+	
+    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 $black(limit:default)
+	}
+	set black(limit:$chan:timer_start) 1
+}
+off {
+	setting:set $chan -limit ""
+	blacktools:tell $nick $host $hand $chan $chan1 limit.7 none
+	putquick "MODE $chan -l"
+if {[info exists black(limit:$chan:timer_start)]} {
+	unset black(limit:$chan:timer_start)
+	}
+}
+
+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 {chans} {
+	global black
+		set channels ""
+foreach chan $chans {
+	lappend channels $chan
+	}
+if {$channels != ""} {
+	limit:act $channels 0
+	}
+}
+
+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]
+	set limitcount [expr $usersnum + $setnum]
+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]
+if {$lim == $limitcount} {
+	if {[lindex $channels $cc] == ""} {
+	return
+	} else {
+	utimer 5 [list limit:act $channels $cc]
+	return
+		}
+	}
+} 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 $limitcount"	
+	}
+}
+if {[lindex $channels $cc] == ""} {
+	return
+	} else {
+	utimer 5 [list limit:act $channels $cc]
+	}
+}
+
+##############
+#########################################################################
+##   END                                                               ##
+#########################################################################

+ 450 - 0
BlackTools2.5.2/Modules/BT.Next.tcl

@@ -0,0 +1,450 @@
+#########################################################################
+##          BlackTools - The Ultimate Channel Control Script           ##
+##                    One TCL. One smart Eggdrop                       ##
+#########################################################################
+#############################   NEXT TCL   ##############################
+#########################################################################
+##						                       ##
+##   BlackTools  : http://blacktools.tclscripts.net	               ##
+##   Bugs report : http://www.tclscripts.net/	                       ##
+##   GitHub page : https://github.com/tclscripts/BlackToolS-TCL-script ##
+##   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 {[string equal -nocase $nick $black(chanserv)]} {
+	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 replace(%counter%) $counter
+	set replace(%nick%) $nick
+	set replace(%chan%) $chan
+	set text1 [black:color:set "" $black(say.$lang.next.6)]
+	set reply1 [join $text1]
+	set text2 [black:color:set "" $black(say.$lang.next.1)]
+	set reply2 [join $text2]
+	set message [string map [array get replace] $reply1]
+	puthelp "NOTICE @$chan :$message"
+	set message [string map [array get replace] $reply2]
+	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: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 getlang [string tolower [setting:get $chan lang]]
+if {$getlang == ""} { set getlang "[string tolower $black(default_lang)]" }
+	set current_nick [lindex [split [concat $black(next:$chan:list)]] 0]
+	set time [return_time $getlang [expr [unixtime] - $black(next:$chan:$current_nick:time)]]
+	set text1 [black:color:set "" $black(say.$getlang.next.2)]
+	set reply1 [join $text1]
+	set replace(%nick%) $nick
+	set message_1 [string map [array get replace] $reply1]
+	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: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
+}
+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 getlang [string tolower [setting:get $chan lang]]
+if {$getlang == ""} { set getlang "[string tolower $black(default_lang)]" }
+	set text1 [black:color:set "" $black(say.$getlang.next.4)]
+	set reply1 [join $text1]
+	set replace(%current%) $user
+	set replace(%chan%) $chan
+	set message_1 [string map [array get replace] $reply1]
+	puthelp "NOTICE $user :$message_1"
+}
+
+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"
+	who:chan $chan
+}
+
+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                                                               ##
+#########################################################################

+ 503 - 0
BlackTools2.5.2/Modules/BT.Notes.tcl

@@ -0,0 +1,503 @@
+#########################################################################
+##          BlackTools - The Ultimate Channel Control Script           ##
+##                    One TCL. One smart Eggdrop                       ##
+#########################################################################
+#############################   NOTES TCL   #############################
+#########################################################################
+##						                       ##
+##   BlackTools  : http://blacktools.tclscripts.net	               ##
+##   Bugs report : http://www.tclscripts.net/	                       ##
+##   GitHub page : https://github.com/tclscripts/BlackToolS-TCL-script ##
+##   Online Help : irc://irc.undernet.org/tcl-help 	               ##
+##                 #TCL-HELP / UnderNet                                ##
+##                 You can ask in english or romanian                  ##
+##					                               ##
+#########################################################################
+
+proc note:process {nick host hand chan chan1 who note user_send note_send number type} {
+	global black botnick
+	set cmd_status [btcmd:status $chan $hand "note" 0]
+if {$cmd_status == "1"} { 
+	return 
+} 
+if {![setting:get $chan note] && ![matchattr $hand nmo]} {
+	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 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) $encoded"
+		} else {
+	lappend inboxlist($num) "$black(say.$getlang.notes.9) $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]
+	set text [black:color:set $botnick $encoded]
+	blacktools:tell $nick $host $hand $chan $chan1 notes.6 "[join $text]"
+	}
+} 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]
+	set text [black:color:set $botnick $encoded]
+	blacktools:tell $nick $host $hand $chan $chan1 notes.6 "[join $text]"
+		}
+	}
+	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 [split $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 nonotes [getuser $user XTRA NO_NOTES]
+if {$nonotes == ""} {
+	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\($black(say.$getlang.notes.17)\)
+	}
+		} 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 $encoded"
+}
+if {$type == "INBOX"} {
+	puts $file "$type $chan $num $read $handle $time $sender $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                                                               ##
+#########################################################################

+ 164 - 0
BlackTools2.5.2/Modules/BT.Private.tcl

@@ -0,0 +1,164 @@
+#########################################################################
+##          BlackTools - The Ultimate Channel Control Script           ##
+##                    One TCL. One smart Eggdrop                       ##
+#########################################################################
+###########################   PRIVATE TCL   #############################
+#########################################################################
+##						                       ##
+##   BlackTools  : http://blacktools.tclscripts.net	               ##
+##   Bugs report : http://www.tclscripts.net/	                       ##
+##   GitHub page : https://github.com/tclscripts/BlackToolS-TCL-script ##
+##   Online Help : irc://irc.undernet.org/tcl-help 	               ##
+##                 #TCL-HELP / UnderNet                                ##
+##                 You can ask in english or romanian                  ##
+##					                               ##
+#########################################################################
+
+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"
+	who:chan $chan
+	}
+}
+
+##############
+#########################################################################
+##   END                                                               ##
+#########################################################################

+ 415 - 0
BlackTools2.5.2/Modules/BT.Quote.tcl

@@ -0,0 +1,415 @@
+#########################################################################
+##          BlackTools - The Ultimate Channel Control Script           ##
+##                    One TCL. One smart Eggdrop                       ##
+#########################################################################
+#############################   QUOTE TCL   #############################
+#########################################################################
+##						                       ##
+##   BlackTools  : http://blacktools.tclscripts.net	               ##
+##   Bugs report : http://www.tclscripts.net/	                       ##
+##   GitHub page : https://github.com/tclscripts/BlackToolS-TCL-script ##
+##   Online Help : irc://irc.undernet.org/tcl-help 	               ##
+##                 #TCL-HELP / UnderNet                                ##
+##                 You can ask in english or romanian                  ##
+##					                               ##
+#########################################################################
+
+proc quote:announce {chans} {
+	global black
+	set channels ""
+foreach chan $chans {
+if {[validchan $chan]} {
+	lappend channels $chan
+	}
+}
+if {$channels != ""} {
+		quote:time $channels 0
+	}
+}
+
+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
+if {[info exists black(lastaction:$chan)]} {
+	set unixtime [unixtime]
+if {[setting:get $chan quote-showtime] != ""} {
+	set return_time [time_return_minute [setting:get $chan quote-showtime]]
+} else {
+	set return_time [time_return_minute $black(quote:msgtime)]
+}
+	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 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 text [black:color:set "" $black(say.$getlang.quote.16)]
+	set reply [join $text]
+	set text2 [black:color:set "" $black(say.$getlang.quote.12)]
+	set reply2 [join $text2]
+	set message [string map [array get replace] $reply]
+if {[onchan $botnick $chan]} {
+if {[regexp {[~]} $message]} {
+	set split_message [split $message "~"]
+if {$black(quote:outtype) == "1"} {
+	puthelp "PRIVMSG $chan :\001ACTION $reply2\001"
+} else {
+	puthelp "PRIVMSG $chan :$reply2"
+}
+foreach mes $split_message {
+	set encoded [encoding convertto utf-8 $mes]
+if {$black(quote:outtype) == "1"} {
+	puthelp "PRIVMSG $chan :\001ACTION \"[join $encoded]\"\001"
+} else { 
+	puthelp "PRIVMSG $chan :\"[join $encoded]\""
+				}
+			}
+		} else {
+		set encoded [encoding convertto utf-8 $message]
+if {$black(quote:outtype) == "1"} {
+	puthelp "PRIVMSG $chan :\001ACTION $reply2 [join $encoded]\001"
+} else { 
+	puthelp "PRIVMSG $chan :$reply2 [join $encoded]"
+			}
+		}
+	}
+}
+	file delete $temp_dir
+}
+
+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
+}
+	set split_host [split $host ":"]
+if {[lindex $split_host 1] == "chan"} {
+	set host [lindex $split_host 1]
+	set charbind [lindex $split_host 0]
+	} else {
+	set charbind "$host"
+}
+
+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 time [lindex [split $line] 4]
+	set time [clock format $time -format %D]
+	set quote [join [lrange [split $line] 6 end]]
+lappend nicklist($msg_num) "$quote :: $black(say.$getlang.quote.15) $by_who :: $black(say.$getlang.quote.20) \002$time\002"
+		}
+	}
+	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 $charbind $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 $charbind $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 $charbind $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 readquote [join [lrange [split $line] 6 end]]
+	set encoded [encoding convertfrom utf-8 $readquote]
+	continue
+			}			
+		}
+	}
+	close $file
+	set split_encoded [split $encoded "~"]
+	foreach enc $split_encoded {
+	blacktools:tell $nick $host $hand $chan $chan1 quote.3 "$quote $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 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"
+}
+	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 [join $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 [color:filter [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                                                               ##
+#########################################################################

+ 282 - 0
BlackTools2.5.2/Modules/BT.SecureMode.tcl

@@ -0,0 +1,282 @@
+#########################################################################
+##          BlackTools - The Ultimate Channel Control Script           ##
+##                    One TCL. One smart Eggdrop                       ##
+#########################################################################
+###########################   SECUREMODE TCL   ##########################
+#########################################################################
+##						                       ##
+##   BlackTools  : http://blacktools.tclscripts.net	               ##
+##   Bugs report : http://www.tclscripts.net/	                       ##
+##   GitHub page : https://github.com/tclscripts/BlackToolS-TCL-script ##
+##   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: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
+	set text [black:color:set "" $black(say.$getlang.securemode.10)]
+	set reply [join $text]
+	putserv "PRIVMSG $chan :[string map [array get replace] $reply]"
+}
+if {[string match "*-D*" $mod]} {
+	set replace(%chan%) $chan
+	set text2 [black:color:set "" $black(say.$getlang.securemode.11)]
+	set reply2 [join $text2]
+	putserv "PRIVMSG $chan :[string map [array get replace] $reply2]"
+		}
+	}
+}
+
+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 "$black(say.$lang.securemode.1)"
+	set len [llength $message] 
+    set random [expr int(rand()*$len)] 
+    set message [lindex $message $random]
+	set text [black:color:set "" $message]
+	set reply [join $text]
+	set message [string map [array get replace] $reply]
+	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 "$black(say.$lang.securemode.1)"
+	set len [llength $message] 
+    set random [expr int(rand()*$len)] 
+    set message [lindex $message $random]
+	set text [black:color:set "" $message]
+	set reply [join $text]
+	set message [string map [array get replace] $reply]
+	putserv "PRIVMSG $nick :$message"
+	lappend black(secure:$chan:list) $nick
+}
+	check:if:bind "get:securemode:host" "302"
+}
+
+##############
+#########################################################################
+##   END                                                               ##
+#########################################################################

+ 831 - 0
BlackTools2.5.2/Modules/BT.Seen.tcl

@@ -0,0 +1,831 @@
+#########################################################################
+##          BlackTools - The Ultimate Channel Control Script           ##
+##                    One TCL. One smart Eggdrop                       ##
+#########################################################################
+#############################   SEEN TCL   ##############################
+#########################################################################
+##						                       ##
+##   BlackTools  : http://blacktools.tclscripts.net	               ##
+##   Bugs report : http://www.tclscripts.net/	                       ##
+##   GitHub page : https://github.com/tclscripts/BlackToolS-TCL-script ##
+##   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 ""
+	set lin 0
+if {![validchan $chan]} { return }
+if {![setting:get $chan seen] && ![setting:get $chan seenlastmsg]} {
+	return
+}
+	set file [open $seen_lastmessage_dir r]
+	set size [file size $seen_lastmessage_dir]
+	set data [split [read $file $size] \n]
+	close $file
+	set timestamp [clock format [clock seconds] -format {%Y%m%d%H%M%S}]
+	set temp "$black(tempdir)/seen_temp.$timestamp"
+	set tempwrite [open $temp w]
+foreach line $data {
+if {$line != ""} {
+	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 "LASTMSG $chanentry $userentry $hostentry $time $arg"
+	continue
+			} else {
+	puts $tempwrite $line
+			}
+		}
+	}
+if {$found_entry != ""} {
+	puts $tempwrite $found_entry
+	} else {
+	set found_entry "LASTMSG $chan $nick $host $time $arg"
+	puts $tempwrite $found_entry
+	}
+	close $tempwrite
+    file rename -force $temp $seen_lastmessage_dir
+}
+
+
+proc seen:save:2 {nick chan host type time staytimer reason} {
+	global black
+	set j 0
+	set line_to_append "$type $chan $nick $host $time $staytimer $reason"
+	set file [open $black(seen_file) r]
+	set size [file size $black(seen_file)]
+	set data [split [read $file $size] \n]
+	close $file
+	set timestamp [clock format [clock seconds] -format {%Y%m%d%H%M%S}]
+	set temp "$black(tempdir)/seen_temp.$timestamp"
+	set tempwrite [open $temp w]
+foreach line $data {
+if {$line != ""} {
+	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 line_to_append "$type $chan $nick $host $time $j $reason"
+		} else {
+	puts $tempwrite $line
+		}
+	}
+}
+	puts $tempwrite $line_to_append
+	close $tempwrite
+	file rename -force $temp $black(seen_file)
+}
+
+proc seen:save:1 {nick chan host type time staytimer} {
+	global black
+	set line_to_append "$type $chan $nick $host $time $staytimer NONE"
+	set file [open $black(seen_file) r]
+	set size [file size $black(seen_file)]
+	set data [split [read $file $size] \n]
+	close $file
+	set timestamp [clock format [clock seconds] -format {%Y%m%d%H%M%S}]
+	set temp "$black(tempdir)/seen_temp.$timestamp"
+	set tempwrite [open $temp w]
+foreach line $data {
+if {$line != ""} {
+	set userentry [lindex  [split $line] 2]
+	set chanentry [lindex [split $line] 1]
+if {[string equal -nocase $userentry $nick] && [string match -nocase $chanentry $chan]} {
+	continue
+			} else {
+	puts $tempwrite $line		
+		}
+	}
+}
+	puts $tempwrite $line_to_append
+	close $tempwrite
+	file rename -force $temp $black(seen_file)
+}
+
+proc seen:join {nick host hand chan} {
+global botnick black
+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
+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
+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
+if {![validchan $chan]} { return }
+if {![setting:get $chan seen]} {
+	return
+}	
+	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 "N/A" }
+if {[isbotnick $kicked]} { return }
+	set line_to_append "KICK $chan $kicked $hosted $time 0 $reason"
+	set file [open $black(seen_file) r]
+	set size [file size $black(seen_file)]
+	set data [split [read $file $size] \n]
+	close $file
+	set timestamp [clock format [clock seconds] -format {%Y%m%d%H%M%S}]
+	set temp "$black(tempdir)/seen_temp.$timestamp"
+	set tempwrite [open $temp w]
+foreach line $data {
+if {$line != ""} {
+	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 line_to_append "KICK $chan $kicked $hosted $time $j $reason"
+} else {
+	puts $tempwrite $line
+		}
+	}
+}
+	puts $tempwrite $line_to_append
+	close $tempwrite
+	file rename -force $temp $black(seen_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 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] || $type == "0"} {
+	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 $read_time"
+	}
+	return
+}
+	set file [open $seendir r]
+	set size [file size $seendir]
+	set data [split [read $file $size] \n]
+	close $file
+	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 $black(seen_details) r]
+	set size [file size $black(seen_details)]
+	set data [split [read $file $size] \n]
+	close $file
+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"
+	set replace(%chan%) "$chanentry"
+} 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"
+	set replace(%chan%) "$chanentry"
+} 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"]} {
+	set text [black:color:set "" $reply]
+	blacktools:tell $nick "prv" $hand $chan $nick seen.27 $text
+	seenreply:all $nick $uhost $hand $chan $nick $chanentry $first_entry "prv"
+} else {
+	set text [black:color:set "" $reply]
+	blacktools:tell $nick $host $hand $chan $chan1 seen.27 $text
+	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"
+}
+	set text [black:color:set "" $reply]
+	blacktools:tell $nick $host $hand $chan $chan1 seen.27 $text
+		} else {
+	set text2 [black:color:set "" [split $first_entry]]
+	blacktools:tell $nick $host $hand $chan $chan1 seen.31 $text2
+			}
+		}
+	}	
+}
+	
+##############
+#########################################################################
+##   END                                                               ##
+#########################################################################

+ 307 - 0
BlackTools2.5.2/Modules/BT.TCL.tcl

@@ -0,0 +1,307 @@
+#########################################################################
+##          BlackTools - The Ultimate Channel Control Script           ##
+##                    One TCL. One smart Eggdrop                       ##
+#########################################################################
+###############################   TCL   #################################
+#########################################################################
+##						                       ##
+##   BlackTools  : http://blacktools.tclscripts.net	               ##
+##   Bugs report : http://www.tclscripts.net/	                       ##
+##   GitHub page : https://github.com/tclscripts/BlackToolS-TCL-script ##
+##   Online Help : irc://irc.undernet.org/tcl-help 	               ##
+##                 #TCL-HELP / UnderNet                                ##
+##                 You can ask in english or romanian                  ##
+##					                               ##
+#########################################################################
+
+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
+}
+	
+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
+}
+
+list {
+	set the_files [glob -directory $black(dirname) "*.tcl"]
+	set current_tcl ""
+	set counter 0
+	set found_tcl 0
+	set timestamp [clock format [clock seconds] -format {%Y%m%d%H%M%S}]
+	set temp "$black(tempdir)/tcl_temp.$timestamp"
+	array set tcllist [list]
+	set num_l 1
+	set num 0
+foreach file $the_files {
+	set split_file [split $file "/"]
+	set the_file [lindex $split_file 1]
+if {[string match -nocase "*.tcl" $the_file]} {
+	set found_tcl 1
+}
+	set status [check:if:load $the_file]
+if {$status == "1"} {
+	lappend tcllist(1) $the_file
+	} else {
+	lappend tcllist(2) $the_file
+	}
+	unset status
+}
+
+if {$found_tcl == "0"} {
+	blacktools:tell $nick $host $hand $chan $chan1 tcl.2 "tcl"
+	return
+}
+
+	set tempwrite [open $temp w]
+foreach n [lsort -integer -increasing [array names tcllist]] {
+foreach tcl $tcllist($n) {
+	set counter [expr $counter + 1]
+if {$n == "1"} {
+	puts $tempwrite "$counter \002$tcl\002"
+	} elseif {$n == "2"} {
+	puts $tempwrite "$counter $tcl"
+		}
+	}
+}
+	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 "tcl" "0" $the_script
+	}
+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 return [lsearch -all -inline $data "source scripts/$tcl"]
+if {$return != ""} {
+	return 1
+} else {
+	return 0
+	}
+}
+
+##############
+#########################################################################
+##   END                                                               ##
+#########################################################################

+ 136 - 0
BlackTools2.5.2/Modules/BT.Timer.tcl

@@ -0,0 +1,136 @@
+#########################################################################
+##          BlackTools - The Ultimate Channel Control Script           ##
+##                    One TCL. One smart Eggdrop                       ##
+#########################################################################
+#############################   TIMER TCL   #############################
+#########################################################################
+##						                       ##
+##   BlackTools  : http://blacktools.tclscripts.net	               ##
+##   Bugs report : http://www.tclscripts.net/	                       ##
+##   GitHub page : https://github.com/tclscripts/BlackToolS-TCL-script ##
+##   Online Help : irc://irc.undernet.org/tcl-help 	               ##
+##                 #TCL-HELP / UnderNet                                ##
+##                 You can ask in english or romanian                  ##
+##					                               ##
+#########################################################################
+
+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                                                               ##
+#########################################################################

+ 668 - 0
BlackTools2.5.2/Modules/BT.TopWords.tcl

@@ -0,0 +1,668 @@
+#########################################################################
+##          BlackTools - The Ultimate Channel Control Script           ##
+##                    One TCL. One smart Eggdrop                       ##
+#########################################################################
+###########################   TOPWORDS TCL   ############################
+#########################################################################
+##						                       ##
+##   BlackTools  : http://blacktools.tclscripts.net	               ##
+##   Bugs report : http://www.tclscripts.net/	                       ##
+##   GitHub page : https://github.com/tclscripts/BlackToolS-TCL-script ##
+##   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]] [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:process {nick host hand chan chan1 cmd type next} {
+global botnick black username
+	set topwords_file "$black(dirname)/BlackTools/FILES/TOPWORDS/$username.$chan.txt"
+	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 {![setting:get $chan topwords]} {
+	return
+}
+if {![validchan $chan]} {
+	blacktools:tell $nick $host $hand $chan $chan1 gl.novalidchan none
+	return
+}
+
+if {![file isdirectory "$black(dirname)/BlackTools/FILES/TOPWORDS"]} {
+	blacktools:tell $nick $host $hand $chan $chan1 topwords.7 none
+	return
+}
+if {![file exists $topwords_file]} {
+	blacktools:tell $nick $host $hand $chan $chan1 topwords.7 none
+	return
+}
+
+if {[string equal -nocase $cmd "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 {[regexp {:} $cmd]} {
+	set split_cmd [split $cmd ":"]
+	set theuser [lindex $split_cmd 1]
+if {[onchan $theuser $chan]} {
+	set mask [return_mask [return_host_num "topwords" $chan [getchanhost $theuser $chan]] [getchanhost $theuser $chan] $theuser]
+} else {
+	set mask ""
+}
+	topwords:user $nick $host $hand $chan $chan1 $cmd $mask $type
+	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 $topwords_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 match -nocase $enc_chan $chan]} {
+if {[string equal -nocase $cmd "total"]} {
+	set words_count [lindex [split $line] 6]
+} elseif {[string equal -nocase $cmd "week"]} {
+	set words_count [lindex [split $line] 7]
+} else {
+	set words_count [lindex [split $line] 8]
+}
+	set read_nick [lindex [split $line] 1]
+if {$words_count > 0} {
+lappend topwordslist($words_count) $read_nick
+		}
+	}
+}
+	close $file
+	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) {
+	puts $tempwrite "$user $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 {$data == ""} {
+if {[string equal -nocase $cmd "total"]} {
+	blacktools:tell $nick $host $hand $chan $chan1 topwords.7 none
+} elseif {[string equal -nocase $cmd "week"]} {
+	blacktools:tell $nick $host $hand $chan $chan1 topwords.23 none
+} else {
+	blacktools:tell $nick $host $hand $chan $chan1 topwords.14 none
+}
+	return
+}
+if {[string equal -nocase $cmd "total"]} {
+	module:getinfo $nick $host $hand $chan $chan1 $type $data "topwords:total" "0" $next
+} elseif {[string equal -nocase $cmd "week"]} {
+	module:getinfo $nick $host $hand $chan $chan1 $type $data "topwords:week" "0" $next
+	} else {
+	module:getinfo $nick $host $hand $chan $chan1 $type $data "topwords" "0" $next
+	}
+}
+
+proc topwords:user {nick host hand chan chan1 user mask type1} {
+	global black username
+	set found_it 0
+	set split_user [split $user ":"]
+	set theuser [lindex $split_user 1]
+	set type [lindex $split_user 0]
+	set topwords_file "$black(dirname)/BlackTools/FILES/TOPWORDS/$username.$chan.txt"
+switch $type {
+	reset {
+	set reset [topwords:user:reset $theuser $chan]
+if {$reset == "1"} {
+	blacktools:tell $nick $host $hand $chan $chan1 topwords.29 $theuser
+} else {
+	blacktools:tell $nick $host $hand $chan $chan1 topwords.4 $theuser
+		}
+	}
+default {
+	set file [open $topwords_file r]
+	set size [file size $topwords_file]
+	set data [split [read $file $size] \n]
+	close $file
+foreach line $data {
+	set read_chan [lindex [split $line] 0]
+	set enc_chan [encoding convertfrom utf-8 $read_chan]
+	set read_user [lindex [split $line] 1]
+	set read_mask [lindex [split $line] 2]
+if {$mask != ""} {
+if {[string equal -nocase $enc_chan $chan] && [string match -nocase $read_mask $mask]} {
+	set found_it 1
+	set read_user [lindex [split $line] 1]
+	set get_lines [lrange [split $line] 3 5]
+	set get_words [lrange [split $line] 6 8]
+	set get_chars [lrange [split $line] 9 11]
+	set get_actions [lrange [split $line] 12 14]
+	set get_smiles [lrange [split $line] 15 17]
+	set get_ques [lrange [split $line] 18 20]
+	show:topwords:user $nick $host $hand $chan $chan1 $read_user $read_mask $get_lines $get_words $get_chars $get_actions $get_smiles $get_ques $type
+	continue
+	}
+} elseif {[string equal -nocase $enc_chan $chan] && [string equal -nocase $read_user $theuser]} {
+	set found_it 1
+	set read_mask [lindex [split $line] 2]
+	set get_lines [lrange [split $line] 3 5]
+	set get_words [lrange [split $line] 6 8]
+	set get_chars [lrange [split $line] 9 11]
+	set get_actions [lrange [split $line] 12 14]
+	set get_smiles [lrange [split $line] 15 17]
+	set get_ques [lrange [split $line] 18 20]
+	show:topwords:user $nick $host $hand $chan $chan1 $read_user $read_mask $get_lines $get_words $get_chars $get_actions $get_smiles $get_ques $type
+	continue			
+				}
+			}
+if {$found_it == "0"} {
+	blacktools:tell $nick $host $hand $chan $chan1 topwords.27 $theuser
+			}
+		}	
+	}	
+}
+
+proc topwords:user:reset {user chan} {
+	global black username
+	set topwords_file "$black(dirname)/BlackTools/FILES/TOPWORDS/$username.$chan.txt"
+	set found_it 0
+	set file [open $topwords_file r]
+	set timestamp [clock format [clock seconds] -format {%Y%m%d%H%M%S}]
+	set temp "$black(tempdir)/othermodule_temp.$timestamp"
+	set tempwrite [open $temp w]
+while {[gets $file line] != -1} {
+	set getuser [lindex [split $line] 1]
+if {[string equal -nocase $getuser $user]} {
+	set found_it 1
+	continue
+		} else {
+	puts $tempwrite $line
+		}	 
+	}
+	close $tempwrite
+	close $file
+    file rename -force $temp $topwords_file
+	return $found_it
+}
+
+proc show:topwords:user {nick host hand chan chan1 read_user read_mask get_lines get_words get_chars get_actions get_smiles get_ques type} {
+	global black
+	set place [getactivplace $read_mask $chan $type]
+	set split_place [split $place ":"]
+	set total [lindex $split_place 1]
+	set theplace [lindex $split_place 0]
+switch $type {
+total {
+	set lines [lindex $get_lines 0]
+	set words [lindex $get_words 0]
+	set chars [lindex $get_chars 0]
+	set actions [lindex $get_actions 0]
+	set smiles [lindex $get_smiles 0]
+	set ques [lindex $get_ques 0]
+	blacktools:tell $nick $host $hand $chan $chan1 topwords.22 "$read_user $read_mask $words $lines $chars $smiles $actions $ques $theplace $total"
+}
+
+week {
+	set lines [lindex $get_lines 1]
+	set words [lindex $get_words 1]
+	set chars [lindex $get_chars 1]
+	set actions [lindex $get_actions 1]
+	set smiles [lindex $get_smiles 1]
+	set ques [lindex $get_ques 1]
+	blacktools:tell $nick $host $hand $chan $chan1 topwords.28 "$read_user $read_mask $words $lines $chars $smiles $actions $ques $theplace $total"
+}
+
+user {
+	set lines [lindex $get_lines 2]
+	set words [lindex $get_words 2]
+	set chars [lindex $get_chars 2]
+	set actions [lindex $get_actions 2]
+	set smiles [lindex $get_smiles 2]
+	set ques [lindex $get_ques 2]
+	blacktools:tell $nick $host $hand $chan $chan1 topwords.3 "$read_user $read_mask $words $lines $chars $smiles $actions $ques $theplace $total"
+		}
+	}
+}
+
+
+proc getactivplace {host chan type} {
+	global black username
+	set topwords_file "$black(dirname)/BlackTools/FILES/TOPWORDS/$username.$chan.txt"
+	array set activlist [list]
+	set counter 0
+	set all_count 0
+	set place 0
+	set file [open $topwords_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 $enc_chan $chan]} {
+	set all_count [expr $all_count + 1]
+if {[string equal -nocase $type "user"]} {
+	set nr_words [lindex [split $line] 8]
+} elseif {[string equal -nocase $type "week"]} {
+	set nr_words [lindex [split $line] 7]
+} elseif {[string equal -nocase $type "total"]} {
+	set nr_words [lindex [split $line] 6]
+}
+	set read_host [lindex [split $line] 2]
+	lappend activlist($nr_words) $read_host
+		}
+	}
+	close $file
+foreach h [lsort -integer -decreasing [array names activlist]] {
+	set counter [expr $counter + 1]
+if {[string equal -nocase $activlist($h) $host]} {
+	set place $counter
+	}
+}	
+if {$place == "0"} { set place $counter }
+	return $place:$all_count
+}
+
+proc topwords:module {nick host hand chan arg} {
+	global black username
+	set arg [split $arg]
+	set topwords_file "$black(dirname)/BlackTools/FILES/TOPWORDS/$username.$chan.txt"
+	set mask [return_mask [return_host_num "topwords" $chan $host] $host $nick]
+	set handle [nick2hand $nick]
+	set topwords_run 0
+if {[setting:get $chan topwords]} {
+if {![file isdirectory "$black(dirname)/BlackTools/FILES/TOPWORDS/"]} {
+	file mkdir "$black(dirname)/BlackTools/FILES/TOPWORDS/"
+}
+if {![file exists $topwords_file]} {
+	set file [open $topwords_file w]
+	close $file
+}
+
+	foreach tmr [timers] {
+if {[string match "*blacktools:timers:runtime*" [join [lindex $tmr 1]]]} {
+	set topwords_run 1
+	}
+}
+
+if {$topwords_run == "0"} {
+	return
+}
+
+if {[isbotnick $nick]} {
+	return
+}
+if {[validuser $handle]} {
+if {[matchattr $handle -|w $chan]} {
+	return
+	}
+}
+if {[setting:get $chan accessonly]} {
+if {![validuser $handle]} {
+	return
+}
+if {![matchattr $handle $black(exceptflags) $chan]} {
+	return
+	}
+}
+if {![info exist black(topwords:$chan:list)]} {
+	set black(topwords:$chan:list) $mask
+} else {
+if {[lsearch -exact -nocase $black(topwords:$chan:list) $mask] < 0} {
+	lappend black(topwords:$chan:list) $mask
+	}
+}
+	set lines 1
+	set last_message [unixtime]
+	set smile_num 0
+	set ques_num 0
+if {[string equal -nocase $hand "ACTION"]} {
+	set actions 1
+} else { set actions 0 }
+	set arg [regsub -all {\s+} $arg " "]
+	set words [llength $arg]
+	set chars [string length $arg]
+if {[regexp {[?]} $arg]} {
+	set ques_num [expr $ques_num + 1]
+}
+foreach text $arg {
+	set smile_stat [topwords:smile $text]
+if {$smile_stat != "-1"} {
+	set smile_num [expr $smile_num + 1]
+	}
+}
+if {![info exists black(topwords:$chan:$mask)]} {
+	set black(topwords:$chan:$mask) "$nick $lines $words $chars $actions $smile_num $ques_num"
+} else {
+	set get_lines [lindex [split $black(topwords:$chan:$mask)] 1]
+	set get_words [lindex [split $black(topwords:$chan:$mask)] 2]
+	set get_chars [lindex [split $black(topwords:$chan:$mask)] 3]
+	set get_actions [lindex [split $black(topwords:$chan:$mask)] 4]
+	set get_smiles [lindex [split $black(topwords:$chan:$mask)] 5]
+	set get_ques [lindex [split $black(topwords:$chan:$mask)] 6]
+	set black(topwords:$chan:$mask) "$nick [expr $get_lines + $lines] [expr $get_words + $words] [expr $get_chars + $chars] [expr $get_actions + $actions] [expr $get_smiles + $smile_num] [expr $get_ques + $ques_num]"	
+		}	
+	} 
+}
+
+
+proc topwords:save:channels {chans} {
+	global black
+foreach chan $chans {
+if {[validchan $chan]} {
+	lappend channels $chan
+		}
+	}
+if {$channels != ""} {
+		topwords:time $channels 0
+	}
+}
+
+proc topwords:time {channels counter} {
+	global black
+	set chan [lindex $channels $counter]
+	set cc [expr $counter + 1]
+if {$chan != ""} {
+	topwords:module:save $chan
+} 
+if {[lindex $channels $cc] == ""} {
+	return
+} else {
+	topwords:time $channels $cc
+	}
+}
+
+proc topwords:module:save {chan} {
+	global black username
+if {![info exists black(topwords:$chan:list)]} {
+	return
+}
+if {$black(topwords:$chan:list) == ""} {
+	return
+}
+	set topwords_file "$black(dirname)/BlackTools/FILES/TOPWORDS/$username.$chan.txt"
+if {![file exists $topwords_file]} {
+	return
+}
+if {$black(topwords:$chan:list) == ""} {
+	return
+}
+	topwords:remove_it $topwords_file $chan $black(topwords:$chan:list) 0
+}
+
+proc topwords:remove_it {files chan list position} {
+	global black
+	set mask [lindex $list $position]
+if {$mask != ""} {
+if {[info exists black(topwords:$chan:$mask)]} {
+	set file [open $files 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]
+	set found_mask 0
+	set counter 0
+	set get_nick [lindex [split $black(topwords:$chan:$mask)] 0]
+	set curr_lines [lindex [split $black(topwords:$chan:$mask)] 1]
+	set curr_words [lindex [split $black(topwords:$chan:$mask)] 2]
+	set curr_chars [lindex [split $black(topwords:$chan:$mask)] 3]
+	set curr_actions [lindex [split $black(topwords:$chan:$mask)] 4]
+	set curr_smiles [lindex [split $black(topwords:$chan:$mask)] 5]
+	set curr_ques [lindex [split $black(topwords:$chan:$mask)] 6]
+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_mask 1
+	set get_lines [lrange [split $line] 3 5]
+	set get_words [lrange [split $line] 6 8]
+	set get_chars [lrange [split $line] 9 11]
+	set get_actions [lrange [split $line] 12 14]
+	set get_smiles [lrange [split $line] 15 17]
+	set get_ques [lrange [split $line] 18 20]
+	continue
+			} else {
+		puts $tempwrite $line
+	}
+}
+if {$found_mask == "0"} {
+	puts $tempwrite "$chan $get_nick $mask $curr_lines $curr_lines $curr_lines $curr_words $curr_words $curr_words $curr_chars $curr_chars $curr_chars $curr_actions $curr_actions $curr_actions $curr_smiles $curr_smiles $curr_smiles $curr_ques $curr_ques $curr_ques"
+	} else {
+	puts $tempwrite "$chan $get_nick $mask [expr $curr_lines + [lindex $get_lines 0]] [expr $curr_lines + [lindex $get_lines 1]] [expr $curr_lines + [lindex $get_lines 2]] [expr $curr_words + [lindex $get_words 0]] [expr $curr_words + [lindex $get_words 1]] [expr $curr_words + [lindex $get_words 2]] [expr $curr_chars + [lindex $get_chars 0]] [expr $curr_chars + [lindex $get_chars 1]] [expr $curr_chars + [lindex $get_chars 2]] [expr $curr_actions + [lindex $get_actions 0]] [expr $curr_actions + [lindex $get_actions 1]] [expr $curr_actions + [lindex $get_actions 2]] [expr $curr_smiles + [lindex $get_smiles 0]] [expr $curr_smiles + [lindex $get_smiles 1]] [expr $curr_smiles + [lindex $get_smiles 2]] [expr $curr_ques + [lindex $get_ques 0]] [expr $curr_ques + [lindex $get_ques 1]] [expr $curr_ques + [lindex $get_ques 2]]"	
+	}
+	close $file
+	close $tempwrite
+	file rename -force $temp $files
+if {[info exists black(topwords:$chan:$mask)]} {
+	unset black(topwords:$chan:$mask)
+		}
+	set place [lsearch -exact -nocase $black(topwords:$chan:list) $mask]
+if {$place > 0} {
+	set black(topwords:$chan:list) [lreplace $black(topwords:$chan:list) $place $place]
+			}
+		}
+	}
+	set counter [expr $position + 1]
+if {[lindex $list $counter] != ""} {
+	topwords:remove_it $files $chan $list $counter
+	}
+}
+
+proc topwords:module:me {nick host hand chan keyword arg} {
+	global black
+if {[string equal -nocase $keyword "ACTION"]} {
+	topwords:module $nick $host "ACTION" $chan $arg
+	}
+}
+
+proc topwords:reset {chan} {
+	global black username
+	set found_entry 0
+if {[file exists "$black(dirname)/BlackTools/FILES/TOPWORDS/$username.$chan.txt"]} {
+	set found_entry 1
+	set file [open "$black(dirname)/BlackTools/FILES/TOPWORDS/$username.$chan.txt" w]
+	close $file
+}
+	return $found_entry
+}
+
+proc topwords:delete {chan} {
+	global black username
+if {$black(chanremove_all) == "0"} {
+	return
+		}
+if {[file exists "$black(dirname)/BlackTools/FILES/TOPWORDS/$username.$chan.txt"]} {
+	file delete "$black(dirname)/BlackTools/FILES/TOPWORDS/$username.$chan.txt"
+	}	
+}
+
+proc topwords:day:reset {minute hour day month year} {
+	global black username
+	set week_reset 0
+if {[clock format [clock seconds] -format "%w"] == 0} {
+	set week_reset 1
+}
+foreach chan [channels] {
+	set tpfile "$black(dirname)/BlackTools/FILES/TOPWORDS/$username.$chan.txt"
+if {[setting:get $chan topwords]} {
+if {![file exists $tpfile]} {
+	continue
+}
+	set file [open $tpfile r]
+	set size [file size $tpfile]
+	set data [split [read $file $size] \n]
+	close $file
+	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]
+foreach line $data {
+if {$line != ""} {
+	set get_chan [lindex [split $line] 0]
+	set get_nick [lindex [split $line] 1]
+	set get_host [lindex [split $line] 2]
+	set curr_lines [lrange [split $line] 3 5]
+	set curr_words [lrange [split $line] 6 8]
+	set curr_chars [lrange [split $line] 9 11]
+	set curr_actions [lrange [split $line] 12 14]
+	set curr_smiles [lrange [split $line] 15 17]
+	set curr_ques [lrange [split $line] 18 20]
+if {$week_reset == "1"} {
+	puts $tempwrite "$get_chan $get_nick $get_host [lindex $curr_lines 0] 0 0 [lindex $curr_words 0] 0 0 [lindex $curr_chars 0] 0 0 [lindex $curr_actions 0] 0 0 [lindex $curr_smiles 0] 0 0 [lindex $curr_ques 0] 0 0"
+		} else {
+	puts $tempwrite "$get_chan $get_nick $get_host [lindex $curr_lines 0] [lindex $curr_lines 1] 0 [lindex $curr_words 0] [lindex $curr_words 1] 0 [lindex $curr_chars 0] [lindex $curr_chars 1] 0 [lindex $curr_actions 0] [lindex $curr_actions 1] 0 [lindex $curr_smiles 0] [lindex $curr_smiles 1] 0 [lindex $curr_ques 0] [lindex $curr_ques 1] 0"
+		}
+	}
+}
+	close $tempwrite
+    file rename -force $temp $tpfile
+		}
+	}
+}
+
+
+proc topwords:smile {text} {
+	global black
+	set found_it [regexp -inline {(:|8|;)(-|o)?(>|D|\)|\]|\})} $text]
+if {$found_it != ""} {
+	return 1
+	} else {
+	return -1
+	}
+}
+
+
+##############
+#########################################################################
+##   END                                                               ##
+#########################################################################

+ 91 - 0
BlackTools2.5.2/Modules/BT.Topic.tcl

@@ -0,0 +1,91 @@
+#########################################################################
+##          BlackTools - The Ultimate Channel Control Script           ##
+##                    One TCL. One smart Eggdrop                       ##
+#########################################################################
+#############################   TOPIC TCL   #############################
+#########################################################################
+##						                       ##
+##   BlackTools  : http://blacktools.tclscripts.net	               ##
+##   Bugs report : http://www.tclscripts.net/	                       ##
+##   GitHub page : https://github.com/tclscripts/BlackToolS-TCL-script ##
+##   Online Help : irc://irc.undernet.org/tcl-help 	               ##
+##                 #TCL-HELP / UnderNet                                ##
+##                 You can ask in english or romanian                  ##
+##					                               ##
+#########################################################################
+
+proc topic:get {chan} {
+	global black
+	set getline ""
+	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 [join [lrange [split $line] 2 end]]
+	set getline [encoding convertfrom utf-8 $read_msg]
+	continue
+		}
+	}
+	close $file
+	return $getline
+}
+
+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]
+	set url [join [setting:get $chan url]]
+if {$url != ""} {
+	set chantopic [string map [list "($url)" ""] $chantopic]
+}
+if {![string equal -nocase [concat [color:filter $chantopic]] [concat [color:filter $gettopic]]]} {
+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
+}
+
+##############
+#########################################################################
+##   END                                                               ##
+#########################################################################

+ 149 - 0
BlackTools2.5.2/Modules/BT.VoiceMe.tcl

@@ -0,0 +1,149 @@
+#########################################################################
+##          BlackTools - The Ultimate Channel Control Script           ##
+##                    One TCL. One smart Eggdrop                       ##
+#########################################################################
+###########################   VOICEME TCL   #############################
+#########################################################################
+##						                       ##
+##   BlackTools  : http://blacktools.tclscripts.net	               ##
+##   Bugs report : http://www.tclscripts.net/	                       ##
+##   GitHub page : https://github.com/tclscripts/BlackToolS-TCL-script ##
+##   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"} {
+	utimer 30 [list voiceme:check:valid $chan]
+}
+if {$mod == "-m"} {
+	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
+	set text [black:color:set "" $black(say.$getlang.voiceme.2)]
+	set text [join $text]
+	puthelp "PRIVMSG $chan :[string map [array get replace] $text]"
+if {[info exists black(voiceme:stat:$chan)]} {
+	unset black(voiceme:stat:$chan)
+		}
+if {[info exists black(voiceme:$chan:timer_start)]} {
+	unset black(voiceme:$chan:timer_start)
+		}
+	}
+}
+
+proc voiceme:get:time {chan} {
+	global black
+if {[setting:get $chan voiceme-showtime] != ""} {
+	set return_time [time_return_minute [setting:get $chan voiceme-showtime]]
+} else {
+	set return_time [time_return_minute $black(voiceme:msgtime)]
+	}
+	return $return_time
+}
+
+proc voiceme:check:valid {chan} {
+	global black botnick
+	set found_timer 0
+	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
+if {[setting:get $chan nologged]} {
+	set text [black:color:set "" $black(say.$getlang.voiceme.6)]
+} else {
+	set text [black:color:set "" $black(say.$getlang.voiceme.1)]
+}
+	set text [join $text]
+	puthelp "PRIVMSG $chan :[string map [array get replace] $text]"
+if {![info exists black(voiceme:$chan:timer_start)]} {
+	set black(voiceme:$chan:timer_start) [voiceme:get:time $chan]
+		}
+	}
+}
+
+proc voiceme:showmsg_timer {chans} {
+	global black botnick
+	set found_entry 0
+	set unixtime [unixtime]
+foreach chan $chans {
+if {[setting:get $chan voiceme]} {
+
+if {[info exists black(lastaction:$chan)]} {
+	set total_anunt 0
+	set unixtime [unixtime]
+if {[setting:get $chan voiceme-showtime] != ""} {
+	set return_time [time_return_minute [setting:get $chan voiceme-showtime]]
+} else {
+	set return_time [time_return_minute $black(voiceme:msgtime)]
+}
+	set time [expr [expr [expr $return_time * $black(entry:shown)] * 60] + $unixtime]
+if {[expr $unixtime - $black(lastaction:$chan)] > [expr $time - $unixtime]} {
+	continue
+	}
+} else { continue }
+	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 {
+if {[setting:get $chan nologged]} {
+	set text [black:color:set "" $black(say.$getlang.voiceme.6)]
+} else {
+	set text [black:color:set "" $black(say.$getlang.voiceme.1)]
+}
+	set text [join $text]
+	puthelp "PRIVMSG $chan :[string map [array get replace] $text]"
+	set found_entry 1
+			}
+		} else {
+if {[info exists black(voiceme:stat:$chan)]} {		
+	unset black(voiceme:stat:$chan)	
+			}
+if {[info exists black(voiceme:$chan:timer_start)]} {
+	unset black(voiceme:$chan:timer_start)
+			}
+		}
+	}
+}
+
+##############
+#########################################################################
+##   END                                                               ##
+#########################################################################

+ 216 - 0
BlackTools2.5.2/Modules/BT.VoiceOnMsg.tcl

@@ -0,0 +1,216 @@
+#########################################################################
+##          BlackTools - The Ultimate Channel Control Script           ##
+##                    One TCL. One smart Eggdrop                       ##
+#########################################################################
+###########################   VOICEONMSG TCL   ##########################
+#########################################################################
+##						                       ##
+##   BlackTools  : http://blacktools.tclscripts.net	               ##
+##   Bugs report : http://www.tclscripts.net/	                       ##
+##   GitHub page : https://github.com/tclscripts/BlackToolS-TCL-script ##
+##   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
+if {[string equal -nocase $keyword "ACTION"]} {
+	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 {[matchattr $hand "nmo|MAOV" $chan]} {
+	return
+}
+
+if {![info exists black(voiceonmsg:list:$chan)]} {
+	set black(voiceonmsg:list:$chan) ""
+}
+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 -nocase "*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} {
+if {[setting:get $chan xonly] && [onchan $black(chanserv) $chan]} {	
+	putserv "PRIVMSG $black(chanserv) :voice $chan $nick"
+} else {
+	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 $host $chan
+	voiceonmsg:remove:the_list $host $chan
+}
+
+proc voiceonmsg:split {nick host hand chan args} {
+	global black
+	voiceonmsg:remove:expire $host $chan
+	voiceonmsg:remove:the_list $host $chan
+}
+
+proc voiceonmsg:kick {nick host hand chan kicked reason} {
+	global black
+	set kickhost [getchanhost $kicked $chan]
+	voiceonmsg:remove:expire $kickhost $chan
+	voiceonmsg:remove:the_list $kickhost $chan
+}
+
+proc voiceonmsg:timer {chans} {
+	global black
+	set channels ""
+foreach chan $chans {
+	lappend channels $chan
+	}
+if {$channels != ""} {
+	voiceonmsg:act $channels 0
+	}
+}
+
+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 [getchanhost $nick $chan]
+	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]} {
+if {[setting:get $chan xonly] && [onchan $black(chanserv) $chan]} {	
+	putserv "PRIVMSG $black(chanserv) :devoice $chan $nick"
+} else {
+	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                                                               ##
+#########################################################################