]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - lib/rbot/ircbot.rb
Thu Aug 04 00:11:52 BST 2005 Tom Gilbert <tom@linuxbrit.co.uk>
[user/henk/code/ruby/rbot.git] / lib / rbot / ircbot.rb
index 5f05129035c6c8beb68e205ead2d2fa269c0b6b2..f99dd940d5207794d00c486eeb7e9fb13dd38427 100644 (file)
@@ -2,6 +2,13 @@ require 'thread'
 require 'etc'
 require 'fileutils'
 
+$debug = false unless $debug
+# print +message+ if debugging is enabled
+def debug(message=nil)
+  print "DEBUG: #{message}\n" if($debug && message)
+  #yield
+end
+
 # these first
 require 'rbot/rbotconfig'
 require 'rbot/config'
@@ -108,8 +115,8 @@ class IrcBot
 
     @argv = params[:argv]
 
-    unless FileTest.directory? Config::DATADIR
-      puts "data directory '#{Config::DATADIR}' not found, did you install.rb?"
+    unless FileTest.directory? Config::datadir
+      puts "data directory '#{Config::datadir}' not found, did you install.rb?"
       exit 2
     end
     
@@ -122,7 +129,7 @@ class IrcBot
         puts "Error: file #{botclass} exists but isn't a directory"
         exit 2
       end
-      FileUtils.cp_r Config::DATADIR+'/templates', botclass
+      FileUtils.cp_r Config::datadir+'/templates', botclass
     end
     
     Dir.mkdir("#{botclass}/logs") unless File.exist?("#{botclass}/logs")
@@ -369,6 +376,7 @@ class IrcBot
     end while(message.length > 0)
   end
 
+  # queue an arbitraty message for the server
   def sendq(message="")
     # temporary
     @socket.queue(message)
@@ -429,6 +437,7 @@ class IrcBot
     sendq "TOPIC #{where} :#{topic}"
   end
 
+  # disconnect from the server and cleanup all plugins and modules
   def shutdown(message = nil)
     trap("SIGTERM", "DEFAULT")
     trap("SIGHUP", "DEFAULT")
@@ -539,6 +548,7 @@ class IrcBot
     return helpstr
   end
 
+  # returns a string describing the current status of the bot (uptime etc)
   def status
     secs_up = Time.new - @startup_time
     uptime = Utils.secs_to_string secs_up