alias F5 /exportline
alias /exportline {
  ;-- Iterator vars
  var %i = 1
  var %j = $cb(0)
  ;-- RegExp's
  var %re.eline /\*\* Export Line \[ver ([\d]+)\] -- (.*) \[ver ([\d]+)\]: \*\*/
  var %re.pname /(The Province of|Buildings Report of|Science Intelligence on|Military Intelligence on) (.*) \(([\d]+):([\d]+)\)/
  var %re.netdef /Net Defense at Home \(from Utopia\): (.*)/
  var %re.back /\*\* Armies [#\/\d]+ \(Back in (.*) hours\) \*\*/
  ;new shit
  var %re.racepers /Personality & Race: (.*), (.*)/si
  var %re.acres /Land: ([\d,]+) Acres/
  var %re.gc /Money: ([\d,]+)gc \(([\d,]+)gc/
  var %re.food /Food: ([\d,]+) bushels/
  var %re.runes /Runes: ([\d,]+) runes/
  var %re.nw /Total Networth: ([\d,]+)gc \(/
  ;var %re.nw /Total Networth: 153,492gc (155.36 per Acre)
  var %re.off /Total Modified Offense: ([\d,]+) \(([\d.]+)/
  var %re.def /Total Modified Defense: ([\d,]+) \(([\d.]+)/
  var %re.hit /Province was (.*)/
  ;-- Scan the Clipboard
  while (%i <= %j) {
    ;-- Get Province name
    if ($regex($cb(%i),%re.pname)) var %el.pname $regml(2) ( $+ $regml(3) $+ : $+ $regml(4) $+ )
    ;get som datas
    if ($regex($cb(%i),%re.netdef)) var %el.netdef $regml(1)
    if ($regex($cb(%i),%re.back)) {
      ; say !xarmy $replace($regml(1),$chr(58),$chr(46)) %el.pname
    }
    ;get cb datas
    if ($regex($cb(%i),%re.racepers)) {
      var %cb.race $regml(2)
      var %cb.pers $regml(1)
    }

    ;if ($regex($cb(%i),%re.acres)) var %cb.acres $remove($regml(1),$chr(44))
    ;if ($regex($cb(%i),%re.gc)) var %cb.gc $remove($regml(1),$chr(44))
    ;if ($regex($cb(%i),%re.gc)) var %cb.income $regml(2)   
    ;if ($regex($cb(%i),%re.gc)) var %cb.gc $int($calc($remove($regml(1),$chr(44)))) $+ k
    ;if ($regex($cb(%i),%re.food)) var %cb.food $int($calc($remove($regml(1),$chr(44)) / 1000)) $+ k
    ;if ($regex($cb(%i),%re.runes)) var %cb.runes $int($calc($remove($regml(1),$chr(44)) / 1000)) $+ k
    ;if ($regex($cb(%i),%re.nw)) var %cb.nw $int($calc($remove($regml(1),$chr(44)) / 1000)) $+ k
    ;if ($regex($cb(%i),%re.off)) var %cb.off $int($calc($regml(1) / 1000)) $+ k $+ ( $+ $regml(2) $+ )
    ;if ($regex($cb(%i),%re.def)) var %cb.def $int($calc($regml(1) / 1000)) $+ k $+ ( $+ $regml(2) $+ )

    if ($regex($cb(%i),%re.acres)) var %cb.acres $remove($regml(1),$chr(44))
    if ($regex($cb(%i),%re.gc)) var %cb.gc $remove($regml(1),$chr(44))
    if ($regex($cb(%i),%re.gc)) var %cb.income $regml(2)   
    if ($regex($cb(%i),%re.gc)) var %cb.gc $remove($regml(1),$chr(44))
    if ($regex($cb(%i),%re.food)) var %cb.food $remove($regml(1),$chr(44))
    if ($regex($cb(%i),%re.runes)) var %cb.runes $remove($regml(1),$chr(44))
    if ($regex($cb(%i),%re.nw)) var %cb.nw $remove($regml(1),$chr(44))
    if ($regex($cb(%i),%re.off)) var %cb.off $remove($regml(1),$chr(44)) $+ ( $+ $regml(2) $+ )
    if ($regex($cb(%i),%re.def)) var %cb.def $remove($regml(1),$chr(44)) $+ ( $+ $regml(2) $+ )

    ;prov hits
    if ($regex($cb(%i),%re.hit)) {
      if (couple isin $regml(1)) var %paste.hit a couple of times ~ 90% gains OOW
      if (moderately isin $regml(1)) var %paste.hit Moderately ~ 75% gains OOW
      if (heavily isin $regml(1)) var %paste.hit Heavily ~ 40% gain OOW
      if (extremely isin $regml(1)) var %paste.hit Extremely heavily ~ 20% gain OOW
    }

    ;-- Get Exportline and Type
    if ($regex($cb(%i),%re.eline)) {
      var %el.type = $regml(2) v. $+ $regml(1) $+ . $+ $regml(3)
      var %k $calc(%i +1)
      while ((%k <= %j) && ($cb(%k) != $null)) {
        var %el.eline %el.eline $cb(%k)
        inc %k
      }
    }
    inc %i
  }
  ;show cb info
  if (%cb.race != $null) {
    say =============================================================
    say 15»14»412 %el.pname  14«15«14  %cb.race %cb.pers 
    say 4»» 7Land: %cb.acres 7Gold: %cb.gc 7Food: %cb.food 7Runes: %cb.runes
    ;say 4»» 7Daily Income: %cb.income 7gc
    say 4»» 7NW: $iif(%cb.nw != $null,$ifmatch,N/A) 7Offence: %cb.off 7Defense: %cb.def
    say 4»» 4Province has been hit $iif(%paste.hit != $null,$ifmatch,None/Once = 100% gain)

  }
  if (%el.eline != $null) {
    ;-- Vars
    ; %el.pname = province name
    ; %el.eline = exportline
    ; %el.type = exportline type and version
    ; %el.netdef = netdef home (som only)
    say $+(4IRC Export Line » %el.eline 4« %el.type)
    if (%el.netdef != $null) say NetDef(home): %el.netdef

  }
  else {
    echo -tmg 4 !
  }
  say =============================================================
}
;-- Makes the Exportline clickable
on ^*:hotlink:*:*:{
  if ($regex($strip($hotline),/» (.*?) «/)) {
    ; exportline is in $regml(1)
    if ($mouse.key & 1) clipboard $regml(1)
    return
  }
  else {
    halt
  }
}