mIRC Scripting

mIRC: On Events

mIRC Triggers or On Events are scripts that react to variety of events automatically. This is how most bots and games work. The use of triggers can be set to automate any kind of activity for any kind of reason.

Syntax:

<level>:<event>:<commands>

; or

on <level>:<event>: {
   ;Statement block
}

Perimeters The ":" (colon) is an important part of the event line. It divides the different sections of the event into parts. As a result, your match text should not contain the character :.

Please note: you may only have one of the same exact events. If for any reason there are two of the same event, the one closer to the top of the page will be executed, the second will be ignored. This issue can be fixed by placing the second script in a separate script file.Wildcard matchtext follow the same logic. For example: an on text “!example*” follows by another on text “!example”. The first on text will always trigger.

Access levels let you limit user’s access to an event. To learn more about access levels click here.

Events

Events are scripts that respond to different actions that take place in mIRC. For example, when a user joins a channel, you can write a script to tell mIRC to voice them.

Below are the list of the most common Events; For a full list of events click here.


 

On Join - This event will trigger when a user joins one of the channels you are on.
Format: on <level>:JOIN:<#[,#]>:<commands>
Example:

on 1:JOIN:#:{
  notice $nick Welcome to $chan $+ !
}

On Kick - This event will trigger once a user has been kicked from a channel you are on.
Format: on <level>:KICK:<#[,#]>:<commands>
Example:

on 1:KICK:#:{
  msg $chan $nick $+ , Why did you kick $knick $+ ?
}

On Text, Action, & Notice - These 3 events are the most commonly used. They are triggered once a user says something in a channel, once a user notices you/channel something, or once a user has self-described (/me).
Format: on <level>:TEXT:<matchtext>:<*><?><#[,#]>:<commands>
Format: on <level>:ACTION:<matchtext>:<*><?><#[,#]>:<commands>
Format: on <level>:NOTICE:<matchtext>:<*><?><#[,#]>:<commands>

<matchtext> - The match text is the text pattern that mIRC will try to find in every user message. Once the text has been matched, the event will trigger.

* - matches any text
& - matches any word
!test - will only match if the ONLY word is "!test"
!test* - will match if the text starts with "!test"
*!test - will match if the text ends with the word "!test"
*!test* - will match any text that has "!test" in it anywhere.

Regular Expression MatchText: - Matched Text can also be a Regular Expression Pattern by prefixing the user level with a dollar sign ($)

Example:

on $1:TEXT:/^!test$/:#:{
  msg $chan Test Worked!
}

Dynamic TextMatch - Textmatches can also be dynamic, for example your name at the time of the execution ($me), a variable or time.
Example:

on 1:ACTION:$(*slaps $me $+ *):#:{
  describe $chan Slaps $nick with dried up sandwich!
}

Assume %text is set to !cool

on 1:TEXT:%text:#:{
  msg $chan I am the coolest!
}

<*><?><#[,#]> - Since messages can be a notice, a private message or a simple channel message, mIRC gives you the ability to define on what kind of message the event should trigger.

? - event will react to any private message
# - event will react to any channel message
#MyChannel - event will react to only messages from channel
* - event will react to any message
%chans - A variable containing a channel or a list of channels is also acceptable.

Example:

on 1:TEXT:*:?:{
  if ($away) {
    msg $nick Thank you for trying to reach me; unfortunately I am currently away. I will reply to your pm as soon as I get back.
    msg $nick ~ $+ $me
  }
}