Matchtext » History » Version 3
Per Amundsen, 11/14/2015 01: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 | *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 | The matchtext parameter can also be a [[[Scripting Regex|Regular Expression]] Pattern by using the '$' event prefix. |
||
37 | |||
38 | *Example* |
||
39 | |||
40 | <pre> |
||
41 | on $*:text:/^!test$/i:#:{ |
||
42 | msg $chan Test Worked! |
||
43 | } |
||
44 | </pre> |
||
45 | 3 | Per Amundsen | |
46 | h2. Matchtext Evaluation |
||
47 | |||
48 | Matchtext can be evaluated using [[$]](code) or contain a single %variable. |
||
49 | |||
50 | *Example* |
||
51 | <pre> |
||
52 | ; Set a target variable. |
||
53 | set %target #channel |
||
54 | |||
55 | ; Subscribe to the TEXT event, try evaluate my nick, and if it matches, print a text. |
||
56 | on *:TEXT:$(* $+ $me $+ *)):%target:echo -ag My nick was highlighted on %target |
||
57 | </pre> |