Count bots
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
kleph 2020-04-17 01:03:48 +02:00
parent 57b67e2132
commit e13df12508
3 changed files with 20 additions and 4 deletions

View file

@ -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)

View file

@ -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
View file

@ -0,0 +1 @@
Flask