#####################################################################
# Name: Allow Chars v1.2
# 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 {
if (!%ach_work) %ach_work = yes
if (!%ach_kick) %ach_kick = yes
if (!%ach_ban) %ach_ban = yes
if (!%ach_reason) %ach_reason = There are forbidden characters in your message!
if (!%ach_btype) %ach_btype = 2,3
if (!%ach_btime) %ach_btime = 3600
if (!%ach_exceptpref) %ach_exceptpref = [+%@&~!]
if (!%ach_exceptnick) %ach_exceptnick = Epic,krisb34213
if (!%ach_charfile) %ach_charfile = scripts\AllowСhars\allowchars.txt
}
menu menubar,status,channel {
Allow Chars
.Work
..$iif(%ach_work == yes,$style(1)) Enable: %ach_work = yes | .echo -a "Allow Chars" - Script:03 enabled.
..$iif(%ach_work == no,$style(1)) Disable: %ach_work = no | .echo -a "Allow Chars" - Script:04 disabled.
.Characters
..File $+([,$nopath(%ach_charfile),]): allowchars_set | if ($exists(%ach_charfile)) .run %ach_charfile
..Path $+([..\,$nopath(%ach_charfile),]): var %p $$?="Enter the full path to the file with allowed characters:" | if ($len(%p) > 0) { %ach_charfile = %p | .echo -a "Allow Chars" - The path to the file:03 %ach_charfile }
.Kick
..$iif(%ach_kick == yes,$style(1)) Enable: %ach_kick = yes | .echo -a "Allow Chars" - Kick:03 enabled.
..$iif(%ach_kick == no,$style(1)) Disable: %ach_kick = no | .echo -a "Allow Chars" - Kick:04 disabled.
..-
..Reason: var %r $$?="Enter the reason for the kick:" | if ($len(%r) > 0) { %ach_reason = %r | .echo -a "Allow Chars" - Kick reason:03 %ach_reason }
.Ban
..$iif(%ach_ban == yes,$style(1)) Enable: %ach_ban = yes | .echo -a "Allow Chars" - Ban:03 enabled.
..$iif(%ach_ban == no,$style(1)) Disable: %ach_ban = no | .echo -a "Allow Chars" - Ban:04 disabled.
..-
..Type $+([,%ach_btype,]): var %t $$?="Enter one or more types of bans separated by commas:" | if ($len(%t) > 0) { %ach_btype = %t | .echo -a "Allow Chars" - Ban type:03 %ach_btype }
..Time $+([,%ach_btime,]) sec: var %t $$?="Enter the number of seconds after which you want to remove the ban:" | if ($len(%t) > 0) { %ach_btime = %t | .echo -a "Allow Chars" - Ban time:03 %ach_btime }
.Except
..Prefixes %ach_exceptpref: var %p $$?="Enter the prefixes of the channel operators to exclude:" | if ($len(%p) > 0) { %ach_exceptpref = $+([,$remove(%p,]),]) | .echo -a "Allow Chars" - Except prefixes:03 %ach_exceptpref }
..Nicks $+([,$numtok(%ach_exceptnick,44),]): var %n $$?="Enter all users nicks separated by commas that you want to exclude:" | if ($len(%n) > 0) { %ach_exceptnick = %n | .echo -a "Allow Chars" - Except nicks:03 %ach_exceptnick }
}
on *:TEXT:*:#: allowchars $nick $chan $1-
on *:ACTION:*:#: allowchars $nick $chan $1-
alias -l allowchars {
allowchars_set | if (%ach_work == yes) {
var %ach_pnick $remove($nick($2,$1).pnick,$1)
if (%ach_pnick isin %ach_exceptpref) || ($istok(%ach_exceptnick,$1,44)) { halt }
if ($exists(%ach_charfile)) {
var %text $remove($3-,$chr(32),$chr(160),$chr(8194),$chr(8195),$chr(8196),$chr(8197),$chr(8198),$chr(8199),$chr(8201),$chr(8202),$chr(8203),$chr(8239),$chr(8287),$chr(12288),$chr(65279))
var %c 1 | while (%c <= $lines(%ach_charfile)) { %chars = $+(%chars,$read(%ach_charfile,n,%c)) | inc %c }
var %pattern $+(/[^,$replacecs(%chars,\,\\,[,\[,],\],-,\-,^,\^),]/iuS) | unset %chars
if ($regex(%text,%pattern) > 0) { allowchars_ban $1 $2 | .echo -st "Allow Chars" Violation detected - Channel05 $2 Nick:05 $1 Message: $+("04,$3-,") }
}
}
}
alias -l allowchars_ban {
if (%ach_ban == yes) {
if (!%ach_btype) %ach_btype = 2,3 | if (%ach_btime > 0) var %ach_key $+(-u,%ach_btime)
var %i 1 | while (%i <= $numtok(%ach_btype,44)) { .ban %ach_key $2 $1 $gettok(%ach_btype,%i,44) | inc %i }
}
if (%ach_kick == yes) { if ($len(%ach_reason) > 1) var %ach_kr %ach_reason | else var %ach_kr - | .kick $2 $1 %ach_kr }
}