The text in chat, PM, search requests and users descriptoions are checking by antiadvertising function by patterns in the adver table. If function finding in the text accordance to the adver templates, if this text don't accordance to the templates-exceptions, the text is not passed or user is baned with ban depending on the mode of antiadvertising. Also possible to activate the users descriptions check. Totally there are 4 antiadvertising modes:
The tables with adver templates stores in the files adverTable, adverTableChatOnly, adverTablePMOnly, adverTableDescOnly, adverTableSROnly.
To add the adver pattern (usual text or LUA-regex) possible by command !advertising+ <type> <pattern>. It is common pattern for all events. To add the adver pattern for chat only possible by command !advertising_chat+ <type> <pattern>. To add the adver pattern for PM only possible by command !advertising_pm+ <type> <pattern>. To add the adver pattern for desc only possible by command !advertising_desc+ <type> <pattern>. To add the adver pattern for search only possible by command !advertising_sr+ <type> <pattern>. To delete the adver pattern from list possible by command !advertising- <index>. To delete the adver pattern from the chat only list possible by command !advertising_chat- <index>. To delete the adver pattern from the PM only list possible by command !advertising_pm- <index>. To delete the adver pattern from the desc only list possible by command !advertising_desc- <index>. To delete the adver pattern from the search only list possible by command !advertising_sr- <index>. To get the adver pattern list possible by command !advertising. Enable/disable scanning of chat, PM, descriptions and search by commands !adver_chatscan, !adver_pmscan, !adver_dscscan and !adver_srscan.
At template addition You must shose the pattern type: 0 - usual text (uncased), 1 - LUA-regex.
For example, we want forbid the hub's advertising dchub://badhub.hub. We can add the string dchub://badhub.hub like adver pattern type 0. If anyone write this text, for example, in the mainchat, the antiadver function cutting this message. BUT! But if we want forbid all possible hub's addresses exept own's hub? It is impossible to add in the adver patterns all possible addresses like usual text. For this purpose You can use very powerful tool: pattern type 1 (LUA-regexes). I will tell shortly about the basic possibilities (more details in the LUA language description):
. (a dot) represents all characters;
%S represents all non-space characters;
%s represents all space characters (blank, tabulation, carret return, line left, etc.): \t \n \v \f \r <space>;
%d represents all digits (from 0 to 9);
%w represents all alphanumeric characters;
%a represents all letters: ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz;
%c represents all control characters: \0 \1 \2 \3 \4 \5 \6 \a \b \t \n \v \f \r \14 \15 \16 \17 \18 \19 \20 \21 \22 \23 \24 \25 \26 \27 \28 \29 \30 \31 ;
%l and %u represents all lowercase and uppercase letters;
%p represents all punctuation characters: !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~;
%x represents all hexadecimal digits: 0123456789ABCDEFabcdef;
%z represents zeroed character: \0;
Symbols ^$()%.[]*+-? are magic characters:
^ and $ at the beginning and end of a pattern anchors the match at the beginning and end of the subject string;
[ and ] represents the class which is the union of all characters in set. A range of characters may be specified by separating the end characters of the range with a '-'. All classes %x described above may also be used as components in set. All other characters in set represent themselves. For example, [%w_] (or [_%w]) represents all alphanumeric characters plus the underscore, [0-7] represents the octal digits, and [0-7%l%-] represents the octal digits plus the lowercase letters plus the '-' character. The interaction between ranges and classes is not defined. Therefore, patterns like [%a-z] or [a-%%] have no meaning;
( and ) represents the captures (sub-patterns enclosed in parentheses). When a match succeeds, the substrings of the subject string that match captures are stored (captured) for future use. Captures are numbered according to their left parentheses. For instance, in the pattern "(a*(.)%w(%s*))", the part of the string matching "a*(.)%w(%s*)" is stored as the first capture (and therefore has number 1); the character matching "." is captured with number 2, and the part matching "%s*" has number 3;
* a single character class followed by '*', which matches 0 or more repetitions of characters in the class. These repetition items will always match the longest possible sequence. For example, the pattern %d* represents 0 or more digits;
+ a single character class followed by '+', which matches 1 or more repetitions of characters in the class. These repetition items will always match the longest possible sequence. For example, the pattern %S+ represents 1 or more non-space letters;
- a single character class followed by '-', which also matches 0 or more repetitions of characters in the class. Unlike '*', these repetition items will always match the shortest possible sequence;
? a single character class followed by '?', which matches 0 or 1 occurrence of a character in the class. For example, the pattern %s? represents 0 or 1 space letter.
For represent in the pattern the magic letter use escape symbol %. For example, for set in pattern the letter "." (the dot), You can write %., else pattern . will represent all characters, not only dot). For example, to set the IP-address pattern possible write: %d+%.%d+%.%d+%.%d+. Here %d+ represent 1 or more digits and %. represent the dot. To set the symbol "%" possible write pattern like %%.
All other characters (witch not one of the magic characters ^$()%.[]*+-?) represents the character itself.
Let's give an example how to set adver template for any address of hub. For this purpose it is enough to add adver template type 1:
dchub://%S+
Here pattern %S+ mean what after the text "dchub://" present 1 or more non-space letters. That the antiadvertising did not react on the own's hub address, let's add the address of our hub in the list of adver exceptions (also supported usual text and LUA-regexes).
By command !adver_banmode <mode> possible to set the chat antiadvertising mode (from 0 to 3). By command !adver_pmbanmode <mode> possible to set the PM antiadvertising mode (from 0 to 3). By command !adver_dscbanmode <mode> possible to set the user's description antiadvertising mode (from 0 to 3). By command !adver_srbanmode <mode> possible to set the serching requests antiadvertising mode (from 0 to 3). By command !adver_bantime <mode> sets the ban time in minutes for the antiadvertising mode 2.
Enable/disable the Chat scan for adver by command !adver_chatscan. Enable/disable the PM scan for adver by command !adver_pmscan. Enable/disable the descriptions scan for adver by command !adver_dscscan. Enable/disable the search scan for adver by command !adver_srscan.
Possible to add the adver exceptions. At finding of this template the antiadvertising will not react. To add pattern in exceptions possible by command !advertising_exceptions+ <type> <pattern> (type 0 - usual text, 1 - LUA-regex). To delete pattern from exceptions possible by command !advertising_exceptions- <pattern>. To get the list of exceptions possible by command !advertising_exceptions.
Enable/disable the ban notices by command !adver_notices.
To check up the plugins reaction on some text possible by command !adver_check <text>.
It is also possible to set for anti-advertisement template with the selected index class of users, above which (including) this template is not checked, by command !adver_setclass <index> <class>.To set the unchecked class for the chat only pattern possible by command !adver_setclasschat <index> <class>. To set the unchecked class for the PM only pattern possible by command !adver_setclasspm <index> <class>. To set the unchecked class for the desc only pattern possible by command !adver_setclassdesc <index> <class>. To set the unchecked class for the search only pattern possible by command !adver_setclasssr <index> <class>. If the class is not specified, the value for the specified index is cleared.
You can add simple text templates anti-advertisement for a chat, PM, search, and descriptions in the files adverTableChat.txt, adverTablePM.txt, adverTableSR.txt and adverTableDesc.txt respectively in the plugin directory. These templates are loaded when you start the plugin and placed by one pattern per line.
In the language localization files of plugin Text_lang.lua placed the text that will receive the user and the operators of the Hub in the case of anti-advertisement. The file Vars.lua constant adverBanType, which specifies the type of function for the ban (0 - a ban on nick, 1 - a complete ban). In some locales, these types are equal.