Java Code Examples for allbegray.slack.webapi.method.chats.ChatPostMessageMethod#setAttachments()
The following examples show how to use
allbegray.slack.webapi.method.chats.ChatPostMessageMethod#setAttachments() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SlackWebApiClientImpl.java From slack-api with MIT License | 5 votes |
@Override public String postMessage(String channel, String text, String username, boolean as_user, boolean link_names, List<Attachment> attachments, boolean unfurl_links, boolean unfurl_media, String icon_url, String icon_emoji) { ChatPostMessageMethod method = new ChatPostMessageMethod(channel, text); method.setUsername(username); method.setLink_names(link_names); method.setAttachments(attachments); method.setUnfurl_links(unfurl_links); method.setUnfurl_media(unfurl_media); method.setIcon_url(icon_url); method.setIcon_emoji(icon_emoji); return postMessage(method); }
Example 2
Source File: BentenSlackToSlackMsgConverter.java From benten with MIT License | 4 votes |
public static ChatPostMessageMethod transform(BentenSlackResponse bentenSlackResponse, String text, String channel) { if (text == null) { text = ""; } ChatPostMessageMethod chatPostMessageMethod = new ChatPostMessageMethod(channel, text); if (bentenSlackResponse.getBentenSlackAttachments() != null && !bentenSlackResponse.getBentenSlackAttachments().isEmpty()) { List<BentenSlackAttachment> bentenSlackAttachments = bentenSlackResponse.getBentenSlackAttachments(); List<Attachment> attachments = new ArrayList<Attachment>(); for (BentenSlackAttachment bentenSlackAttachment : bentenSlackAttachments) { List<BentenSlackField> bentenSlackFields = bentenSlackAttachment.getBentenSlackFields(); List<Field> fields = new ArrayList<Field>(); if(!bentenSlackFields.isEmpty()){ for (BentenSlackField bentenSlackField : bentenSlackFields) { Field field = new Field(bentenSlackField.getTitle(), bentenSlackField.getValue(), bentenSlackField.isShort()); fields.add(field); } } Attachment attachment = new Attachment(); attachment.setFields(fields); if (bentenSlackAttachment.getColor() != null) { attachment.setColor(Color.valueOf(bentenSlackAttachment.getColor())); } else { attachment.setColor(Color.GOOD); } attachments.add(attachment); if(bentenSlackAttachment.getTitle() != null) { attachment.setTitle(bentenSlackAttachment.getTitle()); } if(bentenSlackAttachment.getTitle_link() != null){ attachment.setTitle_link(bentenSlackAttachment.getTitle_link()); } if(bentenSlackAttachment.getPretext() != null){ attachment.setPretext(bentenSlackAttachment.getPretext()); } if(bentenSlackAttachment.getText() != null){ attachment.setText(bentenSlackAttachment.getText()); } if(bentenSlackAttachment.getImage_url() != null){ attachment.setImage_url(bentenSlackAttachment.getImage_url()); } if(bentenSlackAttachment.getThumb_url() != null){ attachment.setThumb_url(bentenSlackAttachment.getThumb_url()); } } chatPostMessageMethod.setAttachments(attachments); } return chatPostMessageMethod; }