def performaction(thing, action, rule, matches):
    origaction = action.strip()
    action = action.strip().lower()
    logging.info("Perform %s on %s from %s" % (action, thing.permalink,
        rule['_filename']))

    # Compose message. All these are made the same way
    if action in ('respond', 'messagemods', 'messageauthor') or action.startswith('messagemods'):
        subject = "Modbot rule matched"
        try:
            if 'subject' in rule:
                subject = rule['subject'].format(thing=thing, rule=rule, matches=matches)
            text = rule['content'].format(thing=thing, rule=rule,
                    matches=matches)
        except Exception:
            # We'll just use a default message then
            text = """
The following post/comment by /u/{thing.author.name} matched the rule
{rule._filename}: {thing.permalink}
""".strip()
            text = text.format(thing=thing, rule=rule, matches=matches)
            pass

    if action == 'upvote':
        thing.upvote()
    elif action == 'log':
        rulelogger = logging.getLogger('rulelogger')
        rulelogger.info("%s - %s", thing.permalink, rule['_filename'])
    elif action == 'spam':
        thing.remove(True)
    elif action == 'remove':
        thing.remove(False)
    elif action == 'approve':
        thing.approve()
    elif action == 'respond':
        if isinstance(thing, Submission):
            comment = thing.add_comment(text)
        else:
            comment = thing.reply(text)
        comment.distinguish()
    elif action.startswith('messagemods'):
        if ':' in action:
            sub = origaction.split(':', 1)[1]
            target = thing.reddit_session.get_subreddit(sub)
        else:
            target = thing.subreddit
        target.send_message(subject, text)
    elif action in ('beep', 'bell'):
        sys.stdout.write("\x07")
    elif action == 'messageauthor':
        thing.author.send_message(subject, text)
    elif action == 'report':
        thing.report()
    elif action.startswith('linkflair') and action in ':':
        linkflair = origaction.split(':', 1)[1]
        values = linkflair.split(':', 1)
        if len(values) == 1:
            s = thing.set_flair(flair_text=values[0])
        else:
            css_class, text = values
            s = thing.set_flair(flair_text=text, flair_css_class=css_class)
    elif action in ('none', 'null', 'ignore'):
        pass
    else:
        logging.warning("Unknown action: %s from %s" % (action,
            rule['_filename']))
dataset/ETHPy150Open rasher/reddit-modbot/modbot.py/performaction/swapped operands of `in`