I've tested this script and I like it. Especially the part when it states the time <nick> stayed on the channel. Good job Black. ^_^bBLaCkShaDoW wrote:BlackSeen 1.1
-Is a new type of TCL
-Has database foreach channel
-It searches only in the database of the channel were the command is applied
-the TCL logs only when he is activated
-NEW- Added in the reply how much the user stayed in the channel
To activate .chanset +blackseen
.seen *!*@host | !seen <nick>
Soon on Egghelp
Thanks for your suggestions and for the error reporting. In version 1.2 i will try to resolve the special <nick> problem and to add a command to delete the data from a chan.Also i will like to add a feature that will remove the users that aren`t seened for a "t" time.And also..i will try to add a function that if a user searches on #chan for nick1 (!seen nick1) and later the user nick1 joins the chan the bot will notice to nick1 one time only that "nick" searched for him including the date when the search has been made and the nick`s host.Koo wrote:I've tested this script and I like it. Especially the part when it states the time <nick> stayed on the channel. Good job Black. ^_^bBLaCkShaDoW wrote:BlackSeen 1.1
-Is a new type of TCL
-Has database foreach channel
-It searches only in the database of the channel were the command is applied
-the TCL logs only when he is activated
-NEW- Added in the reply how much the user stayed in the channel
To activate .chanset +blackseen
.seen *!*@host | !seen <nick>
Soon on Egghelp
However, this script still has a flaw. It can't detect the special characters nick. I've tested it with "!seen [nick]" and the output I got was like "I don't remember seeing [nick] on <channel>" (something like that, I don't quite remember). I've tested it with the nick change too and the output I got was like "<nick> was last seen changing nick to {[nick]}" (is this a special character choke problem?). That's all. Hope you could fix it soon.
Also, it would be better if you could add more feature like removing the seen data from the database when the bot owner types something like ".remove <channel>" or ".delete <channel>". Thanks.
This is from not listening to others, nor following the golden rules of tcl. Take for example the code snippet below, which is merely an example. There are other procedures which make this same mistake:Koo wrote:However, this script still has a flaw. It can't detect the special characters nick. I've tested it with "!seen [nick]" and the output I got was like "I don't remember seeing [nick] on <channel>" (something like that, I don't quite remember). I've tested it with the nick change too and the output I got was like "<nick> was last seen changing nick to {[nick]}" (is this a special character choke problem?)
Code: Select all
proc record:kick {nick host hand chan args} {
... snipped irrelevant parts....
set kicked [lindex [split $args] 0]
Code: Select all
proc record:kick {nick host hand chan args} {
Code: Select all
set kicked [lindex [split $args] 0]
Code: Select all
set kicked [lindex [split [lindex $args 0]] 0]
No problem.BLaCkShaDoW wrote:Thanks for your suggestions and for the error reporting.
Sounds nice. With that features in your script, then there's no doubt that I'll use it! XD ^_^bBLaCkShaDoW wrote:In version 1.2 i will try to resolve the special <nick> problem and to add a command to delete the data from a chan.Also i will like to add a feature that will remove the users that aren`t seened for a "t" time.And also..i will try to add a function that if a user searches on #chan for nick1 (!seen nick1) and later the user nick1 joins the chan the bot will notice to nick1 one time only that "nick" searched for him including the date when the search has been made and the nick`s host.
That are my plans for the next version.
Well, just give them some time and I'm sure they will remember the rule properly. By the way speechles, I'm one of your scripts' fan. Right now I'm using your Google and Webby scripts on my bot and I really love them! Thanks speechles.speechles wrote:You can see how convoluted this gets when you don't understand the function of "args". Wink Where "args" is in the original line must be replace with "[lindex $args 0]". This of course adds extra processing time, and is considered very bad form and quite sloppy style. Always remember the "rule of using args in tcl". That rule is: Never use "args" in procedure headers invoked from binds if you expect to do something with the parameters passed to "args".
These problems happen often when the script author doesn't quite grasp the language fully. Modifying examples from others without really knowing what those examples do. Perhaps reading this would refresh them of their rookie mistakes. Especially the part near the end titled, "A point worthy of note about args".
[01:30] Tcl error [recordz:seen]: invalid command name "recordz:seen"
[01:31] Tcl error [record:changenick]: invalid command name "record:changenick"
[01:31] Tcl error [record:changenick]: invalid command name "record:changenick"
[01:31] Tcl error [record:changenick]: invalid command name "record:changenick"
[01:31] Tcl error [record:changenick]: invalid command name "record:changenick"
[01:31] Tcl error [record:changenick]: invalid command name "record:changenick"
[01:31] Tcl error [record:changenick]: invalid command name "record:changenick"
[01:31] Tcl error [record:changenick]: invalid command name "record:changenick"
[01:31] Tcl error [record:changenick]: invalid command name "record:changenick"
[01:33] Tcl error [record:sign]: invalid command name "record:sign"
Code: Select all
##########################################################################
#
# BlackSeen 1.2
#
#
# BLaCkShaDoW ProductionS
##########################################################################
#
#-Is a new type of TCL
#-Has database foreach channel.
#-It searches only in the database of the channel were the command is applied.
#-the TCL logs only when he is activated.
#
# Version 1.1
#
#-NEW- Added in the reply how much the user stayed in the channel
#-NEW- Resolved some bugs.
#
# Version 1.2
#
#-NEW- Added a life time limit for the information about users.After this time
#the information will be deleted automaticly.
#-NEW- Added a feature in wich if a user is called on chan by (!seen <nick>) and then
#when he joins the chan the bot will announce him that he was searched by someone
#including of course the host of the user who searched and the time of the search.
#-NEW- Resolved some other bugs.
#
# To activate .chanset +blackseen
#
# .seen *!*@host | !seen <nick>
#
##########################################################################
#Who can use the seen command ? ( -|- for everyone )
set seen(flags) "-|-"
#Here you can set the first characters of the command.
set seen(chars) ". ! ` -"
#Anti-flood protection (searches:seconds)
set seen(flood) "4:5"
#Set here "1" if you want the reply to be trough NOTICE to the use
#or set "0" for the reply to be in trough channel message.
set seen(how) "1"
#Set here the maximum time for the bot to remember the information about users.
#After this time the bot will automaticly delete the information.(in days)
set seen(limittime) "60"
#Set here the period time for the bot to check the information ( in hours )
set seen(verifytime) "12"
##########################################################################
#
# There`s no END
#
#
##########################################################################
foreach s(char) $seen(chars) {
bind pub $seen(flags) $s(char)seen recordz:seen
}
bind join - * record:join
bind join - * record:seened
bind part - * record:part
bind sign - * record:sign
bind kick - * record:kick
bind splt - * record:split
bind nick - * record:changenick
setudef flag blackseen
set dir "BlackSeen.db"
set dir1 "seenrecord.db"
if {![file exists $dir]} {
set file [open $dir w]
close $file
}
if {![info exists record:expire_running]} {
timer [expr $seen(verifytime) * 60] record:expire
set record:expire_running 1
}
proc record:join {nick host hand chan} {
global dir botnick
if {![channel get $chan blackseen]} {
return 0
}
set lin 0
set time [unixtime]
set host "*!$host"
if {[isbotnick $nick]} { return 0 }
set who "JOIN $chan $nick $host $time 0"
set file [open $dir "r"]
set database [read -nonewline $file]
close $file
set data [split $database "\n"]
foreach line $data {
set lin [expr $lin +1]
set userentry [lindex [split $line] 2]
set chanentry [lindex [split $line] 1]
if {(([lsearch -exact [string tolower $userentry] [string tolower $nick]] == 0) || [string match -nocase $userentry $nick]) && [string match -nocase $chanentry $chan]} {
if {$line != ""} {
set num [expr $lin - 1]
set delete [lreplace $data $num $num]
set files [open $dir "w"]
puts $files [join $delete "\n"]
close $files
}
}
}
set file [open $dir "r"]
set data [read -nonewline $file]
close $file
if {$data == ""} {
set files [open $dir "w"]
close $files
}
set file [open $dir "a"]
puts $file "$who"
close $file
}
proc record:part {nick host hand chan arg} {
global dir botnick
if {![channel get $chan seen]} {
return 0
}
set lin 0
set time [unixtime]
set reason [join [lrange [split $arg] 0 end]]
if {$reason == ""} { set reason "No Reason"}
set host "*!$host"
if {[isbotnick $nick]} { return 0 }
set who "PART $chan $nick $host $time 0 $reason"
set file [open $dir "r"]
set database [read -nonewline $file]
close $file
set data [split $database "\n"]
foreach line $data {
set lin [expr $lin +1]
set userentry [lindex [split $line] 2]
set chanentry [lindex [split $line] 1]
if {(([lsearch -exact [string tolower $userentry] [string tolower $nick]] == 0) || [string match -nocase $userentry $nick]) && [string match -nocase $chanentry $chan]} {
set joined [lindex [split $line] 0]
if {$joined == "JOIN"} {
set j [lindex [split $line] 4]
set who "PART $chan $nick $host $time $j $reason"
}
if {$line != ""} {
set num [expr $lin - 1]
set delete [lreplace $data $num $num]
set files [open $dir "w"]
puts $files [join $delete "\n"]
close $files
}
}
}
set file [open $dir "r"]
set data [read -nonewline $file]
close $file
if {$data == ""} {
set files [open $dir "w"]
close $files
}
set file [open $dir "a"]
puts $file "$who"
close $file
}
proc record:sign {nick host hand chan arg} {
global dir botnick
if {![channel get $chan seen]} {
return 0
}
set lin 0
set time [unixtime]
set host "*!$host"
set reason [join [lrange [split $arg] 0 end]]
if {$reason == ""} { set reason "No Reason"}
if {[isbotnick $nick]} { return 0 }
set who "SIGN $chan $nick $host $time 0 $reason"
set file [open $dir "r"]
set database [read -nonewline $file]
close $file
set data [split $database "\n"]
foreach line $data {
set lin [expr $lin +1]
set userentry [lindex [split $line] 2]
set chanentry [lindex [split $line] 1]
if {(([lsearch -exact [string tolower $userentry] [string tolower $nick]] == 0) || [string match -nocase $userentry $nick]) && [string match -nocase $chanentry $chan]} {
set joined [lindex [split $line] 0]
if {$joined == "JOIN"} {
set j [lindex [split $line] 4]
set who "SIGN $chan $nick $host $time $j $reason"
}
if {$line != ""} {
set num [expr $lin - 1]
set delete [lreplace $data $num $num]
set files [open $dir "w"]
puts $files [join $delete "\n"]
close $files
}
}
}
set file [open $dir "r"]
set data [read -nonewline $file]
close $file
if {$data == ""} {
set files [open $dir "w"]
close $files
}
set file [open $dir "a"]
puts $file "$who"
close $file
}
proc record:kick {nick host hand chan kicked reason} {
global dir botnick
if {![channel get $chan seen]} {
return 0
}
set lin 0
set time [unixtime]
set hosted [getchanhost $kicked $chan]
set hosted "*!$hosted"
set reason [join [lrange [split $reason] 0 end]]
if {[isbotnick $kicked]} { return 0 }
set who "KICK $chan $kicked $hosted $time 0 $reason"
set file [open $dir "r"]
set database [read -nonewline $file]
close $file
set data [split $database "\n"]
foreach line $data {
set lin [expr $lin +1]
set userentry [lindex [split $line] 2]
set chanentry [lindex [split $line] 1]
if {(([lsearch -exact [string tolower $userentry] [string tolower $kicked]] == 0) || [string match -nocase $userentry $kicked]) && [string match -nocase $chanentry $chan]} {
set joined [lindex [split $line] 0]
if {$joined == "JOIN"} {
set j [lindex [split $line] 4]
set who "KICK $chan $kicked $hosted $time $j $reason"
}
if {$line != ""} {
set num [expr $lin - 1]
set delete [lreplace $data $num $num]
set files [open $dir "w"]
puts $files [join $delete "\n"]
close $files
}
}
}
set file [open $dir "r"]
set data [read -nonewline $file]
close $file
if {$data == ""} {
set files [open $dir "w"]
close $files
}
set file [open $dir "a"]
puts $file "$who"
close $file
}
proc record:split {nick host hand chan args} {
global dir botnick
if {![channel get $chan seen]} {
return 0
}
set lin 0
set time [unixtime]
set host "*!$host"
if {[isbotnick $nick]} { return 0 }
set who "SPLIT $chan $nick $host $time 0"
set file [open $dir "r"]
set database [read -nonewline $file]
close $file
set data [split $database "\n"]
foreach line $data {
set lin [expr $lin +1]
set userentry [lindex [split $line] 2]
set chanentry [lindex [split $line] 1]
if {(([lsearch -exact [string tolower $userentry] [string tolower $nick]] == 0) || [string match -nocase $userentry $nick]) && [string match -nocase $chanentry $chan]} {
set joined [lindex [split $line] 0]
if {$joined == "JOIN"} {
set j [lindex [split $line] 4]
set who "SPLIT $chan $nick $host $time $j $reason"
}
if {$line != ""} {
set num [expr $lin - 1]
set delete [lreplace $data $num $num]
set files [open $dir "w"]
puts $files [join $delete "\n"]
close $files
}
}
}
set file [open $dir "r"]
set data [read -nonewline $file]
close $file
if {$data == ""} {
set files [open $dir "w"]
close $files
}
set file [open $dir "a"]
puts $file "$who"
close $file
}
proc record:changenick {nick host hand chan newnick} {
global dir botnick
if {![channel get $chan seen]} {
return 0
}
set lin 0
set time [unixtime]
set host "*!$host"
if {[isbotnick $nick]} { return 0 }
set who "NICKCHANGE $chan $nick $host $time 0 $newnick"
set file [open $dir "r"]
set database [read -nonewline $file]
close $file
set data [split $database "\n"]
foreach line $data {
set lin [expr $lin +1]
set userentry [lindex [split $line] 2]
set chanentry [lindex [split $line] 1]
if {(([lsearch -exact [string tolower $userentry] [string tolower $nick]] == 0) || [string match -nocase $userentry $nick]) && [string match -nocase $chanentry $chan]} {
if {$line != ""} {
set num [expr $lin - 1]
set delete [lreplace $data $num $num]
set files [open $dir "w"]
puts $files [join $delete "\n"]
close $files
}
}
}
set file [open $dir "r"]
set data [read -nonewline $file]
close $file
if {$data == ""} {
set files [open $dir "w"]
close $files
}
set file [open $dir "a"]
puts $file "$who"
close $file
}
proc recordz:seen {nick uhost hand chan arg} {
global dir dir1 seen count botnick
if {![channel get $chan blackseen]} {
return 0
}
set what [lindex [split $arg] 0]
set number [scan $seen(flood) %\[^:\]]
set timer [scan $seen(flood) %*\[^:\]:%s]
foreach tmr [utimers] {
if {[string match "*count(flood:$uhost:$chan)*" [join [lindex $tmr 1]]]} {
killutimer [lindex $tmr 2]
}
}
if {![info exists count(flood:$uhost:$chan)]} {
set count(flood:$uhost:$chan) 0
}
incr count(flood:$uhost:$chan)
utimer $timer [list unset count(flood:$uhost:$chan)]
if {$count(flood:$uhost:$chan) == "$number"} {
puthelp "NOTICE $nick :Please wait 1 minute before searching again."
return 0
}
if {[string match -nocase $what $nick]} { puthelp "NOTICE $nick :Why are you looking for yourself?"
return 0
}
if {[onchan $what $chan]} { puthelp "NOTICE $nick :$what is already on $chan."
return 0
}
set file [open $dir "r"]
set database [read -nonewline $file]
close $file
if {$database == ""} { puthelp "NOTICE $nick :No records."
return 0
}
if {![string match -nocase "*!*" "$what"]} {
set time [unixtime]
set mask "$nick!$uhost"
seen:rec $what $chan $time $mask
}
set data [split $database "\n"]
foreach line $data {
set how [lindex [split $line] 0]
set userentry [lindex [split $line] 2]
set chanentry [lindex [split $line] 1]
set host [lindex [split $line] 3]
set timer [lindex [split $line] 4]
set jointime [lindex [split $line] 5]
set reason [lrange [split $line] 6 end]
set newnick [lindex [split $line] 6]
set totalyear [expr [unixtime] - $timer]
set staytime [expr [unixtime] - $jointime]
set stayt [expr $timer - $jointime]
set staytime [duration $stayt]
set output [duration $totalyear]
if {$jointime == "0"} { set staymsg "However, I don't know how much time $nick stayed on $chan."
} else { set staymsg "after staying on $chan for $staytime."}
if {(([lsearch -exact [string tolower $what] [string tolower $userentry]] == 0) || [string match -nocase $what $userentry]) && [string match -nocase $chanentry $chan]} {
lappend entry $userentry
set counts [llength $entry]
if {$counts >= 15} {
puthelp "NOTICE $nick :There are too many results to display. Please retry your search."
return 0
}
set seenfound 1
if {[lindex [split $line] 0] == "PART"} {
set reply "Found ($counts) results for your entry. [join $entry ","] ($host) was last seen parting $chan $output ago with the reason ($reason) $staymsg"
}
if {[lindex [split $line] 0] == "SIGN"} {
set reply "Found ($counts) results for your entry. [join $entry ","] ($host) was last seen quiting $chan $output ago with the reason ($reason) $staymsg"
}
if {[lindex [split $line] 0] == "JOIN"} {
set reply "Found ($counts) results for your entry. [join $entry ","] ($host) was last seen joining $chan $output ago."
}
if {[lindex [split $line] 0] == "SPLIT"} {
set reply "Found ($counst) results for your entry. [join $entry ","] ($host) was last seen quitting $chan in *.net *.split $output ago $staymsg"
}
if {[lindex [split $line] 0] == "KICK"} {
set reply "Found ($counts) results for your entry. [join $entry ","] ($host) was last seen being kicked $output ago with the reason ($reason) $staymsg"
}
if {[lindex [split $line] 0] == "NICKCHANGE"} {
if {[onchan $newnick $chan]} { set nowon "$newnick is still on chan." } else { set nowon "I dont see $newnick on chan at the moment" }
set reply "Found ($counts) results for your entry. [join $entry ","] ($host) was last seen changing nick to $newnick $output ago. $nowon"
}
}
if {$what == "*!*@*"} { return 0 }
if {[string match -nocase $what $host] && [string match -nocase $chanentry $chan]} {
lappend entry $userentry
set counts [llength $entry]
if {$counts >= 15} {
puthelp "NOTICE $nick :There are too many search results to display. Please retry the search."
return 0
}
set seenfound 1
if {[lindex [split $line] 0] == "PART"} {
set reply "Found ($counts) results for your entry. [join $entry ","] ($host) was last seen parting $chan about $output with the reason: ($reason) $staymsg"
}
if {[lindex [split $line] 0] == "SIGN"} {
set reply "Found ($counts) results for your entry. [join $entry ","] ($host) was last seen quiting $chan about $output with the reason: ($reason) $staymsg"
}
if {[lindex [split $line] 0] == "JOIN"} {
set reply "Found ($counts) results for your entry. [join $entry ","] ($host) was last seen joining $chan $output ago."
}
if {[lindex [split $line] 0] == "SPLIT"} {
set reply "Found ($counst) results for your entry. [join $entry ","] ($host) was last seen quitting $chan in *.net *.split $output ago $staymsg"
}
if {[lindex [split $line] 0] == "KICK"} {
set reply "Found ($counts) results for your entry. [join $entry ","] ($host) was last seen being kicked from $chan $output ago with the reason: ($reason) $staymsg"
}
if {[lindex [split $line] 0] == "NICKCHANGE"} {
if {[onchan $newnick $chan]} { set nowon "$newnick is still on $chan at this moment." } else { set nowon "However, I don't see $newnick on $chan at this moment." }
set reply "Found ($counts) results for your entry. [join $entry ","] ($host) was last seen changing nick to $newnick $output ago. $nowon"
}
}
}
if {[info exists reply]} {
if {$seen(how) == "1"} {
puthelp "NOTICE $nick :$reply"
} else { puthelp "PRIVMSG $chan :$reply"
}
}
if {![info exists seenfound]} {
puthelp "NOTICE $nick :I don't remember seeing $what on $chan."
}
}
proc seen:rec {nick chan time who} {
global dir1
set lin 0
set w "$nick $chan $time $who"
if {[isbotnick $nick]} { return 0 }
set filez [open $dir1 "r"]
set databases [read -nonewline $filez]
close $filez
set datas [split $databases "\n"]
foreach line $datas {
set lin [expr $lin +1]
set userentry [lindex [split $line] 0]
set chanentry [lindex [split $line] 1]
set inculpat [lindex [split $line] 3]
if {(([lsearch -exact [string tolower $userentry] [string tolower $nick]] == 0) || [string match -nocase $userentry $nick]) && [string match -nocase $chanentry $chan]} {
set w "$nick $chan $time $who"
if {![string match -nocase $inculpat $who]} {
lappend wer $inculpat $who
set w "$nick $chan $time [join $wer " , "]"
}
if {$line != ""} {
set num [expr $lin - 1]
set delete [lreplace $datas $num $num]
set files [open $dir1 "w"]
puts $files [join $delete "\n"]
close $files
}
}
}
set filez [open $dir1 "r"]
set datas [read -nonewline $filez]
close $filez
if {$datas == ""} {
set files [open $dir1 "w"]
close $files
}
set filez [open $dir1 "a"]
puts $filez "$w"
close $filez
}
proc record:seened {nick host hand chan} {
global dir1
if {![channel get $chan blackseen]} {
return 0
}
set lin 0
set filez [open $dir1 "r"]
set databases [read -nonewline $filez]
close $filez
set datas [split $databases "\n"]
foreach line $datas {
set lin [expr $lin +1]
set userentry [lindex [split $line] 0]
set chanentry [lindex [split $line] 1]
if {(([lsearch -exact [string tolower $userentry] [string tolower $nick]] == 0) || [string match -nocase $userentry $nick]) && [string match -nocase $chanentry $chan]} {
set time [lindex [split $line] 2]
set t [expr [unixtime] - $time]
set howmuch [duration $t]
set bywho [lrange [split $line] 3 end]
puthelp "NOTICE $nick :Hello $nick, ($bywho) was looking for you in $howmuch ago."
if {$line != ""} {
set num [expr $lin - 1]
set delete [lreplace $datas $num $num]
set files [open $dir1 "w"]
puts $files [join $delete "\n"]
close $files
}
}
}
}
proc record:expire {} {
global dir seen
putlog "(BlackSeen) Checking informations..."
set curtime [unixtime]
set lin 0
set countlin 0
set day 86400
set file [open $dir "r"]
set database [read -nonewline $file]
close $file
set data [split $database "\n"]
foreach line $data {
set lin [expr $lin +1]
set lastseen [lindex [split $line] 4]
set limitseen [expr ($curtime - $lastseen)/$day]
if {$limitseen > $seen(limittime)} {
set countlin [expr $countlin +1]
if {$line != ""} {
set num [expr $lin - 1]
set delete [lreplace $data $num $num]
set files [open $dir "w"]
puts $files [join $delete "\n"]
close $files
}
}
}
putlog "(BlackSeen) Found $countlin expired information."
timer [expr $seen(verifytime) * 60] record:expire
return 1
}
putlog "BlackSeen 1.2 by BLaCkShaDoW Loaded"
Code: Select all
##########################################################################
#
# BlackSeen 1.2
#
#
# BLaCkShaDoW ProductionS
##########################################################################
#
#-Is a new type of TCL
#-Has database foreach channel.
#-It searches only in the database of the channel were the command is applied.
#-the TCL logs only when he is activated.
#
# Version 1.1
#
#-NEW- Added in the reply how much the user stayed in the channel
#-NEW- Resolved some bugs.
#
# Version 1.2
#
#-NEW- Added a life time limit for the information about users.After this time
#the information will be deleted automaticly.
#-NEW- Added a feature in wich if a user is called on chan by (!seen <nick>) and then
#when he joins the chan the bot will announce him that he was searched by someone
#including of course the host of the user who searched and the time of the search.
#-NEW- Resolved some other bugs.
#
# To activate .chanset +blackseen
#
# .seen *!*@host | !seen <nick>
#
##########################################################################
#Who can use the seen command ? ( -|- for everyone )
set seen(flags) "-|-"
#Here you can set the first characters of the command.
set seen(chars) ". ! ` -"
#Anti-flood protection (searches:seconds)
set seen(flood) "4:5"
#Set here "1" if you want the reply to be trough NOTICE to the use
#or set "0" for the reply to be in trough channel message.
set seen(how) "1"
#Set here the maximum time for the bot to remember the information about users.
#After this time the bot will automaticly delete the information.(in days)
set seen(limittime) "60"
#Set here the period time for the bot to check the information ( in hours )
set seen(verifytime) "12"
##########################################################################
#
# There`s no END
#
#
##########################################################################
foreach s(char) $seen(chars) {
bind pub $seen(flags) $s(char)seen recordz:seen
}
bind join - * record:join
bind join - * record:seened
bind part - * record:part
bind sign - * record:sign
bind kick - * record:kick
bind splt - * record:split
bind nick - * record:changenick
setudef flag blackseen
set dir "BlackSeen.db"
set dir1 "seenrecord.db"
if {![file exists $dir]} {
set file [open $dir w]
close $file
}
if {![file exists $dir1]} {
set file [open $dir1 w]
close $file
}
if {![info exists record:expire_running]} {
timer [expr $seen(verifytime) * 60] record:expire
set record:expire_running 1
}
proc record:join {nick host hand chan} {
global dir botnick
if {![channel get $chan blackseen]} {
return 0
}
set lin 0
set time [unixtime]
set host "*!$host"
if {[isbotnick $nick]} { return 0 }
set who "JOIN $chan $nick $host $time 0"
set file [open $dir "r"]
set database [read -nonewline $file]
close $file
set data [split $database "\n"]
foreach line $data {
set lin [expr $lin +1]
set userentry [lindex [split $line] 2]
set chanentry [lindex [split $line] 1]
if {(([lsearch -exact [string tolower $userentry] [string tolower $nick]] == 0) || [string match -nocase $userentry $nick]) && [string match -nocase $chanentry $chan]} {
if {$line != ""} {
set num [expr $lin - 1]
set delete [lreplace $data $num $num]
set files [open $dir "w"]
puts $files [join $delete "\n"]
close $files
}
}
}
set file [open $dir "r"]
set data [read -nonewline $file]
close $file
if {$data == ""} {
set files [open $dir "w"]
close $files
}
set file [open $dir "a"]
puts $file "$who"
close $file
}
proc record:part {nick host hand chan arg} {
global dir botnick
if {![channel get $chan blackseen]} {
return 0
}
set lin 0
set time [unixtime]
set reason [join [lrange [split $arg] 0 end]]
if {$reason == ""} { set reason "No Reason"}
set host "*!$host"
if {[isbotnick $nick]} { return 0 }
set who "PART $chan $nick $host $time 0 $reason"
set file [open $dir "r"]
set database [read -nonewline $file]
close $file
set data [split $database "\n"]
foreach line $data {
set lin [expr $lin +1]
set userentry [lindex [split $line] 2]
set chanentry [lindex [split $line] 1]
if {(([lsearch -exact [string tolower $userentry] [string tolower $nick]] == 0) || [string match -nocase $userentry $nick]) && [string match -nocase $chanentry $chan]} {
set joined [lindex [split $line] 0]
if {$joined == "JOIN"} {
set j [lindex [split $line] 4]
set who "PART $chan $nick $host $time $j $reason"
}
if {$line != ""} {
set num [expr $lin - 1]
set delete [lreplace $data $num $num]
set files [open $dir "w"]
puts $files [join $delete "\n"]
close $files
}
}
}
set file [open $dir "r"]
set data [read -nonewline $file]
close $file
if {$data == ""} {
set files [open $dir "w"]
close $files
}
set file [open $dir "a"]
puts $file "$who"
close $file
}
proc record:sign {nick host hand chan arg} {
global dir botnick
if {![channel get $chan blackseen]} {
return 0
}
set lin 0
set time [unixtime]
set host "*!$host"
set reason [join [lrange [split $arg] 0 end]]
if {$reason == ""} { set reason "No Reason"}
if {[isbotnick $nick]} { return 0 }
set who "SIGN $chan $nick $host $time 0 $reason"
set file [open $dir "r"]
set database [read -nonewline $file]
close $file
set data [split $database "\n"]
foreach line $data {
set lin [expr $lin +1]
set userentry [lindex [split $line] 2]
set chanentry [lindex [split $line] 1]
if {(([lsearch -exact [string tolower $userentry] [string tolower $nick]] == 0) || [string match -nocase $userentry $nick]) && [string match -nocase $chanentry $chan]} {
set joined [lindex [split $line] 0]
if {$joined == "JOIN"} {
set j [lindex [split $line] 4]
set who "SIGN $chan $nick $host $time $j $reason"
}
if {$line != ""} {
set num [expr $lin - 1]
set delete [lreplace $data $num $num]
set files [open $dir "w"]
puts $files [join $delete "\n"]
close $files
}
}
}
set file [open $dir "r"]
set data [read -nonewline $file]
close $file
if {$data == ""} {
set files [open $dir "w"]
close $files
}
set file [open $dir "a"]
puts $file "$who"
close $file
}
proc record:kick {nick host hand chan kicked reason} {
global dir botnick
if {![channel get $chan blackseen]} {
return 0
}
set lin 0
set time [unixtime]
set hosted [getchanhost $kicked $chan]
set hosted "*!$hosted"
set reason [join [lrange [split $reason] 0 end]]
if {[isbotnick $kicked]} { return 0 }
set who "KICK $chan $kicked $hosted $time 0 $reason"
set file [open $dir "r"]
set database [read -nonewline $file]
close $file
set data [split $database "\n"]
foreach line $data {
set lin [expr $lin +1]
set userentry [lindex [split $line] 2]
set chanentry [lindex [split $line] 1]
if {(([lsearch -exact [string tolower $userentry] [string tolower $kicked]] == 0) || [string match -nocase $userentry $kicked]) && [string match -nocase $chanentry $chan]} {
set joined [lindex [split $line] 0]
if {$joined == "JOIN"} {
set j [lindex [split $line] 4]
set who "KICK $chan $kicked $hosted $time $j $reason"
}
if {$line != ""} {
set num [expr $lin - 1]
set delete [lreplace $data $num $num]
set files [open $dir "w"]
puts $files [join $delete "\n"]
close $files
}
}
}
set file [open $dir "r"]
set data [read -nonewline $file]
close $file
if {$data == ""} {
set files [open $dir "w"]
close $files
}
set file [open $dir "a"]
puts $file "$who"
close $file
}
proc record:split {nick host hand chan args} {
global dir botnick
if {![channel get $chan blackseen]} {
return 0
}
set lin 0
set time [unixtime]
set host "*!$host"
if {[isbotnick $nick]} { return 0 }
set who "SPLIT $chan $nick $host $time 0"
set file [open $dir "r"]
set database [read -nonewline $file]
close $file
set data [split $database "\n"]
foreach line $data {
set lin [expr $lin +1]
set userentry [lindex [split $line] 2]
set chanentry [lindex [split $line] 1]
if {(([lsearch -exact [string tolower $userentry] [string tolower $nick]] == 0) || [string match -nocase $userentry $nick]) && [string match -nocase $chanentry $chan]} {
set joined [lindex [split $line] 0]
if {$joined == "JOIN"} {
set j [lindex [split $line] 4]
set who "SPLIT $chan $nick $host $time $j $reason"
}
if {$line != ""} {
set num [expr $lin - 1]
set delete [lreplace $data $num $num]
set files [open $dir "w"]
puts $files [join $delete "\n"]
close $files
}
}
}
set file [open $dir "r"]
set data [read -nonewline $file]
close $file
if {$data == ""} {
set files [open $dir "w"]
close $files
}
set file [open $dir "a"]
puts $file "$who"
close $file
}
proc record:changenick {nick host hand chan newnick} {
global dir botnick
if {![channel get $chan blackseen]} {
return 0
}
set lin 0
set time [unixtime]
set host "*!$host"
if {[isbotnick $nick]} { return 0 }
set who "NICKCHANGE $chan $nick $host $time 0 $newnick"
set file [open $dir "r"]
set database [read -nonewline $file]
close $file
set data [split $database "\n"]
foreach line $data {
set lin [expr $lin +1]
set userentry [lindex [split $line] 2]
set chanentry [lindex [split $line] 1]
if {(([lsearch -exact [string tolower $userentry] [string tolower $nick]] == 0) || [string match -nocase $userentry $nick]) && [string match -nocase $chanentry $chan]} {
if {$line != ""} {
set num [expr $lin - 1]
set delete [lreplace $data $num $num]
set files [open $dir "w"]
puts $files [join $delete "\n"]
close $files
}
}
}
set file [open $dir "r"]
set data [read -nonewline $file]
close $file
if {$data == ""} {
set files [open $dir "w"]
close $files
}
set file [open $dir "a"]
puts $file "$who"
close $file
}
proc recordz:seen {nick uhost hand chan arg} {
global dir dir1 seen count botnick
if {![channel get $chan blackseen]} {
return 0
}
set what [lindex [split $arg] 0]
set number [scan $seen(flood) %\[^:\]]
set timer [scan $seen(flood) %*\[^:\]:%s]
foreach tmr [utimers] {
if {[string match "*count(flood:$uhost:$chan)*" [join [lindex $tmr 1]]]} {
killutimer [lindex $tmr 2]
}
}
if {![info exists count(flood:$uhost:$chan)]} {
set count(flood:$uhost:$chan) 0
}
incr count(flood:$uhost:$chan)
utimer $timer [list unset count(flood:$uhost:$chan)]
if {$count(flood:$uhost:$chan) == "$number"} {
puthelp "NOTICE $nick :Please wait 1 minute before searching again."
return 0
}
if {[string match -nocase $what $nick]} { puthelp "NOTICE $nick :$nick look into a mirror :)"
return 0
}
if {[onchan $what $chan]} { puthelp "NOTICE $nick :$what is allready on $chan :)"
return 0
}
set file [open $dir "r"]
set database [read -nonewline $file]
close $file
if {$database == ""} { puthelp "NOTICE $nick :I dont have any record in my database."
return 0
}
if {![string match -nocase "*!*" "$what"]} {
set time [unixtime]
set mask "$nick!$uhost"
seen:rec $what $chan $time $mask
}
set data [split $database "\n"]
foreach line $data {
set how [lindex [split $line] 0]
set userentry [lindex [split $line] 2]
set chanentry [lindex [split $line] 1]
set host [lindex [split $line] 3]
set timer [lindex [split $line] 4]
set jointime [lindex [split $line] 5]
set reason [lrange [split $line] 6 end]
set newnick [lindex [split $line] 6]
set totalyear [expr [unixtime] - $timer]
set staytime [expr [unixtime] - $jointime]
set stayt [expr $timer - $jointime]
set staytime [duration $stayt]
set output [duration $totalyear]
if {$jointime == "0"} { set staymsg "I dont know how much he stayed on $chan"
} else { set staymsg "After he stayed on $chan $staytime"}
if {(([lsearch -exact [string tolower $what] [string tolower $userentry]] == 0) || [string match -nocase $what $userentry]) && [string match -nocase $chanentry $chan]} {
lappend entry $userentry
set counts [llength $entry]
if {$counts >= 15} {
puthelp "NOTICE $nick :To many results.Please retry your search"
return 0
}
set seenfound 1
if {[lindex [split $line] 0] == "PART"} {
set reply "Found ($counts) results [join $entry ","] ($host) was seen parting about $output with the reason ($reason).$staymsg"
}
if {[lindex [split $line] 0] == "SIGN"} {
set reply "Found ($counts) results [join $entry ","] ($host) was seen quiting about $output with the reason ($reason).$staymsg"
}
if {[lindex [split $line] 0] == "JOIN"} {
set reply "Found ($counts) results [join $entry ","] ($host) was seen when he/she joined $chan about $output."
}
if {[lindex [split $line] 0] == "SPLIT"} {
set reply "Found ($counst) results [join $entry ","] ($host) was seen when he/she left in *.net *.split about $output.$staymsg"
}
if {[lindex [split $line] 0] == "KICK"} {
set reply "Found ($counts) results [join $entry ","] ($host) was seen when he received a KICK about $output with the reason ($reason).$staymsg"
}
if {[lindex [split $line] 0] == "NICKCHANGE"} {
if {[onchan $newnick $chan]} { set nowon "$newnick is still on chan." } else { set nowon "I dont see $newnick on chan at the moment" }
set reply "Found ($counts) results [join $entry ","] ($host) was seen when he changed his NICK in $newnick about $output.$nowon"
}
}
if {$what == "*!*@*"} { return 0 }
if {[string match -nocase $what $host] && [string match -nocase $chanentry $chan]} {
lappend entry $userentry
set counts [llength $entry]
if {$counts >= 15} {
puthelp "NOTICE $nick :There were to many search results please retry the search."
return 0
}
set seenfound 1
if {[lindex [split $line] 0] == "PART"} {
set reply "Found ($counts) results [join $entry ","] ($host) was seen parting about $output with the reason ($reason).$staymsg"
}
if {[lindex [split $line] 0] == "SIGN"} {
set reply "Found ($counts) results [join $entry ","] ($host) was seen quiting about $output with the reason ($reason).$staymsg"
}
if {[lindex [split $line] 0] == "JOIN"} {
set reply "Found ($counts) results [join $entry ","] ($host) was seen when he/she joined $chan about $output."
}
if {[lindex [split $line] 0] == "SPLIT"} {
set reply "Found ($counst) results [join $entry ","] ($host) was seen when he/she left in *.net *.split about $output.$staymsg"
}
if {[lindex [split $line] 0] == "KICK"} {
set reply "Found ($counts) results [join $entry ","] ($host) was seen when he received a KICK about $output with the reason ($reason).$staymsg"
}
if {[lindex [split $line] 0] == "NICKCHANGE"} {
if {[onchan $newnick $chan]} { set nowon "$newnick is still on $chan" } else { set nowon "I dont see $newnick on $chan for the momment" }
set reply "Found ($counts) results [join $entry ","] ($host) was seen when he changed his NICK in $newnick about $output.$nowon"
}
}
}
if {[info exists reply]} {
if {$seen(how) == "1"} {
puthelp "NOTICE $nick :$reply"
} else { puthelp "PRIVMSG $chan :$reply"
}
}
if {![info exists seenfound]} {
puthelp "NOTICE $nick :I didn`t see $what on $chan"
}
}
proc seen:rec {nick chan time who} {
global dir1
set lin 0
set w "$nick $chan $time $who"
if {[isbotnick $nick]} { return 0 }
set filez [open $dir1 "r"]
set databases [read -nonewline $filez]
close $filez
set datas [split $databases "\n"]
foreach line $datas {
set lin [expr $lin +1]
set userentry [lindex [split $line] 0]
set chanentry [lindex [split $line] 1]
set inculpat [lindex [split $line] 3]
if {(([lsearch -exact [string tolower $userentry] [string tolower $nick]] == 0) || [string match -nocase $userentry $nick]) && [string match -nocase $chanentry $chan]} {
set w "$nick $chan $time $who"
if {![string match -nocase $inculpat $who]} {
lappend wer $inculpat $who
set w "$nick $chan $time [join $wer " , "]"
}
if {$line != ""} {
set num [expr $lin - 1]
set delete [lreplace $datas $num $num]
set files [open $dir1 "w"]
puts $files [join $delete "\n"]
close $files
}
}
}
set filez [open $dir1 "r"]
set datas [read -nonewline $filez]
close $filez
if {$datas == ""} {
set files [open $dir1 "w"]
close $files
}
set filez [open $dir1 "a"]
puts $filez "$w"
close $filez
}
proc record:seened {nick host hand chan} {
global dir1
if {![channel get $chan blackseen]} {
return 0
}
set lin 0
set filez [open $dir1 "r"]
set databases [read -nonewline $filez]
close $filez
set datas [split $databases "\n"]
foreach line $datas {
set lin [expr $lin +1]
set userentry [lindex [split $line] 0]
set chanentry [lindex [split $line] 1]
if {(([lsearch -exact [string tolower $userentry] [string tolower $nick]] == 0) || [string match -nocase $userentry $nick]) && [string match -nocase $chanentry $chan]} {
set time [lindex [split $line] 2]
set t [expr [unixtime] - $time]
set howmuch [duration $t]
set bywho [lrange [split $line] 3 end]
puthelp "NOTICE $nick :Hello $nick, when you were away you had been searched by: ($bywho) about : $howmuch ago"
if {$line != ""} {
set num [expr $lin - 1]
set delete [lreplace $datas $num $num]
set files [open $dir1 "w"]
puts $files [join $delete "\n"]
close $files
}
}
}
}
proc record:expire {} {
global dir seen
putlog "(BlackSeen) Checking informations..."
set curtime [unixtime]
set lin 0
set countlin 0
set day 86400
set file [open $dir "r"]
set database [read -nonewline $file]
close $file
set data [split $database "\n"]
foreach line $data {
set lin [expr $lin +1]
set lastseen [lindex [split $line] 4]
set limitseen [expr ($curtime - $lastseen)/$day]
if {$limitseen > $seen(limittime)} {
set countlin [expr $countlin +1]
if {$line != ""} {
set num [expr $lin - 1]
set delete [lreplace $data $num $num]
set files [open $dir "w"]
puts $files [join $delete "\n"]
close $files
}
}
}
putlog "(BlackSeen) Found $countlin expired information."
timer [expr $seen(verifytime) * 60] record:expire
return 1
}
putlog "BlackSeen 1.2 by BLaCkShaDoW Loaded"
BLaCkShaDoW wrote:Hmm good ideeas
- i will see what i can do
- I will put the modified script soon
And thanks again for the ideeas