swarm: add support

Change-Id: I12ec5fd0d79c9cdda63f25e7d042e6836828833c
diff --git a/AutoAnswer/BotPeerChatSubscriber.cpp b/AutoAnswer/BotPeerChatSubscriber.cpp
index 26c6d30..c1e6761 100644
--- a/AutoAnswer/BotPeerChatSubscriber.cpp
+++ b/AutoAnswer/BotPeerChatSubscriber.cpp
@@ -59,13 +59,21 @@
     if (isAttached) {
         if (message->direction) {
             std::map<std::string, std::string> sendMsg;
-            for (auto& pair : message->data) {
-                if (pair.first == "text/plain" && pair.second == inText_) {
-                    sendMsg[pair.first] = textAnswer_;
+            if (message->fromHistory)
+                return;
+            if (!message->isSwarm)
+                for (auto& pair : message->data) {
+                    if (pair.first == "text/plain" && pair.second == inText_) {
+                        sendMsg[pair.first] = textAnswer_;
+                    }
                 }
+            else if (message->data.at("type") == "text/plain"
+                     && message->data.at("body") == inText_) {
+                sendMsg["type"] = "text/plain";
+                sendMsg["body"] = textAnswer_;
             }
             if (!sendMsg.empty()) {
-                sendText(message->accountId, message->peerId, sendMsg);
+                sendText(message->accountId, message->peerId, sendMsg, message->isSwarm);
             }
         }
     }
@@ -100,9 +108,15 @@
 void
 BotPeerChatSubscriber::sendText(std::string& accountId,
                                 std::string& peerId,
-                                std::map<std::string, std::string>& sendMsg)
+                                std::map<std::string, std::string>& sendMsg,
+                                bool swarm)
 {
-    pluginMessagePtr botAnswer = std::make_shared<JamiMessage>(accountId, peerId, false, sendMsg, true);
+    pluginMessagePtr botAnswer = std::make_shared<JamiMessage>(accountId,
+                                                               peerId,
+                                                               false,
+                                                               sendMsg,
+                                                               true);
+    botAnswer->isSwarm = swarm;
     api_->invokeService(api_, "sendTextMessage", botAnswer.get());
 }
 } // namespace jami