Sha256: cec3bdca557e439962d3fc77ac4994233b568297dffe9fb673f3282ab35727e1

Contents?: true

Size: 1.46 KB

Versions: 3

Compression:

Stored size: 1.46 KB

Contents

class SlackSmartBot
  def personal_settings(user, type, settings_id, settings_value)
    save_stats "#{type}_personal_settings"
    if Thread.current[:typem] == :on_dm
      get_personal_settings()
      @personal_settings[user.name] ||= {}
      if type == :get
        if settings_id.to_s == ''
          personal_settings_txt = ""
          @personal_settings[user.name].each do |key, value|
            personal_settings_txt << "`#{key}`:  #{value}\n"
          end
          respond "Personal settings for *#{user.name}* are:\n#{personal_settings_txt}"
        else
          if @personal_settings[user.name].key?(settings_id)
            respond "Personal settings for *#{settings_id}* is: *#{@personal_settings[user.name][settings_id]}*."
          else
            respond "Personal settings for *#{settings_id}* not found."
          end
        end
      elsif type == :delete
        if @personal_settings[user.name].key?(settings_id)
          @personal_settings[user.name].delete(settings_id)
          update_personal_settings()
          respond "Personal settings deleted for *#{settings_id}*."
        else
          respond "Personal settings for *#{settings_id}* not found."
        end
      else #set
        @personal_settings[user.name][settings_id] = settings_value
        update_personal_settings()
        respond "Personal settings set for *#{settings_id}*."
      end
    else
      respond "This command can only be called on a DM with the SmartBot."
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
slack-smart-bot-1.14.2 lib/slack/smart-bot/commands/general/personal_settings.rb
slack-smart-bot-1.14.1 lib/slack/smart-bot/commands/general/personal_settings.rb
slack-smart-bot-1.14.0 lib/slack/smart-bot/commands/general/personal_settings.rb