From d0b2cf23322463257469e22fb5a859ff4cf1f554 Mon Sep 17 00:00:00 2001 From: Jetsparrow Date: Fri, 28 Jan 2022 15:11:01 +0300 Subject: [PATCH] Move formatting out of heraldbot --- JetHerald/Controllers/HeartbeatController.cs | 2 +- JetHerald/Controllers/ReportController.cs | 2 +- JetHerald/Services/JetHeraldBot.cs | 6 ------ 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/JetHerald/Controllers/HeartbeatController.cs b/JetHerald/Controllers/HeartbeatController.cs index 61dcd5c..9bdbb6b 100644 --- a/JetHerald/Controllers/HeartbeatController.cs +++ b/JetHerald/Controllers/HeartbeatController.cs @@ -77,7 +77,7 @@ public class HeartbeatController : ControllerBase var affected = await Db.ReportHeartbeat(t.TopicId, heart, args.ExpiryTimeout); if (affected == 1) - await Herald.HeartbeatReceived(t, heart); + await Herald.BroadcastMessageRaw(t.TopicId, $"!{t.Description}!:\nHeart \"{heart}\" has started beating at {DateTime.UtcNow:0}"); Timeouts.ApplyCost(t.TopicId, Config.HeartbeatCost); diff --git a/JetHerald/Controllers/ReportController.cs b/JetHerald/Controllers/ReportController.cs index a9ae844..6c9b24e 100644 --- a/JetHerald/Controllers/ReportController.cs +++ b/JetHerald/Controllers/ReportController.cs @@ -61,7 +61,7 @@ public class ReportController : ControllerBase if (Timeouts.IsTimedOut(t.TopicId)) return StatusCode(StatusCodes.Status429TooManyRequests); - await Herald.PublishMessage(t, args.Message); + await Herald.BroadcastMessageRaw(t.TopicId, $"|{t.Description}|:\n{args.Message}"); Timeouts.ApplyCost(t.TopicId, Config.ReportCost); diff --git a/JetHerald/Services/JetHeraldBot.cs b/JetHerald/Services/JetHeraldBot.cs index ff34497..972b89e 100644 --- a/JetHerald/Services/JetHeraldBot.cs +++ b/JetHerald/Services/JetHeraldBot.cs @@ -42,12 +42,6 @@ public partial class JetHeraldBot : IHostedService await StopTelegram(); } - public Task HeartbeatReceived(Topic topic, string heart) - => BroadcastMessageRaw(topic.TopicId, $"!{topic.Description}!:\nHeart \"{heart}\" has started beating."); - - public Task PublishMessage(Topic topic, string message) - => BroadcastMessageRaw(topic.TopicId, $"|{topic.Description}|:\n{message}"); - public async Task BroadcastMessageRaw(uint topicId, string formatted) { var chatIds = await Db.GetSubsForTopic(topicId);