Difference between revisions of "On text"
(changed iswm link) |
m (Added references to "why doesn't my text event work") |
||
(7 intermediate revisions by 6 users not shown) | |||
Line 1: | Line 1: | ||
The on TEXT event triggers when you receive private and/or channel messages. | The on TEXT event triggers when you receive private and/or channel messages. | ||
− | on <level>:TEXT:<matchtext>:<*><?><#[,#]>:<commands> | + | on <level>:TEXT:<[[wildcards|matchtext]]>:<*><?><#[,#]>:<commands> |
The matchtext can be a [[If-Then-Else#The_Operators|wildcard]] match or even a [[Regular_Expression|regular expression]]. | The matchtext can be a [[If-Then-Else#The_Operators|wildcard]] match or even a [[Regular_Expression|regular expression]]. | ||
Line 7: | Line 7: | ||
Read [[Access_Levels|access levels]] to get more info about the <level> field. | Read [[Access_Levels|access levels]] to get more info about the <level> field. | ||
− | + | Read [[wildcards]] to get more information about how to use matchtext to match unknown words, words that may change. | |
− | You can also use variables as matchtext and location parameter. See below for | + | The location where this event occurrs can be either any channel (#), a certain channel (#channel), a query (?) or all (*). |
+ | |||
+ | You can also use variables and identifiers as matchtext and location parameter. See below for examples. | ||
'''Note''' that you can't test out these events by typing text to yourself. To test them, use another connection, that you can establish via [[Server|/server]]. | '''Note''' that you can't test out these events by typing text to yourself. To test them, use another connection, that you can establish via [[Server|/server]]. | ||
− | == | + | '''Note''' that mIRC iterates the triggers in the script files one by one, and when a trigger is catched, other triggers ''in the same script file'' will not be triggered. A "catch-all" trigger (a trigger which catches all events, marked with matchtext of *) should be placed last of the "on TEXT" triggers in the script file. See also [[Why doesnt my text event work]]. |
+ | |||
+ | == Examples == | ||
On *:Text:*moo*:#: { [[echo]] -a [[$nick]] just said moo in [[$chan]] [[DollarPlus|$+]] . } | On *:Text:*moo*:#: { [[echo]] -a [[$nick]] just said moo in [[$chan]] [[DollarPlus|$+]] . } | ||
− | This will echo "<nick> just said moo in <channel>", when someone has said a sentence with "moo" in it. | + | This will echo "<nick> just said moo in <channel>.", when someone has said a sentence with "moo" in it. |
+ | |||
+ | |||
On *:Text:*:?: { echo -a $nick just said in query: $1- } | On *:Text:*:?: { echo -a $nick just said in query: $1- } | ||
This will echo everything someone said to you in query in your active window, as $1- refers to the entire text that was said to you. | This will echo everything someone said to you in query in your active window, as $1- refers to the entire text that was said to you. | ||
+ | |||
+ | |||
On *:Text:%mymatchtext:%mychannels: { [[beep]] } | On *:Text:%mymatchtext:%mychannels: { [[beep]] } | ||
The value of %mymatchtext will be matched against whatever text the user sends, and the value of %mychannels will be matched against the channel to which the message was sent. If both matched, it will beep. | The value of %mymatchtext will be matched against whatever text the user sends, and the value of %mychannels will be matched against the channel to which the message was sent. If both matched, it will beep. | ||
+ | |||
+ | |||
+ | To get identifiers evaluated in the matchtext, you need to use a special identifier [[$(...)]]. If you use this identifier in the matchtext, you can't have anything else outside this identifier in the matchtext. | ||
+ | On *:Text:$([[$me]]):#: { beep } | ||
+ | This beeps when someone says your nick (but nothing else than your nick) in any channel. | ||
+ | |||
+ | |||
+ | You can also combine identifiers and variables inside the $(...) identifier. | ||
+ | On *:Text:[[$(...)|$]]([[DollarPlus|$+]](*,$me,*)):?: { echo -a $nick mentioned your nick in a query. } | ||
+ | This triggers when someone says any line containing your nick in a query. The matchtext is basically *$me*, but in order to get that $me evaluated to your current nick, you need to use the $(...) identifier. | ||
+ | |||
+ | |||
+ | On $*:Text:/\s200\d\s/:#: { echo -a $nick just mentioned some year in channel $chan $+ ! } | ||
+ | This is a regular expression match. It triggers when someone mentions a year between 2000-2009 in any channel. mIRC syntax requires the //'s around the expression. | ||
== See Also == | == See Also == | ||
− | + | * [[if|if-statements]] to make more restrictions. | |
− | + | * [[On_input|On Input]] to trigger to your own text. | |
− | + | * [[Wildcards]] for information on using * and ? in matchtext | |
+ | * [[Why doesnt my text event work]] | ||
[[Category:Events]] | [[Category:Events]] |
Latest revision as of 08:23, 23 March 2012
The on TEXT event triggers when you receive private and/or channel messages.
on <level>:TEXT:<matchtext>:<*><?><#[,#]>:<commands>
The matchtext can be a wildcard match or even a regular expression. To use regular expressions as matchtext, you need the $-Prefix.
Read access levels to get more info about the <level> field.
Read wildcards to get more information about how to use matchtext to match unknown words, words that may change.
The location where this event occurrs can be either any channel (#), a certain channel (#channel), a query (?) or all (*).
You can also use variables and identifiers as matchtext and location parameter. See below for examples.
Note that you can't test out these events by typing text to yourself. To test them, use another connection, that you can establish via /server.
Note that mIRC iterates the triggers in the script files one by one, and when a trigger is catched, other triggers in the same script file will not be triggered. A "catch-all" trigger (a trigger which catches all events, marked with matchtext of *) should be placed last of the "on TEXT" triggers in the script file. See also Why doesnt my text event work.
Examples
On *:Text:*moo*:#: { echo -a $nick just said moo in $chan $+ . }
This will echo "<nick> just said moo in <channel>.", when someone has said a sentence with "moo" in it.
On *:Text:*:?: { echo -a $nick just said in query: $1- }
This will echo everything someone said to you in query in your active window, as $1- refers to the entire text that was said to you.
On *:Text:%mymatchtext:%mychannels: { beep }
The value of %mymatchtext will be matched against whatever text the user sends, and the value of %mychannels will be matched against the channel to which the message was sent. If both matched, it will beep.
To get identifiers evaluated in the matchtext, you need to use a special identifier $(...). If you use this identifier in the matchtext, you can't have anything else outside this identifier in the matchtext.
On *:Text:$($me):#: { beep }
This beeps when someone says your nick (but nothing else than your nick) in any channel.
You can also combine identifiers and variables inside the $(...) identifier.
On *:Text:$($+(*,$me,*)):?: { echo -a $nick mentioned your nick in a query. }
This triggers when someone says any line containing your nick in a query. The matchtext is basically *$me*, but in order to get that $me evaluated to your current nick, you need to use the $(...) identifier.
On $*:Text:/\s200\d\s/:#: { echo -a $nick just mentioned some year in channel $chan $+ ! }
This is a regular expression match. It triggers when someone mentions a year between 2000-2009 in any channel. mIRC syntax requires the //'s around the expression.
See Also
- if-statements to make more restrictions.
- On Input to trigger to your own text.
- Wildcards for information on using * and ? in matchtext
- Why doesnt my text event work