def do_help(bot, update, chat_id): bot.send_message( chat_id=chat_id, text=msg_help, parse_mode=ParseMode.HTML, reply_markup=get_base_reply_keyboard(), )
def do_start(bot, update, job_queue): chat_id = update.effective_message.chat_id bot.send_message( chat_id=chat_id, text=msg_start, parse_mode=ParseMode.HTML, reply_markup=get_base_reply_keyboard(), ) job_queue.run_repeating(check_periodically, 300, context=update.message.chat_id)
def get_last_record(bot, update, chat_id): status = None while status != 200: status, data = get_data() #and we will have to check these values on thresholds reply = 'Datetime of measurements - {},\nTemperature - {} °C,\nHumidity - {} %\nGas - {}'.format( data["timestamp"], data["temperature"], data["humidity"], data["gas"]) bot.send_message( chat_id=chat_id, text=reply, reply_markup=get_base_reply_keyboard(), )
def do_echo(bot, update): chat_id = update.effective_message.chat_id text = update.message.text if text == BUTTON_LAST_RECORD: get_last_record(bot, update, chat_id) elif text == BUTTON_HELP: do_help(bot, update, chat_id) else: reply = msg_echo bot.send_message( chat_id=chat_id, text=reply, reply_markup=get_base_reply_keyboard(), )
def keyboard_callback_handler(bot, update, chat_data=None, **kwargs): health_status = None query = update.callback_query data = query.data chat_id = update.effective_message.chat_id if data == CALLBACK_BUTTON_GOOD: bot.send_message( chat_id=chat_id, text=msg_feel_GOOD, reply_markup=get_inline_keyboard_confirm(), ) health_status = 1 elif data == CALLBACK_BUTTON_OK: bot.send_message( chat_id=chat_id, text=msg_feel_OK, reply_markup=get_inline_keyboard_confirm(), ) health_status = 2 elif data == CALLBACK_BUTTON_BAD: bot.send_message( chat_id=chat_id, text=msg_feel_BAD, reply_markup=get_inline_keyboard_confirm(), ) health_status = 3 elif data == CALLBACK_BUTTON_SEND: bot.send_message( chat_id=chat_id, text=msg_feel_SEND, reply_markup=get_base_reply_keyboard(), ) status = None response_post_request = None while status != 200: status, data = get_data() while response_post_request != 200: response_post_request = send_health_status( health_status=health_status) elif data == CALLBACK_BUTTON_DISCARD: bot.send_message( chat_id=chat_id, text=msg_feel_DISCARD, ) do_feel(bot, update, chat_id)