Sha256: 2988cd5dae135d0a629fe6a954c80b2477015403252b6107c8302c2e9c3cef31

Contents?: true

Size: 1.17 KB

Versions: 15

Compression:

Stored size: 1.17 KB

Contents

def get_channels(bot_is_in: false, types: 'private_channel,public_channel')
  begin
    if config.simulate and config.key?(:client)
      if bot_is_in
        client.web_client.conversations_members.reject { |r, v| !v.members.include?(config.nick_id) }.values
      else
        client.web_client.conversations_members.values
      end
    else
      if bot_is_in
        client.web_client.users_conversations(exclude_archived: true, limit: 1000, types: "im, public_channel,private_channel").channels
      else
        resp = client.web_client.conversations_list(types: types, limit: "600", exclude_archived: "true")
        channels = resp.channels
        begin
          while resp.response_metadata.next_cursor.to_s != ""
            resp = client.web_client.conversations_list(
              cursor: resp.response_metadata.next_cursor.to_s,
              types: types,
              limit: "600",
              exclude_archived: "true",
            )
            channels += resp.channels
          end
        rescue Exception => stack
          @logger.warn stack
        end
        return channels
      end
    end
  rescue Exception => stack
    @logger.warn stack
    return []
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
slack-smart-bot-1.13.2 lib/slack/smart-bot/comm/get_channels.rb
slack-smart-bot-1.13.1 lib/slack/smart-bot/comm/get_channels.rb
slack-smart-bot-1.13.0 lib/slack/smart-bot/comm/get_channels.rb
slack-smart-bot-1.12.9 lib/slack/smart-bot/comm/get_channels.rb
slack-smart-bot-1.12.8 lib/slack/smart-bot/comm/get_channels.rb
slack-smart-bot-1.12.7 lib/slack/smart-bot/comm/get_channels.rb
slack-smart-bot-1.12.6 lib/slack/smart-bot/comm/get_channels.rb
slack-smart-bot-1.12.5 lib/slack/smart-bot/comm/get_channels.rb
slack-smart-bot-1.12.4 lib/slack/smart-bot/comm/get_channels.rb
slack-smart-bot-1.12.3 lib/slack/smart-bot/comm/get_channels.rb
slack-smart-bot-1.12.2 lib/slack/smart-bot/comm/get_channels.rb
slack-smart-bot-1.12.1 lib/slack/smart-bot/comm/get_channels.rb
slack-smart-bot-1.12.0 lib/slack/smart-bot/comm/get_channels.rb
slack-smart-bot-1.11.0 lib/slack/smart-bot/comm/get_channels.rb
slack-smart-bot-1.10.0 lib/slack/smart-bot/comm/get_channels.rb