This commit is contained in:
sam 2024-09-03 00:07:12 +02:00
commit b3bf3a7c16
Signed by: sam
GPG key ID: B4EF20DDE721CAA1
43 changed files with 2057 additions and 0 deletions

View file

@ -0,0 +1,9 @@
using Foxcord.Models;
namespace Foxcord.Gateway.Events.Dispatch;
public class GuildCreateEvent : Guild, IDispatch
{
public bool Unavailable { get; init; } = false;
public int MemberCount { get; init; }
}

View file

@ -0,0 +1,13 @@
namespace Foxcord.Gateway.Events.Dispatch;
public interface IDispatch
{
}
public static class DispatchEventTypeName
{
public const string Ready = "READY";
public const string GuildCreate = "GUILD_CREATE";
public const string MessageCreate = "MESSAGE_CREATE";
}

View file

@ -0,0 +1,8 @@
using Foxcord.Models;
namespace Foxcord.Gateway.Events.Dispatch;
public class MessageCreateEvent : Message, IDispatch
{
}

View file

@ -0,0 +1,18 @@
using System.Text.Json.Serialization;
using Foxcord.Models;
namespace Foxcord.Gateway.Events.Dispatch;
public class ReadyEvent : IDispatch
{
[JsonPropertyName("v")] public int Version { get; init; }
public required User User { get; init; }
public string? SessionId { get; init; }
public string? ResumeGatewayUrl { get; init; }
[JsonPropertyName("shard")] public int[]? RawShard { private get; init; }
[JsonIgnore] public ShardInfo Shard => new(RawShard?[0] ?? 0, RawShard?[1] ?? 1);
[JsonIgnore] public bool CanResume => !string.IsNullOrEmpty(SessionId) && !string.IsNullOrEmpty(ResumeGatewayUrl);
}
public record ShardInfo(int ShardId, int NumShards);

View file

@ -0,0 +1,8 @@
using Foxcord.Gateway.Events.Dispatch;
namespace Foxcord.Gateway.Events;
internal class DispatchEvent : IGatewayEvent
{
public required IDispatch Payload { get; init; }
}

View file

@ -0,0 +1,5 @@
namespace Foxcord.Gateway.Events;
internal class HeartbeatEvent : IGatewayEvent;
internal class HeartbeatAckEvent : IGatewayEvent;

View file

@ -0,0 +1,6 @@
namespace Foxcord.Gateway.Events;
internal class HelloEvent : IGatewayEvent
{
public int HeartbeatInterval { get; init; }
}

View file

@ -0,0 +1,6 @@
namespace Foxcord.Gateway.Events;
internal interface IGatewayEvent
{
}

View file

@ -0,0 +1,15 @@
namespace Foxcord.Gateway.Events;
public class IdentifyEvent : IGatewayEvent
{
public required string Token { get; init; }
public IdentifyProperties Properties { get; init; } = new();
public GatewayIntent Intents { get; init; }
}
public class IdentifyProperties
{
public string Os { get; init; } = "Linux";
public string Browser { get; init; } = "Foxcord";
public string Device { get; init; } = "Foxcord";
}