├── cli ├── version.py ├── commands │ ├── help │ │ ├── __init__.py │ │ └── help.py │ ├── cli │ │ ├── __init__.py │ │ ├── info.py │ │ └── init.py │ ├── chat │ │ ├── __init__.py │ │ ├── info.py │ │ └── open.py │ ├── dir │ │ ├── __init__.py │ │ ├── list.py │ │ ├── forward.py │ │ └── share.py │ ├── logfile │ │ ├── __init__.py │ │ ├── wipe.py │ │ ├── size.py │ │ ├── open.py │ │ └── send.py │ ├── hidden │ │ ├── __init__.py │ │ ├── phrase_gen.py │ │ ├── sk_gen.py │ │ ├── concat.py │ │ └── python_.py │ ├── account │ │ ├── __init__.py │ │ ├── switch.py │ │ ├── info.py │ │ ├── list.py │ │ ├── disconnect.py │ │ └── connect.py │ ├── errors.py │ ├── file │ │ ├── __init__.py │ │ ├── last_id.py │ │ ├── share.py │ │ ├── import_.py │ │ ├── open.py │ │ ├── forward.py │ │ ├── attr_edit.py │ │ ├── remove.py │ │ ├── search.py │ │ └── download.py │ ├── __init__.py │ ├── box │ │ ├── __init__.py │ │ ├── close.py │ │ ├── default.py │ │ ├── share.py │ │ ├── switch.py │ │ ├── account_change.py │ │ ├── request.py │ │ ├── delete.py │ │ ├── open.py │ │ ├── sync.py │ │ ├── make.py │ │ ├── clone.py │ │ ├── list.py │ │ └── info.py │ ├── helpers.py │ └── group.py ├── data │ └── logo.ico ├── __init__.py ├── tools │ ├── __init__.py │ ├── strings.py │ ├── session.py │ ├── convert.py │ ├── terminal.py │ └── other.py └── config.py ├── MANIFEST.in ├── pyinstaller ├── depends │ └── ansicon │ │ ├── ANSI32.dll │ │ └── ANSI64.dll ├── .tgbox_cli_wrapper.py └── tgbox_cli.spec ├── LICENSE ├── setup.py ├── main.py ├── .gitignore └── README.md /cli/version.py: -------------------------------------------------------------------------------- 1 | VERSION = '1.6.0b0' 2 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | recursive-include cli/data * 2 | -------------------------------------------------------------------------------- /cli/commands/help/__init__.py: -------------------------------------------------------------------------------- 1 | from . import help as help_ 2 | -------------------------------------------------------------------------------- /cli/commands/cli/__init__.py: -------------------------------------------------------------------------------- 1 | from . import init 2 | from . import info 3 | -------------------------------------------------------------------------------- /cli/commands/chat/__init__.py: -------------------------------------------------------------------------------- 1 | from . import open as open_ 2 | from . import info 3 | -------------------------------------------------------------------------------- /cli/data/logo.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NotStatilko/tgbox-cli/HEAD/cli/data/logo.ico -------------------------------------------------------------------------------- /cli/commands/dir/__init__.py: -------------------------------------------------------------------------------- 1 | from . import list as list_ 2 | from . import forward 3 | from . import share 4 | -------------------------------------------------------------------------------- /cli/__init__.py: -------------------------------------------------------------------------------- 1 | from . import config 2 | from . import version 3 | 4 | from . import tools 5 | from . import commands 6 | -------------------------------------------------------------------------------- /cli/commands/logfile/__init__.py: -------------------------------------------------------------------------------- 1 | from . import open as open_ 2 | from . import wipe 3 | from . import size 4 | from . import send 5 | -------------------------------------------------------------------------------- /pyinstaller/depends/ansicon/ANSI32.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NotStatilko/tgbox-cli/HEAD/pyinstaller/depends/ansicon/ANSI32.dll -------------------------------------------------------------------------------- /pyinstaller/depends/ansicon/ANSI64.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NotStatilko/tgbox-cli/HEAD/pyinstaller/depends/ansicon/ANSI64.dll -------------------------------------------------------------------------------- /cli/commands/hidden/__init__.py: -------------------------------------------------------------------------------- 1 | from . import phrase_gen 2 | from . import python_ 3 | from . import sk_gen 4 | from . import concat 5 | -------------------------------------------------------------------------------- /cli/tools/__init__.py: -------------------------------------------------------------------------------- 1 | from . import convert 2 | from . import other 3 | from . import terminal 4 | from . import session 5 | from . import strings 6 | -------------------------------------------------------------------------------- /cli/commands/account/__init__.py: -------------------------------------------------------------------------------- 1 | from . import connect 2 | from . import disconnect 3 | from . import list as list_ 4 | from . import info 5 | from . import switch 6 | -------------------------------------------------------------------------------- /cli/commands/errors.py: -------------------------------------------------------------------------------- 1 | """Module with Exception classes""" 2 | 3 | import click 4 | 5 | class CheckCTXFailed(click.exceptions.ClickException): 6 | """Will be raised if check_ctx found unsupported requirement""" 7 | -------------------------------------------------------------------------------- /pyinstaller/.tgbox_cli_wrapper.py: -------------------------------------------------------------------------------- 1 | from pathlib import Path 2 | from sys import path as sys_path 3 | 4 | sys_path = [str(Path(__name__).parent.parent)] 5 | from main import safe_tgbox_cli_startup 6 | 7 | if __name__ == '__main__': 8 | safe_tgbox_cli_startup() 9 | -------------------------------------------------------------------------------- /cli/commands/file/__init__.py: -------------------------------------------------------------------------------- 1 | from . import upload 2 | from . import search 3 | from . import download 4 | from . import open as open_ 5 | from . import attr_edit 6 | from . import remove 7 | from . import forward 8 | from . import import_ 9 | from . import share 10 | from . import last_id 11 | -------------------------------------------------------------------------------- /cli/commands/__init__.py: -------------------------------------------------------------------------------- 1 | from . import errors 2 | from . import group 3 | from . import helpers 4 | 5 | from . import cli 6 | from . import account 7 | from . import box 8 | from . import file 9 | from . import dir as dir_ 10 | from . import chat 11 | from . import logfile 12 | from . import help as help_ 13 | 14 | from . import hidden 15 | -------------------------------------------------------------------------------- /cli/commands/box/__init__.py: -------------------------------------------------------------------------------- 1 | from . import make 2 | from . import open as open_ 3 | from . import close 4 | from . import switch 5 | from . import list as list_ 6 | from . import sync 7 | from . import account_change 8 | from . import request 9 | from . import share 10 | from . import clone 11 | from . import default 12 | from . import info 13 | from . import delete 14 | -------------------------------------------------------------------------------- /cli/commands/logfile/wipe.py: -------------------------------------------------------------------------------- 1 | from ..group import cli_group 2 | from ...tools.terminal import echo 3 | from ...config import LOGFILE 4 | 5 | 6 | @cli_group.command() 7 | def logfile_wipe(): 8 | """Clear all logfile entries""" 9 | if not LOGFILE: 10 | echo('[R0b]Can not clean Logfile[X]') 11 | return 12 | open(LOGFILE,'w',encoding='utf-8').close() 13 | echo('[G0b]Done.[X]') 14 | -------------------------------------------------------------------------------- /cli/commands/hidden/phrase_gen.py: -------------------------------------------------------------------------------- 1 | import click 2 | 3 | from ..group import cli_group 4 | from ...tools.terminal import echo 5 | from ...config import tgbox 6 | 7 | 8 | @cli_group.command(hidden=True) 9 | @click.option( 10 | '--words', '-w', default=6, 11 | help='Words amount in Phrase' 12 | ) 13 | def phrase_gen(words): 14 | """Generate random Phrase""" 15 | echo(f'[M0b]{tgbox.keys.Phrase.generate(words)}[X]') 16 | -------------------------------------------------------------------------------- /cli/commands/logfile/size.py: -------------------------------------------------------------------------------- 1 | from ..group import cli_group 2 | from ...tools.convert import format_bytes 3 | from ...tools.terminal import echo 4 | from ...config import LOGFILE 5 | 6 | 7 | @cli_group.command() 8 | def logfile_size(): 9 | """Get bytesize of logfile""" 10 | if not LOGFILE: 11 | echo('[R0b]We can not calculate the size of Logfile[X]') 12 | return 13 | 14 | size = format_bytes(LOGFILE.stat().st_size) 15 | echo(f'[W0b]{str(LOGFILE)}[X]: {size}') 16 | -------------------------------------------------------------------------------- /cli/commands/hidden/sk_gen.py: -------------------------------------------------------------------------------- 1 | import click 2 | 3 | from base64 import urlsafe_b64encode 4 | 5 | from ..group import cli_group 6 | from ...tools.terminal import echo 7 | from ...config import tgbox 8 | 9 | 10 | @cli_group.command(hidden=True) 11 | @click.option( 12 | '--size', '-s', default=32, 13 | help='SessionKey bytesize' 14 | ) 15 | def sk_gen(size: int): 16 | """Generate random urlsafe b64encoded SessionKey""" 17 | echo(urlsafe_b64encode(tgbox.crypto.get_rnd_bytes(size)).decode()) 18 | -------------------------------------------------------------------------------- /cli/commands/logfile/open.py: -------------------------------------------------------------------------------- 1 | import click 2 | 3 | from ..group import cli_group 4 | from ...config import LOGFILE 5 | from ...tools.terminal import echo 6 | 7 | 8 | @cli_group.command() 9 | @click.option( 10 | '--locate', '-l', is_flag=True, 11 | help='If specified, will open file path in file manager' 12 | ) 13 | def logfile_open(locate): 14 | """Open logfile with default app""" 15 | if LOGFILE: 16 | click.launch(str(LOGFILE), locate=locate) 17 | else: 18 | echo('[R0b]Can not open Logfile[X]') 19 | -------------------------------------------------------------------------------- /cli/commands/help/help.py: -------------------------------------------------------------------------------- 1 | import click 2 | 3 | from ..group import cli_group 4 | from ...tools.terminal import echo, colorize 5 | from ...config import PACKAGE, TGBOX_CLI_NOCOLOR 6 | 7 | 8 | @cli_group.command(name='help') 9 | @click.option( 10 | '--non-interactive', '-n', is_flag=True, 11 | help='If specified, will echo to shell instead of pager' 12 | ) 13 | def help_(non_interactive): 14 | """Write this command for extended Help!""" 15 | 16 | help_path = PACKAGE / 'data' / 'help.txt' 17 | help_text = open(help_path, encoding='utf-8').read() 18 | 19 | if non_interactive: 20 | echo(help_text) 21 | else: 22 | colored = False if TGBOX_CLI_NOCOLOR else None 23 | click.echo_via_pager(colorize(help_text), color=colored) 24 | -------------------------------------------------------------------------------- /cli/commands/file/last_id.py: -------------------------------------------------------------------------------- 1 | import click 2 | 3 | from ..group import cli_group 4 | from ..helpers import check_ctx 5 | from ...tools.terminal import echo 6 | from ...config import tgbox 7 | 8 | 9 | @cli_group.command() 10 | @click.option( 11 | '--remote','-r', is_flag=True, 12 | help='If specified, will return ID of last file on RemoteBox' 13 | ) 14 | @click.pass_context 15 | def file_last_id(ctx, remote): 16 | """Return ID of last uploaded to Box file""" 17 | 18 | check_ctx(ctx, dlb=True, drb=remote) 19 | 20 | if remote: 21 | lfid = tgbox.sync(ctx.obj.drb.get_last_file_id()) 22 | echo(f'ID of last uploaded to [W0b]RemoteBox[X] file is [Y0b]{lfid}[X]') 23 | else: 24 | lfid = tgbox.sync(ctx.obj.dlb.get_last_file_id()) 25 | echo(f'ID of last saved to [W0b]LocalBox[X] file is [Y0b]{lfid}[X]') 26 | -------------------------------------------------------------------------------- /cli/commands/box/close.py: -------------------------------------------------------------------------------- 1 | import click 2 | 3 | from ..group import cli_group 4 | from ..helpers import ctx_require 5 | from ...tools.terminal import echo 6 | 7 | 8 | @cli_group.command() 9 | @click.option( 10 | '--number', '-n', required=True, type=int, 11 | help='Number of other connected box, use box-list command' 12 | ) 13 | @ctx_require(dlb=True) 14 | def box_close(ctx, number): 15 | """Disconnect selected LocalBox from Session""" 16 | 17 | if number < 1 or number > len(ctx.obj.session['BOX_LIST']): 18 | echo('[R0b]Invalid number, see box-list[X]') 19 | else: 20 | ctx.obj.session['BOX_LIST'].pop(number-1) 21 | 22 | if not ctx.obj.session['BOX_LIST']: 23 | ctx.obj.session['CURRENT_BOX'] = None 24 | echo('No more Boxes, use [W0b]box-open[X].') 25 | else: 26 | ctx.obj.session['CURRENT_BOX'] = 0 27 | echo('[G0b]Disconnected & switched to the Box #1[X]') 28 | 29 | ctx.obj.session.commit() 30 | -------------------------------------------------------------------------------- /cli/commands/box/default.py: -------------------------------------------------------------------------------- 1 | import click 2 | 3 | from ..group import cli_group 4 | from ..helpers import ctx_require 5 | from ...tools.terminal import echo 6 | from ...config import tgbox 7 | 8 | 9 | @cli_group.command() 10 | @click.argument('defaults',nargs=-1) 11 | @ctx_require(dlb=True) 12 | def box_default(ctx, defaults): 13 | """Change the TGBOX default values to your own 14 | 15 | \b 16 | E.g:\b 17 | # Change METADATA_MAX to the max allowed size 18 | tgbox-cli box-default FAST_SYNC_ENABLED=1 19 | \b 20 | # Change download path from DownloadsTGBOX to Downloads 21 | tgbox-cli box-default DOWNLOAD_PATH=Downloads 22 | """ 23 | for default in defaults: 24 | try: 25 | key, value = default.split('=',1) 26 | tgbox.sync(ctx.obj.dlb.defaults.change(key, value)) 27 | echo(f'[G0b]Successfully changed {key} to {value}[X]') 28 | except AttributeError: 29 | echo(f'[R0b]Default {key} doesn\'t exist, skipping[X]') 30 | -------------------------------------------------------------------------------- /cli/commands/box/share.py: -------------------------------------------------------------------------------- 1 | import click 2 | 3 | from ..group import cli_group 4 | from ...tools.terminal import echo 5 | from ..helpers import ctx_require 6 | from ...config import tgbox 7 | 8 | 9 | @cli_group.command() 10 | @click.option( 11 | '--requestkey', '-r', 12 | help='Requester\'s RequestKey, by box-request command' 13 | ) 14 | @ctx_require(dlb=True) 15 | def box_share(ctx, requestkey): 16 | """Command to make ShareKey & to share Box""" 17 | 18 | requestkey = requestkey if not requestkey\ 19 | else tgbox.keys.Key.decode(requestkey) 20 | 21 | sharekey = ctx.obj.dlb.get_sharekey(requestkey) 22 | 23 | if not requestkey: 24 | echo( 25 | '\n[R0b]You didn\'t specified requestkey.\n You ' 26 | 'will receive decryption key IN PLAIN\n[X]' 27 | ) 28 | if not click.confirm('Are you TOTALLY sure?'): 29 | return 30 | echo( 31 | '\nSend this Key to the Box requester:\n' 32 | f' [W0b]{sharekey.encode()}[X]\n' 33 | ) 34 | -------------------------------------------------------------------------------- /cli/commands/box/switch.py: -------------------------------------------------------------------------------- 1 | import click 2 | 3 | from ..group import cli_group 4 | from ...tools.terminal import echo 5 | from ..helpers import ctx_require 6 | 7 | @cli_group.command() 8 | @click.option( 9 | '--number', '-n', required=True, type=int, 10 | help='Number of other connected box, use box-list command' 11 | ) 12 | @ctx_require(dlb=True) 13 | def box_switch(ctx, number): 14 | """Set as main your another connected Box""" 15 | 16 | if number < 1 or number > len(ctx.obj.session['BOX_LIST']): 17 | echo( 18 | f'[R0b]There is no box #{number}. Use[X] ' 19 | '[W0b]box-list[X] [R0b]command.[X]' 20 | ) 21 | elif number-1 == ctx.obj.session['CURRENT_BOX']: 22 | echo( 23 | '[Y0b]You already use this box. See other with[X] ' 24 | '[W0b]box-list[X] [Y0b]command.[X]' 25 | ) 26 | else: 27 | ctx.obj.session['CURRENT_BOX'] = number - 1 28 | ctx.obj.session.commit() 29 | 30 | echo(f'[G0b]You switched to box #{number}[X]') 31 | -------------------------------------------------------------------------------- /cli/commands/logfile/send.py: -------------------------------------------------------------------------------- 1 | import click 2 | 3 | from ..group import cli_group 4 | from ..helpers import ctx_require 5 | from ...tools.terminal import echo 6 | from ...config import tgbox, LOGFILE 7 | 8 | 9 | @cli_group.command() 10 | @click.argument('chat', nargs=-1) 11 | @ctx_require(account=True) 12 | def logfile_send(ctx, chat): 13 | """ 14 | Send logfile to Telegram chat 15 | 16 | \b 17 | Example:\b 18 | tgbox-cli logfile-send @username 19 | """ 20 | if not LOGFILE: 21 | echo('[R0b]Logfile is impossible to send[X]') 22 | return 23 | 24 | if not chat: 25 | echo( 26 | '[Y0b]You didn\'t specified any chat! Try' 27 | '[X] [W0b]tgbox-cli logfile-send me[X]') 28 | return 29 | 30 | if not LOGFILE.stat().st_size: 31 | echo(f'[Y0b]Logfile "{LOGFILE.name}" is empty, so not sent.[X]') 32 | return 33 | 34 | for e in chat: 35 | tgbox.sync(ctx.obj.account.send_file(e, LOGFILE)) 36 | echo(f'[W0b]Logfile has been sent to[X] [B0b]{e}[X]') 37 | -------------------------------------------------------------------------------- /cli/commands/dir/list.py: -------------------------------------------------------------------------------- 1 | import click 2 | 3 | from ..group import cli_group 4 | from ..helpers import ctx_require 5 | from ...tools.terminal import echo 6 | from ...tools.other import sync_async_gen 7 | from ...config import tgbox 8 | 9 | 10 | @cli_group.command() 11 | @click.option( 12 | '--cleanup','-c', is_flag=True, 13 | help='If specified, will remove ALL orphaned folders' 14 | ) 15 | @click.option( 16 | '--show-box-chat','-s', is_flag=True, 17 | help='If specified, will show Box Chat dirs (if any)' 18 | ) 19 | @ctx_require(dlb=True) 20 | def dir_list(ctx, cleanup, show_box_chat): 21 | """List all directories in LocalBox""" 22 | 23 | if cleanup: 24 | echo('\n[W0b]@ Cleanup in process, please wait...[X]') 25 | tgbox.sync(ctx.obj.dlb.remove_empty_directories()) 26 | echo('[G0b]Done.[X]\n') 27 | 28 | dirs = ctx.obj.dlb.contents(ignore_files=True) 29 | 30 | for dir in sync_async_gen(dirs): 31 | tgbox.sync(dir.lload(full=True)) 32 | 33 | if str(dir.parts[0]) == '__BOX_CHAT__' and not show_box_chat: 34 | continue 35 | 36 | echo(str(dir)) 37 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Non 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /cli/commands/dir/forward.py: -------------------------------------------------------------------------------- 1 | import click 2 | 3 | from ..group import cli_group 4 | from ..helpers import ctx_require 5 | from ..file.forward import file_forward 6 | from ...tools.terminal import echo 7 | from ...config import tgbox 8 | 9 | 10 | @cli_group.command() 11 | @click.option( 12 | '--directory', '-d', required=True, prompt=True, 13 | help='Absolute path of Directory to forward' 14 | ) 15 | @click.option( 16 | '--chat', '-c', required=True, prompt=True, 17 | help='Chat to send file to' 18 | ) 19 | @click.option( 20 | '--chat-is-name', is_flag=True, 21 | help='Interpret --chat as Chat name and search for it' 22 | ) 23 | @ctx_require(dlb=True, drb=True, account=True) 24 | def dir_forward(ctx, directory, chat, chat_is_name): 25 | """ 26 | Forward files from dir to specified chat 27 | """ 28 | dlbd = tgbox.sync(ctx.obj.dlb.get_directory(directory.strip())) 29 | 30 | if not dlbd: 31 | echo(f'[R0b]There is no dir "{directory}" in LocalBox.[X]') 32 | else: 33 | filters = [f'scope={directory}', 'non_recursive_scope=True'] 34 | ctx.invoke(file_forward, filters=filters, chat=chat, chat_is_name=chat_is_name) 35 | -------------------------------------------------------------------------------- /cli/commands/account/switch.py: -------------------------------------------------------------------------------- 1 | import click 2 | 3 | from ..group import cli_group 4 | from ..helpers import ctx_require 5 | from ...tools.terminal import echo 6 | 7 | 8 | @cli_group.command() 9 | @click.option( 10 | '--number', '-n', required=True, type=int, 11 | help='Number of other connected account, use account-list command' 12 | ) 13 | @ctx_require(session=True) 14 | def account_switch(ctx, number): 15 | """Set as main your another connected Account""" 16 | 17 | if ctx.obj.session['CURRENT_ACCOUNT'] is None: 18 | echo( 19 | '[R0b]You didn\'t connected any account yet. Use[X] ' 20 | '[W0b]account-connect[X] [R0b]command firstly.[X]' 21 | ) 22 | elif number < 1 or number > len(ctx.obj.session['ACCOUNT_LIST']): 23 | echo( 24 | f'[R0b]There is no account #{number}. Use [X]' 25 | '[W0b]account-list[X] [R0b]command.[X]' 26 | ) 27 | elif number-1 == ctx.obj.session['CURRENT_ACCOUNT']: 28 | echo( 29 | '[Y0b]You already on this account. See other with[X] ' 30 | '[W0b]account-list[X] [Y0b]command.[X]') 31 | else: 32 | ctx.obj.session['CURRENT_ACCOUNT'] = number - 1 33 | ctx.obj.session.commit() 34 | 35 | echo(f'[G0b]You switched to account #{number}[X]') 36 | -------------------------------------------------------------------------------- /cli/commands/file/share.py: -------------------------------------------------------------------------------- 1 | import click 2 | 3 | from ..group import cli_group 4 | from ..helpers import ctx_require 5 | from ...tools.terminal import echo 6 | from ...config import tgbox 7 | 8 | 9 | @cli_group.command() 10 | @click.option( 11 | '--requestkey', '-r', 12 | help='Requester\'s RequestKey' 13 | ) 14 | @click.option( 15 | '--id', required=True, type=int, 16 | help='ID of file to share' 17 | ) 18 | @ctx_require(dlb=True) 19 | def file_share(ctx, requestkey, id): 20 | """Get a ShareKey from RequestKey to share file""" 21 | 22 | dlbf = tgbox.sync(ctx.obj.dlb.get_file(id=id)) 23 | 24 | if not dlbf: 25 | echo(f'[R0b]There is no file in LocalBox by ID {id}[X]') 26 | else: 27 | requestkey = requestkey if not requestkey\ 28 | else tgbox.keys.Key.decode(requestkey) 29 | 30 | sharekey = dlbf.get_sharekey(requestkey) 31 | 32 | if not requestkey: 33 | echo( 34 | '\n[R0b]You didn\'t specified requestkey.\n You ' 35 | 'will receive decryption key IN PLAIN[X]\n' 36 | ) 37 | if not click.confirm('Are you TOTALLY sure?'): 38 | return 39 | echo( 40 | '\nSend this Key to the Box requester:\n' 41 | f' [W0b]{sharekey.encode()}[X]\n' 42 | ) 43 | -------------------------------------------------------------------------------- /cli/commands/dir/share.py: -------------------------------------------------------------------------------- 1 | import click 2 | 3 | from ..group import cli_group 4 | from ..helpers import ctx_require 5 | from ...tools.terminal import echo 6 | from ...config import tgbox 7 | 8 | 9 | @cli_group.command() 10 | @click.option( 11 | '--requestkey', '-r', 12 | help='Requester\'s RequestKey' 13 | ) 14 | @click.option( 15 | '--directory', '-d', required=True, prompt=True, 16 | help='Absolute path of Directory to share' 17 | ) 18 | @ctx_require(dlb=True) 19 | def dir_share(ctx, requestkey, directory): 20 | """Get a ShareKey from RequestKey to share dir""" 21 | 22 | dlbd = tgbox.sync(ctx.obj.dlb.get_directory(directory.strip())) 23 | 24 | if not dlbd: 25 | echo(f'[R0b]There is no dir "{directory}" in LocalBox.[X]') 26 | else: 27 | requestkey = requestkey if not requestkey \ 28 | else tgbox.keys.Key.decode(requestkey) 29 | 30 | sharekey = dlbd.get_sharekey(requestkey) 31 | 32 | if not requestkey: 33 | echo( 34 | '\n[R0b]You didn\'t specified requestkey.\n You ' 35 | 'will receive decryption key IN PLAIN[X]\n' 36 | ) 37 | if not click.confirm('Are you TOTALLY sure?'): 38 | return 39 | echo( 40 | '\nSend this Key to the Box requester:\n' 41 | f' [W0b]{sharekey.encode()}[X]\n' 42 | ) 43 | -------------------------------------------------------------------------------- /cli/commands/account/info.py: -------------------------------------------------------------------------------- 1 | import click 2 | 3 | from ..group import cli_group 4 | from ..helpers import ctx_require 5 | from ...tools.terminal import echo 6 | from ...config import tgbox 7 | 8 | 9 | @cli_group.command() 10 | @click.option( 11 | '--show-phone', is_flag=True, 12 | help='Specify this to show phone number' 13 | ) 14 | @ctx_require(account=True) 15 | def account_info(ctx, show_phone): 16 | """Show information about current account""" 17 | 18 | me = tgbox.sync(ctx.obj.account.get_me()) 19 | 20 | last_name = me.last_name if me.last_name else '' 21 | full_name = f'[W0b]{me.first_name} {last_name}[X]' 22 | 23 | if show_phone: 24 | phone = f'[W0b]+{me.phone}[X]' 25 | else: 26 | phone = '[R0b]