From 6abd4912f675b5443fa458b5f717c7dd9fade4af Mon Sep 17 00:00:00 2001 From: lza_menace Date: Thu, 15 Oct 2020 06:45:59 -0700 Subject: [PATCH] update reddit comment method and reddit_random func --- suchwow/app.py | 13 +++++++++++-- suchwow/reddit.py | 5 +++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/suchwow/app.py b/suchwow/app.py index c24dcab..8e7f060 100644 --- a/suchwow/app.py +++ b/suchwow/app.py @@ -83,11 +83,20 @@ def reddit_recent(): @app.cli.command("reddit_random") def reddit_random(): # run every 8 hours + wallet = wownero.Wallet() all_posts = Post.select().where(Post.reddit_url == None) post = choice(all_posts) - title = f"[SuchWow!][{post.submitter}][#{post.id}] {post.title}" - url = url_for("post.read", id=post.id) + title = f"SuchWow #{post.id} - {post.title}" + url = url_for('post.uploaded_file', filename=post.image_name) + _comment = [ + f"'{post.text}'\n\nSubmitter: {post.submitter}\n", + f"Timestamp (UTC): {post.timestamp}\n", + "\nShow this poster some love by sending WOW to the following address: ", + 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}") diff --git a/suchwow/reddit.py b/suchwow/reddit.py index b51b249..eaebc4a 100644 --- a/suchwow/reddit.py +++ b/suchwow/reddit.py @@ -24,8 +24,9 @@ class Reddit(object): except: return False - def comment(self, submission, post): + def comment(self, submission, comment): try: - submission.reply(f"Show this post love by sending WOW: {post.id}") + _comment = submission.reply(comment) + return _comment except: return False