Class: Tkellem::TkellemBot::Help

Inherits:
Command
  • Object
show all
Defined in:
lib/tkellem/tkellem_bot.rb

Instance Attribute Summary

Attributes inherited from Command

#args, #bouncer, #conn, #options, #opts

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Command

admin_option, admin_user?, build_options, #initialize, option, register, resources, #respond, run, #show_help, #user

Constructor Details

This class inherits a constructor from Tkellem::TkellemBot::Command

Class Method Details

.admin_only?Boolean

Returns:

  • (Boolean)


114
115
116
# File 'lib/tkellem/tkellem_bot.rb', line 114

def self.admin_only?
  false
end

Instance Method Details

#executeObject



118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# File 'lib/tkellem/tkellem_bot.rb', line 118

def execute
  name = args.shift.try(:upcase)
  r "**** tkellem help ****"
  if name.nil?
    r "For more information on a command, type:"
    r "help <command>"
    r ""
    r "The following commands are available:"
    TkellemBot.commands.keys.sort.each do |name|
      command = TkellemBot.commands[name]
      next if command.admin_only? && user && !user.admin?
      r "#{name}#{' ' * (25-name.length)}"
    end
  elsif (command = TkellemBot.commands[name])
    r "Help for #{command.name}:"
    r ""
    r command.build_options(user)
  else
    r "No help available for #{name}."
  end
  r "**** end of help ****"
end