Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle viaggiatreno.it errors #19

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/updates/inline.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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:
Expand Down
8 changes: 4 additions & 4 deletions src/updates/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
"<b>🚅 Cerca treno</b> per numero"
Expand Down Expand Up @@ -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 = (
"<b>🚅 Cerca treno</b> per itinerario"
"\n❌ <b>Stazione di partenza non trovata</b>, riprovare o annullare?"
Expand Down Expand Up @@ -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 = (
"<b>🚅 Cerca treno</b> per itinerario"
"\n❌ <b>Stazione di arrivo non trovata</b>, riprovare o annullare?"
Expand Down Expand Up @@ -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 = (
"<b>🚉 Cerca stazione</b>"
"\n❌ <b>Stazione non trovata</b>, riprovare o annullare?"
Expand Down