]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
Abort if levels.rbot is badly messed up. We don't want to make the bot suddenly becom...
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Thu, 27 Jul 2006 19:44:51 +0000 (19:44 +0000)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Thu, 27 Jul 2006 19:44:51 +0000 (19:44 +0000)
lib/rbot/auth.rb
lib/rbot/ircbot.rb

index ad7283b43be55363365cb0d78e67a4d7a184d5a7..c865636cd937072c9e72a4ed2b1685eb06fef636 100644 (file)
@@ -53,6 +53,9 @@ module Irc
           end
         end
       end
+      if @levels.length < 1
+        raise RuntimeError, "No valid levels.rbot found! If you really want a free-for-all bot and this isn't the result of a previous error, write a proper levels.rbot"
+      end
     end
 
     # save current users and levels to files.
index d435ac4c23a862cc9598ce16a5188b094751c69a..a0b64d9b31b6bdee81d381ec7aeea0c9fdb0cb4a 100644 (file)
@@ -314,7 +314,14 @@ class IrcBot
     @httputil = Utils::HttpUtil.new(self)
     @lang = Language::Language.new(@config['core.language'])
     @keywords = Keywords.new(self)
-    @auth = IrcAuth.new(self)
+    begin
+      @auth = IrcAuth.new(self)
+    rescue => e
+      fatal e.inspect
+      fatal e.backtrace.join("\n")
+      log_session_end
+      exit 2
+    end
 
     Dir.mkdir("#{botclass}/plugins") unless File.exist?("#{botclass}/plugins")
     @plugins = Plugins::Plugins.new(self, ["#{botclass}/plugins"])
@@ -546,16 +553,19 @@ class IrcBot
         error "network exception: #{e.class}: #{e}"
         debug e.backtrace.join("\n")
       rescue BDB::Fatal => e
-        error "fatal bdb error: #{e.class}: #{e}"
-        error e.backtrace.join("\n")
+        fatal "fatal bdb error: #{e.class}: #{e}"
+        fatal e.backtrace.join("\n")
         DBTree.stats
-        restart("Oops, we seem to have registry problems ...")
+        # Why restart? DB problems are serious stuff ...
+        # restart("Oops, we seem to have registry problems ...")
+        log_session_end
+        exit 2
       rescue Exception => e
         error "non-net exception: #{e.class}: #{e}"
         error e.backtrace.join("\n")
       rescue => e
-        error "unexpected exception: #{e.class}: #{e}"
-        error e.backtrace.join("\n")
+        fatal "unexpected exception: #{e.class}: #{e}"
+        fatal e.backtrace.join("\n")
         log_session_end
         exit 2
       end