feat: Bot management improvements with wallet configuration and duplicate detection
This commit is contained in:
@@ -15,6 +15,86 @@
|
||||
</a>
|
||||
</p>
|
||||
|
||||
@{
|
||||
// Detect duplicates by platform username
|
||||
var duplicateGroups = Model
|
||||
.Where(b => !string.IsNullOrEmpty(b.PlatformUsername))
|
||||
.GroupBy(b => b.PlatformUsername)
|
||||
.Where(g => g.Count() > 1)
|
||||
.ToList();
|
||||
|
||||
if (duplicateGroups.Any())
|
||||
{
|
||||
<div class="alert alert-warning">
|
||||
<h5 class="alert-heading"><i class="bi bi-exclamation-triangle"></i> Duplicate Bots Detected</h5>
|
||||
<p>Found <strong>@duplicateGroups.Count duplicate bot group(s)</strong> with multiple entries for the same Telegram username.</p>
|
||||
<p>This usually happens when the bot container restarts without a saved API key. The system now prevents this automatically.</p>
|
||||
<button type="button" class="btn btn-sm btn-outline-primary" data-bs-toggle="collapse" data-bs-target="#duplicateDetails">
|
||||
Show Details
|
||||
</button>
|
||||
|
||||
<div id="duplicateDetails" class="collapse mt-3">
|
||||
@foreach (var group in duplicateGroups)
|
||||
{
|
||||
<div class="card mb-2">
|
||||
<div class="card-body">
|
||||
<h6 class="card-title">@@@group.Key (@group.Count() entries)</h6>
|
||||
<table class="table table-sm">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Created</th>
|
||||
<th>Last Seen</th>
|
||||
<th>Status</th>
|
||||
<th>Sessions</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var bot in group.OrderByDescending(b => b.LastSeenAt ?? b.CreatedAt))
|
||||
{
|
||||
var isNewest = bot == group.OrderByDescending(b => b.LastSeenAt ?? b.CreatedAt).First();
|
||||
<tr class="@(isNewest ? "table-success" : "")">
|
||||
<td>@bot.CreatedAt.ToString("yyyy-MM-dd HH:mm")</td>
|
||||
<td>
|
||||
@if (bot.LastSeenAt.HasValue)
|
||||
{
|
||||
@bot.LastSeenAt.Value.ToString("yyyy-MM-dd HH:mm")
|
||||
}
|
||||
else
|
||||
{
|
||||
<span class="text-muted">Never</span>
|
||||
}
|
||||
</td>
|
||||
<td><span class="badge bg-@(bot.Status == LittleShop.Enums.BotStatus.Active ? "success" : "secondary")">@bot.Status</span></td>
|
||||
<td>@bot.TotalSessions</td>
|
||||
<td>
|
||||
@if (isNewest)
|
||||
{
|
||||
<span class="badge bg-success">Keep (Most Recent)</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<form action="/Admin/Bots/Delete/@bot.Id" method="post" style="display:inline;">
|
||||
@Html.AntiForgeryToken()
|
||||
<button type="submit" class="btn btn-sm btn-outline-danger"
|
||||
onclick="return confirm('Delete this duplicate bot entry? Sessions: @bot.TotalSessions')">
|
||||
<i class="bi bi-trash"></i> Delete
|
||||
</button>
|
||||
</form>
|
||||
}
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
||||
@if (TempData["Success"] != null)
|
||||
{
|
||||
<div class="alert alert-success alert-dismissible fade show" role="alert">
|
||||
|
||||
Reference in New Issue
Block a user