Posted by Anonymous Fri 23rd Feb 2007 23:43 - Syntax is None/text - 71 views
Download | New Post | Modify | Hide line numbers
  1. ;en = English,sp[es] = Spanish,fr = French,ge[de] = German,it = Italian,por[pt] = Portuguese
  2. on $*:TEXT:$(/^(?>\Q $+ $me $+ \E,? ?)?([!.@](trans(late)?|lang(uage)?)).*/Si):#:{
  3.   tokenize 32 $iif($me isin $1,$deltok($1-,1,32),$1-)
  4.   if (($me != Plasma) && ($read(onebot.txt, s, $chan))) { halt }
  5.   if (!$2) {
  6.     notice $nick $c1(Please select a correct language to translate to and from. Currently Supports:) $c2(en = English) $c1($chr(124)) $c2(sp = Spanish) $c1($chr(124)) $c2(fr = French) $c1($chr(124)) $c2(ge = German) $c1($chr(124)) $c2(it = Italian) $c1($chr(124)) $c2(por = Portuguese) $c1(Example:) $c2(!translate en-sp Hello) $c1(Remember the languages must be different!)
  7.     halt
  8.   }
  9.   if (!$3) {
  10.     notice $nick $c1(Please select a correct language to translate to and from. Currently Supports:) $c2(en = English) $c1($chr(124)) $c2(sp = Spanish) $c1($chr(124)) $c2(fr = French) $c1($chr(124)) $c2(ge = German) $c1($chr(124)) $c2(it = Italian) $c1($chr(124)) $c2(por = Portuguese) $c1(Example:) $c2(!translate en-sp Hello) $c1(Remember the languages must be different!)
  11.     halt
  12.   }
  13.   if (!$lang($gettok($2,1,45),$gettok($2,2,45))) {
  14.     notice $nick $c1(Please select a correct language to translate to and from. Currently Supports:) $c2(en = English) $c1($chr(124)) $c2(sp = Spanish) $c1($chr(124)) $c2(fr = French) $c1($chr(124)) $c2(ge = German) $c1($chr(124)) $c2(it = Italian) $c1($chr(124)) $c2(por = Portuguese) $c1(Example:) $c2(!translate en-sp Hello) $c1(Remember the languages must be different!)
  15.     halt
  16.   }   
  17.   else {
  18.     /inc %Aa
  19.     /set $+(%,langtext,%Aa) $replace($3-,$chr(32),+)
  20.     /set $+(%,lang,%Aa) $replace($2,$chr(45),$chr(124),eng,en,sp,es,ger,de,ge,de,por,pt)
  21.     if ($readini(public_cmds.ini,Channels,$chan) == off) {
  22.       /set $+(%,langtarget,%Aa) $iif($left($1,1) == @,notice $nick,.notice $nick)
  23.     }
  24.     else {
  25.       /set $+(%,langtarget,%Aa) $iif($left($1,1) == @,msg $chan,.notice $nick)
  26.     }
  27.     /sockopen $+(lang.,%Aa) translate.google.com 80
  28.   }
  29. }
  30. on *:SOCKOPEN:lang.*:{
  31.   /sockwrite -n $sockname GET /translate_t?text= $+ $($+(%,langtext,$gettok($sockname,2,46)),2) $+ &langpair= $+ $($+(%,lang,$gettok($sockname,2,46)),2) HTTP/1.1
  32.   /sockwrite -n $sockname Host: translate.google.com $+ $crlf $+ $crlf
  33. }
  34. on *:SOCKREAD:lang.*:{
  35.   /sockread &var
  36.   /bwrite test.txt 1 -1 &var
  37.   /set $+(%,langstart,$gettok($sockname,2,46)) $bfind(&var,1,
    )
  38.   /set $+(%,langend,$gettok($sockname,2,46)) $bfind(&var,$($+(%,langstart,$gettok($sockname,2,46)),2),
    )
  •   /set $+(%,langoutput,$gettok($sockname,2,46)) $bvar(&var,$($+(%,langstart,$gettok($sockname,2,46)),2),$calc($($+(%,langend,$gettok($sockname,2,46)),2) - $($+(%,langstart,$gettok($sockname,2,46)),2))).text
  •   $($+(%,langtarget,$gettok($sockname,2,46)),2) $c1(The translation for:) $c2($replace($($+(%,langtext,$gettok($sockname,2,46)),2),+,$chr(32))) $c1(from) $c2($replace($gettok($($+(%,lang,$gettok($sockname,2,46)),2),1,124),en,English,es,Spanish,fr,French,de,German,it,Italian,pt,Portuguese)) $c1(to) $c2($replace($gettok($($+(%,lang,$gettok($sockname,2,46)),2),2,124),en,English,es,Spanish,fr,French,de,German,it,Italian,pt,Portuguese)) $c1(is:) $c2($remove($($+(%,langoutput,$gettok($sockname,2,46)),2),
    ))
  •   /unset $+(%,lang*,$gettok($sockname,2,46))
  •   halt
  • }
  •  
  • alias lang {
  •   if (($regex($1,/(eng|en|es|sp|fr|de|ge|ger|it|por|pt)$/Si)) && ($regex($2,/(eng|en|es|sp|fr|de|ge|ger|it|por|pt)$/Si)) && ($replace($1,eng,en,sp,es,ger,de,ge,de,por,pt) != $replace($2,eng,en,sp,es,ger,de,ge,de,por,pt))) {
  •     return true
  •   }
  • }

  • PermaLink to this entry https://pastebin.co.uk/10857
    Posted by Anonymous Fri 23rd Feb 2007 23:43 - Syntax is None/text - 71 views
    Download | New Post | Modify | Hide line numbers

     

    Comments: 0