Ejemplo n.º 1
0
 private void setTick(Info info, String time) {
   int addon = 0;
   try {
     addon = Integer.parseInt(time);
   } catch (NumberFormatException e) {
     info.sendMessage(
         "Format exception.  Command should be !setTick # where # is the number of minutes till the next tick.");
   }
   tickSetter = info.getSender();
   tickTime = System.currentTimeMillis();
   OFFSET = (Utils.getRealMinutes(info) + addon) % 15;
   info.sendMessage("Tick set to " + OFFSET + " minutes off.");
 }
Ejemplo n.º 2
0
 private void tick(Info info) {
   if (Utils.shouldDefer(info)) return;
   // else
   if (OFFSET == -1) {
     info.sendMessage(
         "Tick not sychronized yet. Wait for the next tick and execute /msg "
             + info.getBot().getName()
             + " !setTickor find out how long until the next tick and execute /msg "
             + info.getBot().getName()
             + " !setTick <mins>");
     return;
   }
   int timeRemaining = 15 - ((15 + Utils.getRealMinutes(info) - OFFSET) % 15);
   long daysSinceSet = (System.currentTimeMillis() - tickTime) / (1000 * 60 * 60 * 24);
   info.sendMessage(
       timeRemaining + " minutes until the next tick (last set " + daysSinceSet + " days ago)");
 }
Ejemplo n.º 3
0
 private void tickAlarm(Info info) {
   if (OFFSET == -1) {
     info.sendMessage(
         "Tick not sychronized yet. Wait for the next tick and execute /msg "
             + info.getBot().getName()
             + " !setTick or find out how long until the next tick and execute /msg "
             + info.getBot().getName()
             + " !setTick <mins>");
     return;
   }
   int timeRemaining = 15 - ((15 + Utils.getRealMinutes(info) - OFFSET) % 15);
   if (timeRemaining < 2) {
     info.sendMessage(Colors.BLUE + Colors.BOLD + "The tick is in " + timeRemaining + " minutes.");
   } else {
     PingTask ptask = new PingTask(info, "the tick is in one minute.");
     timer.schedule(ptask, (int) ((timeRemaining - 1) * 60 * 1000));
     info.sendMessage("I'll alert you.");
   }
 }
Ejemplo n.º 4
0
 private void setTick(Info info) {
   tickSetter = info.getSender();
   tickTime = System.currentTimeMillis();
   OFFSET = Utils.getRealMinutes(info) % 15;
   info.sendMessage("Tick set to " + OFFSET + " minutes off.");
 }