X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=data%2Frbot%2Fplugins%2Fquotes.rb;h=c10666899b0024369f04f2610b87d6e358d6b90b;hb=ac8529c8370bd6dbcb0947bc14e1cc2117826a29;hp=59234e705a4b289a7e4ab98ad10c19f37a2903aa;hpb=3f4e7549e87e73c1630870ba99a0294594c321c6;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git diff --git a/data/rbot/plugins/quotes.rb b/data/rbot/plugins/quotes.rb index 59234e70..c1066689 100644 --- a/data/rbot/plugins/quotes.rb +++ b/data/rbot/plugins/quotes.rb @@ -16,7 +16,7 @@ class QuotePlugin < Plugin super @lists = Hash.new @changed = Hash.new - Dir[datafile '*'].each {|f| + Dir[datafile('*')].each {|f| next if File.directory?(f) channel = File.basename(f) @lists[channel] = Array.new if(!@lists.has_key?(channel)) @@ -36,7 +36,7 @@ class QuotePlugin < Plugin begin if @changed[channel] debug "Writing new quotefile for channel #{channel} ..." - Utils.safe_save(datafile channel) {|file| + Utils.safe_save(datafile(channel)) {|file| quotes.compact.each {|q| file.puts "#{q.num} | #{q.date} | #{q.source} | #{q.quote}" } @@ -80,7 +80,7 @@ class QuotePlugin < Plugin end else # random quote - return @lists[channel].compact[rand(@lists[channel].nitems)], + return @lists[channel].compact.pick_one, @lists[channel].length - 1 end end