mirror of
https://github.com/onyx-and-iris/q3rcon-tui.git
synced 2026-02-26 11:09:11 +00:00
include the mapname in the status output
patch bump
This commit is contained in:
parent
1cee478197
commit
d9b74c745d
@ -1,4 +1,4 @@
|
|||||||
# SPDX-FileCopyrightText: 2026-present onyx-and-iris <code@onyxandiris.online>
|
# SPDX-FileCopyrightText: 2026-present onyx-and-iris <code@onyxandiris.online>
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
__version__ = '0.5.1'
|
__version__ = '0.5.2'
|
||||||
|
|||||||
@ -10,6 +10,7 @@ Renderable = Text | Table | str
|
|||||||
|
|
||||||
class Writable:
|
class Writable:
|
||||||
RE_COLOR_CODES = re.compile(r'\^[0-9]')
|
RE_COLOR_CODES = re.compile(r'\^[0-9]')
|
||||||
|
RE_MAP_FROM_STATUS = re.compile(r'^map: (?P<mapname>mp_[a-z_]+)$')
|
||||||
RE_PLAYER_FROM_STATUS = re.compile(
|
RE_PLAYER_FROM_STATUS = re.compile(
|
||||||
r'^\s*(?P<slot>[0-9]+)\s+'
|
r'^\s*(?P<slot>[0-9]+)\s+'
|
||||||
r'(?P<score>[0-9-]+)\s+'
|
r'(?P<score>[0-9-]+)\s+'
|
||||||
@ -62,16 +63,13 @@ class Writable:
|
|||||||
table.add_column('GUID', justify='center')
|
table.add_column('GUID', justify='center')
|
||||||
table.add_column('Name', justify='center')
|
table.add_column('Name', justify='center')
|
||||||
table.add_column('Last', justify='center')
|
table.add_column('Last', justify='center')
|
||||||
table.add_column('IP', justify='center')
|
table.add_column('IP:Port', justify='center')
|
||||||
table.add_column('Port', justify='center')
|
|
||||||
table.add_column('QPort', justify='center')
|
table.add_column('QPort', justify='center')
|
||||||
table.add_column('Rate', justify='center')
|
table.add_column('Rate', justify='center')
|
||||||
|
|
||||||
|
mapname = ''
|
||||||
for line in status_response.splitlines():
|
for line in status_response.splitlines():
|
||||||
match self.RE_PLAYER_FROM_STATUS.match(line):
|
if m := self.RE_PLAYER_FROM_STATUS.match(line):
|
||||||
case None:
|
|
||||||
continue
|
|
||||||
case m:
|
|
||||||
table.add_row(
|
table.add_row(
|
||||||
m.group('slot'),
|
m.group('slot'),
|
||||||
m.group('score'),
|
m.group('score'),
|
||||||
@ -79,14 +77,18 @@ class Writable:
|
|||||||
m.group('guid'),
|
m.group('guid'),
|
||||||
self.remove_color_codes(m.group('name')),
|
self.remove_color_codes(m.group('name')),
|
||||||
m.group('last'),
|
m.group('last'),
|
||||||
m.group('ip'),
|
f'{m.group("ip")}:{m.group("port")}',
|
||||||
m.group('port'),
|
|
||||||
m.group('qport'),
|
m.group('qport'),
|
||||||
m.group('rate'),
|
m.group('rate'),
|
||||||
)
|
)
|
||||||
|
elif m := self.RE_MAP_FROM_STATUS.match(line):
|
||||||
|
mapname = m.group('mapname')
|
||||||
|
|
||||||
|
out = Text(f'Map: {mapname}\n', style='bold #88c0d0')
|
||||||
if len(table.rows) == 0:
|
if len(table.rows) == 0:
|
||||||
return 'No players connected.'
|
return out.append('No players connected', style='#c73d4b')
|
||||||
|
else:
|
||||||
|
table.title = out
|
||||||
return table
|
return table
|
||||||
|
|
||||||
def cvar_table(self, m: re.Match) -> Table:
|
def cvar_table(self, m: re.Match) -> Table:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user