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:
Olen
2017-06-08 20:26:24 +02:00
committed by Neil Lathwood
parent 80bcb0d528
commit 3dd6628101

View File

@@ -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);
}
}
}