finalize
This commit is contained in:
parent
63aa05163f
commit
b9da761c1e
19
run.py
19
run.py
|
|
@ -18,8 +18,8 @@ def sub_exists(sub):
|
||||||
exists = False
|
exists = False
|
||||||
return exists
|
return exists
|
||||||
|
|
||||||
def test(text):
|
# def test(text):
|
||||||
print(f'It is working {text}. Please press CTRL+C to close the script!')
|
# print(f'It is working {text}. Please press CTRL+C to close the script!')
|
||||||
|
|
||||||
def e():
|
def e():
|
||||||
title = input('What will be the title of your post? ')
|
title = input('What will be the title of your post? ')
|
||||||
|
|
@ -55,7 +55,13 @@ def l():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def post(title, body, subreddit):
|
def post(title, body, subreddit):
|
||||||
|
try:
|
||||||
reddit.subreddit(subreddit).submit(title, selftext=body)
|
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!')
|
# sys.exit(f'Succesfully posted your text to r/{subreddit}. Thank you for using my script!')
|
||||||
|
|
||||||
def authenticate(password, user):
|
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!')
|
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 = 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:
|
try:
|
||||||
sched.start()
|
sched.start()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue