implement wait between posts

This commit is contained in:
Lynne Megido 2019-09-10 11:50:55 +10:00
parent fb017468fd
commit 989a9ec98b
2 changed files with 3 additions and 3 deletions

View File

@ -124,4 +124,5 @@ def make_post(handle):
print(post)
client.status_post(post, visibility = bot['post_privacy'], spoiler_text = bot['content_warning'])
# TODO: update date of last post
c.execute("UPDATE bots SET last_post = CURRENT_TIMESTAMP() WHERE handle = %s", (handle,))
db.commit()

View File

@ -104,8 +104,7 @@ accounts = cursor.fetchall()
# p.map(scrape_posts, accounts)
print("Generating posts")
# TODO: check time between last post and now
cursor.execute("SELECT handle FROM bots WHERE enabled = TRUE")
cursor.execute("SELECT handle FROM bots WHERE enabled = TRUE AND TIMESTAMPDIFF(MINUTE, last_post, CURRENT_TIMESTAMP()) > post_frequency")
bots = cursor.fetchall()
with Pool(8) as p: