Mattbuck's special aliases

These functions provide some useful tools not included in the standard mIRC release.

Pre-requisites - Usage - Script

Pre-requisites:

mattbuck's maths function aliases

 

 

Usage:

To use the script, make sure you have all prerequisites, then copy the script below into a new section of the aliases tab of mIRC script editor.  It provides the following commands (capital letters in parameters represent required fields):

$wret(A,B) Returns the Bth word from the string A. If B = 0, it returns the number of words in A.
$raneg(A,B) Returns a random number between A and B or -A and -B.
$ranick(a) Returns a random nick from channel a (if a not specified it uses $chan)
$reverse(A) Returns A reversed, eg $reverse(reverse) is esrever
$stdb(A) Returns A with S and D swapped with T and B respectively.
$fixlog(A) Converts chatlog file A into HTML.

 

 

Script:

/wret {
  if ($remove($2,-) !isnum) { return error }
  elseif ($2 == 0) { return $in($pos($1,$chr(32),0),1) }
  elseif ($right($2,1) == -) { return $right($1,$neg($pos($1,$chr(32),$de($left($2,-1),1)))) }
  elseif ($pos($2,-,0) == 1) {
    var %startword = $left($2,$de($pos($2,-,1),1)), %endword = $right($2,$neg($pos($2,-,1))), %left, %right
    if (%endword >= $in($pos($1,$chr(32),0),1)) { %left = $1 }
    else { %left = $left($1,$de($pos($1,$chr(32),%endword),1)) }
    if (%startword > 1) { %right = $right(%left,$neg($pos($1,$chr(32),$de(%startword,1)))) }
    else { %right = %left }
    return %right
  }
  else {
    if ($pos($1,$chr(32),0) < $de($2,1)) { return $null }
    var %sp1 = $pos($1,$chr(32),$de($2,1)), %sp2 = $pos($1,$chr(32),$2), %chop
    if ($2 == 1) { %sp1 = $neg($len($1)) }
    if (%sp2 == $null) { %chop = $1 }
    else { %chop = $left($1,$de(%sp2,1)) }
    return $right(%chop,$neg(%sp1))
  }
}

/raneg {
  if ($rand(+,-) == +) { return $rand($1,$2) }
  else { return $neg($rand($1,$2)) }
}

/ranick {
  var %chan $chan
  if ($1 ischan) { %chan = $1 }
  return $nick(%chan,$rand(1,$nick(%chan,0)))
}

/reverse {
  var %in = $1-, %out, %ln = $len(%in)
  :revcurse
  %out = %out $+ $mid(%in,%ln,1)
  if ($mid(%in,%ln,1) = $chr(32)) { %ln = %ln - 1 | %out = %out $mid(%in,%ln,1) }
  dec %ln 1
  if (%ln < 1) { return %out }
  else goto revcurse
}

/stdb {
  return $replace($replace($replace($replace($replace($replace($replace($replace($replace($1-,s,$chr(198)),t,s),$chr(198),t),d,$chr(198)),b,d),$chr(198),b),q,$chr(198)),p,q),$chr(198),p)
}



/fixlog {
  if (!$1 || $exists($1) != $true) { echo File location error | Halt }
  elseif ($right($1,4) != .txt) { echo File type error | Halt }
  var %file = $1, %quote = %file
  .remove logtemp.txt
  copy %file logtemp.txt
  %file = logtemp.txt
  var %line = 1, %max = $lines(%file), %start2 = $ctime
  :gtlt
  var %read = $read(%file,n,%line)
  if ($chr(60) isin %read || $chr(62) isin %read) {
    write -l $+ %line %file $replace($replace(%read,<,&lt;),>,&gt;)
  }
  if (%line < %max) { inc %line 1 | goto gtlt }
  echo Completed replacement of < & > in $calc($ctime - %start2) seconds.
  var %line = 1, %start3 = $ctime

  :linecol
  var %read = $read(%file,n,%line), %colour
  if ($wret(%read,4) == $chr(42)) {
    if ($wret(%read,6-8) == was kicked by || $wret(%read,6-7) == sets mode:) { %colour = FF0000 }
    elseif ($wret(%read,6-8) == changes topic to) { %colour = FFFF00 }
    elseif (*@* iswm $wret(%read,6) || $wret(%read,6-9) == is now known as) { %colour = 008800 }
    else { %colour = 00FF00 }
    write -l $+ %line %file <font color="# $+ %colour $+ "> $+ %read $+ </font>
  }
  if (%line < %max) { inc %line 1 | goto linecol }
  var %line = 1, %start4 = $ctime
  echo Completed colouring of kicks, modes, topics, joins, parts, nicks, quits and slaps in $de($ctime,%start3) seconds.

  :addbr
  write -l $+ %line %file $read(%file,n,%line) $+ <br>
  inc %line 1
  if (%line < %max) { goto addbr }
  var %line = 1, %start5 = $ctime
  echo Completed addition of <br> tags in $de($ctime,%start4) seconds.
  echo Operation completed in $de($ctime,%start1) seconds. Opening file.
  run %file
}

 


Click to return to the mattbot index.