mirror of
https://github.com/Lynnesbian/FediBooks/
synced 2024-11-25 08:38:59 +00:00
handle replies properly, including mentions and privacy
This commit is contained in:
parent
630ab4c34e
commit
83ceb83e72
2 changed files with 15 additions and 5 deletions
16
functions.py
16
functions.py
|
@ -36,8 +36,10 @@ def extract_post(post):
|
|||
|
||||
def make_post(args):
|
||||
id = None
|
||||
if len(args) == 2:
|
||||
acct = None
|
||||
if len(args) > 1:
|
||||
id = args[1]
|
||||
acct = args[3]
|
||||
handle = args[0]
|
||||
db = MySQLdb.connect(
|
||||
host = cfg['db_host'],
|
||||
|
@ -51,6 +53,7 @@ def make_post(args):
|
|||
dc.execute("""
|
||||
SELECT
|
||||
learn_from_cw,
|
||||
length,
|
||||
fake_mentions,
|
||||
fake_mentions_full,
|
||||
post_privacy,
|
||||
|
@ -104,7 +107,7 @@ def make_post(args):
|
|||
posts = re.sub(r"@(\w+)@([\w.]+)\s?", "", posts)
|
||||
|
||||
while post is None and tries < 10:
|
||||
post = model.make_short_sentence(500, tries = 10000)
|
||||
post = model.make_short_sentence(bot['length'], tries = 10000)
|
||||
tries += 1
|
||||
|
||||
if post == None:
|
||||
|
@ -125,7 +128,14 @@ def make_post(args):
|
|||
post = re.sub(r"@(\w+)@([\w.]+)", r"@{}\1".format(zws), post)
|
||||
|
||||
print(post)
|
||||
client.status_post(post, id, visibility = bot['post_privacy'], spoiler_text = bot['content_warning'])
|
||||
visibility = bot['post_privacy'] if len(args) == 1 else args[2]
|
||||
if acct is not None:
|
||||
post = "{} {}".format(acct, post)
|
||||
|
||||
# ensure post isn't longer than bot['length']
|
||||
post = post[:bot['length']]
|
||||
# send toot!!
|
||||
client.status_post(post, id, visibility = visibility, spoiler_text = bot['content_warning'])
|
||||
|
||||
if id == None:
|
||||
# this wasn't a reply, it was a regular post, so update the last post date
|
||||
|
|
2
webui.py
2
webui.py
|
@ -532,7 +532,7 @@ def push(id):
|
|||
# assume we haven't been participating in this thread
|
||||
pass
|
||||
|
||||
functions.make_post([id, notification['status']['id']])
|
||||
functions.make_post([id, notification['status']['id'], notification['status']['visibility'], "@" + notification['account']['acct']])
|
||||
|
||||
return "Success!"
|
||||
|
||||
|
|
Loading…
Reference in a new issue