Class: Robut::Plugin::Commitments
- Inherits:
-
Object
- Object
- Robut::Plugin::Commitments
- Includes:
- Robut::Plugin
- Defined in:
- lib/robit/plugins/commitments.rb
Instance Method Summary collapse
Instance Method Details
#handle(time, sender, message) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/robit/plugins/commitments.rb', line 22 def handle time, sender, case .strip.lines.to_a.join(' ') when /^#commit$/ cs = commits if cs.empty? reply 'No commitments' else reply prettify(cs) end when /^#commit +help$/ reply usage when /^#commit +clear$/ cs = clear if cs.empty? reply 'No commitments to clear' else reply 'Cleared commitments' end when /^#commit +delete +(\d+)$/ c = delete($1) if c reply 'Deleted commitment' else reply 'No such commitment to delete' end when /^#commit +marquee +stop?$/ if threads.include? current_room_name threads.delete(current_room_name).kill reply 'Stopped marquee' else reply 'No such marquee to stop' end when /^#commit +marquee( +\d+)?$/ if threads.include? current_room_name reply 'Already going' else interval = ($1 || '60').strip.to_i threads[current_room_name] = Thread.new do periodically_update_topic current_room, interval end reply 'Started marquee' end when /^#commit +(.*?)$/m cs = commit $1 reply prettify(cs) when /^#commit/ reply 'Invalid ' + usage end end |
#usage ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/robit/plugins/commitments.rb', line 10 def usage [ 'Usage:', "#commit - Return all commitments", "#commit help - Return this help text", "#commit clear - Delete all commitments", "#commit delete <N> - Delete a commitment", "#commit marquee - Start a rolling marquee", "#commit <commitment> - Make a new commitment" ].join("\n") end |