about summary refs log tree commit diff
path: root/Utilities/LibMatrix.Utilities.Bot
diff options
context:
space:
mode:
Diffstat (limited to 'Utilities/LibMatrix.Utilities.Bot')
-rw-r--r--Utilities/LibMatrix.Utilities.Bot/Commands/PingCommand.cs15
1 files changed, 14 insertions, 1 deletions
diff --git a/Utilities/LibMatrix.Utilities.Bot/Commands/PingCommand.cs b/Utilities/LibMatrix.Utilities.Bot/Commands/PingCommand.cs

index 76e48f5..161832c 100644 --- a/Utilities/LibMatrix.Utilities.Bot/Commands/PingCommand.cs +++ b/Utilities/LibMatrix.Utilities.Bot/Commands/PingCommand.cs
@@ -1,3 +1,5 @@ +using System.Text.Json; +using System.Text.Json.Nodes; using LibMatrix.EventTypes.Spec; using LibMatrix.Utilities.Bot.Interfaces; @@ -9,5 +11,16 @@ public class PingCommand : ICommand { public string Description { get; } = "Pong!"; public bool Unlisted { get; } - public async Task Invoke(CommandContext ctx) => await ctx.Room.SendMessageEventAsync(new RoomMessageEventContent(body: "pong!")); + public async Task Invoke(CommandContext ctx) { + await ctx.Room.SendMessageEventAsync(new RoomMessageEventContent(body: "pong!") { + AdditionalData = new() { + // maubot ping compatibility + ["pong"] = new { + ms = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() - ctx.MessageEvent.OriginServerTs, + from = ctx.Homeserver.ServerName, + ping = ctx.MessageEvent.EventId + } + } + }); + } } \ No newline at end of file