def run (message):

    # Get the message contents
    text = message['text']

    # Remove a mention. This could be the case
    # if the bot was mentioned in a chat room
    if text.startswith('@'):
        text = text.split(' ', 1)[1].strip()

    # Some bots will accept commands that started
    # with a '/'
    if text.startswith('/'):
        text = text.replace('/', '', 1).strip()

    # Try and determine what was the trigger command
    # for this plugin.
    action = text.split(' ')[0].strip()

    # Hopefully we never get here, but just in case.
    if action not in commands():
        return 'Sorry, I don\'t know what to do with: {command}'.format(
            command = action
        )

    # Remove the trigger command
    for command in commands():
        text = ignore_case_replace(command, '', text).strip()

    # Now, parse the reminder line
    parts = _extract_parts(text)

    # If there was an error with the message, show it
    if parts['error']:
        error_message = 'Reminder not set. Error was: {e}.\n\n{help}'.format(
            e = parts['error_message'],
            help = _show_help(None)
        )

        return error_message

    # Handle a few control commands that should show
    # stop or display help for this plugin
    if parts['action'] in ['show', 'stop', 'help']:
        handle_action = {
            'show': _show_all_reminders,
            'stop': _stop_reminder,
            'help': _show_help,
        }

        # Handle and return the returned message
        return handle_action[parts['action']](message)

    # Fake a small case-like statement for the once or
    # every message types
    handle_recurrence_types = {
        'once': _set_once_reminder,
        'every': _set_recurring_reminder
    }

    # Run the appropriate set function
    handle_recurrence_types[parts['recurrence']](parts, message)

    # Respond with the fact that the reminder is set.
    response = 'Reminder set for: {t} with message: {m}'.format(
        t = parts['parsed_time'],
        m = parts['message']
    )

    return response
Run
dataset/ETHPy150Open leonjza/hogar/hogar/Plugins/Reminders/main.py/run