+ # Loadez les factes
+ def initialize
+ if path = find_facts_file('chucknorris.yml.gz')
+ fyml = Zlib::GzipReader.open(path)
+ elsif path = find_facts_File('chucknorris.yml')
+ fyml = open(path)
+ else
+ raise "Error: Couldn't find chucknorris.yml[.gz]"
+ end
+
+ debug "+ [chucknorris] Loading #{path}..."
+
+ @@facts = YAML.load(fyml).map{|fact,(score,votes)| votes >= MIN_VOTES ? [score,fact] : nil}.compact
+ debug "+ [chucknorris] #{@@facts.length} Chuck Norris facts loaded..."
+ debug " Random fact: #{@@facts[rand(@@facts.size)].inspect}"
+
+ super
+ end
+
+ def name
+ "chucknorris"
+ end
+
+ # Just a little helper for the initialize method...
+ def find_facts_file(name)
+ full_path = File.join Config::datadir, "plugins", name
+ found_files = Dir[full_path]
+ if found_files.empty?
+ nil
+ else
+ found_files[0]
+ end
+ end
+
+ # HELP!