Matchtext » History » Version 11
Per Amundsen, 04/01/2019 07:49 AM
| 1 | 1 | Per Amundsen | {{>toc}} |
|---|---|---|---|
| 2 | |||
| 3 | h1. Matchtext |
||
| 4 | |||
| 5 | 2 | Per Amundsen | A <matchtext> is a text pattern that AdiIRC will use to compare with something during a [[Scripting_Events|scripting event]]. |
| 6 | 1 | Per Amundsen | |
| 7 | h1. Wild characters |
||
| 8 | |||
| 9 | The matchtext can contain wild characters: |
||
| 10 | |||
| 11 | <notextile>* - matches any text</notextile> |
||
| 12 | <notextile>? - matches any single letter</notextile> |
||
| 13 | <notextile>& - matches any single word</notextile> |
||
| 14 | |||
| 15 | 10 | Per Amundsen | _See also [[$matchkey]], [[$stripped]]._ |
| 16 | |||
| 17 | 1 | Per Amundsen | *Example* |
| 18 | |||
| 19 | <pre> |
||
| 20 | ; The matchtext will only match if the ONLY word is "!test" |
||
| 21 | on *:TEXT:!test:*:echo -ag Match |
||
| 22 | |||
| 23 | ; The matchtext will match if the text starts with "!test" |
||
| 24 | on *:TEXT:!test*:*:echo -ag Match |
||
| 25 | |||
| 26 | ; The matchtext will match if the text ends with the word "!test" |
||
| 27 | on *:TEXT:*!test:*:echo -ag Match |
||
| 28 | |||
| 29 | ; The matchtext will match any text that has "!test" in it (anywhere) |
||
| 30 | on *:TEXT:*!test*:*:echo -ag Match |
||
| 31 | |||
| 32 | ; The matchtext will match any text that start with the word test !test and his only followed by a second word |
||
| 33 | on *:TEXT:!test &:*:echo -ag Match |
||
| 34 | </pre> |
||
| 35 | |||
| 36 | h1. Regex text pattern |
||
| 37 | |||
| 38 | 8 | Per Amundsen | The matchtext parameter can also be a [[Scripting Regex|Regular Expression]] Pattern by using the '$' event prefix. |
| 39 | 1 | Per Amundsen | |
| 40 | *Example* |
||
| 41 | |||
| 42 | <pre> |
||
| 43 | on $*:text:/^!test$/i:#:{ |
||
| 44 | msg $chan Test Worked! |
||
| 45 | } |
||
| 46 | </pre> |
||
| 47 | 3 | Per Amundsen | |
| 48 | 11 | Per Amundsen | h1. Matchtext evaluation |
| 49 | 3 | Per Amundsen | |
| 50 | 4 | Per Amundsen | Matchtext can be evaluated using [[$]](code) or contain a single [[Scripting_Variables|%variable]]. |
| 51 | 3 | Per Amundsen | |
| 52 | *Example* |
||
| 53 | <pre> |
||
| 54 | ; Subscribe to the TEXT event, try evaluate my nick, and if it matches, print a text. |
||
| 55 | 6 | Per Amundsen | on *:TEXT:$(* $+ $me $+ *)):*:echo -ag My nick was highlighted on $chan |
| 56 | 9 | Per Amundsen | |
| 57 | ; Set a variable |
||
| 58 | set %variable !test |
||
| 59 | |||
| 60 | ; Subscribe to the TEXT event, if the messages matches the variable, print a text. |
||
| 61 | on *:TEXT:%variable:*:echo -ag Text !test was matched |
||
| 62 | 3 | Per Amundsen | </pre> |