Consume every LIVESTATS heartbeat variant and show them all only with -v
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <[email protected]>
This commit is contained in:
@@ -37,7 +37,7 @@ RENAME_PATTERN = re.compile(r'^(.+?)\s+renamed to\s+(.+?)$')
|
|||||||
STATUS_HEAD_PATTERN = re.compile(r'^\s*\d+\s+-?\d+\s+(bot|\d+)\s+\S', re.MULTILINE)
|
STATUS_HEAD_PATTERN = re.compile(r'^\s*\d+\s+-?\d+\s+(bot|\d+)\s+\S', re.MULTILINE)
|
||||||
STATUS_MAP_PATTERN = re.compile(r'^map:\s+\S+\s*$', re.MULTILINE)
|
STATUS_MAP_PATTERN = re.compile(r'^map:\s+\S+\s*$', re.MULTILINE)
|
||||||
STEAMID_PATTERN = re.compile(r'\b\d{16,}\b')
|
STEAMID_PATTERN = re.compile(r'\b\d{16,}\b')
|
||||||
LIVESTATS_PATTERN = re.compile(r'^LIVESTATS\s+(\S+)\s+(-?\d+)\s+(-?\d+)\s+(-?\d+)\s+(-?\d+)\s*$')
|
LIVESTATS_PATTERN = re.compile(r'^LIVESTATS\s+(.+)\s+(-?\d+)\s+(-?\d+)\s+(-?\d+)\s+(-?\d+)\s*$')
|
||||||
ROSTER_CHAT_GUARD_PATTERN = re.compile(r'^.{1,40}:\s')
|
ROSTER_CHAT_GUARD_PATTERN = re.compile(r'^.{1,40}:\s')
|
||||||
VOTE_CAST_PATTERN = re.compile(r'^(.+?) voted for (.+)\.$')
|
VOTE_CAST_PATTERN = re.compile(r'^(.+?) voted for (.+)\.$')
|
||||||
CHAT_SHAPE_PATTERN = re.compile(r'^[\w(][^:]*:\s')
|
CHAT_SHAPE_PATTERN = re.compile(r'^[\w(][^:]*:\s')
|
||||||
@@ -156,17 +156,20 @@ def is_engine_output(message):
|
|||||||
|
|
||||||
def handle_livestats(message, game_state, ui, verbose=0):
|
def handle_livestats(message, game_state, ui, verbose=0):
|
||||||
"""
|
"""
|
||||||
Parse a LIVESTATS print (engine damage counters, emitted every 10s by the
|
Consume every LIVESTATS heartbeat line (engine damage counters emitted
|
||||||
livedamage plugin) and update the player's live score/damage/ping.
|
every 10s by the livedamage plugin, plus its summary variants). Lines
|
||||||
Returns True when the line is consumed. The raw line displays only at -v
|
matching the full player shape update live score/damage/ping; names may
|
||||||
or higher verbosity; it is never treated as chat.
|
contain spaces, so the counters anchor from the end. The raw lines
|
||||||
|
display only at -v or higher verbosity; they are never treated as chat.
|
||||||
"""
|
"""
|
||||||
match = LIVESTATS_PATTERN.match(strip_color_codes(message).strip())
|
clean = strip_color_codes(message).strip()
|
||||||
if not match:
|
if not clean.lower().startswith('livestats'):
|
||||||
return False
|
return False
|
||||||
name, score, dealt, taken, ping = match.groups()
|
match = LIVESTATS_PATTERN.match(clean)
|
||||||
game_state.player_tracker.update_livestats(name, int(score), int(dealt), int(taken), int(ping))
|
if match:
|
||||||
ui.update_server_info(game_state)
|
name, score, dealt, taken, ping = match.groups()
|
||||||
|
game_state.player_tracker.update_livestats(name, int(score), int(dealt), int(taken), int(ping))
|
||||||
|
ui.update_server_info(game_state)
|
||||||
if verbose > 0:
|
if verbose > 0:
|
||||||
timestamp = time.strftime('%H:%M:%S')
|
timestamp = time.strftime('%H:%M:%S')
|
||||||
ui.print_message(f"^3[^7{timestamp}^3]^7 {message.rstrip()}\n")
|
ui.print_message(f"^3[^7{timestamp}^3]^7 {message.rstrip()}\n")
|
||||||
|
|||||||
Reference in New Issue
Block a user