Project

General

Profile

Scripting » History » Revision 19

Revision 18 (Per Amundsen, 04/02/2011 09:08 PM) → Revision 19/246 (Per Amundsen, 04/02/2011 09:09 PM)

h1. Scripting 

 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. 

 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. 

 As of build 020411. 

 There are 2 types of scripting atm, one that have been here for a long time, and a new system. 

 All scripting is done in Commands -> Edit Commands where one line represent a script or a custom command. 

 Please note that variables and functions are *different* for these 2 types of scripts. 

 h1. Normal custom commands: 

 Here are some variables which can be used in Custom Commands, its like creating aliases of allready 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> 

 Current variables are $1 to $9, $pagearams, $chan and $me. $1 to $9 represents what you type after /yourcommand e.g <pre>/sup "/sup /say whats up $1</pre>, $1", when typing <pre>/sup kr0n</pre> /sup kr0n it will show like this <pre>User: "User: whats up kr0n</pre> kr0n". 

 $pagearam represents everything written after /yourcommand, $chan replaces itself with current channel and $me replaces itself with your current usernick.  

 You can make combo commands by using | as a seperator, e.g <pre>/hi /hi /me says hi to $chan|/me says hi again to $chan</pre> 

 $chan  

 $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). 

 h1. New Scripting 

 In Commands -> Edit Commands you can enter a scripting line with the following syntax: 

 The line must start with <pre>OnEvent<whitespace></pre> 

 Followed by either an expression like this (works recursivly) 

 <pre> 
 if (SOMETING == SOMETHINGELSE) { EXECUTE HERE } 
 if (SOMETING != SOMETHINGELSE) { EXECUTE HERE } 
 if (SOMETING ismatch SOMETHINGELSE) { EXECUTE HERE }</pre> 
 or by an executed command or function 

 You can now combine expressions with && (AND) and || (OR) like this 
 <pre> 
 if (SOMETHING == SOMETHING && SOMETHINGELSE != SOMETHINGELSE) { EXECUTE HERE } 
 if (SOMETHING == SOMETHING || SOMETHINGELSE != SOMETHINGELSE) { EXECUTE HERE }</pre> 
 The logic behind these expressions is not fully tested, id love any feedback on this. 

 (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) 

 Executed commands are /slash commands already in the client e.g /msg #channel hello world. 
 Executed functions are predefined functions in the client, only two exists for now. 

 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> 

 Furthermore there is a lot of predefined variables for use with these functions, for now they are: 

 $event / current event, e.g PRIVMSG 001 MODE and so forth 
 $channel / the channel the event occurred on, if any 
 $msg / the message to the channel/user or the message in a raw irc line e.g whois [kr0n] is a registered nick 
 $nick / the nick the event was sent from, can be a irc.server.com, a nick or null 
 $me / my current nick 
 $network / the network the event occured on e.g Quakenet 
 $ident / the from user ident if any 
 $host / the from user hostname if any 
 $myident / my ident 
 $myhost / my host 
 $server / host from the server e.g irc.server.com 

 Currently predefined functions are: 
 <pre> 
 .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> 

 <pre> 
 .eat <what (text or all)></pre> 
 .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. 

 .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. 

 Putting it all togheter, here are a few examples: 

 <pre> 
 OnEvent if ($event == NOTICE) { if ($msg ismatch hi there) { .insert $nick status MsgNotice $msg|.eat text } }</pre> 

 insert the notice into the server window and tells adiirc to "eat" its own text output from this notice 

 <pre> 
 OnEvent if ($event == PRIVMSG && $msg == herp) { /msg $channel derp } }</pre> 

 if the event is a PRIVMSG AND the $msg equals "herp", then show "derp" in the channel 

 <pre> 
 OnEvent if ($event == PRIVMSG) { if ($nick == Q || $nick == $me) { /msg $channel Q or $me is speaking! } }</pre> 

 if the event is a PRIVMSG and the $nick equals "Q" OR $me then show "Q or $me is speaking" in the channel 

 A list of custom events that is also usable as $event == 
 <pre> 
 OnOwner 
 OnDeOwner 
 OnSpecialOp 
 OnSpecialDeOp 
 OnOp 
 OnDeOp 
 OnHop 
 OnDeHop 
 OnVoice 
 OnDeVoice</pre>