Created
July 4, 2015 23:12
-
-
Save XMPPwocky/ed0c7f48a86d981932ec to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import valve.source.a2s | |
| import re | |
| import valve.source.master_server | |
| regex = re.compile(".*McKay.*") | |
| msq = valve.source.master_server.MasterServerQuerier(timeout=1.0) | |
| try: | |
| for address in msq.find(region=[u"na"], | |
| gamedir=u"tf", | |
| empty="false", | |
| full="false", | |
| gametype=[u"valve"]): | |
| try: | |
| server = valve.source.a2s.ServerQuerier(address, 0.35) | |
| players = server.get_players() | |
| targets = [pl["name"] for pl in players["players"] if regex.match(pl["name"]) is not None] | |
| if len(targets) > 0: | |
| info = server.get_info() | |
| print address | |
| print targets | |
| print info["server_name"] | |
| except: continue | |
| except valve.source.a2s.NoResponseError: | |
| print "Master server request timed out!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment