def send_feedback_request(hours_of_day: list): audience = get_all_humans_for_telegram_notifications( hours_of_day=hours_of_day) # create bot bot = get_telegram_bot_instance() # send to audience notify_admin = True count = 0 for member in audience: try: bot.send_message( chat_id=member[HumanProperties.TELEGRAM_HUMAN_ID.value], text= "*[🤙 Feedback Request]* Please share your feedback on the product by clicking here: @OpendemicTeam", parse_mode='markdown', reply_markup=get_telegram_menu()) except Exception as e: if notify_admin: bot.send_message( chat_id=int( CONFIG.get('telegram-credentials-telegram-admin-id')), text="[ADMIN] `send_feedback_request` exception : {}". format(e)) notify_admin = False # try to unsubscribe try: human = Human(human_id=member[HumanProperties.ID.value]) human.unsubscribe() except Exception as unsb_e: pass else: count += 1 # alert admin bot.send_message( chat_id=int(CONFIG.get('telegram-credentials-telegram-admin-id')), text="[ADMIN] Sent feedback request to {}/{} humans.".format( count, len(audience)))
def send_reminders(hours_of_day: list): audience = get_all_humans_for_telegram_notifications( hours_of_day=hours_of_day) # create bot bot = get_telegram_bot_instance() # send to audience notify_admin = True count = 0 for member in audience: try: bot.send_message( chat_id=member[HumanProperties.TELEGRAM_HUMAN_ID.value], text= "👇 Remember to report your location (always) and symptoms (if any) 👇", reply_markup=get_telegram_menu()) except Exception as e: if notify_admin: bot.send_message( chat_id=int( CONFIG.get('telegram-credentials-telegram-admin-id')), text="[ADMIN] `send_reminders` exception : {}".format(e)) notify_admin = False # try to unsubscribe try: human = Human(human_id=member[HumanProperties.ID.value]) human.unsubscribe() except Exception as unsb_e: pass else: count += 1 # alert admin bot.send_message(chat_id=int( CONFIG.get('telegram-credentials-telegram-admin-id')), text="[ADMIN] Sent reminder to {}/{} humans.".format( count, len(audience)))