@php /** @var \Illuminate\Support\Collection $bots */ $tgGlyph = ''; $tgAccounts = $accounts ?? collect(); $tgAccount = $tgAccounts->first(fn ($a) => $a->hasSession()) ?? $tgAccounts->first(); $tgConnected = $tgAccount && $tgAccount->hasSession(); $tgPending = session()->has('telegram.account.login_id'); $tgNeedPw = (bool) session('telegram.account.need_password'); $tgSentTo = (string) session('telegram.account.sent_to', ''); $botCount = $bots->count(); @endphp
{{-- Header --}}
{{ __('Channel') }} · {{ __('Telegram') }}

{{ __('Telegram') }} {{ __('Connect') }}

{{ __('Deploy a Telegram bot to automate messaging workflows, handle client support, and broadcast updates to your subscribers worldwide.') }}

@if (session('status') || session('success'))
{{ session('status') ?: session('success') }}
@endif @if ($errors->any())
    @foreach ($errors->all() as $e)
  • {{ $e }}
  • @endforeach
@endif
{{-- ── LEFT: connect cards + connected bots ── --}}
{{-- Bot connection card --}}
{!! $tgGlyph !!} @if ($botCount > 0) {{ $botCount }} {{ __('connected') }} @else {{ __('Not Connected') }} @endif
{{ __('Telegram Bot Connection') }}

{{ __('Paste a bot token from @BotFather to automate messaging, handle support, and broadcast to your subscribers.') }}

{{-- Account connection card (MTProto — QR / phone). Second way in. --}}
@if ($tgConnected) {{ __('Connected') }} @else {{ __('Not Connected') }} @endif
{{ __('Telegram Account Connection') }}
@if ($tgConnected)

{{ __('Signed in as') }} {{ $tgAccount->label() }}{{ $tgAccount->phone ? ' · '.$tgAccount->phone : '' }}. {{ __('Create bots below — no @BotFather typing.') }}

{{-- Create a bot --}}
@csrf
{{ __('Create a new bot') }}
@
{{-- Account status + actions --}}
{{ mb_strtoupper(mb_substr($tgAccount->label(), $tgAccount->username ? 1 : 0, 1)) }}
{{ $tgAccount->label() }}
{{ __('linked') }} {{ optional($tgAccount->connected_at)->diffForHumans() }}
@csrf
@csrf @method('DELETE')

{{ __('This login can read the account’s chats — stored encrypted, used only to talk to @BotFather.') }}

@elseif ($tgPending) {{-- Code entry after a phone-code request. --}}

{{ $tgSentTo === 'telegram_app' ? __('Telegram sent a code to your Telegram app — check your other signed-in devices.') : __('Telegram sent a login code to :phone.', ['phone' => session('telegram.account.phone', __('your number'))]) }}

@csrf @if ($tgNeedPw)

{{ __('Your account has two-step verification — re-enter the code with your password.') }}

@endif
@else

{{ __('Link your Telegram account to create bots right here — scan a QR or use your phone number, just like WhatsApp.') }}

@if (auth()->user()?->isAdmin()) {{ __('Optional — needs a Telegram API id/hash in Admin → Channel Settings.') }} @endif
@endif
{{-- Connected bots --}} @if ($botCount > 0)
{{ __('Connected bots') }}
@foreach ($bots as $b) @php $live = $b->active && ! $b->last_error; @endphp
{!! $tgGlyph !!}
{{ $b->bot_name ?: $b->bot_username }} @if ($live) {{ __('Live') }} @elseif (! $b->active) {{ __('Paused') }} @else {{ __('Needs attention') }} @endif
@if($b->bot_username)@ {{ ltrim($b->bot_username, '@') }}@endif
@if ($b->last_error)
{{ $b->last_error }}
@endif @if ($b->last_inbound_at)
{{ __('Last message') }} {{ $b->last_inbound_at->diffForHumans() }}
@endif
{{-- Payments --}}
{{ __('Payments') }} @if ($b->payment_provider_token){{ __('on') }}@endif
@csrf

{{ __('Paste a payment provider token from @BotFather (/mybots → Payments) to enable the Payment flow node — native in-chat invoices.') }}

@if ($b->payment_provider_token) @else@endif
{{ __('Webhook') }}: {{ \Illuminate\Support\Str::limit($b->webhookUrl(), 42, '…') }}
@csrf
@csrf
@csrf @method('DELETE')
@endforeach
@endif
{{-- ── RIGHT: setup guide + prerequisites + what's unlocked + tip ── --}}
{{-- ── MODAL: Connect a bot (paste @BotFather token) ── --}} {{-- ── MODAL: Connect an account (QR / phone code) ── --}}