on *:start:{
if !$hget(Wasted) { .hmake Wasted 100 }
if $exists(Wasted.hsh) { .hload Wasted Wasted.hsh }
}
on *:join:#:{
.hadd -m Wasted $+($chan,.,$address) $ctime
.hadd -m Wasted $+($chan,.,$nick) $addtok($hget(Wasted,$+($chan,.,$nick)),$address,32)
}
on *:part:#:{
wasted $chan $address
}
alias wasted {
if $hget(Wasted,$+($1,.,$2)) {
var %total = $hget(Wasted,$+(Total,.,$1,.,$2))
var %wasted = $calc($ctime - $hget(Wasted,$+($1,.,$2)))
inc %total %wasted
.hadd -m Wasted $+(Total,.,$1,.,$2) %total
}
}
on *:quit:{
var %a = 1, %b = $comchan($nick,0)
while %a <= %b {
wasted $comchan($nick,%a) $address
inc %a
}
}
on *:kick:#:{
wasted $chan $address
}
on *:text:!wasted*:#:{
if !$2 {
.msg $nick Your wasted time in $chan is $duration($calc($ctime - $hget(Wasted,$+($chan,.,$address)) + $hget(Wasted,$+(Total,.,$chan,.,$address))))
}
elseif !$hget(Wasted,$+($chan,.,$2)) {
.msg $nick Sorry, but I don't have a record for $2 on $chan
}
else {
var %a = 1, %b = $numtok($hget(Wasted,$+($chan,.,$2)),32), %time = 0
while %a <= %b {
var %address = $gettok($hget(Wasted,$+($chan,.,$2)),%a,32)
inc %time $hget(Wasted,$+(Total,.,$chan,.,%address))
inc %a
}
if $2 ison $chan {
var %address = $right($address($2,0),-2)
inc %time $calc($ctime - $hget(Wasted,$+($chan,.,%address)))
}
.msg $nick $2 $+ 's wasted time in $chan is $duration(%time)
}
}