on *:join:#:tokenize 32 $+(#,@,$network) | if ($nick == $me) && (!$hget($1)) { hmake $1 | hload -i $1 Bans.db $1 }
on *:part:#:if ($nick == $me) savebans $+(#,@,$network) 1
on *:kick:#:if ($knick == $me) savebans $+(#,@,$network) 1
alias -l savebans if ($hget($1)) { hsave -i $1 Bans.db $1 | if ($2) hfree $1 }
on *:disconnect:var %x = 1 | while ($chan(%x)) { savebans $+($v1,@,$network) 1 | inc %x }
on *:ban:#: {
var %h = $+(#,@,$network),%c $ctime($date 00:00:00)
while ($asctime(%c,dddd) != monday) dec %c 86400
tokenize 32 $hget(%h,$nick)
hadd %h $nick $calc(1+$1) $iif($2 == $asctime(yyyy-mm),$2 $calc(1+$3),$v2 1) $iif($4 == %c,$4 $calc(1+$5),%c 1) $iif($6 == $asctime(yyyy-mm-dd),$6 $calc(1+$7),$v2 1)
;1=total bans, 2=yyyy-mm, 3=monthly bans, 4=last monday ctime, 5=weekly bans, 6=yyyy-mm-dd & 7=daily bans
;Remove the ";" character from below, if you want it to save the record each time its updated. (300 = 5 minute delay, so it's not constantly writing on the HDD/SSD.)
;.timersavebans $+ %h 1 300 savebans %h
}
on *:text:!bans*:#: {
if ($2 ischan) tokenize 32 $2-3 $hget($+($2,@,$network),$3)
else tokenize 32 # $2 $hget($+(#,@,$network),$2)
if ($3) {
var %c = $ctime($date 00:00:00)
while ($asctime(%c,dddd) != monday) dec %c 86400
notice $nick $2 has banned $iif($8 == $asctime(yyyy-mm-dd),$bytes($9,b) $users($9),0 users) today, $iif($6 == %c,$bytes($7,b) $users($7),0 users) this week, $iif($4 == $asctime(yyyy-mm),$bytes($5,b) $users($5),0 users) this month and $bytes($3,b) $users($3) overall on $1 $+ .
}
elseif ($2) notice $nick Either I have no idea who $2 is, or they haven't set any bans on $1 $+ .
else notice $nick Usage: !bans [CHANNEL] <NICK>
}
alias -l users if ($1 == 1) return user | return users