 */
 
 /*
- modified by chaeplin @ gmail.com
- */
+  modified by chaeplin @ gmail.com
+*/
 
 #include <Arduino.h>
 #include <ESP8266WiFi.h>
 #include <WiFiClientSecure.h>
 #include <ESP8266HTTPClient.h>
+// https://github.com/Links2004/arduinoWebSockets
 #include <WebSocketsClient.h>
+// https://github.com/bblanchon/ArduinoJson
 #include <ArduinoJson.h>
+// https://github.com/chaeplin/lgwhisen
+#include <lgWhisen.h>
+// https://github.com/markszabo/IRremoteESP8266
+#include <IRremoteESP8266.h>
 
 #include "/usr/local/src/ap_setting.h"
 #include "/usr/local/src/slack_setting.h"

  2. Conencts the WebSocket
  Returns true if the connection was established successfully.
*/
bool connectToSlack() {
  // Step 1: Find WebSocket address via RTM API (https://api.slack.com/methods/rtm.start)
  HTTPClient http;
  String uri_to_post = "/api/rtm.start?token=";

    case WStype_CONNECTED:
      Serial.printf("[WebSocket] Connected to: %s\n", payload);
      sendPing();
      webSocket.loop();
      sendHello();
      break;

    case WStype_TEXT:
      Serial.printf("[WebSocket] Message: %s\n", payload);

      String receivedpayload;
      for (int i = 0; i < len; i++)
      {
        receivedpayload += (char)payload[i];
      }
      if (receivedpayload.startsWith("{\"type\":\"message"))
      {
        if (receivedpayload.indexOf(SLACK_CHANNEL) != -1 &&
            receivedpayload.indexOf(SLACK_USER) != -1 &&
            receivedpayload.indexOf(SLACK_TEAM) != -1 )
        {
          if (len < 1024) {
            processSlackMessage(receivedpayload);
          }
        }
      }
      break;
  }
}
