Add min tip amount, min withdrawal amount and withdrawal fee.

This commit is contained in:
t1amak
2025-05-29 07:49:26 +00:00
parent 7a0fae0d7a
commit 6f14445858
4 changed files with 36 additions and 7 deletions

View File

@@ -5,10 +5,12 @@ use Salvium\SalviumWallet;
class SalviumTipBotCommands {
private SalviumTipBotDB $db;
private SalviumWallet $wallet;
private array $config;
public function __construct(SalviumTipBotDB $db, SalviumWallet $wallet) {
public function __construct(SalviumTipBotDB $db, SalviumWallet $wallet, array $config) {
$this->db = $db;
$this->wallet = $wallet;
$this->config = $config;
}
public function handle(string $command, array $args, array $context): void {
@@ -55,6 +57,11 @@ class SalviumTipBotCommands {
list(, $address, $amount) = $args;
$amount = (float) $amount;
if ($amount < $this->config['MIN_WITHDRAWAL_AMOUNT']) {
return "Withdrawal amount too low. Minimum is {$this->config['MIN_WITHDRAWAL_AMOUNT']} SAL.";
}
$user = $this->db->getUserByTelegramId($ctx['user_id']);
if (!$user || $user['tip_balance'] < $amount) return "Insufficient balance or invalid account.";
@@ -71,6 +78,11 @@ class SalviumTipBotCommands {
list(, $targetUsername, $amount) = $args;
$amount = (float)$amount;
if ($amount < $this->config['MIN_TIP_AMOUNT']) {
return "Tip too small. Minimum tip is {$this->config['MIN_TIP_AMOUNT']} SAL.";
}
$sender = $this->db->getUserByTelegramId($ctx['user_id']);
$recipient = $this->db->getUserByUsername(ltrim($targetUsername, '@'));