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)"); }
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."); }
private void nextRaid(Info info) { GregorianCalendar nextRaid = raids.get(info.getChannel()); GregorianCalendar now = Utils.getRealDate(info); int diffMins = (int) ((nextRaid.getTimeInMillis() - now.getTimeInMillis()) / 1000 / 60); if (nextRaid.compareTo(now) < 0) { info.sendMessage("There is no future raid set."); return; } String tz = info.getMessage().substring(9).trim(); tz = substituteTimeZone(tz); TimeZone timeZone; if (tz.length() == 0) timeZone = tZF("GMT"); else timeZone = tZF(tz); formatter.setTimeZone(timeZone); String ret = "The next raid is scheduled for " + formatter.format(nextRaid.getTime()); ret = ret + getTimeDifference(diffMins); info.sendMessage(ret); }
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."); } }
private void setTick(Info info) { tickSetter = info.getSender(); tickTime = System.currentTimeMillis(); OFFSET = Utils.getRealMinutes(info) % 15; info.sendMessage("Tick set to " + OFFSET + " minutes off."); }