Module: SlackSearch
- Includes:
- SlackClient
- Included in:
- EnerbotSlack, SlackConsole, SlackMessage
- Defined in:
- lib/modules/slack_search.rb
Overview
Module for searching content on Slack
Instance Method Summary collapse
- #conversation_info(channel = @channel_id) ⇒ Object
- #conversation_list ⇒ Object
- #conversation_members(channel, limit = 60) ⇒ Object
- #conversation_permalink(channel = @channel_id, ts) ⇒ Object
- #conversation_replies(channel = @channel_id, ts) ⇒ Object
- #conversation_type(channel = @channel_id) ⇒ Object
- #get_user_id(channel = @channel_id) ⇒ Object
- #get_user_info(user) ⇒ Object
- #get_user_list ⇒ Object
- #search_messages_on(channel, quantity = 5) ⇒ Object
- #verify_type ⇒ Object
Methods included from SlackClient
Instance Method Details
#conversation_info(channel = @channel_id) ⇒ Object
70 71 72 73 74 75 76 77 |
# File 'lib/modules/slack_search.rb', line 70 def conversation_info(channel = @channel_id) client = configure_client info = client.conversations_info channel: channel @properties = info.channel rescue Slack::Web::Api::Errors::SlackError => e print e. false end |
#conversation_list ⇒ Object
97 98 99 100 101 102 103 |
# File 'lib/modules/slack_search.rb', line 97 def conversation_list client = configure_client client.conversations_list.channels rescue Slack::Web::Api::Errors::SlackError => e print e. false end |
#conversation_members(channel, limit = 60) ⇒ Object
88 89 90 91 92 93 94 95 |
# File 'lib/modules/slack_search.rb', line 88 def conversation_members(channel, limit = 60) client = configure_client info = client.conversations_members channel: channel, limit: limit info.members rescue Slack::Web::Api::Errors::SlackError => e print e. false end |
#conversation_permalink(channel = @channel_id, ts) ⇒ Object
61 62 63 64 65 66 67 68 |
# File 'lib/modules/slack_search.rb', line 61 def conversation_permalink(channel = @channel_id, ts) client = configure_client response = client.chat_getPermalink channel: channel, message_ts: ts response.permalink rescue Slack::Web::Api::Errors::SlackError => e print e. false end |
#conversation_replies(channel = @channel_id, ts) ⇒ Object
79 80 81 82 83 84 85 86 |
# File 'lib/modules/slack_search.rb', line 79 def conversation_replies(channel = @channel_id, ts) client = configure_client info = client.conversations_replies channel: channel, ts: ts info. rescue Slack::Web::Api::Errors::SlackError => e print e. false end |
#conversation_type(channel = @channel_id) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/modules/slack_search.rb', line 46 def conversation_type(channel = @channel_id) @channel_id = channel if @channel_id.nil? result = conversation_info if result == false print 'Check if IM' @channel_id = get_user_id conversation_info == false ? false : verify_type else verify_type end rescue Slack::Web::Api::Errors::SlackError => e print e. false end |
#get_user_id(channel = @channel_id) ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/modules/slack_search.rb', line 9 def get_user_id(channel = @channel_id) client = configure_client dm = client.conversations_open users: channel dm.channel.id rescue Slack::Web::Api::Errors::SlackError => e print e. false end |
#get_user_info(user) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/modules/slack_search.rb', line 18 def get_user_info(user) client = configure_client c = client.users_info user: user c.user rescue Slack::Web::Api::Errors::SlackError => e print e. false end |
#get_user_list ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/modules/slack_search.rb', line 27 def get_user_list client = configure_client client.users_list rescue Slack::Web::Api::Errors::SlackError => e print e. false end |
#search_messages_on(channel, quantity = 5) ⇒ Object
105 106 107 108 109 110 111 112 |
# File 'lib/modules/slack_search.rb', line 105 def (channel, quantity = 5) # type = conversation_type(channel) client = configure_client client.conversations_history channel: channel, count: quantity rescue Slack::Web::Api::Errors::SlackError => e print e. "Channel not found #{channel}" end |
#verify_type ⇒ Object
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/modules/slack_search.rb', line 35 def verify_type properties = { 'channel' => @properties.is_channel, 'group' => @properties.is_group, 'im' => @properties.is_im } check = '' properties.each { |k, v| check = k if v == true } check end |