feat: Bot management improvements with wallet configuration and duplicate detection

This commit is contained in:
2025-10-10 12:34:00 +01:00
parent 91000035f5
commit 7008a95df3
9 changed files with 408 additions and 13 deletions

View File

@@ -307,6 +307,47 @@ public class BotsController : Controller
return RedirectToAction(nameof(Details), new { id });
}
// POST: Admin/Bots/UpdateWallets/5
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> UpdateWallets(Guid id, Dictionary<string, string> wallets)
{
try
{
var bot = await _botService.GetBotByIdAsync(id);
if (bot == null)
{
TempData["Error"] = "Bot not found";
return RedirectToAction(nameof(Index));
}
// Get current settings
var settings = bot.Settings ?? new Dictionary<string, object>();
// Filter out empty wallet addresses
var validWallets = wallets
.Where(w => !string.IsNullOrWhiteSpace(w.Value))
.ToDictionary(w => w.Key, w => w.Value.Trim());
// Update or add wallets section
settings["wallets"] = validWallets;
// Save settings
await _botService.UpdateBotSettingsAsync(id, new UpdateBotSettingsDto { Settings = settings });
_logger.LogInformation("Updated {Count} wallet addresses for bot {BotId}", validWallets.Count, id);
TempData["Success"] = $"Updated {validWallets.Count} wallet address(es) successfully";
return RedirectToAction(nameof(Edit), new { id });
}
catch (Exception ex)
{
_logger.LogError(ex, "Failed to update wallets for bot {BotId}", id);
TempData["Error"] = "Failed to update wallet addresses";
return RedirectToAction(nameof(Edit), new { id });
}
}
// GET: Admin/Bots/RegenerateKey/5
public IActionResult RegenerateKey(Guid id)
{