The snippet is a ban script
You or operators in any channel you are op in can ban certain addresses
Unless the actual ban expires in less than 5 minutes, it unbans the person (like mode -b #channel) in 5 minutes. It stores all the bans in a hash table
When someone joins a channel, it checks then versus the bans on that channel. If a ban matchs, they are kicked, at the actual mask that was banned is banned...
That might not be too clear, Its hard to explain. Examples will help:
Other operators use:
!+ban ADDRESS TIME REASON
!-ban REASON
!baninfo ADDRESS
You use:
/+ban CHANNEL ADDRESS TIME REASON
/-ban CHANNEL ADDRESS
/baninfo ADDRESS
Address is in the form: NICKNAME!NAME@HOST
Time is in seconds
Reason can be anything
Channel must have a # before it
!+ban bear!@ 60000 Learn some manners
That bans the address "bear!@". That means it bans the nickname "bear" on the channel the operator typed it in.
Anyone on that channel matching that address (wildcards such as * and ? are applied) is kick/banned
!+ban !@*.IP 0 No IP addresses allowed in here
That would ban anyone with a .IP address. A 0 time ban never expires
/-ban #realmasks !@.IP
That is what you type to unban !@.IP from #realmasks
/+ban #bear ?!@ 0 Get a longer name please
That is what you type to ban all 1 character nicknames from #bear
It lasts forever (even though it does the actual mode -b in 5 minutes, everytime someone joins or changes their nick to a 1 character it will kick and ban them again)
This script can be useful for longterm bans, or for a network where you can have limited amounts of channel bans.
It can also be used to ban certain nicknames (Like Java???, Guest?????, people from a certain ISP, and one, two etc charater nicknames
The only downside is if you arent on the channel, the banned person/address can get on.
In action:
(bear_test) !+ban bear!@ 60 Learn some manners
(bear_test) !+ban bear!@ 600 Learn some manners
bear was kicked by bearruler (Banned by: bear_test because: Learn some manners. Expires in: 8mins 5secs)
Any questions, comments, concerns, suggestions, etc, email me at bearruler@gmail.com
Bear
on *:text:!+ban*:#: {
if ($me !isop $chan || $nick !isop $chan) halt
if (!$4 || $3 !isnum || $3 < 0) { .notice $nick Invalid ban format. !+ban ADDRESS TIME(Seconds) REASON -- For a Never ending ban, use 0 for Time. | halt }
if (*?!*?*@?* !iswm $2 || $count($2,!) > 1 || $count($2,@) > 1 || ** isin $2) {
.notice $nick Error, Invalid address. Use the format: *!*@* eg: !+ban bearruler!*@*.40E7B703.A8CC573C.IP 600 Learn some manners
halt
}
ban_c $2 $chan
if ($ban_($+($chan,.,$2))) { .notice $nick The address $2 is already banned | halt }
hadd ban $+($chan,.,$2) $iif($3 == 0,0,$calc($ctime + $int($3))) $nick $4-
.notice $nick The address $2 was added to # $+ 's ban list, expiring $iif($3 == 0,Never,in $duration($int($3))) $+ . Reason: $4-
ban_kba $2 $chan
}
on *:text:!-ban*:#: {
if ($me !isop $chan || $nick !isop $chan) halt
if (!$2) { .notice $nick Invalid unban format. !-ban ADDRESS | halt }
ban_c $2 $chan
if (!$ban_($+($chan,.,$2))) {
.notice $nick The address $2 is not banned
halt
}
hdel ban $+($chan,.,$2)
.notice $nick $2 was unbanned from #
mode # -b $2
}
alias +ban {
if (!$4 || $3 !isnum || $3 < 0) { echo -a - Ban - Invalid ban format. /+ban #CHANNEL ADDRESS TIME(Seconds) REASON -- For a Never ending ban, use 0 for Time. | halt }
if ($me !isop $1) halt
if (*?!*?*@?* !iswm $2 || $count($2,!) > 1 || $count($2,@) > 1 || ** isin $2) {
echo -a - Ban - Error, Invalid address. Use the format: *!*@* eg: /+ban #bearruler bearruler!*@*.40E7B703.A8CC573C.IP 600 Learn some manners
halt
}
ban_c $2 $1
if ($ban_($+($1,.,$2))) { echo -a - Ban - The address $2 is already banned | halt }
hadd ban $+($1,.,$2) $iif($3 == 0,0,$calc($ctime + $int($3))) $me $4-
echo -a - Ban - The address $2 was added to $1 $+ 's ban list, expiring $iif($3 == 0,Never,in $duration($int($3))) $+ . Reason: $4-
ban_kba $2 $1
}
alias -ban {
if (!$2) { echo -a - Ban - Invalid unban format. /-ban #CHANNEL ADDRESS | halt }
if ($me !isop $1) halt
ban_c $2 $1
if (!$ban_($+($1,.,$2))) {
echo -a - Ban - The address $2 is not banned
halt
}
hdel ban $+($1,.,$2)
echo -a - Ban - $2 was unbanned from #
mode $1 -b $2
}
on *:text:!baninfo*:#: {
if ($me !isop # || $nick !isop #) halt
if (!$2) { .notice $nick Format: !baninfo ADDRESS (in form *!*@*) | halt }
ban_c $2 $chan
if (!$ban_($+($chan,.,$2))) .notice $nick No information on the ban of $2 on #
else .notice $nick $+ $2 was banned by $ban_b($+($chan,.,$2)) for the reason $ban_r($+($chan,.,$2)) $+ . It expires $iif($ban_t($+($chan,.,$2)) == 0,: Never,in: $duration($calc($v1 - $ctime)))
}
alias baninfo {
if ($me !isop $1) halt
if (!$2) { echo -a - Ban - Format: /baninfo #CHANNEL ADDRESS (in form *!*@*) | halt }
ban_c $2 $1
if (!$ban_($+($chan,.,$2))) echo -a - Ban - No information on the ban of $2 on $1
else echo -a - Ban - $nick $+ $2 was banned by $ban_b($+($1,.,$2)) for the reason $ban_r($+($1,.,$2)) $+ . It expires $iif($ban_t($+($1,.,$2)) == 0,: Never,in: $duration($calc($v1 - $ctime)))
}
alias ban_rem {
hdel ban $2 $+ . $+ $1
ban -r $2 $1
}
alias ban_ return $hget(ban,$1-)
alias ban_t return $gettok($hget(ban,$1-),1,32)
alias ban_b return $gettok($hget(ban,$1-),2,32)
alias ban_r return $gettok($hget(ban,$1-),3-,32)
alias ban_c if ($ctime > $ban_t($+($2,.,$1)) && $v2 != 0) ban_rem $1 $2
on *:start: {
hmake ban 500
if ($isfile(ban.hsh)) hload ban ban.hsh
.timer 0 600 hsave ban ban.hsh
}
on *:exit: hsave ban ban.hsh
on *:join:#: {
if ($me !isop $chan) halt
updatenl
var %a = 1,%c
while $hget(ban,%a).item {
%c = $v1
if ($gettok(%c,1,46) == $chan && $gettok(%c,2-,46) iswm $address($nick,5)) {
ban_kba $gettok(%c,2-,46) $chan
halt
}
inc %a
}
}
on *:nick: {
var %a = 1,%c = 0
while $comchan($newnick,%a) {
if ($comchan($newnick,%a).op) %c = 1
inc %a
}
if (%c = 0) halt
updatenl
%a = 1
while $hget(ban,%a).item {
%c = $v1
if ($newnick ison $gettok(%c,1,46) && $gettok(%c,2-,46) iswm $address($newnick,5)) {
ban_kba $gettok(%c,2-,46) $gettok(%c,1,46)
halt
}
inc %a
}
}
alias ban_kba {
ban_c $1 $2
if (!$ban_t($+($2,.,$1)) && $v1 != 0) halt
ban -u $+ $iif($ban_t($+($2,.,$1)) == 0 || $calc($v1 - $ctime) > 300,300,$v1) $2 $1
var %a = 1
while $ialchan($1,$2,%a).nick {
kick $2 $v1 Banned by: $ban_b($+($2,.,$1)) because: $ban_r($+($2,.,$1)) $+ . Expires $iif($ban_t($+($2,.,$1)) == 0, $+ : Never,in: $duration($calc($v1 - $ctime)))
inc %a
}
}
I like the script but i wish i could modify it to ban in all channels im in, also would be nice if remote users could ban with a shorter command with just the nick like: !+b nick reason
I guess that would involve default settings with ban types, and having default time setting as 0=never ending - so unless specified the script will default ban in all channels with type 2 bans never ending.
I hope this makes sense, if anyone can modify the script for me like this let me know. I would liek to use it for a bot in a room with newbie ops and i need it very simple for them to quickly add bans.