Skip to content

Instantly share code, notes, and snippets.

@thecravenone
Created February 6, 2020 23:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thecravenone/fa67725bd77524a40b37c5de554bdc99 to your computer and use it in GitHub Desktop.
Save thecravenone/fa67725bd77524a40b37c5de554bdc99 to your computer and use it in GitHub Desktop.
# cronjob, assuming server in Houston time:
# 0 6 * * 4 python3 /path/to/this/file.py > /path/to/log
import praw
from datetime import date, timedelta
reddit = praw.Reddit(client_id="CLIENT_ID",
client_secret="CLIENT SECRET",
password="PASSWORD",
user_agent='/r/Houston things to do auto-poster',
username="USERNAME")
body = """**Looking for events during the week, or things not listed here? Check out:**
[CultureMap Houston](http://houston.culturemap.com/events/)
[Houston Press Calendar](https://www.houstonpress.com/calendar)
[Houston on the Cheap](http://www.houstononthecheap.com/)
[Space City Rock](http://www.spacecityrock.com/shows-2/)
If you wish to add to this list, please reply with a formatted text link to the event website or fb event page. If you do not know how to format, click formatting help under the reply box."""
thursday = date.today().strftime('%-m/%-d')
sunday_date = date.today() + timedelta(days=3)
sunday = sunday_date.strftime('%-m/%-d')
subject = "Things to do this Weekend " + thursday + " - " + sunday
try:
thread = reddit.subreddit('Houston').submit(subject, selftext=body)
except Error as error:
print(error)
else:
id = thread.id
print("Succesfully posted thread to https://redd.it/" + id)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment