From 312d25c680576502cd47fe226138c994373e316a Mon Sep 17 00:00:00 2001 From: anthony lloyd Date: Mon, 11 Jul 2022 20:38:40 +1000 Subject: [PATCH] minimum comments user defined variable --- .config.template.toml | 1 + utils/subreddit.py | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.config.template.toml b/.config.template.toml index 62a8c38..721a9c7 100644 --- a/.config.template.toml +++ b/.config.template.toml @@ -13,6 +13,7 @@ max_comment_length = { optional = false, example = 500, explanation = "max numb post_lang = { optional = true, example = "es-cr", explanation = "The language you would like to translate to.", default = "" } sort = { optional = true, example = "hot ,top, relevance, new", explanation = "method of sorting threads", default = "top", options = ["hot", "top", "relevance", "new"] } sort_time = { optional = true, example = "day, hour, week, month, year, all", explanation = "time range to gather threads from", default = "all", options = ["day", "hour", "week", "month", "year", "all"] } +min_comments = { optional = true, example = "100", explanation = "dont allow threads with amount of comments bellow this value", default = "100", type = "int", nmin = 0 } [settings] allow_nsfw = { optional = false, example = "false", explanation = "Whether to allow NSFW content, True or False", default = false, options = [true, false], type = "bool" } diff --git a/utils/subreddit.py b/utils/subreddit.py index c7e00e9..b0d601c 100644 --- a/utils/subreddit.py +++ b/utils/subreddit.py @@ -34,8 +34,14 @@ def get_subreddit_undone(submissions: list, subreddit): if submission.stickied: print_substep("This post was pinned by moderators. Skipping...") continue - if submission.num_comments < 100: - print_substep("This post has less than 100 comments. Skipping...") + if submission.num_comments < 0: + print_substep("This post has 0 comments. Skipping...") + continue + try: + if submission.num_comments < settings.config["reddit"]["thread"]["min_comments"]: + print_substep("This post has less than user defined minimum comments, Skipping...") + continue + except AttributeError: continue return submission print("all submissions have been done going by top submission order")