At your request in personal correspondence made several changes and improvements in the script. Please tested the script before using it.

Allow Chars v1.1 – updates:

  1.Now instead of setting through an alias "allowchars_set" you can customize the script through the channel Menu or the bar Menu, by right-clicking. (All missing variables will be set by default).
  2.Now messages will be checked through regular expressions, instead of loops (while), which in the past could lead to a slowdown in the script with a large number of messages. (Thanks "maroon").
  3.Now in the variable "%ach_btype" you can specify several values of the ban type at once separated by commas (to install several bans at once on the intruder) or leave only one number. Default: <2,3>.
  4.Now instead of the variable "%ach_characters" will be used the variable "%ach_charfile" to specify the full path to the text file, where you can write all the characters allowed. (Within reasonable limits).


An example of how can be filled the file "allowchars.txt" which was specified in the variable "%ach_charfile":
Code
abcdefghijklmnopqrstuvwxyz
абвгдеёжзийклмнопрстуфхцчшщъыьэюя
0123456789^`'"*#№@%$&(){}[]|\/<>:;!?+=-~,._
😀😉😁😆😅😂🤣😊🙂😄🙃😇😃😚🥰😙☺😍😗🥲😘🤩😋😛😜🤪😝🤑🤔🤭🤗🤫😐😶😶😬😏😑😒🙄🤐🤥😌😔😪😴🤤🥶🤧
😷🤯🥴😵🤒🥵🤮🤕🤢🥸🤠🥳🤓😎🧐😕😖😧🥺😫😱😞😯😮😭😟😓😩😢😲😨🥱😳🙁😥😣😦☹😰☠😤😈😡💀👿🤬😠
💩🤡🤖👽👾👻👺👹🙀😽😸😿😾😻😺😼😹🙉🙊🙈


Click on the button to reveal the spoiler. This code must be inserted into the scripts editor. To do this, press the key combination "ALT+R" and replace with this code the old code, then save it under the name "AllowChars.mrc":

Code
#####################################################################
#   Name: Allow Chars v1.1
#   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 = 30
  if (!%ach_exceptpref) %ach_exceptpref = [+%@&~!]
  if (!%ach_charfile) %ach_charfile = scripts\AllowСhars\allowchars.txt
}
menu menubar,status,channel {
  Allow Chars
  .Work
  ..Enable: %ach_work = yes | .echo -a "Allow Chars" - Script:03 enabled.
  ..Disable: %ach_work = no | .echo -a "Allow Chars" - Script:04 disabled.
  .Characters
  ..File: allowchars_set | .run %ach_charfile
  ..Path: 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
  ..Enable: %ach_kick = yes | .echo -a "Allow Chars" - Kick:03 enabled.
  ..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
  ..Enable: %ach_ban = yes | .echo -a "Allow Chars" - Ban:03 enabled.
  ..Disable: %ach_ban = no | .echo -a "Allow Chars" - Ban:04 disabled.
  ..-
  ..Type: 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: 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: var %p $$?="Enter the prefixes of the channel operators to exclude:" | if ($len(%p) > 0) { %ach_exceptpref = $+([,$remove(%p,]),]) | .echo -a "Allow Chars" - Except prefix:03 %ach_exceptpref }
}
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($3-,$chr(32))
    if ($exists(%ach_charfile)) {
      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
    }
  }
}
alias -l allowchars_ban {
  if (%ach_ban == yes) {
    if (!%ach_btype) %ach_btype = 2 | 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
  }
}


Remember that if something went wrong, or you accidentally erased something, then you can always reinstall this script again.
If you find any errors in the code and in its work, or maybe you have new ideas or if you think that this script needs to be improved, then be sure to write to me here about it, and we are together think about what we can do.


🅸🆁🅲 - 𝔦'𝔱𝔰 𝔸 𝕂𝖎ɴ𝙙 ᴏ𝙛 𝕄𝙖𝖌𝙞𝙘