On text

From Scriptwiki
Jump to: navigation, search

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.


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