This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

BlackSeen 1.3

Support & discussion of released scripts, and announcements of new releases.
User avatar
BLaCkShaDoW
Op
Posts: 120
Joined: Sun Jan 11, 2009 4:50 am
Location: Romania
Contact:

BlackSeen 1.3

Post by BLaCkShaDoW »

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 :)
Last edited by BLaCkShaDoW on Thu Jun 24, 2010 9:33 am, edited 2 times in total.
BLaCkShaDoW Production @ WwW.TclScripts.Net
s
symbian001
Voice
Posts: 32
Joined: Sat Jan 17, 2009 1:13 pm

Post by symbian001 »

thank you BLaCkShaDoW. I will try it :)
K
Koo
Voice
Posts: 37
Joined: Fri Apr 02, 2010 7:43 pm

Re: BlackSeen 1.1

Post by Koo »

BLaCkShaDoW 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 :)
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. ^_^b

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. :D
User avatar
BLaCkShaDoW
Op
Posts: 120
Joined: Sun Jan 11, 2009 4:50 am
Location: Romania
Contact:

Re: BlackSeen 1.1

Post by BLaCkShaDoW »

Koo wrote:
BLaCkShaDoW 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 :)
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. ^_^b

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. :D
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.
That are my plans for the next version.
BLaCkShaDoW Production @ WwW.TclScripts.Net
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Re: BlackSeen 1.1

Post by speechles »

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?)
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:

Code: Select all

proc record:kick {nick host hand chan args} {
... snipped irrelevant parts....
set kicked [lindex [split $args] 0]
This appears fine to the novice eggdrop user. To the more educated user they can immediately spot the issue. He has made the mistake of using the special argument "args" within his procedure header expecting it to behave normally. Args is "special" because it will swallow all arguments in it's place and all those that follow and hold them as a tcl-list.

To simplify this even more:

Code: Select all

proc record:kick {nick host hand chan args} {
Args will be a tcl-list composed of 1 element, that being the text the user has entered. Using literally ANYTHING else here: arg, text, input, etc; this situation couldv'e been avoided.

Code: Select all

set kicked [lindex [split $args] 0]
Here he takes that tcl-list which using args produces and splits it. Effectively taking a list, and splitting it into another list?!?! This produces the visible bracings you are experiencing and the inability to match nicknames. Using a variable other than "args", this code would've been correct. With "args" used the set line needs to be changed like below:

Code: Select all

set kicked [lindex [split [lindex $args 0]] 0]
You can see how convoluted this gets when you don't understand the function of "args". ;) 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".
K
Koo
Voice
Posts: 37
Joined: Fri Apr 02, 2010 7:43 pm

Re: BlackSeen 1.1

Post by Koo »

BLaCkShaDoW wrote:Thanks for your suggestions and for the error reporting.
No problem. :D
BLaCkShaDoW 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.
Sounds nice. With that features in your script, then there's no doubt that I'll use it! XD ^_^b
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".
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. :D
User avatar
BLaCkShaDoW
Op
Posts: 120
Joined: Sun Jan 11, 2009 4:50 am
Location: Romania
Contact:

BlackSeen 1.2

Post by BLaCkShaDoW »

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.

Download link :

http://www.tclscripts.net/downloads.php ... nload_id=3
BLaCkShaDoW Production @ WwW.TclScripts.Net
K
Koo
Voice
Posts: 37
Joined: Fri Apr 02, 2010 7:43 pm

Post by Koo »

Black, I've edited your script and loaded it into my bot and then rehashed it. But I got this error. What should I do to correct it?
[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"

Anyway, here's your script that I've edited:

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"
Please tell me what have I done wrong and what should I do to correct it. Thanks in advance. :D


Also, how to make the bot notice person like "<nick1>, <nick2> <nick2's host> was looking for you on <channel> <time> ago."?
User avatar
BLaCkShaDoW
Op
Posts: 120
Joined: Sun Jan 11, 2009 4:50 am
Location: Romania
Contact:

hi

Post by BLaCkShaDoW »

Hmm..in what program did you edited the script..? try to put the original script without modifying it.I made some modif here is the working script.

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 Production @ WwW.TclScripts.Net
K
Koo
Voice
Posts: 37
Joined: Fri Apr 02, 2010 7:43 pm

Post by Koo »

Nice. I've tested it and it works well. ^_^b

There's one thing I like you to change. I got a notice like this: "Hello Koo, ({Koo[test]!~<myHost>} , {Koo[test]!~<myHost>}) was looking for you in #<mychannel>, 18 minutes 33 seconds ago.". (I edited your script, sorry. :P)

How to remove the "{}" in there and could you make the script also will notice me when I change my nick as well (not just the time when I join the channel)? Besides that, could you make the script notices the user that we're looking for her/him in one of any channels she's/he's in, not just only on channel where we typed "!seen <nick>"?

Also Black, I want this script to be able to delete the seen database and seenrecord database when I type ".remove #<channel>" or ".delete #channel" or something like that during bot CTCP.

Sorry, too much requests. Hope you don't mind. :P Thanks in advance Black.
User avatar
BLaCkShaDoW
Op
Posts: 120
Joined: Sun Jan 11, 2009 4:50 am
Location: Romania
Contact:

hi

Post by BLaCkShaDoW »

Hmm good ideeas :D
- i will see what i can do
I will put the modified script soon :)
And thanks again for the ideeas :D
BLaCkShaDoW Production @ WwW.TclScripts.Net
User avatar
BLaCkShaDoW
Op
Posts: 120
Joined: Sun Jan 11, 2009 4:50 am
Location: Romania
Contact:

Re: hi

Post by BLaCkShaDoW »

BLaCkShaDoW wrote:Hmm good ideeas :D
- i will see what i can do
- I will put the modified script soon
And thanks again for the ideeas :D
BLaCkShaDoW Production @ WwW.TclScripts.Net
User avatar
BLaCkShaDoW
Op
Posts: 120
Joined: Sun Jan 11, 2009 4:50 am
Location: Romania
Contact:

Re: hi

Post by BLaCkShaDoW »

Hmm good ideeas :D
- i will see what i can do
- I will put the modified script soon
And thanks again for the ideeas :D
BLaCkShaDoW Production @ WwW.TclScripts.Net
K
Koo
Voice
Posts: 37
Joined: Fri Apr 02, 2010 7:43 pm

Post by Koo »

lol triple posts. XD

I'm looking forward for your next improved version of Blackseen, Black. Good luck with that. :)
User avatar
BLaCkShaDoW
Op
Posts: 120
Joined: Sun Jan 11, 2009 4:50 am
Location: Romania
Contact:

BlackSeen

Post by BLaCkShaDoW »

BlackSeen 1.3 RELEASED


-now it shows how much time the user stayed on chan.
-added a system to notify users on join, if they were searched with !seen
-added a timer to erase old records.
-repaired some bugs.
BLaCkShaDoW Production @ WwW.TclScripts.Net
Post Reply