mirror of
https://github.com/TeamPGM/PagerMaid_Plugins.git
synced 2024-11-22 03:19:17 +00:00
xtao-some 翻译支持自定义语言 (#155)
This commit is contained in:
parent
f5233e5622
commit
25b0bafa5a
@ -62,7 +62,7 @@
|
||||
},
|
||||
{
|
||||
"name": "xtao-some",
|
||||
"version": "1.154",
|
||||
"version": "1.16",
|
||||
"section": "daily",
|
||||
"maintainer": "xtaodada",
|
||||
"size": "18.8 kb",
|
||||
|
29
xtao-some.py
29
xtao-some.py
@ -216,8 +216,9 @@ async def ipping(context):
|
||||
|
||||
|
||||
@listener(is_plugin=True, outgoing=True, command="t",
|
||||
description="通过腾讯AI开放平台将目标消息翻译成指定的语言。",
|
||||
parameters="<文本>")
|
||||
description="通过腾讯AI开放平台将目标消息翻译成指定的语言。"
|
||||
"目前支持的语言有 zh, en, jp, kr, fr, es, it, de, tr, ru, pt, vi, id, ms, th。",
|
||||
parameters="<回复消息/文本> <指定语言>")
|
||||
async def tx_t(context):
|
||||
""" PagerMaid universal translator. """
|
||||
reply = await context.get_reply_message()
|
||||
@ -225,14 +226,30 @@ async def tx_t(context):
|
||||
lang = 'zh'
|
||||
USER_AGENT = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:65.0) Gecko/20100101 Firefox/65.0"
|
||||
headers = {"user-agent": USER_AGENT}
|
||||
if message:
|
||||
pass
|
||||
elif reply:
|
||||
api_lang = ['zh', 'en', 'jp', 'kr', 'fr', 'es', 'it', 'de', 'tr', 'ru', 'pt', 'vi', 'id', 'ms', 'th']
|
||||
if reply:
|
||||
message = reply.text
|
||||
if context.parameter:
|
||||
if re.search(r'[a-z]{2}', context.parameter[0]):
|
||||
if context.parameter[0] in api_lang:
|
||||
lang = context.parameter[0]
|
||||
else:
|
||||
await context.edit("指定语言未支持,使用默认语言")
|
||||
else:
|
||||
await context.edit("未指定语言,使用默认语言")
|
||||
elif context.parameter:
|
||||
message = context.parameter[0]
|
||||
try:
|
||||
if re.search(r'[a-z]{2}', context.parameter[1]):
|
||||
if context.parameter[1] in api_lang:
|
||||
lang = context.parameter[1]
|
||||
else:
|
||||
await context.edit("指定语言未支持,使用默认语言")
|
||||
except IndexError:
|
||||
await context.edit("未指定语言,使用默认语言")
|
||||
else:
|
||||
await context.edit("出错了呜呜呜 ~ 无效的参数。")
|
||||
return
|
||||
|
||||
try:
|
||||
await context.edit("正在生成翻译中 . . .")
|
||||
tx_json = json.loads(requests.get(
|
||||
|
Loading…
Reference in New Issue
Block a user