Ejemplo n.º 1
0
def praise(query, slack_event):
    """
    query - query str
    slack_event - A dict of slack event information

    Returns the query with some additional text praising it.
    """
    if len(query) == 0:
        return ":praise_the_sun:"
    query = query.strip().upper()
    requested_for = commands_helper.karma_requested_for(query, slack_event)

    if requested_for == 'self':
        user = '******' + slack_event['user'] + '>'
        return random.choice([
            user + " Isn't that a little like high fiving yourself?",
            user + ' That seems a little narcissistic...',
            user + " I don't really like doing that.",
            user + " I'm an XO on a space battleship, Who really deservers praise here?",
            user + " Do something someone else thinks worthy of praise and we'll talk",
        ])

    request.dynamodb_update(
        'karma_scores',
        {'user':{'S':query}},
        'ADD karma :val',
        {':val':{'N':'1'}}
    )

    if requested_for == 'bot':
        user = '******' + slack_event['user'] + '>'
        text = random.choice([
            user + " Thanks! That's so nice of you to say",
            user + ' Aww thanks!',
            user + ' :blobblush:',
            user + " :02blush: That's kind of you!",
            user + ' Oh, you! :meowblush:'
        ])

        text = text + '\n' +' My Karma is now: '

    else:
        user = query
        text = random.choice([
            'Great job! ' + user + ' I knew you could do it!',
            user + ' you have brought honor to your family name.',
            user + ' it takes a special person to accomplish what you have accomplished.',
            ':praise_the_sun::praise_the_sun:' + user + ' :praise_the_sun::praise_the_sun:',
            user + ' :drake_approves:',
            user + ' :chika-approves:',
            user + ' :batman-approves:',
            user + ' you have done well, and you should be proud.'
        ])

        text = text + '\n' + user + ' Your Karma is now: '
    return text + request.dynamodb_query(
        'karma_scores',
        {'user': {'S': query}}
    )['Item']['karma']['N']
Ejemplo n.º 2
0
def my_karma(_query, slack_event):
    """
    _query - query str (unused for this function)
    slack_event - A dict of slack event information(unused for this function)

    Returns the users karma:
    """
    text = random.choice([
        'Sure thing! Your karma is: ',
        "Let's see. Your current karma is: ",
        'I have your karma at: ',
        "Looks like your karma is: ",
    ])

    return text + request.dynamodb_query(
        'karma_scores',
        {'user': {'S': '<@' + slack_event['user'] + '>'}}
    )['Item']['karma']['N']
Ejemplo n.º 3
0
def karma_requested_for(query, slack_event):
    """
    Used to determine any special karma cases (e.g. someone wants to give themselves karma)

    query - query str (unused for this function)
    slack_event - A dict of slack event information

    returns one of the following: self, bot, or other
    """

    if query in ['ME', '<@' + slack_event['user'] + '>']:
        return 'self'
    if query == '<@' + request.dynamodb_query('bot_id', {'id': {
            'S': '1'
    }})['Item']['bot_id']['S'] + '>':
        return 'bot'

    return 'other'
Ejemplo n.º 4
0
def shame(query, slack_event):
    """
    query - query str
    slack_event - A dict of slack event information

    Returns the query with some additional text shaming it.
    """

    query = query.strip().upper()
    requested_for = commands_helper.karma_requested_for(query, slack_event)

    if requested_for == 'self':
        user = '******' + slack_event['user'] + '>'
        return random.choice([
            user + " You shouldn't be so hard on yourself :ganbatte:",
            user + " :02pat: There there I'm sure it'll get better",
            user + " :meowhug: It's not so bad I pronise things will get better.",
            ("```\nWhat though life conspire to cheat you,\n"
             "Do not sorrow or complain.\n"
             "Lie still on the day of pain,\n\n"
             "And the day of joy will greet you.\n"
             "Hearts live in the coming day.\n"
             "There's an end to passing sorrow.\n\n"
             "Suddenly all flies away,\n"
             "And delight returns tomorrow.\n"
             "~ A.S. Pushkin\n```"),
            (user + " Life is not always a matter of holding good cards,"
             "but sometimes, playing a poor hand well ~ Jack London"),
        ])

    request.dynamodb_update(
        'karma_scores',
        {'user':{'S':query}},
        'ADD karma :val',
        {':val':{'N':'-1'}}
    )

    if requested_for == 'bot':
        user = '******' + slack_event['user'] + '>'
        text = random.choice([
            user + " I'm sorry I've offended you so :bow:",
            user + ' Failure is not the end, I will endeavor to do better',
            user + ':sorry: I sincerely apologize! :bow: ',
            user + "You learn more from defeat. Still doesn't make it hurt any less. :sad:",
            user + ":sadlute:"
        ])

        text = text + '\n' +' My Karma is now: '

    else:
        user = query
        text = random.choice([
            'Shame on you! ' + user + 'You should know better!',
            user + ' ಠ_ಠ',
            user + ' You have made a mockery of yourself. Turn in your weeabo credentials!',
            user + ' :blobdisapproval:',
            user + ' :disappoint:',
            user + ' you did bad and you should feel bad',
            user + ' :smh:',
        ])
        text = text + '\n' + user + ' Your Karma is now: '

    return text + request.dynamodb_query(
        'karma_scores',
        {'user': {'S': query}}
    )['Item']['karma']['N']