Coming soon - Get a detailed view of why an account is flagged as spam!
view details

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

1
[PRAW] Setting flair?
Post Flair (click to view more posts with a particular flair)
Author Summary
CWinthrop is in PRAW
Post Body

So in the bot I'm working on, I have this code:

flair_triggers = {
                  'medical': 'Rule: Medical Discussion',
                  'underage': 'Rule: Underage Drinking',
                  'illegal': 'Rule: Illegal Activity',
                  'shitpost': 'Rule: Shitposting',
                  'purchase': 'Rule: Purchase/Valuation Request',
                  'advertising': 'Rule: Advertising',
                  'rhetoric': 'Rule: Anti-Alcohol Rhetoric'}

for trigger, flair in flair_triggers.items():
    choices = submission.flair.choices()
    template_id = next(x for x in choices
                       if x['flair_text_editable'])['flair_template_id']
    print('Setting flair: ', flair)
    submission.flair.select(template_id, flair)

BUT, when it gets triggered, it outputs this per trigger:

Setting flair:  Rule: Illegal Activity
Setting flair:  Rule: Anti-Alcohol Rhetoric
Setting flair:  Rule: Medical Discussion
Setting flair:  Rule: Purchase/Valuation Request
Setting flair:  Rule: Advertising
Setting flair:  Rule: Underage Drinking
Setting flair:  Rule: Shitposting

How can I get it to just set the flair to match the trigger?

Edit: Here's the entire bot script.

Author
Account Strength
100%
Account Age
10 years
Verified Email
Yes
Verified Flair
No
Total Karma
19,425
Link Karma
6,051
Comment Karma
13,278
Profile updated: 5 days ago
Posts updated: 9 months ago

Subreddit

Post Details

Location
We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
7 years ago