Beispiel #1
0
 def body(item):
     if hasattr(item, 'body'):
         return item.body
     elif hasattr(item, 'crosspost_parent'):
         return reddit.submission(item.crosspost_parent.split('_')[1]).selftext
     elif hasattr(item, 'selftext'):
         return item.body
Beispiel #2
0
    def crosspost_author(self, value, rule, options):
        if not hasattr(self.item, 'crosspost_parent'):
            return None

        author_checks = ModeratorAuthorChecks(self.moderator)
        author_checks.item = reddit.submission(self.item.crosspost_parent.split('_')[1])
        author_rule = Rule(value)
        return self.moderator.check(author_rule, checks=author_checks)
Beispiel #3
0
    def crosspost_author(self, rule, value):
        if not hasattr(self.item, 'crosspost_parent'):
            return None

        author_actions = ModeratorAuthorActions(self.moderator)
        author_actions.item = reddit.submission(self.item.crosspost_parent.split('_')[1])
        author_rule = Rule(value)
        return self.moderator.action(author_rule, actions=author_actions)
Beispiel #4
0
    def body(self,rule, options):
        body = ""
        if hasattr(self.item, 'crosspost_parent'):
            body = reddit.submission(self.item.crosspost_parent.split('_')[1]).selftext
        else:
            body = self.item.selftext

        if rule.config.get('ignore_blockquotes'):
            tick_match = re.compile(r'```.*?```', re.DOTALL)
            body = re.sub(tick_match, '', body)
            body = re.sub(r'    [^\n]*\n', '', body)

        return body
Beispiel #5
0
    def url(self, rule, options):
        if hasattr(self.item, 'crosspost_parent'):
            return reddit.submission(self.item.crosspost_parent.split('_')[1]).url

        return self.item.url
Beispiel #6
0
 def parent(self):
     return reddit.submission(self.item.crosspost_parent.split('_')[1])
Beispiel #7
0
 def crosspost_title(self, rule, options):
     if hasattr(self.item, 'crosspost_parent'):
         return reddit.submission(self.item.crosspost_parent.split('_')[1]).title
     else:
         return None