Пример #1
0
 def __init__(self, logger):
     self.logger = logger
     self.config = self._load_config()
     self._sub_config = self.config["subreddit"]
     self.praw_h = self.login()
     self.subreddit = self.praw_h.subreddit(self._sub_config["uri"])
     self.puni_h = puni.UserNotes(self.praw_h, self.subreddit)
Пример #2
0
 def __init__(self, r, subreddit):
     self.cache_timeout = {
         'modmail': 0,
         'automoderator_wiki': 0,
         'stylesheet': 0
     }
     self.praw = subreddit
     self.un = puni.UserNotes(r, subreddit)
     self.mmdb = mmdb.ModmaildB(r, subreddit)
Пример #3
0
    def _init_modules(self):
        self.user_warnings = None
        self.spam_cruncher = None
        self.flair_enforcer = None
        self.botbans = False
        self.watch_stickies = False
        self.un = None
        self.summary_generator = None
        users_tracked = False

        if 'botbans' in self.config.modules:
            self.botbans = True

        if "userwarnings" in self.config.modules:
            self.user_warnings = UserWarnings(self.subreddit_name,
                                              self.webhook,
                                              10,
                                              5,
                                              1,
                                              botbans=self.botbans)
            users_tracked = True

        if "flairenforce" in self.config.modules:
            self.flair_enforcer = FlairEnforcer(self.r, self.subreddit_name)

        if "usernotes" in self.config.modules:
            self.un = puni.UserNotes(self.r, self.subreddit)

        if "watchstickies" in self.config.modules:
            self.watch_stickies = True

        try:
            self.summary_generator = SummaryGenerator(
                self.subreddit_name,
                self.config.reddit_refresh_token,
                spamcruncher=self.spam_cruncher,
                users_tracked=users_tracked,
                botbans=self.botbans,
                un=self.un)

        except imgurpython.helpers.error.ImgurClientError:
            print("IMGUR service unavailable")
            print("Summary generation not available")
            raise

        print("Done initializing | " + self.config.subreddit)
        self.do_work()
Пример #4
0
def initialize():
    global reddit
    global pushshift
    global subreddit
    global usernotes
    global slack_client

    try:
        logging.basicConfig(level=logging.INFO)
    except Exception as e:
        logger.error('Error creating log directory or logging.')
        print(e)
        return False

    try:
        reddit = praw.Reddit(client_id=CLIENT_ID,
                             client_secret=CLIENT_SECRET,
                             user_agent=USER_AGENT,
                             username=CLIENT_USERNAME,
                             password=CLIENT_PASSWORD)
    except (Exception) as e:
        logger.error('Error initializing reddit/subreddit instances.')
        return False

    if CHECKAUTOMOD:
        try:
            slack_client = slack.WebClient(token=SLACK_TOKEN)
        except (Exception) as e:
            print(e)
            logger.error('Error initializing slack instances.')
            return False

    try:
        usernotes = puni.UserNotes(reddit, reddit.subreddit(SUBREDDIT))
    except (Exception) as e:
        print(e)
        logger.error('Error initializing usernotes instances.')
        return False

    return True
Пример #5
0
import praw
import puni

#you need to have registed a personal script in reddit 
reddit = praw.Reddit(client_id = ,client_secret = 
, username = , password = , user_agent = )


r = reddit.subreddit("") #type the name of the subreddit you are moderating, without r/ (so just type in askreddit, not r/askreddit)
un = puni.UserNotes(reddit, r)
redditor = reddit.redditor("")#type in your username, exlcluding u/ (so just type in MajorMajorMajor instead of u/MajorMajorMajor


noted = False

for user in un.get_users():
    try:
        #type the name of the subreddit you are moderating, just like before
        if (any(reddit.subreddit(" ").banned(redditor=user))): #this line checks if the user is banned in the particular subreddit

            for note in un.get_notes(user):
                     #if user has no notes, this does not evaulate, hence, noted reamins false
                    print (note.note + " " + user)
                    noted = True

            if (not noted):
                     #user is banned, it has note, but the note is empty
                    link = 'http://www.reddit.com/message/messages/4vjx3v'   #have no idea what this is for
                    n = puni.Note(user, reason(this is the note), moderator(your username), link, 'permban')
                    un.add_note(n)
                    print ("added")