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
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)
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)
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
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
def parent(self): return reddit.submission(self.item.crosspost_parent.split('_')[1])
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