Sha256: a46f38278df466b1749e59dbdb94dfaaf041eddb940c5688207daa24c7839ad5

Contents?: true

Size: 1.4 KB

Versions: 17

Compression:

Stored size: 1.4 KB

Contents

class SlackSmartBot
  def has_access?(method, user = nil)
    user = Thread.current[:user] if user.nil?
    if config[:allow_access].key?(method) and !config[:allow_access][method].include?(user.name) and !config[:allow_access][method].include?(user.id) and
       (!user.key?(:enterprise_user) or (user.key?(:enterprise_user) and !config[:allow_access][method].include?(user[:enterprise_user].id)))
      respond "You don't have access to use this command, please contact an Admin to be able to use it: <@#{config.admins.join(">, <@")}>"
      return false
    else
      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
      if !@access_channels.key?(channel) or !@access_channels[channel].key?(method.to_s) or @access_channels[channel][method.to_s].include?(user.name)
        return true
      else
        if @admins_channels.key?(channel) and !@admins_channels[channel].empty?
            respond "You don't have access to use this command, please contact an Admin to be able to use it: <@#{@admins_channels[channel].join(">, <@")}>"
        else
            respond "You don't have access to use this command, please contact an Admin to be able to use it."
        end        
        return false
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
slack-smart-bot-1.14.2 lib/slack/smart-bot/utils/has_access.rb
slack-smart-bot-1.14.1 lib/slack/smart-bot/utils/has_access.rb
slack-smart-bot-1.14.0 lib/slack/smart-bot/utils/has_access.rb
slack-smart-bot-1.13.2 lib/slack/smart-bot/utils/has_access.rb
slack-smart-bot-1.13.1 lib/slack/smart-bot/utils/has_access.rb
slack-smart-bot-1.13.0 lib/slack/smart-bot/utils/has_access.rb
slack-smart-bot-1.12.9 lib/slack/smart-bot/utils/has_access.rb
slack-smart-bot-1.12.8 lib/slack/smart-bot/utils/has_access.rb
slack-smart-bot-1.12.7 lib/slack/smart-bot/utils/has_access.rb
slack-smart-bot-1.12.6 lib/slack/smart-bot/utils/has_access.rb
slack-smart-bot-1.12.5 lib/slack/smart-bot/utils/has_access.rb
slack-smart-bot-1.12.4 lib/slack/smart-bot/utils/has_access.rb
slack-smart-bot-1.12.3 lib/slack/smart-bot/utils/has_access.rb
slack-smart-bot-1.12.2 lib/slack/smart-bot/utils/has_access.rb
slack-smart-bot-1.12.1 lib/slack/smart-bot/utils/has_access.rb
slack-smart-bot-1.12.0 lib/slack/smart-bot/utils/has_access.rb
slack-smart-bot-1.11.0 lib/slack/smart-bot/utils/has_access.rb