Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; Translate v1.0.1 - by entropy 2020
- ; Simple to use Google Translator mIRC Script.
- ; Example: /trans vous là-bas? - msgs active window the settings for "FROM/TO"
- ; Set From/To under: "Translate".
- ; To auto translate on query, you right click a nickname (in query/nicklist) and set the: "TO" and "FROM" and "COLOR".
- ;============================================================== START/EXIT
- on *:start:{ if (!$hget(trans)) { hmake trans 100 } | if ($isfile($qt($scriptdirtrans.dat))) { hload trans $qt($scriptdirtrans.dat) } }
- on *:exit:{ if ($hget(trans)) { hsave -o $qt($scriptdirtrans.dat) } }
- ;============================================================== MENUS
- menu status,channel,menubar {
- -
- Translate $sversion
- .Network Translate $chr(9) (/trans) { dialogtrans $+($network,.net) }
- -
- }
- menu query,nicklist {
- -
- Translate $sversion
- .Network Translate $chr(9) (/trans) { dialogtrans $+($network,.net) }
- .Nickname Translate $chr(9) $+([,$iif($menu == query,$active,$snick(#,1)),]) { dialogtrans $iif($menu == query,$active,$snick(#,1)) }
- -
- }
- ;============================================================== ON TEXT
- on *:text:*:*:{ if ($hget(trans,$+($nick,.to)) && $hget(trans,$+($nick,.from)) && http*://* !iswm $1-) { %_target = $target | %_nick = $nick | google $hget(trans,$+($nick,.from)) $hget(trans,$+($nick,.to)) $hget(trans,$+($nick,.color)) $remove($strip($1-),") } }
- ;============================================================== VERSION
- ctcp *:version:?:{ .ctcpreply $nick VERSION Translate $sversion - by $sauthor $syear }
- ;============================================================== MAIN ALIASES
- alias trans { if (!$server) { echo 11 -gat * You are not on a server! } | elseif ($me !ison $active && !$query($active)) { echo 11 -gat * You can't translate to this window! } | elseif (!$1) { echo 11 -gat * Nothing to translate! } | elseif (!$hget(trans,$+($network,.net.to)) || !$hget(trans,$+($network,.net.from))) { echo 11 -gat * You have not specified TO/FROM languages! } | else { %_target = $active | %_nick = $me | google $hget(trans,$+($network,.net.from)) $hget(trans,$+($network,.net.to)) $hget(trans,$+($network,.net.color)) $remove($strip($1-),") } }
- alias -l dialogtrans { %_to = $+($1,.to) | %_from = $+($1,.from) | %_color = $+($1,.color) | dialog $iif($dialog(trans),-x,-m) trans trans }
- alias -l emoticons { var %a = $replace($1-,\u003e,>,\u003d,=,\u003c,<,$+(;,$chr(41)),$+($chr(32),;,$chr(41)),$+(;,$chr(40)),$+($chr(32),;,$chr(40))) | return $regsubex(%a,/([\x3A\x3B\x3D])( )([oO0PDSb\x28\x29\x5B\x5D\x3C\x3E])/g,\2\1\3) }
- alias -l sversion { return v1.0.1 }
- alias -l syear { return 2020 }
- alias -l sauthor { return entropy }
- alias -l xlang {
- var %a = trans $1
- did $+(-a,$iif($2 == ar,c)) %a AR - Arabic
- did $+(-a,$iif($2 == zh,c)) %a ZH - Chinese
- did $+(-a,$iif($2 == da,c)) %a DA - Danish
- did $+(-a,$iif($2 == nl,c)) %a NL - Dutch
- did $+(-a,$iif($2 == en,c)) %a EN - English
- did $+(-a,$iif($2 == fi,c)) %a FI - Finnish
- did $+(-a,$iif($2 == fr,c)) %a FR - French
- did $+(-a,$iif($2 == de,c)) %a DE - German
- did $+(-a,$iif($2 == el,c)) %a EL - Greek
- did $+(-a,$iif($2 == hi,c)) %a HI - Hindi
- did $+(-a,$iif($2 == it,c)) %a IT - Italian
- did $+(-a,$iif($2 == la,c)) %a LA - Latin
- did $+(-a,$iif($2 == ms,c)) %a MS - Malay
- did $+(-a,$iif($2 == no,c)) %a NO - Norwegian
- did $+(-a,$iif($2 == pl,c)) %a PL - Polish
- did $+(-a,$iif($2 == pt,c)) %a PT - Portuguese
- did $+(-a,$iif($2 == ru,c)) %a RU - Russian
- did $+(-a,$iif($2 == es,c)) %a ES - Spanish
- did $+(-a,$iif($2 == tr,c)) %a TR - Turkish
- }
- alias -l xcolor {
- var %a = trans $1
- did $+(-a,$iif($2 == 00,c)) %a 00 - White
- did $+(-a,$iif($2 == 01,c)) %a 01 - Black
- did $+(-a,$iif($2 == 02,c)) %a 02 - Dark Blue
- did $+(-a,$iif($2 == 03,c)) %a 03 - Green
- did $+(-a,$iif($2 == 04,c)) %a 04 - Red
- did $+(-a,$iif($2 == 05,c)) %a 05 - Brown
- did $+(-a,$iif($2 == 06,c)) %a 06 - Purple
- did $+(-a,$iif($2 == 07,c)) %a 07 - Orange
- did $+(-a,$iif($2 == 08,c)) %a 08 - Yellow
- did $+(-a,$iif($2 == 09,c)) %a 09 - Light Green
- did $+(-a,$iif($2 == 10,c)) %a 10 - Teal
- did $+(-a,$iif($2 == 11,c)) %a 11 - Light Blue
- did $+(-a,$iif($2 == 12,c)) %a 12 - Blue
- did $+(-a,$iif($2 == 13,c)) %a 13 - Pink
- did $+(-a,$iif($2 == 14,c)) %a 14 - Dark Grey
- did $+(-a,$iif($2 == 15,c)) %a 15 - Grey
- }
- ;============================================================== DIALOG
- dialog trans {
- title "Translate"
- size -1 -1 235 41
- option dbu notheme
- text "From:", 1, 3 7 15 8, right
- combo 2, 21 5 60 189, size drop
- text "To:", 3, 84 7 10 8, right
- combo 4, 97 5 60 189, size drop
- text "Color:", 5, 159 7 17 8, right
- combo 6, 179 5 52 189, size drop
- box "", 7, -5 17 296 50
- button "OK", 8, 193 25 37 12, ok
- button "Delete", 9, 156 25 37 12
- }
- ;============================================================== DIALOG EVENTS
- on *:dialog:trans:close:0:{ hsave -o trans $qt($scriptdirtrans.dat) }
- on *:dialog:trans:init:0:{ xlang 2 $hget(trans,%_from) | xlang 4 $hget(trans,%_to) | xcolor 6 $hget(trans,%_color) | did -f trans 8 | dialog -t trans $iif(%_to == $+($network,.net.to),Network Translate,Nickname Translate) - $+([,$remove(%_from,.net,.from),]) $iif(%_to == $+($network,.net.to), (/trans) ) }
- on *:dialog:trans:sclick:2:{ hadd -m trans %_from $lower($gettok($did(2).seltext,1,32)) }
- on *:dialog:trans:sclick:4:{ hadd -m trans %_to $lower($gettok($did(4).seltext,1,32)) }
- on *:dialog:trans:sclick:6:{ hadd -m trans %_color $lower($gettok($did(6).seltext,1,32)) }
- on *:dialog:trans:sclick:9:{ hdel -m trans %_from | hdel -m trans %_to | hdel -m trans %_color | dialog -x trans | unset %_to %_from %_color }
- on *:dialog:trans:sclick:8:{ unset %_to %_from %_color }
- ;============================================================== GOOGLE SOCKETS
- alias -l google {
- sockclose googletrans
- sockopen -e46 googletrans translate.googleapis.com 443
- sockmark googletrans $1-
- }
- on *:sockopen:googletrans:{
- if ($sockerr) { return }
- var %from = $gettok($sock($sockname).mark,1,32)
- var %to = $gettok($sock($sockname).mark,2,32)
- var %color = $gettok($sock($sockname).mark,3,32)
- var %text = $replace($gettok($sock($sockname).mark,4-,32),$chr(32),+)
- sockwrite -n $sockname GET $+(https://translate.googleapis.com/translate_a/single?client=gtx&ie=UTF-8&oe=UTF-8&dt=bd&dt=ex&dt=ld&dt=md&dt=qca&dt=rw&dt=rm&dt=ss&dt=t&dt=at&sl=,%from,&tl=,%to,&hl=hl&q=,%text) HTTP/1.1
- sockwrite -n $sockname Content-Type: application/json; charset=utf-8
- sockwrite -n $sockname Content-Disposition: inline; filename=json.txt
- sockwrite -n $sockname User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:62.0) Gecko/20100101 Firefox/62.0
- sockwrite -n $sockname Host: translate.googleapis.com
- sockwrite -n $sockname $str($crlf,2)
- }
- on *:sockread:googletrans:{
- if ($sockerr) { return }
- var %from = $gettok($sock($sockname).mark,1,32)
- var %to = $gettok($sock($sockname).mark,2,32)
- var %color = $gettok($sock($sockname).mark,3,32)
- var %text = $gettok($sock($sockname).mark,4-,32)
- var %a
- sockread -f %a
- tokenize 32 %a
- if ($1) {
- if (*null,null,3,null,null,null* iswm $1- || *null,null,1]* iswm $1-) { var %t = $gettok($replace($1-,",$chr(1)),2,1) | if (%t !isin %final) { %final = %final %t } }
- if ([[["*"* iswm $1- && *null,null,1] iswm $1- && !%final) { %final = $gettok($replace($1-,",$chr(1)),2,1) }
- if (?1.0?[* iswm $1- && %final) {
- if ($gettok(%final,1-3,32) == $gettok(%text,1-3,32)) { unset %final %_nick %_target | return }
- %final = $emoticons($replace(%final,',"))
- if (%_nick == $me) { msg %_target %final | echo %color -tg %_target * $+([,$upper(%from),/,$upper(%to),]) ( $+ %_nick $+ ) $replace(%text,+,$chr(32)) }
- elseif (%_target ischan) { echo %color -tg %_target * $+([,$upper(%from),/,$upper(%to),]) ( $+ %_nick $+ ) %final }
- else { echo %color -tg %_nick * $+([,$upper(%from),/,$upper(%to),]) ( $+ %_nick $+ ) %final }
- unset %final %_nick %_target
- sockclose $sockname
- }
- }
- }
- ;============================================================== EOF
Advertisement
Add Comment
Please, Sign In to add comment