From 989a9ec98ba34e9fce84ee575c096db5b168e782 Mon Sep 17 00:00:00 2001 From: Lynne Date: Tue, 10 Sep 2019 11:50:55 +1000 Subject: [PATCH] implement wait between posts --- functions.py | 3 ++- service.py | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/functions.py b/functions.py index b545a00..6502fe2 100644 --- a/functions.py +++ b/functions.py @@ -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() diff --git a/service.py b/service.py index 42c565f..e3b7ae1 100755 --- a/service.py +++ b/service.py @@ -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: