From a30bc0e5b5260cbf1581afe36c08413b5574d6af Mon Sep 17 00:00:00 2001 From: Insomnia731 <120348762+Insomnia731@users.noreply.github.com> Date: Sun, 22 Sep 2024 23:28:31 +0300 Subject: [PATCH] Create start_main.py --- start_main.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 start_main.py diff --git a/start_main.py b/start_main.py new file mode 100644 index 0000000..1a31cb6 --- /dev/null +++ b/start_main.py @@ -0,0 +1,32 @@ +import sys +import subprocess +import time +import random +import asyncio +import aiohttp + +async def get_ip_info(): + try: + async with aiohttp.ClientSession() as session: + async with session.get("https://ipinfo.io") as response: + data = await response.json() + + ip = data.get('ip') + city = data.get('city') + country = data.get('country') + + print(f"IP: {ip}") + print(f"Location: {city}, {country}") + except Exception as e: + print(f"Error: {e}") + +def run_main(arg=None): + if arg is not None: + subprocess.run([sys.executable, 'hello.py'] + arg) + else: + subprocess.run([sys.executable, 'hello.py']) + +if __name__ == "__main__": + asyncio.run(get_ip_info()) + time.sleep(random.randint(0, 60*2)) # 2 минуты + run_main(["-a", "2"]) # Запускает main.py -a 2