Project

General

Profile

Scripting » History » Version 13

Per Amundsen, 04/01/2011 06:34 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 8 Per Amundsen
Syntax, variables and functions will probably change a lot, so don't except previous scripts to still work in the next beta and so forth.
6 1 Per Amundsen
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 13 Per Amundsen
if (SOMETING ismatch SOMETHINGELSE) { EXECUTE HERE }</pre>
19 1 Per Amundsen
or by an executed command or function
20
21 2 Per Amundsen
You can now combine expressions with && (AND) and || (OR) like this
22 1 Per Amundsen
<pre>
23 2 Per Amundsen
if (SOMETHING == SOMETHING && SOMETHINGELSE != SOMETHINGELSE) { EXECUTE HERE }
24 13 Per Amundsen
if (SOMETHING == SOMETHING || SOMETHINGELSE != SOMETHINGELSE) { EXECUTE HERE }</pre>
25 1 Per Amundsen
The logic behind these expressions is not fully tested, id love any feedback on this.
26 12 Per Amundsen
27
(note: ismatch will check if SOMETHING exist inside SOMETHINGELSE e.g if something is "hello" and something else is "hello world" it would return True because "hello" exist)
28 2 Per Amundsen
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 13 Per Amundsen
.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></pre>
50 1 Per Amundsen
51
<pre>
52 13 Per Amundsen
.eat <what (text or all)></pre>
53 1 Per Amundsen
.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.
54
55
.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.
56
57
Putting it all togheter, here are a few examples:
58
59
<pre>
60 13 Per Amundsen
OnEvent if ($event == NOTICE) { if ($msg ismatch hi there) { .insert $nick status MsgNotice $msg|.eat text } }</pre>
61 1 Per Amundsen
62
insert the notice into the server window and tells adiirc to "eat" its own text output from this notice
63
64
<pre>
65 13 Per Amundsen
OnEvent if ($event == PRIVMSG && $msg == herp) { /msg $channel derp } }</pre>
66 7 Per Amundsen
67 1 Per Amundsen
if the event is a PRIVMSG AND the $msg equals "herp", then show "derp" in the channel
68
69 6 Per Amundsen
<pre>
70 13 Per Amundsen
OnEvent if ($event == PRIVMSG) { if ($nick == Q || $nick == $me) { /msg $channel Q or $me is speaking! } }</pre>
71 1 Per Amundsen
72
if the event is a PRIVMSG and the $nick equals "Q" OR $me then show "Q or $me is speaking" in the channel
73 9 Per Amundsen
74 3 Per Amundsen
A list of custom events that is also usable as $event ==
75 4 Per Amundsen
<pre>
76 3 Per Amundsen
OnOwner
77
OnDeOwner
78
OnSpecialOp
79
OnSpecialDeOp
80
OnOp
81
OnDeOp
82
OnHop
83
OnDeHop
84
OnVoice
85 13 Per Amundsen
OnDeVoice</pre>