mirror of
https://git.wownero.com/lza_menace/suchwow.git
synced 2024-08-15 01:03:19 +00:00
use a bool to track reddit posts
This commit is contained in:
parent
cda49c8146
commit
94b58f7437
3 changed files with 10 additions and 5 deletions
|
@ -67,7 +67,7 @@ def create_accounts():
|
||||||
@app.cli.command("reddit_recent")
|
@app.cli.command("reddit_recent")
|
||||||
def reddit_recent():
|
def reddit_recent():
|
||||||
# run every 5 mins
|
# run every 5 mins
|
||||||
all_posts = Post.select().order_by(Post.timestamp.desc()).where(Post.reddit_url == None)
|
all_posts = Post.select().order_by(Post.timestamp.desc()).where(Post.to_reddit == False)
|
||||||
for post in all_posts:
|
for post in all_posts:
|
||||||
diff = datetime.now() - post.timestamp
|
diff = datetime.now() - post.timestamp
|
||||||
recent_post = diff < timedelta(hours=2)
|
recent_post = diff < timedelta(hours=2)
|
||||||
|
|
|
@ -17,6 +17,7 @@ class Post(Model):
|
||||||
address_index = IntegerField()
|
address_index = IntegerField()
|
||||||
timestamp = DateTimeField(default=datetime.now)
|
timestamp = DateTimeField(default=datetime.now)
|
||||||
reddit_url = CharField(null=True)
|
reddit_url = CharField(null=True)
|
||||||
|
to_reddit = BooleanField(default=False)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
database = db
|
database = db
|
||||||
|
|
|
@ -46,7 +46,11 @@ def make_post(post):
|
||||||
comment = "".join(_comment)
|
comment = "".join(_comment)
|
||||||
reddit_post = Reddit().post(title, url)
|
reddit_post = Reddit().post(title, url)
|
||||||
reddit_comment = Reddit().comment(reddit_post, comment)
|
reddit_comment = Reddit().comment(reddit_post, comment)
|
||||||
post.reddit_url = reddit_post.url
|
if reddit_post:
|
||||||
|
post.to_reddit = True
|
||||||
post.save()
|
post.save()
|
||||||
print(f"Posted #{post.id} to Reddit - {reddit_post.url}")
|
print(f"Posted #{post.id} to Reddit")
|
||||||
return True
|
return True
|
||||||
|
else:
|
||||||
|
print(f"Unable to post #{post.id} to Reddit")
|
||||||
|
return False
|
||||||
|
|
Loading…
Reference in a new issue