2021-11-26 19:23:57 +00:00
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
|
|
|
|
using NodaTime;
|
|
|
|
|
2021-11-27 02:10:56 +00:00
|
|
|
namespace PluralKit.Core;
|
|
|
|
|
|
|
|
public class PKMessage
|
2021-11-26 19:23:57 +00:00
|
|
|
{
|
2021-11-27 02:10:56 +00:00
|
|
|
public ulong Mid { get; set; }
|
|
|
|
public ulong? Guild { get; set; } // null value means "no data" (ie. from before this field being added)
|
|
|
|
public ulong Channel { get; set; }
|
2022-01-11 14:43:55 +00:00
|
|
|
public MemberId? Member { get; set; }
|
2021-11-27 02:10:56 +00:00
|
|
|
public ulong Sender { get; set; }
|
|
|
|
public ulong? OriginalMid { get; set; }
|
|
|
|
}
|
2021-11-26 19:23:57 +00:00
|
|
|
|
2023-05-15 15:17:34 +00:00
|
|
|
public static class PKMessageExt
|
|
|
|
{
|
|
|
|
public static string JumpLink(this PKMessage msg) =>
|
|
|
|
$"https://discord.com/channels/{msg.Guild!.Value}/{msg.Channel}/{msg.Mid}";
|
|
|
|
}
|
|
|
|
|
2021-11-27 02:10:56 +00:00
|
|
|
public class FullMessage
|
|
|
|
{
|
|
|
|
public PKMessage Message;
|
2022-01-11 14:43:55 +00:00
|
|
|
public PKMember? Member;
|
|
|
|
public PKSystem? System;
|
2021-11-26 19:23:57 +00:00
|
|
|
|
2022-04-20 16:20:03 +00:00
|
|
|
public JObject ToJson(LookupContext ctx)
|
2021-11-27 02:10:56 +00:00
|
|
|
{
|
|
|
|
var o = new JObject();
|
2021-11-26 19:23:57 +00:00
|
|
|
|
2021-11-27 02:10:56 +00:00
|
|
|
o.Add("timestamp", Instant.FromUnixTimeMilliseconds((long)(Message.Mid >> 22) + 1420070400000).ToString());
|
|
|
|
o.Add("id", Message.Mid.ToString());
|
|
|
|
o.Add("original", Message.OriginalMid.ToString());
|
|
|
|
o.Add("sender", Message.Sender.ToString());
|
|
|
|
o.Add("channel", Message.Channel.ToString());
|
|
|
|
o.Add("guild", Message.Guild?.ToString());
|
2022-04-20 16:20:03 +00:00
|
|
|
o.Add("system", System?.ToJson(ctx));
|
|
|
|
o.Add("member", Member?.ToJson(ctx));
|
2021-11-26 19:23:57 +00:00
|
|
|
|
2021-11-27 02:10:56 +00:00
|
|
|
return o;
|
2021-11-26 19:23:57 +00:00
|
|
|
}
|
|
|
|
}
|