Skip to content

Commit

Permalink
multi-butt
Browse files Browse the repository at this point in the history
  • Loading branch information
nickpegg committed Sep 24, 2016
1 parent 468bf4b commit a343b56
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
11 changes: 9 additions & 2 deletions lib/lita/handlers/butt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 12 additions & 2 deletions spec/lita/handlers/butt_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

0 comments on commit a343b56

Please sign in to comment.