Git Product home page Git Product logo

slack-api's Introduction

Release

slack-api

A Java client for the Slack Web API, Incoming Webhooks, Slackbot Remote Control, RTM(Real Time Messaging) API

Maven

Step 1. Add the JitPack repository to your build file

<repository>
    <id>jitpack.io</id>
    <url>https://jitpack.io</url>
</repository>

Step 2. Add the dependency in the form

<dependency>
    <groupId>com.github.allbegray</groupId>
    <artifactId>slack-api</artifactId>
    <version>v1.7.0.RELEASE</version>
</dependency>

Change Logs

v1.7.0.RELEASE

merge async-http-client version update to 2.4.5 #49
merge Get bot id, bot acess token and get bot user id #50

v1.6.0.RELEASE

merge Add reply broadcast flag #43
merge Adjust code indentation on README #45
merge add specific exception if hitting rate limits #46
merge fix create group param #47

v1.5.1.RELEASE

merge add threads support #37
merge RestUtils logs verbosity reduced #39
merge Don't check webhookUrl #40

Slack Web API compatibility

auth, bots, channels, chat, dnd, emoji, files.comments. files, groups, im, mpim, oauth, pins, reactions, reminders, rtm, stars, team, usergroups, usergroups.users, users

public interface SlackWebApiClient {
	
    void shutdown();

    // auth

    Authentication auth();

    void setWebApiUrl(String webApiUrl);
      
    String getWebApiUrl();

    // bots

    Bot getBotInfo(String bot);

    // channels

    boolean archiveChannel(String channel);
    Channel createChannel(String name);
    History getChannelHistory(String channel);
    History getChannelHistory(String channel, int count);
    History getChannelHistory(String channel, String latest, String oldest, boolean inclusive, int count, boolean unreads);
    Channel getChannelInfo(String channel);
    Channel inviteUserToChannel(String channel, String user);
    Channel joinChannel(String name);
    boolean kickUserFromChannel(String channel, String user);
    boolean leaveChannel(String channel);
    List<Channel> getChannelList();
    List<Channel> getChannelList(boolean exclude_archived);
    boolean markChannel(String channel, String ts);
    Channel renameChannel(String channel, String name);
    boolean setChannelPurpose(String channel, String purpose);
    boolean setChannelTopic(String channel, String topic);
    boolean unarchiveChannel(String channel);

    // chat

