Coders-IRC
IRC for Coders
Archive December 2021
ban script particular.
Allow Chars v1.0– description:
1.This script controls the use of only those characters in channel messages that are allowed and listed in the variable "%ach_characters". Otherwise, the user will receive "KiÑk+Ban".
2.In the alias "allowchars_set" you can remake all the settings for this script by changing the values of the variables:
%ach_work – configures the enable or disable of the script. The options are:
%ach_kick – configures whether to enable or disable execution "Kick" for the offender. The options are:
%ach_ban – configures whether to enable or disable execution "Ban" for the offender. The options are:
%ach_reason – configures the reason for the ban, which will be indicated in the kick message. (You can change this to your text).
%ach_btype – configures the type (format) of the ban for the offender. More details about the types of bans are described here:$mask. Default:<2>.
%ach_btime – contains the time (in seconds) for which a temporary ban will be set, and after which it will be automatically canceled on the channel. If you do not want to remove the ban, then set: <0>.
%ach_exceptpref – contains prefixes of symbols (channel operator status) for which there will be an exception and the script will not react to these users. Default:<[!~&@%+]>. (You can change this to other prefixes).
%ach_characters – contains all characters that are allowed for use in channel messages. (You can change or add to this set your national valid charactersUnicode andEmoji).
#####################################################################
# Name: Allow Chars v1.0
# Author: Epic (epicnet@mail.ru, http://epicnet.ru)
# Description: Allows to use in channel messages only those characters that are specified in the script.
#####################################################################
alias -l allowchars_set {
%ach_work = yes
%ach_kick = yes
%ach_ban = yes
%ach_reason = There are forbidden characters in your message!
%ach_btype = 2
%ach_btime = 3600
%ach_exceptpref = [!~&@%+]
%ach_characters = [abcdefghijklmnopqrstuvwxyz0123456789^`'"*#â„–@%$&(){}[]|\/<>:;!?+=-~,._]
}
on *:TEXT:*:#: allowchars $nick $chan $1-
on *:ACTION:*:#: allowchars $nick $chan $1-
alias -l allowchars {
allowchars_set | var %ach_pnick $remove($nick($2,$1).pnick,$1)
if (%ach_work == yes && %ach_pnick !isin %ach_exceptpref) {
var %text $remove($strip($3-),$chr(32))
if ($checkchars(%text) == false) allowchars_ban $1 $2
}
}
alias -l checkchars {
var %chars $remove(%ach_characters,$left(%ach_characters,1),$right(%ach_characters,1))
var %i 1 | while (%i <= $len($1)) { if ($mid($1,%i,1) !isin %chars) { return false | break } | inc %i } | return true
}
alias -l allowchars_ban {
if (%ach_kick == yes) {
if ($len(%ach_reason) > 1) var %ach_kr %ach_reason | else var %ach_kr -
.kick $2 $1 %ach_kr
}
if (%ach_ban == yes) {
if (!%ach_btype) %ach_btype = 2 | if (%ach_btime > 0) var %ach_key $+(-u,%ach_btime)
.ban %ach_key $2 $1 %ach_btype
}
}
menu nicklist
kickban identical nicks
on *:JOIN:#: {
;=== Are we some form of op or ircop?
if ($nick(#,$me,@&~%) || o isin $usermode) {
;=== Is the nickname that joined at least 5 characters?
if ($len($nick) >= 5) {
;=== Define variables for the pattern and get number of matches for pattern.
var %pattern = $+($mid($nick,1,5),?*!*@*) , %matches = $ialchan(%pattern,#,0)
;=== Do we have more than one match?
if (%matches > 1) {
;=== Define a variable to house our timer name, get its tokens if it exists already and append our pattern to it.
var %timer = $+(-clones-,$cid,-,#) , %tokens = $addtok($gettok($timer(%timer).com,2-,32),%pattern,32)
;=== (Re)set the timer to execute in 1/4 of a second (250 ms) to filter clones with our new pattern(s).
; THIS is an important step! if we don't delay, we could miss a few! say 3 join in succession, this will trigger on #2 (> 1)
; which will kick 1-2, which means next join trigger on #3 will only have 1 match because we already dealt with #1-2!
; by simply delaying a little bit we can nab rapid succession joins that match all in one go!
$+(timer,%timer) -m 1 250 FilterClones # %tokens
}
}
}
}
alias -l FilterClones {
var %chan = $1 , %patterns = $2- , %total = $numtok(%patterns,32)
;=== Are we still some form of op or ircop?
if ($nick(%chan,$me,@&~%) || o isin $usermode) {
;=== Iterate over our passed patterns
var %x = 0
while (%x < %total) {
inc %x
;=== Define variables for our pattern, and number of pattern matches
var %pattern = $gettok(%patterns,%x,32) , %matches = $ialchan(%pattern,%chan,0)
;=== Do we have more than one match?
if (%matches > 1) {
;=== clear out results/bans (potential leftover from last pattern) and iterate over our matches
var %y = 0 , %result = $null , %bans = $null
while (%y < %matches) {
inc %y
;=== Define variables for the address, nickname, and the nicknames idle time.
var %address = $ialchan(%pattern,%chan,%y) , %nick = $ialchan(%pattern,%chan,%y).nick , %idle = $nick(%chan,%nick).idle
;=== Is our matching nick NOT some form of access level or $me, and idle for <= 3 seconds? If so they either
; just joined, or spoken. Add to results/bans lists. NOTE: We probably don't want nicks that just spoken, but this is
; an unfortunate side-effect of this method that should be a rare case, they must match the pattern, and
; have spoken within the 3 sec timeframe of the join flood.
if (!$nick(%chan,%nick,$prefix) && %nick != $me && %idle <= 3) { var %result = $addtok(%result,%nick,44) , %bans = $addtok(%bans,$mask(%address,2),32) }
}
;=== Get the number of results
var %results = $numtok(%result,44)
;=== Do we have more than one nick left that met all of the above criteria?
if (%results > 1) {
;=== set mode +MR and ban the pattern
mode %chan +MRb %pattern
;=== set a timer to unlock modes "MR" in 5 seconds
$+(.timer,-unlock-,$cid,-,%chan) 1 5 mode %chan -MR
;=== Iterate bans by modespl and ban them
while ($gettok(%bans,$+(1-,$modespl),32)) {
mode %chan $+(+,$str(b,$numtok($v1,32))) $v1
var %bans = $gettok(%bans,$+($calc($modespl +1),-),32)
}
;=== Iterate nicks by TARGMAX-kick and kick them
var %FixMeFrom005 = $modespl
while ($gettok(%result,$+(1-,%FixMeFrom005),44)) {
kick %chan $v1 IDenticaL NICK(s)
var %result = $gettok(%result,$+($calc(%FixMeFrom005 +1),-),44)
}
}
}
}
}