Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Commit

Permalink
Change formatting of long incoming chat messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Torom committed Sep 7, 2023
1 parent 5c8291c commit 81aa8bf
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions chatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,16 @@ def handle_chat_message(self, chatLine_Event: dict) -> None:

if chat_message.username == 'lichess':
if chat_message.room == 'player':
print(f'{chat_message.username}: {chat_message.text}')
print(chat_message.text)
return

if chat_message.username != self.api.username:
print(f'{chat_message.username} ({chat_message.room}): {chat_message.text}')
prefix = f'{chat_message.username} ({chat_message.room}): '
output = prefix + chat_message.text
if len(output) > 128:
output = f'{output[:128]}\n{len(prefix) * " "}{output[128:]}'

print(output)

if chat_message.text.startswith('!'):
if response := self._handle_command(chat_message):
Expand Down

0 comments on commit 81aa8bf

Please sign in to comment.