mIRC Home    About    Download    Register    News    Help

Print Thread
Request ban script particular... #269476 12/10/21 01:44 PM
Joined: Sep 2021
Posts: 4
K
krisb34213 Online OP
Self-satisfied door
OP Online
Self-satisfied door
K
Joined: Sep 2021
Posts: 4
Hi, I don't know if it is possible to create this type of script but I will try to explain anyway.

A lot of people on the channel where I am evade bans on forbidden words using special characters and things like that.

For example, there are people who spam their contacts (let's take the telegram contact for example) by saying they offer paid photos and videos and then scam those who believe in them.

If I block the word "telegram", then they use special characters to write it and avoid the ban, for example by using ๐“ฃ๐“ฎ๐“ต๐“ฎ๐“ฐ๐“ป๐“ช๐“ถ.

I would like to cut off the head of the bull and know if it is possible to create a script (with the ability to activate and deactivate it) that will ban any message that does not contain the characters entered in the script.

So, something like this: a script that contains the normal letters of the alphabet, the exlamation and question mark and the numbers (with the possibility to add and remove what you want) and which then ban any message in the channel (/say and /me also) that contains anything else: emoticons, special characters, and so on. All. Anything that is not in the script. So you can only write messages with the characters contained in the script.

Would it be possible to create such a script?

Re: Request ban script particular... [Re: krisb34213] #269521 23/10/21 12:30 PM
Joined: Jan 2012
Posts: 174
Epic Offline
Vogon poet
Offline
Vogon poet
Joined: Jan 2012
Posts: 174
You can try using the script I created especially for you.

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: <yes|no>.
โ€‡โ€‡โ€‡โ€‡โ€‡โ€‡%ach_kick โ€“ configures whether to enable or disable execution "Kick" for the offender. The options are: <yes|no>.
โ€‡โ€‡โ€‡โ€‡โ€‡โ€‡%ach_ban โ€“ configures whether to enable or disable execution "Ban" for the offender. The options are: <yes|no>.
โ€‡โ€‡โ€‡โ€‡โ€‡โ€‡%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 characters Unicode and Emoji).

Screenshot for demo operability of the script's:

โ€‡โ€‡โ€‡โ€‡ โ€‡[Linked Image from i.ibb.co]

The script was tested on InspIRCD v3 + mIRC v7.67.

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 save this code as new "File/New" script called "AllowChars.mrc":

Code
#####################################################################
#   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
  }
}


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.



๐Ÿ…ธ๐Ÿ†๐Ÿ…ฒ - ๐”ฆ'๐”ฑ๐”ฐ ๐”ธ ๐•‚๐–Žษด๐™™ แด๐™› ๐•„๐™–๐–Œ๐™ž๐™˜
Re: Request ban script particular... [Re: Epic] #269525 24/10/21 01:32 AM
Joined: Jan 2004
Posts: 1,620
maroon Offline
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 1,620
Your script will be somewhat slower than it needs to be. It's doing a scripted comparison of the message against the list of allowed characters. It would be much faster to let that comparison loop happen inside the $regex identifier.

https://en.wikichip.org/wiki/mirc/regex

The simplest verify against the allowed list would look something like:

//echo -a $regex(string,/[^abcdef]/u)

This looks at the string and checks to see if it can find a character that is NOT on the list. As soon as it does, $regex returns '1' indicating the number it found. If you're interested in how many bad characters there are, you can change the /u to /ug and it will return the number of matches instead of 1. But this will take slightly longer since it doesn't return as soon as it finds something not on the list.

With this method, you can also avoid the $remove of the spaces by simply having spaces be as part of your list.

If you want to allow color/control codes without needing to put them into %allowed you can add the "S" flag by changing /u to /uS. The /u identifier is not needed until you start putting codepoints outside the normal 7-bit text range, but it's harmless to leave it there. Without the /u flag, if it encounters a codepoint above 127, it instead sees the individual bytes making up the UTF8 encoding, instead of seeing the codepoint character.

Inside the [list] you need to make sure that any chars with special meaning have been 'escaped' by preceding them with a \backslash. For example, if you have a hyphen in the list that's not in the first/last position, it behaves like a range, so [^a-z] means the range 'a' THROUGH 'z' not the 2 letters and the hyphen. The ^ as the 1st character means 'not the following characters, but anywhere else it means the literal carat.

So, just to be safe, you should preced these characters with a backslash: []-^\

Just to be clear, there are other characters having special meaning in other places in a regex pattern, but not inside the [list].

//var %string foo bar , %allowed !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ | var -s %pattern $+( /[^, $replacecs(%allowed,\,\\,[,\[,],\],-,\-,^,\^) ,]/u) | echo -a $regex(%string,%pattern)

