Project

General

Profile

Scripting » History » Version 25

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