update reddit comment method and reddit_random func

graphs-n-shit
lza_menace 4 years ago
parent 8f6be97cb7
commit 6abd4912f6

@ -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}")

@ -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

Loading…
Cancel
Save