forked from mud/bankerbot-rb
naive fradulent activity punishment
This commit is contained in:
parent
339f42234a
commit
3b2586bac1
23
coin.rb
23
coin.rb
@ -30,22 +30,37 @@ def get_coin_count(scoreboard, user)
|
||||
scoreboard[user] || 0
|
||||
end
|
||||
|
||||
def increment_coin(scoreboard, user)
|
||||
def increment_coin(user)
|
||||
scoreboard = load_scoreboard()
|
||||
coins = get_coin_count(scoreboard, user) + 1
|
||||
scoreboard[user] = coins
|
||||
|
||||
File.write(SCOREBOARD, scoreboard.to_yaml)
|
||||
end
|
||||
|
||||
def empty_coin(user)
|
||||
scoreboard = load_scoreboard()
|
||||
scoreboard[user] = 0
|
||||
|
||||
File.write(SCOREBOARD, scoreboard.to_yaml)
|
||||
end
|
||||
|
||||
def plural(string, count)
|
||||
"#{count} #{string}#{count != 1 ? 's' : ''}"
|
||||
end
|
||||
|
||||
bot.message(with_text: 'GET COIN' ) do |event|
|
||||
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.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|
|
||||
# update score
|
||||
if coin_state_active
|
||||
scoreboard = load_scoreboard()
|
||||
increment_coin(scoreboard, event.author.id)
|
||||
increment_coin(event.author.id)
|
||||
|
||||
coin_state_active = false
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user