From 3e934eee892f69a8f78b94950993000522702769 Mon Sep 17 00:00:00 2001 From: "Emma [it/its]@Rory&" Date: Thu, 23 Nov 2023 05:42:33 +0100 Subject: Moderation bot work --- .../StateEventTypes/Policies/BasePolicy.cs | 52 ++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 ExampleBots/ModerationBot/StateEventTypes/Policies/BasePolicy.cs (limited to 'ExampleBots/ModerationBot/StateEventTypes/Policies/BasePolicy.cs') diff --git a/ExampleBots/ModerationBot/StateEventTypes/Policies/BasePolicy.cs b/ExampleBots/ModerationBot/StateEventTypes/Policies/BasePolicy.cs new file mode 100644 index 0000000..94b2f63 --- /dev/null +++ b/ExampleBots/ModerationBot/StateEventTypes/Policies/BasePolicy.cs @@ -0,0 +1,52 @@ +using System.ComponentModel.DataAnnotations; +using System.Text.Json.Serialization; +using LibMatrix; +using LibMatrix.Interfaces; + +namespace ModerationBot.StateEventTypes.Policies; + +public abstract class BasePolicy : EventContent { + /// + /// Entity this policy applies to, null if event was redacted + /// + [JsonPropertyName("entity")] + public string? Entity { get; set; } + + /// + /// Reason this policy exists + /// + [JsonPropertyName("reason")] + public string? Reason { get; set; } + + /// + /// Suggested action to take, one of `ban`, `kick`, `mute`, `redact`, `spoiler`, `warn` or `warn_admins` + /// + [JsonPropertyName("recommendation")] + [AllowedValues("ban", "kick", "mute", "redact", "spoiler", "warn", "warn_admins")] + public string Recommendation { get; set; } = "warn"; + + /// + /// Expiry time in milliseconds since the unix epoch, or null if the ban has no expiry. + /// + [JsonPropertyName("support.feline.policy.expiry.rev.2")] //stable prefix: expiry, msc pending + public long? Expiry { get; set; } + + //utils + /// + /// Readable expiry time, provided for easy interaction + /// + [JsonPropertyName("gay.rory.matrix_room_utils.readable_expiry_time_utc")] + public DateTime? ExpiryDateTime { + get => Expiry == null ? null : DateTimeOffset.FromUnixTimeMilliseconds(Expiry.Value).DateTime; + set => Expiry = value is null ? null : ((DateTimeOffset)value).ToUnixTimeMilliseconds(); + } + +#region Internal metadata + + [JsonIgnore] + public PolicyList PolicyList { get; set; } + + public StateEventResponse OriginalEvent { get; set; } + +#endregion +} -- cgit 1.4.1