|
Joined: Sep 2021
Posts: 7
Nutrimatic drinks dispenser
|
OP
Nutrimatic drinks dispenser
Joined: Sep 2021
Posts: 7 |
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?
|
|
|
|
Joined: Jan 2012
Posts: 321
Pan-dimensional mouse
|
Pan-dimensional mouse
Joined: Jan 2012
Posts: 321 |
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: โโโโ โ 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":
#####################################################################
# 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.
|
|
|
|
Joined: Jan 2004
Posts: 2,127
Hoopy frood
|
Hoopy frood
Joined: Jan 2004
Posts: 2,127 |
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/regexThe 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.
|
|
|
|
Joined: Jan 2012
Posts: 321
Pan-dimensional mouse
|
Pan-dimensional mouse
Joined: Jan 2012
Posts: 321 |
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.
|
|
|
|
Joined: Jan 2004
Posts: 2,127
Hoopy frood
|
Hoopy frood
Joined: Jan 2004
Posts: 2,127 |
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)
|
|
|
|
Joined: Jan 2012
Posts: 321
Pan-dimensional mouse
|
Pan-dimensional mouse
Joined: Jan 2012
Posts: 321 |
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":
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":
#####################################################################
# 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.
|
|
|
|
Joined: Sep 2021
Posts: 7
Nutrimatic drinks dispenser
|
OP
Nutrimatic drinks dispenser
Joined: Sep 2021
Posts: 7 |
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 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 So, see you next time, thanks again for everything! : D
|
|
|
|
Joined: Jan 2012
Posts: 321
Pan-dimensional mouse
|
Pan-dimensional mouse
Joined: Jan 2012
Posts: 321 |
At your request in personal correspondence, several new changes and improvements were made to the script code. Please tested the script before using it. Allow Chars v1.2 โ updates:โโ 1.Now when you select the "Enable" or "Disable" item in the menu, a checkmark will be set on the left, indicating which item is currently selected. โโ 2.Now when viewing menu items, the values of the configured parameters will be displayed next to the right in square brackets. โโ 3.Now after each detected violation, an echo message with the name of the channel, user nick and the message for which he was banned will be displayed in the status window. โโ 4.Now together with the space, all invisible characters (similar to space) will also be removed from the message (for ignored) when checking for valid characters. See all: Here (There is no need to list them in the file). โโ 5.In the menu in the "Except" item, a new sub-item "Nicks" has been added so that you can specify a comma-separated list of nicknames for to exclude from checking. Default variable: %ach_exceptnick = Epic,krisb34213Screenshot for demo operability of the script's: โโ 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":
#####################################################################
# 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 }
}
Remember that if something went wrong, or you accidentally erased something, then you can always reinstall this script again.
|
|
|
|
Joined: Sep 2021
Posts: 7
Nutrimatic drinks dispenser
|
OP
Nutrimatic drinks dispenser
Joined: Sep 2021
Posts: 7 |
Point 4 of the new update is fundamental.
There seemed to be apparently some meaningless bans in messages that looked okay, instead they were those special characters equal to simple spaces ... And it's a big mess if you don't know that those special characters exist .-.
Also great are the rest of the changes that make the script much better to use!
|
|
|
|
|