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']) {
|
||||
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:' : ''));
|
||||
foreach ($alert['faults'] as $k => $v) {
|
||||
$this->ircRaw('PRIVMSG '.$chan.' :#'.$k.' '.$v['string']);
|
||||
$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);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
foreach ($this->authd as $nick => $data) {
|
||||
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']).' )' : '' ).':' : ''));
|
||||
foreach ($alert['faults'] as $k => $v) {
|
||||
$this->ircRaw('PRIVMSG '.$nick.' :#'.$k.' '.$v['string']);
|
||||
if ($k >= 3) {
|
||||
break;
|
||||
$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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user