Commit Graph

58 Commits

Author SHA1 Message Date
Rene Arumetsa
3b35f82d80 Fix RequestView over-funding reentrancy (do_give double-transfer)
A follow-up reentrancy sweep of the five remaining money-moving views found
one more instance of the same bug class. The other four (quests, prestige,
fish, shop) verified clean - their underlying do_* functions are idempotent.

RequestView / FundModal (commands/economy_support_commands.py):
- on_submit read self._view.remaining, then awaited do_give, then decremented
  remaining. Because discord.py dispatches each modal submit as its own task
  and do_give is a plain non-idempotent transfer, a funder could open two
  modals and submit both before the first resolved: both read the same
  pre-decrement remaining, both passed the range check, and both transferred
  `amount` - over-funding the request (remaining goes negative) and moving up
  to the funder's whole balance.
- Fix: reserve the amount synchronously (decrement remaining BEFORE the do_give
  await, with no await in between - atomic under asyncio), and roll the
  reservation back if the transfer fails. The second concurrent submit now
  sees the reduced remaining and is rejected. Added a cheap _fund guard
  (remaining<=0 / is_finished) so a click on a funded request doesn't open a
  dead modal.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-08-10 18:49:25 +03:00
Rene Arumetsa
968356f925 Fix money-safety bugs in economy (heist, blackjack, bail)
Multi-agent audit of the money-moving economy modules surfaced three
confirmed correctness bugs. All three are fixed here with regression tests.

heist (core/economy/heist.py):
- `house = await get_user(house.HOUSE_ID)` shadowed the imported `house`
  module for the whole function, so `house.HOUSE_ID` raised UnboundLocalError
  on every successful heist (win payout was entirely dead) and on the
  fail-path compensation branch. Rename the local to `house_rec`.
- Un-shadowing exposed a latent mint: the pot was floored at 300 but the
  house was debited only min(total, balance), so a poor house paid out more
  than it lost. Cap the pot at the balance and debit exactly what is paid
  (house debit == sum of payouts). No mint, no leak.
- Add the missing `_is_jailed` import (do_heist_check referenced it unimported).

blackjack (commands/economy_games_commands.py):
- Button callbacks had no reentrancy guard; discord.py dispatches each click
  as its own task, so double-clicking Stand within the dealer-reveal window
  paid out twice (mint), and double-clicking Double/Split deducted the extra
  bet twice. Add a synchronous `_busy` guard (matching the existing RpsGame
  idiom) on all four callbacks plus a `_resolved` idempotency flag on
  settlement, so a game can only pay out once.

bail (core/economy/jail.py, commands/economy_extra_commands.py):
- do_bail only checked balance, never jail state; a double-click or a stale
  BailView from a re-run /jailbreak charged bail twice, destroying coins (bail
  is a pure sink). Make do_bail a no-op when the user is not jailed, and add a
  UI reentrancy guard + "already free" message.

