def upload(files, to, config, delete_on_success, print_file_id, force_file, forward, directories, large_files, caption, no_thumbnail, thumbnail_file, proxy, album): """Upload one or more files to Telegram using your personal account. The maximum file size is 2 GiB and by default they will be saved in your saved messages. """ client = Client(config or default_config(), proxy=proxy) client.start() files = filter( lambda file: is_valid_file( file, lambda message: click.echo(message, err=True)), files) files = DIRECTORY_MODES[directories](files) if directories == 'fail': # Validate now files = list(files) if no_thumbnail: thumbnail = False elif thumbnail_file: thumbnail = thumbnail_file else: thumbnail = None files_cls = LARGE_FILE_MODES[large_files] files = files_cls(files, caption=caption, thumbnail=thumbnail, force_file=force_file) if large_files == 'fail': # Validate now files = list(files) if album: client.send_files_as_album(to, files, delete_on_success, print_file_id, forward) else: client.send_files(to, files, delete_on_success, print_file_id, forward)
def upload(files, to, config, delete_on_success, print_file_id, force_file, forward, directories, large_files, caption, no_thumbnail, thumbnail_file, proxy, album, interactive): """Upload one or more files to Telegram using your personal account. The maximum file size is 2 GiB and by default they will be saved in your saved messages. """ client = Client(config or default_config(), proxy=proxy) client.start() if interactive and not files: click.echo('Select the local files to upload:') click.echo('[SPACE] Select file [ENTER] Next step') files = async_to_sync(interactive_select_local_files()) if interactive and not files: # No files selected. Exiting. return if interactive and to is None: click.echo('Select the recipient dialog of the files:') click.echo('[SPACE] Select dialog [ENTER] Next step') to = async_to_sync(interactive_select_dialog(client)) elif to is None: to = 'me' files = filter( lambda file: is_valid_file( file, lambda message: click.echo(message, err=True)), files) files = DIRECTORY_MODES[directories](files) if directories == 'fail': # Validate now files = list(files) if no_thumbnail: thumbnail = False elif thumbnail_file: thumbnail = thumbnail_file else: thumbnail = None files_cls = LARGE_FILE_MODES[large_files] files = files_cls(files, caption=caption, thumbnail=thumbnail, force_file=force_file) if large_files == 'fail': # Validate now files = list(files) if album: client.send_files_as_album(to, files, delete_on_success, print_file_id, forward) else: client.send_files(to, files, delete_on_success, print_file_id, forward)