First Commit

This commit is contained in:
marco
2026-09-01 07:49:48 -03:00
commit 28b1044038
399 changed files with 41659 additions and 0 deletions
+171
View File
@@ -0,0 +1,171 @@
@extends('layouts.app')
@section('title', __('Telegram Integration'))
@section('header')
<div class="flex justify-between items-center">
<h2 class="font-semibold text-xl text-gray-800 leading-tight">
{{ __('Telegram Integration') }}
</h2>
</div>
@endsection
@section('content')
<div class="py-6">
<div class="max-w-4xl mx-auto sm:px-6 lg:px-8">
@if(session('success'))
<div class="bg-green-100 border border-green-400 text-green-700 px-4 py-3 rounded-lg mb-6">
{{ session('success') }}
</div>
@endif
@if(session('error'))
<div class="bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded-lg mb-6">
{{ session('error') }}
</div>
@endif
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<!-- Configure Bot -->
<div class="bg-white rounded-xl shadow-sm border border-gray-100 p-6">
<div class="flex items-center gap-3 mb-4">
<div class="w-12 h-12 bg-blue-100 rounded-lg flex items-center justify-center">
<svg class="w-6 h-6 text-blue-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"/>
</svg>
</div>
<div>
<h3 class="text-lg font-semibold text-gray-900">{{ __('Configure Your Bot') }}</h3>
<p class="text-sm text-gray-500">{{ __('Set up your own Telegram bot to receive insights.') }}</p>
</div>
</div>
<div class="bg-gray-50 rounded-lg p-4 mb-4">
<h4 class="text-sm font-medium text-gray-700 mb-2">{{ __('How to create your bot:') }}</h4>
<ol class="text-sm text-gray-600 space-y-2 list-decimal list-inside">
<li>{{ __('Open Telegram and search for') }} <strong>@BotFather</strong></li>
<li>{{ __('Send') }} <code>/newbot</code> {{ __('and follow the instructions') }}</li>
<li>{{ __('Copy the HTTP API token provided by BotFather') }}</li>
<li>{{ __('Start a chat with your new bot and send') }} <code>/start</code></li>
<li>{{ __('Get your Chat ID (use @userinfobot or similar)') }}</li>
<li>{{ __('Fill in the fields below and click Connect') }}</li>
</ol>
</div>
<form method="POST" action="{{ route('admin.telegram.connect') }}" class="space-y-4">
@csrf
<div>
<label for="bot_token" class="block text-sm font-medium text-gray-700 mb-2">
{{ __('Bot Token') }} *
</label>
<input type="text" name="bot_token" id="bot_token" required
value="{{ old('bot_token', $telegramUser->bot_token ?? '') }}"
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500 font-mono text-sm"
placeholder="1234567890:ABCdefGHIjklMNOpqrsTUVwxyz">
</div>
<div>
<label for="bot_username" class="block text-sm font-medium text-gray-700 mb-2">
{{ __('Bot Username (optional)') }}
</label>
<input type="text" name="bot_username" id="bot_username"
value="{{ old('bot_username', $telegramUser->bot_username ?? '') }}"
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500"
placeholder="@your_bot">
</div>
<div>
<label for="chat_id" class="block text-sm font-medium text-gray-700 mb-2">
{{ __('Chat ID') }} *
</label>
<input type="text" name="chat_id" id="chat_id" required
value="{{ old('chat_id', $telegramUser->chat_id ?? '') }}"
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500 font-mono text-sm"
placeholder="123456789">
</div>
<div>
<label for="telegram_username" class="block text-sm font-medium text-gray-700 mb-2">
{{ __('Your Telegram Username (optional)') }}
</label>
<input type="text" name="telegram_username" id="telegram_username"
value="{{ old('telegram_username', $telegramUser->telegram_username ?? '') }}"
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500"
placeholder="@your_username">
</div>
<button type="submit" class="w-full px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition font-medium">
{{ $telegramUser && $telegramUser->isFullyConfigured() ? __('Update Bot Configuration') : __('Connect Bot') }}
</button>
</form>
</div>
<!-- Connection Status & Test -->
<div class="bg-white rounded-xl shadow-sm border border-gray-100 p-6">
<div class="flex items-center gap-3 mb-4">
<div class="w-12 h-12 {{ $telegramUser && $telegramUser->isFullyConfigured() ? 'bg-green-100' : 'bg-gray-100' }} rounded-lg flex items-center justify-center">
<svg class="w-6 h-6 {{ $telegramUser && $telegramUser->isFullyConfigured() ? 'text-green-600' : 'text-gray-400' }}" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"/>
</svg>
</div>
<div>
<h3 class="text-lg font-semibold text-gray-900">{{ __('Connection Status') }}</h3>
<p class="text-sm text-gray-500">{{ __('Your bot configuration status.') }}</p>
</div>
</div>
@if($telegramUser && $telegramUser->isFullyConfigured())
<div class="bg-green-50 border border-green-200 rounded-lg p-4 mb-4">
<div class="flex items-center gap-2 mb-2">
<span class="w-3 h-3 rounded-full bg-green-500"></span>
<span class="text-sm font-medium text-green-800">{{ __('Bot Configured') }}</span>
</div>
@if($telegramUser->bot_username)
<p class="text-sm text-green-700">{{ __('Bot: :username', ['username' => '@' . ltrim($telegramUser->bot_username, '@')]) }}</p>
@endif
<p class="text-sm text-green-700">{{ __('Chat ID: :id', ['id' => $telegramUser->chat_id]) }}</p>
<p class="text-sm text-green-700">{{ __('Connected since: :date', ['date' => $telegramUser->created_at->format('d/m/Y H:i')]) }}</p>
</div>
<div class="flex gap-2 mb-4">
<!-- Test Button -->
<form method="POST" action="{{ route('admin.telegram.test') }}" class="flex-1">
@csrf
<button type="submit" class="w-full px-4 py-2 bg-green-600 text-white rounded-lg hover:bg-green-700 transition font-medium">
<svg class="w-4 h-4 inline mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M14.752 11.168l-3.197-2.132A1 1 0 0010 9.87v4.263a1 1 0 001.555.832l3.197-2.132a1 1 0 000-1.664z"/>
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 12a9 9 0 11-18 0 9 9 0 0118 0z"/>
</svg>
{{ __('Send Test Message') }}
</button>
</form>
<!-- Disconnect Button -->
<form method="POST" action="{{ route('admin.telegram.disconnect') }}">
@csrf
<button type="submit" class="px-4 py-2 bg-red-600 text-white rounded-lg hover:bg-red-700 transition font-medium"
onclick="return confirm('{{ __('Disconnect Telegram bot?') }}')">
{{ __('Disconnect') }}
</button>
</form>
</div>
@else
<div class="bg-gray-50 border border-gray-200 rounded-lg p-4 mb-4">
<div class="flex items-center gap-2 mb-2">
<span class="w-3 h-3 rounded-full bg-gray-400"></span>
<span class="text-sm font-medium text-gray-600">{{ __('Not Configured') }}</span>
</div>
<p class="text-sm text-gray-500">{{ __('Create your own Telegram bot and configure it here to receive insights.') }}</p>
</div>
@endif
<div class="bg-indigo-50 border border-indigo-100 rounded-lg p-4">
<h4 class="text-sm font-medium text-indigo-800 mb-2">{{ __('Why use your own bot?') }}</h4>
<ul class="text-sm text-indigo-700 space-y-1">
<li>✓ {{ __('Full control over your notifications') }}</li>
<li>✓ {{ __('No shared bots - completely private') }}</li>
<li>✓ {{ __('Receive insights in real-time') }}</li>
<li>✓ {{ __('Works with your existing bot configuration') }}</li>
</ul>
</div>
</div>
</div>
</div>
</div>
@endsection