]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
Clean up logging from the plugins
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Thu, 20 Jul 2006 20:26:11 +0000 (20:26 +0000)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Thu, 20 Jul 2006 20:26:11 +0000 (20:26 +0000)
data/rbot/plugins/digg.rb
data/rbot/plugins/imdb.rb
data/rbot/plugins/karma.rb
data/rbot/plugins/lart.rb
data/rbot/plugins/math.rb
data/rbot/plugins/quotes.rb
data/rbot/plugins/remind.rb
data/rbot/plugins/slashdot.rb
data/rbot/plugins/url.rb
data/rbot/plugins/wserver.rb

index e125d3c46b1becb99032aad3fa653eae0ad5f101..8663bd0f6a1bd11419d044118a7b5421dcb62d45 100644 (file)
@@ -12,7 +12,7 @@ class DiggPlugin < Plugin
   
   def digg(m, params)
     max = params[:limit].to_i
-    puts "max is #{max}"
+    debug "max is #{max}"
     xml = @bot.httputil.get(URI.parse("http://digg.com/rss/index.xml"))
     unless xml
       m.reply "digg news parse failed"
index 759e380c091d43a2d8496af53c420046f4ab97ae..432d0efc47ea4d87f537f6d431a9f3abb7073e0a 100644 (file)
@@ -39,7 +39,7 @@ class Imdb
   def info(rawstr)
     sr = search(rawstr)
     if !sr
-      puts "IMDB : search returned NIL"
+      debug "IMDB: search returned NIL"
       return nil
     end
     resp, data = @http.get(sr, "User-Agent" =>
index 824ffa956445e3f98ef375a7286c63d0df57232b..93cf659bd82a07564aa4974de723247d86cd88eb 100644 (file)
@@ -15,7 +15,7 @@ class KarmaPlugin < Plugin
 
     # import if old file format found
     if(File.exist?("#{@bot.botclass}/karma.rbot"))
-      puts "importing old karma data"
+      log "importing old karma data"
       IO.foreach("#{@bot.botclass}/karma.rbot") do |line|
         if(line =~ /^(\S+)<=>([\d-]+)$/)
           item = $1
index bf656027c64427e3e30f03ff6b5300e12e23a484..c7200cabeba6632f8cf0d9618ea5a18041b30e93 100644 (file)
@@ -57,6 +57,7 @@ class LartPlugin < Plugin
        #{{{
        def save
                Dir.mkdir("#{@bot.botclass}/lart") if not FileTest.directory? "#{@bot.botclass}/lart"
+               # TODO implement safe saving here too
                File.open("#{@bot.botclass}/lart/larts", "w") { |file|
                        file.puts @larts
                }
index 09e3ed3f36a53fe32d93d2e88bd3492a36aa5afc..afa4737cd9eff71bf10292245ea04e67c8a8b132 100644 (file)
@@ -111,7 +111,7 @@ class MathPlugin < Plugin
          end
          m.reply answer
        rescue Exception => e
-         puts "couldn't evaluate expression \"#{m.params}\": #{e}"
+         error "couldn't evaluate expression \"#{m.params}\": #{e.inspect}"
          m.reply "illegal expression \"#{m.params}\""
          return
        end
index b795af531619e12e67e1d9839bc2afbd2315cf25..917c6901461f9f464f269a1582c8ac869b679a7d 100644 (file)
@@ -33,9 +33,9 @@ class QuotePlugin < Plugin
         File.rename("#{@bot.botclass}/quotes/new/#{channel}",
                     "#{@bot.botclass}/quotes/#{channel}")
       rescue => e
-        $stderr.puts "failed to write quotefile for channel #{channel}!\n#{$!}"
-        debug "#{e.class}: #{e}"
-        debug e.backtrace.join("\n")
+        error "failed to write quotefile for channel #{channel}!\n#{$!}"
+        error "#{e.class}: #{e}"
+        error e.backtrace.join("\n")
       end
     }
   end