    boolean deleteMessage(String channel, String ts);
    boolean meMessage(String channel, String text);
    String postMessage(String channel, String text);
    String postMessage(String channel, String text, String username, boolean as_user);
    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);
    String postMessage(ChatPostMessageMethod method);
    String updateMessage(String channel, String ts, String text);
    String updateMessage(String channel, String ts, String text, List<Attachment> attachments, boolean link_names);

    // dnd

    boolean endDnd();
    EndSnooze endSnooze();
    SetSnooze setSnooze(int num_minutes);
    DndInfo getDndInfo();
    DndInfo getDndInfo(String user);
    Map<String, DndSimpleInfo> getDndTeamInfo();
    Map<String, DndSimpleInfo> getDndTeamInfo(List<String> users);

    // emoji

    Map<String, String> getEmojiList();

    // files.comments

    Comment addFileComment(String file, String comment);
    Comment editFileComment(String file, String id, String comment);
    boolean deleteFileComment(String file, String id);

    // files

    boolean deleteFile(String file);
    FileInfo getFileInfo(String file);
    FileInfo getFileInfo(String file, int page);
    FileInfo getFileInfo(String file, int page, int count);
    FileList getFileList();
    FileList getFileList(int page);
    FileList getFileList(int page, int count);
    FileList getFileList(String user);
    FileList getFileList(String user, int page);
    FileList getFileList(String user, int page, int count);
    FileList getFileList(String user, String ts_from, String ts_to, String types, int page, int count);
    File revokeFilePublicURL(String file);
    File sharedFilePublicURL(String file);
    File uploadFile(java.io.File file, String title, String initial_comment, String channels);
    File uploadFile(java.io.File file, String filetype, String filename, String title, String initial_comment, String channels);
    File uploadFile(InputStream is, String filetype, String filename, String title, String initial_comment, String channels);

    // groups

    boolean archiveGroup(String channel);
    boolean closeGroup(String channel);
    Group createGroup(String name);
    Group createChildGroup(String name);
    History getGroupHistory(String channel);
    History getGroupHistory(String channel, int count);
    History getGroupHistory(String channel, String latest, String oldest, boolean inclusive, int count, boolean unreads);
    Group getGroupInfo(String channel);
    Group inviteUserToGroup(String channel, String user);
    boolean kickUserFromGroup(String channel, String user);
    boolean leaveGroup(String channel);
    List<Group> getGroupList();
    List<Group> getGroupList(boolean exclude_archived);
    boolean markGroup(String channel, String ts);
    boolean openGroup(String channel);
    Group renameGroup(String channel, String name);
    boolean setGroupPurpose(String channel, String purpose);
    boolean setGroupTopic(String channel, String topic);
    boolean unarchiveGroup(String channel);

    // im (direct message channel)

    boolean closeDirectMessageChannel(String channel);
    History getDirectMessageChannelHistory(String channel);
    History getDirectMessageChannelHistory(String channel, int count);
    History getDirectMessageChannelHistory(String channel, String latest, String oldest, boolean inclusive, int count, boolean unreads);
    List<DirectMessageChannel> getDirectMessageChannelList();
    boolean markDirectMessageChannel(String channel, String ts);
    String openDirectMessageChannel(String user);

    // mpim (multiparty direct message channel)

    boolean closeMultipartyDirectMessageChannel(String channel);
    History getMultipartyDirectMessageChannelHistory(String channel);
    History getMultipartyDirectMessageChannelHistory(String channel, int count);
    History getMultipartyDirectMessageChannelHistory(String channel, String latest, String oldest, boolean inclusive, int count, boolean unreads);
    List<Group> getMultipartyDirectMessageChannelList();
    boolean markMultipartyDirectMessageChannel(String channel, String ts);
    Group openMultipartyDirectMessageChannel(String... users);
    Group openMultipartyDirectMessageChannel(List<String> users);

    // oauth

    OAuthAccessToken accessOAuth(String client_id, String client_secret, String code, String redirect_uri);

    // pins

    boolean pinFile(String channel, String file);
    boolean pinFileComment(String channel, String file_comment);
    boolean pinMessage(String channel, String timestamp);
    List<PinItem> getPinList(String channel);
    boolean unpinFile(String channel, String file);
    boolean unpinFileComment(String channel, String file_comment);
    boolean unpinMessage(String channel, String timestamp);

    // reactions

    boolean addReactionToFile(String emojiName, String file);
    boolean addReactionToFileComment(String emojiName, String file_comment);
    boolean addReactionToMessage(String emojiName, String channel, String timestamp);
    ReactionItem getReactionByFile(String emojiName, String file);
    ReactionItem getReactionByFileComment(String emojiName, String file_comment);
    ReactionItem getReactionByMessage(String emojiName, String channel, String timestamp);
    ReactionList getReactionList(int page);
    ReactionList getReactionList(int page, int count);
    ReactionList getReactionList(String user, int page);
    ReactionList getReactionList(String user, int page, int count);
    boolean removeReactionFromFile(String emojiName, String file);
    boolean removeReactionFromFileComment(String emojiName, String file_comment);
    boolean removeReactionFromMessage(String emojiName, String channel, String timestamp);

    // reminders
    boolean addReminder(String text, String time);
    boolean addReminder(String text, long time);
    boolean completeReminder(String reminderId);
    boolean deleteReminder(String reminderId);
    ReminderInfo getReminderInfo(String reminderId);
    ReminderList getReminderList();

    // rtm

    JsonNode startRealTimeMessagingApi();
    JsonNode startRealTimeMessagingApi(String simple_latest, String no_unreads, String mpim_aware);

    // stars

    boolean addStarToFile(String file);
    boolean addStarToFileComment(String file_comment);
    boolean addStarToMessage(String channel, String timestamp);
    StarList getStarList(int page);
    StarList getStarList(int page, int count);
    StarList getStarList(String user, int page);
    StarList getStarList(String user, int page, int count);
    boolean removeStarFromFile(String file);
    boolean removeStarFromFileComment(String file_comment);
    boolean removeStarFromMessage(String channel, String timestamp);

    // team

    TeamAccessLogList getTeamAccessLogList(int page);
    TeamAccessLogList getTeamAccessLogList(int page, int count);
    Team getTeamInfo();
    TeamIntegrationLogList getTeamIntegrationLogList(int page);
    TeamIntegrationLogList getTeamIntegrationLogList(int page, int count);
    TeamIntegrationLogList getTeamIntegrationLogList(String service_id, String app_id, String user, String change_type, int page, int count);

    // usergroups

    Usergroup createUsergroup(String name, String handle, String description, List<String> channels);
    Usergroup createUsergroup(String name, String handle, String description, List<String> channels, boolean include_count);
    Usergroup disableUsergroup(String usergroup);
    Usergroup disableUsergroup(String usergroup, boolean include_count);
    Usergroup enableUsergroup(String usergroup);
    Usergroup enableUsergroup(String usergroup, boolean include_count);
    List<Usergroup> getUsergroupList();
    List<Usergroup> getUsergroupList(boolean include_disabled, boolean include_count, boolean include_users);
    Usergroup updateUsergroup(String name, String handle, String description, List<String> channels);
    Usergroup updateUsergroup(String name, String handle, String description, List<String> channels, boolean include_count);

    // usergroups.users

    List<String> getUsergroupUserList(String usergroup);
    List<String> getUsergroupUserList(String usergroup, boolean include_disabled);
    Usergroup updateUsergroupUser(String usergroup, List<String> users);
    Usergroup updateUsergroupUser(String usergroup, List<String> users, boolean include_count);

    // users

    UserPresence getUserPresence(String user);
    User getUserInfo(String user);
    User lookupUserByEmail(String email);
    List<User> getUserList();
    List<User> getUserListWithPresence();
    boolean setActiveUser();
    boolean setPresenceUser(Presence presence);

}

