Skip to content

Instantly share code, notes, and snippets.

@siyo
Created October 11, 2011 17:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save siyo/1278685 to your computer and use it in GitHub Desktop.
Save siyo/1278685 to your computer and use it in GitHub Desktop.
サイコロ降ってtweet / earthquake.gem plugin
# dice tweet / earthquake plugin
#
# e.g. :d100 # update 'D100 = 47' [Yn]
# :10D567 # update '10D567 = 2992' [Yn]
# :3d100 $xx # update '@who 3D100 = 239' [Yn]
#
Earthquake.init do
command %r|^:(\d*)([dD])(\d+)\s*(\d+)*$|, :as => :dice do |m|
t = m[1] == "" ? 1 : m[1].to_i
c = m[4] ? ":reply #{m[4]}" : ":update"
input( "%s %s%s%s = %d" % [ c,
m[1],
m[2],
m[3],
t.times.inject(0){|s| s += rand(m[3].to_i)} ] )
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment