Project

General

Profile

Scripting » History » Revision 166

Revision 165 (Per Amundsen, 09/19/2012 04:42 PM) → Revision 166/246 (Per Amundsen, 05/19/2013 12:02 AM)

h1. Notice: this is info for 1.8.10 and higher. 

 h1. Scripting changes as of 1.9.0 

 h1. Implemented NB. in next beta I will be aiming for 1:1 compatibility with mIRC events so far: scripting, much of these info will be invalidated, have that in mind when writing scripts. 

 <pre> 
 raw <numeric>:<matchtext>:<commands> *[[Scripting BETA]] Click here to see scripting in the latest beta versions.* 

 ctcp <level>:<matchtext>:<*|#|?>:<commands> You can write full scripts in Commands -> Edit Scripts or you can create one liners in Commands -> Edit Commands 

 on 1:sockopen:name:commands h1. Custom Commands: 

 on 1:sockread:name:commands Custom Commands are created in Commands -> Edit Commands 

 on 1:socklisten:name:commands Custom commands consists of differents ways to execute a script either by making your own command, or use a hotkey, you can also enter a full script as a one liner (for legacy reasons) 

 on 1:sockclose:name:commands *Alias* 
 <pre> 
 /hello /msg $channel hello everybody 
 </pre> 

 on *:SIGNAL:name:command This creates a alias named "/hello", everytime you type "/hello" the script "/msg $channel hello everybody" will be executed, you can use any script features here. 

 on <level>:DNS:<commands> *Hot keys* 
 <pre> 
 Ctrl&r /msg $channel hello everybody i pressed 'ctrl' and 'r' 
 </pre> 

 on <level>:CTCPREPLY:<matchtext>:<commands> Every time you press ctrl + r, the script "/msg $channel hello everybody i pressed 'ctrl' and 'r'" will be executed, you can use any script features her. 

 on <level>:OPEN|CLOSE:<?|@|=|!|*>:<matchtext>:<commands> You can comment out a command by putting a # in front of it. 

 on <level>:ACTIVE:<*#?=!@>:<commands> 

 on <level>:HOTLINK:<matchtext>:<*#?=!@>:<commands> 

 on <level>:INVITE:<#[,#]>:<commands> 

 on <level>:TABCOMP:<*#?=!@>:<commands> 

 on <level>:WALLOPS:<matchtext>:<commands> 

 on <level>:ERROR:<matchtext>:<commands> 

 on <level>:RAWMODE:#:<commands> 

 on <level>:DEHELP:<#[,#]>:<commands> 

 on <level>:HELP:<#[,#]>:<commands> 

 on <level>:DEVOICE:<#[,#]>:<commands> 

 on <level>:VOICE:<#[,#]>:<commands> 

 on <level>:DEOP:<#[,#]>:<commands> 

 on <level>:OP:<#[,#]>:<commands> 

 on <level>:INPUT:<*#?=!@>:<commands> 

 on <level>:UNBAN:<#[,#]>:<commands> 

 on <level>:BAN:<#[,#]>:<commands> 

 on <level>:CHAT:<matchtext>:<commands> 

 on <level>:KICK:<#[,#]>:<commands> 

 on <level>:NOTIFY:<commands> 

 on <level>:UNNOTIFY:<commands> 

 on <level>:NICK:<commands> 

 on <level>:QUIT:<commands> 

 on <level>:LOAD:<commands> 

 on <level>:UNLOAD:<commands>' 

 on <level>:START:<commands> 

 on <level>:EXIT:<commands> 

 on <level>:DNS:<commands> 

 on <level>:CONNECTFAIL:<commands> 

 on <level>:CONNECT:<commands> 

 on <level>:DISCONNECT:<commands> 

 on <level>:TOPIC:<#[,#]>:<commands> 

 on <level>:USERMODE:<commands> 

 on <level>:MODE:<#[,#]>:<commands> 

 on <level>:PART:<#[,#]>:<commands> 

 on <level>:JOIN:<#[,#]>:<commands> 

 on <level>:SNOTICE:<matchtext>:<commands> 

 on <level>:NOTICE:<matchtext>:<*><?><#[,#]>:<commands> 

 on <level>:ACTION:<matchtext>:<*><?><#[,#]>:<commands> 

 on <level>:TEXT:<matchtext>:<*><?><#[,#]>:<commands> 

 This event It is added as also possible to use a replacement for OnSongChanged 
 full script, but it has to be on <level>:SONG:<commands> one line, and the script editor is preferred. 

 </pre> h1. Scripts: 

 Supported prefixes so far *Events:* 
 There are ^ different ways to enable halt events (hide default text output from listen to the event), ! to ignore irc client/server events made by you, @ to only trigger if you have channel op, $ to indicate for legacy reasons. 
 On/OnEvent will be executed after the wildcard text is a regular expression. 

 User access event 
 OnBefore/OnBeforeEvent will come later.  

 h1. Functions added so far be executed before the event 

 <pre> 
 $abs() OnEvent if ($event == PRIVMSG) { /EXECUTE } 
 $acos() OnBeforeEvent if ($event == PRIVMSG) { /EXECUTE } 

 On PRIVMSG { /EXECUTE } 
 $address() OnBefore PRIVMSG { /EXECUTE } 

 OnBefore OnCommand { /EXECUTE } 
 $addtok() OnCommand /mode { /EXECUTE } 
 $addtokcs() </pre> 

 *Available events:* 
 $and() <pre> 
 $asc() SockOpen / Called when a script opens a socket 
 $asctime() SockRead / Called when a socket have data to read 
 $asin() SockOpen / Called when a script socket is closed 

 OnLoad / Called when the script is loaded 
 $atan() OnUnload / Called when the script is unloaded 
 $audio() OnReload / Called when the script is reloaded 
 $base() OnConnecting / Called when a server is connecting 
 $bfind() OnLookingUp / Called when a server is looking up the hostname 
 $bindip() OnConnected / Called when a server is connected 
 $bitoff() OnDisconnect / Called when a server gets disconnected 
 $biton() OnCommand / Called whenever a user types a /slash command in the client ($0- will hold the full command, $0 will be the first word, $1 the second and so on) 

 OnCTCPRequest / Called when a user recives a CTCP request 
 $bvar() OnCTCPReply / Called when a user recives a CTCP reply 
 $bytes() OnDCCRequest / Called when a user recived a DCC request 

 OnNickChanged / Called when a user's nick changes, will only trigger on the user unlike NICK who triggers for everyone 
 $calc() OnSongChanged / Called when a song is changed in the selected media player 

 OnDeVoice / Called when a user gets devoiced 
 $cb() OnVoice / Called when a user gets voiced 
 $ceil() OnDeHop / Called when a user gets dehalfoppeed 
 $chan() OnHop / Called when a user gets halfopped 
 $char() OnOp / Called when a user gets opped 
 $chat() OnDeOp / Called when a user gets deopped 
 $chr() OnDeOwner/ Called when a user gets owner deopped 
 $color() OnOwner/ Called when a user gets owner opped 
 $colour() OnDeSop / Called when a user gets special deopped 
 $comchan() OnSop / Called when a user gets special opped 

 MODE / Called whenever a channel or user mode is changed 
 $cos() JOIN / Called whenever a user joins a channel 
 $count() PART / Called when a user parts a channel  
 NICK / Called when a user changes their nick 
 $countcs() TOPIC / Called when a topic is set/changed 
 $crc() KICK / Called when any user gets kicked 
 $ctime() NOTICE / Called when any notice is recived 
 $datediff() QUIT / Called when a user quits irc 
 $datematch() PRIVMSG / Called when any message is recived 
 $decode() WHOIS / Called when any whois reply is recived 
 $decrypt() LIST / Called when a user gets a /list 
 $deltok() KILL / Called when a user gets killed 
 $dialog() ACTION / Called when a user recives a ACTION (/me) message 

 <irc numeric> / Called when a raw irc line with <irc numeric> is recived 
 $did() <irc textual> / Called when a raw irc line with <irc textual> is recived 
 $didreg() </pre> 

 *if/else if/else blocks:* 

 You can use any combination of if, else if, else and while 
 $didtok() <pre> 
 $didwm() OnEvent if ($event == PRIVMSG) {  
	 if (%test == null) {  
		 /echo Hello world 
		 if (%test == null) {  
			 /echo Hello world 
		 } 
		 else /echo Hello World 
	 } else if (%test == null) {  
		 /echo Hello world 
	 } else (%test == null) {  
		 /echo Hello world  
	 }  

	 if (%test == null) {  
		 /echo Hello world 
		 while (%test == null) { 
			 /echo Hello world 
		 } 
	 } 

	 if(%test == null)/echo Hello World 
	 else if(%test == null)/echo Hello World 
	 else/echo Hello world 
	
	 if(%test == null){/echo Hello World 
	 }else if(%test == null){/echo Hello World 
	 }else{/echo Hello World 
	 } 

	 if(%test == null){/echo Hello World}else if(%test == null){/echo Hello World}else{/echo Hello World} 
 $disk() } 
 $diskmenu() </pre> 

 *while blocks:* 
 $dns() <pre> 
 $duration() On JOIN { 
	 var %t = 0 
	 /echo There are ($user($chan, 0)) users in ($chan) 
	
	 while (%t < $user($chan, 0)) { 
		 %t++ 
		 var %nick = $user($chan, %t) 
		 /echo User (%t) is (%nick) and is $iif(%nick isop $chan, opped, not opped) 
	 } 
 $editbox() } 
 $encode() 
 $encodingmenu() 
 $encrypt() 
 $eval() 
 $exists() 
 $fdate() 
 $fgetc() 
 $file() 
 $fileexists() 
 $fileloop() 
 $filerandom() 
 $finddir() 
 $findfile() 
 $findtok() 
 $findtokcs() 
 $fline() 
 $floop() 
 $floor() 
 $fopen() 
 $formatdate() 
 $frand() 
 $fread() 
 $freadc() 
 $freadchar() 
 $getdir() 
 $getdot() 
 $gettok() 
 $gfx() 
 $gfxram() 
 $group() 
 $height() 
 $hfind() 
 $hget() 
 $host() 
 $ial() 
 $ialchan() 
 $ibl() 
 $ident() 
 $iel() 
 $ignore() 
 $iil() 
 $inellipse() 
 $ini() 
 $inpoly() 
 $input() 
 $inrect() 
 $insert() 
 $instok() 
 $int() 
 $invitemenu() 
 $isalias() 
 $isbit() 
 $isdir() 
 $isfile() 
 $isid() 
 $islower() 
 $istok() 
 $istokcs() 
 $istype() 
 $isupper() 
 $left() 
 $len() 
 $line() 
 $lines() 
 $log() 
 $longfn() 
 $longip() 
 $lower() 
 $mask() 
 $matchtok() 
 $matchtokcs() 
 $md5() 
 $mid() 
 $mkfn() 
 $mklogfn() 
 $mknickfn() 
 $mp3() 
 $msfile() 
 $nick() 
 $nofile() 
 $nopath() 
 $noqt() 
 $not() 
 $notify() 
 $numtok() 
 $or() 
 $ord() 
 $pic() 
 $portfree() 
 $pos() 
 $poscs() 
 $prop() 
 $puttok() 
 $qt() 
 $query() 
 $r() 
 $rand() 
 $read() 
 $readini() 
 $regex() 
 $regmatch() 
 $regml() 
 $regreplace() 
 $regsub() 
 $regsubex() 
 $remove() 
 $removecs() 
 $remtok() 
 $remtokcs() 
 $repeat() 
 $replace() 
 $replacecs() 
 $replacex() 
 $replacexcs() 
 $reptok() 
 $reptokcs() 
 $rgb() 
 $right() 
 $round() 
 $scid() 
 $scon() 
 $screen() 
 $screenb() 
 $screenh() 
 $screenw() 
 $script() 
 $sdir() 
 $server() 
 $sfile() 
 $sha1() 
 $shortfn() 
 $sin() 
 $slapsmenu() 
 $sline() 
 $snick() 
 $sock() 
 $sorttok() 
 $sorttokcs() 
 $sqrt() 
 $str() 
 $strip() 
 $style() 
 $substr() 
 $tan() 
 $time() 
 $timer() 
 $tip() 
 $toolbar() 
 $true() 
 $trust() 
 $upper() 
 $uptime() 
 $user() 
 $utfdecode() 
 $utfencode() 
 $var() 
 $vol() 
 $width() 
 $wildtok() 
 $wildtokcs() 
 $window() 
 $xor() 
 </pre> 

 h1. Variables added so far *goto/label:* 

 <pre> 
 $0 OnCommand /goto { 
	 var %loop = 0  
	 if ($1 == 1) { 
		 goto 1 
	 } else if ($1 == 2) { 
		 goto 2 
	 } else if ($1 == loop) { 
		 :3 
		 /echo you typed loop 
		 %loop++ 
		 if (%loop < 5) { 
			 goto 3 
		 } 
		 return 
	 } else { 
		 goto 4 
	 } 

	 :1 
	 /echo You typed 1 
	 return 
	 :2 
	 /echo You typed 2 
	 return 
	 :4 
	 /echo The end 
	 return 
 $active } 
 $activeserver </pre> 

 *client variables:* 
 $activewid All client variables starts with $ 

 <pre> 
 $adate $event / current event, e.g PRIVMSG 001 MODE and so forth 
 $address 
 $adiircdir 
 $adiircexe 
 $adiircini 
 $album 
 $anick 
 $appactive 
 $appstate 
 $artist 
 $audio 
 $away 
 $awaymsg 
 $awaytime 
 $bitrate 
 $bwdown 
 $bwdownb 
 $bwname 
 $bwspeed 
 $bwup 
 $bwupb 
 $cb 
 $chan 
 $chanmodes 
 $channel / the channel the event occurred on, if any 
 $chantypes $msg / the message to the channel/user or the message in a raw irc line e.g whois [kr0n] is a registered nick 
 $cid $nick / the nick the event was sent from, can be a irc.server.com, a nick or null 
 $clevel $me / my current nick 
 $cmdline $network / the network the event occured on e.g Quakenet 
 $comment $ident / the from user ident if any 
 $cpucache 
 $cpucount 
 $cpuident 
 $cpuload 
 $cpumhz 
 $cpuname 
 $cr 
 $crlf 
 $ctime 
 $date 
 $day 
 $daylight 
 $disk 
 $diskfree 
 $disktotal 
 $dlevel 
 $duration 
 $error 
 $event 
 $false 
 $feof 
 $ferr 
 $frequency 
 $fulladdress 
 $fulldate 
 $fulltitle 
 $genre 
 $getdir 
 $gfx 
 $gfxram 
 $gmt 
 $highlight 
 $host / the from user hostname if any 
 $ial $myident / my ident 
 $ident 
 $idle 
 $ignore 
 $inmidi 
 $inpaste 
 $insong 
 $inwave 
 $ip 
 $isid 
 $layer 
 $left 
 $length 
 $logdir 
 $logstamp 
 $logstampfmt 
 $lr 
 $ltimer 
 $maddress 
 $matchkey 
 $me 
 $memfree 
 $memfreep 
 $memtotal 
 $mircdir 
 $mircexec 
 $mircini 
 $mnick 
 $mode 
 $modespl 
 $motherboard 
 $mversion 
 $myhost / my host 
 $myident $server / host from the server e.g irc.server.com 
 $network 
 $newnick 
 $nick 
 $now / returns unixtime/ctime from current time. 
 $null $active / returns the current window Status/#channel/Nick. 
 $numeric $activeserver / returns an id for current server 
 $online $status / returns current server status 
 $os $crlf / returns newline \r\n 
 $osbuild $0-$9 / will return parts of the $msg, $<number>- will combine parts of the $msg from 0 to <number>. $0- will return everything 
 $osedition $! / returns how many $0 $1 etc variables are filled (not sure if final name of it) 
 $osmajor $raw0-$raw9 / will return parts of the raw message, $raw<number>- will combine parts of the raw message from 0 to <number>. $raw0- will return everything 
 $osminor 
 $osname 
 $osservicepack 
 $osversion 
 $percentl 
 $percentp 
 $playcount 
 $player 
 $port 
 $position 
 $prefix 
 $progress 
 $r 
 $r0 
 $r! / returns how many $raw0 $raw1 etc variables are filled (not sure if final name of it) 
 $rawbytes $+ / use to combine variables output e.g "$now $+ $server" 
 $rawmsg 
 $result 
 $screen 
 $screenb 
 $screenh 
 $screenw 
 $script 
 $scriptdir 
 $scriptline 
 $server 
 $serverip 
 $show 
 $site 
 $size 
 $sockbr 
 $song 
 $status 
 $target 
 $ticks 
 $time 
 $timestamp 
 $timestampfmt 
 $timezone 
 $title 
 $totaltracks 
 $track 
 $true 
 $ulevel 
 $updays 
 $uphours 
 $upmins 
 $usermode 
 $version 
 $volume 
 $volumeb 
 $volumep 
 $wid 
 $wildsite 
 $window 
 $year 
 </pre> 

 Commands added so far All sysinfo/mediaplayer variables are available as well. 

 <pre> *user set variables:* 
 /aclear All user set variables starts with % 

 var %variable = 4242, %variable2 = 4343; will create local variables that gets deleted when the script is done. 
 /action using += instead of = will append to the variable, if both variable and new value is numbers it will combine them to a new number %variable += 4242. 

 If a variable is created without var, the variable will be available to all scripts, saved to a file and restored when AdiIRC is started. 

 Commands for manipulating variables: 
 /advertise <pre> 
 /ajinvite 
 /alias 
 /aline 
 /alphaup 
 /amark 
 /ame 
 /amsg 
 /anick 
 /aquit 
 /away 
 /back 
 /background 
 /ban 
 /banlist 
 /bcopy 
 /beep 
 /betaup 
 /bin2txt 
 /bindip 
 /bread 
 /break 
 /breplace 
 /bset 
 /btrunc 
 /bunset 
 /bwrite 
 /channel 
 /channelbar 
 /charset 
 /clear 
 /clearall 
 /clipboard 
 /close 
 /closefile 
 /color 
 /config 
 /continue 
 /ctcp 
 /ctcpreply 
 /cycle 
 /dcc 
 /debug 
 /set {-u seconds/-d] [%var] [value] / create or update a variable with value -u seconds, will delete the variable after X seconds, -d will decrease its value by 1 every second, then remove it 

 /unset [var] / deletes a variable 

 /inc {-u seconds/-d] [%var] [value] / increases a variable with value (only if value and var is ints) -u seconds, will delete the variable after X seconds, -d will decrease its value by 1 every second, then remove it 

 /dec {-u seconds/-d] [%var] [value] / decreases a variable with value (only if value and var is ints) -u seconds, will delete the variable after X seconds, -d will decrease its value by 1 every second, then remove it 

 /vars shows a list of all variables and their values 
 /dehalfop </pre> 

 *functions:* 
 /deop Several functions are exsists, they are all recursive and you can use any %variable or $variable as parameters: 
 /describe They are also usable inside if () else if () while () statements. 
 /desop All variable numbers are floats and all functions supports floats for precise calculations. 

 <pre> 
 /devoice $replace(text, text2, text3) / replace all occurrences of text2 in text with text3 
 /dialog $upper(text) / return text uppercase 
 /did $lower(text) return text lowercase 
 /didtok $mid(text, startpos, endpos) / return part of text from startpos to endpos 
 /disable $substr(text, startpos, endpos) / return part of text from startpos to endpos 
 /disconnect $left(text, pos) / return pos characters starting from left of the text 
 /dns $right(text, pos) / return pos characters starting from right of the text 
 /dop $remove(text, text2) / replace all occurrences of text2 from text 
 /drawcopy $len(text) / return length of text 
 /drawdot $count(text, text2) / counts all occurrences of text2 in text 
 /drawfill $pos(text, text2) / returns first occurrences position of text2 in text 
 /drawline $lastpos(text, text2) / returns last occurrences position of text2 in text 
 /drawpic $strip(text) / removes all color and font tags 
 /drawrect $repeat(text, times) / repeats text X times 
 /drawreplace $insert(text, text2, pos) / inserts text2 into pos of text 
 /drawsave $chr(num) / returns ascii character from the number num 
 /drawscroll $char(num) / returns ascii character from the number num 

 $calc(formula) / calculate any variation of +-*/ 
 /drawtext $formatdate(date, text) / formats a unix timestamp into date using date variables %d %m %y etc 
 /echo $fdate(date, text) / formats a unix timestamp into date using date variables %d %m %y etc 
 /editbox $ctime(datestamp) / converts most variations of a date stamp to unix/ctime 
 /enable $datediff(ctime1, ctime2) / diffs two unix/ctime and fills the $datematch array with values 
 /encoding $datematch(num) / returns part of a $datediff, 0 = milliseconds, 1 = seconds, 2 = minutes, 3 = hours, 4 = days 
 /exec $host(nick) / returns the hostmask of nick 
 /exit $ident(nick) / returns the ident of nick 
 /fakeraw $(number) / dynamically gets a $0 $1 $2 variable e.g $(1) is same as $1 (not sure if final function name) 
 /fclose $cond(cond, execute1, execute2) / checks if cond is true then executes execute1, else executes execute2, will return string if not at the begining of the line 
 /filter $iif(cond, execute1, execute2) / checks if cond is true then executes execute1, else executes execute2, will return string if not at the begining of the line 
 /flist $round(num, decimals) / rounds down a float to X decimals 
 /fopen $regex(text, pattern) / does a regular expression test if text matches pattern, then returns the matched part 
 /fseek $regmatch(num) / returns the captured group at pos num from a $regex. 0 returns group count 
 /fwrite $regreplace(text, pattern, text2) / replace any occurence in text of patterh with text2 where pattern is a regular expression 

 $file(path) / reads file to end and returns the entire output without newlines 
 /gcmem $fileloop(path) / reads through a file one line at the time, line increases +1 every time the same file is called 
 /google $floop(path) / reads through a file one line at the time, line increases +1 every time the same file is called 
 /google $filerandom(path) / returns a random line from a file 
 /goto $frand(path) / returns a random line from a file 
 /hadd $fread(name) / reads a line from current pos in file named name 
 /halfop $fileread(name) / reads a line from current pos in file named name 
 /halt $freadc(name) / reads a char/byte from current pos in file named name 
 /haltdef $freadchar(name) / reads a char/byte from current pos in file named name 
 /hdec $fsize(file) / returns size off file in bytes 
 /hdel $filesize(file) / returns size off file in bytes 
 /help $fpos(name) / returns current position/byte in file named name 
 /hfree $filepos(name) / returns current position/byte in file named name 
 /hinc $flines(file) / returns amount of lines in file 
 /hload $filelines(file) / returns amount of lines in file 
 /hmake $fileexists(file) / returns if file exists or not 
 /hop $isfile(file) / returns if file exists or not 

 $chan(num) / if num is 0 returns how many channels you are joined on this server else returns channel name in position num 
 /hsave $user(#chan, num) / if num is 0 returns how many users are on this #chan else returns nick in position num 
 /ignore $nick(#chan, num) / if num is 0 returns how many users are on this #chan else returns nick in position num 
 /inc $server(num) / if num is 0 returns how many servers you are connected to else returns server id in position num 

 $sread(name) / reads available bytes from socket named name (on sockread) 
 /join $sockread(name) / reads available bytes from socket named name (on sockread) 
 /kick $sbytes(name) / returns amount of available bytes to be read from socket named name 
 /kickban $sockbytes(name) / returns amount of available bytes to be read from socket named name 
 /kill </pre> 

 *operators:* 

 All operators can use ! to reverse the logic e.g !ison.  
 If no operators are added it will test if remaining text is not null if (%test), if ($channel) or if (!$channel) etc. 

 <pre> 
 /lag == / Will check if left and right string or int is the same 
 /linesep > / Will try and cast left and right variable to int and try "int1 greater than int2" 
 /list < / Will try and cast left and right variable to int and try "int1 lower than int2" 
 /load >= / Will try and cast left and right variable to int and try "int1 greater than or equal to int2" 
 /logs <= / Will try and cast left and right variable to int and try "int1 lower than or equal to int2" 
 /logview isbetween / Will try and cast left variable to int and right variable have to be int-int, e.g "40 isbetween 30-50" 
 /loopfile ison / check if ($nick ison $channel) nick is the channel 
 /markall isop / check if ($nick isop $channel) is operator on the channel 
 /me ishop / check if ($nick ishop $channel) is half operator on the channel 
 /menubar issop / check if ($nick issop $channel) is special operator on the channel 
 /mkdir isowner / check if ($nick isowner $channel) is channel owner 
 /mode hasvoice / check if ($nick hasvoice $channel) have voice on the channel 
 /msg inchan / check if i am in chan (#channel inchan) (#channel !inchan) 
 /msgbox isnum / check something is a number (5 isnum) (5 !isnum) 
 /nick ismatch / will check if left contains right value or right contains left value 
 /nickcolor isin / same as ismatch except only checking if left value is in right value, ismatch checks both 
 /nmsg </pre> 

 *tips:* 
 /nomsg / is not needed to execute a command in scripts e.g /echo and echo is the same. 
 /noop use null to check for nothing "if ($nick == null)" 
 /noquery Comment out a line with # or several lines with /* code */ 
 /notice All paths needs to be escaped e.g c:\\users\\kr0n\\file.txt if only a filename is entered, the script directory will be used. 
 /notify All characters that needs to be escaped before used as strings are \ { } ; 
 /np In some cases you might have to escape ( ) | , # $ % 
 /onotice ; as a newline "/echo 1; /echo 2" is the same as 
 /op /echo 1 
 /openfile 
 /part 
 /paths 
 /pgoogle 
 /pgoogle 
 /priv 
 /query 
 /quit 
 /quote 
 /raw 
 /rawlog 
 /reconnect 
 /rejoin 
 /reload 
 /remini 
 /remove 
 /rename 
 /reseterror 
 /resolve 
 /restart 
 /return 
 /rmdir 
 /run 
 /runloop 
 /say 
 /scid 
 /sclose 
 /scon 
 /search 
 /seekfile 
 /server 
 /serverlist 
 /set 
 /setoption 
 /sidebar 
 /signal 
 /slap 
 /sleep 
 /smsg 
 /sockaccept 
 /sockclose 
 /socklist 
 /socklisten 
 /sockmark 
 /sockopen 
 /sockpause 
 /sockread 
 /sockrename 
 /sockwrite 
 /sop 
 /sopen 
 /splay 
 /split 
 /statusbar 
 /swrite 
 /tab 
 /tester 
 /time 
 /timer 
 /titlebar 
 /tokenize 
 /toolbar 
 /topic 
 /txt2bin 
 /unban 
 /unignore 
 /unload 
 /unnotify 
 /unset 
 /update 
 /var 
 /vars 
 /viewlog 
 /voice 
 /vol 
 /wdown 
 /window 
 /wjump 
 /wnext 
 /wpause 
 /wplay 
 /wprev 
 /write 
 /writefile 
 /writeini 
 /wsearch 
 /wseekf 
 /wseekr 
 /wselect 
 /wstop 
 /wup 
 </pre> /echo 2 

 Not all are from mIRC, ill seperate "halt" will halt the list later. script immediately, telling the client to eat the event and ignoring the rest of the script. 
 "return" will halt immediately, ignoring rest of the script, but not eat anything. 

 All operaters are added. 

 h1. Example scripts 

 Simple kickcounter script: 

 <pre> 
 alias kick OnBefore OnCommand {  
	 if (!%kickcount) ($0 != /kick)    return 
		
	 if (%kickcount == null) %kickcount = 0 

	 inc %kickcount %kickcount++ 
		 
	 if (!$3) ($2 == null) {  
		 kick # $$2 /kick $channel $1 Kick number %kickcount 
		 halt 
	 }  
 } 
 </pre> 

 Kickban example 
 <pre> 
 alias kb OnCommand /kb { 
	 if (!$1) { 
		 echo /echo /kb - Nick missing 
		 return 
	 } 

	 var %msg = $iif(#, $iif($channel, $2-, $3-) 
	 var %chan = $iif(#, #, $iif($channel, $channel, $2) 
		
	 ; # Set this for default ban reason, or remove for no default reason 
	 ; # Can be shortened to %msg = $iif(%msg, %msg, GTFO) 
	 if (!%msg) (%msg == null) %msg = GTFO 

	 if ($me isop %chan) { 
		 /raw MODE %chan +b $wildsite *!$ident($1)@$host($1) 
		 /raw KICK %chan $1 %msg 
	 }  
	 else echo /echo You are not oper on %chan 
 } 
 </pre> 

 Simple calculator script: 
 <pre> 
 alias calc OnCommand /calc { 
	 if (!$1) { 
		 echo /echo /calc - Parameters missing 
		 return 
	 } 
		
	 ; # typing /calc -p <expression> sends output to channel 
	 if ($1 == -p) { 
		 msg # /msg $channel Calculating : $2- 
		 msg # /msg $channel Result is : $calc($2-) 
	 } else { 
		 echo /echo Calculating : $1- 
		 echo /echo Result is : $calc($1-) 
	 } 
 } 
 </pre> 

 Colored version 
 <pre> 
 alias calc OnCommand /calc { 
	 if (!$1) { 
		 echo /echo /calc - Parameters missing 
		 return 
	 } 
	
	 # typing /calc -p <expression> sends output to channel 
	 if ($1 == -p) { 
		 msg # /msg $channel $chr(3)4Calculating : $2- 
		 msg # /msg $channel $chr(3)4Result is : $calc($2-) 
	 } else { 
		 echo /echo $chr(3)4Calculating : 4$1- 
		 echo /echo $chr(3)4Result is : $calc($1-) 
	 } 
 } }*/ 
 </pre> 

 CTCP flood detection example 

 <pre> 
 CTCP *:*:*:{ On OnCTCPRequest { 
	 if (!%count) set -u10 (%count == null) /set -u 10 %count 1 
	 else inc -u10 /inc -u 10 %count 1 

	 if (%count > 4) ignore -tu30 $wildsite /ignore    -u 30 -t $nick!$ident@$host 
 } 
 </pre> 

 Mass mode example 

 <pre> 
 alias mass OnCommand /mass { 
	 if (!$2) { 
		 echo /echo /mass - Parameters missing [+/-<mode> <nick> <nick> <nick>] 
		 return 
	 } 

	 %len = 2 
	
	 ; # equal to while (%len <= $count(%1-, $count(%0-, $chr(32))) 
	 while (%len <= $0) $!) { 
		 if ($(%len) ison #) mode # $channel) /mode $channel $1 $($ $+ %len) $(%len) 
		 inc /inc %len 
	 } 
 } 
 </pre> 

 Shows info about servers, channels and users 
 <pre> 
 on *:JOIN:#: On JOIN { 
	 var %s = $server(0), %c = 0, %u = 0, %t = 0, %c2 = 0; 
	
	 while (%t < %s) { 
		 inc %t %t++ 
		 setserver /setserver $server(%t); 
		 %c += $chan(0) 
	
		 %c2 = 0 
		 while (%c2 < $chan(0)) { 
			 in %c2 %c2++ 
			 %u += $user($chan(%c2), 0) 
		 } 
	 } 

	 /echo You are on ( $+ %s $+ ) (%s) servers, ( $+ %c $+ ) (%c) channels with ( $+ %u $+ ) (%u) users 
 } 
 </pre> 

 It is possible to use scripts as functions. 
 These functions are fully nested like the client functions. 

 Lets say you make a /mycalc like this. 
 <pre> 
 alias mycalc OnCommand /mycalc { 
	 return $calc($$1 + $$2); $calc($0+$1); 
 } 
 </pre> 

 Then you can call this function with eiter /mycalc <number> <number> the normal way or $mycalc(<number, <number>) 
 Typing /testcalc will show the result. 
 <pre> 
 alias testcalc OnCommand /testcalc { 
	 echo -a /echo $0 + $1 + $2 is $mycalc($1, $2); $mycalc($0, $1); 
	 echo -a /echo 5 + 4 is $mycalc(5, 4); 
 } 
 </pre> 

 Simple convert temperature C to F or F to C 
 /temp C 20 will print 68 F 

 <pre> 
 alias temp OnCommand /temp { 
	 if ($1 == C) echo /echo $calc(($2 * 9/5) + 32) F 
	 else if ($1 == F) echo /echo $round($calc(($2 - 32) * 5/9), 1) C 
	 else echo /echo Temp missing 
 } 
 </pre> 

 Announce song changes in Test if input contains a channel or to a user link 
 <pre> 
 On *:SONG:{  
	 nmsg <network> <channel/Nick> $1- OnCommand /testlink { 
	 if (!$1) { 
		 /echo Link missing 
		 return 
	 } 

	 /echo $iif($regex($1, (?i)\\b((?:[a-z][\\w-]+:(?:/\{1\,3\}|[a-z0-9%])|www\\d\{0\,3\}[.]|[a-z0-9.\\-]+[.][a-z]\{2\,4\}/)(?:[^\\s()<>]+|\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\))+(?:\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\)|[^\\s`!()\\[\\]\\\{\\\}\\\;:'".\,<>?«»“”‘’]))), yes, no) 
 } 
 </pre> 

 Announce to several channels with: 
 <pre> 
 On *:SONG:{  
	 nmsg <network> <channel1/Nick>,<channel2/Nick> $1- 
	 nmsg <network2> <channel3/Nick> $1-  
 } 
 </pre> 

 Automatically find the Retrives plot summary of a imdb url from captured imbd links 
 <pre> 
 On *:TEXT:*:#k: PRIVMSG { 
     
	 var %reg = $regex($1-, http://www\.imdb\.com(/title/[a-z0-9]+/)) 
     $regex($0-, http://www\\.imdb\\.com(/title/[a-z0-9]+/)) 
	 if (!%reg) { return } 
     sockclose 
		
	 /sockclose imdb 
     unset %data 
     
	 %text = null 
	 %imdb = $regml(1) $+ plotsummary 
     $regmatch(1)plotsummary 
	 %imdbchan = # 
     sockopen $channel 
	 /sockopen imdb www.imdb.com 80 
 } 

 on *:sockopen:imdb: On SockOpen { 
     sockwrite 
	 if ($1 != imdb) { return } 

	 /sockwrite -n imdb GET %imdb HTTP/1.1 
     sockwrite 
	 /sockwrite -n imdb Host: www.imdb.com 
     sockwrite 
	 /sockwrite -n imdb User-Agent: Mozilla/5.0 (Windows NT 6.1; 6.1\; WOW64) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.24 Safari/536.5 
     sockwrite 
	 /sockwrite -n imdb Referer: http://www.imdb.com 
     sockwrite 
	 /sockwrite -n imdb Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,video/x-mng,image/png,image/jpeg,image/gif;q=0.2,text/css,*/*;q=0.1 
     sockwrite text/xml,application/xml,application/xhtml+xml,text/html\;q=0.9,text/plain\;q=0.8,video/x-mng,image/png,image/jpeg,image/gif\;q=0.2,text/css,*\/*\;q=0.1 
	 /sockwrite -n imdb Accept-Language: en-us, en;q=0.50 
     sockwrite en\;q=0.50 
	 /sockwrite -n imdb Connection: Close $+ $crlf $+ $crlf Close$crlf 
 } 

 on *:sockread:imdb:{ 
     sockread On SockRead { 
	 if ($1 != imdb) { return } 
		
	 %text 
     %data = %data $+ %text  
 += $sockread(imdb) 
 } 

 on *:sockclose:imdb: On SockClose { 
     
	 if ($regex(%data, ($1 != imdb) { return } 
	
	 if ($regex(%text, <p class="plotpar">([\s\S]*?)<i>)) class="plotpar">([\\s\\S]*?)<i>)) { 
         msg 
		 /msg %imdbchan $regml(1) 
     $regmatch(1) 
	 } 

     unset %data 

	 %text = null 
 } 
 </pre> 

 An example showing the difference between dates 
 <pre> 
 OnCommand /test { 
	 $datediff($ctime(1/1 2042), $now) 
	
	 var %text = Difference is 
	 %text += $chr(32)$datematch(4) $iif($datematch(4) == 1, day, days) 
	 %text += $chr(32)$datematch(3) $iif($datematch(3) == 1, hour, hours)  
	 %text += $chr(32)$datematch(2) $iif($datematch(3) == 1, minut, minutes)  
    
	 /echo %text 
 } 
 </pre> 

 Announce song changes in a channel or to a user 
 <pre> 
 On OnSongChanged {  
	 /nmsg <network> <channel/Nick> $0- 
 } 
 </pre> 

 Announce to several channels with: 
 <pre> 
 On OnSongChanged {  
	 /nmsg <network> <channel1/Nick>,<channel2/Nick> $0- 
	 /nmsg <network2> <channel3/Nick> $0-  
 } 
 </pre>