; $seen.dir -> network specific directory.
; $seen.dir(nick) -> network and nick specific file.
alias seen.dir {
if ($0) {
; This will replace invalid characters with an underscore.
var %fn = $replacex($1,/,_,\,_,:,_,",_,<,_,>,_,|,_)
return $qt($+(seen\,$network,\,%fn,.ini))
}
else {
return $qt($+(seen\,$network))
}
}
; /seen.clear nick -> Clears the info stored about the nick
alias seen.clear {
; this are going to change [ to @ and ] to ~
var %topic = $replacex($1,[,@,],~)
var %filename = $seen.dir($1)
if ($isfile(%filename)) {
remini $seen.dir($1) %topic
}
else {
var %dir = $qt($left($nofile(%filename),-1))
if ($isdir(%dir) == $false) {
mkdir %dir
}
}
}
; /seen.set nick name value -> Stores name=value for the nick.
alias seen.set {
var %topic = $replacex($1,[,@,],~)
var %filename = $seen.dir($1)
var %dir = $qt($left($nofile(%filename),-1))
if ($isdir(%dir) == $false) {
mkdir %dir
}
if ($3 != $null ) {
writeini %filename %topic $2 $3- }
}
; $seen.get(nick,name) -> Retrieves the value stored for the nick.
alias seen.get {
var %topic = $replacex($1,[,@,],~)
var %filename = $seen.dir($1)
return $readini(%filename,%topic,$2)
}
on 1:TEXT:!seen:#:{
msg $chan $nick $+ , there are $findfile($seen.dir(*),0) seen records in my database. Please refine your search.
}
on 1:TEXT:suggest seen *:#:{
var %pattern = $+(*,$3,*.ini)
var %delay = 1
.timer 1 %delay notice $nick [ClubCX AI] Based on your search, I would suggest you are looking for one of the following nicknames:
inc %delay 2
var %n = $findfile($seen.dir,%pattern,0)
var %i = 1
while (%i < %n) {
.timer 1 %delay notice $nick $left($nopath($findfile($seen.dir,%pattern,%i)),-4)
inc %delay 2
inc %i
if (%i == 5) { break }
}
.timer 1 %delay notice $nick I found $calc(%n - %i) more matches. You can refine your search even more by supplying a better query. For example, *TAR* instead of *AR*
}
on 1:TEXT:!seen *:#:{
; if the guy is looking for you
if (* isin $2) || (? isin $2) {
var %pattern = $+(*,$2,*.ini)
msg $chan [ClubCX AI] $nick $+ , there are $findfile($seen.dir,%pattern,0) matching records in my database. To list them, type: suggest seen $2
return
}
elseif ($2 == $me) {
msg $chan $2 is running successfully.
return
}
; if the guy is so stupid that he looks after him self
elseif ($2 == $nick) {
msg $chan $nick $+ , you do realise this is a computer don't you?
return
}
; if the person he's looking for already is in the channel
elseif ($2 ison $chan) {
msg $chan $nick $+ , $2- is still in $chan $+ .
return
}
; this are going to change [ to @ and ] to ~
var %action = $seen.get($2,action)
var %time = $seen.get($2,time)
; if he's not in the ini files
if (%action == $null) {
msg $chan Sorry $nick $+ . I haven't seen $2 around.
}
; if the latest thing he did was to join the channel
elseif (%action == join) {
var %joinchannel = $seen.get($2,channel)
msg $chan $nick $+ , $2- joined %joinchannel $+ , $duration($calc($ctime - %time)) ago.
}
; if the latest thing he did was to part the channel...
elseif (%action == part) {
var %partchannel = $seen.get($2,channel)
msg $chan $nick $+ , $2 parted %partchannel $+ , $duration($calc($ctime - %time)) ago.
}
; if the latest thing he did was to quit...
elseif (%action == quit) {
var %quitmessage = $seen.get($2,message)
msg $chan $nick $+ , $2 quit with the message $qt(%quitmessage) $+ , $duration($calc($ctime - %time)) ago.
}
; if the latest thing he did was to be kicked...
elseif (%action == kick) {
var %kickchannel = $seen.get($2,channel)
msg $chan $nick $+ , $2 was kicked from %kickchannel $+ , $duration($calc($ctime - %time)) ago.
}
; if the latest thing he did was to change nickname
elseif (%action == nick) {
var %nicknew = $seen.get($2,nick)
msg $chan $nick $+ , $2 changed his nick to %nicknew $+ , $duration($calc($ctime - %time)) ago.
}
; if the latest thing he did was to say something...
elseif (%action == text) {
var %textchannel = $seen.get($2,channel)
msg $chan $nick $+ , $2 said something $+ , $duration($calc($ctime - %time)) ago.
}
; if the latest thing he did was an action
elseif (%action == action) {
var %actionchannel = $seen.get($2,channel)
msg $chan $nick $+ , $2 did an action in %actionchannel $+ , $duration($calc($ctime - %time)) ago.
}
}
; when someone joins...
on 1:JOIN:#:{
seen.clear $nick
seen.set $nick action join
seen.set $nick channel $chan
seen.set $nick time $ctime
}
; when someone parts the channel
on 1:PART:#:{
seen.clear $nick
seen.set $nick action part
seen.set $nick channel $chan
seen.set $nick time $ctime
}
; when someone quits
on 1:QUIT:{
seen.clear $nick
seen.set $nick action quit
seen.set $nick time $ctime
seen.set $nick message $1-
}
; when some moron gets kicked from the channel
on 1:KICK:#:{
seen.clear $nick
seen.set $nick action kick
seen.set $nick channel $chan
seen.set $nick time $ctime
}
; when someone changes nick
on 1:NICK:{
seen.clear $nick
seen.set $nick action nick
seen.set $nick newnick $newnick
seen.set $nick time $ctime
}
; when someone says something in the channel
on 1:TEXT:*:#:{
seen.clear $nick
seen.set $nick action text
seen.set $nick channel $chan
seen.set $nick text $1-
seen.set $nick time $ctime
}
; when someone makes an action in the channel
on 1:ACTION:*:#:{
seen.clear $nick
seen.set $nick action action
seen.set $nick channel $chan
seen.set $nick text $nick $1-
seen.set $nick time $ctime
}