Scripting » History » Version 7
Per Amundsen, 04/01/2011 06:25 PM
1 | 1 | Per Amundsen | h1. Scripting |
---|---|---|---|
2 | |||
3 | In the latest beta's, I am experimenting with a little more advanced scripting features and I will use this wiki to track progress and features. |
||
4 | |||
5 | Syntax, variables and functions will probably change a lot, so don't except previous scripts will still work in the next beta and so forth. |
||
6 | |||
7 | 2 | Per Amundsen | As of build 010411. |
8 | 1 | Per Amundsen | |
9 | In Commands -> Edit Commands you can enter a scripting line with the following syntax: |
||
10 | |||
11 | The line must start with <pre>OnEvent<whitespace></pre> |
||
12 | |||
13 | Followed by either an expression like this (works recursivly) |
||
14 | |||
15 | <pre> |
||
16 | if (SOMETING == SOMETHINGELSE) { EXECUTE HERE } |
||
17 | if (SOMETING != SOMETHINGELSE) { EXECUTE HERE } |
||
18 | if (SOMETING ismatch SOMETHINGELSE) { EXECUTE HERE } |
||
19 | </pre> |
||
20 | or by an executed command or function |
||
21 | |||
22 | 2 | Per Amundsen | You can now combine expressions with && (AND) and || (OR) like this |
23 | <pre> |
||
24 | if (SOMETHING == SOMETHING && SOMETHINGELSE != SOMETHINGELSE) { EXECUTE HERE } |
||
25 | if (SOMETHING == SOMETHING || SOMETHINGELSE != SOMETHINGELSE) { EXECUTE HERE } |
||
26 | </pre> |
||
27 | The logic behind these expressions is not fully tested, id love any feedback on this. |
||
28 | |||
29 | 1 | Per Amundsen | Executed commands are /slash commands already in the client e.g /msg #channel hello world. |
30 | Executed functions are predefined functions in the client, only two exists for now. |
||
31 | |||
32 | An execution block can consist of both commands and functions if seperated by | (pipe) character like this <pre>/msg #channel hello world|.function bla bla|/msg #channel2 hello world</pre> |
||
33 | |||
34 | Furthermore there is a lot of predefined variables for use with these functions, for now they are: |
||
35 | |||
36 | $event / current event, e.g PRIVMSG 001 MODE and so forth |
||
37 | $channel / the channel the event occurred on, if any |
||
38 | $msg / the message to the channel/user or the message in a raw irc line e.g whois [kr0n] is a registered nick |
||
39 | $nick / the nick the event was sent from, can be a irc.server.com, a nick or null |
||
40 | $me / my current nick |
||
41 | $network / the network the event occured on e.g Quakenet |
||
42 | $ident / the from user ident if any |
||
43 | $host / the from user hostname if any |
||
44 | $myident / my ident |
||
45 | $myhost / my host |
||
46 | |||
47 | Currently predefined functions are: |
||
48 | <pre> |
||
49 | .insert requires .insert <nick (use null for nonick)> <where (a channel or $channel, a nick or $nick, or status)> <MsgType (MsgServer/MsgUser/MsgEmote/MsgCTCP/MsgNotice/MsgClient/MsgLog)> <$msg or message> |
||
50 | </pre> |
||
51 | |||
52 | <pre> |
||
53 | .eat <what (text or all)> |
||
54 | </pre> |
||
55 | .insert is used for inserting a specific message type into a chat window, its intended for use in cases where you want to override how adiirc shows a given event, but can also be used for adding additional messages. |
||
56 | |||
57 | .eat is used to tell adiirc to either "eat" the text output from an event or "eat" everything and don't act on this event at all. |
||
58 | |||
59 | Putting it all togheter, here are a few examples: |
||
60 | |||
61 | <pre> |
||
62 | 2 | Per Amundsen | OnEvent if ($event == NOTICE) { if ($msg ismatch hi there) { .insert $nick status MsgNotice $msg|.eat text } } |
63 | 1 | Per Amundsen | </pre> |
64 | |||
65 | insert the notice into the server window and tells adiirc to "eat" its own text output from this notice |
||
66 | |||
67 | <pre> |
||
68 | 5 | Per Amundsen | OnEvent if ($event == PRIVMSG && $msg == herp) { /msg $channel derp } } |
69 | 1 | Per Amundsen | </pre> |
70 | |||
71 | 7 | Per Amundsen | if the event is a PRIVMSG AND the $msg equals "herp", then show "derp" in the channel |
72 | 1 | Per Amundsen | |
73 | <pre> |
||
74 | 6 | Per Amundsen | OnEvent if ($event == PRIVMSG) { if ($nick == Q || $nick == $me) { /msg $channel Q or $me is speaking! } } |
75 | 1 | Per Amundsen | </pre> |
76 | |||
77 | 7 | Per Amundsen | if the event is a PRIVMSG and the $nick equals "Q" OR $me then show "Q is speaking" in the channel |
78 | 3 | Per Amundsen | |
79 | 4 | Per Amundsen | A list of custom events that is also usable as $event == |
80 | 3 | Per Amundsen | <pre> |
81 | OnOwner |
||
82 | OnDeOwner |
||
83 | OnSpecialOp |
||
84 | OnSpecialDeOp |
||
85 | OnOp |
||
86 | OnDeOp |
||
87 | OnHop |
||
88 | OnDeHop |
||
89 | OnVoice |
||
90 | OnDeVoice |
||
91 | </pre> |