From bd00ad2cfb9928f4ea756163dcfd174366e546f6 Mon Sep 17 00:00:00 2001 From: Giuseppe Marino Date: Wed, 1 Feb 2023 11:32:31 +0100 Subject: [PATCH] Handle viaggiatreno.it errors --- src/updates/inline.py | 4 ++-- src/updates/messages.py | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/updates/inline.py b/src/updates/inline.py index d1ecd59..aebc5a3 100644 --- a/src/updates/inline.py +++ b/src/updates/inline.py @@ -123,7 +123,7 @@ def not_found_answer(): results = api.call('cercaNumeroTrenoTrenoAutocomplete', iq.query) except HTTPError: results = [] - if len(results) == 0: + if results is None or len(results) == 0: return not_found_answer() u.increaseStat("stats_inline_queries") @@ -200,7 +200,7 @@ def not_found_answer(): else: # Search station results = api.call('cercaStazione', iq.query) - if len(results) == 0: + if results is None or len(results) == 0: return not_found_answer() elif len(results) > 0: diff --git a/src/updates/messages.py b/src/updates/messages.py index 5b210f4..3d61706 100644 --- a/src/updates/messages.py +++ b/src/updates/messages.py @@ -42,7 +42,7 @@ def process_messages(bot, message, u): except HTTPError: results = [] - if len(results) == 0: + if results is None or len(results) == 0: u.state("home") text = ( "šŸš… Cerca treno per numero" @@ -102,7 +102,7 @@ def process_messages(bot, message, u): elif state == "train_byiti": results = api.call('cercaStazione', message.text) - if len(results) == 0: + if results is None or len(results) == 0: text = ( "šŸš… Cerca treno per itinerario" "\nāŒ Stazione di partenza non trovata, riprovare o annullare?" @@ -152,7 +152,7 @@ def process_messages(bot, message, u): elif state == "train_byiti_2": results = api.call('cercaStazione', message.text) - if len(results) == 0: + if results is None or len(results) == 0: text = ( "šŸš… Cerca treno per itinerario" "\nāŒ Stazione di arrivo non trovata, riprovare o annullare?" @@ -259,7 +259,7 @@ def minifyStation(__str): elif state == "station": results = api.call('cercaStazione', message.text) - if len(results) == 0: + if results is None or len(results) == 0: text = ( "šŸš‰ Cerca stazione" "\nāŒ Stazione non trovata, riprovare o annullare?"