Note how this example returns a '1' because the string contains a space which I didn't put in the list. But as soon as you add the space anywhere inside the %allowed list, then it reports 0 (zero characters not in the list).

If you change it so you do not $replacex "-" with "\-" then you can have the variable be much shorter, because you can have ranges defined by the characters sandwiching the hyphen. Instead of listing the entire alphabet, you can just have A-Z. If you want to avoid listing the A-Z a-z alphabet twice, you can add the 'i' flag, changing /u to /ui. The /i flag seems to only see case-insensitive within the A-Z and a-z ranges, and not among the accented characters above codepoint 127.

While only those 5 characters have special meaning in a regex [list], there are other characters that you'll have trouble with if you try to use them literally inside the $regex() identifier. But only because they have special meaning to mIRC, such as commas, parenthesis, dollars, etc. But by parking them in a %variable like you did, that also avoids a lot of problems.

Re: Request ban script particular... [Re: maroon] #269528 24/10/21 02:07 PM
Joined: Jan 2012
Posts: 174
Epic Offline
Vogon poet
Offline
Vogon poet
Joined: Jan 2012
Posts: 174
Actually, I originally wanted to use regular expressions to check when creating such a script, but faced the difficulty of building a regex and the confusion of implementing this idea. In addition, provided that for some special characters it is necessary to use escaping these characters with a backslash "\" and also follow some other regex rules, this can cause difficulties and questions for most users when editing and configuring the script. It is also likely that some users, for some reason, may need to use only a certain limited set of characters, maybe not even the entire English alphabet (or mixed with other national characters) and also possibly not with all numbers, etc. Therefore, I decided to do it easier, to the detriment of efficiency, but with the ability to manually enumerate all the necessary symbols to resolve them in messages.

Nevertheless, I will try to figure it out with this, to would improve the script and make it more efficient, taking into account your useful advice and recommendations.

Thanks to you for the sufficiently meaningful capacious post and a detailed explanation of how to use $regex. Undoubtedly, this information will be useful both to me and to many other scripters.


๐Ÿ…ธ๐Ÿ†๐Ÿ…ฒ - ๐”ฆ'๐”ฑ๐”ฐ ๐”ธ ๐•‚๐–Žษด๐™™ แด๐™› ๐•„๐™–๐–Œ๐™ž๐™˜
Re: Request ban script particular... [Re: Epic] #269530 24/10/21 09:14 PM
Joined: Jan 2004
Posts: 1,620
maroon Offline
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 1,620
If you're certain the script is not going to forbid any of the normal 7-bit text characters, you can use a much simpler range regex that avoids all the issues of escaping those 5 special characters.

/[^\x20-\x7e]/uS

The above regex pattern looks for anything that's not in the $chr(20) through $chr(126) range where the space and the 95 7-bit text characters exist. If you want to include additional accented characters above codepoint 126, you can include them literally inside the [^list] Since this range includes the A-Z and a-z, there's no need for a case-insensitive /i flag.

That makes the regex much simpler, and the /S flag there is if you're wanting to allow colors/bold/etc. Instead of listing the literal accented letters, they can be listed in the \xformat, however if the codepoint is above 255 it needs to be wrapped inside {brackets}. i.e. \x31 is the number '1', but codepoint 10004 is \x{2714}
If you want to put allowed emojis on the list, you can either put the literal emoji symbol into the %allowed list, or include something like the black cat emoji at codepoint 128049 is \x{1f431}

if you change the above regex pattern to have parenthesis around it, you can retrieve the offending symbol.

/([^\x20-\x7e])/uS

This will put the 1st encountered not-allowed character into $regml(1)

Re: Request ban script particular... [Re: krisb34213] #269542 26/10/21 09:00 PM
Joined: Jan 2012
Posts: 174
Epic Offline
Vogon poet
Offline
Vogon poet
Joined: Jan 2012
Posts: 174
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.


๐Ÿ…ธ๐Ÿ†๐Ÿ…ฒ - ๐”ฆ'๐”ฑ๐”ฐ ๐”ธ ๐•‚๐–Žษด๐™™ แด๐™› ๐•„๐™–๐–Œ๐™ž๐™˜
Re: Request ban script particular... [Re: krisb34213] #269546 8 hours ago
Joined: Sep 2021
Posts: 4
K
krisb34213 Online OP
Self-satisfied door
OP Online
Self-satisfied door
K
Joined: Sep 2021
Posts: 4
As Epic also wrote while working on the script I was in contact with him to try to create the best version of the script.

A perfect job came out of it smile

Thank you so much for your availability and expertise, Epic!

Being on a net that, at least at the moment, does not have many settings to counter this kind of messages, spam and such, this script in combination with badwords and badnicks will surely be useful for me to clean up the channel a bit!
Maybe it will be useful to other users too smile

So, see you next time, thanks again for everything! : D