Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support slack markdown message #145

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions jbot/src/main/java/me/ramswaroop/jbot/core/slack/Bot.java
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,12 @@ protected final void reply(WebSocketSession session, Event event, Message reply)
}

protected final void reply(WebSocketSession session, Event event, String text) {
reply(session, event, text, false);
}

protected final void reply(WebSocketSession session, Event event, String text, boolean mrkdwn) {
Message message = new Message(text);
message.setMrkdwn(mrkdwn);
reply(session, event, new Message(text));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
reply(session, event, new Message(text));
reply(session, event, message);

Should it be passing in the message you build to the reply method?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, as you have built the message in the previous line, you can directly pass it to reply() method. Also, can you please share me the link to the Slack API documentation which shows the mrkdwn property?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i saw mrkdwn property from this url :)
https://api.slack.com/docs/message-formatting

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public class Message {
private String lastRead;
@JsonProperty("unread_count")
private int unreadCount;
private boolean mrkdwn;

public Message() {
}
Expand Down Expand Up @@ -181,6 +182,14 @@ public void setUnreadCount(int unreadCount) {
this.unreadCount = unreadCount;
}

public boolean isMrkdwn() {
return mrkdwn;
}

public void setMrkdwn(boolean mrkdwn) {
this.mrkdwn = mrkdwn;
}

public String toJSONString() throws JsonProcessingException {
return new ObjectMapper().writeValueAsString(this);
}
Expand Down