This commit is contained in:
parent
57b67e2132
commit
e13df12508
3 changed files with 20 additions and 4 deletions
15
pyquake3.py
15
pyquake3.py
|
@ -22,6 +22,16 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
import socket
|
||||
import re
|
||||
|
||||
bot_names = ['Crash', # Tier 0
|
||||
'Ranger', 'Phobos', 'Mynx', 'Orbb', 'Sarge', # Tier 1
|
||||
'Bitterman', 'Grunt', 'Hossman', 'Daemia', 'Hunter', # Tier 2
|
||||
'Angel', 'Gorre', 'Klesk', 'Slash', 'Wrack', # Tier 3
|
||||
'Biker', 'Lucy', 'Patriot', 'Tank Jr.', 'Anarki', # Tier 4
|
||||
'Stripe', 'Razor', 'Keel', 'Visor', 'Uriel', # Tier 5
|
||||
'Bones', 'Cadaver', 'Sorlag', 'Doom', 'Major', # Tier 6
|
||||
'Xaero' # Tier 7
|
||||
]
|
||||
|
||||
class Player:
|
||||
def __init__(self, name, frags, ping, address=None, bot=-1):
|
||||
self.name = name
|
||||
|
@ -110,7 +120,10 @@ class PyQuake3:
|
|||
print 'couldnt match', player
|
||||
continue
|
||||
frags, ping, name = match.groups()
|
||||
self.players.append(Player(name, frags, ping))
|
||||
if name in bot_names:
|
||||
self.players.append(Player(name, frags, ping, bot=1))
|
||||
else:
|
||||
self.players.append(Player(name, frags, ping, bot=0))
|
||||
def update(self):
|
||||
cmd, data = self.command('getstatus')
|
||||
self.vars = self.parse_status(data)
|
||||
|
|
|
@ -21,9 +21,11 @@ def index(hours=None, minutes=None):
|
|||
q = PyQuake3(q3server, rcon_password)
|
||||
q.update()
|
||||
|
||||
data = 'The name of %s is %s, running map %s with %s player(s).' % \
|
||||
(q.get_address(), q.vars['sv_hostname'], \
|
||||
q.vars['mapname'], len(q.players))
|
||||
data = 'The name is %s, running map %s with %s human player(s) and %s bot(s).' % \
|
||||
(q.vars['sv_hostname'], \
|
||||
q.vars['mapname'], \
|
||||
len([x for x in q.players if not x.bot]),\
|
||||
len([x for x in q.players if x.bot]))
|
||||
|
||||
return data
|
||||
|
||||
|
|
1
requirements.txt
Normal file
1
requirements.txt
Normal file
|
@ -0,0 +1 @@
|
|||
Flask
|
Loading…
Reference in a new issue