79 |
|
if(((alert.getLevel() == 0) && (alert.getLastLevel() >= level)) || (alert.getLevel() >= level)) { |
80 |
|
String alertType = Alert.alertLevels[alert.getLevel()]; |
81 |
|
String thresholdType = Alert.thresholdLevels[alert.getThreshold()]; |
82 |
< |
String timeFirstSince = DateUtils.formatTime(System.currentTimeMillis() - alert.getInitialAlertTime(), "%DAYS% days, %HOURS% hours, %MINS% mins, and %SECS% secs"); |
82 |
> |
String timeFirstSince = DateUtils.formatTime((System.currentTimeMillis() - alert.getInitialAlertTime())/1000, "%DAYS% days, %HOURS% hours, %MINS% mins, and %SECS% secs"); |
83 |
|
String timeFirstOccured = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, Locale.UK).format(new Date(alert.getInitialAlertTime())); |
84 |
|
// sort out the message |
85 |
|
String message; |
96 |
|
message = StringUtils.replaceText(message, "%value%", alert.getValue()); |
97 |
|
message = StringUtils.replaceText(message, "%thresholdValue%", alert.getThresholdValue()); |
98 |
|
message = StringUtils.replaceText(message, "%attributeName%", alert.getAttributeName()); |
99 |
< |
message = StringUtils.replaceText(message, "%timeTillNextAlert%", getTimeString(Long.parseLong(alert.getTimeTillNextAlert()))); |
99 |
> |
message = StringUtils.replaceText(message, "%timeTillNextAlert%", DateUtils.getTimeString(Long.parseLong(alert.getTimeTillNextAlert()))); |
100 |
|
message = StringUtils.replaceText(message, "%timeSinceFirstAlert%", timeFirstSince); |
101 |
|
message = StringUtils.replaceText(message, "%timeOfFirstAlert%", timeFirstOccured); |
102 |
|
|
138 |
|
|
139 |
|
//---PRIVATE METHODS--- |
140 |
|
|
141 |
– |
private String getTimeString(long time) { |
142 |
– |
String timeString = null; |
143 |
– |
if (time >= 60) { |
144 |
– |
timeString = (time / 60) + " minute(s)"; |
145 |
– |
} else if (time >= 3600) { |
146 |
– |
timeString = ((time/60) / 60) + " hour(s)"; |
147 |
– |
} else { |
148 |
– |
timeString = time + " second(s)"; |
149 |
– |
} |
150 |
– |
return timeString; |
151 |
– |
} |
152 |
– |
|
141 |
|
//---ACCESSOR/MUTATOR METHODS--- |
142 |
|
|
143 |
|
//---ATTRIBUTES--- |
519 |
|
endOfChan = newChan.length(); |
520 |
|
} |
521 |
|
newChan = newChan.substring(0, endOfChan); |
522 |
< |
sendMsg(getMsgSender(line)+", okay, I'm off to "+newChan); |
523 |
< |
_socketOut.println("PART "+_channel); |
524 |
< |
_socketOut.println("JOIN "+newChan); |
525 |
< |
_channel = newChan; |
522 |
> |
if(newChan.equals(_channel)) { |
523 |
> |
sendMsg(getMsgSender(line)+", I'm already on "+newChan+"!"); |
524 |
> |
} else { |
525 |
> |
sendMsg(getMsgSender(line)+", okay, I'm off to "+newChan); |
526 |
> |
_socketOut.println("PART "+_channel); |
527 |
> |
_socketOut.println("JOIN "+newChan); |
528 |
> |
_channel = newChan; |
529 |
> |
} |
530 |
|
} |
531 |
|
else if(message.indexOf(nickChangeCommand)!=-1) { |
532 |
|
String nickChangeCmd = nickChangeCommand; |