diff --git a/README.md b/README.md index 0ec93f6..ef6bbb8 100644 --- a/README.md +++ b/README.md @@ -110,7 +110,6 @@ Check out the [Budget Manual](https://github.com/n3d1117/chatgpt-telegram-bot/di | `SPOTIFY_CLIENT_SECRET` | Spotify app Client Secret (required for the `spotify` plugin, you can find it on the [dashboard](https://developer.spotify.com/dashboard/)) | `-` | | `SPOTIFY_REDIRECT_URI` | Spotify app Redirect URI (required for the `spotify` plugin, you can find it on the [dashboard](https://developer.spotify.com/dashboard/)) | `-` | | `DEEPL_API_KEY` | DeepL API key (required for the `deepl` plugin, you can get one [here](https://www.deepl.com/pro-api?cta=header-pro-api)) | `-` | -| `DEEPL_API_PRO` | DeepL API key plan (required for the `deepl` plugin. set 'true' if you have paid api key) | `false` | #### Available plugins | Name | Description | Required API key(s) | diff --git a/bot/plugins/deepl.py b/bot/plugins/deepl.py index 533db7a..b58d271 100644 --- a/bot/plugins/deepl.py +++ b/bot/plugins/deepl.py @@ -13,11 +13,9 @@ class DeeplTranslatePlugin(Plugin): def __init__(self): deepl_api_key = os.getenv('DEEPL_API_KEY') - deepl_api_pro = os.getenv('DEEPL_API_PRO', 'false').lower() == 'true' if not deepl_api_key: raise ValueError('DEEPL_API_KEY environment variable must be set to use DeepL Plugin') self.api_key = deepl_api_key - self.api_pro = deepl_api_pro def get_source_name(self) -> str: return "DeepL Translate" @@ -37,10 +35,10 @@ class DeeplTranslatePlugin(Plugin): }] async def execute(self, function_name, **kwargs) -> Dict: - if self.api_pro: - url = "https://api.deepl.com/v2/translate" - else: + if self.api_key.endswith(':fx'): url = "https://api-free.deepl.com/v2/translate" + else: + url = "https://api.deepl.com/v2/translate" headers = { "Authorization": f"DeepL-Auth-Key {self.api_key}",