mirror of https://github.com/SeanOMik/znc-push.git
Added message_length option
This commit is contained in:
parent
c749f4874b
commit
563b52bab7
|
@ -72,6 +72,12 @@ Configuration
|
||||||
|
|
||||||
### Notifications
|
### 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 = ""`
|
* `message_url = ""`
|
||||||
|
|
||||||
URI that will be sent with the notification to Notifo. This could be a web address or a
|
URI that will be sent with the notification to Notifo. This could be a web address or a
|
||||||
|
|
11
notifo.cpp
11
notifo.cpp
|
@ -76,6 +76,7 @@ class CNotifoMod : public CModule
|
||||||
options["client_count_less_than"] = "0";
|
options["client_count_less_than"] = "0";
|
||||||
|
|
||||||
// Notification settings
|
// Notification settings
|
||||||
|
options["message_length"] = "100";
|
||||||
options["message_uri"] = "";
|
options["message_uri"] = "";
|
||||||
}
|
}
|
||||||
virtual ~CNotifoMod() {}
|
virtual ~CNotifoMod() {}
|
||||||
|
@ -113,9 +114,17 @@ class CNotifoMod : public CModule
|
||||||
*/
|
*/
|
||||||
void send_message(const CString& message, const CString& title="New Message")
|
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
|
// POST body parameters for the request
|
||||||
CString post = "to=" + urlencode(options["username"]);
|
CString post = "to=" + urlencode(options["username"]);
|
||||||
post += "&msg=" + urlencode(message);
|
post += "&msg=" + urlencode(short_message);
|
||||||
post += "&label=" + urlencode(app);
|
post += "&label=" + urlencode(app);
|
||||||
post += "&title=" + urlencode(title);
|
post += "&title=" + urlencode(title);
|
||||||
post += "&uri=" + urlencode(options["message_uri"]);
|
post += "&uri=" + urlencode(options["message_uri"]);
|
||||||
|
|
Loading…
Reference in New Issue