Added message_length option

This commit is contained in:
John Reese 2011-01-13 22:46:02 -05:00
parent c749f4874b
commit 563b52bab7
2 changed files with 16 additions and 1 deletions

View File

@ -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

View File

@ -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"]);