; ################################### ; ; Basic v23042002 ; blue-elf, belf@mircscripter.com ; ; more unsorted aliases ; ; ################################### percent { return $calc(($1 * 100) / $2) } _percent { return $int($percent($1,$2)) $+ % } rawcon { .raw PRIVMSG $me :DCC CHAT CHAT $longip($1) $2 $+  } _comchan { var %z = 1, %comchans while ($comchan($1,%z)) { %comchans = $addtok(%comchans,$comchan($1,%z),44) inc %z } return %comchans } _ctcpreply { var %r = .ctcpreply $1-2 if ($read($_datfile(ctcps.txt),nw,$+($2,$chr(9),*))) %r $gettok($ifmatch,2-,9) else { ; if ($2 == VERSION) %r mIRC v $+ $version Khaled Mardam-Bey if ($2 == PING) %r $3- if ($2 == FINGER) %r Stick your finger somewhere else if ($2 == TIME) %r $date(h:nnTT - ddd mmm dd yyyy) if ($2 == CLIENTINFO) %r PING FINGER VERSION TIME } } _scrlf { return $remove($1,$cr,$lf,$crlf) } _woop { if ($1 == begin) return - if ($chan($1) ischan) return $ifmatch $+ :part $ifmatch $!input(Enter part msg,1,Part channel) } s2 { if (!$1) server -n else server -m $1- } server { if ((-* iswm $1) && ($regex($1,mn))) ForceStatusWindowFontsBecauseThereIsNoOnOpenEventForItAndmIRCfontsAreBroken !server $1- } ForceStatusWindowFontsBecauseThereIsNoOnOpenEventForItAndmIRCfontsAreBroken { scid -a ThisIsReallyStupid } ThisIsReallyStupid { if ($group(#display.basic) == on) { var %f = $_(display,fontname), %s = $_(display,fontsize) if (%f) font -sd %s %f } elseif ($group(#display.mts) == on) { var %f = $gts(fontdefault) if (%f) font -sd $gettok(%f,2,44) $gettok(%f,1,44) if ($gettok(%f,3,44)) font -sb } } whereis { if ($isalias($1-).fname) echo -a $1- $+ : $ifmatch else echo -a $1- : no such alias. } _ignore.delete { igq $active $active 180 .timer 1 1 delq $active } ; igq $1 $active N igq { if ($query($2)) closemsg $1 elseif (=* iswm $2) close -c $1 if ($server) { var %time = -pu $+ $iif($3,$3,60) var %addr = $1 $+ ! $+ $query($2).addr var %addr = $mask(%addr,3) if (%addr) .timer 1 0 .ignore %time %addr else .timer 1 0 .ignore %time $1 3 } } delq { if ($_logfile($1)) .remove $+(",$ifmatch,") } ; system aliases ; -------------- setup nb explorer run explorer.exe $1- bc echo -a * $$1- = $calc($$1-) _switchgroup { var %g = #$1 if ($group(%g)) $+($iif($ifmatch == on,.dis,.en),able) %g } _censor return $replace($1,a,*,e,*,i,*,o,*,u,*) _trimdur return $remove($1-,ks,k,ays,ay,rs,r,ins,in,ecs,ec,$chr(32)) _isfile if ($isfile($1-)) return $1- _isdir if ($isdir($1-)) return $1- _SystemMainHashTable return Sys.HashTable. $+ $cid _showmotd return $_mopt(1,11) ; /_bld <- bhelp last dialog _bld %sys.last.bdlg = $1 _ldlg set -u %sys.last.dialog $1 _showdlg { if ($dialog($1)) dialog -v $1 if ($1 == %sys.last.dialog) unset %sys.last.dialog } ; extreme error ; /_err [-1] Text ; -1 to continue _err { var %err, %halt = halt if ($1 == -1) { tokenize 32 $2- %halt = return } if (%sys.show) iecho $1- else %err = $input($1-,516,Script error) _showdlg %sys.last.dialog %halt } ; prompt ; /_confirm(Text,Title) _confirm return $input($1,256,$iif($2,$2,Confirm action)) _modechk return $iif($1 isin $chan(#).mode,-,+) $+ $1 _themes { if (($group(#display.mts).status == off) && ($group(#display.basic).status == off)) return 0 return 1 } _opendlg { if ($dialog($1)) dialog -v $1 else dialog $iif($_(desktop,$_iif($2,$1)),-md,-m) $1 $_iif($2,$1) } ; /_dialogsort _dialogsort { var %tmp = % $+ _sys.tmp. $+ $cid $+ . $+ $1 if (!$(%tmp,2)) set -u120 $(%tmp) -ctio filter $(%tmp,2) $4 9 $1 $2 $dname $3 * filter $(%tmp,2) $4 9 $1 $2 $dname $2 * if (e isincs $(%tmp,2)) set -u120 $(%tmp) -ctio else set -u120 $(%tmp) -ctioe } _hfree { var %x = 1 while ($gettok($1-,%x,32)) { if ($hget($ifmatch)) hfree $ifmatch inc %x } } ; All internal aliases and identifiers to begin with _sys ; All variables to begin with %Sys. ; $_sysfile ; returns the main file for the script settings. _sysfile return sys\default.ini ; $_datfile(filename) ; for general .txt and .dat files _datfile return sys\data\ $+ $1 ; system files exmpt.dat return sys\data\exemptfilter.dat quits.txt return sys\data\quits.txt fkeys.dat return sys\data\fkeys.dat fkeys.txt return sys\data\fkeys.txt dcc.log return sys\data\dcc.log ; /_syswrite [value] ; Similar to /writeini but writes to $_sysfile ; If value is null, remini the item. _syswrite { if ($len($3)) writeini -n $_sysfile $1-2 $3- else remini $_sysfile $1-2 } _set { if ($3 != $null) writeini -n $_sysfile $$1 $$2 $3- else remini $_sysfile $$1 $2 } ; $_cset() as shortcut for $_sysgetopt(default,etc..) to be used in dialog events. ; /_cset same as /_set but specific for channels.ini _cset { if ($3 != $null) writeini -n sys\channels.ini $$1 $$2 $_repc($3-) else remini sys\channels.ini $$1 $2 } ; /_sysdef ; Sets system default for a certain setting. _sysdef { if ($_($1,$2) == $null) _set $1- } ; $_sysread(name,item) ; Reads the value for the name and item. _sysread { if ($hget($1,$2) != $null) return $ifmatch return $readini(sys\channels.ini,$1,$2) } ; Same as $_sysread but for general settings. _ return $readini($_sysfile,$1,$2) ; $_sysgetopt(server,#channel,option,network) ; Attempts to get specific settings for a server. ; If no such setting is found, try to find setting for a network of that server, ; and if it still fails, use Default settings. ; Network is $4 in case there's no value for $network _sysgetopt { var %n = $iif($4,$4,$server($1).group) if ((!%n) || (%n isnum)) %n = Default if ($_sysread($+($1,.,$2),$3) != $null) return $ifmatch if ($_sysread($+(%n,.,$2),$3) != $null) return $ifmatch return $_sysread(Default.Default,$3) } ; $_sysgo(channel,option) ; shortcut for $_sysgetopt() ; If $network and $server needs to be specific in every alias, ; use /set -u %network $_network and /set -u %server $server ; before calling $_sysgo and $_sysga (?) _sysgox { var %n = $iif($network,$network,$server($server).group) if ((!%n) || (%n isnum)) %n = Default ; add $hget() ? ; if ($_sysread($+($server,.,$1),$2) != $null) return $ifmatch if ($_sysread($+(%n,.,$1),$2) != $null) return $ifmatch if ($_sysread($+(%n,.Default),$2) != $null) return $ifmatch if ($_sysread($+(Default.,$1),$2) != $null) return $ifmatch return $_sysread(Default.Default,$2) } _sysgo { if ($readini(sys\channels.ini,$+($network,.,$1),$2) != $null) return $ifmatch var %f = sys\channels.ini, %n = $iif($network,$network,$server($server).group) if ((!%n) || (%n isnum)) %n = Default if ($readini(%f,$+($server,.,$1),$2) != $null) return $ifmatch if ($readini(%f,$+(%n,.,$1),$2) != $null) return $ifmatch if ($readini(%f,$+(%n,.Default),$2) != $null) return $ifmatch if ($readini(%f,$+(Default.,$1),$2) != $null) return $ifmatch return $readini(%f,Default.Default,$2) } _network { if ($network) return $network if (($server($server).group != $null) && ($ifmatch !isnum)) return $ifmatch return Default } ; $_achan($1) "active chan" ; to be used with /command [#channel] ; if the optional channel is not specified, revert to # ; it should be $null if there's no $1 and if the active window or the event doesn't have a # value. _achan { return $iif((#$1 == $1),$1,#) } _mopt { var %m = $readini($mircini,options,$+(n,$1)) return $gettok(%m,$2,44) } _mdid { var %t = $3 while (%t <= $4) { did $1-2 %t inc %t } } _realname { if ($_isfile($_datfile(names.txt))) && ($read($ifmatch,n)) return $ifmatch return http://elf.wot.net/ } ;-------------------- ; Custom identifiers ccode { if ($_isfile(sys\country.ini)) return $readini($ifmatch,country,$1) return unknown } ; $srvbot(nick,address) ; checks if the nick is a service bot srvbot { if ((*.dal.net iswm $server) && ($regex($1,^(nick|memo|chan)serv))) return 1 if ((*.undernet.org iswm $server) && ($1 == X) && ($2 == cservice@undernet.org)) return 1 return 0 } _logf { if ($1 == begin) { window -c @_loglist window -hsl @_loglist var %x = $findfile($mircdir,*.txt,@_loglist) return - } elseif ($1 == end) window -c @_loglist elseif ($line(@_loglist,$1)) return $nopath($ifmatch) : echo -s $+(",$ifmatch,") } ; $_logfile(window), taken from aIRC by tabo, modified by me _logfile { var %file if (=* iswm $1) %file = $chat($1).logfile elseif ($1 ischan) %file = $chan($1).logfile else %file = $query($1).logfile if (!%file) %file = $+($logdir,$mklogfn($1)) return $_isfile(%file) } _isticks { return $iif((($calc($ctime - $1) > 604800) || ($calc($ctime - $1) < -604800)),1) } _istok { if ($istok($1,$2,$3)) return $2 } _isquery { return $iif($query($1) == $1,$1) } _isvalidwin { if ($chat($remove($1,=)).status == active) return $1 if (!$server) return return $iif(($1 ischan) || ($query($1) == $1),$1) } _iswin { return $iif(($1 != Status Window) && (@* !iswm $1),$1) } _font { var %a = $+(@_SysFont.,$ticks) window -pfh +d %a 50 50 1 1 cancel 13 window -a %a font if ($window(%a).font == cancel) { window -c %a | return } var %fontname = $window(%a).font, %fontsize = $window(%a).fontsize window -c %a if ($prop == font) return %fontname if ($prop == size) return %fontsize return %fontsize %fontname } ; $_repc(text) ; replace control codes and back, for writing and reading to and from ini files. yeah.. this is a stupid way of doing it :/ _repc return $iif($count($1,,,,,),$replace($1,,ÿ¯b,,ÿ¯u,,ÿ¯r,,ÿ¯k,,ÿ¯o),$replace($1,ÿ¯b,,ÿ¯u,,ÿ¯r,,ÿ¯k,,ÿ¯o,)) _iif return $iif($1 != $null,$1,$2) _hn return $+($cid,.,$1) ; $_connected to check if ANY of the Status Windows are connected _connected { var %s = $scon(0) while (%s) { if ($scon(%s).status == connected) return $true dec %s } return $false } ; $_isconnected checks if the active $cid is connected _isconnected { return $iif($status == connected,1) } _ctrlcodes { var %r = 0 if (a isin $2) return $count($1,,,,) if (b isin $2) inc %r $count($1,) if (u isin $2) inc %r $count($1,) if (r isin $2) inc %r $count($1,) if (k isin $2) inc %r $count($1,) return %r } ;--- $repchar(string,char,N) ; replace the Nth character with char ; if N is negative, replace the Nth character from the end of the string ; if N is 0, replace the whole string with the character repchar { parmcheck repchar $3 if ($3 == 0) return $str($2,$len($1)) if (-* iswm $3) return $left($1,$3) $+ $2 $+ $right($1,$calc($remove($3,-) -1)) if ($3 > $len($1)) return $1 $+ $2 return $left($1,$calc($3 - 1)) $+ $2 $+ $right($1,$calc($len($1) - $3)) } ;--- $inschar(string,char,N) ; inserts char at position N in string ; if N is -negative, insert Nth position from end of string. ; if N is 0, put the character at the beginning of the string. inschar { parmcheck inschar $3 if (($3 == 1) || ($3 == 0)) return $2 $+ $1 if (-* iswm $3) { if ($3 == -1) return $1 $+ $2 var %n = $3 inc %n return $left($1,%n) $+ $2 $+ $right($1,$remove(%n,-)) } return $left($1,$calc($3 - 1)) $+ $2 $+ $right($1,- $+ $calc($3 - 1)) } ;------ $delchar(string,char,N) ; deletes char at position N from string ; if N is -negative, deletes character at position N from the end of the string ; (or start counting from the end of the string towards the beginning) ; if N is 0, remove all instances of char or use $remove ; .cs - will only delete case sensitive matches delchar { parmcheck delchar $3 if ($prop == cs) var %op1 = !isincs, %op2 = $str(=,3), %eval = $!poscs($1,$2,$3), %rem = $!removecs($1,$2) else var %op1 = !isin, %op2 = $str(=,2), %eval = $!pos($1,$2,$3), %rem = $!remove($1,$2) if ($2 %op1 $1) return $1 if ($3 == 0) return $(%rem,2) if (-* iswm $3) { if ($remove($3,-) > $count($1,$2)) var %pos = $count($1,$2) else var %pos = $remove($3,-) var %loop = 0, %char, %string, %match, %len = $len($1) while ($remove(%loop,-) < %len) { var %char = $mid($1,$calc(%len %loop),1) if (%char %op2 $2) { inc %match if (%match %op2 %pos) break } %string = %char $+ %string dec %loop } return $left($1,$calc(%len - $len(%string) - 1)) $+ %string } var %end = $calc($(%eval,2) - 1) if (%end) return $mid($1,1,%end) $+ $right($mid($1,$(%eval,2),$len($1)),-1) return $right($mid($1,$(%eval,2),$len($1)),-1) } ; /parmcheck ; verify that parm must be a number and an integer parmcheck { var %e if ($2 == $null) %e = Too few parameters: elseif (($2 !isnum) || ($int($2) != $2)) %e = Invalid parameters: if (%e) { echo $colour(info) -s * %e $ $+ $1 halt } } getumode { if ($left($nick($1,$2).pnick,1) isin $prefix) return $ifmatch } scramble { var %i = 1, %x while ($gettok($1,%i,32) != $null) { var %tmp = $ifmatch, %w = %tmp, %y = $len(%tmp), %r while (%y) { var %c = $mid(%w,$rand(1,%y),1), %p = $poscs(%w,%c,1), %e = $calc(%p -1), %w = $iif(%e,$mid(%w,1,%e)) $+ $right($mid(%w,%p,$len(%w)),-1), %r = $+(%r,%c) dec %y } %x = %x %r inc %i } return %x } ; $ewin(join,part,quit,mode,topic,ctcp,nick,kick) ;all 0 chan ;1 status; 2 hide ;quit 0 chan ;1 status; 2 both;3 hide ;ctcp 0 chan ;1 status ;nick 0 chan ;1 hide ewin { return $gettok($readini($mircini,events,default),$findtok(join part quit mode topic ctcp nick kick,$_iif($1,$event),1,32),44) } ; /_usefont <@window> _usefont { if ($1) { if ($group(#display.basic) == on) var %n = $_(display,fontname), %s = $_(display,fontsize) else { var %f = $readini($mircini,fonts,fquery) if (!%f) %f = $readini($mircini,fonts,fmessage) var %n = $gettok(%f,1,44), %s = $gettok(%f,2,44) if ($left(%s,1) isin 47) %s = $remove($calc($+($ifmatch,00) - %s),-) } if ((%n) && (%s)) font $2 %s %n } } ; $hgetw(wildcard,N) ; returns Nth matching hash table ; if N is 0, returns all matching hash tables hgetw { var %i = 1, %result, %x = 0 while ($hget(%i) != $null) { if ($1 iswm $hget(%i)) { inc %x if ($2 == %x) return $hget(%i) %result = %result $hget(%i) } inc %i } ; ALWAYS treat $2 as a valid number. return a $null if the user specifies ; something either out of range or something that isn't a valid number. if ($2 <= %x) return %result } ; /hloadini ; Loads all items of an .ini file to a hash table. hloadini { if (!$isfile($1-)) return var %total = $ini($1-,0) while (%total) { var %header = $ini($1-,%total), %i = 1 while ($ini($1-,%header,%i)) { hadd -m %header $ifmatch $readini($1-,%header,$ifmatch) inc %i } dec %total } } ; /_dlgscroll _dlgscroll { if (!$did($1,$2).lines) return if ($did($1,$2).sel) { var %linenum = $ifmatch, %text = $did($1,$2,%linenum) if ($did($1,$3).sel) { var %scroll = $ifmatch did -d $1-2 %linenum if (%scroll > $did($1,$2).lines) did -a $1-2 %text else did -ci $1-2 %scroll %text } } } ; $_isbadword(type,$_network,$chan,$1-) ; using this instead of $hmatch because $hmatch would still require a loop thru $1- altho it might have been shorter _isbadwordx { _wordcheck var %word, %pre = $+(_syswordkick.,$1), %text = $strip($4-), %i = 1, %list = $hget(%pre,$+($2,.,$3)) ; all this error checking is making things s l o w if (!%list) %list = $hget(%pre,$+($2,.Default)) if (!%list) %list = $hget(%pre,$+(Default.,$3)) if (!%list) %list = $hget(%pre,Default.Default) while ($gettok(%list,%i,32) != $null) { %word = $ifmatch ; exact matches first if (($istok(%text,%word,32)) || ($istok($1-,%word,32))) return %word ; use wildmatch only if a * is in the word trigger if (* isin %word) { if ((%word iswm %text) || ($wildtok(%text,%word,1,32)) || (%word iswm $4-) || ($wildtok($4-,%word,1,32))) return $ifmatch } inc %i } } _isbadword { var %word, %file = $+(sys\words_,$1,.txt), %text = $strip($4-), %i = 1, %list = $readini(%file,$2,$3) if (!%list) %list = $readini(%file,$2,Default) if (!%list) %list = $readini(%file,Default,$3) if (!%list) %list = $readini(%file,Default,Default) while ($gettok(%list,%i,32) != $null) { %word = $ifmatch if (($istok(%text,%word,32)) || ($istok($1-,%word,32))) return %word if (* isin %word) { if ((%word iswm %text) || ($wildtok(%text,%word,1,32)) || (%word iswm $4-) || ($wildtok($4-,%word,1,32))) return $ifmatch } inc %i } } _wordcheck { if ((!$hget(_syswordkick.swear)) && (!$hget(_syswordkick.hosts)) && (!$hget(_syswordkick.spam))) _loadwords } _loadwords { hfree -w _syswordkick.* var %t, %f, %i = 1 while ($gettok(swear hosts spam,%i,32)) { %t = $ifmatch if ($_isfile($+(sys\words_,%t,.txt))) { var %f = $ifmatch, %total = $ini(%f,0) while (%total) { var %h = $ini(%f,%total), %x = 1 while ($ini(%f,%total,%x)) { hadd -m $+(_syswordkick.,%t) $+(%h,.,$ifmatch) $readini(%f,%h,$ifmatch) inc %x } dec %total } } inc %i } ; if (%Sys.PerformOnConnect) iecho Loading words... [OK] } ; /_badnick _badnick { if ($_isex($3,$4)) return if (($_sysgetopt($server,$3,BadNick,$2)) && ($_isbadword(hosts,$2,$3,$5))) _react $1 $+($2,.,$3,.BadUserHost) 1 $3-5 Bad word: you cannot have $_censor($ifmatch) in your address. } ; mdx-related aliases. believe it, blue-elf is using mdx... mdx { !.echo -q $dll(dll\mdx\mdx.dll,$1,$2-) } listview { mdx SetControlMDX $1-2 listview $3- > dll\mdx\views.mdx } headers { did -i $1-2 1 headertext $3- } headersizes { did -i $1-2 1 headerdims $3- } mdxResizeFix { mdx SetDialog $1 style title border sysmenu } ; /mdxinit $replace(,160,32) mdxinit { mdx SetMircVersion $version mdx MarkDialog $1 mdx SetControlMDX $1-2 listview report showsel rowselect > dll\mdx\views.mdx ; flatsb grid ; listview $1-2 report showsel rowselect grid var %s = 1, %z while ($gettok($3,%s,44)) { %z = %z $ifmatch inc %s } headersizes $1-2 %z var %t = 1, %tab while ($gettok($4,%t,44)) { %tab = $instok(%tab,$replace($ifmatch,$chr(160),$chr(32)),0,9) inc %t } headers $1-2 %tab } ; EOF ; group list glist { var %i = $group(0), %w = @Groups if ($window(%w)) clear %w window -lk -t $+ $calc($len(Filename) + 5) $+ ,35 %w aline %w $tab(Filename,Groupname,Status) aline %w $tab(-,-,-) while (%i) { aline %w $tab($nopath($group(%i).fname),$group(%i),$group(%i).status) dec %i } window -b %w } ; hash tables list hlist { var %r, %i, %w = @Hash Tables if ($window(%w)) clear %w window -lk -t35,45,80 %w aline %w $tab(TableName,No.,Item,Data) aline %w $tab(-,-,-,-) %i = 1 while ($hget(%i) != $null) { var %h = $ifmatch, %r = 1 while ($hmatch(%h,*,%r) != $null) { var %a = $ifmatch aline %w $tab($iif(%r == 1,%h, ),%r,%a,$hget(%h,%a)) inc %r } aline %w   inc %i } window -b %w }