Scripting » History » Revision 6
Revision 5 (Per Amundsen, 04/01/2011 06:24 PM) → Revision 6/246 (Per Amundsen, 04/01/2011 06:25 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 will still work in the next beta and so forth. As of build 010411. 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. 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 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 || PRIVMSG && $nick == $me) Q) { /msg $channel Q or $me is speaking! } } </pre> if the event is a PRIVMSG and the $nick equals "Q" then show "Q 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>