示例#1
0
文件: bot.py 项目: jtbg/SnooHelper
    def scan_comments(self):
        db.connect()
        comments = self.subreddit.comments(limit=100)
        sticky_comments_ids = [
            "t1_" + submission.sticky_cmt_id
            for submission in SubmissionModel.select()
        ]

        for comment in comments:
            try:
                self.already_done_helper.add(comment.id, self.subreddit_name)
            except IntegrityError:
                continue

            try:
                user = UserModel.get(
                    UserModel.username == comment.author.name.lower(),
                    UserModel.subreddit == comment.subreddit.display_name)
            except DoesNotExist:
                continue

            if user.shadowbanned:
                self.subreddit.mod.remove(comment)
            if user.tracked:
                self.user_warnings.send_warning(comment)
            if self.watch_stickies and comment.parent_id in sticky_comments_ids:
                self.subreddit.mod.remove(comment)

            self.user_warnings.check_user_offenses(user)
        db.close()
示例#2
0
文件: bot.py 项目: jtbg/SnooHelper
    def scan_submissions(self):
        db.connect()
        submissions = self.subreddit.new(limit=50)
        if self.flair_enforcer is not None:
            self.flair_enforcer.check_submissions()

        for submission in submissions:
            try:
                self.already_done_helper.add(submission.id,
                                             self.subreddit_name)
            except IntegrityError:
                continue

            if self.flair_enforcer is not None and submission.link_flair_text is None:
                self.flair_enforcer.add_submission(submission)

            try:
                user = UserModel.get(
                    UserModel.username == submission.author.name.lower() and
                    UserModel.subreddit == submission.subreddit.display_name)
            except DoesNotExist:
                continue

            if user.shadowbanned:
                self.subreddit.mod.remove(submission)

            if self.user_warnings is not None:
                if user.tracked:
                    self.user_warnings.send_warning(submission)

                self.user_warnings.check_user_offenses(user)
        db.close()
示例#3
0
 def unmute_user_warnings(user, subreddit):
     user = UserModel.get(UserModel.username == user.lower()
                          and UserModel.subreddit == subreddit)
     user.warnings_muted = False
     user.save()