1
0
mirror of https://github.com/ihabunek/toot.git synced 2024-11-03 04:17:21 -05:00

Add option for scheduling tweets

This commit is contained in:
Ivan Habunek 2021-01-17 12:42:08 +01:00
parent 0fd1d7d8b8
commit 7e0da50603
No known key found for this signature in database
GPG Key ID: CDBD63C43A30BB95
4 changed files with 17 additions and 1 deletions

View File

@ -1,3 +1,8 @@
0.28.0:
date: TBA
changes:
- "Add `--scheduled-at` option to `toot post`, allows scheduling toots"
0.27.0: 0.27.0:
date: 2020-06-15 date: 2020-06-15
changes: changes:

View File

@ -92,6 +92,7 @@ def post_status(
spoiler_text=None, spoiler_text=None,
in_reply_to_id=None, in_reply_to_id=None,
language=None, language=None,
scheduled_at=None,
): ):
""" """
Posts a new status. Posts a new status.
@ -110,6 +111,7 @@ def post_status(
'spoiler_text': spoiler_text, 'spoiler_text': spoiler_text,
'in_reply_to_id': in_reply_to_id, 'in_reply_to_id': in_reply_to_id,
'language': language, 'language': language,
'scheduled_at': scheduled_at
}, headers=headers).json() }, headers=headers).json()

View File

@ -114,8 +114,12 @@ def post(app, user, args):
spoiler_text=args.spoiler_text, spoiler_text=args.spoiler_text,
in_reply_to_id=args.reply_to, in_reply_to_id=args.reply_to,
language=args.language, language=args.language,
scheduled_at=args.scheduled_at,
) )
if "scheduled_at" in response:
print_out("Toot scheduled for: <green>{}</green>".format(response["scheduled_at"]))
else:
print_out("Toot posted: <green>{}</green>".format(response.get('url'))) print_out("Toot posted: <green>{}</green>".format(response.get('url')))

View File

@ -326,6 +326,11 @@ POST_COMMANDS = [
"help": "Specify an editor to compose your toot, " "help": "Specify an editor to compose your toot, "
"defaults to editor defined in $EDITOR env variable.", "defaults to editor defined in $EDITOR env variable.",
}), }),
(["--scheduled-at"], {
"type": str,
"help": "ISO 8601 Datetime at which to schedule a status. Must "
"be at least 5 minutes in the future.",
}),
], ],
require_auth=True, require_auth=True,
), ),