this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

sdw: drop replies, embeds, and facets

+18 -12
+18 -12
feeds/sevendirtywords.py
··· 6 6 7 7 from . import BaseFeed 8 8 9 + # https://en.wikipedia.org/wiki/Seven_dirty_words 9 10 SDW_REGEX = re.compile(r'^(shit|piss|fuck|cunt|cocksucker|motherfucker|tits)[!,./;?~ ]*$', re.I|re.A) 10 11 11 12 class SevenDirtyWordsFeed(BaseFeed): ··· 35 36 if record is None: 36 37 return 37 38 38 - if record.get('reply') is not None: 39 + conds = [ 40 + record.get('reply') is None, 41 + record.get('embed') is None, 42 + record.get('facets') is None, 43 + SDW_REGEX.search(record['text']) is not None, 44 + ] 45 + 46 + if not all(conds): 39 47 return 40 48 41 - # https://en.wikipedia.org/wiki/Seven_dirty_words 42 - if SDW_REGEX.search(record['text']) is not None: 43 - repo = commit['did'] 44 - rkey = commit['rkey'] 45 - post_uri = f'at://{repo}/app.bsky.feed.post/{rkey}' 46 - ts = self.safe_timestamp(record.get('createdAt')).timestamp() 47 - self.transaction_begin(self.db_cnx) 48 - self.db_cnx.execute( 49 - 'insert into posts (uri, create_ts) values (:uri, :ts)', 50 - dict(uri=post_uri, ts=ts) 51 - ) 49 + repo = commit['did'] 50 + rkey = commit['rkey'] 51 + post_uri = f'at://{repo}/app.bsky.feed.post/{rkey}' 52 + ts = self.safe_timestamp(record.get('createdAt')).timestamp() 53 + self.transaction_begin(self.db_cnx) 54 + self.db_cnx.execute( 55 + 'insert into posts (uri, create_ts) values (:uri, :ts)', 56 + dict(uri=post_uri, ts=ts) 57 + ) 52 58 53 59 def commit_changes(self): 54 60 self.logger.debug('committing changes')