Slack client factory

SlackWebApiClient webApiClient = SlackClientFactory.createWebApiClient(token);

SlackWebhookClient webhookClient = SlackClientFactory.createWebhookClient(webhookUrl);

SlackbotClient slackbotClient = SlackClientFactory.createSlackbotClient(slackbotUrl);

SlackRealTimeMessagingClient rtmClient = SlackClientFactory.createSlackRealTimeMessagingClient(String token)

Coming soon next

search

slack-api's People

Contributors

abadongutierrez avatar allbegray avatar alucryd avatar h7io avatar kaktooss avatar ldreux avatar ngsilverman avatar peralta avatar pschroen avatar rdanci-neo avatar seratch avatar timbuethe avatar yamada-masa avatar zerpet avatar zolv avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

slack-api's Issues

uploadFile doesn't work work with non-English text comments

I'm using this api in my Android app to send a slack message containing a screenshot and some diagnostic text, which is in the initial comment. Everything works great when the text is in English, but with non-English characters the comments show up as question marks in Slack. My guess is that the text is being encoded incorrectly.

Here's the call I make:

webApiClient.uploadFile(feedback.screenshotFile, "screenshot", "가다" , channel);

Strangely, this problem doesn't occur with postMessage, the text is encoded correctly and is shown correctly in Slack.

Thanks in advance!

get presence status of users

