mirror of
https://github.com/aljazceru/chatgpt-telegram-bot.git
synced 2025-12-22 07:04:59 +01:00
minor improvements
This commit is contained in:
@@ -111,7 +111,7 @@ Check out the [Budget Manual](https://github.com/n3d1117/chatgpt-telegram-bot/di
|
|||||||
| `SPOTIFY_REDIRECT_URI` | Spotify app Redirect URI (required only for the `spotify` plugin, you can find it on the [dashboard](https://developer.spotify.com/dashboard/)) | - |
|
| `SPOTIFY_REDIRECT_URI` | Spotify app Redirect URI (required only for the `spotify` plugin, you can find it on the [dashboard](https://developer.spotify.com/dashboard/)) | - |
|
||||||
| `WORLDTIME_DEFAULT_TIMEZONE` | Default timezone to use, i.e. `Europe/Rome` (required only for the `worldtimeapi` plugin, you can get TZ Identifiers from [here](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones)) | - |
|
| `WORLDTIME_DEFAULT_TIMEZONE` | Default timezone to use, i.e. `Europe/Rome` (required only for the `worldtimeapi` plugin, you can get TZ Identifiers from [here](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones)) | - |
|
||||||
| `DUCKDUCKGO_SAFESEARCH` | DuckDuckGo safe search (`on`, `off` or `moderate`) (optional, applies to `ddg_web_search` and `ddg_image_search`) | `moderate` |
|
| `DUCKDUCKGO_SAFESEARCH` | DuckDuckGo safe search (`on`, `off` or `moderate`) (optional, applies to `ddg_web_search` and `ddg_image_search`) | `moderate` |
|
||||||
| `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_KEY` | DeepL API key (required for the `deepl` plugin, you can get one [here](https://www.deepl.com/pro-api?cta=header-pro-api)) | - |
|
||||||
|
|
||||||
#### Available plugins
|
#### Available plugins
|
||||||
| Name | Description | Required environment variable(s) |
|
| Name | Description | Required environment variable(s) |
|
||||||
@@ -126,7 +126,7 @@ Check out the [Budget Manual](https://github.com/n3d1117/chatgpt-telegram-bot/di
|
|||||||
| `worldtimeapi` | Get latest world time (powered by [WorldTimeAPI](https://worldtimeapi.org/)) | `WORLDTIME_DEFAULT_TIMEZONE` |
|
| `worldtimeapi` | Get latest world time (powered by [WorldTimeAPI](https://worldtimeapi.org/)) | `WORLDTIME_DEFAULT_TIMEZONE` |
|
||||||
| `dice` | Send a dice in the chat! | - |
|
| `dice` | Send a dice in the chat! | - |
|
||||||
| `youtube_audio_extractor` | Extract audio from YouTube videos | - |
|
| `youtube_audio_extractor` | Extract audio from YouTube videos | - |
|
||||||
| `deepl` | Translate text to any language (powered by [DeepL](https://deepl.com)) - by [@LedyBacer](https://github.com/LedyBacer) | `DEEPL_API_KEY` |
|
| `deepl_translate` | Translate text to any language (powered by [DeepL](https://deepl.com)) - by [@LedyBacer](https://github.com/LedyBacer) | `DEEPL_API_KEY` |
|
||||||
|
|
||||||
Check out the [official API reference](https://platform.openai.com/docs/api-reference/chat) for more details.
|
Check out the [official API reference](https://platform.openai.com/docs/api-reference/chat) for more details.
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ class PluginManager:
|
|||||||
'worldtimeapi': WorldTimeApiPlugin,
|
'worldtimeapi': WorldTimeApiPlugin,
|
||||||
'youtube_audio_extractor': YouTubeAudioExtractorPlugin,
|
'youtube_audio_extractor': YouTubeAudioExtractorPlugin,
|
||||||
'dice': DicePlugin,
|
'dice': DicePlugin,
|
||||||
'deepl': DeeplTranslatePlugin
|
'deepl_translate': DeeplTranslatePlugin
|
||||||
}
|
}
|
||||||
self.plugins = [plugin_mapping[plugin]() for plugin in enabled_plugins if plugin in plugin_mapping]
|
self.plugins = [plugin_mapping[plugin]() for plugin in enabled_plugins if plugin in plugin_mapping]
|
||||||
|
|
||||||
|
|||||||
@@ -10,12 +10,11 @@ class DeeplTranslatePlugin(Plugin):
|
|||||||
"""
|
"""
|
||||||
A plugin to translate a given text from a language to another, using DeepL
|
A plugin to translate a given text from a language to another, using DeepL
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
deepl_api_key = os.getenv('DEEPL_API_KEY')
|
deepl_api_key = os.getenv('DEEPL_API_KEY')
|
||||||
if not deepl_api_key:
|
if not deepl_api_key:
|
||||||
raise ValueError('DEEPL_API_KEY environment variable must be set to use DeepL Plugin')
|
raise ValueError('DEEPL_API_KEY environment variable must be set to use DeepL Plugin')
|
||||||
self.api_key = deepl_api_key
|
self.api_key = deepl_api_key
|
||||||
|
|
||||||
def get_source_name(self) -> str:
|
def get_source_name(self) -> str:
|
||||||
return "DeepL Translate"
|
return "DeepL Translate"
|
||||||
@@ -42,13 +41,11 @@ class DeeplTranslatePlugin(Plugin):
|
|||||||
|
|
||||||
headers = {
|
headers = {
|
||||||
"Authorization": f"DeepL-Auth-Key {self.api_key}",
|
"Authorization": f"DeepL-Auth-Key {self.api_key}",
|
||||||
"User-Agent": "chatgpt-telegram-bot/0.2.7",
|
"User-Agent": "chatgpt-telegram-bot",
|
||||||
"Content-Type": "application/x-www-form-urlencoded"
|
"Content-Type": "application/x-www-form-urlencoded"
|
||||||
}
|
}
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
"text": kwargs['text'],
|
"text": kwargs['text'],
|
||||||
"target_lang": kwargs['to_language']
|
"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"]
|
||||||
|
|||||||
Reference in New Issue
Block a user