Merge pull request 'sync w/main' (#1) from mud/bankerbot-rb:main into main

Reviewed-on: yagich/bankerbot-rb#1
This commit is contained in:
Lera Elvoé 2022-11-07 11:56:05 +00:00
commit 899a496f14

19
coin.rb
View File

@ -6,6 +6,9 @@ require 'discordrb'
MAX_COINS_PER_DAY = 3 MAX_COINS_PER_DAY = 3
COIN_TIMEOUT = 15 COIN_TIMEOUT = 15
SCOREBOARD = './scoreboard.yml' SCOREBOARD = './scoreboard.yml'
DUMBASS = 521596582962003968
DUMBASS_BOT = 1034966228755820575
coin_state_active = false coin_state_active = false
coins_offered_today = 0 coins_offered_today = 0
@ -57,7 +60,6 @@ def clean_name(input)
end end
bot.message(in: Integer(ENV['BOT_CHANNEL'])) 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 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! #{clean_name 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)
@ -65,11 +67,13 @@ bot.message(in: Integer(ENV['BOT_CHANNEL'])) do |event|
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
if event.author.bot_account?
event.respond "Bots don't get coins!"
end
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!!! #{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!" 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!"
@ -87,9 +91,16 @@ bot.message(with_text: '/coins') do |event|
event.respond "#{clean_name 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.message(from: DUMBASS_BOT) do |event|
next unless event.message.content.scan(/(?=no swearing)/).count > 0
coins = increment_coin(DUMBASS, -1)
event.respond "<@#{DUMBASS}>, you have been penalized 1 coin for the grossly negligent behavior of your Intellectual Offspring! You now have #{plural('coin', coins)}."
end
bot.run(true) bot.run(true)
loop do loop do
# sleep random amount of time between 1 and 4 hours # sleep random amount of time between 1 and 4 hours
sleep(get_random_hours(1, 4)) sleep(get_random_hours(1, 4))
# activate coin state # activate coin state