Adopt previous commit changes in cli.py

This commit is contained in:
Iam54r1n4
2025-01-26 11:43:59 +00:00
parent 7daccebd0f
commit 84c9d0adae

View File

@ -323,8 +323,14 @@ def warp_status():
@click.option('--adminid', '-aid', required=False, help='Telegram admins ID for running the telegram bot', type=str) @click.option('--adminid', '-aid', required=False, help='Telegram admins ID for running the telegram bot', type=str)
def telegram(action: str, token: str, adminid: str): def telegram(action: str, token: str, adminid: str):
try: try:
cli_api.telegram(action, token, adminid) if action == 'start':
click.echo(f"Telegram bot {action}ed successfully.") if not token or not adminid:
raise click.UsageError('Error: Both --token and --adminid are required for the start action.')
cli_api.start_telegram_bot(token, adminid)
click.echo(f"Telegram bot started successfully.")
elif action == 'stop':
cli_api.stop_telegram_bot()
click.echo(f"Telegram bot stopped successfully.")
except Exception as e: except Exception as e:
click.echo(f'{e}', err=True) click.echo(f'{e}', err=True)
@ -335,8 +341,14 @@ def telegram(action: str, token: str, adminid: str):
@click.option('--port', '-p', required=False, help='Port number for Singbox service', type=int) @click.option('--port', '-p', required=False, help='Port number for Singbox service', type=int)
def singbox(action: str, domain: str, port: int): def singbox(action: str, domain: str, port: int):
try: try:
cli_api.singbox(action, domain, port) if action == 'start':
click.echo(f"Singbox service {action}ed successfully.") if not domain or not port:
raise click.UsageError('Error: Both --domain and --port are required for the start action.')
cli_api.start_singbox(domain, port)
click.echo(f"Singbox started successfully.")
elif action == 'stop':
cli_api.stop_singbox()
click.echo(f"Singbox stopped successfully.")
except Exception as e: except Exception as e:
click.echo(f'{e}', err=True) click.echo(f'{e}', err=True)
@ -347,8 +359,14 @@ def singbox(action: str, domain: str, port: int):
@click.option('--port', '-p', required=False, help='Port number for NormalSub service', type=int) @click.option('--port', '-p', required=False, help='Port number for NormalSub service', type=int)
def normalsub(action: str, domain: str, port: int): def normalsub(action: str, domain: str, port: int):
try: try:
cli_api.normalsub(action, domain, port) if action == 'start':
click.echo(f"NormalSub service {action}ed successfully.") if not domain or not port:
raise click.UsageError('Error: Both --domain and --port are required for the start action.')
cli_api.start_normalsub(domain, port)
click.echo(f"NormalSub started successfully.")
elif action == 'stop':
cli_api.stop_normalsub()
click.echo(f"NormalSub stopped successfully.")
except Exception as e: except Exception as e:
click.echo(f'{e}', err=True) click.echo(f'{e}', err=True)