mirror of
https://git.wownero.com/lza_menace/suchwow.git
synced 2024-08-15 01:03:19 +00:00
update reddit comment method and reddit_random func
This commit is contained in:
parent
8f6be97cb7
commit
6abd4912f6
2 changed files with 14 additions and 4 deletions
|
@ -83,11 +83,20 @@ def reddit_recent():
|
||||||
@app.cli.command("reddit_random")
|
@app.cli.command("reddit_random")
|
||||||
def reddit_random():
|
def reddit_random():
|
||||||
# run every 8 hours
|
# run every 8 hours
|
||||||
|
wallet = wownero.Wallet()
|
||||||
all_posts = Post.select().where(Post.reddit_url == None)
|
all_posts = Post.select().where(Post.reddit_url == None)
|
||||||
post = choice(all_posts)
|
post = choice(all_posts)
|
||||||
title = f"[SuchWow!][{post.submitter}][#{post.id}] {post.title}"
|
title = f"SuchWow #{post.id} - {post.title}"
|
||||||
url = url_for("post.read", id=post.id)
|
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_post = Reddit().post(title, url)
|
||||||
|
reddit_comment = Reddit().comment(reddit_post, comment)
|
||||||
post.reddit_url = reddit_post.url
|
post.reddit_url = reddit_post.url
|
||||||
post.save()
|
post.save()
|
||||||
print(f"Posted #{post.id} to Reddit - {reddit_post.url}")
|
print(f"Posted #{post.id} to Reddit - {reddit_post.url}")
|
||||||
|
|
|
@ -24,8 +24,9 @@ class Reddit(object):
|
||||||
except:
|
except:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def comment(self, submission, post):
|
def comment(self, submission, comment):
|
||||||
try:
|
try:
|
||||||
submission.reply(f"Show this post love by sending WOW: {post.id}")
|
_comment = submission.reply(comment)
|
||||||
|
return _comment
|
||||||
except:
|
except:
|
||||||
return False
|
return False
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue