Skip to content

Commit

Permalink
add Accept-Encoding: utf-8 to header
Browse files Browse the repository at this point in the history
reason for this change is avoiding to get unicode escape characters in response for non-ANSI characters

potential fix for issue #541
  • Loading branch information
yurnov committed Feb 28, 2024
1 parent 4162f8e commit 0ac3b2d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions bot/plugins/deepl.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,11 @@ async def execute(self, function_name, helper, **kwargs) -> Dict:
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"]

0 comments on commit 0ac3b2d

Please sign in to comment.