Beispiel #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']
Beispiel #2
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']