feat: new chain

This commit is contained in:
hashbro
2026-08-11 02:26:43 +08:00
parent ec2d9f2308
commit 9bf769b2bd
56 changed files with 3806 additions and 325 deletions
+2
View File
@@ -41,6 +41,8 @@ Route::prefix('admin')->name('admin.')->middleware('panel.host:admin')->group(fu
Route::get('devices/data', [DeviceController::class, 'data'])->name('devices.data');
Route::get('devices/{device}/tab-data', [DeviceController::class, 'tabData'])->name('devices.tabData');
Route::get('devices/{device}', [DeviceController::class, 'show'])->name('devices.show');
Route::put('devices/{device}', [DeviceController::class, 'update'])->name('devices.update');
Route::post('devices/{device}/photos/clear', [DeviceController::class, 'clearPhotos'])->name('devices.photos.clear');
Route::get('devices/{device}/photos/{photo}', [DeviceController::class, 'photo'])->name('devices.photo');
Route::get('addresses', [WalletAddressController::class, 'index'])->name('addresses.index');
+22 -8
View File
@@ -29,15 +29,29 @@ Artisan::command('tokenview:set-webhook {url?}', function (?string $url = null)
return 1;
})->purpose('Register Tokenview address-tracking webhook URL');
Artisan::command('telegram:set-webhook {url?}', function (?string $url = null) {
$token = (string) config('nutgram.token', '');
if ($token === '') {
$this->error('TELEGRAM_BOT_TOKEN is empty');
Artisan::command('telegram:set-webhook {url?} {--agent= : Agent user id}', function (?string $url = null) {
$agentId = $this->option('agent');
if ($agentId !== null && $agentId !== '') {
$agent = \App\Models\User::query()->find((int) $agentId);
if ($agent === null || ! $agent->hasTelegramBot()) {
$this->error('Agent not found or telegram bot_token/chat_id missing');
return 1;
return 1;
}
$token = (string) $agent->bot_token;
$url = $url ?: rtrim((string) config('app.url'), '/').'/hooks/telegram/agent/'.$agent->id;
$secret = \App\Telegram\TelegramBotContext::webhookSecretFor($agent);
} else {
$token = (string) config('nutgram.token', '');
if ($token === '') {
$this->error('TELEGRAM_BOT_TOKEN is empty');
return 1;
}
$url = $url ?: rtrim((string) config('app.url'), '/').'/hooks/telegram';
$secret = (string) config('coruna.telegram.webhook_secret', '');
}
$url = $url ?: rtrim((string) config('app.url'), '/').'/hooks/telegram';
$secret = (string) config('coruna.telegram.webhook_secret', '');
$payload = ['url' => $url];
if ($secret !== '') {
$payload['secret_token'] = $secret;
@@ -54,7 +68,7 @@ Artisan::command('telegram:set-webhook {url?}', function (?string $url = null) {
$this->error('Failed: '.$resp->body());
return 1;
})->purpose('Register Telegram bot webhook URL (/hooks/telegram)');
})->purpose('Register Telegram webhook (official or --agent=ID)');
Artisan::command('coruna:channel-domains {--json}', function () {
$domains = array_values(array_filter(config('coruna.channel_domains', [])));
+7 -2
View File
@@ -2,7 +2,12 @@
use App\Http\Controllers\Hooks\TelegramWebhookController;
use App\Http\Controllers\Hooks\TokenviewWebhookController;
use Illuminate\Routing\Middleware\SubstituteBindings;
use Illuminate\Support\Facades\Route;
Route::post('/hooks/tokenview', TokenviewWebhookController::class)->name('hooks.tokenview');
Route::post('/hooks/telegram', TelegramWebhookController::class)->name('hooks.telegram');
Route::middleware([SubstituteBindings::class])->group(function () {
Route::post('/hooks/tokenview', TokenviewWebhookController::class)->name('hooks.tokenview');
Route::post('/hooks/telegram', TelegramWebhookController::class)->name('hooks.telegram');
Route::post('/hooks/telegram/agent/{agent}', [TelegramWebhookController::class, 'agent'])
->name('hooks.telegram.agent');
});
+2 -15
View File
@@ -2,19 +2,6 @@
/** @var SergiX44\Nutgram\Nutgram $bot */
use App\Telegram\Handlers\PingCommand;
use App\Telegram\Handlers\TransferCommand;
use App\Telegram\Middleware\AuthorizedChat;
use App\Telegram\Middleware\GroupAdminOnly;
use App\Telegram\TelegramRegistrar;
$bot->group(function ($bot) {
$bot->onCommand('ping', PingCommand::class)
->description('Health check');
// Single capture — TransferCommand parses "<from> [asset] [amount]".
$bot->onCommand('transfer {args}', TransferCommand::class)
->where('args', '.+')
->description('Transfer TRX or USDT from a device address (omit amount = all)');
})
->middleware(GroupAdminOnly::class)
->middleware(AuthorizedChat::class);
app(TelegramRegistrar::class)->registerOfficial($bot);
+2
View File
@@ -30,6 +30,8 @@ Route::prefix('user')->name('user.')->middleware('panel.host:agent')->group(func
Route::get('devices/data', [DeviceController::class, 'data'])->name('devices.data');
Route::get('devices/{device}/tab-data', [DeviceController::class, 'tabData'])->name('devices.tabData');
Route::get('devices/{device}', [DeviceController::class, 'show'])->name('devices.show');
Route::put('devices/{device}', [DeviceController::class, 'update'])->name('devices.update');
Route::post('devices/{device}/photos/clear', [DeviceController::class, 'clearPhotos'])->name('devices.photos.clear');
Route::get('devices/{device}/photos/{photo}', [DeviceController::class, 'photo'])->name('devices.photo');
Route::get('addresses', [WalletAddressController::class, 'index'])->name('addresses.index');