2015-05-29 11:20:55 -05:00
|
|
|
<?php
|
2015-06-04 04:25:51 -05:00
|
|
|
PluginList("trans", "translate");
|
2015-06-26 01:14:14 -05:00
|
|
|
if (preg_match("/^".TAG."trans (.*)$/", $text, $matches)) {
|
2015-05-29 11:20:55 -05:00
|
|
|
$matches = explode(" ", $matches[1], 2);
|
|
|
|
if (!isset($matches[1])) {
|
2015-06-04 04:25:51 -05:00
|
|
|
$to = "en";
|
|
|
|
$text = urlencode($matches[0]);
|
|
|
|
}elseif (isset($matches[1]) and strlen($matches[0]) != 2) {
|
|
|
|
$to = "en";
|
|
|
|
$text = urlencode($matches[0].$matches[1]);
|
2015-05-29 11:20:55 -05:00
|
|
|
}else{
|
|
|
|
$to = $matches[0];
|
2015-06-04 04:25:51 -05:00
|
|
|
$text = urlencode($matches[1]);
|
2015-05-29 11:20:55 -05:00
|
|
|
}
|
2015-06-26 00:19:40 -05:00
|
|
|
$trans = file_get_contents('http://api.microsofttranslator.com/v2/ajax.svc/TranslateArray2?appId=%22TWQET6TO9c7Iw1yXOahFm8zfEzty5DUHuaTHkl5SCrHUPgu3ABP7aflbz8teet6IS%22&to="'.$to.'"&options={}&texts=["'.$text.'"]');
|
|
|
|
preg_match("/\[{.*?\}]/is", $trans, $trans_json);
|
|
|
|
$msg = "Result: ".json_decode($trans_json[0],true)[0]["TranslatedText"];
|
2015-06-26 00:59:37 -05:00
|
|
|
$BOT->msg($from, $msg);
|
2015-05-29 11:20:55 -05:00
|
|
|
|
|
|
|
}
|