;;----------------------------------------------------------------------------------------
- Alternating $replace
- $reptokall
- Shuffle Algorithm
- Backspace
- Escape
- Long multiplication
- Find the 3 roots of a cubic equation
- Spin
- See if a command/identifier is an inbuilt mIRC one
- Clone scanner with kick/ban functions
- Highest Common Factor algorithm including LCM and fraction conversion
- Find the angle between 2 lines
- Draw a line N degrees from another line with a common point
- Talker code
- Mp3Rank system
- Remove HTML from text
- File Encrypter/Decrypter
- Scroll text in a dialog editbox
- Replace only a specified number of matching strings in text
- Centi-second timestamp
- Clone flood protection
- Repeat flood protection
- Simple away system
- Excess caps kicker
- Acronym Replacer
- Op/Voice notice
- Kick/ban/deop protection
- Put commas in a number
- Differentiate an equation
- Return tokens common to 2 strings
- Encrypt an html string or file
;;----------------------------------------------------------------------------------------
;;
;; Useful codes by Sigh
;;
;;----------------------------------------------------------------------------------------
;; Alternating replacements
;; Usage $altrep(string,repstring,substring1,substring2,.....,substringN)[.cs]
;; Use the .cs property if you want case sensitivity
;; Replaces all occurences of repstring by each substring alternately
;; For example: $altrep(bold text more bold text even more bold text,,<b>,</b>)
;; Returns: <b>bold text</b> <b>more bold text</b> <b>even more bold text</b>
;; Another example: $altrep(peter piper picked a peck of Pickled peppers,p,a,b,c,d,e,f).cs
;; Returns: aeter bicer dicked a eeck of Pickled feabers
;; Note: a carriage return ($cr) is used in the code to monitor replacements, using it in a parameter may yield incorrect results
alias altrep {
var %m = $1, $&
%i = 0
while ($regsub(%m,/(?<!\x0A)(\Q $+ $2 $+ \E)/ $+ $iif($prop != cs,i),$cr $+ $($ $+ $calc(3+%i % ($0 -2)),2),%m)) inc %i
return $remove(%m,$cr)
}
;; Top
;;----------------------------------------------------------------------------------------
;; Usage: $reptokall(string,token,new,token2,new2,token3,new3,...,C)
;; Replaces all matching tokens in the string with corresponding new tokens
;; Example:
;; $reptokall(Why did he make another useless snippet? He doesn't realize it's useless,he,Sigh,useless,useful,32)
;; Returns:
;; Why did Sigh make another useful snippet? Sigh doesn't realize it's useful
alias reptokall {
var %i = 0, $&
%str = $1, $&
%c = $($ $+ $0,2)
while (%i < $0) {
var %tok = $($ $+ $ifmatch,2), $&
%rep = $($ $+ $calc(1+$ifmatch),2)
.echo -q $regsub(%str,/(?<=^|\x $+ $base(%c,10,16) $+ ) $+ %tok $+ (?=\x $+ $base(%c,10,16) $+ |$)/gi,%rep,%str)
inc %i 2
}
return %str
}
;; Top
;;----------------------------------------------------------------------------------------
;; Shuffle alias by Sigh
;; Usage: $shuffle(N,C)
;; Shuffle algorithm used to generate N amount of numbers delimited by character with ascii number C
;; For example: $shuffle(10,44) can equal 1,5,4,7,3,6,10,8,9,2
;; Users with mIRC versions less than 6.16 must replace $v1 with $ifmatch in the following code
alias shuffle {
var %m
while ($numtok(%m,$2) < $1) %m = $instok(%m,$calc(1+$v1),$r(0,$v1),$2)
return %m
}
;; An adaption of the above alias, used to randomize a list of tokens
;; Usage: $shuffle2(string,C)
;; For example $shuffle2(my!list!of!tokens,33) can equal of!tokens!my!list
alias shuffle2 {
var %m
while ($numtok(%m,$2) < $numtok($1,$2)) %m = $instok(%m,$gettok($1,$calc(1+$v1),$2),$r(0,$v1),$2)
return %m
}
;; Top
;;----------------------------------------------------------------------------------------
;; $backsp
;; Usage: $backsp(string,C)
;; Treats $chr(C) in the string as if it was a backspace and removes the text before it
;; Example: $backsp(in this example..a period... is a backspace char..acter,46)
;; = in this exampa per is a backspace chacter
alias backsp {
var %m = $1
while ($regsub(%m,(^|.)\ $+ $chr($2),,%m)) !
return %m
}
;; Top
;;----------------------------------------------------------------------------------------
;; /escape
;; Usage: /escape [-nN] or $escape(string,N)
;; -nN well escape the string N times, if no switch is specified it defaults to 1
;; Example: /escape -n2 if (%myvar = $ident) { echo $ifmatch } | command2 %myvar [ $+ [ $ident ] ]
;; Becomes: if (%myvar = $!!ident) $!chr(123) echo $!!ifmatch $!chr(125) $!(|) command2 % $!+ myvar $!([) $!!+ $!([) $!!ident
$!(]) $!(])
;; Which should evaluate twice to give the original string
;; An example of how it can be used as an identifier: on *:text:!escape *:#:{ msg # Result: $escape($2-) }
;;
;; This is intended to be used from the editbox of a window, but can be used from a script provided you remember the
parameters must be
;; escaped manually before being passed to the alias which more than likely defeats the purpose of using it. So it's just
intended
;; as a manual command to quickly escape strings for your timers and such.
alias escape {
var %i = $iif($isid,$iif($2 isnum,$2,1),$iif($regex(esc,$1,^-n(\d+)$),$regml(esc,1),1)), $&
%x = /(?<=^| ), $&
%m = $iif($isid,$1,$iif($regml(esc,1),$2-,$1-))
while (%i) {
.echo -q $regsub(%m,%x $+ \$(?=\S+)/g,\$!,%m) $&
$regsub(%m,%x $+ \%(?=\S+)/g,% \$+ $chr(32),%m) $&
$regsub(%m,%x $+ \|(?= |$),\$(|),%m) $&
$regsub(%m,%x $+ (\[|\])(?= |$)/g,\$(\1),%m) $&
$regsub(%m,%x $+ {(?= |$)/g,\$({,),%m) $&
$regsub(%m,%x $+ }(?= |$)/g,\$(},),%m)
dec %i
}
if ($isid) return %m
echo $color(i) -eag %m
}
;; Top
;;----------------------------------------------------------------------------------------
;; Quick long multiplication algorithm able to handle very large multiplications
;; Usage: $lmultp(n1,n2)
;; For example $lmultp(123456789123456789,987654321987654321) = 121932631356500531347203169112635269
;; Doesn't support decimals, since you can just remove/re-add them on your own
alias lmultp {
var %a = $1-
.echo -q $regsub(%a,/^0*(\d*) 0*(\d*)$/,\1 \2,%a) $regsub(z,%a,/(0+)(?= |$)/g,,%a)
var %w = $str(0,$len($regml(z,1) $+ $regml(z,2)))
tokenize 32 %a
if ($len(%a) < 11) return $calc($1 *$2) $+ %w
if ($hget(ladd)) hfree ladd
hmake ladd
var %1 = $iif($1 > $2,$1,$2), $&
%2 = $iif($1 > $2,$2,$1), $&
%i = $len(%2), $&
%k = 1
while (%i) {
var %x = 0
while (%x < $len(%1)) {
inc %x 8
var %m = $len(%1) - %x, $&
%p = $calc($mid(%1,$iif(%m < 0,1,- $+ %x),$iif(%m < 0,$calc(8+%m),8))*$mid(%2,%i,1)), $&
%y = $len(%p)
while (%y) {
var %q = $calc($len(%p)-%y +$len(%2)-7-%i +%x), $&
%k = $iif(%q > %k,%q,%k)
hinc ladd %q $mid(%p,%y,1)
dec %y
}
}
dec %i
}
var %i = 1, $&
%o, $&
%h
while (%i <= %k) {
%h = $iif($hget(ladd,%i),$ifmatch,0)
if (%h > 9) hinc ladd $calc(1+%i) $int($calc(%h /10))
var %o = $iif(%i = %k,%h,$calc(%h % 10)) $+ %o
inc %i
}
hfree ladd
return %o $+ %w
}
;; Top
;;----------------------------------------------------------------------------------------
;; Solution to cubic equations
;;
;; Solves equations of the type ax^3 + bx^2 +cx + d = 0 (a != 0)
;; Usage: $cubic(a,b,c,d)
;; Supports complex roots
alias cubic {
var %i = $calc((3*$3 /$1 -($2)^2/($1)^2)/3),%x = $calc(((2*($2)^3)/($1)^3-(9*$2 *$3)/($1)^2+(27*$4)/$1)/27), $&
%n = $calc((%x)^2 /4+(%i)^3/27)
if (%n <= 0) {
var %k = $sqrt($calc(((%x)^2/4)-%n)),%j = -1 * $cbrt(%k),%t = $acos($calc(-(%x /(2*%k)))) / 3,%m = $cos(%t), $&
%b = $sqrt(3) * $sin(%t),%p = $calc(-1*$2 /(3*$1))
return $round($calc(-2*%j *$cos(%t) -$2 /(3*$1)),2) , $round($calc(%j *(%m +%b)+%p),2) , $round($calc(%j *(%m -%b)+%p),2)
}
var %s = $cbrt($calc(-(%x /2)+$sqrt(%n))),%u = $cbrt($calc(-(%x /2)-$sqrt(%n))),%p = $round($calc(-(%s +%u)/2 -$2
/(3*$1)),2), $&
%t = $iif($round($calc($sqrt(3)*(%s -%u)/2),2) != 1,$ifmatch)
return $round($calc(%s +%u -$2 /(3*$1)),3) , %p + %t $+ i , %p - %t $+ i
}
alias -l cbrt {
return $iif(-* iswm $1,-) $+ $calc($abs($1)^(1/3))
}
;; Top
;;----------------------------------------------------------------------------------------
;; Spin by Sigh
;; /spin to start - right click for extra options
alias spin {
window -dopC @Spin -1 -1 210 230
%sp.d = +
%sp.s = 0
%sp.c = 10
%sp.z = 1
sp1n 10 +
}
alias -l sp1n {
if (!$window(@Spin)) return
if ($4) drawline -n @Spin $color(b) $4-
var %a = $iif($abs($3) = 359,0,$3),%c = $cos(%a) [ $+ [ $iif(%sp.z,.deg) ] ],%s = $sin(%a) [ $+ [ $iif(%sp.z,.deg) ] ],%v =
$iif(%sp.b,$1,100), $&
%c1 = 1 $iif(%sp.s = 4 || %sp.3 = 2,-,+) %c,%s1 = 1 + %s,%c2 = 1 - %c,%s2 = 1 - %s,%n = $iif($or(%sp.s,1) = 5 || %sp.3 =
1,45,%v), $&
%c3 = %v * %c1,%c4 = %n * %c2,%s3 = %n * %s1,%s4 = %v * %s2,%c5 = %v + %c3,%c6 = %v + %c4,%s5 = %v + %s3,%s6 = %v + %s4,
$&
%c = 5 %s3 %c4 %c3 $iif(%sp.s & 1,%s4,%s3) $iif($and(2,%sp.s),%c3,%s4) %c3 %c4 %s4 %s3 %c4 $&
$iif(%sp.v,%s3 %c6 %c4 %s6 %c4 %s4 %s4 %c3 %s4 %c5 %c4 %s6 %s3 %c6 %c3 %s5 %s4 %c5 %c3 %s5 %c3 %s3)
drawline -n @Spin %sp.c %c
drawdot @Spin
.timer -m 1 15 sp1n $iif($1 = 100,99 -,$iif($1 = 10,11 +,$calc($1 $2 1) $2))) $calc(%a %sp.d 1) %c
}
menu @Spin {
Dimension
.2D:{
window @Spin -1 -1 210 230
%sp.v = 0
}
.3D:{
window @Spin -1 -1 210 335
%sp.v = 1
%sp.3 = $iif(%sp.s = 4,1,0)
%sp.s = 0
}
Direction
.Clockwise:%sp.d = +
.Anti-clockwise:%sp.d = -
Styles
.Norm:{
%sp.s = 0
%sp.3 = 0
}
.$submenu($sp($1))
Color
.$submenu($sp($iif($1 isnum,$calc($1 -1),$1),1))
Turn expanding/compressing $iif(%sp.b,off,on):%sp.b = $iif(%sp.b,0,1)
$iif(%sp.z,Crazy,Uncrazy) mode:%sp.z = $iif(%sp.z,0,1)
}
alias -l sp return $iif($1 isnum 0- $+ $iif($2,15,$iif(%sp.v,2,5)),$+(.,$1,:%sp.,$iif($2,c,$iif(%sp.v,3,s)) = $1),-)
on *:close:@Spin:unset %sp.*
;; Top
;;----------------------------------------------------------------------------------------
;; Find out if a command or identifier is inbuilt in mIRC
;; Usage: $ismirc($!identifier) or $ismirc(/command)
;; $!identifier is to prevent it being evaluated when passed to the alias
alias ismirc {
;; Declare local variables for storing list of undocumented identifiers/commands
var %f = $+(",$findfile($mircdir,mirc.hlp,1),"),%r = return,%e = echo $color(i) -ea,%i = $iif($!* iswm $1,1),%s = $iif($!*
iswm $&
$1,identifier.,command.),%c = $eval($remote $beta $nopnick $nvnick $nhopnick $* $r $colour $nickmode $true $false $yes
$no $ok $&
$cancel $hfile $lof $bits $evalnext $initopic $dir $auto $banlist $token $rnick $mp3 $wavedir $mp3dir $mididir $addtokcs
$findtokcs $&
$istokcs $matchtokcs $remtokcs $reptokcs $sorttokcs $wildtokcs $getdir $inpaste $trust $! $? /xyzzy /colour /closemsg
/clearial $&
/quote /auto /leave /registration /action /else /elseif /setlayer /notice /username,0),%l = %e ** $1 is a built in %s
;; If it's an identifier such as $1-2 or an undocumented command/identifier then proceed
if ((i* iswm %s) && ($regex($mid($1,2),^\d+-*\d*$))) || ($istok(%c $!&,$1,32)) goto y
if (!$1) || (!$regex($1,^\$|/)) {
%e Specify a command/identifier to search for $iif(!$1,(remember to use ! in identifiers to keep them from evaluating))
%r
}
if (!%f) {
%e Help file missing
%r
}
if ($version < 6.1) {
%e mIRC version 6.1 or greater required.
%r
}
;; Read the contents of the help file into a binary variable and search for the requested command/identifier within it
bread %f 1 $lof(%f) &t
var %p = $bfind(&t,1,$1)
if (%p && !$bvar(&t,$calc(%p -1))) && (!$bvar(&t,$calc($len($1)+%p))) {
:y
if ($isid) %r 1
%l
%r
}
;; Output results
if ($isid) %r 0
$instok(%l,not,7,32)
}
;; Top
;;----------------------------------------------------------------------------------------
;; Clone scan with a kick/ban function
;; Usage: /clonescan [#chan] [level]
;; On the window that pops up you may double click on nicknames to ban and kick them
;; If you click on [all] it will kick/ban the whole group of clones
on ^*:hotlink:*:@CScan_*:{
var %c = $gettok($target,2-,95)
if ($me isop %c) && (($unprefix($remove($1,$chr(44))) ison %c) || ($1 = [all])) return
halt
}
on *:hotlink:*:@CScan_*:{
var %c = $gettok($target,2-,95),%h = $gettok($hotline,2,32),%v = $iif($1 = [all],1,0),%m = :Clones - %h
if (%v) {
tokenize 32 $unprefix($hotline)
var %e = /, ([^,]+)/g,%r
.echo -q $regsub($4- [ $+ [ $calc($0 -1) ] ],%e,$cr $+ kick %c \1 %m,%r)
}
.raw mode %c b $+(%h,$cr,kick) %c $unprefix($remove($iif(%v,$4,$1),$chr(44))) $iif(%v,$+(%m,$cr,$gettok(%r,2-,13)),%m)
}
alias clonescan {
var %c = $iif($1 ischan,$1,#),%w = @CScan_ $+ %c
%temp_lev = $iif($1 isnum || $2 isnum,$ifmatch,2)
if (!$chan(%c).ial) {
if (!$ial) .ial on
echo -ea Updating IAL for clone scan.
.enable #clonescan
who %c
return
}
window -da %w 25 25 500 350
var %i = 1,%t = $ticks
while ($mask($ialchan(*,%c,%i),%temp_lev)) {
var %m = $ifmatch,%n = $ialchan(%m,%c,0),%z = %n,%a
if (%n > 1) && (!%µ. [ $+ [ %n ] ]) {
var %µ. $+ %n 1
while (%n) {
%a = %a $nick(%c,$ialchan(%m,%c,%n).nick).pnick
dec %n
}
echo %w $var(%µ.*,0) $+ : %m ( $+ %z $+ ) $replace(%a,$chr(32),$chr(44) $+ $chr(32)) $iif($me isop %c,[all])
}
inc %i
}
echo -e %w Scanned %c in $calc($ticks -%t) $+ ms ( $+ $var(%µ.*,0) groups found)
unset %temp_lev
}
alias -l unprefix {
var %p = $iif($prefix,$prefix,@+),%i = 1,%r
while ($mid(%p,%i,1)) {
%r = $+(%r,\,$ifmatch,?)
inc %i
}
.echo -q $regsub($1,$+(/(^| ),%r,/g),\1,%i)
return %i
}
#clonescan off
raw 352:*:haltdef
raw 315:*:{
if (!$chan($2).ial) echo $color(i) -ea Error: IAL isn't being updated, you may be on a network that restricts the /who
command
else .timer 1 0 clonescan $2 %temp_lev
unset %temp_lev
.disable #clonescan
haltdef
}
#clonescan end
;; Top
;;----------------------------------------------------------------------------------------
;; $hcf(integer1,integer2) - finds the Highest Common Factor of two integers
;; $lcm(integer1,integer2) - finds the Lowest Common Multiple of two integers
;; $fract(number) - turn any number into a fraction
;; Thanks to Kamek for suggesting a method of optimization
;; The Highest Common Factor of two integers is the largest integer that divides exactly into the both.
;; e.g. $hcf(6,4) = 2
alias hcf {
while ($2) tokenize 32 $2 $calc($1 % $2)
return $1
}
;; The Lowest Common Multiple of two integers is the smallest integer which both divide exactly into.
;; e.g. $lcm(6,4) = 12
alias lcm {
return $calc($1 *$2 /$hcf($1,$2))
}
;; This alias turns any decimal number into a top heavy fraction in its lowest terms.
;; e.g. $fract(1.56) = 39/25
alias fract {
if (. !isin $$1) return $1
var %n = $calc(10^($len($1)-$pos($1,.)))),%x = $calc(%n *$1),%f = $hcf(%n,%x)
return $+($calc(%x /%f),/,$calc(%n /%f))
}
;; Top
;;----------------------------------------------------------------------------------------
;; Identifier to return the angle between two lines
;; $angle(x1,y1,x2,y2,x1,y1,x2,y2) where the first x1,y1,x2,y2 are the x and y points of the first line
;; The second 4 points are the x and y points of the second line
alias angle {
var %x1 = $3 - $1,%y1 = $4 - $2,%x2 = $7 - $5,%y2 = $8 - $6, $&
%m1 = $sqrt($calc((%x1 ^2)+(%y1 ^2))),%m2 = $sqrt($calc((%x2 ^2)+(%y2 ^2))), $&
%x1 = %x1 / %m1,%y1 = %y1 / %m1,%x2 = %x2 / %m2,%y2 = %y2 / %m2
return $round($calc(180*$acos($calc(%x1 *%x2 +%y1 *%y2))/$pi),2)
}
;; Top
;;----------------------------------------------------------------------------------------
;; Command to draw a line N angles from the specified line about the point x1,y1
;; /drawangle @Win color size x1 y1 x2 y2 angle
;; e.g. /drawangle @Win 4 4 0 0 100 0 45 will draw the line 0,0 to 100,0 45 degrees clockwise from 0,0,100,0
;; When used as an identifier as $drawangle(x1,y1,x2,y2) it will return the co-ordinate of the point
;; where the line creates the specified angle
alias drawangle {
if (!$isid) tokenize 32 $4-8 $1-3
var %3 = $3 - $1,%4 = $4 - $2,%c = $cos($5).deg,%s = $sin($5).deg, $&
%x = $1-2 $calc($1 +%c *%3 -%s *%4),%y = $calc($2 +%s *%3 +%c *%4)
if ($isid) return %x %y
drawline $6-8 %x %y
}
;; Top
;;----------------------------------------------------------------------------------------
;; $talker(text,burcN,burcN) - first burcN lets you specify the modes for the first letter of each word
;; second burcN is for the second word. b = bold, u = underline, r = highlight, cN = Nth color
;; eg. $talker(text here,buc3,c2) returns 3t2ext 3h2ere
alias talker {
var %m
.echo -q $regsub($1,/(?<=^| )(.)/g,$+($m($2),\1,$chr(15),$m($3)),%m)
return %m
}
alias -l m return $replace($1,b,$chr(2),u,$chr(31),r,$chr(22),c,$chr(3))
;; Top
;;-----------------------------------------------------------------------------------------
;; Alias for an mp3 rank system.
;; /mp3rank filename will add a "point" to a song
;; $mp3rank(filename) will retrieve its rank
;; $mp3rank(filename).ord will return the rank in ordinal form (1st/2nd/3rd etc.)
;; $mp3rank(filename).tp will return the amount of times the file has been played
alias mp3rank {
if ($isid) {
if ($prop = tp) return $iif($gettok($read(mp3rank.txt,w,* $1-),1,32),$ifmatch,0)
window -h @Mp3rank
filter -eutfw 1 32 mp3rank.txt @Mp3rank
.timer 1 1 window -c @Mp3rank
var %r = $fline(@Mp3rank,* $+ $1-)
return $iif($prop = ord,$ord(%r),%r)
}
var %n = $gettok($read(mp3rank.txt,w,* $+ $1-),1,32)
write $iif($readn,-l $+ $readn) mp3rank.txt $calc(%n +1) $1-
}
;; Top
;;----------------------------------------------------------------------------------------
;; Remove html from a string
;; Usage: $remhtml(string)
;; Also converts N; html "special characters"
alias remhtml {
var %m
.echo -q $regsub($1-,/(?:^[^<]+?>|<.+?>|<[^>]+?$)/gs,,%m)
while ($regex(%m,/((\d{1,3});)/s)) %m = $replace(%m,$regml(1),$chr($regml(2)))
return %m
}
;; Top
;;----------------------------------------------------------------------------------------
;; Simple file encryption to make information illegible
;; /encdec [-r]
;; Using the -r switch opens the file after completing the encryption
alias encdec {
:-(
var %f = $$sfile(C:\,Input file to encode/decode,Input)
if (!$isfile(%f)) goto -(
var %v = $$sfile(C:\,Output file to be created/overwritten,Output),%i 0,%w @EncDec
clear %w
window -ea %w
while (%i <= $calc($lof(%f) /8192)) {
bread $+(",%f,") $calc(8192*%i) $calc(8192*(1+%i)) &t $+ $calc(1+%i)
inc %i
}
var %n = %i
$iif($line(%w,0),rline,iline) %w 1 $+($chr(3),12,$chr(44),12,$str(_,50),$chr(3)) 0% Done
while (%n) {
var %x = $bvar(&t $+ %n,0)
while (%x) {
var %o = $bvar(&t $+ %n,%x)
bset &w $+ %n %x $iif($len(%o) = 2,$iif(*0 !iswm %o,$right(%o,1) $+
$left(%o,1),%o),$+($left(%o,1),$mid(%o,3,1),$mid(%o,2,1)))
dec %x
}
bwrite $+(",%v,") $calc(8192*(%n -1)) &w $+ %n
dec %n
var %p = $round($calc((1-(%n /%i))*50),0)
rline %w 1 $+($chr(3),04,$chr(44),04,$str(_,%p),$chr(3),12,$chr(44),12,$str(_,$calc(50-%p)),$chr(3)) $calc(2*%p) $+ %
Done
}
if ($1 = -r) run %v
}
menu @EncDec {
Close:/window -c $menu
Enc/Dec another file:{
clear
encdec
}
}
;; Top
;;----------------------------------------------------------------------------------------
;; Alias to scroll text in a dialog editbox
;; Usage: /sc_start <name> <id> <size> <direction> <delay in ms> <text>
;; is the dialog name
;; is the id of the editbox to scroll text in
;; is the amount of characters that fit inside the editbox
;; is the direction to scroll in. l = left, r = right
;; is the time in milliseconds between each scroll
;; is the text you wish to scroll
alias sc_start {
var %r = return,%e = echo $color(info) -ea * /sc_start:,%c = did -r $1-2
if ($isid) {
%e incorrect usage
%r
}
if (!$5) {
%e insufficient parameters
%r
}
if (!$dialog($1)) {
%e no such dialog
%r
}
if ($4 != l) && ($4 != r) {
%e invalid direction
%r
}
var %x = $timer(0)
while (%x) {
if ($+(sc_,$1,_,$2,_*) iswm $timer(%x)) {
.timer $+ $ifmatch off
%c
break
}
dec %x
}
var %a = did -a $1-2,%n = $+($iif($4 = l,$6-),$chr(160),$iif($3 > $len($6-),$str($chr(160),$calc($3 - $len($6-)))),$iif($4
= r,$6-)),%x = 1
%a %n
while (%x <= $len(%n)) {
$+(.timersc_,$1,_,$2,_,%x) -m 1 $calc($5*%x) %c $(|) %a $right(%n,$iif($4 = l,-) $+ %x) $+ $left(%n,$iif($4 = r,-)
$+ %x) $iif(!$calc($len(%n)-%x),$chr(124) sc_start $1-)
inc %x
}
}
on *:dialog:*:close:*:$+(.timersc_,$dname,*) off
;; Top
;;----------------------------------------------------------------------------------------
;; Snippet that works like $replace but will only replace a specified number of occurences of a string
;; Usage: $replace2(text,substring,newstring,N)
;; Where N is the number of times to replace
;; You can use the 'cs' property for case sensitivity.
;;
;; The reason for using $ [ $+ [ $0 ] ] as a starting value for the loop is that it can easily be turned
;; into a $remove2 alias simply by replacing $3 with $null in the code
;; Then you would use $remove2(text,substring,N)
alias replace2 {
var %t = $1,%x = $ [ $+ [ $0 ] ]
while (%x) {
.echo -q $regsub(%t,$iif($prop = cs,$2,$+(/,$2,/i)),$3,%t)
dec %x
}
return %t
}
Top
;;----------------------------------------------------------------------------------------
;; Centisecond timestamp
;; If you want a centisecond timestamp (showing hundredths of a second) type the command & use the remote
on *:start:.timermil -om 0 10 .timestamp -f $!+([HH:nn:ss:,$mid($ticks,-3,2),])
;; Top
;;----------------------------------------------------------------------------------------
;; Simple clone flood protection
;; Triggers if 4 users join from the same (type 4) host join in 7 seconds
;; Keeps track of the nicknames so as not to kick someone who may be "innocent"
on @*:join:#:{
var %m = $mask($fulladdress,4),%h = # $+ %m
hadd -mu7 c.flood %h $hget(c.flood,%h) $nick
tokenize 32 $hget(c.flood,%h)
if ($numtok($1-,32) = 3) {
mode # b %m
kick # $* Clone flood - 3 clones in 7 seconds ( $+ %m $+ )
}
}
;; Top
;;----------------------------------------------------------------------------------------
;; Simple repeat flood protection
;; Kicks for 4 repeated lines in 10 seconds
on @*:text:*:#:{
var %m = $hash($lower($strip($1-)),32),%v = $+(%m,$wildsite,#)
hinc -mu10 repeat %v
if ($hget(repeat,%v) = 5) .raw mode # b $wildsite $crlf kick # $nick :4 repeats in 10 seconds
}
;; Top
;;----------------------------------------------------------------------------------------
;; Simple command line away system
;; /away can be typed to set away & back
alias away {
if ($away) {
amsg I have returned from: $awaymsg - Gone: $duration($awaytime)
!away
return
}
!away $$?="Reason?"
amsg I am now away, reason: $!
}
;; Top
;;----------------------------------------------------------------------------------------
;; Simple caps kicker that kicks if someone typed over 80% capital letters
on @*:text:*:#:{
if ($calc($regex($1-,/[A-ZÀ-ÖØ-Ý]/g)/$len($1-)) > 0.8) .raw mode # b $wildsite $crlf kick # $nick :Excess caps
}
;; Top
;;----------------------------------------------------------------------------------------
;; Acronym replacer
;; This code will replace acronyms in your text
;; You can add extra acronyms and remove any you wish
;; Bear in mind this may interfere with any other acronym scripts you may have so disable those first before
;; trying this one out or combine them.
on *:input:*:{
;;The list of your acronyms, separate each of them with a comma (you can add color and style to them too)
;;but you can't use a comma in any of the replacements.
var %acronyms = lol laughing out loud,brb be right back,gtg got to go,bbl be back later
;;Main script, do not edit
if ((/* !iswm $1) || ($ctrlenter)) && ($active != Status Window) {
var %m = $1-
tokenize 44 %acronyms
while (%acronyms != $null) {
tokenize 32 $gettok(%acronyms,-1,44)
var %i = $findtok(%m,$1,0,32)
.echo -q $regsub(%m,$+(/(?<=^| ),$1,(?= |$)/gi),$2-,%m)
%acronyms = $deltok(%acronyms,-1,44)
}
say %m
haltdef
}
}
;; Top
;;----------------------------------------------------------------------------------------
;; Alias to notice all op/voices in a channel
;; /ov message will send an o/v notice to the active channel
alias ov {
if (# !ischan) return
var %m = $+(«Op/Voice-,#,») $+(«,$1-,»),%i = $nick(#,0,v)
.notice @ $+ # %m
while ($nick(#,%i,v) !isnum) {
if ($ifmatch !isop #) && ($ifmatch != $me) .notice $ifmatch %m
dec %i
}
echo -at -> %m
}
;; Top
;;----------------------------------------------------------------------------------------
;; Basic kick/ban/deop protection without revenge
;; Works on servers where ChanServ has an invite command restricted to non-regular users
;; Revenge does more harm than good since you are likely to flood off the server
on *:kick:#:{
if ($me !isreg #) && ($knick = $me) {
cs invite #
inc -u60 %inv. $+ #
}
}
on *:invite:#:{
if (%inv. [ $+ [ # ] ]) && ($me !ison #) {
join #
unset %inv. $+ #
}
}
on @*:ban:#:{
if ($banmask iswm $address($me,5)) .timerunban $+ # 1 3 mode # -b $banmask
}
on *:deop:#:{
if ($opnick = $me) .timerreop $+ # 1 3 cs op # $me
}
;; Top
;;----------------------------------------------------------------------------------------
;; Alias to insert commas into a number
;; $comma(number)
alias comma {
tokenize 46 $1
var %i = 1,%d,%n
while ($mid($1,- $+ %i,1) isnum) {
var %d = $ifmatch,%n = $+($iif(3 // %i,$chr(44)),%d,%n)
inc %i
}
return $iif($chr(44) $+ * iswm %n,$mid(%n,2),%n) $+ $iif($2,. $+ $2)
}
;; Top
;;----------------------------------------------------------------------------------------
;; Alias to differentiate an equation
;; From the returned equation you can then substitute x in to find the gradient of the line tangent to the curve at the given
point
;; For example: $diff(x^2 + 2x + 1) returns 2x + 2
;; Only supports polynomials in x, trigonometric/logarthmic functions not supported
alias diff {
tokenize 32 $1-
var %i = $0,%p,%e
while (%i) {
var %n = $ [ $+ [ %i ] ],%p = $gettok(%n,2,94),%c = $gettok(%n,1,120)
%e = $iif($istok(- + * /,%n,32),%n,$iif(x !isin %n,0,$iif(^ !isin %n,%c,$+($calc($iif(^* iswm
%c,1,%c)*%p),x^,$calc(-1+%p))))) %e
dec %i
}
.echo -q $regsub(%e,/([*/+-] 0)|\^1\D/g,$chr(32),%e)
return %e
}
;; Top
;;----------------------------------------------------------------------------------------
;; Alias that returns the tokens common to both strings
;; Usage: $comtok(string 1,C,string 2,C,N,C)
;; Eg: $comtok(one!two!three!four,33,three.four.five.six,46,1-,32) returns: three four
alias comtok {
var %1 = $1,%3 = $3,%i = $numtok(%3,$4),%f,%a
while (%i) {
%f = $gettok(%3,%i,$4)
if ($istok(%1,%f,$2)) %a = $instok(%a,%f,1,$6)
dec %i
}
return $gettok(%a,$5,$6)
}
;; Top
;;----------------------------------------------------------------------------------------
;; When used as an identifier it encrypts a string of HTML
;; Returns the ecrypted string in a javascript ready to be put on your webpage
;; Example: //echo -a $htmlenc(<script>function secret() { if (document.form1.input1.value=="secret")
location.href='page2.html' }</script>)
;;
;; When used as a command it encrypts a whole HTML file into a new file called HTMLEnc
;; Example: /htmlenc index.html
;; This will become HTMLEncindex.html
;;
;; Please note that this is not 100% secure and the process can be reversed to find the original HTML
;; Also note that due to binary variables being able to store only up to 8,192 bytes in versions of mIRC less than 6.1, you
;; must use the second alias with files less than 2,716 bytes or split the file up into manageable pieces and have multiple
;; encrypting javascripts on 1 page
;; This limit is 2,715 bytes because the script will take up 45bytes + 3*<amount of bytes the html file is>
alias htmlenc {
var %c = echo $color(i) -ea,%r = return,%e = (line $!scriptline $!+ , $!nopath($script) $!+ )
if ($isid) {
if ($1 = $null) {
%c Include string to encrypt $eval(%e,2)
%r
}
var %i = $len($1-),%s
while (%i) {
%s = $+(%,$base($asc($mid($1-,%i,1)),10,16),%s)
dec %i
}
%r <script>document.write(unescape(" $+ %s $+ "))</script>
}
var %d = $lof($1),%f = HTMLEnc $+ $nopath($1)
if ($1 = $null) {
%c supply a filename $eval(%e,2)
%r
}
if (!$isfile($1)) {
%c file doesn't exist $eval(%e,2)
%r
}
if (%d > 2715) && ($version < 6.1) {
%c file too large $eval(%e,2)
%r
}
if ($isfile(%f)) btrunc %f 0
bset -t &y 1 <script>document.write(unescape("
bread $+(",$1,") 0 %d &t
var %t = $bvar(&t,0),%h,%i = 1,%b = 34
while (%i <= %t) {
%h = $bvar(&t,%i)
if (%h > 16) {
bset -t &y %b % $+ $base(%h,10,16)
%b = 1 + $bvar(&y,0)
}
inc %i
}
bset -t &y %b "))</script>
bwrite %f -1 -1 &y
echo -ea Encryption complete. /run %f
}
;; Top
;;----------------------------------------------------------------------------------------