Project

General

Profile

Scripting » History » Revision 167

Revision 166 (Per Amundsen, 05/19/2013 12:02 AM) → Revision 167/246 (Per Amundsen, 08/02/2013 02:12 AM)

h1. Scripting changes as of 1.9.1 1.9.0 

 h1. Implemented mIRC events so far: 

 <pre> 
 raw <numeric>:<matchtext>:<commands> 

 ctcp <level>:<matchtext>:<*|#|?>:<commands> 

 on 1:sockopen:name:commands 

 on 1:sockread:name:commands 

 on 1:socklisten:name:commands 

 on 1:sockclose:name:commands 

 on *:SIGNAL:name:command 

 on <level>:LOGON:*:<commands> 

 on <level>:DNS:<commands> 

 on <level>:CTCPREPLY:<matchtext>:<commands> 

 on <level>:OPEN|CLOSE:<?|@|=|!|*>:<matchtext>:<commands> 

 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 is added as a replacement for OnSongChanged 
 on <level>:SONG:<commands> 

 </pre> 

 Supported prefixes so far are ^ to enable halt events (hide default text output from the event), ! to ignore events made by you, @ to only trigger if you have channel op, $ to indicate the wildcard text is a regular expression. 

 User access will come later.  

 h1. Functions added so far 

 <pre> 
 $abs() 
 $acos() 
 $address() 
 $addtok() 
 $addtokcs() 
 $and() 
 $asc() 
 $asctime() 
 $asin() 
 $atan() 
 $audio() 
 $base() 
 $bfind() 
 $bindip() 
 $bitoff() 
 $biton() 
 $bvar() 
 $bytes() 
 $calc() 
 $cb() 
 $ceil() 
 $chan() 
 $char() 
 $chat() 
 $chr() 
 $color() 
 $colour() 
 $comchan() 
 $cos() 
 $count() 
 $countcs() 
 $crc() 
 $ctime() 
 $datediff() 
 $datematch() 
 $decode() 
 $decrypt() 
 $deltok() 
 $dialog() 
 $did() 
 $didreg() 
 $didtok() 
 $didwm() 
 $disk() 
 $diskmenu() 
 $dns() 
 $duration() 
 $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 

 <pre> 
 $0 
 $active 
 $activeserver 
 $activewid 
 $adate 
 $address 
 $adiircdir 
 $adiircexe 
 $adiircini 
 $album 
 $anick 
 $appactive 
 $appstate 
 $artist 
 $audio 
 $away 
 $awaymsg 
 $awaytime 
 $bitrate 
 $bwdown 
 $bwdownb 
 $bwname 
 $bwspeed 
 $bwup 
 $bwupb 
 $cb 
 $chan 
 $chanmodes 
 $channel 
 $chantypes 
 $cid 
 $clevel 
 $cmdline 
 $comment 
 $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 
 $ial 
 $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 
 $myident 
 $network 
 $newnick 
 $nick 
 $now 
 $null 
 $numeric 
 $online 
 $os 
 $osbuild 
 $osedition 
 $osmajor 
 $osminor 
 $osname 
 $osservicepack 
 $osversion 
 $percentl 
 $percentp 
 $playcount 
 $player 
 $port 
 $position 
 $prefix 
 $progress 
 $r 
 $r0 
 $raw0 
 $rawbytes 
 $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 

 <pre> 
 /aclear 
 /action 
 /advertise 
 /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 
 /dec 
 /dehalfop 
 /deop 
 /describe 
 /desop 
 /devoice 
 /dialog 
 /did 
 /didtok 
 /disable 
 /disconnect 
 /dns 
 /dop 
 /drawcopy 
 /drawdot 
 /drawfill 
 /drawline 
 /drawpic 
 /drawrect 
 /drawreplace 
 /drawsave 
 /drawscroll 
 /drawtext 
 /echo 
 /editbox 
 /enable 
 /encoding 
 /exec 
 /exit 
 /fakeraw 
 /fclose 
 /filter 
 /flist 
 /fopen 
 /fseek 
 /fwrite 
 /gcmem 
 /google 
 /google 
 /goto 
 /hadd 
 /halfop 
 /halt 
 /haltdef 
 /hdec 
 /hdel 
 /help 
 /hfree 
 /hinc 
 /hload 
 /hmake 
 /hop 
 /hsave 
 /ignore 
 /inc 
 /join 
 /kick 
 /kickban 
 /kill 
 /lag 
 /linesep 
 /list 
 /load 
 /logs 
 /logview 
 /loopfile 
 /markall 
 /me 
 /menubar 
 /mkdir 
 /mode 
 /msg 
 /msgbox 
 /nick 
 /nickcolor 
 /nmsg 
 /nomsg 
 /noop 
 /noquery 
 /notice 
 /notify 
 /np 
 /onotice 
 /op 
 /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> 

 Not all are from mIRC, ill seperate the list later. 

 All operaters are added. 

 h1. Example scripts 

 Simple kickcounter script: 

 <pre> 
 alias kick {  
	 if (!%kickcount) %kickcount = 0 

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

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

	 var %msg = $iif(#, $2-, $3-) 
	 var %chan = $iif(#, #, $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 = GTFO 

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

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

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

 CTCP flood detection example 

 <pre> 
 CTCP *:*:*:{ 
	 if (!%count) set -u10 %count 1 
	 else inc -u10 %count 1 

	 if (%count > 4) ignore -tu30 $wildsite 
 } 
 </pre> 

 Mass mode example 

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

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

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

	 /echo You are on ( $+ %s $+ ) servers, ( $+ %c $+ ) channels with ( $+ %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 { 
	 return $calc($$1 + $$2); 
 } 
 </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 { 
	 echo -a $1 + $2 is $mycalc($1, $2); 
	 echo -a 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 { 
	 if ($1 == C) echo $calc(($2 * 9/5) + 32) F 
	 else if ($1 == F) echo $round($calc(($2 - 32) * 5/9), 1) C 
	 else echo Temp missing 
 } 
 </pre> 

 Announce song changes in a channel or to a user 
 <pre> 
 On *:SONG:{  
	 nmsg <network> <channel/Nick> $1- 
 } 
 </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 summary of a imdb url 
 <pre> 
 On *:TEXT:*:#k: { 
     var %reg = $regex($1-, http://www\.imdb\.com(/title/[a-z0-9]+/)) 
     if (!%reg) { return } 
     sockclose imdb 
     unset %data 
     %imdb = $regml(1) $+ plotsummary 
     %imdbchan = # 
     sockopen imdb www.imdb.com 80 
 } 

 on *:sockopen:imdb: { 
     sockwrite -n imdb GET %imdb HTTP/1.1 
     sockwrite -n imdb Host: www.imdb.com 
     sockwrite -n imdb User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.24 Safari/536.5 
     sockwrite -n imdb Referer: http://www.imdb.com 
     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 -n imdb Accept-Language: en-us, en;q=0.50 
     sockwrite -n imdb Connection: Close $+ $crlf $+ $crlf 
 } 

 on *:sockread:imdb:{ 
     sockread %text 
     %data = %data $+ %text  
 } 

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

     unset %data 
 } 
 </pre>