Difference between revisions of "On text"

From Scriptwiki
Jump to: navigation, search
m (added space to make it more legible which example goes with which text.)
(added examples)
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.
  
The location where this event occurrs can be either a channel (#), a query (?) or both (*).
+
The location where this event occurrs can be either any channel (#), a certain channel (#channel), a query (?) or all (*).
  
You can also use variables as matchtext and location parameter. See below for an example.
+
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]].
  
== Example ==
+
== 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.
  
  
Line 25: Line 25:
 
  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:$($+(*,$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 ==
To make more restrictions, you have to use [[if|if-statements]].
+
To make more restrictions, you can use [[if|if-statements]].
  
 
To trigger your own text, you need to use the [[On_input|On Input]] event.
 
To trigger your own text, you need to use the [[On_input|On Input]] event.
  
 
[[Category:Events]]
 
[[Category:Events]]

Revision as of 16:51, 18 February 2006

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.

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.

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

To make more restrictions, you can use if-statements.

To trigger your own text, you need to use the On Input event.