Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from apscheduler.schedulers.blocking import BlockingScheduler
- import praw
- from datetime import datetime,date
- sched = BlockingScheduler()
- def postit():
- reddit = praw.Reddit(client_id='reddit_app_id',
- client_secret='reddit_client_secret',
- password='reddit_password',
- user_agent='your custom user agent',
- username='reddit_username')
- reditor = reddit.redditor('target_redditor')
- file = open('response.txt', 'r')
- for submission in reditor.submissions.hot(limit=5):
- post_date=datetime.fromtimestamp(submission.created).strftime('%Y-%m-%d')
- current_date=date.today()
- if str(post_date) == str(current_date):
- print "Commenting...."
- submission.reply(file.read())
- print "Commented!"
- break
- def testit():
- reddit = praw.Reddit(client_id='reddit_app_id',
- client_secret='reddit_app_secret',
- password='reddit_password',
- user_agent='your custom user agent',
- username='reddit_username')
- subredit = reddit.subreddit('target_subreddit')
- file = open('response.txt', 'r')
- for submission in subredit.hot(limit=15):
- submission.reply(file.read())
- print "commented"
- break
- '''@sched.scheduled_job('interval', seconds=60)
- def timed_job():
- print "testing"
- testit()'''
- @sched.scheduled_job('cron', hour='9,21')
- def scheduled_job():
- postit()
- sched.start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement