Add the MessagePrinter to print a message in Markdown.
This commit is contained in:
@@ -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))
|
||||||
|
|
||||||
@@ -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:
|
||||||
|
|||||||
Reference in New Issue
Block a user