import praw from suchwow import config, wownero class Reddit(object): def __init__(self): self.reddit = praw.Reddit( 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" def post(self, title, url): try: submission = self.reddit.subreddit(self.subreddit).submit( title=title, url=url, resubmit=False, ) return submission except: return False def comment(self, submission, comment): try: _comment = submission.reply(comment) return _comment except: return False def make_post(post): wallet = wownero.Wallet() title = f"SuchWow #{post.id} - {post.title}" url = url_for('post.uploaded_file', filename=post.image_name) _comment = [ f"Submitter: {post.submitter}\n", f"Timestamp (UTC): {post.timestamp}\n", "\nShow this poster some love by sending WOW to the following address:\n\n", f"{wallet.get_address(account=post.account_index)}" ] comment = "".join(_comment) reddit_post = Reddit().post(title, url) reddit_comment = Reddit().comment(reddit_post, comment) post.reddit_url = reddit_post.url post.save() print(f"Posted #{post.id} to Reddit - {reddit_post.url}") return True