1.6: Error Handling Improvements

This commit is contained in:
hockeygoalie35 2024-03-07 22:52:44 -05:00
parent c460898694
commit cb8dbdd79b

View file

@ -22,6 +22,7 @@ DEBUG_ROOT_PATH = './env'
# Web agent used to access Deezer
USER_AGENT = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:83.0) Gecko/20100101 Firefox/110.0'
@dataclass
class Plan:
name: str
@ -170,7 +171,6 @@ class LidarrExtendedAPI:
if 'telegramUserChatID=' in line:
self.telegram_user_chat_id = re.search(re_search_pattern, line)[0].replace('"', '')
if self.enable_telegram_bot:
self.log.info('Telegram bot is enabled.')
@ -195,7 +195,7 @@ class LidarrExtendedAPI:
else:
self.report_status('EXPIRED')
self.log.error(Fore.RED + 'Update the token in extended.conf' + Fore.LIGHTWHITE_EX)
if self.telegram_bot_running: # Don't re-start the telegram bot if it's alread running after bot invalid token entry
if self.telegram_bot_running: # Don't re-start the telegram bot if it's already running after bot invalid token entry
return False
if self.enable_telegram_bot:
self.log.info(Fore.YELLOW + 'Starting Telegram bot...Check Telegram and follow instructions.' + Fore.LIGHTWHITE_EX)
@ -273,6 +273,7 @@ class TelegramBotControl:
self.application.stop_running()
except Exception:
pass
async def set_token(self, update, context: ContextTypes.DEFAULT_TYPE):
async def send_message(text, reply=False):
if reply is True:
@ -328,7 +329,7 @@ def check_token(token=None):
log.info('-------------------------------')
return True
except Exception as e:
if type(e) == AuthError:
if type(e) is AuthError:
log.error(Fore.RED + 'ARL Token Invalid/Expired.' + Fore.LIGHTWHITE_EX)
return False
else:
@ -343,7 +344,6 @@ def parse_arguments():
parser.add_argument('-t', '--test_token', help='Test any token for validity', type=str, required=False, default=False)
parser.add_argument('-d', '--debug', help='For debug and development, sets root path to match testing env. See DEBUG_ROOT_PATH', required=False, default=False, action='store_true')
if not argv[1:]:
parser.print_help()
parser.exit()