diff --git a/.config.template.toml b/.config.template.toml index 34bd103..192ae3d 100644 --- a/.config.template.toml +++ b/.config.template.toml @@ -13,7 +13,6 @@ 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"] } -random = { optional = true, example = "True", explanation = "If set to no, it will ask you a thread link to extract the thread, if yes it will randomize it.", default = false, options = [true, false], type = "bool" } [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/reddit/subreddit.py b/reddit/subreddit.py index 44ef55a..3ad604c 100644 --- a/reddit/subreddit.py +++ b/reddit/subreddit.py @@ -70,10 +70,19 @@ def get_subreddit_threads(POST_ID: str): comment_type = settings.config["reddit"]["thread"]["sort"] - if str(comment_type) == "top": - threads = subreddit.top(limit=25) - else: - threads = subreddit.hot(limit=25) + try: + if str(comment_type) == "top": + threads = subreddit.top(limit=25) + elif str(comment_type) == "new": + threads = subreddit.new(limit=25) + elif str(comment_type) == "hot": + threads = subreddit.hot(limit=25) + elif str(comment_type) == "relevance": + threads = subreddit.relevance(limit=25) + else: + threads = subreddit.top(limit=25) + except AttributeError: + threads = subreddit.top(limit=25) submission = get_subreddit_undone(threads, subreddit) submission = check_done(submission) # double-checking