Triggers, Bot-triggers, PM-triggers, Robots, AntiCapslock

Plugin: Triggery i anticapslok.Triggers and anticapslock

This is, perhaps, most interesting plugin. Triggers react to the text in chat or PM and have wide assortment of reactions. By means of triggers it is possible to create simple reactions of bot to the text in chat and PM with the answer, To form teams with various functions up to reception and formatting of web-pages from the Internet, record of files and many other things. Event (text) on which there should be reaction, is set with short patterns system. To check the parsing of  short template results it is possible by command !checkpattern <short pattern>.

Triggers

Triggers seens events in the main chat on conformity to available templates of triggers. If the template does not represent a command the triggers core does not react to users in exceptions. At first the new trigger is created by command !addtriggers <short_pattern>. Then for the task of any reaction for this event it is necessary to add the answer (or answers) in this trigger with desirable index. It becomes by command !addanswers <index> <answer>. If it is some answers, one of them in random way gets out. The answer can be in the line. The answer text will be sent in chat on behalf of the Bot. At the text there can be special inserts which represent instructions for this or that action. After processing special inserts are cut out from the answer. If after processing of all special inserts of plain text it will not be found, reaction on behalf of the Bot will not be (except the actions set in instructions flags). Here the list of possible flags:

{class:min_class[-max_class]:answer} - sets the minimum class of the user for operation, differently the processing termination (the instructions of the maximum class through hyphen are possible). If the class of the user, on which given trigger with this answer has worked, more low (or does not enter into the specified range) the user will receive the answer specified in a flag and processing of the trigger will break.

{ifclass:min_class[-max_class]} - it is similar to the previous flag {class}, only in case of default of condition event does not interrupt. No reaction will exist.

{user:nick1[$nick2]} - sets the users nicks list for operation, differently there is no reaction (nicks are divided by symbol $). It is possible to specify nick directly or variable.

{usernot:nick1[$nick2]} – flag with opposite to the previous flag {user} reaction.

{if:var:value} - sets condition for operation, differently there is no reaction. Checks, whether there corresponds value value to value of variable var. Value can be both the text, and variable with value.

{ifnot:var:value} - flag with opposite to the previous flag {if} reaction. Will work, if value value is not equal to value of variable var.

{var:Var_name1="Value_pattern1" [Var_name2="Value_pattern2"]} - sets names of variables and their value for use further in answers: [var_name]. Thus the name of the variable set by this flag, at use in the answer in square brackets will be replaced with its value. The template is made by rules LUA-regex.

{gvar:var:value} - sets a global variable with name var and value value. The global variable is stored in memory and is accessible at the subsequent references.

{delvar:var1[$var2]} - deletes global variables (it is possible to specify some variables, dividing names with symbol $).

{repl:Replace_pattern1="Replace_value1" [Replace_pattern2="Replace_value2"]} - sets templates of replacements for use in answers. Thus it is possible to replace the initial text on templates with the replacements specified in parametres. templates of replacements are made by rules LUA-regex. The captures transferred in answers are possible.

{srepl:text1="replace1" [text2="replace2"]} - sets text replacements for use in answers, without use of templates of regular expressions, as in the previous flag {repl}.

{rev:Reverce_pattern1 [Reverce_pattern2]} - sets templates of sites which will be turned (reverced). Captures use is possible.

{rand:var:d1:d2} - will appropriate variable var random number in an interval from d1 to d2 which can be integers or the variables which values are integers.

{math:var:action:elem1:elem2} - will appropriate variable var result of action action over elements elem1 and elem2. Action can be:

+ addition;
- subtraction;
^ exponentiation;
* multiplication;
/ division;
\ integer division with rounding downwards;
% integer division with rounding upwards;
> or < will set to variable the value 1 if the inequality is true, else 0.
Elements elem1 and elem2 can be both numbers, and numerical variables.

{chat:text} - will send the text in the general chat as is. Using variables is possible.

{mode:type:text} - will send the text in chat to all users with connection mode type (A,P,S). Using variables is possible.

{profile:class:text} - will send the text in chat to all users with the specified class. Using variables is possible.

{touser:nick1[$nick2…$nickN]:text} - will send the text in the general to the specified user. Probably to specify several nicks, divided by symbol $. Using variables is possible.

{pm:text} - will send the text in PM to the user on behalf of the Bot on which has worked the trigger. Using variables is possible.

