fix plugins ["trans","tts"]
This commit is contained in:
parent
3d4035aecc
commit
72a36e5164
@ -1,16 +1,20 @@
|
|||||||
<?php
|
<?php
|
||||||
//PluginList("trans", "translate");
|
PluginList("trans", "translate");
|
||||||
if (preg_match("/^".TAG."trans (.*)$/", $_GET['text'], $matches)) {
|
if (preg_match("/^".TAG."trans (.*)$/", $_GET['text'], $matches)) {
|
||||||
$matches = explode(" ", $matches[1], 2);
|
$matches = explode(" ", $matches[1], 2);
|
||||||
if (!isset($matches[1])) {
|
if (!isset($matches[1])) {
|
||||||
$to = "zh";
|
$to = "en";
|
||||||
$text = $matches[0];
|
$text = urlencode($matches[0]);
|
||||||
|
}elseif (isset($matches[1]) and strlen($matches[0]) != 2) {
|
||||||
|
$to = "en";
|
||||||
|
$text = urlencode($matches[0].$matches[1]);
|
||||||
}else{
|
}else{
|
||||||
$to = $matches[0];
|
$to = $matches[0];
|
||||||
$text = $matches[1];
|
$text = urlencode($matches[1]);
|
||||||
}
|
}
|
||||||
$trans = file_get_contents("http://tool.dennx.com/translate/?text=".$text."&to=".$to);
|
$trans = file_get_contents('http://api.microsofttranslator.com/v2/ajax.svc/TranslateArray2?appId=%22TKT68kjRgkUbVtIKst6Vo0Hxnb6g2f0K3tUMyn1gZ7nc*%22&to="'.$to.'"&options={}&texts=["'.$text.'"]');
|
||||||
$msg = "Result: ".$trans;
|
preg_match('/"TranslatedText":"([^"]+)/i', $trans, $trans_result);
|
||||||
|
$msg = "Result: ".$trans_result[1];
|
||||||
$BOT->exec("msg ".$from." ".escapeString($msg));
|
$BOT->exec("msg ".$from." ".escapeString($msg));
|
||||||
|
|
||||||
}
|
}
|
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
PluginList("tts", "Text To Speech");
|
PluginList("tts", "Text To Speech");
|
||||||
if (preg_match("/^".TAG."tts (.*)$/", $_GET['text'], $matches)) {
|
if (preg_match("/^".TAG."tts (.*)$/", $_GET['text'], $matches)) {
|
||||||
$mp3 = file_get_contents("http://tts.baidu.com/text2audio?lan=zh&ie=UTF-8&text=".$matches[1]);
|
$mp3 = file_get_contents("http://tts.baidu.com/text2audio?lan=zh&ie=UTF-8&text=".urlencode($matches[1]));
|
||||||
$file = fopen($_GET['from'].".mp3","w");
|
$file = fopen($_GET['from'].".mp3","w");
|
||||||
echo fwrite($file,$mp3);
|
echo fwrite($file,$mp3);
|
||||||
fclose($file);
|
fclose($file);
|
||||||
|
Loading…
Reference in New Issue
Block a user