summaryrefslogtreecommitdiff
path: root/data/rbot/plugins/quotes.rb
diff options
context:
space:
mode:
Diffstat (limited to 'data/rbot/plugins/quotes.rb')
-rw-r--r--data/rbot/plugins/quotes.rb10
1 files changed, 7 insertions, 3 deletions
diff --git a/data/rbot/plugins/quotes.rb b/data/rbot/plugins/quotes.rb
index c631527f..2a646789 100644
--- a/data/rbot/plugins/quotes.rb
+++ b/data/rbot/plugins/quotes.rb
@@ -8,11 +8,15 @@
define_structure :Quote, :num, :date, :source, :quote
class QuotePlugin < Plugin
+ def dirname
+ 'quotes'
+ end
+
def initialize
super
@lists = Hash.new
@changed = Hash.new
- Dir["#{@bot.botclass}/quotes/*"].each {|f|
+ Dir[datafile '*'].each {|f|
next if File.directory?(f)
channel = File.basename(f)
@lists[channel] = Array.new if(!@lists.has_key?(channel))
@@ -27,12 +31,12 @@ class QuotePlugin < Plugin
end
def save
- Dir.mkdir("#{@bot.botclass}/quotes") if(!FileTest.directory?("#{@bot.botclass}/quotes"))
+ Dir.mkdir(datafile) unless FileTest.directory? datafile
@lists.each {|channel, quotes|
begin
if @changed[channel]
debug "Writing new quotefile for channel #{channel} ..."
- Utils.safe_save("#{@bot.botclass}/quotes/#{channel}") {|file|
+ Utils.safe_save(datafile channel) {|file|
quotes.compact.each {|q|
file.puts "#{q.num} | #{q.date} | #{q.source} | #{q.quote}"
}