Sha256: 15e353859aa6a4aa689f44217a97a7f500e39236c0fced602707aefbb48681a5

Contents?: true

Size: 1.5 KB

Versions: 2

Compression:

Stored size: 1.5 KB

Contents

class SlackSmartBot
  # helpmaster: ----------------------------------------------
  # helpmaster: `set maintenance on`
  # helpmaster: `set maintenance on MESSAGE`
  # helpmaster: `set maintenance off`
  # helpmaster: `turn maintenance on`
  # helpmaster: `turn maintenance on MESSAGE`
  # helpmaster: `turn maintenance off`
  # helpmaster:    The SmartBot will be on maintenance and responding with a generic message
  # helpmaster:    Only works if you are on Master channel and you are a master admin user
  # helpmaster:
  def set_maintenance(from, status, message)
    save_stats(__method__)
    if config.on_master_bot
      if config.admins.include?(from) #admin user
        if message == ''
          config.on_maintenance_message = "Sorry I'm on maintenance so I cannot attend your request."
        else
          config.on_maintenance_message = message
        end

        if status == 'on'
          config.on_maintenance = true
          respond "From now on I'll be on maintenance status so I won't be responding accordingly."
        else
          config.on_maintenance = false
          respond "From now on I won't be on maintenance. Everything is back to normal!"
        end
        
        file = File.open("#{config.path}/config_tmp.status", "w")
        file.write config.inspect
        file.close
    
      else
        respond 'Only master admins on master channel can use this command.'
      end
    else
      respond 'Only master admins on master channel can use this command.'
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
slack-smart-bot-1.9.2 lib/slack/smart-bot/commands/on_master/admin_master/set_maintenance.rb
slack-smart-bot-1.9.1 lib/slack/smart-bot/commands/on_master/admin_master/set_maintenance.rb