Class: RSlack::HelpAction
Instance Attribute Summary
Attributes inherited from Action
Instance Method Summary collapse
Methods inherited from Action
Constructor Details
This class inherits a constructor from RSlack::Action
Instance Method Details
#help(msg) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/rslack/actions/help.rb', line 11 def help(msg) = msg.var. routes = bot.routes.select { |r| r.helptext || .to_s.split.include?('--all') } content = StringIO.new content.puts "```" routes.map do |route| prefix = [(bot.name unless route.matchall), route.regexp.inspect].compact.join(' ') + ':' indent = (prefix.size / 4 + 1) * 4 content.print "#{prefix.ljust(indent)}" content.print "`#{route.helptext}`" if route.helptext content.puts end content.puts "```" bot.reply(msg, text: content.string) end |