Commits

David Lazar committed f8b463a

Support more time abbreviations.

Comments (0)

Files changed (1)

src/org/jibble/reminderbot/ReminderBot.java

 
     public synchronized void onMessage(String channel, String sender, String login, String hostname, String message) {
 
-        Pattern messagePattern = Pattern.compile("^\\s*(?i:(" + getNick() + ")?\\s*[\\:,]?\\s*remind\\s+me\\s+in\\s+(((\\d+\\.?\\d*|\\.\\d+)\\s*(years?|y|weeks?|days?|hours?|hrs?|minutes?|mins?|m|seconds?|secs?|s)[\\s,]*(and)?\\s+)+)(.*)\\s*)$");
+        Pattern messagePattern = Pattern.compile("^\\s*(?i:(" + getNick() + ")?\\s*[\\:,]?\\s*remind\\s+me\\s+in\\s+(((\\d+\\.?\\d*|\\.\\d+)\\s*(years?|y|weeks?|w|days?|d|hours?|hrs?|h|minutes?|mins?|m|seconds?|secs?|s)[\\s,]*(and)?\\s+)+)(.*)\\s*)$");
         Matcher m = messagePattern.matcher(message);
         if (m.matches()) {
             String reminderMessage = m.group(7);
 
             try {
                 double years = getPeriod(periods, "years|year|y"); // Julian year
-                double weeks = getPeriod(periods, "weeks|week");
-                double days = getPeriod(periods, "days|day");
-                double hours = getPeriod(periods, "hours|hrs|hour|hr");
+                double weeks = getPeriod(periods, "weeks|week|w");
+                double days = getPeriod(periods, "days|day|d");
+                double hours = getPeriod(periods, "hours|hrs|hour|hr|h");
                 double minutes = getPeriod(periods, "minutes|mins|minute|min|m");
                 double seconds = getPeriod(periods, "seconds|secs|second|sec|s");
                 due += (years * 31557600 + weeks * 604800 + days * 86400 + hours * 3600 + minutes * 60 + seconds) * 1000;