From 0ac3b2d66febbe949479589668702fb5631ea84f Mon Sep 17 00:00:00 2001 From: Yuriy Novostavskiy Date: Wed, 28 Feb 2024 16:41:56 +0000 Subject: [PATCH] add Accept-Encoding: utf-8 to header reason for this change is avoiding to get unicode escape characters in response for non-ANSI characters potential fix for issue #541 --- bot/plugins/deepl.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bot/plugins/deepl.py b/bot/plugins/deepl.py index d2236c2..813122a 100644 --- a/bot/plugins/deepl.py +++ b/bot/plugins/deepl.py @@ -42,10 +42,11 @@ class DeeplTranslatePlugin(Plugin): headers = { "Authorization": f"DeepL-Auth-Key {self.api_key}", "User-Agent": "chatgpt-telegram-bot", - "Content-Type": "application/x-www-form-urlencoded" + "Content-Type": "application/x-www-form-urlencoded", + "Accept-Encoding": "utf-8" } data = { "text": kwargs['text'], "target_lang": kwargs['to_language'] } - return requests.post(url, headers=headers, data=data).json()["translations"][0]["text"] + return requests.post(url, headers=headers, data=data).json()["translations"][0]["text"] \ No newline at end of file