ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/server/uk/org/iscream/cms/server/client/alerters/IRC__Alerter.java
(Generate patch)

Comparing projects/cms/source/server/uk/org/iscream/cms/server/client/alerters/IRC__Alerter.java (file contents):
Revision 1.7 by tdb, Sat Mar 3 01:09:53 2001 UTC vs.
Revision 1.8 by ajm, Sun Mar 4 02:41:16 2001 UTC

# Line 50 | Line 50 | public class IRC__Alerter implements PluginAlerter {
50  
51      public void sendAlert(Alert alert) {
52          ConfigurationProxy cp = ConfigurationProxy.getInstance();
53 <        int level = Integer.parseInt(cp.getProperty(_name, "Alerter.IRC.level"));
53 >        String levelName = cp.getProperty(_name, "Alerter.IRC.level");
54 >        int level = StringUtils.getStringPos(levelName, Alert.alertLevels);
55          // only send if it's equal (or above) our level
56          if(alert.getLevel() >= level) {
57 <            String alertType = Alert.alerts[alert.getLevel()]+"["+String.valueOf(alert.getLevel())+"]";
57 >            String alertType = Alert.alertLevels[alert.getLevel()];
58 >            String thresholdType = Alert.thresholdLevels[alert.getThreshold()];
59              // sort out the message
60              String message = cp.getProperty(_name, "Alerter.IRC.message");
61              message = StringUtils.replaceText(message, "%level%", alertType);
62 +            message = StringUtils.replaceText(message, "%threshold%", thresholdType);
63              message = StringUtils.replaceText(message, "%source%", alert.getSource());
64              message = StringUtils.replaceText(message, "%value%", alert.getValue());
65              message = StringUtils.replaceText(message, "%thresholdValue%", alert.getThresholdValue());
66              message = StringUtils.replaceText(message, "%attributeName%", alert.getAttributeName());
67 +            message = StringUtils.replaceText(message, "%timeTillNextAlert%",  getTimeString(Long.parseLong(alert.getTimeTillNextAlert())));
68              
69              // send the message
70 <            _logger.write(toString(), Logger.DEBUG, "Sending IRC Alert at level"+String.valueOf(alert.getLevel()));
70 >            _logger.write(toString(), Logger.DEBUG, "Sending " + _name + " at "+ levelName + " level");
71              _ircbot.sendMsg(message);
72          }
73      }
# Line 93 | Line 97 | public class IRC__Alerter implements PluginAlerter {
97  
98   //---PRIVATE METHODS---
99  
100 +    private String getTimeString(long time) {
101 +        String timeString = null;
102 +        if (time >= 60) {
103 +            timeString = (time / 60) + " minute(s)";
104 +        } else if (time >= 3600) {
105 +            timeString = ((time/60) / 60) + " hour(s)";
106 +        } else {
107 +            timeString = time + " second(s)";
108 +        }
109 +        return timeString;
110 +    }
111 +
112   //---ACCESSOR/MUTATOR METHODS---
113  
114   //---ATTRIBUTES---
# Line 111 | Line 127 | public class IRC__Alerter implements PluginAlerter {
127       * can be placed here.  This name could also
128       * be changed to null for utility classes.
129       */
130 <    private String _name = ClientMain.NAME;
130 >    private String _name = "IRC Alert";
131  
132      /**
133       * This holds a reference to the

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines