64 |
|
* @param alert the alert to send |
65 |
|
*/ |
66 |
|
public void sendAlert(Alert alert) { |
67 |
+ |
// sort out the message |
68 |
+ |
String alertType = Alert.alertLevels[alert.getLevel()]; |
69 |
+ |
String message; |
70 |
+ |
try { |
71 |
+ |
message = _cp.getProperty(_name, "Alerter.IRC.message"); |
72 |
+ |
} catch (PropertyNotFoundException e) { |
73 |
+ |
message = NOT_CONFIGURED; |
74 |
+ |
_logger.write(toString(), Logger.WARNING, "Alerter.IRC.message value unavailable using default of " + message); |
75 |
+ |
} |
76 |
+ |
message = processAlertMessage(message, alert); |
77 |
|
// only send alerts if we're active |
78 |
< |
if(_active) { |
69 |
< |
// sort out the message |
70 |
< |
String alertType = Alert.alertLevels[alert.getLevel()]; |
71 |
< |
String message; |
72 |
< |
try { |
73 |
< |
message = _cp.getProperty(_name, "Alerter.IRC.message"); |
74 |
< |
} catch (PropertyNotFoundException e) { |
75 |
< |
message = NOT_CONFIGURED; |
76 |
< |
_logger.write(toString(), Logger.WARNING, "Alerter.IRC.message value unavailable using default of " + message); |
77 |
< |
} |
78 |
< |
message = processAlertMessage(message, alert); |
79 |
< |
|
78 |
> |
if(_active) { |
79 |
|
// send the message |
80 |
|
_logger.write(toString(), Logger.DEBUG, "Sending " + _name + " at "+ alertType + " level"); |
81 |
|
_ircbot.sendMsg(message); |
82 |
< |
_lastAlert = message; |
83 |
< |
_lastAlertTime = System.currentTimeMillis(); |
85 |
< |
_alertCount ++; |
82 |
> |
// count sent alerts |
83 |
> |
_alertCount++; |
84 |
|
} else { |
85 |
< |
_ignoredCount ++; |
85 |
> |
// don't send, but keep a count that we ignored it |
86 |
> |
_ignoredCount++; |
87 |
|
} |
88 |
+ |
// we'll always store the "last alert", regardless |
89 |
+ |
// of whether we actually display it or not |
90 |
+ |
_lastAlert = message; |
91 |
+ |
_lastAlertTime = System.currentTimeMillis(); |
92 |
|
} |
93 |
|
|
94 |
|
/** |
119 |
|
//---PRIVATE METHODS--- |
120 |
|
|
121 |
|
//---ACCESSOR/MUTATOR METHODS--- |
122 |
+ |
|
123 |
+ |
/** |
124 |
+ |
* Returns the "friendly" name of this class. This |
125 |
+ |
* is simply an accessor for _name, required due to |
126 |
+ |
* inheritance issues with extending AlerterSkeleton. |
127 |
+ |
* |
128 |
+ |
* @return the friendly name |
129 |
+ |
*/ |
130 |
+ |
protected String getFName() { |
131 |
+ |
return _name; |
132 |
+ |
} |
133 |
|
|
134 |
|
//---ATTRIBUTES--- |
135 |
|
|