def run(self): MINUTE_DELAY = 60 while True: # Get the current hot posts from the subreddit. front_posts = RedditManager.getFrontPage(subreddit=self.subreddit) count = 0 for post in front_posts: count += 1 DatabaseManager.update_post_rank(post.post_id, sub_rank=count) # Get the current hot posts from r/all filtered_dict = RedditManager.getFrontPageFiltered( subreddit='all', filtersub=self.subreddit) for rank, ranked_post in filtered_dict.items(): DatabaseManager.update_post_rank(ranked_post.post_id, all_rank=rank) print(rank) #Sleep for 5 minutes before checking again. time.sleep(10)
def setup_threads(subreddit): mod_monitor = ModeratorsMonitorThread(subreddit) rule_maint = RuleMaintenanceThread(subreddit) hot_monitor = HotMonitorThread(subreddit) user_stream = UserStreamThread() user_maint = UserMaintenanceThread() RedditManager.fetchCommentMetaRecent(subreddit) post_maint = PostMaintenanceThread() post_stream = PostStreamThread(subreddit) comment_stream = CommentStreamThread(subreddit) comment_maint = CommentMaintenanceThread() flair_maint = FlairMantenanceThread(subreddit) ban_maint = BanMaintenanceThread(subreddit) mod_monitor.start() rule_maint.start() hot_monitor.start() post_maint.start() user_stream.start() user_maint.start() post_stream.start() comment_stream.start() comment_maint.start() flair_maint.start() ban_maint.start()
def run(self): flair_list = RedditManager.get_flairs(subreddit=self.subreddit) DatabaseManager.update_flairs(flair_list) #Sleep for 10 minutes time.sleep(10 * 60)
def run(self): userlist = RedditManager.get_subreddit_moderators(self.subreddit) DatabaseManager.update_moderators(userlist, self.subreddit) for mod in userlist: DatabaseManager.ensure_user_exists(mod.username, self.subreddit) #Sleep for 10 minutes time.sleep(10 * 60)
def run(self): #TODO: change this by looking at changes in the modlog, and updating accordingly. #Currently, this simply pulls the entire mod list and updates it every 10 minutes. ban_list = RedditManager.get_bans(subreddit=self.subreddit) DatabaseManager.update_bans(ban_list=ban_list, subreddit=self.subreddit) # Sleep for 10 minutes time.sleep(10 * 60)
def main(): DatabaseManager.init_connection('test.sqlite') DatabaseManager.create_tables() RedditManager.login_threads_from_file("config.yml") ThreadedServices.setup_threads("BotParty") # RedditManager.get_bans("BotParty") # RedditManager.get_messages() # ThreadedServices.setup_threads(SUBREDDIT) # ThreadedServices.setup_threads("OnionHate") # ThreadedServices.setup_threads("OnionHate") while True: time.sleep(0)
def run(self): print("Comment Stream Thread Started") if self.sub is None: return while True: metaList = RedditManager.fetchCommentMetaRecent(self.sub) DatabaseManager.updateCommentList(metaList) for post_meta in metaList: DatabaseManager.ensure_user_exists(post_meta.username, post_meta.subreddit) time.sleep(10) pass