All pastes #337419 Raw Edit

Unnamed

public text v1 · immutable
·published 2007-02-02 20:00 UTC
rendered paste body
on *:input:*:{
  if (/* !iswm $1) {
    set %translate-text $1-
    set %translate-chan $active
    translate-text
    halt
  }
}

alias -l translate-text {
  sockopen lang ets.freetranslation.com 80
}
on *:SOCKOPEN:lang:{
  sockwrite -n $sockname GET /?srcText= $+ $replace(%translate-text,$chr(32),$+(%,2,0)) $+ &mode=html&template=results_en-us.htm&sequence=core&language= $+ English $+ $+(%,2,F) $+ Spanish HTTP/1.1
  sockwrite -n $sockname Host: ets.freetranslation.com $+ $crlf $+ $crlf
}
on *:SOCKREAD:lang:{
  if ($sockerr) { /echo -a Sorry $nick There was a problem connecting to the site, try again soon. | { /halt } }
  else {
    var %outcome-looks-?
    sockread -f %outcome-looks-?
    if (*textarea name="dsttext" cols="40" rows="6"* iswm %outcome-looks-?) { 
      /msg %translate-chan $html($remove(%outcome-looks-?,$chr(9)))
      /unset %translate* %%outcome-looks-? 
      /sockclose lang
      /halt
    }
    if ($sockerr) { /echo -a Sorry $nick There was a problem connecting to the site, try again soon. }
  }
}

alias -l html {
  var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x,&nbsp;)
  return %x
}