; ••• add data after own join of a chan ('end of names list') •••
RAW 366:*: {
; no table existing (it's the first /names reply)
if (!$hget($+(Presence,$chr(9),$network,$chr(9),$2))) {
; add all nicks with value 'current time' to a hash table
var %nr = 1
while ($nick($2,%nr)) {
hadd -m $+(Presence,$chr(9),$network,$chr(9),$2) $v1 $ctime
inc %nr
}
}
}
; ••• add data on join •••
on !*:JOIN:#: {
; if table had been created, add nick with value 'current time'
if ($hget($+(Presence,$chr(9),$network,$chr(9),$chan))) { hadd $v1 $nick $ctime }
}
; ••• update data on nick •••
on *:NICK: {
; cycle all hash tables
var %nr = 1
while ($hget(%nr)) {
var %table = $v1
; it's a 'presence' table and it contains an entry for $nick
if (($gettok(%table,1,9) === Presence) && ($hget(%table,$nick))) {
; add a new item $newnick with the value of $nick and delete the old entry for $nick
hadd %table $newnick $v1
hdel %table $nick
}
inc %nr
}
}
; ••• delete data on kick •••
on *:KICK:#: {
; someone had been kicked
if ($knick != $me) {
; remove data of kicked user for this chan
if ($hget($+(Presence,$chr(9),$network,$chr(9),$chan),$knick)) {
hdel $+(Presence,$chr(9),$network,$chr(9),$chan) $knick
}
}
; you're kicked: remove ALL the chan's data
elseif ($hget($+(Presence,$chr(9),$network,$chr(9),$chan))) { hfree $v1 }
}
; ••• delete all data for the chan you parted •••
on me:*:PART:#: {
if ($hget($+(Presence,$chr(9),$network,$chr(9),$chan))) { hfree $v1 }
}
; ••• someone parted: custom part output, delete data of parting nick •••
on ^!*:PART:#: {
if ($hget($+(Presence,$chr(9),$network,$chr(9),$chan),$nick)) {
; this is the part output:
; ---------------------------------------------------------------------------------------------------------------------
ECHO -tbfrc part $chan *** $nick parts $chan (had been $duration($calc($ctime - $v1)) present on $chan $+ )
; ---------------------------------------------------------------------------------------------------------------------
; if you want to replace the default part message, remove the ; at the beginning of the next line
; HALTDEF
hdel $+(Presence,$chr(9),$network,$chr(9),$chan) $nick
}
}
; ••• delete all tables if you quit •••
on me:*:QUIT: {
; cycle all hash tables
var %nr = 1
while ($hget(%nr)) {
var %table = $v1
; it's a 'presence' table and it is a table for network: delete it
if (($gettok(%table,1,9) === Presence) && ($gettok(%table,2,9) == $network)) { hfree %table }
inc %nr
}
}
; ••• someone quitted: custom quit output, delete all data of quitting nick •••
on ^!*:QUIT: {
; cycle all hash tables
var %nr = 1
while ($hget(%nr)) {
var %table = $v1
tokenize 9 $v1
if (($1 === Presence) && ($2 == $network) && ($me ison $3) && ($hget(%table,$nick))) {
; this is the quit output
; ---------------------------------------------------------------------------------------------------------------------
ECHO -tbfrc quit $3 *** $nick left $3 (had been $duration($calc($ctime - $v1)) present on $3 $+ )
; ---------------------------------------------------------------------------------------------------------------------
; if you want to replace the default quit message, remove the ; at the beginning of the next line
; HALTDEF
hdel %table $nick
}
inc %nr
}
}