All pastes #148038 Raw Edit

Miscellany

public text v1 · immutable
#148038 ·published 2006-08-24 20:50 UTC
rendered paste body
on *:TEXT:*:*:{ 
  if ($1 == !trans) { 
    if (!$2) { 
      msg $chan [ $+ Dicitionary $+ ] nothing to Translate! 
      halt 
    } 
    set %trans.input $replace($lower($2-),$chr(32),+)
    if $sock(Dicitionary) { sockclose Dicitionary } 
    sockopen Dicitionary http://www.tranexp.com
    set %trans.nick $nick 
  } 
} 
on *:SOCKOPEN:Dicitionary: { 
  sockwrite -n Dicitionary GET /2000/Translate/result.shtml  HTTP/1.1
  sockwrite -n Dicitionary Host: http://www.tranexp.com

} 
on *:SOCKREAD:Dicitionary: { 
  if ($sockerr) { 
    notice %trans.nick $cmderror Socket error translating %trans.input $+ ! 
    sockclose Dicitionary
    halt 
  }  
  else { 
    var %Dicitionary
    sockread %Dicitionary
    var %Dicitionary = $htmlfree(%Dicitionary) 
    if (trans: isin Dicitionary) { notice %trans.nick [ $+  Translation $+ ] $right(%Dicitionary,-6) } 
  } 
} 
alias htmlfree { 
  var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x,&nbsp;) 
  return %x 
}