Auto Channel Google Translate

Platform:  mIRC
Published  Feb 03, 2011
Updated  Feb 03, 2011
Translates whatever text is put in the channel if these conditions are met:
1. The translation has been turned on in the channel
2. The text is not the same as the given text

It fetches a result from google and can translate the whole channel from (auto - but you can set primary) language to a specified language (Defaults to english). This is made for a bot - not yourself - it messages the channel whenever someone speaks if it finds a translation

Commands
!translate on - Turns autotranslation on for the channel you are in
!translate off - Turns autotranslation off for the channel you are in
!translate primary <Language CODE> - Sets the primary speaking language (Just updates a var in the url not sure if it does much xD)
!translate tolang <Language CODE> - Sets the language you want the bot to return in for example es will make it translate into spanish

Credits - other than myself ;)
FordLawnmower - For the UrlEncode alias
JimmyJames - idea :P ; Url Encode Alias made by FordLawnmower
alias UrlEncode return $regsubex($1-,/([^\d\w])/g,$+(%,$base($asc(\t),10,16)))
;End Short alias
on *:TEXT:*:#:{
if ($me != TransBot) halt
if ($readini(translation.ini,settings,$chan) == on && !* !iswm $1) {
translate $strip($remove($1-,>,<,$chr(58)),burcmo)
}
elseif ($1 == !translate) {
if ($2 == on || $2 == off) {
writeini translation.ini settings $chan $2
msg $chan Auto Translation for $chan is now $2 $+ .
}
elseif ($2 == primary) {
writeini translation.ini settings p $+ $chan $3
msg $chan Changed the primary speaking language to $3 $+ . If the script does not work after this, please make sure you are using the language code - IE: en, es, it.
}
elseif ($2 == tolang) {
writeini translation.ini settings tl $+ $chan $3
msg $chan Changed the translation language to $3 $+ . If the script does not work after this, please make sure you are using the language code - IE: en, es, it.
}
}
}
alias translate {
var %sname translate. $+ $r(1,9999999)
sockopen %sname translate.google.com 80
sockmark %sname $chan $+ : $+ $remove($1-,\)
}
on *:SOCKOPEN:translate.*:{
var %hl $iif($readini(translation.ini,settings,p $+ $gettok($sock($sockname).mark,1,58)),$v1,en)
var %tl $iif($readini(translation.ini,settings,tl $+ $gettok($sock($sockname).mark,1,58)),$v1,en)
sockwrite -n $sockname GET /translate_a/t?client=t&text= $+ $urlencode($gettok($sock($sockname).mark,2,58)) $+ &hl= $+ %hl $+ &sl=auto&tl= $+ %tl $+ &multires=1&otf=2&ssel=0&tsel=0&notlr=0&sc=1 HTTP/1.1
sockwrite $sockname Host: translate.google.com $+ $crlf $+ $crlf
}

on *:SOCKREAD:translate.*:{
sockread -n &data
var %regy $+(/,$chr(34),(.+?),$chr(34),$chr(44),/)
noop $regex($bvar(&data,1,$bvar(&data,0)).text,%regy)
if ($regml(1) && $remove($regml(1),\) != $gettok($sock($sockname).mark,2,58)) {
msg $gettok($sock($sockname).mark,1,58) [Translation] $remove($regml(1),\)
}
}

Comments

Sign in to comment.
cptpan   -  Sep 29, 2012
Does this even work? It doesn't seem to do anything
 Respond  
scorps   -  Feb 03, 2011
P.s. "!translate primary <Language CODE> - Sets the primary speaking language (Just updates a var in the url not sure if it does much xD)" nope, not much at all. still grabs all languages :( only want es
 Respond  
scorps   -  Feb 03, 2011
nvm, i typoed on bots name lmao
 Respond  
scorps   -  Feb 03, 2011
Ok, loaded into 2 bots and nothing. I type in !translate on and nothing. So out of curiosity I tried off etc and nothing at all. Both bots on mirc 6.35
 Respond  
[Plornt]   -  Feb 03, 2011
Fixed & Works on all channels :P

Also note, you might need to set Primary to "auto"
 Respond  
[Plornt]   -  Feb 03, 2011
Oh fail left in my debug
 Respond  
_Dean_   -  Feb 03, 2011
so it will only work on channel #scripting?

Code

 
 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.