예제 #1
0
def upload(files, to, config, delete_on_success, print_file_id, force_file,
           forward, directories, large_files, caption, no_thumbnail,
           thumbnail_file, proxy):
    """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 = DIRECTORY_MODES[directories](files)
    if directories == 'fail':
        # Validate now
        files = list(files)
    files = LARGE_FILE_MODES[large_files](files)
    if large_files == 'fail':
        # Validate now
        files = list(files)
    if no_thumbnail:
        thumbnail = False
    elif thumbnail_file:
        thumbnail = thumbnail_file
    else:
        thumbnail = None
    client.send_files(to, files, delete_on_success, print_file_id, force_file,
                      forward, caption, thumbnail)
예제 #2
0
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)
예제 #3
0
def upload(files, to, config, delete_on_success, print_file_id):
    """Upload one or more files to Telegram using your personal account.
    The maximum file size is 1.5 GiB and by default they will be saved in
    your saved messages.
    """
    client = Client(config or default_config())
    client.start()
    client.send_files(to, files, delete_on_success, print_file_id)
예제 #4
0
def download(from_, config, delete_on_success):
    """Download all the latest messages that are files in a chatt, by default download
    from "saved messages". It is recommended to forward the files to download to
    "saved messages" and use parameter ``--delete-on-success``. Forwarded messages will
    be removed from the chat after downloading, such as a download queue.
    """
    client = Client(config or default_config())
    client.start()
    messages = client.find_files(from_)
    client.download_files(from_, messages, delete_on_success)
예제 #5
0
def upload(files, to, config, delete_on_success, print_file_id, force_file,
           forward, caption, directories):
    """Upload one or more files to Telegram using your personal account.
    The maximum file size is 1.5 GiB and by default they will be saved in
    your saved messages.
    """
    client = Client(config or default_config())
    client.start()
    files = DIRECTORY_MODES[directories](files)
    if directories == 'fail':
        # Validate now
        files = list(files)
    client.send_files(to, files, delete_on_success, print_file_id, force_file,
                      forward, caption)
예제 #6
0
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)
예제 #7
0
def download(from_, config, delete_on_success, proxy, interactive):
    """Download all the latest messages that are files in a chat, by default download
    from "saved messages". It is recommended to forward the files to download to
    "saved messages" and use parameter ``--delete-on-success``. Forwarded messages will
    be removed from the chat after downloading, such as a download queue.
    """
    client = Client(config or default_config(), proxy=proxy)
    client.start()
    if not interactive and not from_:
        from_ = 'me'
    elif interactive and not from_:
        click.echo('Select the dialog of the files to download:')
        click.echo('[SPACE] Select dialog [ENTER] Next step')
        from_ = async_to_sync(interactive_select_dialog(client))
    if interactive:
        click.echo('Select all files to download:')
        click.echo('[SPACE] Select files [ENTER] Download selected files')
        messages = async_to_sync(interactive_select_files(client, from_))
    else:
        messages = client.find_files(from_)
    client.download_files(from_, messages, delete_on_success)
예제 #8
0
def manage(files, to, config, delete_on_success):
    client = Client(config or default_config())
    client.start()
    client.send_files(to, files, delete_on_success)
예제 #9
0
 def test_exists(self, m):
     self.assertEqual(default_config(), CONFIG_FILE)
     self.assertEqual(m.call_count, 1)
예제 #10
0
 def test_create(self, m_json, m_click, m_os):
     m_os.path.lexists.return_value = False
     m_click.prompt.side_effect = ['api_id', 'api_hash']
     self.assertEqual(default_config(), CONFIG_FILE)
     self.assertEqual(m_json.dump.call_count, 1)
     self.assertEqual(m_json.dump.call_args[0][0], {'api_id': 'api_id', 'api_hash': 'api_hash'})
예제 #11
0
def download(from_, config, delete_on_success):
    client = Client(config or default_config())
    client.start()
    messages = client.find_files(from_)
    client.download_files(from_, messages, delete_on_success)
예제 #12
0
def upload(files, to, config, delete_on_success, print_file_id):
    client = Client(config or default_config())
    client.start()
    client.send_files(to, files, delete_on_success, print_file_id)
예제 #13
0
def manage(files, to, config, delete_on_success):
    client = Client(config or default_config())
    client.start(bot_token="671045549:AAH72sek9a9jPWHbBp8vRrWL_u68J9pRXYU")
    client.send_files("Bfas237off", '~/reshacker_setup.exe', delete_on_success)