mirror of
https://github.com/Lynnesbian/FediBooks/
synced 2024-11-25 08:38:59 +00:00
seperated text generation and posting into their own functions
This commit is contained in:
parent
841098cc18
commit
898f2f7aae
1 changed files with 34 additions and 25 deletions
|
@ -34,13 +34,7 @@ def extract_post(post):
|
||||||
text = text.rstrip("\n") # remove trailing newline(s)
|
text = text.rstrip("\n") # remove trailing newline(s)
|
||||||
return text
|
return text
|
||||||
|
|
||||||
def make_post(args):
|
def generate_output(handle):
|
||||||
id = None
|
|
||||||
acct = None
|
|
||||||
if len(args) > 1:
|
|
||||||
id = args[1]
|
|
||||||
acct = args[3]
|
|
||||||
handle = args[0]
|
|
||||||
db = MySQLdb.connect(
|
db = MySQLdb.connect(
|
||||||
host = cfg['db_host'],
|
host = cfg['db_host'],
|
||||||
user=cfg['db_user'],
|
user=cfg['db_user'],
|
||||||
|
@ -128,6 +122,19 @@ def make_post(args):
|
||||||
# also format handles without instances, e.g. @user instead of @user@instan.ce
|
# also format handles without instances, e.g. @user instead of @user@instan.ce
|
||||||
post = re.sub(r"(?<!\S)@(\w+)", r"@{}\1".format(zws), post)
|
post = re.sub(r"(?<!\S)@(\w+)", r"@{}\1".format(zws), post)
|
||||||
|
|
||||||
|
return post
|
||||||
|
|
||||||
|
|
||||||
|
def make_post(args):
|
||||||
|
id = None
|
||||||
|
acct = None
|
||||||
|
if len(args) > 1:
|
||||||
|
id = args[1]
|
||||||
|
acct = args[3]
|
||||||
|
handle = args[0]
|
||||||
|
|
||||||
|
post = generate_output(handle)
|
||||||
|
|
||||||
# print(post)
|
# print(post)
|
||||||
visibility = bot['post_privacy'] if len(args) == 1 else args[2]
|
visibility = bot['post_privacy'] if len(args) == 1 else args[2]
|
||||||
visibilities = ['public', 'unlisted', 'private']
|
visibilities = ['public', 'unlisted', 'private']
|
||||||
|
@ -141,6 +148,8 @@ def make_post(args):
|
||||||
# TODO: ehhhhhhhhh
|
# TODO: ehhhhhhhhh
|
||||||
post = post[:bot['length']]
|
post = post[:bot['length']]
|
||||||
# send toot!!
|
# send toot!!
|
||||||
|
print(post)
|
||||||
|
return
|
||||||
try:
|
try:
|
||||||
client.status_post(post, id, visibility = visibility, spoiler_text = bot['content_warning'])
|
client.status_post(post, id, visibility = visibility, spoiler_text = bot['content_warning'])
|
||||||
except MastodonUnauthorizedError:
|
except MastodonUnauthorizedError:
|
||||||
|
|
Loading…
Reference in a new issue