All pastes #152229 Raw Edit

Something

public text v1 · immutable
#152229 ·published 2006-08-28 17:22 UTC
rendered paste body
on $*:TEXT:/^[@!]trans(lation|late)/Si:#:{ 
  set %trans.dest $iif($left($1,1) == @,msg $chan,notice $nick)
  if (!$2) { %trans.dest Sorry, you didn't specify a word to translate. } 
  set %trans.input $replace($lower($2-),$chr(32),+)
  sockopen spanishtran ets.freetranslation.com 80
}
on *:SOCKOPEN:spanishtran:{ 
  sockwrite -n spanishtran GET /?srcText= $+ %trans.input $+ &mode=html&template=results_en-us.htm&sequence=core&language=English%2FSpanish HTTP/1.1
  sockwrite -n spanishtran Host: ets.freetranslation.com $+ $crlf $+ $crlf
} 
on *:SOCKREAD:spanishtran:{ 
  if ($sockerr) { %trans.dest $sockerror | sockclose spanishtran }    
  var %result | sockread -f %result
  set %trans.result $remove($htmlfree(%result),$chr(9))
  sockread -f %trans.result 
  if (*writetoolbar* iswm %trans.result) {
    sockread -f %trans.result | sockread -f %trans.result 
    %trans.dest Spanish Translation for $+($replace(%trans.input,+,$chr(32)),:) $+(,$remove($htmlfree(%trans.result),$chr(9)),)
    sockclose $sockname | halt
  }
}
on *:sockclose:spanishtran:{
  unset %trans.*
}
alias htmlfree { 
  var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x,&nbsp;) 
  return %x 
}