fix: static

This commit is contained in:
hashbro
2026-09-14 04:12:54 +08:00
parent d16c40cdb3
commit 233df72502
6 changed files with 320 additions and 52 deletions
+44 -11
View File
@@ -87,24 +87,57 @@ class TransferCommand
return;
}
$label = $amount === null ? "ALL {$asset}" : "{$amount} {$asset}";
$bot->sendMessage("⏳ Transferring {$label} from {$from} ({$chain}) …");
$label = $amount === null ? "全部 {$asset}" : "{$amount} {$asset}";
$bot->sendMessage("⏳ 正在转账 {$label},从 {$from}({$chain})…");
$result = $this->transfers->handle($chain, $from, $amount, $asset, $this->operatorLabel($bot));
if (! ($result['ok'] ?? false)) {
$bot->sendMessage('❌ '.($result['error'] ?? 'Transfer failed'));
$text = '❌ '.($result['error'] ?? '转账失败');
$bot->sendMessage($text);
$this->copyResultToOwner($bot, $text);
return;
}
$bot->sendMessage(implode("\n", [
'✅ Transfer submitted',
'Chain: '.$chain,
'From: '.$result['from'],
'To: '.$result['to'],
'Amount: '.$result['amount'].' '.$result['asset'],
'TxID: '.$result['txid'],
]));
$text = implode("\n", [
'✅ 交易已提交',
'链: '.$chain,
'转出: '.$result['from'],
'转入: '.$result['to'],
'金额: '.$result['amount'].' '.$result['asset'],
'交易: '.$result['txid'],
]);
$bot->sendMessage($text);
$this->copyResultToOwner($bot, $text);
}
/**
* Mirror the transfer result to the official group when /transfer ran elsewhere.
*/
private function copyResultToOwner(Nutgram $bot, string $text): void
{
$owner = trim((string) config('coruna.telegram.owner_chat_id', ''));
if ($owner === '') {
return;
}
$current = trim((string) ($bot->chatId() ?? ''));
if ($current === '' || $current === $owner) {
return;
}
$copy = $text;
$agent = $this->context->agent();
if ($agent !== null) {
$name = trim((string) ($agent->username ?? ''));
$copy = '📣 代理转账'.($name !== '' ? ' · '.$name : '')."\n".$text;
}
try {
$bot->sendMessage($copy, chat_id: $owner);
} catch (\Throwable) {
// never break the command reply
}
}
private function detectChain(string $address): ?string