mirror of
https://github.com/tcsenpai/telnet_retro_chat.git
synced 2025-06-06 03:05:35 +00:00
better console support
This commit is contained in:
parent
f6a36b689c
commit
dffadb65da
@ -12,8 +12,12 @@ def broadcast_message(
|
|||||||
else (room.users if room else connections.keys())
|
else (room.users if room else connections.keys())
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Always show to console
|
||||||
|
print(formatted_message)
|
||||||
|
|
||||||
|
# Send to other recipients
|
||||||
for addr in recipients:
|
for addr in recipients:
|
||||||
if addr not in connections:
|
if addr not in connections or addr == ("console", 0):
|
||||||
continue
|
continue
|
||||||
try:
|
try:
|
||||||
if sender_addr and addr == sender_addr:
|
if sender_addr and addr == sender_addr:
|
||||||
|
6
main.py
6
main.py
@ -117,8 +117,10 @@ def process_complete_line(line, addr, active_connections, conn):
|
|||||||
room,
|
room,
|
||||||
)
|
)
|
||||||
|
|
||||||
# For console, print locally instead of sending
|
# Send back to sender (if not console)
|
||||||
if not conn:
|
if conn:
|
||||||
|
conn.sendall(f"\r\n{message_with_user}\r\n".encode("ascii"))
|
||||||
|
else:
|
||||||
print(f"\r\n{message_with_user}\r\n")
|
print(f"\r\n{message_with_user}\r\n")
|
||||||
|
|
||||||
except UnicodeDecodeError:
|
except UnicodeDecodeError:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user