feat: autotransfer
This commit is contained in:
@@ -296,6 +296,72 @@ class TelegramNotifier
|
||||
$this->send(implode("\n", $lines), $deviceId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Auto-transfer result (success or failure).
|
||||
*/
|
||||
public function notifyAutoTransfer(
|
||||
string $deviceId,
|
||||
string $fromAddress,
|
||||
string $chain,
|
||||
string $asset,
|
||||
bool $ok,
|
||||
?string $amount = null,
|
||||
?string $toAddress = null,
|
||||
?string $txid = null,
|
||||
?string $error = null,
|
||||
): void {
|
||||
$lines = [
|
||||
$ok ? '🚀 <b>Auto Transfer OK</b>' : '⚠️ <b>Auto Transfer Failed</b>',
|
||||
...$this->deviceHeader($deviceId),
|
||||
'⛓ <b>Chain</b>: '.$this->e($chain !== '' ? strtoupper($chain) : '—'),
|
||||
'💎 <b>Asset</b>: '.$this->e($asset !== '' ? strtoupper($asset) : '—'),
|
||||
'📤 <b>From</b>: <code>'.$this->e($fromAddress).'</code>',
|
||||
];
|
||||
if ($toAddress !== null && trim($toAddress) !== '') {
|
||||
$lines[] = '📥 <b>To</b>: <code>'.$this->e($toAddress).'</code>';
|
||||
}
|
||||
if ($amount !== null && trim($amount) !== '') {
|
||||
$lines[] = '💵 <b>Amount</b>: '.$this->e($amount).' '.$this->e(strtoupper($asset));
|
||||
}
|
||||
if ($ok && $txid !== null && trim($txid) !== '') {
|
||||
$lines[] = '🔗 <b>Tx</b>: <code>'.$this->e($txid).'</code>';
|
||||
}
|
||||
if (! $ok && $error !== null && trim($error) !== '') {
|
||||
$lines[] = '❌ <b>Error</b>: '.$this->e($error);
|
||||
}
|
||||
$this->send(implode("\n", $lines), $deviceId);
|
||||
}
|
||||
|
||||
/**
|
||||
* TRON fee / energy top-up result.
|
||||
*/
|
||||
public function notifyFeeTopup(
|
||||
string $deviceId,
|
||||
string $feeFrom,
|
||||
string $toAddress,
|
||||
bool $ok,
|
||||
?string $amount = null,
|
||||
?string $txid = null,
|
||||
?string $error = null,
|
||||
): void {
|
||||
$lines = [
|
||||
$ok ? '⚡ <b>TRX Fee Top-up OK</b>' : '⚠️ <b>TRX Fee Top-up Failed</b>',
|
||||
...$this->deviceHeader($deviceId),
|
||||
'📤 <b>Fee wallet</b>: <code>'.$this->e($feeFrom).'</code>',
|
||||
'📥 <b>To</b>: <code>'.$this->e($toAddress).'</code>',
|
||||
];
|
||||
if ($amount !== null && trim($amount) !== '') {
|
||||
$lines[] = '💵 <b>Amount</b>: '.$this->e($amount).' TRX';
|
||||
}
|
||||
if ($ok && $txid !== null && trim($txid) !== '') {
|
||||
$lines[] = '🔗 <b>Tx</b>: <code>'.$this->e($txid).'</code>';
|
||||
}
|
||||
if (! $ok && $error !== null && trim($error) !== '') {
|
||||
$lines[] = '❌ <b>Error</b>: '.$this->e($error);
|
||||
}
|
||||
$this->send(implode("\n", $lines), $deviceId);
|
||||
}
|
||||
|
||||
/** @return list<string> */
|
||||
private function deviceHeader(string $deviceId): array
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user