Sha256: 9d5b3ebd9d87aa852eab4fbeea6527afffc0a6cbe9cd205308fa288c03a64a6b
Contents?: true
Size: 727 Bytes
Versions: 4
Compression:
Stored size: 727 Bytes
Contents
plugin = Plugin.new "random" # flips a coin which can come up heads or tails plugin.handle(/^coin$/i) do |data| if rand(2) == 0 next data[:room].me "flipped a coin: Came up tails." else next data[:room].me "flipped a coin: Came up heads." end end # generates a pseudo-random number plugin.handle(/^rand$/i) do |data, args| if args.empty? next data[:room].say rand.to_s else next data[:room].say rand(args[0].to_i).to_s end end # chooses an option from a set of option plugin.handle(/^decide$/i) do |data, args| if args.empty? next data[:room].say "What do you want me to decide?" end next data[:room].say args.sample end $bot.plugins.add(plugin)
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
fantasy-irc-0.3.0 | lib/plugins/random.rb |
fantasy-irc-0.2.3 | lib/plugins/random.rb |
fantasy-irc-0.2.2 | lib/plugins/random.rb |
fantasy-irc-0.2.1 | lib/plugins/random.rb |