예제 #1
0
 public MircString stats(String duration) {
   // valid durations
   // all, year, month, week, day
   MircString mircString = new MircString();
   // default
   LocalDate dateFrom = LocalDate.now().minusYears(10);
   if (duration.equals("year")) {
     dateFrom = LocalDate.now().minusYears(1);
   } else if (duration.equals("month")) {
     dateFrom = LocalDate.now().minusMonths(1);
   } else if (duration.equals("week")) {
     dateFrom = LocalDate.now().minusWeeks(1);
   } else if (duration.equals("day")) {
     dateFrom = LocalDate.now().minusDays(1);
   }
   LocalDate dateTo = LocalDate.now();
   ArrayList<NicksAndLines> unsortedOutput = Statistics.topNicks(quotes, dateFrom, dateTo);
   ArrayList<NicksAndLines> output = NicksAndLines.sortDesc(unsortedOutput);
   StringBuffer stringBuffer = new StringBuffer();
   String initial = "Quote summary: ";
   stringBuffer.append(initial);
   for (int i = 0; i < output.size() && i < 10; i++) {
     if (i > 0) {
       stringBuffer.append(", ");
     }
     String tempString = output.get(i).getNick() + " - " + output.get(i).getLines();
     stringBuffer.append(tempString);
   }
   mircString = MircString.of(stringBuffer.toString());
   return mircString;
 }
예제 #2
0
 public MircString quotesToday() {
   quotes = ReadLog.load(file);
   LocalDate date = LocalDate.now();
   Long output = Statistics.dailyQuotes(quotes, date);
   System.out.println("quotecache output: " + output);
   String inputString = "Total quotes for today: " + output.toString();
   MircString string = MircString.of(inputString);
   return string;
 }
예제 #3
0
  public MircString whatDoesTheFoxSay() {
    MircString mircString = new MircString();
    try {
      File file = new File("whatdoesthefoxsay.txt");
      FileReader fileReader = new FileReader(file);
      BufferedReader bufferedReader = new BufferedReader(fileReader);
      ArrayList<String> stringBuffer = new ArrayList<String>();
      String line;
      while ((line = bufferedReader.readLine()) != null) {
        stringBuffer.add(line);
      }
      fileReader.close();
      Random rand = new Random();
      int n = rand.nextInt(stringBuffer.size()) + 0;
      mircString = MircString.of(stringBuffer.get(n));
    } catch (IOException e) {
      e.printStackTrace();
    }

    return mircString;
  }
예제 #4
0
 public MircString lanCountdown() {
   LocalDateTime lan = LocalDateTime.of(2016, 4, 29, 18, 0, 0);
   LocalDateTime now = LocalDateTime.now();
   Long seconds = now.until(lan, ChronoUnit.SECONDS);
   int totalSeconds = (60 * 60 * 24 * 365 * 1000);
   BigDecimal bigSeconds = new BigDecimal(totalSeconds);
   BigDecimal secondsLeft = new BigDecimal(seconds);
   BigDecimal millennia = secondsLeft.divide(bigSeconds, 50, RoundingMode.HALF_UP);
   String inputString =
       "There are "
           + seconds.toString()
           + " seconds to LAN - you'd better be prepared for it, mofos. Or, if you're Ragnar, there are "
           + millennia
           + " millennia left.";
   if (seconds < 0) {
     seconds = Math.abs(seconds);
     inputString = "LAN has been running for " + seconds.toString() + " seconds! Kick ass!";
   }
   MircString mircString = MircString.of(inputString.toString());
   return mircString;
 }
예제 #5
0
 public MircString randomSingleQuote() {
   String string = Statistics.randomSingleQuote(quotes);
   String outputString = "A random quote: " + string;
   MircString mircString = MircString.of(outputString);
   return mircString;
 }
예제 #6
0
 public MircString reddit(String subreddit) {
   MircString mircString = new MircString();
   String redditOutput = Reddit.redditTopLink(subreddit);
   mircString = MircString.of(redditOutput);
   return mircString;
 }