Update configure-warp

This commit is contained in:
Whispering Wind
2024-08-21 00:37:52 +03:30
committed by GitHub
parent 8350795d95
commit 36a9899582

View File

@ -253,17 +253,35 @@ def uninstall_warp():
@click.option('--popular-sites', '-p', is_flag=True, help='Use WARP for popular sites like Google, OpenAI, etc') @click.option('--popular-sites', '-p', is_flag=True, help='Use WARP for popular sites like Google, OpenAI, etc')
@click.option('--domestic-sites', '-d', is_flag=True, help='Use WARP for Iran domestic sites') @click.option('--domestic-sites', '-d', is_flag=True, help='Use WARP for Iran domestic sites')
@click.option('--block-adult-sites', '-x', is_flag=True, help='Block adult content (porn)') @click.option('--block-adult-sites', '-x', is_flag=True, help='Block adult content (porn)')
def configure_warp(all: bool, popular_sites: bool, domestic_sites: bool, block_adult_sites: bool): @click.option('--warp-option', '-w', type=click.Choice(['warp', 'warp plus'], case_sensitive=False), help='Specify whether to use WARP or WARP Plus')
options = { @click.option('--warp-key', '-k', help='WARP Plus key (required if warp-option is "warp plus")')
"all": all, def configure_warp(all: bool, popular_sites: bool, domestic_sites: bool, block_adult_sites: bool, warp_option: str, warp_key: str):
"popular_sites": popular_sites, if warp_option == 'warp plus' and not warp_key:
"domestic_sites": domestic_sites, print("Error: WARP Plus key is required when 'warp plus' is selected.")
"block_adult_sites": block_adult_sites return
}
options = {k: 'true' if v else 'false' for k, v in options.items()} options = {
run_cmd(['bash', Command.CONFIGURE_WARP.value, "all": 'true' if all else 'false',
options['all'], options['popular_sites'], options['domestic_sites'], options['block_adult_sites']]) "popular_sites": 'true' if popular_sites else 'false',
"domestic_sites": 'true' if domestic_sites else 'false',
"block_adult_sites": 'true' if block_adult_sites else 'false',
"warp_option": warp_option or '',
"warp_key": warp_key or ''
}
cmd_args = [
'bash', Command.CONFIGURE_WARP.value,
options['all'],
options['popular_sites'],
options['domestic_sites'],
options['block_adult_sites'],
options['warp_option']
]
if options['warp_key']:
cmd_args.append(options['warp_key'])
run_cmd(cmd_args)
@cli.command('telegram') @cli.command('telegram')
@click.option('--action', '-a', required=True, help='Action to perform: start or stop', type=click.Choice(['start', 'stop'], case_sensitive=False)) @click.option('--action', '-a', required=True, help='Action to perform: start or stop', type=click.Choice(['start', 'stop'], case_sensitive=False))