index f66c4fc8a40b79b7f9da4974df1c9f13cf6afc01..ef9d4be75525b9eecafc9a675519b03bbacec9e1 100644 (file)
@@ -175,7 +175,7 @@ class RemindPlugin < Plugin
   def remind(m, params)
     who = params.has_key?(:who) ? params[:who] : m.sourcenick
     string = params[:string].to_s
-    puts "in remind, string is: #{string}"
+    debug "in remind, string is: #{string}"
     if(string =~ /^(.*)\s+in\s+(.*)$/)
       subject = $1
       period = $2
index 1a70de08c4ceb8091a1c6e4b8ee1a19384b3ab70..30f58dc9ee31370a1d0ce5514a24adf8cb2f90cd 100644 (file)
@@ -21,11 +21,11 @@ class SlashdotPlugin < Plugin
       m.reply "search for #{search} failed"
       return
     end
-    puts xml.inspect
+    debug xml.inspect
     begin
       doc = Document.new xml
     rescue REXML::ParseException => e
-      puts e
+      warning e.inspect
       m.reply "couldn't parse output XML: #{e.class}"
       return
     end
@@ -33,7 +33,7 @@ class SlashdotPlugin < Plugin
       m.reply "search for #{search} failed"
       return
     end
-    puts doc.inspect
+    debug doc.inspect
     max = 8 if max > 8
     done = 0
     doc.elements.each("*/item") {|e|
@@ -50,9 +50,9 @@ class SlashdotPlugin < Plugin
   end
   
   def slashdot(m, params)
-    puts params.inspect
+    debug params.inspect
     max = params[:limit].to_i
-    puts "max is #{max}"
+    debug "max is #{max}"
     xml = @bot.httputil.get(URI.parse("http://slashdot.org/slashdot.xml"))
     unless xml
       m.reply "slashdot news parse failed"
index 821b0cc7f12dd66fa95b0585877e9be9addfc587..f5aa88e61e18c78baabc7977a268043a9d222261 100644 (file)
@@ -346,13 +346,13 @@ class UrlPlugin < Plugin
         raise "Error: Maximum redirects hit."
     end
     
-    puts "+ Getting #{uri_str}"
+    debug "+ Getting #{uri_str}"
     url = URI.parse(uri_str)
     return if url.scheme !~ /https?/
 
     title = nil
     
-    puts "+ connecting to #{url.host}:#{url.port}"
+    debug "+ connecting to #{url.host}:#{url.port}"
     http = @bot.httputil.get_proxy(url)
     http.start { |http|
       url.path = '/' if url.path == ''
@@ -363,15 +363,15 @@ class UrlPlugin < Plugin
           when Net::HTTPRedirection, Net::HTTPMovedPermanently then
             # call self recursively if this is a redirect
             redirect_to = response['location']  || './'
-            puts "+ redirect location: #{redirect_to.inspect}"
+            debug "+ redirect location: #{redirect_to.inspect}"
             url = URI.join url.to_s, redirect_to
-            puts "+ whee, redirecting to #{url.to_s}!"
+            debug "+ whee, redirecting to #{url.to_s}!"
             return get_title_for_url(url.to_s, depth-1)
           when Net::HTTPSuccess then
             if response['content-type'] =~ /^text\//
               # since the content is 'text/*' and is small enough to
               # be a webpage, retrieve the title from the page
-              puts "+ getting #{url.request_uri}"
+              debug "+ getting #{url.request_uri}"
               data = read_data_from_response(response, 50000)
               return get_title_from_html(data)
             else
index fb4738c173a13bcd6e662227478e5c6c97071d34..1baa0d90c9a9504f05c8f098dfd37a2f9dc7b1e5 100644 (file)
@@ -61,7 +61,7 @@ class WserverPlugin < Plugin
       hostname = err.message
       retry
     rescue StandardError => err
-      puts err
+      error err.inspect
       m.reply "couldn't connect to #{uri.host}:#{uri.port} :("
       return
     end