finalize
This commit is contained in:
parent
63aa05163f
commit
b9da761c1e
21
run.py
21
run.py
|
|
@ -18,8 +18,8 @@ def sub_exists(sub):
|
|||
exists = False
|
||||
return exists
|
||||
|
||||
def test(text):
|
||||
print(f'It is working {text}. Please press CTRL+C to close the script!')
|
||||
# def test(text):
|
||||
# print(f'It is working {text}. Please press CTRL+C to close the script!')
|
||||
|
||||
def e():
|
||||
title = input('What will be the title of your post? ')
|
||||
|
|
@ -55,7 +55,13 @@ def l():
|
|||
pass
|
||||
|
||||
def post(title, body, subreddit):
|
||||
reddit.subreddit(subreddit).submit(title, selftext=body)
|
||||
try:
|
||||
reddit.subreddit(subreddit).submit(title, selftext=body)
|
||||
print(f'Please press CTRL+C to close the script!')
|
||||
pass
|
||||
except:
|
||||
print(f'Something went wrong. Maybe you don\'t have permission to post in r/{subreddit}. Please press CTRL+C to close the script!')
|
||||
pass
|
||||
# sys.exit(f'Succesfully posted your text to r/{subreddit}. Thank you for using my script!')
|
||||
|
||||
def authenticate(password, user):
|
||||
|
|
@ -137,9 +143,16 @@ q -> quit the script-
|
|||
|
||||
print('Please don\'t exit the script until the scheduled time because in that case it wouldn\'t work!')
|
||||
|
||||
try:
|
||||
file = open("post.txt")
|
||||
except:
|
||||
print('Something went wrong while reading your post data. Please try again!')
|
||||
exit()
|
||||
|
||||
body = file.read()
|
||||
|
||||
sched = BlockingScheduler()
|
||||
sched.add_job(test, 'date', run_date=date_to_post, args=['text'])
|
||||
sched.add_job(post, 'date', run_date=date_to_post, args=[title, body, subreddit])
|
||||
|
||||
try:
|
||||
sched.start()
|
||||
|
|
|
|||
Loading…
Reference in New Issue