1
0
Fork 0
mirror of https://github.com/Lynnesbian/FediBooks/ synced 2024-11-25 16:48:58 +00:00

handle content warning and post privacy settings

This commit is contained in:
Lynne Megido 2019-09-09 14:08:25 +10:00
parent 7b5227c3dc
commit 3ebcb589ce

View file

@ -43,10 +43,18 @@ def make_post(handle):
db=cfg['db_name'] db=cfg['db_name']
) )
print("Generating post for {}".format(handle)) print("Generating post for {}".format(handle))
dc = db.cursor(MySQLdb.cursors.DictCursor)
c = db.cursor() c = db.cursor()
c.execute(""" dc.execute("""
SELECT SELECT
learn_from_cw, client_id, client_secret, secret learn_from_cw,
fake_mentions,
fake_mentions_full,
post_privacy,
content_warning,
client_id,
client_secret,
secret
FROM FROM
bots, credentials bots, credentials
WHERE WHERE
@ -58,18 +66,18 @@ def make_post(handle):
handle = %s) handle = %s)
""", (handle,)) """, (handle,))
bot = c.fetchone() bot = dc.fetchone()
client = Mastodon( client = Mastodon(
client_id = bot[1], client_id = bot['client_id'],
client_secret = bot[2], client_secret = bot['client_secret'],
access_token = bot[3], access_token = bot['secret'],
api_base_url = "https://{}".format(handle.split("@")[2]) api_base_url = "https://{}".format(handle.split("@")[2])
) )
# by default, only select posts that don't have CWs. # by default, only select posts that don't have CWs.
# if learn_from_cw, then also select posts with CWs # if learn_from_cw, then also select posts with CWs
cw_list = [False] cw_list = [False]
if bot[0]: if bot['learn_from_cw']:
cw_list = [False, True] cw_list = [False, True]
# select 1000 random posts for the bot to learn from # select 1000 random posts for the bot to learn from
@ -97,6 +105,6 @@ def make_post(handle):
# TODO: send an error email # TODO: send an error email
pass pass
else: else:
client.status_post(sentence) client.status_post(sentence, visibility = bot['post_privacy'], spoiler_text = bot['content_warning'])
# TODO: update date of last post # TODO: update date of last post