aboutsummaryrefslogtreecommitdiff
path: root/south_browser/__main__.py
blob: f0040b3a72fabe9417f320d7628a5956354ba9d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import inquirer

from requests.exceptions import ConnectionError
from .rpc import *

def main():
    try:
        work()
    except ConnectionError:
        print("Failed to connect to RPC")

def work():
    servers = NSGetGameServers()

    choices = [f"{s[2]} ({s[6]}/{s[7]})" for s in servers]
    questions = [
        inquirer.List('server_index',
            message="What server do you want to join?",
            choices=choices,
        ),
    ]

    answers = inquirer.prompt(questions)
    i = answers["server_index"]
    si = choices.index(i)

    NSTryAuthWithServer(si)

    sleep(1)

    if not NSWasAuthSuccessful():
        print("Failed to auth")
        return

    NSConnectToAuthedServer()


if __name__ == "__main__":
    main()