Sha256: 946bc52d0f3c4d74cf6143f3e7d41d9c0e0c91ef9a5a659b9682f70fcf9cd333

Contents?: true

Size: 1.61 KB

Versions: 17

Compression:

Stored size: 1.61 KB

Contents

class SlackSmartBot
    def is_admin?(from=nil)
        if from.nil?
            user = Thread.current[:user]
            from = user.name
        end
        
        if (Thread.current[:dchannel].to_s!='' and !@channels_creator.key?(Thread.current[:dchannel])) or 
            (Thread.current[:dest].to_s!='' and Thread.current[:dest][0]!='D' and !@channels_creator.key?(Thread.current[:dest])) or 
            (Thread.current[:using_channel].to_s!='' and !@channels_creator.key?(:using_channel))
            get_channels_name_and_id() 
        end

        if config.masters.include?(from) or 
           config.admins.include?(from) or 
           (Thread.current[:typem] == :on_call and @admins_channels.key?(Thread.current[:dchannel]) and @admins_channels[Thread.current[:dchannel]].include?(from)) or
           (Thread.current[:using_channel].to_s == '' and @admins_channels.key?(Thread.current[:dest]) and @admins_channels[Thread.current[:dest]].include?(from)) or
           (@admins_channels.key?(Thread.current[:using_channel]) and @admins_channels[Thread.current[:using_channel]].include?(from)) or 
           (Thread.current[:using_channel].to_s=='' and @channels_creator.key?(Thread.current[:dest]) and from == @channels_creator[Thread.current[:dest]]) or 
           (Thread.current[:typem] == :on_call  and @channels_creator.key?(Thread.current[:dchannel]) and from == @channels_creator[Thread.current[:dchannel]]) or 
           (@channels_creator.key?(Thread.current[:using_channel]) and from == @channels_creator[Thread.current[:using_channel]])
            return true
        else
            return false
        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/is_admin.rb
slack-smart-bot-1.14.1 lib/slack/smart-bot/utils/is_admin.rb
slack-smart-bot-1.14.0 lib/slack/smart-bot/utils/is_admin.rb
slack-smart-bot-1.13.2 lib/slack/smart-bot/utils/is_admin.rb
slack-smart-bot-1.13.1 lib/slack/smart-bot/utils/is_admin.rb
slack-smart-bot-1.13.0 lib/slack/smart-bot/utils/is_admin.rb
slack-smart-bot-1.12.9 lib/slack/smart-bot/utils/is_admin.rb
slack-smart-bot-1.12.8 lib/slack/smart-bot/utils/is_admin.rb
slack-smart-bot-1.12.7 lib/slack/smart-bot/utils/is_admin.rb
slack-smart-bot-1.12.6 lib/slack/smart-bot/utils/is_admin.rb
slack-smart-bot-1.12.5 lib/slack/smart-bot/utils/is_admin.rb
slack-smart-bot-1.12.4 lib/slack/smart-bot/utils/is_admin.rb
slack-smart-bot-1.12.3 lib/slack/smart-bot/utils/is_admin.rb
slack-smart-bot-1.12.2 lib/slack/smart-bot/utils/is_admin.rb
slack-smart-bot-1.12.1 lib/slack/smart-bot/utils/is_admin.rb
slack-smart-bot-1.12.0 lib/slack/smart-bot/utils/is_admin.rb
slack-smart-bot-1.11.0 lib/slack/smart-bot/utils/is_admin.rb