Sha256: d27ee844fe715f2e2f8a922d3064b1528ec69a23d1682f95295bcc3b0684af19

Contents?: true

Size: 1.53 KB

Versions: 12

Compression:

Stored size: 1.53 KB

Contents

class SlackSmartBot
  # help: ----------------------------------------------
  # help: `see shortcuts`
  # help: `see sc`
  # help:    It will display the shortcuts stored for the user and for :all
  # help:
  def see_shortcuts(dest, user, typem)
    save_stats(__method__)
    from = user.name
    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(">, <@")}>"
    else
      unless typem == :on_extended
        msg = ""
        if @shortcuts[:all].keys.size > 0
          msg = "*Available shortcuts for all:*\n"
          @shortcuts[:all].each { |name, value|
            msg += "    _#{name}: #{value}_\n"
          }
          respond msg, dest
        end

        if @shortcuts.keys.include?(from) and @shortcuts[from].keys.size > 0
          new_hash = @shortcuts[from].dup
          @shortcuts[:all].keys.each { |k| new_hash.delete(k) }
          if new_hash.keys.size > 0
            msg = "*Available shortcuts for #{from}:*\n"
            new_hash.each { |name, value|
              msg += "    _#{name}: #{value}_\n"
            }
            respond msg, dest
          end
        end
        respond "No shortcuts found", dest if msg == ""
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
slack-smart-bot-1.8.2 lib/slack/smart-bot/commands/on_bot/see_shortcuts.rb
slack-smart-bot-1.8.1 lib/slack/smart-bot/commands/on_bot/see_shortcuts.rb
slack-smart-bot-1.8.0 lib/slack/smart-bot/commands/on_bot/see_shortcuts.rb
slack-smart-bot-1.7.0 lib/slack/smart-bot/commands/on_bot/see_shortcuts.rb
slack-smart-bot-1.6.8 lib/slack/smart-bot/commands/on_bot/see_shortcuts.rb
slack-smart-bot-1.6.7 lib/slack/smart-bot/commands/on_bot/see_shortcuts.rb
slack-smart-bot-1.6.6 lib/slack/smart-bot/commands/on_bot/see_shortcuts.rb
slack-smart-bot-1.6.5 lib/slack/smart-bot/commands/on_bot/see_shortcuts.rb
slack-smart-bot-1.6.4 lib/slack/smart-bot/commands/on_bot/see_shortcuts.rb
slack-smart-bot-1.6.3 lib/slack/smart-bot/commands/on_bot/see_shortcuts.rb
slack-smart-bot-1.6.2 lib/slack/smart-bot/commands/on_bot/see_shortcuts.rb
slack-smart-bot-1.6.1 lib/slack/smart-bot/commands/on_bot/see_shortcuts.rb