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
This commit is contained in:
Yuriy Novostavskiy
2024-02-28 16:41:56 +00:00
parent 4162f8e380
commit 0ac3b2d66f

View File

@@ -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"]