Matchtext » History » Version 7
Per Amundsen, 11/14/2015 02:17 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 | *Example* |
||
16 | |||
17 | <pre> |
||
18 | ; The matchtext will only match if the ONLY word is "!test" |
||
19 | on *:TEXT:!test:*:echo -ag Match |
||
20 | |||
21 | ; The matchtext will match if the text starts with "!test" |
||
22 | on *:TEXT:!test*:*:echo -ag Match |
||
23 | |||
24 | ; The matchtext will match if the text ends with the word "!test" |
||
25 | on *:TEXT:*!test:*:echo -ag Match |
||
26 | |||
27 | ; The matchtext will match any text that has "!test" in it (anywhere) |
||
28 | on *:TEXT:*!test*:*:echo -ag Match |
||
29 | |||
30 | ; The matchtext will match any text that start with the word test !test and his only followed by a second word |
||
31 | on *:TEXT:!test &:*:echo -ag Match |
||
32 | </pre> |
||
33 | |||
34 | h1. Regex text pattern |
||
35 | |||
36 | 7 | Per Amundsen | The matchtext parameter can also be a [[[Scripting_Regex|Regular Expression]] Pattern by using the '$' event prefix. |
37 | 1 | Per Amundsen | |
38 | *Example* |
||
39 | |||
40 | <pre> |
||
41 | on $*:text:/^!test$/i:#:{ |
||
42 | msg $chan Test Worked! |
||
43 | } |
||
44 | </pre> |
||
45 | 3 | Per Amundsen | |
46 | 5 | Per Amundsen | h1. Matchtext Evaluation |
47 | 3 | Per Amundsen | |
48 | 4 | Per Amundsen | Matchtext can be evaluated using [[$]](code) or contain a single [[Scripting_Variables|%variable]]. |
49 | 3 | Per Amundsen | |
50 | *Example* |
||
51 | <pre> |
||
52 | ; Subscribe to the TEXT event, try evaluate my nick, and if it matches, print a text. |
||
53 | 6 | Per Amundsen | on *:TEXT:$(* $+ $me $+ *)):*:echo -ag My nick was highlighted on $chan |
54 | 3 | Per Amundsen | </pre> |