# initialise your bot module. Always call super if you override this method,
# as important variables are set up for you
def initialize
- @manager = Plugins::pluginmanager
+ @manager = Plugins::manager
@bot = @manager.bot
@botmodule_triggers = Array.new
@botmodules[:Plugin].clear
@names_hash.clear
@commandmappers.clear
+ @failures_shown = false
end
# Associate with bot _bot_
list << "no plugins active"
end
# Ignored plugins next
- unless @ignored.empty?
+ unless @ignored.empty? or @failures_shown
list << "; #{Underline}#{@ignored.length} plugin#{'s' if @ignored.length > 1} ignored#{Underline}"
list << ": use #{Bold}help ignored plugins#{Bold} to see why" unless short
end
# Failed plugins next
- unless @failed.empty?
+ unless @failed.empty? or @failures_shown
list << "; #{Reverse}#{@failed.length} plugin#{'s' if @failed.length > 1} failed to load#{Reverse}"
list << ": use #{Bold}help failed plugins#{Bold} to see why" unless short
end
# return list of help topics (plugin names)
def helptopics
- return status
+ rv = status
+ @failures_shown = true
+ rv
end
def length
}.join("\n")
when /ignored?\s*plugins?/
return "no plugins were ignored" if @ignored.empty?
- return @ignored.inject(Array.new) { |list, p|
- case p[:reason]
- when :loaded
- list << "#{p[:name]} in #{p[:dir]} (overruled by previous)"
- else
- list << "#{p[:name]} in #{p[:dir]} (#{p[:reason].to_s})"
- end
- list
- }.join(", ")
+
+ 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
end
# Returns the only PluginManagerClass instance
- def Plugins.pluginmanager
+ def Plugins.manager
return PluginManagerClass.instance
end