From 27dda75ab66b0369cebb953f3d695f1da7e38b12 Mon Sep 17 00:00:00 2001
From: yasirarism <55983182+yasirarism@users.noreply.github.com>
Date: Fri, 16 Dec 2022 10:21:09 +0700
Subject: [PATCH] Update misc_tools.py
---
misskaty/plugins/misc_tools.py | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)
diff --git a/misskaty/plugins/misc_tools.py b/misskaty/plugins/misc_tools.py
index 8c9784ef..2ff2b696 100644
--- a/misskaty/plugins/misc_tools.py
+++ b/misskaty/plugins/misc_tools.py
@@ -129,19 +129,15 @@ async def translate(client, message):
target_lang = message.text.split(None, 2)[1]
text = message.text.split(None, 2)[2]
msg = await message.reply("Menerjemahkan...")
- json_data = {
- 'source': 'auto',
- 'target': target_lang,
- 'text': text
- }
+ my_translator = GoogleTranslator(source='auto', target=target_lang)
try:
- tekstr = (await http.post("https://deep-translator-api.azurewebsites.net/google/", json=json_data)).json()["translation"]
- await msg.edit(f"{tekstr}")
+ tresult = my_translator.translate(text=text)
+ await msg.edit(f"Translation using source = {my_translator.source} and target = {my_translator.target}\n\n-> {result}")
except MessageTooLong:
- url = await rentry(tekstr)
+ url = await rentry(tresult)
await msg.edit(f"Your translated text pasted to rentry because has long text:\n{url}")
except Exception as err:
- await msg.edit(f"Error: {str(err)}")
+ await msg.edit(f"ERROR: {str(err)}")
@app.on_message(filters.command(["tts"], COMMAND_HANDLER))