allbegray.slack.webapi.method.chats.ChatPostMessageMethod Java Examples
The following examples show how to use
allbegray.slack.webapi.method.chats.ChatPostMessageMethod.
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: SlackNotifier.java From yfiton with Apache License 2.0 | 7 votes |
@Override protected void notify(Parameters parameters) throws NotificationException { SubnodeConfiguration config = retrieveTeamInformation(); if (config == null) { throw new NotificationException("Invalid configuration"); } SlackWebApiClient slackClient = SlackClientFactory.createWebApiClient(config.getString("accessToken")); ChatPostMessageMethod chatPostMessageMethod = new ChatPostMessageMethod(channel, message); chatPostMessageMethod.setAs_user(true); slackClient.postMessage(chatPostMessageMethod); log.info("https://" + config.getString("teamName") + ".slack.com/messages/" + channel + "/"); }
Example #2
Source File: SlackNotifier.java From yfiton with Apache License 2.0 | 6 votes |
@Override protected void notify(Parameters parameters) throws NotificationException { SubnodeConfiguration config = retrieveTeamInformation(); if (config == null) { throw new NotificationException("Invalid configuration"); } SlackWebApiClient slackClient = SlackClientFactory.createWebApiClient(config.getString("accessToken")); ChatPostMessageMethod chatPostMessageMethod = new ChatPostMessageMethod(channel, message); chatPostMessageMethod.setAs_user(true); slackClient.postMessage(chatPostMessageMethod); log.info("https://" + config.getString("teamName") + ".slack.com/messages/" + channel + "/"); }
Example #3
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) { ChatPostMessageMethod method = new ChatPostMessageMethod(channel, text); method.setUsername(username); method.setAs_user(as_user); return postMessage(method); }
Example #4
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 #5
Source File: SlackWebApiClientImpl.java From slack-api with MIT License | 5 votes |
@Override public String postMessage(ChatPostMessageMethod method) { if (method.getMapper() == null) { method.setMapper(mapper); } JsonNode retNode = call(method); return retNode.findPath("ts").asText(); }
Example #6
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; }
Example #7
Source File: BentenHtmlToSlackMsgConverter.java From benten with MIT License | 4 votes |
public static ChatPostMessageMethod transform(BentenHtmlResponse bentenHtmlResponse, String text, String channel) { ChatPostMessageMethod chatPostMessageMethod = new ChatPostMessageMethod(channel, text); Attachment attachment = new Attachment(); return chatPostMessageMethod; }
Example #8
Source File: SlackWebApiClientImpl.java From slack-api with MIT License | 4 votes |
@Override public String postMessage(String channel, String text) { return postMessage(new ChatPostMessageMethod(channel, text)); }
Example #9
Source File: ChatApi.java From slack-api with MIT License | votes |
String postMessage(ChatPostMessageMethod method);