def help(topic="")
case topic
when /fail(?:ed)?\s*plugins?.*(trace(?:back)?s?)?/
return _("no plugins failed to load") if @failed.empty?
return @failed.collect { |p|
_('%{highlight}%{plugin}%{highlight} in %{dir} failed with error %{exception}: %{reason}') % {
:highlight => Bold, :plugin => p[:name], :dir => p[:dir],
:exception => p[:reason].class, :reason => p[:reason],
} + if $1 && !p[:reason].backtrace.empty?
_('at %{backtrace}') % {:backtrace => p[:reason].backtrace.join(', ')}
else
''
end
}.join("\n")
when /ignored?\s*plugins?/
return _('no plugins were ignored') if @ignored.empty?
tmp = Hash.new
@ignored.each do |p|
reason = p[:loaded] ? _('overruled by previous') : _(p[:reason].to_s)
((tmp[p[:dir]] ||= Hash.new)[reason] ||= Array.new).push(p[:name])
end
return tmp.map do |dir, reasons|
s = reasons.map { |r, list|
list.map { |_| _.sub(/\.rb$/, '') }.join(', ') + " (#{r})"
}.join('; ')
"in #{dir}: #{s}"
end.join('; ')
when /^(\S+)\s*(.*)$/
key = $1
params = $2
(core_modules + plugins).each { |p|
next unless p.name == key
begin
return p.help(key, params)
rescue Exception => err
error report_error("#{p.botmodule_class} #{p.name} help() failed:", err)
end
}
k = key.to_sym
if commands.has_key?(k)
p = commands[k][:botmodule]
begin
return p.help(key, params)
rescue Exception => err
error report_error("#{p.botmodule_class} #{p.name} help() failed:", err)
end
end
end
return false
end