MIRC Scripting/BeyondBasics/Text Matching

on TEXT

The on TEXT event triggers when you receive private and/or channel messages.

Format:

on <level>:TEXT:<matchtext>:<*><?><#[,#]>:<commands>

Example:

on 1:TEXT:*help*:#mirc,#irchelp:/msg $nick what is the problem?

The on ACTION and on NOTICE events use exactly the same format as on TEXT, and trigger on an action and on a notice event respectively.

The match text can be a wildcard string, where:

*        matches any text
&        matches any word
text     matches if text contains only this word
text*    matches if text starts with this word
*text    matches if text ends with this word
*text*   matches if text contains this word anywhere

The match text can also be a regular expression. See the $ prefix section in Access Levels.

The location where this event occurs can be specified using:

?        for any private message
#        for any channel message
#mirc    for any messages on channel #mirc
*        for any private or channel messages

Examples:

on 1:TEXT:hello*:#:/msg $chan Welcome to $chan $nick!

This listens on any channel for any line beginning with the word hello and welcomes the user who said it to the channel.

on 1:TEXT:*cookie*:#food:/describe $chan gives $nick a cookie :)

This listens on channel #food for any message containing the word cookie and gives the user who said it a cookie.

on 1:ACTION:moo:#:/msg $chan Aha, I see we have a cow among us.

This listens on any channel for an action that contains the word moo and responds accordingly.

on 1:NOTICE:*:?:/msg $nick I am AFK, back in a moment!

This listens for any private notice and responds with the message that you are away from the keyboard.

For more flexibility, you can also use Variables in place of both the matchtext and the channel parameters.

on 1:TEXT:%matchtext:%channel:/msg $nick You just said $1- on channel %channel

The value of %matchtext will be matched against whatever text the user sends, and the value of %channel will be matched against the channel to which the message was sent.

Note: You cannot test out these events by typing text to yourself. They can only be initiated by someone else saying something in a channel or in a private message.