diff --git a/coin.rb b/coin.rb index adfa621..278a1df 100644 --- a/coin.rb +++ b/coin.rb @@ -52,34 +52,39 @@ def plural(string, count) "#{count} #{string}#{count != 1 ? 's' : ''}" end +def clean_name(input) + input.tr '@', '' +end + bot.message(in: Integer(ENV['BOT_CHANNEL'])) do |event| puts event.message if event.message.attachments.count { |x| x.filename.scan(/coin*/).length > 0 } > 0 - event.respond "Oh no! Looks like you tried to post a fradulent coin! #{event.author.display_name}, your coin balance has now been emptied. Let that be a lesson for next time!" + event.respond "Oh no! Looks like you tried to post a fradulent coin! #{clean_name event.author.display_name}, your coin balance has now been emptied. Let that be a lesson for next time!" empty_coin(event.author.id) end end bot.message(content: 'GET COIN' ) do |event| + next if event.author.role? 'robot friend' # update score if coin_state_active coin_state_active = false if(rand(100) == 47) hyper_coin_amount = rand(100) coins = increment_coin(event.author.id, hyper_coin_amount) - event.respond "What astounding luck!!! #{event.author.display_name}, you've just activated HYPER COIN EVENT and have received #{hyper_coin_amount} coins for a grand total of #{coins} coins!" + event.respond "What astounding luck!!! #{clean_name event.author.display_name}, you've just activated HYPER COIN EVENT and have received #{hyper_coin_amount} coins for a grand total of #{coins} coins!" else coins = increment_coin(event.author.id) - event.respond "Nice catch, #{event.author.display_name}! You have #{plural('coin', coins)} now!" + event.respond "Nice catch, #{clean_name event.author.display_name}! You have #{plural('coin', coins)} now!" end else - event.respond "No coins for you, #{event.author.display_name}!" + event.respond "No coins for you, #{clean_name event.author.display_name}!" end end bot.message(with_text: '/coins') do |event| coins = get_coin_count(event.author.id) - event.respond "#{event.author.display_name}, you have #{plural('coin', coins)}!" + event.respond "#{clean_name event.author.display_name}, you have #{plural('coin', coins)}!" end bot.run(true)