Sha256: d895f6474ec1e3c46d154a0f0b4602734d8bad48379aeae3ef81fcc159f015c8

Contents?: true

Size: 1.68 KB

Versions: 3

Compression:

Stored size: 1.68 KB

Contents

class SlackSmartBot
  def deny_access(user, command_id)
    save_stats(__method__)
    not_allowed = ['hi_bot', 'bye_bot', "allow_access", "deny_access", "get_bot_logs", "add_routine", "pause_bot", "pause_routine", "remove_routine", "run_routine", "start_bot",
                   "start_routine", "delete_message", "update_message", "send_message", "kill_bot_on_channel", "exit_bot", "notify_message", "publish_announcements", "set_general_message",
                   "set_maintenance", 'bot_help', 'bot_rules']
    if !is_admin?(user)
      respond "Only admins of this channel can use this command. Take a look who is an admin of this channel by calling `see admins`"
    elsif Thread.current[:dest][0] == "D"
      respond "This command cannot be called from a DM"
    elsif not_allowed.include?(command_id)
      respond "Sorry but the access for `#{command_id}` cannot be changed."
    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
      command_ids = get_command_ids()
      if command_ids.values.flatten.include?(command_id)
        if !@access_channels.key?(channel)
          @access_channels[channel] = {}
        end

        @access_channels[channel][command_id] = []

        update_access_channels()
        respond "The command `#{command_id}` won't be available in this channel. Call `allow access #{command_id}` if you want it back."
      else
        respond "It seems like #{command_id} is not valid. Please be sure that exists by calling `see command ids`"
      end
    end
  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/deny_access.rb
slack-smart-bot-1.15.1 lib/slack/smart-bot/commands/general/deny_access.rb
slack-smart-bot-1.15.0 lib/slack/smart-bot/commands/general/deny_access.rb