Compare commits

..

50 Commits

Author SHA1 Message Date
8eaed5595c big cum 2023-05-19 08:47:38 +00:00
973c4980f8 resize block gif 2023-05-14 19:33:23 +00:00
87d7cc5933 Merge pull request 'fix bad math result spam' (#5) from yagich/bankerbot-rb:fix/fix-bad-math-spam into main
Reviewed-on: #5
2023-05-14 19:32:07 +00:00
ac30629979
fix bad math result spam 2023-05-13 19:27:27 +03:00
3c3815defb FIX AWFUL BUG 2023-05-09 21:39:12 +00:00
06d44e564f
fix missing global variable token 2023-05-09 16:03:33 +02:00
caaf419d6d
send block gif for math questions 2023-05-09 13:38:32 +02:00
d548e00fb3 Merge pull request 'cryptobanky' (#4) from yagich/bankerbot-rb:feat/cryptobanky into main
Reviewed-on: #4
2023-05-09 11:37:03 +00:00
0832d25a26
fix never getting a + 2023-05-08 18:01:51 +03:00
89dcaf46ea
cryptobanky 2023-05-08 17:57:51 +03:00
9ec7f92a4c
fix coin debt exploit 2023-03-29 14:05:48 +02:00
b3e84736dc Update 'coin.rb' 2023-02-24 23:10:24 +00:00
54bc64e337
fix wrong variable 2023-02-14 12:29:59 +01:00
6772fa2711
add coin gift amount to event response 2023-02-14 12:27:44 +01:00
b7c10342bb
decrease bag money amount to 5 2023-02-14 12:24:22 +01:00
ded4ddb09a
effectively remove coin limit 2023-02-14 12:22:15 +01:00
4492dae059
add money bag give coin function 2023-02-14 12:21:32 +01:00
8245932e33 Merge pull request 'prevent coin gifting to coinbot' (#3) from feature/stop-coinbot-gifting into main
Reviewed-on: #3
2023-02-08 10:32:57 +00:00
ebac399c68
prevent coin gifting to coinbot 2023-02-08 11:30:39 +01:00
2490688bb0
change cum word 2023-01-26 17:33:15 +01:00
b243e8d4f0
fix: change bankerbot coin give messages, fix merge 2023-01-26 17:31:22 +01:00
ef57832480 Merge pull request 'GIVE COIN' (#2) from yagich/bankerbot-rb:feat/GIVE-COIN into main
Reviewed-on: #2
2023-01-26 16:21:46 +00:00
c87a54932a
give coin with react 2023-01-26 19:02:27 +03:00
702f0ca119 Update 'coin.rb' 2022-12-23 17:36:36 +00:00
29bca2cafc Update 'coin.rb' 2022-12-23 11:39:26 +00:00
f188c90284 Update 'coin.rb' 2022-11-12 08:09:09 +00:00
ccc19b384e Update 'coin.rb' 2022-11-11 09:37:10 +00:00
5e98f7353b Update 'coin.rb' 2022-11-09 21:12:08 +00:00
6e492fc296 Update 'coin.rb' 2022-11-09 14:12:41 +00:00
0c94e60258 Update 'coin.rb' 2022-11-09 08:10:20 +00:00
cc0c60a82b increase max coins per day 2022-11-09 07:59:08 +00:00
66e6c3f688 narrow down midnight sleep time 2022-11-09 07:58:17 +00:00
d61f9543fb
aggressive bot wars 2022-11-04 14:31:32 +01:00
a9a313aa02 Update 'coin.rb' 2022-10-27 22:18:22 +00:00
56f54bed6a Merge pull request 'fuck off bots' (#1) from yagich/bankerbot-rb:feat/fuck-off-bots into main
Reviewed-on: #1
2022-10-27 22:17:51 +00:00
8014f90e2c
no bots 2022-10-28 01:15:20 +03:00
c6fc4cdf0e Update 'coin.rb'
remove annoying '@' mentions, prevent bots from get coin
2022-10-27 22:10:53 +00:00
dc32fb3dcc
Merge branch 'main' of git.poto.cafe:mud/bankerbot-rb 2022-10-20 11:20:29 +02:00
97e2108968
disable coin state as soon as GET COIN is received 2022-10-20 11:20:05 +02:00
0ffc771d09 add random offset to starting out coin handouts after midnight 2022-10-15 07:16:40 +00:00
dceabb23c3 use author display_name for fraud coins 2022-10-11 17:07:13 +00:00
2ebe97ebcd
implement HYPER COIN EVENT 2022-10-11 16:14:09 +02:00
55ebc9856c
fix scoreboard missing variable for get_coin_count 2022-10-11 14:45:15 +02:00
3b2586bac1
naive fradulent activity punishment 2022-10-11 13:24:26 +02:00
339f42234a fix coin state active 2022-10-10 19:47:09 +00:00
ed0f5d33e7
offer coin up to a max, between 1 and 4 hours 2022-10-10 09:40:47 +02:00
6b586596ae
immediate coin join mode 2022-10-07 20:58:22 +02:00
ae4b1ea6d5
fix pluralize 2022-10-07 20:50:01 +02:00
e32b6f5a00
use display name instead of user name 2022-10-07 20:46:36 +02:00
1d134bd50a
reeanble coin 2022-10-07 17:54:16 +02:00
2 changed files with 162 additions and 28 deletions

BIN
block.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

188
coin.rb
View File

@ -2,9 +2,26 @@ require 'dotenv/load'
require 'yaml'
require 'discordrb'
MAX_COINS_PER_DAY = 999
COIN_TIMEOUT = 15
SCOREBOARD = './scoreboard.yml'
coin_state_active = false
PASTA='You know what? Im done, i am leaving, we were friendly talking about the subject. This crossed the line of "ok killer of joy" to "no fun allowed"'
COIN_EMOJI = '🪙'
BAG_EMOJI = '💰'
COIN_STATE_IDLE = 0
COIN_STATE_ACTIVE = 1
COIN_STATE_MATH = 2
MATH_PROBLEM_COIN_GAIN = 3
$coin_state_active = COIN_STATE_IDLE
$coins_offered_today = 0
$mathproblem_op1 = 0
$mathproblem_op2 = 0
$mathproblem_operator = "+"
bot = Discordrb::Bot.new token: ENV['DISCORD_TOKEN']
@ -13,63 +30,180 @@ def get_seconds_to_midnight(time)
return t2 - time
end
def get_random_duration(time)
max = get_seconds_to_midnight(time)
return rand(0..max)
def get_random_hours(min, max)
min_hours = min * 60 * 60
max_hours = max * 60* 60
return rand(min_hours..max_hours)
end
def load_scoreboard()
YAML::load_file(SCOREBOARD) || {}
end
def get_coin_count(scoreboard, user)
def get_coin_count(user)
scoreboard = load_scoreboard()
scoreboard[user] || 0
end
def increment_coin(scoreboard, user)
coins = get_coin_count(scoreboard, user) + 1
def increment_coin(user, amount=1)
scoreboard = load_scoreboard()
coins = get_coin_count(user) + amount
scoreboard[user] = coins
File.write(SCOREBOARD, scoreboard.to_yaml)
return coins
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' : ''}"
"#{count} #{string}#{count != 1 ? 's' : ''}"
end
bot.message(with_text: 'GET COIN' ) do |event|
def clean_name(input)
input.tr '@', ''
end
def get_coin(event, amt = 1)
# update score
if coin_state_active
scoreboard = load_scoreboard()
increment_coin(scoreboard, event.author.id)
author = event.methods.include?(:author) ? event.author : event.user
coin_state_active = false
coins = get_coin_count(scoreboard, event.author.id)
event.respond "Nice catch, #{event.author.name}! You have #{plural('coin', coins)} now!"
if $coin_state_active != 0
if author.bot_account?
event.respond "Bots don't get coins!"
end
$coin_state_active = COIN_STATE_IDLE
if(rand(100) == 47)
hyper_coin_amount = rand(100)
coins = increment_coin(event.author.id, hyper_coin_amount)
event.respond "What astounding luck!!! #{clean_name 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(author.id, amt)
event.respond "Nice catch, #{clean_name author.display_name}! You have #{plural('coin', coins)} now!"
end
else
event.respond "No coins for you, #{event.author.name}!"
event.respond "No coins for you, #{clean_name author.display_name}!"
end
end
def give_coin(event)
reactor_coins = get_coin_count(event.user.id)
if reactor_coins <= 0
event.respond("Nice gesture, <@#{event.user.id}>, but you're broke! To get more coins, type the words `GET COIN` whenever I post the coin event message! But be quick, your friends are trying their best to get it before you do!")
return
end
if event.message.author == event.user
event.respond("<@#{event.user.id}>, you can't give coins to yourself!")
return
end
coin_amount = 0
if event.emoji.name == COIN_EMOJI
coin_amount = 1
elsif event.emoji.name == BAG_EMOJI
coin_amount = 5
end
if reactor_coins < coin_amount
coin_amount = reactor_coins
end
increment_coin(event.message.author.id, coin_amount)
increment_coin(event.user.id, -coin_amount)
event.respond "How nice! <@#{event.message.author.id}> has received #{plural('coin', coin_amount)} from <@#{event.user.id}>!"
end
bot.message(in: Integer(ENV['BOT_CHANNEL'])) do |event|
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!"
empty_coin(event.author.id)
end
end
bot.message(content: 'GET COIN' ) do |event|
get_coin(event)
end
bot.message(with_text: '/coins') do |event|
coins = get_coin_count(load_scoreboard(), event.author.id)
event.respond "#{event.author.name}, you have #{plural('coin', coins)}!"
coins = get_coin_count(event.author.id)
event.respond "#{clean_name event.author.display_name}, you have #{plural('coin', coins)}!"
end
bot.message(with_text: '!leave') do |event|
event.respond PASTA
end
bot.message(with_text: 'boobs', in: Integer(ENV['CUM_CHANNEL'])) do |event|
next if not ENV['CUM_CHANNEL']
event.respond "# OHHHHHH IM GONNA CUM"
end
bot.reaction_add do |event|
next unless [COIN_EMOJI, BAG_EMOJI].include? event.emoji.name
if event.message.author.id == bot.bot_application.id
get_coin(event)
else
give_coin(event)
end
end
# math problem
bot.message(in: Integer(ENV['BOT_CHANNEL'])) do |event|
next unless $coin_state_active == COIN_STATE_MATH
result = eval("$mathproblem_op1 #{$mathproblem_operator} $mathproblem_op2")
user_result = Integer(event.message.content) rescue false
if result == user_result
get_coin(event, MATH_PROBLEM_COIN_GAIN)
elsif user_result.is_a? Integer
event.respond "Nice try, but you're wrong!"
end
end
bot.run(true)
loop do
# sleep until random time from now to midnight
# sleep(get_random_duration(Time.now))
# sleep random amount of time between 1 and 4 hours
sleep(get_random_hours(1, 4))
if rand(6) == 1
# math problem
# activate coin state
coin_state_active = true
# send coin GIF
bot.send_file(ENV['BOT_CHANNEL'], File.open('./coin.gif', 'r'))
# activate coin state
$coin_state_active = COIN_STATE_MATH
# sleep until midnight to reset cycle
sleep(get_seconds_to_midnight(Time.now))
$mathproblem_op1 = rand(10..150)
$mathproblem_op2 = rand(10..150)
$mathproblem_operator = rand(2) == 1 ? "+" : "-"
# send the math problem
bot.send_file(ENV['BOT_CHANNEL'], File.open('./block.gif', 'r'))
bot.send_message(ENV['BOT_CHANNEL'], "Solve the following for #{MATH_PROBLEM_COIN_GAIN} coins: `#{$mathproblem_op1} #{$mathproblem_operator} #{$mathproblem_op2}`")
else
# activate coin state
$coin_state_active = COIN_STATE_ACTIVE
# send coin GIF
bot.send_file(ENV['BOT_CHANNEL'], File.open('./coin.gif', 'r'))
end
$coins_offered_today += 1
# if max coins per day has reached, sleep until midnight
if $coins_offered_today >= MAX_COINS_PER_DAY
sleep(get_seconds_to_midnight(Time.now))
sleep(get_random_hours(5, 11))
$coins_offered_today = 0
end
end
bot.join()