From 973c8dfdfd90b82e0144af8d979e49e3018ddd0d Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Sun, 14 Feb 2021 17:20:14 +0200 Subject: Improve week processing --- hommaexceli_py/telegram_client.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'hommaexceli_py/telegram_client.py') diff --git a/hommaexceli_py/telegram_client.py b/hommaexceli_py/telegram_client.py index ad1f478..d11d876 100644 --- a/hommaexceli_py/telegram_client.py +++ b/hommaexceli_py/telegram_client.py @@ -40,9 +40,13 @@ def _callback_alarm(context: CallbackContext, sheets_service: Resource): this_weeks_rows = filter_only_this_week(processed_rows) logging.info(f"Sending sheet data to chat id {chat_id}...") - message = "Tällä viikolla tehtävät hommat:\n" + "\n".join( - map(lambda task: f"{task.name} ({task.interval})", this_weeks_rows) - ) + if len(this_weeks_rows) > 0: + message = "Tällä viikolla tehtävät hommat:\n" + "\n".join( + map(lambda task: f"{task.name} ({task.interval})", this_weeks_rows) + ) + else: + message = "Tällä viikolla ei toistuvia hommia! 🎉 " + context.bot.send_message(chat_id=chat_id, text=message) update_sheet_last_done_column(sheets_service, processed_rows) -- cgit v1.3