Project

General

Profile

Scripting » History » Version 40

Per Amundsen, 04/29/2011 11:02 AM

1 40 Per Amundsen
h1. Notice: this is info for 1.8.8 Beta and will not work for 1.8.7.
2 39 Per Amundsen
3 1 Per Amundsen
h1. Scripting
4
5
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.
6
7 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.
8 1 Per Amundsen
9 33 Per Amundsen
As of build 130411.
10 1 Per Amundsen
11 30 Per Amundsen
There are 2 types of scripting at the moment, one that have been here for a long time, and a new system.
12 16 Per Amundsen
13 38 Per Amundsen
All scripting is done in Commands -> Edit Commands where one line represent a script or a custom command and its trigger is one of 3 ways:
14
15
/something<whitespace> 
16 37 Per Amundsen
keys<whitespace>
17
OnEvent<whitespace>
18 16 Per Amundsen
19 1 Per Amundsen
Please note that variables and functions are *different* for these 2 types of scripts.
20 37 Per Amundsen
21
You can comment out a command by putting a # in front of it.
22 17 Per Amundsen
23 1 Per Amundsen
h1. Normal custom commands:
24 26 Per Amundsen
25 25 Per Amundsen
<pre>Syntax = /something<whitespace>/somethingelse</pre>
26 16 Per Amundsen
27 23 Per Amundsen
Here are some variables which can be used in Custom Commands, its like creating aliases of already available commands, e.g <pre>/hi /me says hi to $chan</pre> will show <pre>* kr0n says hi to #adiirc</pre> when typing <pre>/hi</pre>
28 16 Per Amundsen
29 32 Per Amundsen
Current variables are $1 to $9, $params, $chan and $me. $1 to $9 represents what you type after /yourcommand e.g <pre>/sup /say whats up $1</pre> when typing <pre>/sup kr0n</pre> it will show like this <pre>User: whats up kr0n</pre>
30 16 Per Amundsen
31 29 Per Amundsen
$params represents everything written after /yourcommand, $chan replaces itself with current channel and $me replaces itself with your current usernick. 
32 16 Per Amundsen
33 19 Per Amundsen
You can make combo commands by using | as a seperator, e.g <pre>/hi /me says hi to $chan|/me says hi again to $chan</pre>
34 16 Per Amundsen
35 1 Per Amundsen
$file[path] returns data from a file, $frand[path] fetchs a random line from a file and $floop[path] gets one line increasingly (line1, then line2, then line3 etc).
36 23 Per Amundsen
37 27 Per Amundsen
h1. Custom Commands by hotkeys
38 1 Per Amundsen
39 25 Per Amundsen
<pre>Syntax = key&key<whitespace>/something</pre>
40 1 Per Amundsen
41 27 Per Amundsen
In addition to making a custom command trigger by typing a /slash command, you make it trigger with a hotkey instead (note, these commmands will not be useable from the new scripting engine)
42
43 23 Per Amundsen
Useable modifies are ctrl, alt and shift and any character or number or F key.
44
45
An example
46
47 24 Per Amundsen
<pre>ctrl&o /msg $chan ohai i just pressed ctrl and o</pre>
48 23 Per Amundsen
49 1 Per Amundsen
Everytime you press ctrl and 'o' now, this command will be fired off.
50 24 Per Amundsen
51
<pre>ctrl&alt&o /msg $chan ohai i just pressed ctrl and alt and o</pre>
52
53 1 Per Amundsen
Everytime you press ctrl and alt and 'o' now, this command will be fired off.
54 16 Per Amundsen
55 27 Per Amundsen
h1. Unified Scripting
56 1 Per Amundsen
57 27 Per Amundsen
<pre>Syntax = OnEvent<whitespace>code</pre>
58
59 1 Per Amundsen
The new scripting tries to combine normal client commands, your custom commands, functions and events into one scripting language.
60
61 25 Per Amundsen
In Commands -> Edit Commands you can enter a scripting line with the following syntax:
62 1 Per Amundsen
63
Followed by either an expression like this (works recursivly)
64
65
<pre>
66
if (SOMETING == SOMETHINGELSE) { EXECUTE HERE }
67
if (SOMETING != SOMETHINGELSE) { EXECUTE HERE }
68 13 Per Amundsen
if (SOMETING ismatch SOMETHINGELSE) { EXECUTE HERE }</pre>
69 1 Per Amundsen
or by an executed command or function
70
71 2 Per Amundsen
You can now combine expressions with && (AND) and || (OR) like this
72 1 Per Amundsen
<pre>
73 2 Per Amundsen
if (SOMETHING == SOMETHING && SOMETHINGELSE != SOMETHINGELSE) { EXECUTE HERE }
74 13 Per Amundsen
if (SOMETHING == SOMETHING || SOMETHINGELSE != SOMETHINGELSE) { EXECUTE HERE }</pre>
75 1 Per Amundsen
The logic behind these expressions is not fully tested, id love any feedback on this.
76 33 Per Amundsen
77
It is also possible to use else if like this
78
<pre>if (SOMETHING == SOMETHING) { EXECUTE HERE } else if (SOMETHINGELSE == SOMETHINGELSE) { EXECUTE HERE }</pre>
79
In the future just "else" will be possible to.
80 12 Per Amundsen
81
(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)
82 2 Per Amundsen
83 1 Per Amundsen
Executed commands are /slash commands already in the client e.g /msg #channel hello world.
84
Executed functions are predefined functions in the client, only two exists for now.
85
86
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>
87
88
Furthermore there is a lot of predefined variables for use with these functions, for now they are:
89
90
$event / current event, e.g PRIVMSG 001 MODE and so forth
91
$channel / the channel the event occurred on, if any
92
$msg / the message to the channel/user or the message in a raw irc line e.g whois [kr0n] is a registered nick
93
$nick / the nick the event was sent from, can be a irc.server.com, a nick or null
94
$me / my current nick
95
$network / the network the event occured on e.g Quakenet
96
$ident / the from user ident if any
97
$host / the from user hostname if any
98
$myident / my ident
99
$myhost / my host
100 14 Per Amundsen
$server / host from the server e.g irc.server.com
101 1 Per Amundsen
102
Currently predefined functions are:
103
<pre>
104 36 Per Amundsen
.insert <nick (use null for nonick)> 
105
<where (a channel or $channel, a nick or $nick, or status)> 
106
<MsgType (MsgServer/MsgUser/MsgEmote/MsgCTCP/MsgNotice/MsgClient/MsgLog)> 
107
<$msg or message></pre>
108 1 Per Amundsen
109
<pre>
110 13 Per Amundsen
.eat <what (text or all)></pre>
111 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.
112
113
.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.
114
115
Putting it all togheter, here are a few examples:
116
117
<pre>
118 13 Per Amundsen
OnEvent if ($event == NOTICE) { if ($msg ismatch hi there) { .insert $nick status MsgNotice $msg|.eat text } }</pre>
119 1 Per Amundsen
120
insert the notice into the server window and tells adiirc to "eat" its own text output from this notice
121
122
<pre>
123 13 Per Amundsen
OnEvent if ($event == PRIVMSG && $msg == herp) { /msg $channel derp } }</pre>
124 7 Per Amundsen
125 1 Per Amundsen
if the event is a PRIVMSG AND the $msg equals "herp", then show "derp" in the channel
126
127 6 Per Amundsen
<pre>
128 13 Per Amundsen
OnEvent if ($event == PRIVMSG) { if ($nick == Q || $nick == $me) { /msg $channel Q or $me is speaking! } }</pre>
129 1 Per Amundsen
130
if the event is a PRIVMSG and the $nick equals "Q" OR $me then show "Q or $me is speaking" in the channel
131 9 Per Amundsen
132 34 Per Amundsen
<pre>OnEvent if ($event == OnOp && $nick == $me) { /msg $channel Thx for op! }</pre>
133
134 35 Per Amundsen
if the event is OnOp and the target nick is me, then show "Thx for op!" in the channel
135
136 3 Per Amundsen
A list of custom events that is also usable as $event ==
137 4 Per Amundsen
<pre>
138 3 Per Amundsen
OnOwner
139
OnDeOwner
140
OnSpecialOp
141
OnSpecialDeOp
142
OnOp
143
OnDeOp
144
OnHop
145
OnDeHop
146
OnVoice
147 13 Per Amundsen
OnDeVoice</pre>