diff options
| author | Jan Tuomi <jans.tuomi@gmail.com> | 2021-02-12 14:58:25 +0200 |
|---|---|---|
| committer | Jan Tuomi <jans.tuomi@gmail.com> | 2021-02-12 14:58:25 +0200 |
| commit | 99c8b7c679616a22274b1ce6abcc57e404a1a3a1 (patch) | |
| tree | 32fe0f32c2ac948bc16c6212dbc918efdbfd1086 /hommaexceli_py/telegram_client.py | |
| parent | 6d69d7f19c3014318734e618baff5ba958fe2344 (diff) | |
Send actual sheets data as message
Diffstat (limited to 'hommaexceli_py/telegram_client.py')
| -rw-r--r-- | hommaexceli_py/telegram_client.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/hommaexceli_py/telegram_client.py b/hommaexceli_py/telegram_client.py index 0c7fcf2..108f525 100644 --- a/hommaexceli_py/telegram_client.py +++ b/hommaexceli_py/telegram_client.py @@ -4,6 +4,7 @@ import sys from os import getenv from telegram.ext import Updater, CommandHandler, Job from telegram import Update +from sheets_client import authenticate_and_fetch_sheets_data chats_mem_cache = set() @@ -19,7 +20,9 @@ def _signal_handler(sig, frame): def _callback_alarm(context): - context.bot.send_message(chat_id=context.job.context, text="Alarm") + rows = authenticate_and_fetch_sheets_data() + message = "\n".join(map(str, rows)) + context.bot.send_message(chat_id=context.job.context, text=message) def _callback_timer(update: Update, context): @@ -29,7 +32,7 @@ def _callback_timer(update: Update, context): chats_mem_cache.add(update.message.chat_id) context.job_queue.run_repeating( _callback_alarm, - datetime.timedelta(seconds=1), + datetime.timedelta(seconds=10), context=update.message.chat_id, ) |
