Add the MessagePrinter to print a message in Markdown.

This commit is contained in:
2023-12-12 18:04:17 +02:00
parent d90b280d41
commit 1bd5fd5145
2 changed files with 15 additions and 0 deletions
+12
View File
@@ -0,0 +1,12 @@
from rich.console import Console
from rich.markdown import Markdown
class MessagePrinter:
@staticmethod
def print(title: str, message: str):
console = Console()
full_message = f'# {title}\n{message}'
console.print(Markdown(full_message))
+3
View File
@@ -19,6 +19,7 @@
import asyncio import asyncio
import struct import struct
from notification_client.MessagePrinter import MessagePrinter
class Client: class Client:
@@ -44,6 +45,8 @@ class Client:
title = await self.receive_message(reader) title = await self.receive_message(reader)
message = await self.receive_message(reader) message = await self.receive_message(reader)
MessagePrinter.print(title, message)
except asyncio.CancelledError: except asyncio.CancelledError:
print('Something went wrong') print('Something went wrong')
finally: finally: