Created
May 17, 2015 18:09
-
-
Save ChangedNameTo/fb39b045bf7c0101f252 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def process_pms(self): | |
for pm in self.pms: | |
try: | |
if str(pm.subject) == self.SUBJECT: | |
author = str(pm.author) # Author of the PM | |
if author.lower() in (user.lower() for user in self.BLACKLIST): | |
continue | |
content = str(pm.body) # Content of the PM | |
index = content.find(":") | |
if index != -1: | |
continue | |
newflair = content[:index].strip()# Substrings the PM to get flair only | |
subreddit = self.r.get_subreddit(self.TARGET_SUB) | |
if newflair in flairs: | |
# Get the flair text that corresponds with the class name | |
flair_text = content[index + 1:].strip() | |
subreddit.set_flair(author, flair_text, newflair) | |
if self.LOGGING: | |
self.log(author, content, flair_text, newflair) | |
pm.mark_as_read() # Mark processed PM as read |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment