m (→Dynamic text pattern) |
(→Dynamic text pattern) |
||
Line 60: | Line 60: | ||
<syntaxhighlight lang="mIRC">on *:text:$(*slaps $me $+ *):#:{ | <syntaxhighlight lang="mIRC">on *:text:$(*slaps $me $+ *):#:{ | ||
describe $chan Slaps $nick with dried-up sandwich! | describe $chan Slaps $nick with dried-up sandwich! | ||
+ | }</syntaxhighlight> | ||
+ | |||
+ | Or | ||
+ | |||
+ | <syntaxhighlight lang="mIRC">on *:text:$(!example * $+ %match $+ *):#:{ | ||
+ | describe $chan This is an example, $+ $nick $+ ! | ||
}</syntaxhighlight> | }</syntaxhighlight> | ||
Revision as of 14:44, 1 January 2014
The on text event is an mIRC event that triggers when a remote user (I.E. not the local user) receives a channel or a query message.
Contents
Synopsis
on <level>:text:<matchtext>:<target>:<commands> ;or on <level>:text:<matchtext>:<target>:{ }
Level
- <level> - The appropriate access level for the event.
Matchtext
The <matchtext> is the text pattern that mIRC will use to compare with every user message. Once the text has been matched (and the channel if provided), the event will trigger.
Wildcard text pattern
The matchtext can contain wild characters:
- * - matches any text
- ? - matches any single letter
- & - matches any single word
For Example:
- !test - the matchtext will only match if the ONLY word is "!test"
- !test* - the matchtext will match if the text starts with "!test"
- *!test - the matchtext will match if the text ends with the word "!test"
- *!test* - the matchtext will match any text that has "!test" in it (anywhere)
The basic text pattern
The most basic on text event is the normal wildcard pattern:
on *:text:!help:#:{ notice $nick For Help just state your question and pastebin any relevant code. }
Sometimes we want to get the user's input. We can use the & to match a single word (in this case it will be a name, although it doesn't matter)
on *:text:!color &:?:{ var %color = $gettok(white black red blue brown yellow orange green, $rand(1, 8), 32) msg $chan $2's random color is: %color $+ . }
RegEx text pattern
The matchtext parameter can also be a Regular Expression Pattern by prefixing the user level with a dollar sign ($)
Example:
on $*:text:/^!test$/i:#:{ msg $chan Test Worked! }
Dynamic text pattern
Text matched patterns can also be dynamic, for example your name at the time of the execution ($me), a variable or time. In order for mIRC to know to evaluate the expression, it must be enclosed by the $() identifier.
Example:
on *:text:$(*slaps $me $+ *):#:{ describe $chan Slaps $nick with dried-up sandwich! }
Or
on *:text:$(!example * $+ %match $+ *):#:{ describe $chan This is an example, $+ $nick $+ ! }
If the entire match text patter contains a SINGLE variable, the $() is not required.
Example:
;Assume %text is set to !cool on *:text:%text:#:{ msg $chan I am the coolest! }
It is also possible to use regular expressions with dynamic match text.
on $*:text:$(/^!slaps $me $+ /Si):#:{ describe $chan Slaps $nick with dried-up sandwich! }
Target
The target parameter of the event defines the locations of where the event can be triggered from. For example, the on text event can be triggered by a channel message or by a query.
- ? - defines query location
- # - defines channel location
- * - defines both query and channel locations
- %var - A variable containing a channel or a list of channels is also acceptable
Example:
;let %chan equal #mSL,#help,#supprt on *:text:!hi:%chan:{ notice $nick Hello! }