suchwow/suchwow/reddit.py

32 lines
860 B
Python
Raw Normal View History

2020-10-15 07:14:50 +00:00
import praw
from suchwow import config
class Reddit(object):
def __init__(self):
2020-10-15 07:14:50 +00:00
self.reddit = praw.Reddit(
2020-10-15 07:00:51 +00:00
client_id=config.PRAW_CLIENT_ID,
client_secret=config.PRAW_CLIENT_SECRET,
user_agent=config.PRAW_USER_AGENT,
username=config.PRAW_USERNAME,
password=config.PRAW_PASSWORD
)
self.subreddit = "wownero"
2020-10-15 07:14:50 +00:00
def post(self, title, url):
try:
2020-10-15 07:14:50 +00:00
submission = self.reddit.subreddit(self.subreddit).submit(
title=title,
url=url,
resubmit=False,
)
return submission
except:
return False
2020-10-15 07:14:50 +00:00
def comment(self, submission, post):
try:
submission.reply(f"Show this post love by sending WOW: {post.id}")
except:
return False