Example #1
0
def change_reminder_intent(message, intent):
    """Handle change meeting reminder intent

    Args:
        message (Message): the Telegram message object
        intent (IntentResult): the intent result from Dialogflow
    """
    datetime = intent.params["datetime"]

    # Change meeting reminder with a given datetime
    if datetime is not None:
        meeting = database.get_meeting_by_time(message.chat.id, datetime)
        if meeting is None:
            message.reply_text(
                "No meeting found with the given date and time. Please try again."
            )
        else:
            if meeting.has_reminder:
                status = "on"
                button = "Turn off"
            else:
                status = "off"
                button = "Turn on"

            keyboard = [[
                InlineKeyboardButton(
                    button,
                    callback_data=
                    f"{consts.CHANGE_REMIND},{meeting.meeting_id}",
                )
            ]]
            reply_markup = InlineKeyboardMarkup(keyboard)
            message.reply_text(
                text=(f"Reminder is currently <b>turned {status}</b> for "
                      f"the meeting on <b>{meeting.formatted_datetime()}</b>"),
                reply_markup=reply_markup,
                parse_mode=ParseMode.HTML,
            )

    # Provide user with a list of meetings to choose from
    else:
        reply_markup = remind_main_menu_keyboard(message.chat.id)
        if reply_markup is None:
            message.reply_text(
                "No meetings found or your meetings are in the past")
        else:
            message.reply_text(
                text="Select the meeting to change its reminder setting:",
                reply_markup=reply_markup,
            )
Example #2
0
def get_notes_with_datetime(message, datetime):
    """Get notes with a given meeting datetime

    Args:
        message (Message): the Telegram message object
        datetime (Arrow): the arrow datetime
    """
    meeting = database.get_meeting_by_time(message.chat_id, datetime)
    if meeting is None:
        message.reply_text(
            "No meeting found with the given date and time. Please try again.")
    else:
        if meeting.notes:
            message.reply_document(meeting.notes,
                                   caption="Here's your meeting notes.")
        else:
            message.reply_text("No meeting notes found for the meeting.")
def cancel_meeting_intent(message, intent):
    """Handle cancel meeting intent

    Args:
        message (Message): the Telegram message object
        intent (IntentResult): the intent result from Dialogflow
    """
    datetime = intent.params["datetime"]

    # Cancel meeting with a given meeting datetime
    if datetime is not None:
        meeting = database.get_meeting_by_time(message.chat.id, datetime)
        if meeting is None:
            message.reply_text(
                "No meeting found with the given date and time. Please try again."
            )
        else:
            # cm: cancel_meeting
            keyboard = [
                [
                    InlineKeyboardButton(
                        "Yes", callback_data=f"cm{meeting.meeting_id}")
                ],
                [
                    InlineKeyboardButton("No",
                                         callback_data="cancel_cancel_meeting")
                ],
            ]
            reply_markup = InlineKeyboardMarkup(keyboard)
            message.reply_text(
                text=("Are you sure you want to cancel the meeting at "
                      f"<b>{meeting.formatted_datetime()}</b>"),
                reply_markup=reply_markup,
                parse_mode=ParseMode.HTML,
            )

    # Provide user with a list of meetings to choose to cancel
    else:
        reply_markup = cancel_meeting_main_menu_keyboard(message.chat.id)
        if reply_markup is None:
            message.reply_text("No scheduled meetings.")
        else:
            message.reply_text(text="Choose the option in main menu:",
                               reply_markup=reply_markup)
Example #4
0
def store_notes_with_datetime(context, message, datetime):
    """Store notes with a given meeting datetime

    Args:
        context (Context): the Telegram context object
        message (Message): the Telegram message object
        datetime (Arrow): the arrow datetime
    """
    meeting = database.get_meeting_by_time(message.chat_id, datetime)
    if meeting is None:
        message.reply_text(
            "No meeting found with the given date and time. Please try again.")
    else:
        if meeting.datetime > arrow.utcnow():
            message.reply_text(
                "Your meeting hasn't started yet, you can only store notes "
                "after you've finished your meeting.")
        else:
            # Check if meeting notes file exists, if so, ask if user wants to replace it
            if meeting.notes:
                context.user_data[consts.CONFIRM_STORE_NOTES] = True
                message.reply_text(
                    "A meeting notes file already exists for this meeting, "
                    "do you want to replace it?",
                    reply_markup=store_notes_confirm_keyboard(
                        meeting.meeting_id),
                )
            else:
                context.user_data[consts.STORE_NOTES] = meeting
                reply_markup = None

                if message.chat.type != Chat.PRIVATE:
                    reply_markup = ForceReply()

                message.reply_text("Please send me the meeting notes file.",
                                   reply_markup=reply_markup)