Example #1
0
  public void doPost(HttpServletRequest request, HttpServletResponse response)
      throws IOException, ServletException {
    // Actual logic goes here.

    // System.out.print("Test");

    StringBuilder sb = new StringBuilder();
    try (BufferedReader reader = request.getReader()) {
      String line;
      while ((line = reader.readLine()) != null) {
        sb.append(line).append('\n');
      }
    }

    try {
      JSONObject jsonObject = new JSONObject(sb.toString());

      JSONObject message = jsonObject.getJSONObject("message");
      String command = message.getString("text");
      if (BotHelper.command(command, "/echo")) {
        functions.echo(jsonObject);
      } else if (BotHelper.command(command, "/engage")) {
        functions.engage(jsonObject);
      } else if (BotHelper.command(command, "/debug")) {
        functions.debugjson(jsonObject);
      } else if (BotHelper.command(command, "/amazon")) {
        functions.searchAmazon(jsonObject);
      } else if (BotHelper.command(command, "/decide")) {
        functions.decide(jsonObject);
      } else if (BotHelper.command(command, "/ohkadsewasessenwirheute")) {
        functions.ohkadsewasessenwirheute(jsonObject);
      } else if (BotHelper.command(command, "/ohmagischekadse")) {
        functions.ohmagischekadse(jsonObject);
      } else if (BotHelper.command(command, "/otherchat")) {
        functions.otherChat(jsonObject);
      } else if ((BotHelper.command(command, "/help")) || (BotHelper.command(command, "/?"))) {
        functions.help(jsonObject);
      } else {
        functions.unknown(jsonObject);
      }

    } catch (Exception e) {
      e.printStackTrace();
    }
  }