From 427592c5c59feccc6f93f4bed7d642ce72dcbc95 Mon Sep 17 00:00:00 2001 From: Alexander Bersenev Date: Sat, 23 Jun 2018 02:45:32 +0500 Subject: [PATCH] use command line to pass args --- mtprotoproxy.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/mtprotoproxy.py b/mtprotoproxy.py index b3a229b..61599ba 100755 --- a/mtprotoproxy.py +++ b/mtprotoproxy.py @@ -65,10 +65,22 @@ except (ValueError, OSError): except ImportError: pass -if len(sys.argv) > 1: - config = runpy.run_path(sys.argv[1]) +# if len(sys.argv) > 1: +# config = runpy.run_path(sys.argv[1]) +# else: +# config = runpy.run_module("config") + +if len(sys.argv) < 3: + print("Usage: mtprotoproxy [ad_tag]") + print("Example: mtprotoproxy 3256 0123456789abcdef0123456789abcdef 3c09c680b76ee91a4c25ad51f742267d") + sys.exit(0) else: - config = runpy.run_module("config") + config = {} + config["PORT"] = int(sys.argv[1]) + config["USERS"] = {"tg": sys.argv[2]} + if len(sys.argv) >= 4: + config["AD_TAG"] = sys.argv[3] + PORT = config["PORT"] USERS = config["USERS"]