on *:join:#:{
set $+(%,Join.,$cid,.,$chan,.,$nick) $ctime
}
on *:part:#:{
var %ts = $eval($+(%,Join.,$cid,.,$chan,.,$nick),2)
if (%ts) {
echo 2 $chan $nick spent $duration($calc($ctime - %ts)) in the channel
unset $+(%,Join.,$cid,.,$chan,.,$nick)
}
}