- Add discovery API endpoints to TeleBot (probe, initialize, configure, status) - Add LivenessService for LittleShop connectivity monitoring with 5min shutdown - Add BotDiscoveryService to LittleShop for remote bot management - Add Admin UI: DiscoverRemote wizard, RepushConfig page, status badges - Add remote discovery fields to Bot model (RemoteAddress, RemotePort, etc.) - Add CheckRemoteStatus and RepushConfig controller actions - Update Index/Details views to show remote bot indicators - Shared secret authentication for discovery, BotKey for post-init 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
178 lines
7.7 KiB
Plaintext
178 lines
7.7 KiB
Plaintext
@model LittleShop.DTOs.BotDto
|
|
@{
|
|
ViewData["Title"] = $"Re-push Configuration - {Model.Name}";
|
|
var hasExistingToken = (bool)(ViewData["HasExistingToken"] ?? false);
|
|
var existingToken = ViewData["ExistingToken"] as string;
|
|
}
|
|
|
|
<h1>Re-push Configuration</h1>
|
|
<h4 class="text-muted">@Model.Name</h4>
|
|
|
|
<nav aria-label="breadcrumb" class="mb-4">
|
|
<ol class="breadcrumb">
|
|
<li class="breadcrumb-item"><a href="/Admin/Bots">Bots</a></li>
|
|
<li class="breadcrumb-item"><a href="/Admin/Bots/Details/@Model.Id">@Model.Name</a></li>
|
|
<li class="breadcrumb-item active" aria-current="page">Re-push Config</li>
|
|
</ol>
|
|
</nav>
|
|
|
|
@if (TempData["Error"] != null)
|
|
{
|
|
<div class="alert alert-danger alert-dismissible fade show" role="alert">
|
|
@TempData["Error"]
|
|
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
|
</div>
|
|
}
|
|
|
|
<div class="row">
|
|
<div class="col-md-8">
|
|
<div class="card border-info">
|
|
<div class="card-header bg-info text-white">
|
|
<h5 class="mb-0"><i class="fas fa-upload"></i> Push Configuration to Remote Bot</h5>
|
|
</div>
|
|
<div class="card-body">
|
|
<p class="text-muted mb-4">
|
|
This will push the Telegram bot token to the remote TeleBot instance at
|
|
<code>@Model.RemoteAddress:@Model.RemotePort</code>.
|
|
Use this when the remote bot has been restarted and needs reconfiguration.
|
|
</p>
|
|
|
|
@if (hasExistingToken)
|
|
{
|
|
<div class="alert alert-success">
|
|
<h6><i class="fas fa-check-circle"></i> Existing Token Found</h6>
|
|
<p class="mb-2">A Telegram bot token is already stored for this bot.</p>
|
|
<form asp-area="Admin" asp-controller="Bots" asp-action="RepushConfig" asp-route-id="@Model.Id" method="post" class="d-inline">
|
|
@Html.AntiForgeryToken()
|
|
<input type="hidden" name="useExistingToken" value="true" />
|
|
<button type="submit" class="btn btn-success">
|
|
<i class="fas fa-sync"></i> Re-push Existing Token
|
|
</button>
|
|
</form>
|
|
</div>
|
|
|
|
<hr />
|
|
|
|
<p class="text-muted">Or provide a new token:</p>
|
|
}
|
|
|
|
<form asp-area="Admin" asp-controller="Bots" asp-action="RepushConfig" asp-route-id="@Model.Id" method="post">
|
|
@Html.AntiForgeryToken()
|
|
<div class="mb-3">
|
|
<label for="botToken" class="form-label">Telegram Bot Token</label>
|
|
<input type="text" class="form-control" id="botToken" name="botToken"
|
|
placeholder="123456789:ABCDefGHIjklMNOpqrsTUVwxyz" required />
|
|
<div class="form-text">
|
|
Get this from <a href="https://t.me/BotFather" target="_blank">@@BotFather</a> on Telegram.
|
|
</div>
|
|
</div>
|
|
|
|
<div class="d-flex gap-2">
|
|
<button type="submit" class="btn btn-primary">
|
|
<i class="fas fa-upload"></i> Push New Token
|
|
</button>
|
|
<a href="/Admin/Bots/Details/@Model.Id" class="btn btn-secondary">
|
|
Cancel
|
|
</a>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card mt-3">
|
|
<div class="card-header">
|
|
<h5 class="mb-0">Current Remote Status</h5>
|
|
</div>
|
|
<div class="card-body">
|
|
<dl class="row mb-0">
|
|
<dt class="col-sm-4">Remote Address</dt>
|
|
<dd class="col-sm-8"><code>@Model.RemoteAddress:@Model.RemotePort</code></dd>
|
|
|
|
<dt class="col-sm-4">Instance ID</dt>
|
|
<dd class="col-sm-8"><code>@(Model.RemoteInstanceId ?? "N/A")</code></dd>
|
|
|
|
<dt class="col-sm-4">Discovery Status</dt>
|
|
<dd class="col-sm-8">
|
|
@switch (Model.DiscoveryStatus)
|
|
{
|
|
case "Configured":
|
|
<span class="badge bg-success">@Model.DiscoveryStatus</span>
|
|
break;
|
|
case "Initialized":
|
|
<span class="badge bg-info">@Model.DiscoveryStatus</span>
|
|
break;
|
|
case "Discovered":
|
|
<span class="badge bg-warning">@Model.DiscoveryStatus</span>
|
|
break;
|
|
case "Offline":
|
|
case "Error":
|
|
<span class="badge bg-danger">@Model.DiscoveryStatus</span>
|
|
break;
|
|
default:
|
|
<span class="badge bg-secondary">@Model.DiscoveryStatus</span>
|
|
break;
|
|
}
|
|
</dd>
|
|
|
|
<dt class="col-sm-4">Last Discovery</dt>
|
|
<dd class="col-sm-8">
|
|
@if (Model.LastDiscoveryAt.HasValue)
|
|
{
|
|
@Model.LastDiscoveryAt.Value.ToString("yyyy-MM-dd HH:mm:ss")
|
|
}
|
|
else
|
|
{
|
|
<span class="text-muted">Never</span>
|
|
}
|
|
</dd>
|
|
</dl>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="col-md-4">
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h5 class="mb-0">Instructions</h5>
|
|
</div>
|
|
<div class="card-body">
|
|
<ol class="ps-3">
|
|
<li class="mb-2">Ensure the remote TeleBot is running and accessible</li>
|
|
<li class="mb-2">If the bot was just restarted, it may be in "Awaiting Discovery" mode</li>
|
|
<li class="mb-2">Enter the Telegram bot token from @@BotFather</li>
|
|
<li class="mb-2">Click "Push New Token" to configure the remote bot</li>
|
|
</ol>
|
|
|
|
<hr />
|
|
|
|
<h6>When to use this:</h6>
|
|
<ul class="ps-3 text-muted small">
|
|
<li>After TeleBot container restart</li>
|
|
<li>When changing the Telegram bot token</li>
|
|
<li>If the remote bot lost its configuration</li>
|
|
<li>After infrastructure recovery</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card mt-3">
|
|
<div class="card-header">
|
|
<h5 class="mb-0">Quick Actions</h5>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="d-grid gap-2">
|
|
<form asp-area="Admin" asp-controller="Bots" asp-action="CheckRemoteStatus" asp-route-id="@Model.Id" method="post" class="d-inline">
|
|
@Html.AntiForgeryToken()
|
|
<button type="submit" class="btn btn-outline-info w-100">
|
|
<i class="fas fa-sync"></i> Check Remote Status
|
|
</button>
|
|
</form>
|
|
<a href="/Admin/Bots/Details/@Model.Id" class="btn btn-outline-secondary">
|
|
<i class="fas fa-arrow-left"></i> Back to Details
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|