mirror of
https://github.com/ihabunek/toot.git
synced 2024-09-29 04:35:54 -04:00
Reinstate toot post --using option
This commit is contained in:
parent
2e2945822a
commit
11aaa1dc29
@ -6,8 +6,8 @@ from datetime import datetime, timedelta, timezone
|
|||||||
from time import sleep, time
|
from time import sleep, time
|
||||||
from typing import BinaryIO, Optional, Tuple
|
from typing import BinaryIO, Optional, Tuple
|
||||||
|
|
||||||
from toot import api
|
from toot import api, config
|
||||||
from toot.cli import cli, json_option, pass_context, Context
|
from toot.cli import AccountParamType, cli, json_option, pass_context, Context
|
||||||
from toot.cli import DURATION_EXAMPLES, VISIBILITY_CHOICES
|
from toot.cli import DURATION_EXAMPLES, VISIBILITY_CHOICES
|
||||||
from toot.cli.validators import validate_duration, validate_language
|
from toot.cli.validators import validate_duration, validate_language
|
||||||
from toot.entities import MediaAttachment, from_dict
|
from toot.entities import MediaAttachment, from_dict
|
||||||
@ -106,6 +106,11 @@ from toot.utils.datetime import parse_datetime
|
|||||||
is_flag=True,
|
is_flag=True,
|
||||||
default=False,
|
default=False,
|
||||||
)
|
)
|
||||||
|
@click.option(
|
||||||
|
"-u", "--using",
|
||||||
|
type=AccountParamType(),
|
||||||
|
help="The account to use, overrides the active account.",
|
||||||
|
)
|
||||||
@json_option
|
@json_option
|
||||||
@pass_context
|
@pass_context
|
||||||
def post(
|
def post(
|
||||||
@ -127,12 +132,20 @@ def post(
|
|||||||
poll_expires_in: int,
|
poll_expires_in: int,
|
||||||
poll_multiple: bool,
|
poll_multiple: bool,
|
||||||
poll_hide_totals: bool,
|
poll_hide_totals: bool,
|
||||||
json: bool
|
json: bool,
|
||||||
|
using: str
|
||||||
):
|
):
|
||||||
"""Post a new status"""
|
"""Post a new status"""
|
||||||
if len(media) > 4:
|
if len(media) > 4:
|
||||||
raise click.ClickException("Cannot attach more than 4 files.")
|
raise click.ClickException("Cannot attach more than 4 files.")
|
||||||
|
|
||||||
|
if using:
|
||||||
|
user, app = config.get_user_app(using)
|
||||||
|
if not user or not app:
|
||||||
|
raise click.ClickException(f"Account '{using}' not found. Run `toot auth` to see available accounts.")
|
||||||
|
else:
|
||||||
|
user, app = ctx.user, ctx.app
|
||||||
|
|
||||||
media_ids = _upload_media(ctx.app, ctx.user, media, descriptions, thumbnails)
|
media_ids = _upload_media(ctx.app, ctx.user, media, descriptions, thumbnails)
|
||||||
status_text = _get_status_text(text, editor, media)
|
status_text = _get_status_text(text, editor, media)
|
||||||
scheduled_at = _get_scheduled_at(scheduled_at, scheduled_in)
|
scheduled_at = _get_scheduled_at(scheduled_at, scheduled_in)
|
||||||
@ -141,8 +154,8 @@ def post(
|
|||||||
raise click.ClickException("You must specify either text or media to post.")
|
raise click.ClickException("You must specify either text or media to post.")
|
||||||
|
|
||||||
response = api.post_status(
|
response = api.post_status(
|
||||||
ctx.app,
|
app,
|
||||||
ctx.user,
|
user,
|
||||||
status_text,
|
status_text,
|
||||||
visibility=visibility,
|
visibility=visibility,
|
||||||
media_ids=media_ids,
|
media_ids=media_ids,
|
||||||
|
Loading…
Reference in New Issue
Block a user