mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
alerts: Updated Irc transport to use templates (#6758)
* Use templates also for irc-alerts * Remove old code * Make messages to admins (nicks) use the templates as well * Added a "strip_tags" to remove html-tags from the irc-messages
This commit is contained in:
@@ -257,19 +257,24 @@ class IRCBot
|
|||||||
|
|
||||||
if ($this->config['irc_alert_chan']) {
|
if ($this->config['irc_alert_chan']) {
|
||||||
foreach ($this->config['irc_alert_chan'] as $chan) {
|
foreach ($this->config['irc_alert_chan'] as $chan) {
|
||||||
$this->ircRaw('PRIVMSG '.$chan.' :'.$severity.trim($alert['title']).' - Rule: '.trim($alert['name'] ? $alert['name'] : $alert['rule']).(sizeof($alert['faults']) > 0 ? ' - Faults:' : ''));
|
$this->ircRaw('PRIVMSG '.$chan.' :'.$severity.trim($alert['title']));
|
||||||
foreach ($alert['faults'] as $k => $v) {
|
foreach (explode("\n", $alert['msg']) as $line) {
|
||||||
$this->ircRaw('PRIVMSG '.$chan.' :#'.$k.' '.$v['string']);
|
// We don't need to repeat the title
|
||||||
|
$line = strip_tags($line);
|
||||||
|
if (trim($line) != trim($alert['title'])) {
|
||||||
|
$this->ircRaw('PRIVMSG '.$chan.' :'.$line);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
foreach ($this->authd as $nick => $data) {
|
foreach ($this->authd as $nick => $data) {
|
||||||
if ($data['expire'] >= time()) {
|
if ($data['expire'] >= time()) {
|
||||||
$this->ircRaw('PRIVMSG '.$nick.' :'.$severity.trim($alert['title']).' - Rule: '.trim($alert['name'] ? $alert['name'] : $alert['rule']).(sizeof($alert['faults']) > 0 ? ' - Faults'.(sizeof($alert['faults']) > 3 ? ' (showing first 3 out of '.sizeof($alert['faults']).' )' : '' ).':' : ''));
|
$this->ircRaw('PRIVMSG '.$nick.' :'.$severity.trim($alert['title']));
|
||||||
foreach ($alert['faults'] as $k => $v) {
|
foreach (explode("\n", $alert['msg']) as $line) {
|
||||||
$this->ircRaw('PRIVMSG '.$nick.' :#'.$k.' '.$v['string']);
|
// We don't need to repeat the title
|
||||||
if ($k >= 3) {
|
$line = strip_tags($line);
|
||||||
break;
|
if (trim($line) != trim($alert['title'])) {
|
||||||
|
$this->ircRaw('PRIVMSG '.$nick.' :'.$line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user