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
|
scoreboard[user] || 0
|
||||||
end
|
end
|
||||||
|
|
||||||
def increment_coin(scoreboard, user)
|
def increment_coin(user)
|
||||||
|
scoreboard = load_scoreboard()
|
||||||
coins = get_coin_count(scoreboard, user) + 1
|
coins = get_coin_count(scoreboard, user) + 1
|
||||||
scoreboard[user] = coins
|
scoreboard[user] = coins
|
||||||
|
|
||||||
File.write(SCOREBOARD, scoreboard.to_yaml)
|
File.write(SCOREBOARD, scoreboard.to_yaml)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def empty_coin(user)
|
||||||
|
scoreboard = load_scoreboard()
|
||||||
|
scoreboard[user] = 0
|
||||||
|
|
||||||
|
File.write(SCOREBOARD, scoreboard.to_yaml)
|
||||||
|
end
|
||||||
|
|
||||||
def plural(string, count)
|
def plural(string, count)
|
||||||
"#{count} #{string}#{count != 1 ? 's' : ''}"
|
"#{count} #{string}#{count != 1 ? 's' : ''}"
|
||||||
end
|
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
|
# update score
|
||||||
if coin_state_active
|
if coin_state_active
|
||||||
scoreboard = load_scoreboard()
|
increment_coin(event.author.id)
|
||||||
increment_coin(scoreboard, event.author.id)
|
|
||||||
|
|
||||||
coin_state_active = false
|
coin_state_active = false
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user