From 658cddc9d6693ccbf236340a66938c1620183a09 Mon Sep 17 00:00:00 2001 From: misyaguziya Date: Tue, 12 Sep 2023 11:31:22 +0900 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B[bigfix]=20DeepL=20Auth=20Key?= =?UTF-8?q?=E3=81=AE=E5=88=A9=E7=94=A8=E4=B8=8A=E9=99=90=E3=81=AB=E9=81=94?= =?UTF-8?q?=E3=81=97=E3=81=9F=E5=A0=B4=E5=90=88=E3=81=AE=E5=87=A6=E7=90=86?= =?UTF-8?q?=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 12 ++++++++++++ model.py | 30 ++++++++++++++++++------------ view.py | 2 +- 3 files changed, 31 insertions(+), 13 deletions(-) diff --git a/main.py b/main.py index e830b054..ef3ac904 100644 --- a/main.py +++ b/main.py @@ -19,6 +19,10 @@ def sendMicMessage(message): else: translation = model.getInputTranslate(message) + if translation == None: + view.printToTextbox_AuthenticationError() + translation = "" + if config.ENABLE_TRANSCRIPTION_SEND is True: if config.ENABLE_OSC is True: if len(translation) > 0: @@ -56,6 +60,10 @@ def receiveSpeakerMessage(message): else: translation = model.getOutputTranslate(message) + if translation == None: + view.printToTextbox_AuthenticationError() + translation = "" + if config.ENABLE_TRANSCRIPTION_RECEIVE is True: if config.ENABLE_NOTICE_XSOVERLAY is True: xsoverlay_message = config.MESSAGE_FORMAT.replace("[message]", message) @@ -86,6 +94,10 @@ def sendChatMessage(message): else: translation = model.getInputTranslate(message) + if translation == None: + view.printToTextbox_AuthenticationError() + translation = "" + # send OSC message if config.ENABLE_OSC is True: if len(translation) > 0: diff --git a/model.py b/model.py index 559306de..46ac13ea 100644 --- a/model.py +++ b/model.py @@ -135,21 +135,27 @@ class Model: return list(self.translator.translator_status.keys()) def getInputTranslate(self, message): - translation = self.translator.translate( - translator_name=config.CHOICE_TRANSLATOR, - source_language=config.SOURCE_LANGUAGE, - target_language=config.TARGET_LANGUAGE, - message=message - ) + try: + translation = self.translator.translate( + translator_name=config.CHOICE_TRANSLATOR, + source_language=config.SOURCE_LANGUAGE, + target_language=config.TARGET_LANGUAGE, + message=message + ) + except: + translation = None return translation def getOutputTranslate(self, message): - translation = self.translator.translate( - translator_name=config.CHOICE_TRANSLATOR, - source_language=config.TARGET_LANGUAGE, - target_language=config.SOURCE_LANGUAGE, - message=message - ) + try: + translation = self.translator.translate( + translator_name=config.CHOICE_TRANSLATOR, + source_language=config.TARGET_LANGUAGE, + target_language=config.SOURCE_LANGUAGE, + message=message + ) + except: + translation = None return translation def addKeywords(self): diff --git a/view.py b/view.py index 4d24063f..fa986a52 100644 --- a/view.py +++ b/view.py @@ -416,7 +416,7 @@ class View(): self._printToTextbox_Info("Auth key update completed") def printToTextbox_AuthenticationError(self): - self._printToTextbox_Info("Auth Key or language setting is incorrect") + self._printToTextbox_Info("Auth Key is incorrect or Usage limit reached") def printToTextbox_OSCError(self): self._printToTextbox_Info("OSC is not enabled, please enable OSC and rejoin")