From 563b52bab76871707311bf815db0fde16244792a Mon Sep 17 00:00:00 2001 From: John Reese Date: Thu, 13 Jan 2011 22:46:02 -0500 Subject: [PATCH] Added message_length option --- README.md | 6 ++++++ notifo.cpp | 11 ++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 703c8ab..2e755b1 100644 --- a/README.md +++ b/README.md @@ -72,6 +72,12 @@ Configuration ### Notifications +* `message_length = 100` + + Maximum length of the notification message to be sent. The message will be nicely + truncated and ellipsized at or before this length is reached. A value of 0 (zero) will + disable this option. + * `message_url = ""` URI that will be sent with the notification to Notifo. This could be a web address or a diff --git a/notifo.cpp b/notifo.cpp index e670ce5..75f272e 100644 --- a/notifo.cpp +++ b/notifo.cpp @@ -76,6 +76,7 @@ class CNotifoMod : public CModule options["client_count_less_than"] = "0"; // Notification settings + options["message_length"] = "100"; options["message_uri"] = ""; } virtual ~CNotifoMod() {} @@ -113,9 +114,17 @@ class CNotifoMod : public CModule */ void send_message(const CString& message, const CString& title="New Message") { + // Shorten message if needed + unsigned int message_length = options["message_length"].ToUInt(); + CString short_message = message; + if (message_length > 0) + { + short_message = message.Ellipsize(message_length); + } + // POST body parameters for the request CString post = "to=" + urlencode(options["username"]); - post += "&msg=" + urlencode(message); + post += "&msg=" + urlencode(short_message); post += "&label=" + urlencode(app); post += "&title=" + urlencode(title); post += "&uri=" + urlencode(options["message_uri"]);