mirror of
https://github.com/Jetsparrow/jetherald.git
synced 2026-01-20 23:56:08 +03:00
Move formatting out of heraldbot
This commit is contained in:
parent
4e3da2e917
commit
d0b2cf2332
@ -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);
|
||||||
|
|
||||||
|
|||||||
@ -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);
|
||||||
|
|
||||||
|
|||||||
@ -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);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user