All pastes #1239292 Raw Edit

LS Relay Script (0.1)

public text v1 · immutable
#1239292 ·published 2008-10-29 03:08 UTC
rendered paste body
;Check that chan exists (and you're in it)
;Customize output format
;Silence relay start on auto day switch
;Network connects/disconnects
;Allow color stripping
;Auto-start on startup/reconnect
;Easy way to start/stop relay
;Switches for relay option overrides (make it easier to script with)
;Add color regex (logger option)

alias ffxi_relay {
  if ($1 == off) {
    .timerffxi_relay* off
    unset %ffxi_relay*
    echo -a Relay Stopped
    return
  }
  if (!$readini($options,Options,RelayChar)) {
    if (!$isid) echo -a Configuration File Error: No character specified
    return
  }
  if (!$readini($options,Options,LogDirectory)) {
    if (!$isid) echo -a Configuration File Error: No log path specified
    return
  }
  var %logfiledir = $readini($options,Options,LogDirectory)
  if ($right(%logfiledir,1) !isin \/) %logfiledir = %logfiledir $+ \

  set %ffxi_relay_file $+(%logfiledir,$readini($options,Options,RelayChar),_,$asctime($ctime,yyyy.mm.dd),.log)
  set  %ffxi_relay_line $iif($exists(%ffxi_relay_file),$lines(%ffxi_relay_file),0)
  echo -a Relay Started
  .timerffxi_relay_check 0 1 ffxi_relay_check
}

alias -l options return $scriptdirffxi_relay.ini
alias -l ffxi_relay_colorcheck return $iif(c isin $chan($1).mode,$strip($2-,c),$2-)

alias -l ffxi_relay_check {
  ;%ct = color and timestamp regex. may change in logger versions
  var %ct = (?:\[\d\d:\d\d:\d\d\])?
  var %ffxi_relay_chan = $readini($options,Channel,RelayChannel)
  while ($read(%ffxi_relay_file,r,/^ $+ %ct $+ <([a-z]+)>\s*(.*)$/i,%ffxi_relay_line)) {
    %ffxi_relay_line = $calc($readn + 1)
    if (%ffxi_relay_chan) msg $v1 $ffxi_relay_colorcheck($v1,$+($chr(2),$regml(1),$chr(2),:,$chr(32),$replace($regml(2),ï',09<,ï $+ $chr(40),04>)))
  }
  if (($regex(%ffxi_relay_file,/_(.*).log/)) && ($regml(1) != $asctime($ctime,yyyy.mm.dd))) ffxi_relay
}