mirror of
https://github.com/Jerryplusy/rc-plugin.git
synced 2025-10-14 16:19:18 +00:00
✨ feat: 开放咕咕翻译 & 🐞 fix: 修正部分文字性错误
This commit is contained in:
parent
45e5962489
commit
321b974ea4
@ -131,8 +131,6 @@ export class tools extends plugin {
|
|||||||
"📝咕咕翻译:" + (await translateEngine.google(place, language[1]));
|
"📝咕咕翻译:" + (await translateEngine.google(place, language[1]));
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.error("咕咕翻译失败");
|
logger.error("咕咕翻译失败");
|
||||||
} finally {
|
|
||||||
translateResult = "";
|
|
||||||
}
|
}
|
||||||
// 腾讯交互式进行补充
|
// 腾讯交互式进行补充
|
||||||
translateResult += "\n\n🐧翻译:" + (await translateEngine.tencent(place, language[1]));
|
translateResult += "\n\n🐧翻译:" + (await translateEngine.tencent(place, language[1]));
|
||||||
@ -342,7 +340,6 @@ export class tools extends plugin {
|
|||||||
};
|
};
|
||||||
// 格式化数据
|
// 格式化数据
|
||||||
const combineContent =
|
const combineContent =
|
||||||
`标题:${title}\n` +
|
|
||||||
`点赞:${dataProcessing(like,)} | 硬币:${dataProcessing(coin)} | 收藏:${dataProcessing(favorite)} | 分享:${dataProcessing(share)}\n`+
|
`点赞:${dataProcessing(like,)} | 硬币:${dataProcessing(coin)} | 收藏:${dataProcessing(favorite)} | 分享:${dataProcessing(share)}\n`+
|
||||||
`总播放量:${dataProcessing(view)} | 弹幕数量:${dataProcessing(danmaku)} | 评论:${dataProcessing(reply)}\n`+
|
`总播放量:${dataProcessing(view)} | 弹幕数量:${dataProcessing(danmaku)} | 评论:${dataProcessing(reply)}\n`+
|
||||||
`简介:${desc}`;
|
`简介:${desc}`;
|
||||||
|
@ -1,10 +1,21 @@
|
|||||||
/**
|
/**
|
||||||
* 用于翻译的常量控制
|
* 用于百度翻译的常量控制
|
||||||
*
|
*
|
||||||
* @type {{英: string, 日: string, 文: string, 中: string}}
|
* @type {{英: string, 日: string, 文: string, 中: string}}
|
||||||
*/
|
*/
|
||||||
export const transMap = { 中: "zh", 日: "jp", 文: "wyw", 英: "en", 俄: "ru", 韩: "kr" };
|
export const transMap = { 中: "zh", 日: "jp", 文: "wyw", 英: "en", 俄: "ru", 韩: "kr" };
|
||||||
export const transMap2 = { 中: "zh", 日: "ja", 韩: "ko", 英: "en", 俄: "ru" };
|
/**
|
||||||
|
* 用于腾讯交互式翻译的常量控制
|
||||||
|
*
|
||||||
|
* @type {{英: string, 俄: string, 日: string, 韩: string, 中: string}}
|
||||||
|
*/
|
||||||
|
export const tencentTransMap = { 中: "zh", 日: "ja", 韩: "ko", 英: "en", 俄: "ru" };
|
||||||
|
/**
|
||||||
|
* 用于腾讯交互式翻译的常量控制
|
||||||
|
*
|
||||||
|
* @type {{英: string, 俄: string, 日: string, 韩: string, 中: string}}
|
||||||
|
*/
|
||||||
|
export const googleTransMap = { 中: "zh-CN", 日: "jp", 韩: "ko", 英: "en", 俄: "ru" };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 以下为抖音/TikTok类型代码
|
* 以下为抖音/TikTok类型代码
|
||||||
@ -38,4 +49,4 @@ export const HOT_SEARCH_ACTIONS = {
|
|||||||
"哔哩哔哩": HOT_SEARCH_API + "bilihot",
|
"哔哩哔哩": HOT_SEARCH_API + "bilihot",
|
||||||
"头条": HOT_SEARCH_API + "toutiaohot",
|
"头条": HOT_SEARCH_API + "toutiaohot",
|
||||||
"头条新闻": HOT_SEARCH_API + "toutiaohotnew"
|
"头条新闻": HOT_SEARCH_API + "toutiaohotnew"
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import {transMap, transMap2} from "./constant.js";
|
import {transMap, tencentTransMap, googleTransMap} from "./constant.js";
|
||||||
import md5 from "md5";
|
import md5 from "md5";
|
||||||
import fetch from "node-fetch";
|
import fetch from "node-fetch";
|
||||||
import HttpProxyAgent from "https-proxy-agent";
|
import HttpProxyAgent from "https-proxy-agent";
|
||||||
@ -52,7 +52,7 @@ export default class Translate {
|
|||||||
* @returns {Promise<string>}
|
* @returns {Promise<string>}
|
||||||
*/
|
*/
|
||||||
async google(query, targetLanguage) {
|
async google(query, targetLanguage) {
|
||||||
const url = `https://translate.googleapis.com/translate_a/single?client=gtx&dt=t&sl=auto&tl=${transMap2[targetLanguage]}&q=${query}`;
|
const url = `https://translate.googleapis.com/translate_a/single?client=gtx&dt=t&sl=auto&tl=${googleTransMap[targetLanguage]}&q=${query}`;
|
||||||
return fetch(url, {
|
return fetch(url, {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
headers: {
|
headers: {
|
||||||
@ -119,7 +119,7 @@ export default class Translate {
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"target": {
|
"target": {
|
||||||
"lang": transMap2[targetLanguage]
|
"lang": tencentTransMap[targetLanguage]
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}).then(async resp => {
|
}).then(async resp => {
|
||||||
@ -130,4 +130,4 @@ export default class Translate {
|
|||||||
return data.auto_translation?.[1];
|
return data.auto_translation?.[1];
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user