mirror of
https://github.com/Lynnesbian/FediBooks/
synced 2024-11-25 08:38:59 +00:00
handle content warning and post privacy settings
This commit is contained in:
parent
7b5227c3dc
commit
3ebcb589ce
1 changed files with 23 additions and 15 deletions
38
functions.py
38
functions.py
|
@ -43,33 +43,41 @@ 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
|
||||||
bots.credentials_id = (SELECT
|
bots.credentials_id = (SELECT
|
||||||
credentials_id
|
credentials_id
|
||||||
FROM
|
FROM
|
||||||
bots
|
bots
|
||||||
WHERE
|
WHERE
|
||||||
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
|
||||||
|
|
Loading…
Reference in a new issue