Merge pull request #245 from CallumIO/regex-inputs
Apply regex on subreddit inputs
This commit is contained in:
1 file changed
+3
-5
+3
-5
@@ -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")
|
||||
|
||||
Reference in new issue
Block a user