]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - lib/rbot/core/irclog.rb
chucknorris: fix loading
[user/henk/code/ruby/rbot.git] / lib / rbot / core / irclog.rb
index 88d8b00f8d9c6726a276c7ae3581729039c0ecf6..3b3134c205ebe67ce7e0022a839fc4489cd4332b 100644 (file)
@@ -33,7 +33,9 @@ class IrcLogModule < CoreBotModule
     @queue = Queue.new
     @thread = Thread.new { loggers_thread }
     @logs = Hash.new
-    Dir.mkdir("#{@bot.botclass}/logs") unless File.exist?("#{@bot.botclass}/logs")
+    logdir = @bot.path 'logs'
+    Dir.mkdir(logdir) unless File.exist?(logdir)
+    # TODO what shall we do if the logdir couldn't be created? (e.g. it existed as a file)
     event_irclog_list_changed(@bot.config['irclog.no_log'], @bot.config['irclog.do_log'])
     @fn_format = @bot.config['irclog.filename_format']
   end
@@ -45,7 +47,7 @@ class IrcLogModule < CoreBotModule
   end
 
   def timestamp(time)
-    return time.strftime @bot.config['irclog.timestamp_format']
+    return time.strftime(@bot.config['irclog.timestamp_format'])
   end
 
   def event_irclog_list_changed(nolist, dolist)
@@ -151,7 +153,7 @@ class IrcLogModule < CoreBotModule
         irclog "@ #{m.source} asked #{who} about #{[m.ctcp, m.message].join(' ')}", logtarget
       end
     else
-      if m.public? 
+      if m.public?
         irclog "<#{m.source}> #{m.logmessage}", m.target
       else
         irclog "<#{m.source}(#{m.sourceaddress})> #{m.logmessage}", m.source
@@ -244,7 +246,7 @@ class IrcLogModule < CoreBotModule
   end
 
   def logfilepath(where_str, now)
-    File.join(@bot.botclass, 'logs', now.strftime(@fn_format) % { :where => where_str })
+    @bot.path('logs', now.strftime(@fn_format) % { :where => where_str })
   end
 
   protected
@@ -261,7 +263,7 @@ class IrcLogModule < CoreBotModule
       else
         where_str = where.downcase.gsub(/[:!?$*()\/\\<>|"']/, "_")
       end
-      return unless can_log_on(where_str)
+      next unless can_log_on(where_str)
 
       # close the previous logfile if we're rotating
       if @logs.has_key? where_str
@@ -287,7 +289,7 @@ class IrcLogModule < CoreBotModule
           # If it's a file, we rename to filename.old.filedate
           up = dir.dup
           until File.exist? up
-            up.replace File.dirname up
+            up.replace(File.dirname(up))
           end
           unless File.directory? up
             backup = up.dup