X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=lib%2Frbot%2Fplugins.rb;h=50b5576b89a485b9b83479762bb2dc5bf98a8dbf;hb=05917e75de2cbd14071ef335f4c3129a33f30cf6;hp=9fa7ad88ecbe5c5297a5e339c07eefdc7af804ce;hpb=708b18ab6ea124a1646f75785c48d797fdf164a9;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git diff --git a/lib/rbot/plugins.rb b/lib/rbot/plugins.rb index 9fa7ad88..50b5576b 100644 --- a/lib/rbot/plugins.rb +++ b/lib/rbot/plugins.rb @@ -299,22 +299,37 @@ module Plugins cleanup @@plugins = Hash.new scan + end - # return list of help topics (plugin names) - def helptopics + def status(short=false) # Active plugins first if(@@plugins.length > 0) - list = " [#{length} plugin#{'s' if length > 1}: " + @@plugins.values.uniq.collect{|p| p.name}.sort.join(", ") + list = "#{length} plugin#{'s' if length > 1}" + if short + list << " loaded" + else + list << ": " + @@plugins.values.uniq.collect{|p| p.name}.sort.join(", ") + end else - list = " [no plugins active" + list = "no plugins active" end # Ignored plugins next - list << "; #{Underline}#{@ignored.length} plugin#{'s' if @ignored.length > 1} ignored#{Underline}: use #{Bold}help ignored plugins#{Bold} to see why" unless @ignored.empty? + unless @ignored.empty? + 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 - list << "; #{Reverse}#{@failed.length} plugin#{'s' if @failed.length > 1} failed to load#{Reverse}: use #{Bold}help failed plugins#{Bold} to see why" unless @failed.empty? - list << "]" - return list + unless @failed.empty? + 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 + list + end + + # return list of help topics (plugin names) + def helptopics + return " [#{status}]" end def length @@ -386,6 +401,10 @@ module Plugins @@bot.auth.allow?(m.plugin, m.source, m.replyto)) begin @@plugins[m.plugin].privmsg(m) + rescue BDB::Fatal => err + error "plugin #{@@plugins[m.plugin].name} privmsg() failed: #{err.class}: #{err}" + error err.backtrace.join("\n") + raise rescue Exception => err #rescue TimeoutError, StandardError, NameError, SyntaxError => err error "plugin #{@@plugins[m.plugin].name} privmsg() failed: #{err.class}: #{err}"