Oxyd Last Seen Script

By Hyper on Jan 29, 2006

This script is quite simple. Just load it and you're set. It will keep track of what users do, then when somebody needs to locate them, they can type !seen <username / search> in a channel... and it will find either the username, or the latest matches to the search.

; Hyper's Last Seen Script
; Last Edit: January 30, 2006
; For help...
; irc.enterthegame.com #null
; ...or...
; http://nullprod.abacionline.com/forum

on *:START:{
  if (!$hget(LastSeen)) { .hmake LastSeen 100 }
  if ($exists(LastSeen.hsh)) { .hload LastSeen LastSeen.hsh }
}
on *:TEXT:!seen*:#:{
  if (!$2) { halt }
  else {
    var %seen.entry = $hget(LastSeen,$2), %seen.action = $null, %seen.name = $2
    if ($nick == $2) { msg $chan Hey, Narcisso, stop looking for yourself. | halt }
    elseif ($2 == $me) { describe $chan waves to $nick $+ . | halt }
    elseif ($2 ison $chan) { msg $chan $2 is currently in the channel! | halt }
    elseif (!%seen.entry) {
      var %seen.num = $hfind(LastSeen,* $+ $2 $+ *,0,w)
      if (%seen.num == 0) {
        msg $chan I found no results for your LastSeen query.
        halt
      }
      else {
        var %seen.i = 1
        while (%seen.i <= $hfind(LastSeen,* $+ $2 $+ *,0,w)) {
          write LastSeen.tmp $hfind(LastSeen,* $+ $2 $+ *,%seen.i,w) $hget(LastSeen,$hfind(LastSeen,* $+ $2 $+ *,%seen.i,w))
          inc %seen.i
        }
        filter -ffteu 3 32 LastSeen.tmp LastSeen2.tmp *
        msg $chan I found %seen.num results for your LastSeen query. $iif(%seen.num > 5,Here are the top 5,Here are the results) $+ , starting with the newest result: $gettok($read(LastSeen2.tmp,1),1,32) $gettok($read(LastSeen2.tmp,2),1,32) $gettok($read(LastSeen2.tmp,3),1,32) $gettok($read(LastSeen2.tmp,4),1,32) $gettok($read(LastSeen2.tmp,5),1,32)
        %seen.name = $gettok($read(LastSeen2.tmp,1),1,32)
        .remove LastSeen.tmp
        .remove LastSeen2.tmp
      }
    }
    %seen.entry = $hget(LastSeen,%seen.name)
    %seen.action = $replace($gettok(%seen.entry,3,32),JOIN,joining $gettok(%seen.entry,4,32) $+ .)
    %seen.action = $iif(%seen.action == $gettok(%seen.entry,3,32),$replace($gettok(%seen.entry,3,32),TEXT,talking in $gettok(%seen.entry,4,32) $+ . They were saying: $gettok(%seen.entry,5-,32)),%seen.action)
    %seen.action = $iif(%seen.action == $gettok(%seen.entry,3,32),$replace($gettok(%seen.entry,3,32),ACT,acting in $gettok(%seen.entry,4,32) $+ . They were saying: * $2 $gettok(%seen.entry,5-,32)),%seen.action)
    %seen.action = $iif(%seen.action == $gettok(%seen.entry,3,32),$replace($gettok(%seen.entry,3,32),PART,parting from $gettok(%seen.entry,4,32) $+ $chr(44) stating: $gettok(%seen.entry,5-,32)),%seen.action)
    %seen.action = $iif(%seen.action == $gettok(%seen.entry,3,32),$replace($gettok(%seen.entry,3,32),QUIT,quitting from IRC $+ $chr(44) saying: $gettok(%seen.entry,4-,32)),%seen.action)
    %seen.action = $iif(%seen.action == $gettok(%seen.entry,3,32),$replace($gettok(%seen.entry,3,32),KICKED,being kicked from $gettok(%seen.entry,5,32) by $gettok(%seen.entry,4,32) $+ $chr(44) who stated: $gettok(%seen.entry,6-,32)),%seen.action)
    %seen.action = $iif(%seen.action == $gettok(%seen.entry,3,32),$replace($gettok(%seen.entry,3,32),KICK,kicking $gettok(%seen.entry,4,32) from $gettok(%seen.entry,5,32) $+ $chr(44) stating: $gettok(%seen.entry,6-,32)),%seen.action)
    %seen.action = $iif(%seen.action == $gettok(%seen.entry,3,32),$replace($gettok(%seen.entry,3,32),FROMNICK,changing nicknames from their old nick $+ $chr(44) which was $gettok(%seen.entry,4,32) $+ .),%seen.action)
    %seen.action = $iif(%seen.action == $gettok(%seen.entry,3,32),$replace($gettok(%seen.entry,3,32),CHNICK,changing their nickname to $gettok(%seen.entry,4,32) $+ .),%seen.action)
    %seen.entry = I last saw  $+ %seen.name $+  ( $+ $gettok(%seen.entry,1,32) $+ ) $duration($calc($ctime - $gettok(%seen.entry,2,32))) ago, %seen.action
    msg $chan %seen.entry
  }
}
on *:JOIN:#:{
  .hadd -m LastSeen $nick $address $ctime JOIN $chan
}
on *:TEXT:*:#:{
  .hadd -m LastSeen $nick $address $ctime TEXT $chan $1-
}
on *:ACTION:*:#:{
  .hadd -m LastSeen $nick $address $ctime ACT $chan $1-
}
on *:PART:#:{
  .hadd -m LastSeen $nick $address $ctime PART $chan $1-
}
on *:QUIT:{
  .hadd -m LastSeen $nick $address $ctime QUIT $1-
}
on *:KICK:#:{
  .hadd -m LastSeen $nick $address $ctime KICK $knick $chan $1-
  .hadd -m LastSeen $knick $remove($address($knick,5),$knick $+ !) $ctime KICKED $nick $chan $1-
}
on *:NICK:{
  .hadd -m LastSeen $newnick $address $ctime FROMNICK $nick
  .hadd -m LastSeen $nick $address $ctime CHNICK $newnick
}
on *:DISCONNECT:{
  .hsave -o LastSeen LastSeen.hsh
}
on *:EXIT:{
  .hsave -o LastSeen LastSeen.hsh
}

