mirror of
https://github.com/ihabunek/toot
synced 2025-01-10 16:52:40 +01: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 typing import BinaryIO, Optional, Tuple
|
||||
|
||||
from toot import api
|
||||
from toot.cli import cli, json_option, pass_context, Context
|
||||
from toot import api, config
|
||||
from toot.cli import AccountParamType, cli, json_option, pass_context, Context
|
||||
from toot.cli import DURATION_EXAMPLES, VISIBILITY_CHOICES
|
||||
from toot.cli.validators import validate_duration, validate_language
|
||||
from toot.entities import MediaAttachment, from_dict
|
||||
@ -106,6 +106,11 @@ from toot.utils.datetime import parse_datetime
|
||||
is_flag=True,
|
||||
default=False,
|
||||
)
|
||||
@click.option(
|
||||
"-u", "--using",
|
||||
type=AccountParamType(),
|
||||
help="The account to use, overrides the active account.",
|
||||
)
|
||||
@json_option
|
||||
@pass_context
|
||||
def post(
|
||||
@ -127,12 +132,20 @@ def post(
|
||||
poll_expires_in: int,
|
||||
poll_multiple: bool,
|
||||
poll_hide_totals: bool,
|
||||
json: bool
|
||||
json: bool,
|
||||
using: str
|
||||
):
|
||||
"""Post a new status"""
|
||||
if len(media) > 4:
|
||||
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)
|
||||
status_text = _get_status_text(text, editor, media)
|
||||
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.")
|
||||
|
||||
response = api.post_status(
|
||||
ctx.app,
|
||||
ctx.user,
|
||||
app,
|
||||
user,
|
||||
status_text,
|
||||
visibility=visibility,
|
||||
media_ids=media_ids,
|
||||
|
Loading…
Reference in New Issue
Block a user