From 44c7e24a53cd8b682fe58f6a789b43ff7a6f5fba Mon Sep 17 00:00:00 2001 From: Lynne Date: Sat, 7 Sep 2019 13:31:11 +1000 Subject: [PATCH] initial work on bot posting --- service.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/service.py b/service.py index 96e6e23..346c42e 100755 --- a/service.py +++ b/service.py @@ -84,6 +84,9 @@ def scrape_posts(account): c.close() print("Finished {}".format(handle)) +def make_post(bot): + pass + print("Establishing DB connection") db = MySQLdb.connect( host = cfg['db_host'], @@ -93,12 +96,26 @@ db = MySQLdb.connect( ) print("Downloading posts") - cursor = db.cursor() cursor.execute("SELECT `handle`, `outbox` FROM `fedi_accounts` ORDER BY RAND()") accounts = cursor.fetchall() -cursor.close() with Pool(8) as p: p.map(scrape_posts, accounts) +print("Generating posts") +cursor.execute(""" +SELECT + bots.handle, credentials.client_id, credentials.client_secret, credentials.secret +FROM + bots, + credentials +WHERE + bots.credentials_id = credentials.id + AND bots.enabled = TRUE; +""") +bots = cursor.fetchall() + +with Pool(8) as p: + p.map(make_post, bots) + #TODO: other cron tasks should be done here, like updating profile pictures