Project

General

Profile

Scripting » History » Version 148

Per Amundsen, 04/10/2012 07:28 AM

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