Sha256: b26ca8817010d5de685ae3f00ef6a641062f728293b46cf2aa91859bbcfc7add

Contents?: true

Size: 402 Bytes

Versions: 11

Compression:

Stored size: 402 Bytes

Contents

require 'calc'

# Let fate decide!
class Robut::Plugin::Pick
  include Robut::Plugin

  desc "pick <a>, <b>, <c>, ...  - randomly selects one of the options"
  match /^pick (.*)/, :sent_to_me => true do |message|
    options = message.split(',').map { |s| s.strip }
    rsp = options[random(options.length)]
    reply("And the winner is... #{rsp}") if rsp
  end

  def random(c)
    rand(c)
  end

end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
sclemmer-robut-0.6.3 lib/robut/plugin/pick.rb
sclemmer-robut-0.6.2 lib/robut/plugin/pick.rb
sclemmer-robut-0.6.1 lib/robut/plugin/pick.rb
sclemmer-robut-0.6.0 lib/robut/plugin/pick.rb
sclemmer-robut-0.5.4 lib/robut/plugin/pick.rb
sclemmer-robut-0.5.3 lib/robut/plugin/pick.rb
sclemmer-robut-0.5.2 lib/robut/plugin/pick.rb
robut-0.5.2 lib/robut/plugin/pick.rb
robut-0.5.1 lib/robut/plugin/pick.rb
robut-0.5.0 lib/robut/plugin/pick.rb
robut-0.4.0 lib/robut/plugin/pick.rb