My first actual attempt at using hash tables.
On command will ban the specified user for x minutes. If the user isn't on the channel will add them to a list. Should they return to the channel while they are on the list it will ban them then and there. Great way to deal with ban evaders breaking a rule and leaving before you can ban them. Makes sure that they HAVE to wait out their ban at a time when they want to be on the channel.
Multi-channel support allows for use with larger bots. Any command on a channel relates only to that channel so you can ban a user on one channel, or several.
Commands:
!tb : Tempbans the user from the channel for time specified.
!tblist : Checks to see if a user is banned from that channel and messages information if they are.
!tbremove : Removes the user from the tb list for that channel
On *:CONNECT: {
hmake tempban 10
if ( $isfile(tban.hsh) ) hload tempban tban.hsh
}
On *:EXIT: hsave -o tempban tban.hsh
On *:DISCONNECT: hsave -o tempban tban.hsh
on *:TEXT:!tb *:#: { if ($2 !ison $chan) && ($nick ishop $chan || $nick isop $chan) && ($3 isnum) && ($2 != $me) {
hadd tempban $2 $+ $chan $chan
hadd tempban duration $+ $chan $+ $2 $calc($3 * 60)
hadd tempban reason $+ $chan $+ $2 $4-
msg $chan 05 $+ $2 has been added to the07 $chan 05automated ban list for07 $3 05minutes (Reason:07 $4- $+ 05) $+ .
}
elseif ($nick ishop $chan || $nick isop $chan) && (!$2 || $3 !isnum || $2 = $me) {
notice $nick Error: Correct Syntax - !tb <nick> <minutes> <reason> }
elseif ($nick ishop $chan || $nick isop $chan) && ($3 isnum || $2 != $me) {
inc %tbcount
timer 1 0 ban -ku $+ $calc($3 * 60) $chan $2 $4-
timer 1 1 msg $chan 07 $2 05has been tempbanned from07 $chan 05for07 $3 05minutes (Reason:07 $4- $+ ) 05[07 $+ %tbcount 05 people banned].
timer 1 2 notice $2 05You have been tempbanned from07 $chan 05for07 $3 05minutes (Reason:07 $4- $+ ).
}
}
on *:TEXT:!tblist *:#: { if ( $hget(tempban,$2 $+ $chan) == $null ) && ($2 != $null) {
notice $nick $2 is not on the automated tempban list for $chan $+ . }
elseif ($2 == $null) { notice $nick Please specify a username to search for }
else { msg $nick 07 $+ $chan 05TempBan Listing for07 $2
msg $nick 05-----
msg $nick 05Duration:07 $calc($hget(tempban,duration $+ $chan $+ $2) / 60) minutes
msg $nick 05Reason:07 $hget(tempban,reason $+ $chan $+ $2)
}
}
on *:TEXT:!tbremove *:#: { if ($nick ishop $chan || $nick isop $chan) && ( $hget(tempban,$2 $+ $chan) != $null ) {
hdel -w tempban * $+ $2 $+ $chan
hdel -w tempban * $+ $chan $+ $2
msg $chan 07 $+ $2 05removed from automated tempban list for07 $chan 05(Requested by:07 $nick $+ 05).
}
}
On *:JOIN:#: { if ( $hget(tempban,$nick $+ $chan) == $null ) { /halt }
else {
inc %tbcount
ban -ku $+ $hget(tempban,duration $+ $chan $+ $nick) $chan $nick
msg $chan 05 $+ $nick has been banned from07 $chan 05for07 $calc($hget(tempban,duration $+ $chan $+ $nick) / 60) 05minutes by the autoban system.
msg $chan 05(Reason:07 $hget(tempban,reason $+ $chan $+ $nick) $+ 05) [07 $+ %tbcount 05 removed]
msg $nick 05You were added to the07 $chan 05ban list (Reason:07 $hget(tempban,reason $+ $chan $+ $nick) $+ 05)
msg $nick 05You will be unbanned from07 $chan 05in07 $calc($hget(tempban,duration $+ $chan $+ $nick) / 60) 05minutes.
hdel -w tempban * $+ $chan $+ $nick $+ *
hdel tempban $nick $+ $chan
}
}