Sha256: 76d94a96ca39746c6dbf479cc68888c594507f44ad1dee1ffd12fd3b34dd921a

Contents?: true

Size: 1009 Bytes

Versions: 13

Compression:

Stored size: 1009 Bytes

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, from, typem)
    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

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
slack-smart-bot-1.4.3 lib/slack/smart-bot/commands/on_bot/see_shortcuts.rb
slack-smart-bot-1.4.2 lib/slack/smart-bot/commands/on_bot/see_shortcuts.rb
slack-smart-bot-1.4.1 lib/slack/smart-bot/commands/on_bot/see_shortcuts.rb
slack-smart-bot-1.4.0 lib/slack/smart-bot/commands/on_bot/see_shortcuts.rb
slack-smart-bot-1.3.1 lib/slack/smart-bot/commands/on_bot/see_shortcuts.rb
slack-smart-bot-1.3.0 lib/slack/smart-bot/commands/on_bot/see_shortcuts.rb
slack-smart-bot-1.2.0 lib/slack/smart-bot/commands/on_bot/see_shortcuts.rb
slack-smart-bot-1.1.2 lib/slack/smart-bot/commands/on_bot/see_shortcuts.rb
slack-smart-bot-1.1.1 lib/slack/smart-bot/commands/on_bot/see_shortcuts.rb
slack-smart-bot-1.1.0 lib/slack/smart-bot/commands/on_bot/see_shortcuts.rb
slack-smart-bot-1.0.2 lib/slack/smart-bot/commands/on_bot/see_shortcuts.rb
slack-smart-bot-1.0.1 lib/slack/smart-bot/commands/on_bot/see_shortcuts.rb
slack-smart-bot-1.0.0 lib/slack/smart-bot/commands/on_bot/see_shortcuts.rb