Comments

Sign in to comment.
HassanAbbas   -  Dec 01, 2006

Good :D

 Respond  
ch1zra   -  Apr 18, 2006

nice code...a good base for developing a full addon anyway :)

I\'ve never wrote a !seen script of mine... you gave me the idea now :)

:thumbsup:

 Respond  
bearruler   -  Feb 03, 2006

It has its advantages and disadvantages
I like the last 5 things they did, but theres alot of code involved.
Instead of all those $gettoks, you could make an alias like $s_t($nick) for the time. It can save alot of code space

Bear

 Respond  
`Kazuma   -  Jan 31, 2006

This is nice, I didn\'t have problems like bulgarianMAN stated in his comment. I dont have alot of people in and out of my chan, so i wouldnt need a hash table. But it\'s nice. Good feature.

 Respond  
xDaeMoN   -  Jan 30, 2006

@ Yoinx, I loop to each entry, save it in a text file & /filter it there. You could also use a window & /filter it there. I heard that using a window will be much faster.

 Respond  
Yoinx   -  Jan 30, 2006

Hey xdaemon, do you have a way of filtering a hash table? or are you just saying to save it as an ini/text and filtering that?

 Respond  
xDaeMoN   -  Jan 30, 2006

Or just type /hmake LastSeen 100

 Respond  
Hyper   -  Jan 30, 2006

restart mIRC, maybe? That script ought to work.

 Respond  
bulgarianMAN   -  Jan 30, 2006
  • /hdel: no such table \'LastSeen\' (line 49, script14.ini)
  • /hdel: no such table \'LastSeen\' (line 57, script14.ini)
  • /hdel: no such table \'LastSeen\' (line 45, script14.ini)
  • /hdel: no such table \'LastSeen\' (line 45, script14.ini)

sux...

 Respond  
Hyper   -  Jan 30, 2006

well, I could do that, but this way works fine. No need to fix it if it isn\'t broken. :P

 Respond  
xDaeMoN   -  Jan 30, 2006

Instead of doing that, you could use /filter to sort the entries :). Just a suggestion.

 Respond  
Hyper   -  Jan 30, 2006

I do hdel so that it orders the entries. :) I have it sort search results by the newest.

 Respond  
xDaeMoN   -  Jan 30, 2006

On each event, you don\'t have to do /hdel since if the item name is already there, it will just be overwritten.

On this part, \'$remove($address($nick,5),$nick $+ !)\', you just use \'$address\'

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.