post verification and print post link
This commit is contained in:
parent
59241a0ebe
commit
ecbe06b61c
|
@ -9,6 +9,7 @@ def load_config() -> dict:
|
||||||
return config_data
|
return config_data
|
||||||
|
|
||||||
# create Mastodon object using stored API secrets
|
# create Mastodon object using stored API secrets
|
||||||
|
# TODO: load config from $XDG_CONFIG_HOME
|
||||||
def gen_masto_obj(config_data: dict) -> Mastodon:
|
def gen_masto_obj(config_data: dict) -> Mastodon:
|
||||||
m = Mastodon(
|
m = Mastodon(
|
||||||
access_token = config_data['token'],
|
access_token = config_data['token'],
|
||||||
|
@ -24,19 +25,38 @@ def gen_url(config_data: dict, phlog_file: str) -> dict:
|
||||||
urls = {'gopher':gopher_url, 'proxy':proxy_url}
|
urls = {'gopher':gopher_url, 'proxy':proxy_url}
|
||||||
return urls
|
return urls
|
||||||
|
|
||||||
|
# display post contents and verify with the user
|
||||||
|
def post_check(post: str) -> bool:
|
||||||
|
print('You are about to post')
|
||||||
|
print()
|
||||||
|
print(post)
|
||||||
|
print()
|
||||||
|
will_continue = input("Continue? [y/N] ")
|
||||||
|
print()
|
||||||
|
return will_continue.upper() in ['Y', 'YES']
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
# load config.json
|
||||||
# TODO: handle command line switches to override defaults
|
# TODO: handle command line switches to override defaults
|
||||||
config_data = load_config()
|
config_data = load_config()
|
||||||
m = gen_masto_obj(config_data)
|
m = gen_masto_obj(config_data)
|
||||||
|
|
||||||
|
# generate URLs
|
||||||
|
# TODO: prompt for phlog path
|
||||||
phlog_file = 'test.txt'
|
phlog_file = 'test.txt'
|
||||||
urls = gen_url(config_data, phlog_file)
|
urls = gen_url(config_data, phlog_file)
|
||||||
|
|
||||||
|
# get post description, generate post text
|
||||||
# TODO: Spawn $EDITOR, content warnings
|
# TODO: Spawn $EDITOR, content warnings
|
||||||
text = "Test post, please ignore"
|
text = "Test post, please ignore"
|
||||||
post = f"{text}\n\nGopher: {urls['gopher']}\nHTML Proxy: {urls['proxy']}"
|
post = f"{text}\n\nGopher: {urls['gopher']}\nHTML Proxy: {urls['proxy']}"
|
||||||
|
|
||||||
m.status_post(post, visibility=config_data['visibility'])
|
# verify the post with the user and post it
|
||||||
|
if post_check(post):
|
||||||
|
toot_dict = m.status_post(post, visibility=config_data['visibility'])
|
||||||
|
print(f"Posted at {toot_dict['url']}")
|
||||||
|
else:
|
||||||
|
print('Aborted.')
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Reference in New Issue