| Class | Commands::Chucknorris |
| In: |
commands/modules/chucknorris.rb
|
| Parent: | Dispatchers::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 commands/modules/chucknorris.rb, line 42
42: def initialize
43: path = './commands/modules/chucknorris.yml.gz'
44: begin
45: fyml = Zlib::GzipReader.open(path)
46: #yml fyml = open(path)
47: rescue
48: raise "Error: Couldn't find chucknorris.yml[.gz]"
49: end
50:
51: $logger.debug "+ [chucknorris] Loading #{path}..."
52:
53: @@facts = YAML.load(fyml).map{|fact,(score,votes)| votes >= 0 ? [score,fact] : nil}.compact
54: $logger.debug "+ [chucknorris] #{@@facts.length} Chuck Norris facts loaded..."
55: $logger.debug " Random fact: #{@@facts[rand(@@facts.size)].inspect}"
56:
57: super
58: end