Commit c2dd84c0 authored by m!nus's avatar m!nus

first release version

parent 12659053
#!/usr/bin/python
from __future__ import print_function
from teeworlds import Teeworlds
# set up stuff
tw = Teeworlds(timeout=2)
# ask the masters for servers
tw.query_masters()
# query servers, wait for responses
# stops if no packet is received for `timeout` seconds
tw.run_loop()
# filter the serverlist
servers = tw.serverlist.find(name="^C", # Server whose name begins with "C", regex style
gametype="CTF", # gametype contains "CTF"
maxping=0.1) # ping is lower or equal to 100ms
# sort by ping
servers.sort(key=lambda s: s.latency)
# display a nice list
for server in servers:
print("{server: <64} [{gametype: ^16}] on {master}: {clients: >2}/{max_clients: <2} - {latency: >4.0f} ms" \
.format(server=server.name, gametype=server.gametype, master=server.master.name, clients=server.clients, \
max_clients=server.max_clients, latency=server.latency*1000))
# check if m!nus is currently playing
minus_list = tw.playerlist.find(name="^m!nus$")
if minus_list.players:
minus = minus_list.players[0]
print("m!nus is currently playing on {server} ({address}) with {players} other player(s)."
.format(server=minus.server.name, address=minus.server.address, players=(minus.server.players-1)))
else:
print("m!nus isn't playing at the moment.")
#!/usr/bin/python
from __future__ import print_function
from teeworlds import Teeworlds
import sys
# set up stuff
tw = Teeworlds(timeout=2)
# ask the masters for servers
tw.query_masters()
# query servers, wait for responses
# stops if no packet is received for `timeout` seconds
tw.run_loop()
# filter the serverlist
ip_filter = "^"+sys.argv[1].replace(".", "\\.")
servers = tw.serverlist.find(address=ip_filter)
# sort by ping
servers.sort(key=lambda s: s.address)
# display a nice list
for server in servers:
print("{server: <64} {address: <15} [{gametype: ^16}] on {master}: {clients: >2}/{max_clients: <2} - {latency: >4.0f} ms" \
.format(server=server.name, address=server.address, gametype=server.gametype, master=server.master.name, clients=server.clients, \
max_clients=server.max_clients, latency=server.latency*1000))
# check if m!nus is currently playing
#minus_list = tw.playerlist.find(name="^m!nus$")
#if minus_list.players:
# minus = minus_list.players[0]
# print("m!nus is currently playing on {server} ({address}) with {players} other player(s)."
# .format(server=minus.server.name, address=minus.server.address, players=(minus.server.players-1)))
#else:
# print("m!nus isn't playing at the moment.")
#!/usr/bin/python
from __future__ import print_function
from teeworlds import Teeworlds
import sys
# set up stuff
tw = Teeworlds(timeout=2)
# ask the masters for servers
tw.query_masters()
# query servers, wait for responses
# stops if no packet is received for `timeout` seconds
tw.run_loop()
servers = tw.serverlist
# sort by ping
servers.sort(key=lambda s: s.address)
# display a nice list
for server in servers:
print("{server: <64} {address: <15} [{gametype: ^16}] on {master}: {clients: >2}/{max_clients: <2} - {latency: >4.0f} ms" \
.format(server=server.name, address=server.address, gametype=server.gametype, master=server.master.name, clients=server.clients, \
max_clients=server.max_clients, latency=server.latency*1000))
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment