.format(num = trunc_pad("#", 'num'), id = trunc_pad("id"), author = trunc_pad("author"), title = trunc_pad("title"), _ = ' ').upper()) subreddit = reddit.get_subreddit('ucsc') list_of_posts_with_mentions = [] for counter, submission in enumerate(subreddit.get_new(limit = num_posts_), start = 1): found_mentions = _get_mentions_in_submission(counter, submission) if found_mentions is not None: list_of_posts_with_mentions.append(found_mentions) if running_on_own: tools.save_found_mentions(list_of_posts_with_mentions) print("------------------------------") for post_with_mention in list_of_posts_with_mentions: print(str(post_with_mention)) return list_of_posts_with_mentions if __name__ == "__main__": import sys num_posts = 10 if len(sys.argv) == 2: num_posts = int(sys.argv[1]) find_mentions(tools.auth_reddit(), num_posts, running_on_own = True)
""" Runs find_mentions and post_comments. """ from db_core import CourseDatabase, Department, Course # need this to de-pickle course_database.pickle from mention_search_posts import find_mentions from post_comments import post_comments import tools import sys num_posts = 3 if len(sys.argv) == 2: num_posts = int(sys.argv[1]) reddit = tools.auth_reddit() post_comments(find_mentions(reddit, num_posts), reddit)
:param running_on_own: whether file is being ran by itself or imported by reddit_bot.py :type running_on_own: bool :param reddit: authorized reddit praw object :type reddit: praw.Reddit :param new_mentions_list: list of mentions :type new_mentions_list: list """ if new_mentions_list: new_mention = new_mentions_list.pop(0) else: print("No more mentions.") return _post_comment_helper(new_mention, reddit) if running_on_own: tools.save_found_mentions(new_mentions_list) post_comments(new_mentions_list, reddit, running_on_own) existing_posts_with_comments = tools.load_posts_with_comments() db = db_core.load_database() if __name__ == "__main__": print('{id}{_}{author}{_}{title}{_}{action}{_}current mentions{_}previous mentions' .format(id = trunc_pad("id"), author = trunc_pad("author"), title = trunc_pad("title"), action = trunc_pad("action"), _ = ' ')) post_comments(tools.load_found_mentions(), tools.auth_reddit(), running_on_own = True)