{pmto:nick1[$nick2…$nickN]:from:text} - will send the text in PM to the specified user from name from. Probably to specify several nicks, divided by symbol $. Using variables is possible.

{pmall:text} - will send the text in PM to all users on behalf of bot. Using variables is possible.

{pmmode:type:from:text} - will send the text from name from in PM to all users with connection mode type (A,P,S). Using variables is possible.

{pmprofile:class:from:text} - will send the text from name from in PM to all users with the specified class. Using variables is possible.

{flood:count:text} - will send the text in PM to the user on whom has worked the trigger, the specified number of times. Using variables is possible.

{flooduser:nick:count:text} - will send the text in PM to the specified user the specified number of times. Using variables is possible.

{file:filename} - will send the text from file by the way filename (the full way) in PM specifies to the user on whom has worked trigger (name of file without expansion in file in directory txt). Using variables is possible.

{varfile:var:filename} - will place file contents on the way filename (full way) in variable var (the rest by rules of flag {file}).

{url:address,GZip,CodePage,Proxy"main_pattern"inner_pattern"answer} - receives the text of page with the specified URL-address. Thus use can be specified GZip (1 or 0), codepage (for PtokaX the coding which is available in the table of local codings should be specified) and proxy address (these parametres can be passed, but commas are obligatory). The received text passes on all basic templates, allocating in them template of the answer and returning the answer. The answer template can contain captures (captures) which come back in the answer.

{varurl:var:address,GZip,CodePage,Proxy"main_pattern"inner_pattern"answer} - it is similar to flag {url}, but the result brings in variable var.

{curl:codepage} - establishes the coding for transformation of the url-address of flags {url} and {varurl}. If the local table of codings the available coding should be specified is used.

{ban:minutes:reason} - ban the user on whom has worked the trigger, on the specified number of minutes with the specified reason. Using variables is possible.

{tofile:write_mode:filename$text} - text record text in file with name filename (are divided by symbol $). Write modes:
w - mode of record with contents replacement, a - mode writing in the file end. Use of variables is possible.

{wait} - flag for delay of reaction to time before the nearest operation of the timer of script (the period of the timer of 60 seconds).

{exit} - makes the immediate termination of procedure of the further processing.

Keep in mind that in the answer text probably to apply the reserved inserts: [curUser], [BotName], [hub], [time], [date], [topic], [revUser], [ip], which are replaced accordingly on nick the current user, the Bot name, the Hub name, time, the date, flowing topic, reverces nick and IP of the current user.

To remove the trigger with the chosen index it is possible by command !deltriggers <index>. For triggers it is necessary to mean that the trigger with an index 1 is reserved under system of anticapslock and to change of template or removal is not subject. To remove the answer with the chosen index from the trigger with the chosen index it is possible by command !delanswers <trigger_index> <answer_index>. On/off system of triggers it is possible by command !istriggers. To look the list of triggers it is possible by command !seetriggers. To look in detail trigger with the chosen index and its answers it is possible by command !seetriggeranswers <index>.

It is possible to group triggers in groups for convenience. To place the trigger with the chosen index in group with the chosen name it is possible by command !triggersaddgroup <index> <groupname>. To clean the chosen trigger from group in which it is at the moment, it is possible by command !triggersdelgroup <index>. To remove the chosen group together with triggers it is possible by command !triggersremgroup <groupname>. To rename group with the chosen name it is possible by command !triggersrengroup <groupname>$<newgroupname>. To disband group with the chosen name it is possible by command !triggersclsgroup <groupname>. To look structure of group with the chosen name it is possible by command !triggersseegroup <groupname>.

Bot-Triggers

Bot-triggers are similar to triggers, only are adhered to the certain robot (about them later). And by default the text (both in chat and PM) in the answer to the user arrives on behalf of this robot to which the bot-trigger is adhered. Rules of addition of bot-triggers and answers to them are similar to rules for triggers. At addition of the trigger in case of programming of short template for private messages the format of private messages of the report is considered.

To look the list of bot-triggers it is possible by command !seebottriggers. To look more in detail bot-trigger with the chosen index and its answers it is possible by command !seebottriggeranswers <index>. To add bot-trigger for the robot with chosen nick it is possible by command !addbottriggers <nick> <short_pattern>. To add the answer in bot-trigger with the chosen index it is possible by command !àddbotànswers <index> <answer>. To remove bot-trigger with the chosen index it is possible by command !delbottriggers <index>. To remove the answer with the chosen index from the bot-trigger with the chosen index it is possible by command !delbotanswers <trigger_index> <answer_index>. To add bot-trigger with the chosen index in group with the chosen name it is possible by command !bottriggersaddgroup <index> <groupname>. To clean bot-trigger with the chosen index from group in which it consists at present, it is possible by command !bottriggersdelgroup <index>. To remove group with the chosen name together with bot-triggers available in it it is possible by command !bottriggersremgroup <groupname>. To rename group with the chosen name it is possible by command !bottriggersrengroup <groupname>$<newgroupname>. To disband group with the chosen name it is possible by command !bottriggersclsgroup <groupname>. To look structure of group with the chosen name it is possible by command !bottriggersseegroup <groupname>. The system of bot-triggers on/off together with system of triggers.

PM-Triggers

PM-triggers are similar to triggers, only specialised on personal (private) messages. They look through private messages of the Hub. Rules of addition of PM-triggers and answers to them are similar to rules for triggers. At trigger addition the format of private messages of the report is considered.

To look the list of PM-triggers it is possible by command !seepmtriggers. To look more in detail PM-trigger with the chosen index and its answers it is possible by command !seepmtriggeranswers <index>. To add PM-triggers possible by command !addpmtriggers <short_pattern>. To add the answer in PM-trigger with the chosen index it is possible by command !addpmanswers <index> <answer>. To remove PM-trigger with the chosen index it is possible by command !delpmtriggers <index>. To remove the answer with the chosen index from the PM-trigger with the chosen index it is possible by command !delpmanswers <trigger_index> <answer_index>. To add PM-trigger with the chosen index in group with the chosen name it is possible by command !pmtriggersaddgroup <index> <groupname>. To clean PM-trigger with the chosen index from group in which it consists at present, it is possible by command !pmtriggersdelgroup <index>. To remove group with the chosen name together with PM-triggers available in it it is possible by command !pmtriggersremgroup <groupname>. To rename group with the chosen name it is possible by command !pmtriggersrengroup <groupname>$<newgroupname>. To disband group with the chosen name it is possible by command !pmtriggersclsgroup <groupname>. To look structure of group with the chosen name it is possible by command !pmtriggersseegroup <groupname>. On/off PM-triggers possible by command !ispmtriggers.

Robots

Robots represent bots which are visible in the list of users. The created robots can appropriate bot-triggers. It is convenient, when it is necessary to make service which can accept the information in the form of private messages. To add the robot with wished anybody and the description it is possible by command !addnewbot <nick> <OP> <description>. Flag OP can be 1 (visible as operator) or 0 (visible as user). To remove the robot with chosen nick it is possible by command !delnewbot <nick>. To look the list of robots it is possible by command !newbotlist.

Anticapslock

This service serves for automatic transformation of symbols to the bottom register if the user abuses caps letters. Can how simply to warn the user in chat (answers from the reserved trigger with an index 1 are carried out) or simply automatically changes the register. This mode is switched by command !capsmode. The trigger with an index 1 cannot be deleted. Answers can be deleted and changed.

Global triggers variables

In answers of triggers it is possible to apply variables which are set as "global". These variables, unlike simple, do not leave after processing of the answer and remain in a special file in memory. Are accessible to all triggers. There is possibility to include function of preservation list of global variables in file. Except special flags of answers of triggers it is possible to apply commands to management of global variables. To set the chosen value for global variable with the chosen name it is possible to take advantage by command !triggersaddvar <varname> <varvalue>. If the variable with such name does not exist, it will be created. To remove global variable with the chosen name it is possible by command !triggersdelvar [<varname>]. If the name is not specified, all available global variables will be removed. To look value of global variable with the chosen name it is possible by command !triggersseevar [<varname>]. If the name is not specified, the list of names of available global variables will be deduced.

If constant triggers_isSaveGVars is 1 (by default 0), that global variables will remain in file. Thus they remain accessible after reboot. Tables of triggers, PM-triggers and bot-triggers are stored in files Trigs.lua, PMTrigs.lua and BotTrigs.lua. Robots base keep in file BotList.

Triggers examples:


===== Answers list: =====
Trigger: 31. ^coin$
Patterns:
    ^(%z?)[Cc]+[Oo]+[Ii]+[Nn]+(%z?)$
Answers:
1.    [curUser] has throws the coin, but it somewhere was went :(
2.    [curUser] has throws the coin and drops out TAIL
3.    [curUser] has throws the coin and drops out HEADS
=============================================
In this example on phrase "coin" (without other text) in chat gets out a random answer.

===== Answers list: =====
Trigger: 3. ^[%%%+!]weather$
 Patterns:
    ^(%z?)[%+!]+[Ww]+[Ee]+[Aa]+[Tt]+[Hh]+[Ee]+[Rr]+(%z?)$
 Answers:
  1.    {repl:<b>=" • " <b..->="" <[^b].->=""}{varurl:T:http://weather.yahooapis.com/forecastrss?p=RSXX0094&u=c,,,"<title>.-</title>.-<description><!%[CDATA%[.-<a"<title>(.-)</title>.-<description><!%[CDATA%[(.-)<a"\n%1%2}{touser:[curUser]:<[BotName]> [T]}{exit}
=============================================
In this example is realised the command "!weather" (or "+weather") to get weather for Samara Sity (city code RSXX0094).

===== Answers list: =====
Trigger: 4. ^[%%%+!]phantom_[%%%S]
 Patterns:
    ^(%z?)[%+!]+[Pp]+[Hh]+[Aa]+[Nn]+[Tt]+[Oo]+[Mm]+[%s]+[%S]+
 Answers:
  1.    {class:3:For administration only.}{var:T="%S+%s+(.+)"}{chat:[T]}{exit}
=============================================
In this example it is shown how to write in chat the text without nick. This command allowed to users, whose class not less then 3.

===== Answers list: =====
Trigger: 2. ^$-To:_[%%%S]_From:_[%%%S]_$-<[%%%S]>_[%%%S]   Robot: Translator{English-Russian}
 Patterns:
    ^(%z?)[$][Tt]+[Oo]+[:]+[%s]+[%S]+[%s]+[Ff]+[Rr]+[Oo]+[Mm]+[:]+[%s]+[%S]+[%s]+[$][<]+[%S]+[>]+[%s]+[%S]+
 Answers:
  1.    {class:1:Only for registered users}{var:SR=".To:%s%S+%sFrom:%s%S+%s.<%S+>%s(.+)"}{curl:utf8}{url:http://m.translate.ru/translator/result/?text=[SR]&dirCode=er,1,utf8,"<div%s+class%=.tres.>.-</div>"<div%s+class%=.tres.>(.-)</div>"\nOriginal:\n--------------------\n[SR]\n\nTranslate:\n--------------------\n%1}{exit}
============================
Here shown the bot-trigger example for robot "Translator{English-Russian}". This is the English-Russian translator witch translates the text written in PM to robot, from English on Russian.

===== Answers list: =====
Òðèããåð: 1. ^$-To:_[%%%S]_From:_[%%%S]_$-<[%%%S]>_[%%%S]   Áîò: •Google•
 Patterns:
    ^(%z?)[$][TtÒ]+[OoÎî0]+[:]+[%s]+[%S]+[%s]+[Ff]+[Rr]+[OoÎî0]+[MmÌ]+[:]+[%s]+[%S]+[%s]+[$][<]+[%S]+[>]+[%s]+[%S]+
 Answers:
  1.    {var:Q=".To:%s%S+%sFrom:%s%S+%s.<%S+>%s(.+)"}{repl:</?b>="" <br/>=" "}{curl:utf8}{url:http://www.google.com/pda?q=[Q],,utf8,"<div>%s*<div.class%=.r%s+ld.>%s*<div.class%=.jd.><a.-href%=.%S-.%s*>.-</a>%s*</div>.-<div.class%=.kd.>.-</div>"<div>%s*<div.class%=.r%s+ld.>%s*<div.class%=.jd.><a.-href%=.(%S-).%s*>(.-)</a>%s*</div>.-<div.class%=.kd.>(.-)</div>"\n%1 - %2\n%3\n}
============================
Here shown the bot-trigger example for robot "•Google•". This is the Google search.

===== Answers list: =====
Trigger: 41. ^[%^%%%+%!%%%*]-[%%%S]?
Patterns:
    ^(%z?)[^%+!%*][%S]*
Answers:
1.    {user:[USERSREVERSE]}{rev:(%S+)}{var:T="(.+)"}{chat:<[revUser]> [T]}{exit}
=============================================
===== Answers list: =====
Trigger: 42. ^[%%%+!]miror_[%%%S]$
Patterns:
    ^(%z?)[%+!]+[Mm]+[Ii]+[Rr]+[Oo]+[Rr]+[%s]+[%S]+(%z?)$
Answers:
1.    {class:3:For OPs only}{var:U="%S+%s+(%S+)"}{gvar:USERSREVERSE:[USERSREVERSE]$[U]}{chat:<[BotName]> [curUser] waves a magic wand and [U] starts to look as reflexion in the mirror O.o}{exit}
=============================================
===== Answers list: =====
Trigger: 43. ^[%%%+!]unmiror_[%%%S]$
Patterns:
    ^(%z?)[%+!]+[Uu]+[Nn]+[Mm]+[Ii]+[Rr]+[Oo]+[Rr]+[%s]+[%S]+(%z?)$
Answers:
1.    {class:3:For OPs only}{var:U="%S+%s+(%S+)"}{srepl:$[U]=""}{gvar:USERSREVERSE:[USERSREVERSE]}{chat:<[BotName]> [curUser] waves a magic wand and [U] starts to look as usually :)}{exit}
=============================================
This example represents a joke. By command "!mirror nick" user will write to chat back to front. By command "!unmirror nick" to the user possibility to write normally comes back.

Here example of one more interesting service will be shown. We will assume that we wish to make service of automatic translation of the text which we write to chat, on other languages at our choice.

===== Answers list: =====
Trigger: 54. ^[%%%+!]autotranslate_[%e%r%g%f%s%p%i]-[%e%r%g%f%s%p%i]-$
Patterns:
    ^(%z?)[%+!]+[Aa]+[Uu]+[Tt]+[Oo]+[Tt]+[Rr]+[Aa]+[Nn]+[Ss]+[Ll]+[Aa]+[Tt]+[Ee]+[%s]+[ergfspi][ergfspi](%z?)$
Answers:
  1.    {class:1:Only foe registered users.}{var:T="^%S+%s+(%S+)"}{gvar:[curUser]_AUTOTRANSLATE:[T]}{touser:[curUser]:<[BotName]> You will write in chat with automatic translation: [T]}{exit}
=============================================
===== Answers list: =====
Trigger: 56. ^[%%%+!]autotranslate$
Patterns:
    ^(%z?)[%+!]+[Aa]+[Uu]+[Tt]+[Oo]+[Tt]+[Rr]+[Aa]+[Nn]+[Ss]+[Ll]+[Aa]+[Tt]+[Ee]+(%z?)$
Answers:
  1.    {class:1:Only foe registered users.}{delvar:[curUser]_AUTOTRANSLATE}{touser:[curUser]:<[BotName]> You will not write in chat with automatic translation.}{exit}
=============================================
===== Answers list: =====
Trigger: 58. ^[%^%%%+%!%%%*]-[%%%S]?
Patterns:
    ^(%z?)[^%+!%*][%S]*
Answers:
  1.    {if:[curUser]_AUTOTRANSLATE:[[curUser]_AUTOTRANSLATE]}{curl:utf8}{repl:%"="'"}{var:SR="(.+)"}{varurl:ET:http://m.online-translator.com/translator/result/?text=[SR]&dirCode=[[curUser]_AUTOTRANSLATE],1,utf8,"<div%s+class%=.tres.>.-</div>"<div%s+class%=.tres.>(.-)</div>"%1}{chat:<[curUser]> [ET]}{exit}
=============================================
By command "!autotranslate <from_to>" user sets to itself the translation mode from languige "from" to "to". The direction represents two letters, first of which is direction with which is translated, and second - a direction on which it is translated. For example, direction "re" defines translation from Russian on English, and direction "fg" from French on German and etc. The phrase is translated, if the line does not begin on symbols *,+ and !. A command "!autotranslate" without parametres the user switch off for itself autotranslation.

And etc… Actually possibilities of system of triggers far are not limited to these examples and to show all possibilities here it is not obviously possible. But all of them are simple enough and submit to one system.


<<< back | print | To main...
PhazaSoft© Ekzekutor©
Hosted by uCoz