-# GB: Ok, we *really* need to switch to db for this plugin too
+#-- vim:sw=2:et
+#++
+#
+# :title: Quotes plugin
+#
+# TODO:: use new auth system
+# TODO:: use message mapper instead of multiple ifs
+# TODO:: switch to db
define_structure :Quote, :num, :date, :source, :quote
@changed[channel] = false
}
end
+
def save
Dir.mkdir("#{@bot.botclass}/quotes") if(!FileTest.directory?("#{@bot.botclass}/quotes"))
@lists.each {|channel, quotes|
end
}
end
+
def cleanup
@lists.clear
@changed.clear
end
+
def addquote(source, channel, quote)
@lists[channel] = Array.new if(!@lists.has_key?(channel))
num = @lists[channel].length
@changed[channel] = true
return num
end
+
def getquote(source, channel, num=nil)
return nil unless(@lists.has_key?(channel))
return nil unless(@lists[channel].length > 0)
@lists[channel].length - 1
end
end
+
def delquote(channel, num)
return false unless(@lists.has_key?(channel))
return false unless(@lists[channel].length > 0)
end
return false
end
+
def countquote(source, channel=nil, regexp=nil)
unless(channel)
total=0
end
return matches.length
end
+
def searchquote(source, channel, regexp)
return nil unless(@lists.has_key?(channel))
return nil unless(@lists[channel].length > 0)
return nil
end
end
+
def help(plugin, topic="")
case topic
when "addquote"
return "Quote module (Quote storage and retrieval) topics: addquote, delquote, getquote, searchquote, topicquote, countquote, whoquote, whenquote"
end
end
+
def listen(m)
return unless(m.kind_of? PrivMessage)