Show client id and endpoint on connect/disconnect, gate command echoes behind -v

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <[email protected]>
This commit is contained in:
Debian
2026-09-16 22:04:47 +02:00
co-authored by Sisyphus
parent e834b44ba6
commit 8eccfefc75
2 changed files with 11 additions and 8 deletions
+10 -7
View File
@@ -103,9 +103,9 @@ def parse_cvar_response(message, game_state, ui):
return False
def is_own_command_echo(message, identity):
"""True for echo lines of commands this client sent (the server echoes them to every RCON client)"""
return message.startswith(f'zmq RCON command from {identity}:')
def is_command_echo(message):
"""True for the server's echo lines announcing that an RCON client sent a command"""
return message.startswith('zmq RCON command')
def is_command_output(message):
@@ -422,7 +422,8 @@ def main_loop(screen, args):
monitor_event = rcon.check_monitor()
if monitor_event and monitor_event[0] == zmq.EVENT_CONNECTED:
timestamp = time.strftime('%H:%M:%S')
ui.print_message(f"^3[^7{timestamp}^3]^7 Connected to server\n")
ui.print_message(f"^3[^7{timestamp}^3]^7 Connected to server ({monitor_event[2]}) "
f"as rcon client {rcon.identity}\n")
rcon.send_command(b'register')
logger.info('Registration message sent')
@@ -434,7 +435,8 @@ def main_loop(screen, args):
name_capture.request(rcon)
elif monitor_event and monitor_event[0] == zmq.EVENT_DISCONNECTED:
timestamp = time.strftime('%H:%M:%S')
ui.print_message(f"^3[^7{timestamp}^3] ^8^1Disconnected from server - waiting for reconnect...^0^7\n")
ui.print_message(f"^3[^7{timestamp}^3] ^8^1Disconnected from server ({monitor_event[2]}) "
f"as rcon client {rcon.identity} - waiting for reconnect...^0^7\n")
if stats_conn is not None:
poller.unregister(stats_conn.socket)
stats_conn.close()
@@ -475,8 +477,9 @@ def main_loop(screen, args):
if parse_player_events(message, game_state, ui):
continue
# Hide echoes of our own commands; other clients' echoes stay visible
if is_own_command_echo(message, rcon.identity):
# Command echoes only show at -v or higher verbosity
if is_command_echo(message) and args.verbose == 0:
logger.debug('Suppressed RCON command echo')
continue
if 'Game Initialization' in message: