[Python] Is there a way that a python function can grab the IP given by Playit.gg in the...

Discussão em 'Python' iniciado por Stack, Abril 12, 2025.

  1. Stack

    Stack Membro Participativo

    I am making a server manager script in python that can run a minecraft server and start a playit.gg executable. Normally both have their own console window but when doing it with python, everything is put into 1 console window.

    I linked the server manager to a discord bot so that my friends can turn on the server and play on it as well but I want the IP given by playit.gg to be send in the chat. Sending the message isn't the problem, getting python to take the ip and write it to a save file (txt file) is the problem.

    I've tried having python look at the console, using stdout/stdin, I've asked AI (helpful as ever), I've tried logging the console to a separate file... At this point I don't know if it's python, the console, playit.exe...

    def extract_and_save():
    pattern = re.compile(r'\b[\w\-]+\.gl\.joinmc\.link\b')

    print("Waiting for Playit IP... (Ctrl+C to stop)")
    while True:
    for line in sys.stdin:
    match = pattern.search(line)
    if match:
    ip = match.group(0)
    print(f"Found Playit IP: {ip}")
    with open("playit_ip.txt", "w") as f:
    f.write(ip)
    break # Stop after finding the IP


    In short: normally 2 consoles (1 for java (minecraft server) and 1 for playit.exe), now 1 console (Python.exe). I need it to find the IP with structure something + .joinmc.link and write it to the playit_ip.txt file.

    Continue reading...

Compartilhe esta Página