feat: new chain
This commit is contained in:
+22
-8
@@ -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', [])));
|
||||
|
||||
Reference in New Issue
Block a user