daily pastebin goal
75%
SHARE
TWEET

Untitled

a guest Jan 12th, 2019 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def set_meeting_job(bot, update, chat_data, job_queue):
  2.     logger.info("[set_meeting_job] Setting cron job of meeting.")
  3.  
  4.     if update.callback_query.data == CANCEL:
  5.         update.callback_query.answer(text='')
  6.         update.effective_message.edit_text('Meeting cancelada ⛔️')
  7.         logger.info("Conversation ended.")
  8.         return ConversationHandler.END
  9.  
  10.     period_key = update.callback_query.data.split('_')[-1]
  11.     time_delta = time_delta_map[period_key]
  12.     frequency_friendly_name = friendly_name[period_key]
  13.  
  14.     # Feature: manage jobs in db to survive bot shutdown
  15.     job_queue.run_repeating(
  16.         send_notification,
  17.         interval=time_delta,
  18.         first=chat_data['datetime_utc'],
  19.         context=chat_data
  20.     )
  21.     logger.info("[set_meeting_job] Meeting set with datetime %s. Bs As: %s, and timedelta %s.",
  22.                 chat_data['datetime_utc'], chat_data['date_buenos_aires'], time_delta)
  23.  
  24.     # Save meeting to db
  25.     try:
  26.         save_meeting(chat_data['name'], chat_data['datetime_utc'])
  27.     except Exception:
  28.         logger.exception("Meeting could not be saved")
  29.  
  30.     update.callback_query.answer(text='Meeting saved')
  31.     update.callback_query.message.edit_text(
  32.         f"✅ Listo. La reunión `{chat_data['name']}` quedó seteada para el  `{chat_data['date_buenos_aires'].capitalize()}` "
  33.         f"y se repetirá `{frequency_friendly_name}`",
  34.         parse_mode='markdown',
  35.         reply_markup=None
  36.     )
  37.  
  38.     logger.info("Conversation has ended.")
  39.     return ConversationHandler.END
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top