tglogo.png

Downloading File

Filename: /splitmsg
; --------------------------------------
; /splitmsg v1.0 - by Flobse
;
; This snippet split a long textline in more lines.
; It try to doesnt split in a word and it support also colorcodes.
; The main-function is /msg, but you can also specify other commands, 
; maybe to add a token seperated line in a dialog or whatever
; or just to use /notice, /echo or smth.
;
; In the alias you can set in the first var's the standard settings.
; 
;
; Have Fun!
;
; --------------------------------------
; Syntax: /splitmsg [-lNtN] <"command"|target> <text>
;
; Parameters:
; -l is lenght. Example -l50 for a max linelenght of 50 signs.
;    The lenght means the whole-lenght including colorcodes.
; -t is token. Example -l44 to split the textline on "," if its possible. (Standard is -t32)
; <"Command"|Target> means that u have to set there an $qt(Command) what have to used on every line,
; or just an Target like a #Channel or $nick where you want to /msg the splitted lines.
;
; --------------------------------------
; Examples:
;
; /splitmsg #chan Blablupp etc. for a standard splitmsg.
; /splitmsg -l250 $nick Blabla to msg the nick with a max lenght of 250 signs per line.
; /splitmsg $qt(echo -s) Blabla to echo all splitted lines into the status window.
; /splitmsg -l500t9 $qt(did -a MyDialog 9) blablupp to add all splitted lines, seperated with tabulator and lenght 500 to your dialog.
;
; --------------------------------------
; ## #Flobse @ Quakenet - [email protected] - UIN: 152759920 ##


splitmsg {
  var %standardlength 473, %standardtoken 32, %standardcommand msg
  if (!$regex(split,$1-,/^(-[lt\d]+ )?((?:".+?")|(?:\S+)) (.+)/i)) { echo -sc info2 * /splitmsg: insufficient parameters. | return }
  var %length %standardlength, %token %standardtoken
  if ($asc($regml(split,1)) == 45) && ($regex(split2,$regml(split,1),/([lt])(\d+)/g)) {
    var %length $iif($regml(split2,1) == l && $regml(split2,2) isnum 0-,$v1,$iif($regml(split2,3) == l && $regml(split2,4) isnum 0-,$v1,%standardlength))
    var %token $iif($regml(split2,1) == t && $regml(split2,2) isnum 1-255,$v1,$iif($regml(split2,3) == t && $regml(split2,4) isnum 1-255,$v1,%standardtoken))
  }
  var %regml $iif($asc($regml(split,1)) == 45,2,1)
  var %cmd $iif(" isin $regml(split,%regml),$noqt($v2),%standardcommand $v2) | inc %regml
  var %text $regsubex(colrep,$regml(split,%regml),/(\d)(\D)/g,0\1\2)
  if (%length == 0) { var %length $len(%text) }
  var %x 1, %r, %tokens $numtok(%text,%token), %ol
  while (%text != $null) {
    var %r $iif(%r != $null,%r $+ $chr(%token)) $+ $gettok(%text,%x,%token), %ol $len(%text)
    if (%x > 1) && ($len(%r) > %length) {
      dec %x
      %cmd $gettok(%text,1- $+ %x,%token)
      var %color $gettok($gettok(%text,1- $+ %x,%token),$numtok($gettok(%text,1- $+ %x,%token),15),15)
      var %color $iif($regex(%color,/(\d\d?)/g), $+ $regml($v1)) $+ $iif(2 \\ $count(%color,$chr(31)),$chr(31)) $+ $iif(2 \\ $count(%color,$chr(2)),$chr(2))
      var %text $iif($gettok(%text,$calc(%x +1) $+ -,%token) != $null,%color $+ $v1), %x, %r, %tokens $numtok(%text,%token)
      if (%ol == $len(%text)) { echo -sc info2 * /splitmsg: Error occured. Increase the messagelength. | return }
    }
    elseif ($len(%r) > %length) || (%x >= %tokens) {
      %cmd $left(%text,%length)
      var %color $gettok($left(%text,%length),$numtok($left(%text,%length),15),15)
      var %color $iif($regex(%color,/(\d\d?)/g), $+ $regml($v1)) $+ $iif(2 \\ $count(%color,$chr(31)),$chr(31)) $+ $iif(2 \\ $count(%color,$chr(2)),$chr(2))
      var %text $iif($right(%text,- $+ %length) != $null,%color $+ $v1), %x, %r, %tokens $numtok(%text,%token)
      if (%ol == $len(%text)) { echo -sc info2 * /splitmsg: Error occured. Increase the messagelength. | return }
    }
    inc %x
  }
}

Related Files

by Paul and Gabriel
by eXonyte

Please note that on our website we use cookies necessary for the functioning of our website, cookies that optimize the performance. To learn more about our cookies, how we use them and their benefits, please read our Cookie Policy.
I Understand