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
|
|
|
|
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
|
|
|
|
2021-11-27 02:10:56 +00:00
|
|
|
public JObject ToJson(LookupContext ctx, APIVersion v)
|
|
|
|
{
|
|
|
|
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-01-11 14:43:55 +00:00
|
|
|
o.Add("system", System?.ToJson(ctx, v));
|
|
|
|
o.Add("member", Member?.ToJson(ctx, v: v));
|
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
|
|
|
}
|
|
|
|
}
|