Class | Extensions::Chucknorris |
In: |
extensions/chucknorris.rb
|
Parent: | Extensions::Simple |
This module provides a helpful Chuck Norris fact. Actions provided are:
This module is adapted from the corresponding plugin of rbot project. Apparently, the main author of the prject as stated in the AUTHORS file is:
Main Author
Please refer to that projects web site for information on the authors: linuxbrit.co.uk/rbot/
INFO | = | { :commands => { 'fact' => { :desc => 'shows a random Chuck Norris fact', :syntax => [ ] |
# File extensions/chucknorris.rb, line 39 def initialize(params={}) path = './extensions/chucknorris.yml.gz' begin fyml = Zlib::GzipReader.open(path) #yml fyml = open(path) rescue raise "Error: Couldn't find chucknorris.yml[.gz]" end $logger.debug{ "\t\t\t[chucknorris] Loading #{path}..." } @@facts = YAML.load(fyml).map{|fact,(score,votes)| votes >= 0 ? [score,fact] : nil}.compact $logger.debug{ "\t\t\t[chucknorris] #{@@facts.length} Chuck Norris facts loaded..." } $logger.debug{ "\t\t\tRandom fact: #{@@facts[rand(@@facts.size)].inspect}" } super end