Update 'coin.rb'
remove annoying '@' mentions, prevent bots from get coin
This commit is contained in:
parent
dc32fb3dcc
commit
c6fc4cdf0e
15
coin.rb
15
coin.rb
@ -52,34 +52,39 @@ def plural(string, count)
|
|||||||
"#{count} #{string}#{count != 1 ? 's' : ''}"
|
"#{count} #{string}#{count != 1 ? 's' : ''}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def clean_name(input)
|
||||||
|
input.tr '@', ''
|
||||||
|
end
|
||||||
|
|
||||||
bot.message(in: Integer(ENV['BOT_CHANNEL'])) do |event|
|
bot.message(in: Integer(ENV['BOT_CHANNEL'])) do |event|
|
||||||
puts event.message
|
puts event.message
|
||||||
if event.message.attachments.count { |x| x.filename.scan(/coin*/).length > 0 } > 0
|
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)
|
empty_coin(event.author.id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
bot.message(content: 'GET COIN' ) do |event|
|
bot.message(content: 'GET COIN' ) do |event|
|
||||||
|
next if event.author.role? 'robot friend'
|
||||||
# update score
|
# update score
|
||||||
if coin_state_active
|
if coin_state_active
|
||||||
coin_state_active = false
|
coin_state_active = false
|
||||||
if(rand(100) == 47)
|
if(rand(100) == 47)
|
||||||
hyper_coin_amount = rand(100)
|
hyper_coin_amount = rand(100)
|
||||||
coins = increment_coin(event.author.id, hyper_coin_amount)
|
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
|
else
|
||||||
coins = increment_coin(event.author.id)
|
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
|
end
|
||||||
else
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
bot.message(with_text: '/coins') do |event|
|
bot.message(with_text: '/coins') do |event|
|
||||||
coins = get_coin_count(event.author.id)
|
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
|
end
|
||||||
|
|
||||||
bot.run(true)
|
bot.run(true)
|
||||||
|
Loading…
Reference in New Issue
Block a user