Tests: 47 passed (4 new regression tests covering heist coin-conservation and
bail idempotency).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-08-10 18:31:46 +03:00
Rene Arumetsa
8d16da268d Fix eco bot service
All checks were successful
Test & Deploy / test (push) Successful in 21s
Test & Deploy / deploy (push) Successful in 7s
2026-07-27 15:52:51 +03:00
Rene Arumetsa
4dd7379e03 Fix workflow
Some checks failed
Test & Deploy / test (push) Successful in 22s
Test & Deploy / deploy (push) Failing after 7s
2026-07-27 15:22:56 +03:00
Rene Arumetsa
7fc0ccc77f Fix deploy.yml
Some checks failed
Test & Deploy / test (push) Successful in 57s
Test & Deploy / deploy (push) Failing after 5s
2026-07-27 01:04:26 +03:00
Rene Arumetsa
83a60cda55 Refator eco code. Split into modules
Some checks failed
Test & Deploy / test (push) Has been cancelled
Test & Deploy / deploy (push) Has been cancelled
2026-07-27 00:49:34 +03:00
Rene Arumetsa
d89383ee20 CI test
Some checks failed
Test & Deploy / test (push) Failing after 12m44s
Test & Deploy / deploy (push) Has been cancelled
2026-07-27 00:25:25 +03:00
Rene Arumetsa
8884cce9b5 Added a runner, ci/cd 2026-07-26 21:45:23 +03:00
Rene Arumetsa
94fe57a596 Add startup scheme 2026-07-26 21:36:26 +03:00
Rene Arumetsa
c40c871a4b Sync pb 2026-07-26 21:29:35 +03:00
Rene Arumetsa
5ba5642694 Added tests, fix README. 2026-07-26 20:32:13 +03:00
Rene Arumetsa
cb18d9b882 Added quests 2026-07-26 20:11:14 +03:00
Rene Arumetsa
0cdd8dac63 Update env variables 2026-06-21 22:49:46 +03:00
Rene Arumetsa
6101a278e7 Admin check now a dict 2026-06-21 22:40:57 +03:00
Rene Arumetsa
1e9ec56761 Update tipidice emoij to be animated 2026-06-03 18:50:06 +03:00
Rene Arumetsa
a96488fe9e Added eco server emoij ID 2026-06-03 18:45:46 +03:00
Rene Arumetsa
25cf60d2e1 Fix conflict 2026-06-03 18:38:40 +03:00
Rene Arumetsa
3939c879c9 Refacor emoijs to use application emoijs 2026-06-03 18:34:29 +03:00
Rene Arumetsa
42f7bae681 Edit discord role rights 2026-06-01 22:19:12 +03:00
Rene Arumetsa
b0e23c1a17 Change admin command permissions 2026-06-01 22:11:44 +03:00
Rene Arumetsa
24de79c503 Edit discord interaction, seems to cause a trouble 2026-05-25 17:51:33 +03:00
Rene Arumetsa
ee4e639c30 Remove custom_id from shop, which causes bug of tiers not working 2026-05-25 17:44:43 +03:00
Rene Arumetsa
48cc8398ec Rename logger to include bot profiles 2026-05-20 17:48:44 +03:00
Rene Arumetsa
b83b347d6a Fix shop interation 2026-05-19 18:37:42 +03:00
Rene Arumetsa
8d7ac504ca Change exp leveling system 2026-05-13 22:43:34 +03:00
Rene Arumetsa
15e3121d55 Fix birthday bug 2026-05-11 22:28:21 +03:00
Rene Arumetsa
b0a3dcb03b Document cleanup 2026-05-04 20:50:30 +03:00
Rene Arumetsa
0e617d87a2 Merge branch 'master' of ssh://git.lapikud.ee:202/renkar/tipibot 2026-05-04 20:18:31 +03:00
Rene Arumetsa
2c2621d24e Make exp gains less grindy 2026-05-04 17:48:55 +03:00
Rene Arumetsa
192888625e Refactor db error catch to one helper 2026-05-04 17:31:16 +03:00
Rene Arumetsa
6d344a47f4 Fix 403 auth error 2026-05-04 17:14:21 +03:00
Rene Arumetsa
07e7f5e0b2 More bug fixes 2026-05-03 15:11:32 +03:00
Rene Arumetsa
d65173fbe9 Some bug updates 2026-05-03 14:45:42 +03:00
Rene Arumetsa
58684d5f34 Add patch notes to bot 2026-05-03 12:02:19 +03:00
Rene Arumetsa
8529706809 Remove docker support 2026-05-03 09:21:39 +03:00
Rene Arumetsa
173e2564f1 Add missing import 2026-05-01 10:52:48 +03:00
Rene Arumetsa
93f4d471dc Add db error in functions 2026-04-29 00:04:24 +03:00
Rene Arumetsa
de7cfce833 Lower pb token timeout 2026-04-29 00:00:18 +03:00
Rene Arumetsa
a4a447867f Added ci/cd 2026-04-26 21:51:07 +03:00
Rene Arumetsa
9ae26049c5 Fix fishing sell bug 2026-04-26 20:37:07 +03:00
Rene Arumetsa
b998418c14 Remove data/, usless folder 2026-04-20 23:13:02 +03:00
Rene Arumetsa
94df54dde2 Remove data/ from git logs 2026-04-20 23:06:17 +03:00
Rene Arumetsa
77a3badd41 Feature: Clean up the codebase 2026-04-20 23:01:51 +03:00
Rene Arumetsa
17102ae202 Removed BOT_PROFILE from .env, set in compose.yml instead 2026-04-20 22:52:29 +03:00
Rene Arumetsa
cd41bc2a48 Remove DEV_NOTE3S in root directory 2026-04-20 22:42:26 +03:00
802a6a2e8d Merge pull request 'Add container support' (#2) from containers into master
Reviewed-on: #2
2026-04-20 19:39:24 +00:00
Rene Arumetsa
64d9b304a9 Add container support 2026-04-20 22:37:55 +03:00
Rene Arumetsa
07360d3f11 Remove logs from git 2026-04-20 22:28:24 +03:00
8f28832432 Merge pull request 'Feature: Start with rewrite-v2' (#1) from rewrite-v2 into master
Reviewed-on: #1
2026-04-20 19:09:45 +00:00
AlacrisDevs
4d1981420d Fucking shit pask bad 2026-04-20 12:09:39 +03:00