Class: Cinch::Plugins::Porno

Inherits:
Object
  • Object
show all
Includes:
Cinch::Plugin
Defined in:
lib/cinch/plugins/porno.rb

Instance Method Summary collapse

Instance Method Details

#execute_porno(m, search) ⇒ Object


11
12
13
14
15
16
17
18
19
# File 'lib/cinch/plugins/porno.rb', line 11

def execute_porno(m, search)
  pornos = YAML.load_file(config[:porno_list_path])
  if search
    results = pornos.find_all {|title| title =~ /#{Regexp.escape(search)}/i }
    m.reply (results.empty? ? pornos : results).sample, true
  else
    m.reply pornos.sample, true
  end
end