diff --git a/lib/lita/handlers/butt.rb b/lib/lita/handlers/butt.rb index 552dc06..3b7a39a 100644 --- a/lib/lita/handlers/butt.rb +++ b/lib/lita/handlers/butt.rb @@ -3,13 +3,20 @@ module Handlers # s/chatbot/chatbutt/ class Butt < Handler # insert handler code here - route(/^b(u*)tt/, :butt, help: { 'butt' => '(_)_)' }) + route(/^b(u*)tt(s?)/, :butt, help: { 'butt' => '(_)_)' }) def butt(response) groups = response.matches.first width = groups.first.size - response.reply "(#{'_' * width})#{'_' * width})" + bottom = '_' * width + butt = "(#{bottom})#{bottom})" + + if groups.last == 's' + response.reply [butt, butt].join ' ' + else + response.reply butt + end end Lita.register_handler(self) diff --git a/spec/lita/handlers/butt_spec.rb b/spec/lita/handlers/butt_spec.rb index dfc3054..1b608e6 100644 --- a/spec/lita/handlers/butt_spec.rb +++ b/spec/lita/handlers/butt_spec.rb @@ -8,12 +8,12 @@ it { is_expected.to route('buuuuuutt').to(:butt) } describe '#butt' do - it 'replied with a butt' do + it 'replies with a butt' do send_message 'butt' expect(replies.last).to eq '(_)_)' end - it 'replied with a big ol butt' do + it 'replies with a big ol butt' do send_message 'buuuuuuuuuutt' expect(replies.last).to eq '(__________)__________)' end @@ -22,5 +22,15 @@ send_message 'btt' expect(replies.last).to eq '())' end + + it 'replies with multiple butts' do + send_message 'butts' + expect(replies.last).to eq '(_)_) (_)_)' + end + + it 'replies with multiple big butts' do + send_message 'buuuuutts' + expect(replies.last).to eq '(_____)_____) (_____)_____)' + end end end