logs: add logs and comments

This commit is contained in:
Guillermo Marcel 2025-05-16 12:27:22 -03:00
parent 1a361c6bba
commit 6d20f5fa76
2 changed files with 8 additions and 11 deletions

View File

@ -70,7 +70,7 @@ public class BotController : IController
[BotCommand("/startScan", "Start a scan of last night images")] [BotCommand("/startScan", "Start a scan of last night images")]
public async Task StartScan(TextMessage msg, BotCommand ctx) public async Task StartScan(TextMessage msg, BotCommand ctx)
{ {
await ctx.Responder(msg, "Starting scan 🔍📼"); await ctx.Responder(msg, "Starting scan 🔍📼 (It may take more than an hour)");
await _autoScanApp.StartNewScan(); await _autoScanApp.StartNewScan();
} }
@ -114,7 +114,6 @@ public class BotController : IController
[BotCommand("/status", "Get the status of the alarm")] [BotCommand("/status", "Get the status of the alarm")]
public async Task Status(TextMessage msg, BotCommand ctx) public async Task Status(TextMessage msg, BotCommand ctx)
{ {
await ctx.Responder(msg, _controlServer.IsConnected() ? await ctx.Responder(msg, _controlServer.IsConnected() ?
$"Alarm is connected 🟢\nLast Contact: {FormatTimeSpan(_controlServer.GetLastContactTime())} ago" : $"Alarm is connected 🟢\nLast Contact: {FormatTimeSpan(_controlServer.GetLastContactTime())} ago" :
$"Alarm is not connected 🔴\nLast Contact: {FormatTimeSpan(_controlServer.GetLastContactTime())} ago"); $"Alarm is not connected 🔴\nLast Contact: {FormatTimeSpan(_controlServer.GetLastContactTime())} ago");

View File

@ -97,11 +97,9 @@ public class ControlServer : IControlServer
private readonly List<Card> _cards = new() private readonly List<Card> _cards = new()
{ {
new Card("1", "Card 1"), new Card("0438768a2c6a80", "veriz Guille"),
new Card("2", "Card 2"), new Card("23141f2d", "Pin Azul"),
new Card("3", "Card 3"), new Card("91cf3e02", "Tarjeta Blanca")
new Card("4", "Card 4"),
new Card("5", "Card 5"),
}; };
private void HandleUpdate(HttpListenerResponse response) private void HandleUpdate(HttpListenerResponse response)
{ {
@ -186,14 +184,14 @@ public class ControlServer : IControlServer
public void AuthorizeEvent(long eventId) public void AuthorizeEvent(long eventId)
{ {
if (_events.TryGetValue(eventId, out var sensorEvent)) if (!_events.TryGetValue(eventId, out var sensorEvent)) return;
{ _logger.LogInformation("Authorizing event {eventId}", eventId);
sensorEvent.Authorization = Authorization.Authorized; sensorEvent.Authorization = Authorization.Authorized;
} }
}
public void RequestDisarm() public void RequestDisarm()
{ {
_logger.LogInformation("Disarm request received");
_disarmRequestPending = true; _disarmRequestPending = true;
_disarmRequestTime = DateTime.Now; _disarmRequestTime = DateTime.Now;
} }