From b7fdd6e0e69582f5c811039547c81f65769a7e6d Mon Sep 17 00:00:00 2001 From: Homer S Date: Wed, 14 Jul 2021 19:27:39 +0200 Subject: [PATCH] Added some condtions to prevent script from breaking if list of missed calls is empty. --- fritzab2matrix.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/fritzab2matrix.py b/fritzab2matrix.py index 1a62c2e..d1c5dfa 100755 --- a/fritzab2matrix.py +++ b/fritzab2matrix.py @@ -70,13 +70,20 @@ def get_last_call(): except: print("Couldn't connect to Box") missed_calls = fc.get_missed_calls(False,1,1) - return missed_calls[0] + + if len(missed_calls) > 0: + return missed_calls[0] + else: + return False def lastcall2matrix(tam,tam_no): # Call Watch to Matrix if env_call_watch and not at_least_one_new_message: c = get_last_call() - c_msg = "{} - {} ({})".format(c.Date, c.Caller, c.Name) + if c: + c_msg = "{} - {} ({})".format(c.Date, c.Caller, c.Name) + else: + return False # ... and send message and file to Matrix Room ## if Number of a TAM and the last call match