Merge pull request #245 from CallumIO/regex-inputs

Apply regex on subreddit inputs
pull/274/head
Luka Hietala 3 years ago committed by GitHub
commit 1f895afeb2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,8 +1,6 @@
from utils.console import print_markdown, print_step, print_substep
import praw
import random
from dotenv import load_dotenv
import os
import os, random, praw, re
def get_subreddit_threads():
@ -37,12 +35,12 @@ def get_subreddit_threads():
)
if os.getenv("SUBREDDIT"):
subreddit = reddit.subreddit(os.getenv("SUBREDDIT"))
subreddit = reddit.subreddit(re.sub(r"r\/", "", os.getenv("SUBREDDIT")))
else:
# ! Prompt the user to enter a subreddit
try:
subreddit = reddit.subreddit(
input("What subreddit would you like to pull from? ")
re.sub(r"r\/", "", input("What subreddit would you like to pull from? "))
)
except ValueError:
subreddit = reddit.subreddit("askreddit")

Loading…
Cancel
Save