Example #1
0
def handleMessage(msg):
    shield = msg.subject.lower()
    title = msg.body
    user = msg.author
    flair = flairs.get(shield, None)
    if (shield.lower() == "clear"):
        clearFlair(user)
        pprint("Clear the flair for %s" % (user))
    elif (flair is None):
        pprint("Flair isn't recognized %s - %s - %s" % (user, title, shield))
        r.send_message(msg.author, "Flair and Title Not Updated -- Unrecognized Shield Name", flair_response.noShieldFlairReply , None)
    elif (len(title) > 40):
        pprint("Flair is too long %s - %s -%s" % (user, title, shield))
        r.send_message(msg.author, "Flair and Title Not Updated -- Flair is too long", flair_response.tooLongFlairReply , None)
    elif (isCaps(title)):
        pprint("Flair is caps %s - %s - %s" % (user, title, shield))
        r.send_message(msg.author, "Flair and Title Not Updated -- Rule Violation -- All Caps", flair_response.allCapsFlairReply  , None)
    elif ((hasBadWord(title, spoiler) or hasBadWord(title,naughty)) and not isApprovedFlair(title)):
        r.send_message(msg.author, "Flair and Title Waiting for approval -- Possible Spoiler", flair_response.spoilerFlairReply , None)
        #send mod message
        r.send_message('/r/'+subreddit, "Flair needs approval", flair_response.approvalFlairReply.format(user.name, title, "http://www.reddit.com/message/compose?to="+urllib.quote(creds['user'])+"&subject="+urllib.quote(user.name+" "+msg.subject)+"&message="+urllib.quote(title)))
        pprint("Flair needs approval %s - %s - %s" % (user, title, shield))
    else:
        if changeFlair(flair, title, user.name):
            r.send_message(msg.author, "Shield and Title Changed Successfully!", flair_response.successFlairReply, None)
Example #2
0
def handeModMessage(msg):
    print "handling mod message"
    title = msg.subject.split()
    if (len(title) < 2):
        #changing personal flair?
        return handleMessage(msg)
    user = title[0]
    shield = title[1].lower()
    flair = flairs.get(shield, None)
    title = msg.body
    if (shield.lower() == 'clear'):
        clearFlair(user)
    elif (flair is None):
        return False
    else:
        if changeFlair(flair, title, user):
            r.send_message(user, "Shield and Title Changed Successfully!", flair_response.successFlairReply  , None)
            return True