Advertisement
Azure

Untitled

Sep 11th, 2011
385
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.78 KB | None | 0 0
  1. # az-Android.rb:837
  2.  
  3.             # Random number generator X x Y
  4.             when /^\.rand/i
  5.                 wordarr = words[1].split(" ")
  6.                 wordarr.slice!(0)
  7.                 myphrase = wordarr.join(" ")
  8.                
  9.                 if myphrase.match(/^([^ ]+?)$/i) != nil
  10.                     command( "say Nothing here." )
  11.                 end
  12.                
  13.                 if myphrase.match(/^(-?\d+?) (-?\d+?)$/i) != nil
  14.                     x = Integer(myphrase.match(/^(-?\d+?) (-?\d+?)$/i)[1])
  15.                     y = Integer(CGI::escape(myphrase.match(/^(-?\d+?) (-?\d+?)$/i)[2]))
  16.                     puts "X=#{x} Y=#{y}"
  17.                     if y > x
  18.                         srand();
  19.                         command("say #{triggerUser}, your number is... #{x + rand(y-x)}.")
  20.                     elsif y == x+1
  21.                         command("say Your second number must be greater than your first number + 1.")
  22.                     else
  23.                         command("say Your second number must be larger than your first.")
  24.                     end
  25.                 end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement