Updated the .env.template to be a little easier to deal with.

pull/4/head
Lewis Menelaws 3 years ago
parent 4f4616a49f
commit 9bb116793a

@ -2,5 +2,5 @@ REDDIT_CLIENT_ID=""
REDDIT_CLIENT_SECRET="" REDDIT_CLIENT_SECRET=""
REDDIT_USERNAME="" REDDIT_USERNAME=""
REDDIT_PASSWORD="" REDDIT_PASSWORD=""
ASK_EACH_TIME="TRUE"
SUBREDDIT="" SUBREDDIT=""

@ -22,16 +22,14 @@ def get_subreddit_threads():
password=os.getenv("REDDIT_PASSWORD"), password=os.getenv("REDDIT_PASSWORD"),
) )
if os.getenv("ASK_EACH_TIME") == "TRUE": if os.getenv("SUBREDDIT"):
try: subreddit = reddit.subreddit(os.getenv("SUBREDDIT"))
subreddit = reddit.subreddit(input("What subreddit would you like to pull from? "))
except ValueError:
subreddit = reddit.subreddit("askreddit")
print_substep("Subreddit not defined. Using AskReddit.")
else: else:
# ! Prompt the user to enter a subreddit
try: try:
subreddit = reddit.subreddit(os.getenv("SUBREDDIT")) subreddit = reddit.subreddit(
print_substep(f"Using subreddit {os.getenv('SUBREDDIT')}") input("What subreddit would you like to pull from? ")
)
except ValueError: except ValueError:
subreddit = reddit.subreddit("askreddit") subreddit = reddit.subreddit("askreddit")
print_substep("Subreddit not defined. Using AskReddit.") print_substep("Subreddit not defined. Using AskReddit.")

Loading…
Cancel
Save