com.github.seratch.jslack.api.methods.SlackApiException Java Examples

The following examples show how to use com.github.seratch.jslack.api.methods.SlackApiException. 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: SlackAppender.java    From arbitrader with MIT License 6 votes vote down vote up
@Override
protected void append(T eventObject) {
    ApplicationContext applicationContext = SpringContextSingleton.getInstance().getApplicationContext();

    if (applicationContext == null) {
        return;
    }

    NotificationConfiguration notificationConfiguration = (NotificationConfiguration) applicationContext.getBean("notificationConfiguration");

    try {
        Slack.getInstance().methods().chatPostMessage(ChatPostMessageRequest.builder()
                .token(notificationConfiguration.getSlack().getAccessToken())
                .asUser(false)
                .channel(notificationConfiguration.getSlack().getChannel())
                .text(eventObject.toString())
                .attachments(Collections.emptyList())
                .build());
    } catch (IOException | SlackApiException e) {
        // can't log here or we'll cause an endless loop...
    }
}
 
Example #2
Source File: SlackAuth.java    From jbpm-work-items with Apache License 2.0 6 votes vote down vote up
public ChatPostMessageResponse authChatPostMessageRequest(String channelId,
                                                          String accessToken,
                                                          String message) throws IllegalAccessError, IOException, SlackApiException {
    ChatPostMessageResponse chatMessageResponse = slack.methods().chatPostMessage(ChatPostMessageRequest.builder()
                                                                                          .channel(channelId)
                                                                                          .token(accessToken)
                                                                                          .text(message)
                                                                                          .replyBroadcast(false)
                                                                                          .build());

    if (!chatMessageResponse.isOk()) {
        throw new IllegalAccessError("Error authenticating chat message: " + chatMessageResponse.getError());
    }

    return chatMessageResponse;
}
 
Example #3
Source File: SlackAuth.java    From jbpm-work-items with Apache License 2.0 5 votes vote down vote up
public AuthTestResponse authBaseRequest(String accessToken) throws IllegalAccessError, IOException, SlackApiException {
    AuthTestResponse response = slack.methods().
            authTest(AuthTestRequest.builder().token(accessToken).build());
    if (!response.isOk()) {
        throw new IllegalAccessError("Error authenticating: " + response.getError());
    }

    return response;
}
 
Example #4
Source File: SlackAuth.java    From jbpm-work-items with Apache License 2.0 5 votes vote down vote up
public ChannelsListResponse authChannelListRequest(String accessToken) throws IllegalAccessError, IOException, SlackApiException {
    ChannelsListResponse channelListResponse = slack.methods().channelsList(
            ChannelsListRequest.builder().token(accessToken).build());

    if (!channelListResponse.isOk()) {
        throw new IllegalAccessError("Error authenticating channel list: " + channelListResponse.getError());
    }

    return channelListResponse;
}
 
Example #5
Source File: SlackAuth.java    From jbpm-work-items with Apache License 2.0 5 votes vote down vote up
public RemindersAddResponse authAddReminderRequest(String accessToken,
                                                   String reminderText,
                                                   String time) throws IllegalAccessError, IOException, SlackApiException {
    RemindersAddResponse addReminderResponse = slack.methods().remindersAdd(RemindersAddRequest.builder()
                                                                                    .token(accessToken)
                                                                                    .text(reminderText)
                                                                                    .time(time)
                                                                                    .build());

    if (!addReminderResponse.isOk()) {
        throw new IllegalAccessError("Error authenticating add reminder message: " + addReminderResponse.getError());
    }

    return addReminderResponse;
}