['private'], 'deposit' => ['private'], 'withdraw' => ['private'], 'balance' => ['private'], 'tip' => ['private', 'group', 'supergroup'], ]; 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 { $method = 'cmd_' . ltrim($command, '/'); $cmdKey = ltrim($command, '/'); $allowedChats = $this->commandAccess[$cmdKey] ?? []; if (!in_array($context['chat_type'], $allowedChats)) { return; // not allowed } if (method_exists($this, $method)) { $response = $this->$method($args, $context); } else { $response = ""; // Optional fallback } if ($response) { sendMessage($context['chat_id'], $response); } $this->db->logMessage($context['chat_id'], $context['chat_name'], $context['username'], $context['raw'], $response); } private function cmd_start(array $args, array $ctx): string { if (!empty($ctx['username'])) { $this->db->updateUsername($ctx['user_id'], $ctx['username']); } return "Welcome to the Salvium Tip Bot! Use /deposit to get started."; } private function cmd_deposit(array $args, array $ctx): string { $user = $this->db->getUserByTelegramId($ctx['user_id']); if (!$user) { $sub = $this->wallet->getNewSubaddress(); if (!$sub) return "Error generating subaddress."; $this->db->createUser($ctx['user_id'], $sub); if (!empty($ctx['username'])) { $this->db->updateUsername($ctx['user_id'], $ctx['username']); } return "Your deposit address: $sub"; } return "Your deposit address: {$user['salvium_subaddress']}"; } private function cmd_balance(array $args, array $ctx): string { $user = $this->db->getUserByTelegramId($ctx['user_id']); return $user ? "Your balance: {$user['tip_balance']} SAL" : "No account found. Use /deposit first."; } private function cmd_withdraw(array $args, array $ctx): string { if (count($args) < 3) return "Usage: /withdraw