All pastes #50789 Raw Edit

Someone

public text v1 · immutable
#50789 ·published 2006-04-23 22:37 UTC
rendered paste body
on *:input:*: {
  if ( ( $left($1,1) != / ) || ( $1 == /me ) ) {
    ;
    ; Quick Input check, if under 400 characters, don't bother
    var %textlen = $len($1-)
    ;
    if (%textlen > 400) {   
      ;
      var %pos = 1
      var %text = $mid($1-, %pos, 400)
      var %firsttime = 1
      ;
      while ( %text != $null ) {
        ;
        ; Try to cut at the last word but if the last word is too long
        ; then just crop in the middle and be done with it.
        ;
        if ( $len($deltok(%text, -1, 32)) < 370 ) {
          %text = $left(%text, 370)
          inc %pos 370
        }
        else {
          %text = $deltok(%text,-1,32)
          inc %pos $len(%text)
          inc %pos
        }
        ;
        ; Store the outgoing text, and figure if this is the last
        ; batch of text we're sending, to see if we need to end it.
        ;
        var %outtext = %text
        %text = $mid($1-, %pos, 400)
        ;
        ; If this is the first batch of text, figure on what to do
        ;
        if (%firsttime == 1) {
          if ($gettok(%outtext, 1, 32) == /me) {
            ; This is a me command, treat it as such
            %outtext
          }
          else {
            ; Regular plain text being sent.
            say %outtext
          }
          ;
          %firsttime = 0;
        }
        else {
          ;
          ; Not the first, we're in the middle or end now.
          ;
          if (%text != $null) {
            ; This is only a fragment of a statement.
            say %outtext
          }
          else {
            if (%textlen <= 945) {
              ; If this is is it, mark the end flag
              say %outtext
            }
            else {
              ; Input is empty, but the user may not be done.
              say %outtext
            }
          }
        }
      }
      ;
      ; Prevent regular output from being sent to the server
      ;
      halt
    }
  }
}