public class SlackManager extends Object
Constructor and Description |
---|
SlackManager(String apiToken)
Construct new slack manager object
|
Modifier and Type | Method and Description |
---|---|
HashMap<String,String> |
getEmailToUserIdMapping()
Get map where the key is user's emails and the corresponding value is their slack id.
|
List<com.github.seratch.jslack.api.model.User> |
getUserList()
Get list of all Slack users
|
Boolean |
handleSlackResponse(com.github.seratch.jslack.api.methods.SlackApiResponse resp)
Checks if the response contains an error or warning message, and returns true if the request
was successful.
|
String |
lookupUserIdByEmail(String email)
Get slack user id from their email.
|
com.github.seratch.jslack.api.methods.response.chat.ChatPostMessageResponse |
sendConfirmationRequestToUser(String userId,
String alertId,
String message)
Send message with confirmation request to slack user.
|
com.github.seratch.jslack.api.methods.response.chat.ChatPostMessageResponse |
sendMessageToChannel(String channelId,
String message)
Send message to slack channel.
|
public SlackManager(String apiToken)
apiToken
- Slack api tokenpublic com.github.seratch.jslack.api.methods.response.chat.ChatPostMessageResponse sendMessageToChannel(String channelId, String message) throws IOException, com.github.seratch.jslack.api.methods.SlackApiException
If it is a private channel, the bot must be invited to that channel first.
channelId
- Slack channel idmessage
- Message to be sentIOException
- IOExceptioncom.github.seratch.jslack.api.methods.SlackApiException
- SlackApiExceptionpublic String lookupUserIdByEmail(String email) throws IOException, com.github.seratch.jslack.api.methods.SlackApiException
email
- User's emailIOException
- IOExceptioncom.github.seratch.jslack.api.methods.SlackApiException
- SlackApiExceptionpublic HashMap<String,String> getEmailToUserIdMapping() throws IOException, com.github.seratch.jslack.api.methods.SlackApiException
IOException
- IOExceptioncom.github.seratch.jslack.api.methods.SlackApiException
- SlackApiExceptionpublic List<com.github.seratch.jslack.api.model.User> getUserList() throws IOException, com.github.seratch.jslack.api.methods.SlackApiException
IOException
- IOExceptioncom.github.seratch.jslack.api.methods.SlackApiException
- SlackApiExceptionpublic com.github.seratch.jslack.api.methods.response.chat.ChatPostMessageResponse sendConfirmationRequestToUser(String userId, String alertId, String message) throws IOException, com.github.seratch.jslack.api.methods.SlackApiException
userId
- Slack user id to send message toalertId
- Alert id to include in button callbackmessage
- Message to be sentIOException
- IOExceptioncom.github.seratch.jslack.api.methods.SlackApiException
- SlackApiExceptionpublic Boolean handleSlackResponse(com.github.seratch.jslack.api.methods.SlackApiResponse resp)
resp
- Slack api responseCopyright © 2022. All rights reserved.