tools/players.py

28 lines
665 B
Python
Raw Permalink Normal View History

2021-11-30 14:51:26 +01:00
#!/usr/bin/env python3
import time
import sys
import re
from mcrcon import MCRcon
import pdb
from CONFIG import HOST,PW,PORT
flushed=False
with MCRcon(HOST, PW, port=PORT) as mcr:
resp = mcr.command("list uuids")
resp = resp.split(":")
player_list = resp[1].strip().split(",")
player_list = list(map(lambda x: x.strip(), player_list))
count_regex = re.match("There are ([0-9]+) of a max of ([0-9]+) players online", resp[0])
num_players = count_regex.group(1)
max_players = count_regex.group(2)
print("Current # players:", num_players)
print("Max # players:", max_players)
print(player_list)
pdb.set_trace()
if flushed:
sys.exit(0)
else:
sys.exit(1)