if __name__ == "__main__": parser = argparse.ArgumentParser(description="Reddit Personal Utils") parser.add_argument("user", help="The reddit user account to use") parser.add_argument("--once", help="Only run the loop once", action='store_const', const=True, default=False) args = parser.parse_args() reddit = praw.Reddit(args.user) discord_logging.init_discord_logging(args.user, logging.WARNING, 1) counters.init(8004) database.init() log.info(f"Starting up: u/{args.user}") while True: try: main(reddit) except Exception as err: utils.process_error(f"Error in main loop", err, traceback.format_exc()) discord_logging.flush_discord() if args.once:
parser.add_argument("--debug_db", help="Use the debug database", action='store_const', const=True, default=False) parser.add_argument( "--no_post", help="Print out reddit actions instead of posting to reddit", action='store_const', const=True, default=False) parser.add_argument( "--no_backup", help="Don't backup the database", action='store_const', const=True, default=False) parser.add_argument( "--reset_comment", help="Reset the last comment read timestamp", action='store_const', const=True, default=False) parser.add_argument("--debug", help="Set the log level to debug", action='store_const', const=True, default=False) parser.add_argument( "--pushshift", help="Select the pushshift client to use", action='store', choices=["prod", "beta", "auto"], default="prod") args = parser.parse_args() counters.init(8001) counters.errors.labels(type="startup").inc() if args.debug: discord_logging.set_level(logging.DEBUG) discord_logging.init_discord_logging(args.user, logging.WARNING, 1) if args.pushshift == "prod": pushshift_client = PushshiftType.PROD elif args.pushshift == "beta": pushshift_client = PushshiftType.BETA elif args.pushshift == "auto": pushshift_client = PushshiftType.AUTO else: log.warning(f"Invalid pushshift client: {args.pushshift}")
praw_file = discord_logging.get_config() discord_logging.init_discord_logging("QueueBot", logging.WARNING, 1, logging_webhook=discord_logging.get_config_var(praw_file, "global", 'queue_webhook')) database = Database() instances = {} for username in ['OWMatchThreads', 'CustomModBot', 'Watchful1']: try: instances[username] = praw.Reddit(username, user_agent=static.USER_AGENT) log.info(f"Logged into reddit as /u/{instances[username].user.me().name}") except configparser.NoSectionError: log.error("User "+args.user+" not in praw.ini, aborting") sys.exit(0) log.info(f"Python version {sys.version}") counters.init(8003) comp_ow = Subreddit( "CompetitiveOverwatch", 1, instances['OWMatchThreads'], static.COMPOW_MODERATORS, known_log_types=static.COMPOW_KNOWN_LOG_TYPES, warning_log_types=static.COMPOW_WARNING_LOG_TYPES, report_reasons=static.COMPOW_REPORT_REASONS, comment_report_reasons=static.COMPOW_COMMENT_REPORT_REASONS, reapprove_reasons=['#2 No Off-Topic or Low-Value Content', 'This is spam'], thresholds={ 'unmod': {'track': True, 'post': 15, 'ping': 20}, 'unmod_hours': {'post': 4, 'ping': 6}, 'modqueue': {'track': True, 'post': 8, 'ping': 12},