Exemple #1
0
 def test_delete(self, _):
     self.reddit.read_only = False
     with self.recorder.use_cassette("TestComment.test_delete"):
         comment = Comment(self.reddit, "d1616q2")
         comment.delete()
         assert comment.author is None
         assert comment.body == "[deleted]"
Exemple #2
0
 def test_delete(self, _):
     self.reddit.read_only = False
     with self.recorder.use_cassette('TestComment.test_delete'):
         comment = Comment(self.reddit, 'd1616q2')
         comment.delete()
         assert comment.author is None
         assert comment.body == '[deleted]'
Exemple #3
0
def delete_removal_comment(subreddit: Subreddit, post_removal):
    logger.warning("2: Deleting removal comment {post_id}".format(post_id=post_removal.removal_comment_id))

    removal_comment = Comment(id=post_removal.removal_comment_id, reddit=subreddit.reddit_api)
    removal_comment.delete()

    post_removal.removal_comment_id = None
    post_removal.save()
Exemple #4
0
def modify_exisiting_comment(
    comment: Comment, comment_string: str, post_tags: List[str]
) -> None:
    logger.debug(comment.body)
    if comment_string != comment.body:
        if len(post_tags) > 0:
            comment.edit(comment_string)
            logger.info(f"edited {comment_string}")
        else:
            comment.delete()
            logger.info(f"Comment deleted: {comment_string}")
    else:
        logger.info("Comment is the same as last time, not editing")
Exemple #5
0
def downvote_deleter():
    reddit = get_reddit()
    redis_client = get_redis_client()
    logging.info('Monitoring downvotes')
    while True:
        for comment_id in redis_client.smembers('comments'):
            try:
                comment = Comment(reddit, id=comment_id.decode(
                    'utf-8'))  # redis-py bug, not decoding to UTF-8
                if comment.score < 1:
                    comment.delete()
                    redis_client.srem('comments', comment_id)
                    logging.info(f'Removed downvoted comment {comment.id}')
            except praw.exceptions.PRAWException as e:
                logging.exception(e)
        time.sleep(60)