Hello! I use Slack Api and every changes in user profile and messages converted to json and stored in aws s3.After that from that json I get necessary for me informaion.Now I need user active/away status so how can I get it from slack? presence_change event does not work because ``Compatibility:RTM```.Any other suggestions?

Pull requests failing

The Travis build associated with pull requests seems to be failing at the compile stage with:

"Fatal error compiling: invalid target release: 1.8 "

同学,您这个项目引入了26个开源组件,存在65个漏洞,辛苦升级一下

检测到 allbegray/slack-api 一共引入了26个开源组件,存在65个漏洞

漏洞标题:netty 安全漏洞
缺陷组件:io.netty:[email protected]
漏洞编号:CVE-2021-37136
漏洞描述:Netty是Netty社区的一款非阻塞I/O客户端-服务器框架,它主要用于开发Java网络应用程序,如协议服务器和客户端等。
netty存在安全漏洞,该漏洞源于Bzip2 decompression decoder功能不允许对解压输出数据设置大小限制(这会影响解压期间使用的分配大小)。攻击者可利用该漏洞引发DoS攻击。
影响范围:(∞, 4.1.68.Final)
最小修复版本:4.1.68.Final
缺陷组件引入路径:allbegray:[email protected]>org.asynchttpclient:[email protected]>io.netty:[email protected]>io.netty:[email protected]

另外还有65个漏洞,详细报告:https://mofeisec.com/jr?p=i9ac74

Possibility to send messages through the RTM connection

The API currently doesn't allow it.

Fyi I've tried to add the following code to SlackRealTimeMessagingClient:

public void sendTypingEvent(String channel) {
    ObjectNode message = mapper.createObjectNode();
    message.set("id", TextNode.valueOf("1"));
    message.set("type", TextNode.valueOf("typing"));
    message.set("channel", TextNode.valueOf(channel));
    logger.info("Sending typing event: " + channel);
    webSocket.sendMessage(message.toString().getBytes());
}

However when I invoke this method, the message doesn't seem to get sent and the channel gets closed. Any idea of what I'm doing wrong?

SlackRealTimeMessagingClient stops receiving after aprox. 3 minutes

Here's the log:

Connecting to APIs
Connecting to Slack API
Dec 15, 2015 6:09:15 PM flowctrl.integration.slack.RestUtils execute
INFO: url : https://slack.com/api/rtm.start
Dec 15, 2015 6:09:16 PM flowctrl.integration.slack.RestUtils execute
INFO: return : {"ok":true,"self":{"id":"U0GKH20HL","name":"gilmore","prefs":{"highlight_words":"","user_colors":"","color_names_in_list":true,"growls_enabled":true,"tz":null,"push_dm_alert":true,"push_mention_alert":true,"push_everything":false,"push_idle_wait":2,"push_sound":"b2.mp3","push_loud_channels":"","push_mention_channels":"","push_loud_channels_set":"","email_alerts":"instant","email_alerts_sleep_until":0,"email_misc":true,"email_weekly":true,"welcome_message_hidden":false,"all_channels_loud":false,"loud_channels":"","never_channels":"","loud_channels_set":"","show_member_presence":true,"search_sort":"timestamp","expand_inline_imgs":true,"expand_internal_inline_imgs":true,"expand_snippets":false,"posts_formatting_guide":true,"seen_welcome_2":false,"seen_ssb_prompt":false,"seen_spaces_new_xp_tooltip":false,"spaces_new_xp_banner_dismissed":false,"search_only_my_channels":false,"emoji_mode":"default","emoji_use":"","has_invited":false,"has_uploaded":false,"has_created_channel":false,"search_exclude_channels":"","messages_theme":"default","webapp_spellcheck":true,"no_joined_overlays":false,"no_created_overlays":false,"dropbox_enabled":false,"seen_domain_invite_reminder":false,"seen_member_invite_reminder":false,"mute_sounds":false,"arrow_history":false,"tab_ui_return_selects":true,"obey_inline_img_limit":true,"new_msg_snd":"knock_brush.mp3","collapsible":false,"collapsible_by_click":true,"require_at":true,"ssb_space_window":"","mac_ssb_bounce":"","mac_ssb_bullet":true,"expand_non_media_attachments":true,"show_typing":true,"pagekeys_handled":true,"last_snippet_type":"","display_real_names_override":0,"time24":false,"enter_is_special_in_tbt":false,"graphic_emoticons":false,"convert_emoticons":true,"autoplay_chat_sounds":true,"ss_emojis":true,"sidebar_behavior":"","seen_onboarding_start":false,"onboarding_cancelled":false,"seen_onboarding_slackbot_conversation":false,"seen_onboarding_channels":false,"seen_onboarding_direct_messages":false,"seen_onboarding_invites":false,"seen_onboarding_search":false,"seen_onboarding_recent_mentions":false,"seen_onboarding_starred_items":false,"seen_onboarding_private_groups":false,"onboarding_slackbot_conversation_step":0,"dnd_enabled":null,"dnd_start_hour":null,"dnd_end_hour":null,"mark_msgs_read_immediately":true,"start_scroll_at_oldest":true,"snippet_editor_wrap_long_lines":false,"ls_disabled":false,"sidebar_theme":"default","sidebar_theme_custom_values":"","f_key_search":false,"k_key_omnibox":true,"speak_growls":false,"mac_speak_voice":"com.apple.speech.synthesis.voice.Alex","mac_speak_speed":250,"comma_key_prefs":false,"at_channel_suppressed_channels":"","push_at_channel_suppressed_channels":"","prompted_for_email_disabling":false,"full_text_extracts":false,"no_text_in_notifications":false,"muted_channels":"","no_macssb1_banner":false,"no_winssb1_banner":false,"no_omnibox_in_channels":false,"k_key_omnibox_auto_hide_count":0,"hide_user_group_info_pane":false,"mentions_exclude_at_user_groups":false,"privacy_policy_seen":true,"search_exclude_bots":false,"fuzzy_matching":false,"load_lato_2":false,"fuller_timestamps":false,"last_seen_at_channel_warning":0,"flex_resize_window":false,"msg_preview":false,"msg_preview_displaces":true,"msg_preview_persistent":true,"emoji_autocomplete_big":false,"winssb_run_from_tray":true,"winssb_window_flash_behavior":"idle","two_factor_auth_enabled":false,"two_factor_type":null,"two_factor_backup_type":null,"mentions_exclude_at_channels":true,"confirm_clear_all_unreads":true,"confirm_user_marked_away":true,"box_enabled":false,"seen_single_emoji_msg":false,"confirm_sh_call_start":true,"preferred_skin_tone":"","show_all_skin_tones":false,"separate_private_channels":false,"whats_new_read":1450127241},"created":1450127241,"manual_presence":"active"},"team":{"id":"T08G18M1V","name":"Critical Role","email_domain":"joshuaslik.nl","domain":"criticalrole","msg_edit_window_mins":-1,"prefs":{"default_channels":["C08G1J40H","C0A4X144R","C08G18YSJ"],"posts_migrating":0,"who_can_create_channels":"regular","who_can_archive_channels":"regular","who_can_create_groups":"ra","who_can_kick_channels":"admin","who_can_kick_groups":"regular","who_can_at_everyone":"admin","who_can_at_channel":"ra","who_can_post_general":"admin","warn_before_at_channel":"always","slackbot_responses_disabled":false,"slackbot_responses_only_admins":true,"emoji_only_admins":true,"loading_only_admins":true,"disable_builtin_loading":true,"dnd_enabled":false,"dnd_start_hour":"22:00","dnd_end_hour":"08:00","msg_edit_window_mins":-1,"allow_message_deletion":true,"hide_referers":true,"display_real_names":false,"allow_shared_channels":false,"who_has_team_visibility":"ra","who_can_create_delete_user_groups":"admin","who_can_edit_user_groups":"admin","who_can_change_team_profile":"admin","retention_type":0,"retention_duration":0,"group_retention_type":0,"group_retention_duration":0,"dm_retention_type":0,"dm_retention_duration":0,"file_retention_type":0,"file_retention_duration":0,"allow_retention_override":true,"require_at_for_mention":0,"compliance_export_start":0,"invites_only_admins":true,"auth_mode":"normal","who_can_manage_integrations":{"type":["regular"]}},"icon":{"image_34":"https:\/\/s3-us-west-2.amazonaws.com\/slack-files2\/avatars\/2015-09-28\/11469922624_307f18a226545c5720a2_34.jpg","image_44":"https:\/\/s3-us-west-2.amazonaws.com\/slack-files2\/avatars\/2015-09-28\/11469922624_307f18a226545c5720a2_44.jpg","image_68":"https:\/\/s3-us-west-2.amazonaws.com\/slack-files2\/avatars\/2015-09-28\/11469922624_307f18a226545c5720a2_68.jpg","image_88":"https:\/\/s3-us-west-2.amazonaws.com\/slack-files2\/avatars\/2015-09-28\/11469922624_307f18a226545c5720a2_88.jpg","image_102":"https:\/\/s3-us-west-2.amazonaws.com\/slack-files2\/avatars\/2015-09-28\/11469922624_307f18a226545c5720a2_102.jpg","image_132":"https:\/\/s3-us-west-2.amazonaws.com\/slack-files2\/avatars\/2015-09-28\/11469922624_307f18a226545c5720a2_132.jpg","image_original":"https:\/\/s3-us-west-2.amazonaws.com\/slack-files2\/avatars\/2015-09-28\/11469922624_307f18a226545c5720a2_original.jpg"},"over_storage_limit":false,"plan":"","profile":{"fields":[{"id":"Xf0DAZ8LH5","ordering":0,"label":"Skype","hint":"This will be displayed on your profile.","type":"text","possible_values":null,"options":null,"is_hidden":false}]},"over_integrations_limit":true},"latest_event_ts":"1450198733.000000","channels":[{"id":"C0BCK31R8","name":"discussion","is_channel":true,"created":1443313022,"creator":"U08G18M2B","is_archived":false,"is_general":false,"has_pins":false,"is_member":false},{"id":"C08G1J40H","name":"general","is_channel":true,"created":1438561704,"creator":"U08G18M2B","is_archived":false,"is_general":true,"has_pins":false,"is_member":false},{"id":"C0A4X144R","name":"questions","is_channel":true,"created":1441317843,"creator":"U08G18M2B","is_archived":false,"is_general":false,"has_pins":false,"is_member":false},{"id":"C08G18YSJ","name":"random","is_channel":true,"created":1438561704,"creator":"U08G18M2B","is_archived":false,"is_general":false,"has_pins":false,"is_member":false},{"id":"C0B7DBRT2","name":"reddit","is_channel":true,"created":1443044484,"creator":"U08G18M2B","is_archived":false,"is_general":false,"has_pins":false,"is_member":false},{"id":"C0GKR06TT","name":"test_channel","is_channel":true,"created":1450133734,"creator":"U08G18M2B","is_archived":false,"is_general":false,"has_pins":false,"is_member":false},{"id":"C0B7G6GM8","name":"wiki","is_channel":true,"created":1443044479,"creator":"U08G18M2B","is_archived":false,"is_general":false,"has_pins":false,"is_member":false}],"groups":[{"id":"G0A4WQL8K","name":"admin-reddit","is_group":true,"created":1441317827,"creator":"U08G18M2B","is_archived":false,"is_mpim":false,"has_pins":false,"is_open":true,"last_read":"1450126770.000015","latest":{"type":"message","user":"U08G18M2B","text":"Perfect","edited":{"user":"U08G18M2B","ts":"1450198849.000000"},"ts":"1450198843.000101"},"unread_count":75,"unread_count_display":71,"members":["U08G18M2B","U0B0X9E8L","U0B13Q30A","U0BCG922W","U0FULAMB7","U0FUQCMPT","U0GKH20HL"],"topic":{"value":"","creator":"","last_set":0},"purpose":{"value":"Private group for subreddit administration","creator":"U08G18M2B","last_set":1443312648}}],"ims":[{"id":"D0GKH1TRQ","is_im":true,"user":"USLACKBOT","created":1450127241,"has_pins":false,"last_read":"0000000000.000000","latest":null,"unread_count":0,"unread_count_display":0,"is_open":true},{"id":"D0GKL0UNS","is_im":true,"user":"U08G18M2B","created":1450129396,"has_pins":false,"last_read":"0000000000.000000","latest":{"type":"message","user":"U08G18M2B","text":"<@U0GKH20HL> shutdown","ts":"1450199323.000024"},"unread_count":28,"unread_count_display":22,"is_open":true},{"id":"D0GMPGF9D","is_im":true,"user":"U0FUQCMPT","created":1450198612,"has_pins":false,"last_read":"0000000000.000000","latest":{"type":"message","user":"U0GKH20HL","text":"Unauthorized operation: [shutdown]","ts":"1450198760.000002"},"unread_count":1,"unread_count_display":0,"is_open":true}],"cache_ts":1450199333,"subteams":{"self":[],"all":[]},"users":["REDACTED FOR PRIVACY REASONS"],"cache_version":"v11-mouse","cache_ts_version":"v1-cat","bots":[{"id":"B0A4S6WKS","deleted":false,"name":"bot","icons":{"image_36":"https:\/\/slack.global.ssl.fastly.net\/12b5a\/plugins\/bot\/assets\/service_36.png","image_48":"https:\/\/slack.global.ssl.fastly.net\/12b5a\/plugins\/bot\/assets\/service_48.png","image_72":"https:\/\/slack.global.ssl.fastly.net\/12b5a\/plugins\/bot\/assets\/service_72.png"}},{"id":"B0BF81DSR","deleted":false,"name":"twitter","icons":{"image_36":"https:\/\/slack.global.ssl.fastly.net\/66f9\/img\/services\/twitter_36.png","image_48":"https:\/\/slack.global.ssl.fastly.net\/66f9\/img\/services\/twitter_48.png","image_72":"https:\/\/slack.global.ssl.fastly.net\/205a\/img\/services\/twitter_72.png"}},{"id":"B0CPWH3NG","deleted":false,"name":"giphy","icons":{"image_36":"https:\/\/slack.global.ssl.fastly.net\/12b5a\/plugins\/giphy\/assets\/service_36.png","image_48":"https:\/\/slack.global.ssl.fastly.net\/12b5a\/plugins\/giphy\/assets\/service_48.png","image_72":"https:\/\/slack.global.ssl.fastly.net\/12b5a\/plugins\/giphy\/assets\/service_72.png"}},{"id":"B0GKCQ277","deleted":false,"name":"bot","icons":{"image_36":"https:\/\/slack.global.ssl.fastly.net\/12b5a\/plugins\/bot\/assets\/service_36.png","image_48":"https:\/\/slack.global.ssl.fastly.net\/12b5a\/plugins\/bot\/assets\/service_48.png","image_72":"https:\/\/slack.global.ssl.fastly.net\/12b5a\/plugins\/bot\/assets\/service_72.png"}},{"id":"B08G19H5G","deleted":true,"name":"gdrive"}],"url":"wss:\/\/ms381.slack-msgs.com\/websocket\/c12rlQj-5q-ZpMN1n4YnBDBnxk0xyjT54NvTdACZO0EsEK8rjOlZTPnftY0RphulHRtjvMoga7XyeuumtotzP0BF6MUSDWFLo0QTShCXJlF7GW2y04869Xdftq1P0ZUiHgJ9IjtxK9XM7wF80q5rWg=="}
Connected to Slack API
Connecting to Twitter API
Dec 15, 2015 6:09:16 PM flowctrl.integration.slack.RestUtils execute
Connected to Twitter API
INFO: url : https://slack.com/api/users.list
Connected to APIs
Dec 15, 2015 6:09:17 PM flowctrl.integration.slack.RestUtils execute
INFO: return : {"ok":true,"members":["REDACTED FOR PRIVACY REASONS"]}
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Dec 15, 2015 6:09:18 PM flowctrl.integration.slack.rtm.SlackRealTimeMessagingClient connect
INFO: connected Slack RTM(Real Time Messaging) server : wss://ms381.slack-msgs.com/websocket/c12rlQj-5q-ZpMN1n4YnBDBnxk0xyjT54NvTdACZO0EsEK8rjOlZTPnftY0RphulHRtjvMoga7XyeuumtotzP0BF6MUSDWFLo0QTShCXJlF7GW2y04869Xdftq1P0ZUiHgJ9IjtxK9XM7wF80q5rWg==
Dec 15, 2015 6:09:18 PM flowctrl.integration.slack.rtm.SlackRealTimeMessagingClient onMessage
INFO: Slack RTM message : {"type":"hello"}
Dec 15, 2015 6:09:18 PM flowctrl.integration.slack.rtm.SlackRealTimeMessagingClient onMessage
INFO: Slack RTM message : {"type":"presence_change","user":"U0GKH20HL","presence":"active"}
Dec 15, 2015 6:09:18 PM flowctrl.integration.slack.rtm.SlackRealTimeMessagingClient onMessage
INFO: Slack RTM message : {"type":"presence_change","user":"U0GKH20HL","presence":"active"}
Dec 15, 2015 6:09:58 PM flowctrl.integration.slack.rtm.SlackRealTimeMessagingClient onMessage
INFO: Slack RTM message : {"type":"user_typing","channel":"D0GKL0UNS","user":"U08G18M2B"}
Dec 15, 2015 6:10:42 PM flowctrl.integration.slack.rtm.SlackRealTimeMessagingClient onMessage
INFO: Slack RTM message : {"type":"user_typing","channel":"D0GKL0UNS","user":"U08G18M2B"}
Dec 15, 2015 6:11:13 PM flowctrl.integration.slack.rtm.SlackRealTimeMessagingClient onMessage
INFO: Slack RTM message : {"type":"user_typing","channel":"D0GKL0UNS","user":"U08G18M2B"}

After that, further events of me typing did nothing. My first attempt not visible was at about 6:12:00 PM.

The token I use for the Real Time Messaging Client is also used for a Web API Client in the same session at the same time, perhaps that gives it some issues?

There is one listener attached to the RTM Client, for Event.MESSAGE.

Here is the repository for the program: https://github.com/JoshCode/gilmore

Maven project building issue

Hi,

Thanks for this project.

Today I started to use this project in my project. I have added the jitpack repo and dependencies in my existing maven project POM file as below.

<repositories> <repository> <id>maven</id> <name>app</name> <url>http://maven.apache.org</url> </repository> <repository> <id>jitpack.io</id> <url>https://jitpack.io</url> </repository> </repositories>

<dependency> <groupId>com.github.flowctrl</groupId> <artifactId>slack-api</artifactId> <version>v1.0.10.RELEASE</version> </dependency>

While compiling, I got the error as POM for slack-api jar is invalid. The downloaded jar file size is only 2kb. Something was missing.

After few hours, I have tried to change the version in the dependency as v1.0.9.RELEASE. Then it starts downloading all the dependencies correctly. Any reason for this issue?

Thanks
Thileepan

Channel name reg expression

Channel names can start with an underscore or dash.

Class: flowctrl.integration.slack.validation.SlackFieldValidationUtils

regex constant should be:
private static final String CHANNEL_NAME_REGEX = "^[a-z0-9-]{1}[a-z0-9-]{0,20}$";

Return channel ID resulted from im.open call

Web API method im.open returns a channel ID with the OK message. This channel ID is important to use the recently opened private chat.

The method SlackWebApiClientImpl.openDirectMessageChannel(String) should return this ID if the call is successful.

User -

JSON parser fails on non-boolean string values. Should be String not Boolean:

two_factor_type - app or sms

flowctrl.integration.slack.type.User
protected String two_factor_type;

https://api.slack.com/types/user

channels.list method no longer exists

In SlackWebApiConstants.java

String CHANNELS_LIST = "channels.list";

The channels.list method no longer exists in the official Slack API. It will cause an unknown method error if used by getChannelList()

No proxy option

Unfortunately one cannot instantiate client using proxy. The RestUtils class is missing this option.

Attempted read on closed stream

Release 7 throws the below:

Exception in thread "main" flowctrl.integration.slack.exception.SlackException: java.io.IOException: Attempted read on closed stream.
at flowctrl.integration.slack.webapi.SlackWebApiClientImpl.call(SlackWebApiClientImpl.java:1073)
at flowctrl.integration.slack.webapi.SlackWebApiClientImpl.call(SlackWebApiClientImpl.java:1027)
at flowctrl.integration.slack.webapi.SlackWebApiClientImpl.auth(SlackWebApiClientImpl.java:144)

No sources available

Please add maven-source-plugin to the project so that sources can be downloaded in IDE.

<plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-source-plugin</artifactId>
                    <version>${maven-source-plugin.version}</version>
                    <executions>
                        <execution>
                            <id>attach-sources</id>
                            <goals>
                                <goal>jar</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>

Thanks

Getting Usergroup List fails to execute

The usergroup.list method (SlackWebApiClientImpl.getUsergroupList) fails because Slack returns a structure with a key of usersgroups and the code is looking for usergroup (singular vs plural).

Simple one character fix.

flowctrl.integration.slack.type.Attachment setColor check error

flowctrl.integration.slack.type.Attachment

public void setColor(String color) {
if (color != null) {
if (color.charAt(0) == '#') {

//this line
// !color.substring(1).matches(HEX_REGEX)
if (color.substring(1).matches(HEX_REGEX)) {
throw new SlackArgumentException("invalid hex color");
}
} else if (!color.matches(PREDEFINED_COLOR_REGEX)) {
throw new SlackArgumentException("invalid predefined(good|warning|danger) color");
}
}

    this.color = color;
}

new Client that handles slash command async responses

this is very similar to SlackWebApiClientImpl and can be used to send responses to 'response_url' when receiving /slash commands. The thing special is the handling of the 'response_type' ('in_channel' or 'ephemeral') within the post(..) method. See also https://api.slack.com/docs/attachments

my code:

public class SlackSlashResponseWebhookClient {
   private String webhookUrl;
   private ObjectMapper mapper;
   private CloseableHttpClient httpClient;

   public SlackSlashResponseWebhookClient(String webhookUrl) {
      this(webhookUrl, null);
   }

   public SlackSlashResponseWebhookClient(String webhookUrl, ObjectMapper mapper) {
      this(webhookUrl, mapper, SlackWebApiConstants.DEFAULT_TIMEOUT);
   }

   public SlackSlashResponseWebhookClient(String webhookUrl, ObjectMapper mapper, int timeout) {
      if (webhookUrl == null) {
         throw new SlackArgumentException("Missing WebHook URL Configuration @ SlackApi");
      } else if (!webhookUrl.startsWith("https://hooks.slack.com/commands/")) {
         throw new SlackArgumentException("Invalid Service URL. WebHook URL Format: https://hooks.slack.com/commands/{id_1}/{id_2}/{token}");
      }
      this.webhookUrl = webhookUrl;
      this.mapper = mapper != null ? mapper : new ObjectMapper();
      httpClient = RestUtils.createHttpClient(timeout);
   }

   public void shutdown() {
      if (httpClient != null) try { httpClient.close(); } catch (Exception e) {}
   }

   public String post(Payload payload, boolean ephemeral) {
      if (payload != null) {
         String message = null;
         try {
            message = mapper.writeValueAsString(payload);
         } catch (JsonProcessingException e) {
            throw new SlackException(e);
         }

         Map<String, String> parameters = new HashMap<String, String>();
         parameters.put("response_url", ephemeral ? "ephemeral" : "in_channel");
         parameters.put("payload", message);
         return RestUtils.execute(httpClient, this.webhookUrl, RestUtils.createUrlEncodedFormEntity(parameters));
      }
      return null;
   }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.