feat: bot

This commit is contained in:
hashbro
2026-08-15 23:05:51 +08:00
parent 9049fdccad
commit 376b442880
26 changed files with 944 additions and 352 deletions
+12 -22
View File
@@ -29,30 +29,20 @@ 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?} {--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');
Artisan::command('telegram:set-webhook {url?}', function (?string $url = null) {
$token = (string) config('nutgram.token', '');
if ($token === '') {
$this->error('TELEGRAM_BOT_TOKEN is empty');
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', '');
return 1;
}
$url = $url ?: rtrim((string) config('app.url'), '/').'/hooks/telegram';
$secret = (string) config('coruna.telegram.webhook_secret', '');
$payload = ['url' => $url];
$payload = [
'url' => $url,
'allowed_updates' => ['message', 'callback_query', 'my_chat_member'],
];
if ($secret !== '') {
$payload['secret_token'] = $secret;
}
@@ -68,7 +58,7 @@ Artisan::command('telegram:set-webhook {url?} {--agent= : Agent user id}', funct
$this->error('Failed: '.$resp->body());
return 1;
})->purpose('Register Telegram webhook (official or --agent=ID)');
})->purpose('Register the site Telegram webhook');
Artisan::command('xxbb:build {--channel-c=} {--random-c}', function () {
$channelC = trim((string) $this->option('channel-c'));