Пример #1
0
 @GET
 @Produces(MediaType.APPLICATION_JSON)
 @Path("whatdoesthefoxsay")
 public Response whatDoesTheFoxSay() {
   MircString quote = QuoteCache.INST.whatDoesTheFoxSay();
   Response resp = null;
   if (quote.toString() != "") {
     resp = Response.ok(quote).build();
     // TaskCache.INST.incrementTask(task);
   } else {
     resp = Response.noContent().build();
   }
   return resp;
 }
Пример #2
0
 @GET
 @Produces(MediaType.APPLICATION_JSON)
 @Path("oppa")
 public Response gangnamStyle() {
   MircString quote = QuoteCache.INST.gangnamStyle();
   Response resp = null;
   if (quote.toString() != "") {
     resp = Response.ok(quote).build();
     // TaskCache.INST.incrementTask(task);
   } else {
     resp = Response.noContent().build();
   }
   return resp;
 }
Пример #3
0
 @GET
 @Produces(MediaType.APPLICATION_JSON)
 @Path("stats/{duration}")
 public Response stats(@PathParam("duration") String duration) {
   MircString quote = QuoteCache.INST.stats(duration);
   Response resp = null;
   if (quote.toString() != "") {
     resp = Response.ok(quote).build();
     // TaskCache.INST.incrementTask(task);
   } else {
     resp = Response.noContent().build();
   }
   return resp;
 }
Пример #4
0
 @GET
 @Produces(MediaType.APPLICATION_JSON)
 @Path("reddit/{subreddit}")
 public Response reddit(@PathParam("subreddit") String subreddit) {
   System.out.println("subreddit string is: " + subreddit);
   MircString quote = QuoteCache.INST.reddit(subreddit);
   Response resp = null;
   if (quote.toString() != "") {
     resp = Response.ok(quote).build();
     // TaskCache.INST.incrementTask(task);
   } else {
     resp = Response.noContent().build();
   }
   return resp;
 }
Пример #5
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;
 }
Пример #6
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;
 }
Пример #7
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;
  }
Пример #8
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;
 }
Пример #9
0
 public MircString randomSingleQuote() {
   String string = Statistics.randomSingleQuote(quotes);
   String outputString = "A random quote: " + string;
   MircString mircString = MircString.of(outputString);
   return mircString;
 }
Пример #10
0
 public MircString reddit(String subreddit) {
   MircString mircString = new MircString();
   String redditOutput = Reddit.redditTopLink(subreddit);
   mircString = MircString.of(redditOutput);
   return mircString;
 }