diff --git a/jbot/src/main/java/me/ramswaroop/jbot/core/slack/Bot.java b/jbot/src/main/java/me/ramswaroop/jbot/core/slack/Bot.java index 025e192f..de3b8452 100644 --- a/jbot/src/main/java/me/ramswaroop/jbot/core/slack/Bot.java +++ b/jbot/src/main/java/me/ramswaroop/jbot/core/slack/Bot.java @@ -1,8 +1,7 @@ package me.ramswaroop.jbot.core.slack; import com.fasterxml.jackson.databind.ObjectMapper; -import me.ramswaroop.jbot.core.slack.models.Event; -import me.ramswaroop.jbot.core.slack.models.Message; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -14,13 +13,23 @@ import org.springframework.web.socket.client.WebSocketConnectionManager; import org.springframework.web.socket.client.standard.StandardWebSocketClient; -import javax.annotation.PostConstruct; import java.io.IOException; import java.lang.reflect.Method; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Queue; import java.util.regex.Matcher; import java.util.regex.Pattern; +import javax.annotation.PostConstruct; + +import me.ramswaroop.jbot.core.slack.models.Event; +import me.ramswaroop.jbot.core.slack.models.Message; + /** * Base class for making Slack Bots. Any class extending * this will get all powers of a Slack Bot. @@ -234,7 +243,9 @@ public boolean isConversationOn(Event event) { */ public final void reply(WebSocketSession session, Event event, Message reply) { try { - reply.setType(EventType.MESSAGE.name().toLowerCase()); + if (StringUtils.isEmpty(reply.getType())) { + reply.setType(EventType.MESSAGE.name().toLowerCase()); + } reply.setText(encode(reply.getText())); if (reply.getChannel() == null && event.getChannelId() != null) { reply.setChannel(event.getChannelId()); diff --git a/jbot/src/main/java/me/ramswaroop/jbot/core/slack/models/Attachment.java b/jbot/src/main/java/me/ramswaroop/jbot/core/slack/models/Attachment.java index 9b2ec20a..a7bde942 100644 --- a/jbot/src/main/java/me/ramswaroop/jbot/core/slack/models/Attachment.java +++ b/jbot/src/main/java/me/ramswaroop/jbot/core/slack/models/Attachment.java @@ -3,6 +3,8 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + /** * Created by ramswaroop on 12/06/2016. */ @@ -31,6 +33,9 @@ public class Attachment { private String footerIcon; private String ts; + @JsonProperty("mrkdwn_in") + private List markdownIn; + public String getFallback() { return fallback; } @@ -150,5 +155,13 @@ public String getTs() { public void setTs(String ts) { this.ts = ts; } + + public List getMarkdownIn() { + return markdownIn; + } + + public void setMarkdownIn(List markdownIn) { + this.markdownIn = markdownIn; + } }