Update bot messages

This commit is contained in:
2025-07-05 15:35:07 +07:00
parent daef7ddcfc
commit b7f608c8ba
6 changed files with 204 additions and 11 deletions

View File

@@ -68,6 +68,11 @@ public class MessengerService : IMessengerService
}
}
public async Task SendMessage(string message, string telegramChannel)
{
await _webhookService.SendMessage(message, telegramChannel);
}
private string BuildPositionMessage(Position position)
{
var direction = position.OriginDirection.ToString();

View File

@@ -77,7 +77,7 @@ public class WebhookService : IWebhookService
message = message,
timestamp = DateTime.UtcNow,
type = "general_message",
telegramChannel = telegramChannel
telegramChannel = FormatTelegramChannel(telegramChannel)
};
// Send the webhook notification
@@ -97,4 +97,23 @@ public class WebhookService : IWebhookService
_logger.LogError(ex, "Error sending webhook message");
}
}
private string FormatTelegramChannel(string? telegramChannel)
{
if (string.IsNullOrEmpty(telegramChannel))
{
return string.Empty;
}
if (telegramChannel.StartsWith("100"))
{
return telegramChannel.Substring(3);
}
else if (telegramChannel.StartsWith("-100"))
{
return telegramChannel.Substring(4);
}
return telegramChannel;
}
}