littleshop/LittleShop/DTOs/BotDiscoveryDto.cs
SysAdmin 521bff2c7d
All checks were successful
Build and Deploy LittleShop / Deploy to Production VPS (Manual Only) (push) Has been skipped
Build and Deploy LittleShop / Deploy to Pre-Production (CT109) (push) Successful in 1m0s
feat: Add Remote TeleBot Discovery & Configuration
- 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>
2025-11-25 13:41:36 +00:00

147 lines
4.0 KiB
C#

using System.ComponentModel.DataAnnotations;
namespace LittleShop.DTOs;
/// <summary>
/// Input for discovering a remote TeleBot instance
/// </summary>
public class RemoteBotDiscoveryDto
{
[Required]
[StringLength(255)]
public string IpAddress { get; set; } = string.Empty;
[Range(1, 65535)]
public int Port { get; set; } = 5010;
}
/// <summary>
/// Response from TeleBot's discovery probe endpoint
/// </summary>
public class DiscoveryProbeResponse
{
public string InstanceId { get; set; } = string.Empty;
public string Name { get; set; } = string.Empty;
public string Version { get; set; } = string.Empty;
public string Status { get; set; } = string.Empty;
public bool HasToken { get; set; }
public bool IsConfigured { get; set; }
public bool IsInitialized { get; set; }
public string? TelegramUsername { get; set; }
public DateTime Timestamp { get; set; }
}
/// <summary>
/// Input for registering a discovered remote bot
/// </summary>
public class RemoteBotRegistrationDto
{
[Required]
[StringLength(255)]
public string IpAddress { get; set; } = string.Empty;
[Range(1, 65535)]
public int Port { get; set; } = 5010;
[Required]
[StringLength(100)]
public string Name { get; set; } = string.Empty;
[StringLength(500)]
public string Description { get; set; } = string.Empty;
[StringLength(50)]
public string PersonalityName { get; set; } = string.Empty;
/// <summary>
/// Instance ID from the discovery probe response
/// </summary>
public string? RemoteInstanceId { get; set; }
}
/// <summary>
/// Input for configuring a remote bot with Telegram credentials
/// </summary>
public class RemoteBotConfigureDto
{
[Required]
public Guid BotId { get; set; }
[Required]
public string BotToken { get; set; } = string.Empty;
public Dictionary<string, object>? Settings { get; set; }
}
/// <summary>
/// Result of a discovery probe operation
/// </summary>
public class DiscoveryResult
{
public bool Success { get; set; }
public string Message { get; set; } = string.Empty;
public DiscoveryProbeResponse? ProbeResponse { get; set; }
}
/// <summary>
/// Result of initializing a remote bot
/// </summary>
public class InitializeResult
{
public bool Success { get; set; }
public string Message { get; set; } = string.Empty;
public string? InstanceId { get; set; }
}
/// <summary>
/// Result of configuring a remote bot
/// </summary>
public class ConfigureResult
{
public bool Success { get; set; }
public string Message { get; set; } = string.Empty;
public string? TelegramUsername { get; set; }
public string? TelegramDisplayName { get; set; }
public string? TelegramId { get; set; }
}
/// <summary>
/// View model for the discovery wizard
/// </summary>
public class DiscoveryWizardViewModel
{
// Step 1: Discovery
public string IpAddress { get; set; } = string.Empty;
public int Port { get; set; } = 5010;
// Step 2: Registration (populated after probe)
public DiscoveryProbeResponse? ProbeResponse { get; set; }
public string BotName { get; set; } = string.Empty;
public string Description { get; set; } = string.Empty;
public string PersonalityName { get; set; } = string.Empty;
// Step 3: Configuration (populated after registration)
public Guid? BotId { get; set; }
public string? BotKey { get; set; }
public string BotToken { get; set; } = string.Empty;
// Step tracking
public int CurrentStep { get; set; } = 1;
public string? ErrorMessage { get; set; }
public string? SuccessMessage { get; set; }
}
/// <summary>
/// Discovery status constants
/// </summary>
public static class DiscoveryStatus
{
public const string Local = "Local";
public const string AwaitingDiscovery = "AwaitingDiscovery";
public const string Discovered = "Discovered";
public const string Initialized = "Initialized";
public const string Configured = "Configured";
public const string Offline = "Offline";
public const string Error = "Error";
}