feature: Added a irc_alert_short option to only send the alert title (#8312)

* Add a irc_alert_short option to only send the alert title

* Add doc for 'irc_alert_short'
This commit is contained in:
Arzhel Younsi
2018-03-03 02:52:47 +09:00
committed by Neil Lathwood
parent 5af51fa46f
commit 7eda8d9989
3 changed files with 16 additions and 10 deletions

View File

@ -259,11 +259,13 @@ class IRCBot
if ($this->config['irc_alert_chan']) {
foreach ($this->config['irc_alert_chan'] as $chan) {
$this->ircRaw('PRIVMSG '.$chan.' :'.$severity.trim($alert['title']));
foreach (explode("\n", $alert['msg']) as $line) {
// We don't need to repeat the title
$line = strip_tags($line);
if (trim($line) != trim($alert['title'])) {
$this->ircRaw('PRIVMSG '.$chan.' :'.$line);
if (!$this->config['irc_alert_short']) { // Only send the title if set to short
foreach (explode("\n", $alert['msg']) as $line) {
// We don't need to repeat the title
$line = strip_tags($line);
if (trim($line) != trim($alert['title'])) {
$this->ircRaw('PRIVMSG '.$chan.' :'.$line);
}
}
}
}
@ -271,11 +273,13 @@ class IRCBot
foreach ($this->authd as $nick => $data) {
if ($data['expire'] >= time()) {
$this->ircRaw('PRIVMSG '.$nick.' :'.$severity.trim($alert['title']));
foreach (explode("\n", $alert['msg']) as $line) {
// We don't need to repeat the title
$line = strip_tags($line);
if (trim($line) != trim($alert['title'])) {
$this->ircRaw('PRIVMSG '.$nick.' :'.$line);
if (!$this->config['irc_alert_short']) { // Only send the title if set to short
foreach (explode("\n", $alert['msg']) as $line) {
// We don't need to repeat the title
$line = strip_tags($line);
if (trim($line) != trim($alert['title'])) {
$this->ircRaw('PRIVMSG '.$nick.' :'.$line);
}
}
}
}

View File

@ -19,6 +19,7 @@ Option | Default-Value | Notes
`$config['irc_alert']` | `false` | Optional; Enables Alerting-Socket. `EXPERIMENTAL`
`$config['irc_alert_chan']` | `false` | Optional; Multiple channels can be defined as Array or delimited with `,`. `EXPERIMENTAL`
`$config['irc_alert_utf8']` | `false` | Optional; Enables use of strikethrough in alerts via UTF-8 encoded characters. Might cause trouble for some clients.
`$config['irc_alert_short']` | `false` | Optional; Send a one line alert summary instead of multi-line detailed alert.
`$config['irc_authtime']` | `3` | Optional; Defines how long in Hours an auth-session is valid.
`$config['irc_chan']` | `##librenms` | Optional; Multiple channels can be defined as Array or delimited with `,`. Passwords are defined after a `space-character`.
`$config['irc_debug']` | `false` | Optional; Enables debug output (Wall of text)

View File

@ -599,6 +599,7 @@ $config['irc_authtime'] = 3;
$config['irc_debug'] = false;
$config['irc_alert'] = false;
$config['irc_alert_utf8'] = false;
$config['irc_alert_short'] = false;
$config['irc_ctcp'] = false;
$config['irc_ctcp_version'] = "LibreNMS IRCbot. https://www.librenms.org/";