From 6f684337feacbfa7147967817ad5796f5259229c Mon Sep 17 00:00:00 2001 From: KKlochko Date: Wed, 13 Dec 2023 14:04:16 +0200 Subject: [PATCH] Add the truncation for the data of the system notification. --- notification_client/notitication.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/notification_client/notitication.py b/notification_client/notitication.py index 3fd1c43..7fa4294 100644 --- a/notification_client/notitication.py +++ b/notification_client/notitication.py @@ -2,10 +2,17 @@ from notifypy import Notify class Notification: + @staticmethod + def truncatechars(message: str, size: int): + if len(message) > size: + return message[:(size-3)] + '...' + + return message + @staticmethod def notify(title: str, message: str): notification = Notify() - notification.title = title - notification.message = message + notification.title = Notification.truncatechars(title, 80) + notification.message = Notification.truncatechars(message, 100) notification.send()