Sha256: de3f596daa2a06a5ae6eb59de9f9d48a81e874107c9d7d44521676a3ed26be09

Contents?: true

Size: 1.45 KB

Versions: 3

Compression:

Stored size: 1.45 KB

Contents

class SlackSmartBot
  def see_admins()
    save_stats(__method__)
    if Thread.current[:typem] == :on_call
      channel = Thread.current[:dchannel]
    elsif Thread.current[:using_channel].to_s==''
      channel = Thread.current[:dest]
    else
      channel = Thread.current[:using_channel]
    end

    messages = []
    admins = []
    team_id_admins = []
    channels = get_channels()
    channel_found = channels.detect { |c| c.id == channel }
    if !channel_found.nil? and channel_found.creator.to_s != ''
      messages << "*Channel creator*: <@#{channel_found.creator}>"
      creator_info = find_user(channel_found.creator)
    else
      creator_info = {name: [], team_id: []}
    end
    messages << "*Master admins*: <@#{config.masters.join('>, <@')}>"
    if Thread.current[:typem] == :on_bot or Thread.current[:typem] == :on_master
      admins = config.admins.dup
      team_id_admins = config.team_id_admins.dup
    end
    if @admins_channels.key?(channel) and @admins_channels[channel].size > 0
      team_id_admins = (@admins_channels[channel] + team_id_admins).uniq
      admins = (@admins_channels[channel].map { |a| a.split('_')[1..-1].join('_') } + admins).uniq
    end
    admins = admins - config.masters - [creator_info.name]
    team_id_admins = team_id_admins - config.team_id_masters - ["#{creator_info.team_id}_#{creator_info.name}"]
    messages << "*Admins*: <@#{admins.join('>, <@')}>" unless admins.empty?
    respond messages.join("\n")
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
slack-smart-bot-1.15.25 lib/slack/smart-bot/commands/general/see_admins.rb
slack-smart-bot-1.15.1 lib/slack/smart-bot/commands/general/see_admins.rb
slack-smart-bot-1.15.0 lib/slack/smart-bot/commands/general/see_admins.rb