Move formatting out of heraldbot

This commit is contained in:
Jetsparrow 2022-01-28 15:11:01 +03:00
parent 4e3da2e917
commit d0b2cf2332
3 changed files with 2 additions and 8 deletions

View File

@ -77,7 +77,7 @@ public class HeartbeatController : ControllerBase
var affected = await Db.ReportHeartbeat(t.TopicId, heart, args.ExpiryTimeout); var affected = await Db.ReportHeartbeat(t.TopicId, heart, args.ExpiryTimeout);
if (affected == 1) 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); Timeouts.ApplyCost(t.TopicId, Config.HeartbeatCost);

View File

@ -61,7 +61,7 @@ public class ReportController : ControllerBase
if (Timeouts.IsTimedOut(t.TopicId)) if (Timeouts.IsTimedOut(t.TopicId))
return StatusCode(StatusCodes.Status429TooManyRequests); 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); Timeouts.ApplyCost(t.TopicId, Config.ReportCost);

View File

@ -42,12 +42,6 @@ public partial class JetHeraldBot : IHostedService
await StopTelegram(); 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) public async Task BroadcastMessageRaw(uint topicId, string formatted)
{ {
var chatIds = await Db.GetSubsForTopic(topicId); var chatIds = await Db.GetSubsForTopic(topicId);