mirror of
https://github.com/barelyprofessional/KfChatDotNet.git
synced 2026-04-30 03:22:04 -04:00
Big update. Replaced Newtonsoft with System.Text.Json where possible, removed Spectre, tried to suppress the pile of compiler warnings I get on the GUI project, and tried to correct an issue where sometimes the session token retrieved is not usable.
This commit is contained in:
37
KickWsClient/Converters/StringOrObjectConverter.cs
Normal file
37
KickWsClient/Converters/StringOrObjectConverter.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace KickWsClient.Converters;
|
||||
|
||||
// Literal mess, but it is AI generated so what do you expect. Couldn't be bothered writing this myself.
|
||||
public class StringOrObjectConverter<T> : JsonConverter<T>
|
||||
{
|
||||
public override bool CanConvert(Type typeToConvert)
|
||||
{
|
||||
return typeof(T).IsAssignableFrom(typeToConvert) || (typeof(T) == typeof(string) && typeToConvert == typeof(object));
|
||||
}
|
||||
|
||||
public override T Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
{
|
||||
if (reader.TokenType == JsonTokenType.String)
|
||||
{
|
||||
return (T)(object)reader.GetString()!;
|
||||
}
|
||||
else
|
||||
{
|
||||
return JsonSerializer.Deserialize<T>(ref reader, options)!;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Write(Utf8JsonWriter writer, T value, JsonSerializerOptions options)
|
||||
{
|
||||
if (value is string)
|
||||
{
|
||||
writer.WriteStringValue((string)(object)value);
|
||||
}
|
||||
else
|
||||
{
|
||||
JsonSerializer.Serialize(writer, value, options);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,8 @@
|
||||
using System.Net;
|
||||
using System.Net.WebSockets;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using KickWsClient.Models;
|
||||
using Newtonsoft.Json;
|
||||
using Websocket.Client;
|
||||
using NLog;
|
||||
|
||||
@@ -114,7 +115,7 @@ public class KickWsClient
|
||||
public void SendPusherPacket(string eventName, object data)
|
||||
{
|
||||
var pkt = new PusherModels.BasePusherRequestModel { Event = eventName, Data = data};
|
||||
var json = JsonConvert.SerializeObject(pkt);
|
||||
var json = JsonSerializer.Serialize(pkt);
|
||||
_logger.Debug("Sending message to Pusher");
|
||||
_logger.Debug(json);
|
||||
_wsClient.Send(json);
|
||||
@@ -152,6 +153,10 @@ public class KickWsClient
|
||||
private void WsMessageReceived(ResponseMessage message)
|
||||
{
|
||||
OnWsMessageReceived?.Invoke(this, message);
|
||||
var options = new JsonSerializerOptions
|
||||
{
|
||||
NumberHandling = JsonNumberHandling.AllowReadingFromString
|
||||
};
|
||||
|
||||
if (message.Text == null)
|
||||
{
|
||||
@@ -162,7 +167,7 @@ public class KickWsClient
|
||||
PusherModels.BasePusherEventModel pusherMsg;
|
||||
try
|
||||
{
|
||||
pusherMsg = JsonConvert.DeserializeObject<PusherModels.BasePusherEventModel>(message.Text) ??
|
||||
pusherMsg = JsonSerializer.Deserialize<PusherModels.BasePusherEventModel>(message.Text, options) ??
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -182,7 +187,7 @@ public class KickWsClient
|
||||
case "pusher:connection_established":
|
||||
{
|
||||
var data =
|
||||
JsonConvert.DeserializeObject<PusherModels.PusherConnectionEstablishedEventModel>(pusherMsg.Data);
|
||||
JsonSerializer.Deserialize<PusherModels.PusherConnectionEstablishedEventModel>(pusherMsg.Data, options);
|
||||
OnPusherConnectionEstablished?.Invoke(this, data);
|
||||
return;
|
||||
}
|
||||
@@ -194,67 +199,67 @@ public class KickWsClient
|
||||
return;
|
||||
case @"App\Events\FollowersUpdated":
|
||||
{
|
||||
var data = JsonConvert.DeserializeObject<KickModels.FollowersUpdatedEventModel>(pusherMsg.Data);
|
||||
var data = JsonSerializer.Deserialize<KickModels.FollowersUpdatedEventModel>(pusherMsg.Data, options);
|
||||
OnFollowersUpdated?.Invoke(this, data);
|
||||
return;
|
||||
}
|
||||
case @"App\Events\ChatMessageEvent":
|
||||
{
|
||||
var data = JsonConvert.DeserializeObject<KickModels.ChatMessageEventModel>(pusherMsg.Data);
|
||||
var data = JsonSerializer.Deserialize<KickModels.ChatMessageEventModel>(pusherMsg.Data, options);
|
||||
OnChatMessage?.Invoke(this, data);
|
||||
return;
|
||||
}
|
||||
case @"App\Events\ChannelSubscriptionEvent":
|
||||
{
|
||||
var data = JsonConvert.DeserializeObject<KickModels.ChannelSubscriptionEventModel>(pusherMsg.Data);
|
||||
var data = JsonSerializer.Deserialize<KickModels.ChannelSubscriptionEventModel>(pusherMsg.Data, options);
|
||||
OnChannelSubscription?.Invoke(this, data);
|
||||
return;
|
||||
}
|
||||
case @"App\Events\SubscriptionEvent":
|
||||
{
|
||||
var data = JsonConvert.DeserializeObject<KickModels.SubscriptionEventModel>(pusherMsg.Data);
|
||||
var data = JsonSerializer.Deserialize<KickModels.SubscriptionEventModel>(pusherMsg.Data, options);
|
||||
OnSubscription?.Invoke(this, data);
|
||||
return;
|
||||
}
|
||||
case @"App\Events\MessageDeletedEvent":
|
||||
{
|
||||
var data = JsonConvert.DeserializeObject<KickModels.MessageDeletedEventModel>(pusherMsg.Data);
|
||||
var data = JsonSerializer.Deserialize<KickModels.MessageDeletedEventModel>(pusherMsg.Data, options);
|
||||
OnMessageDeleted?.Invoke(this, data);
|
||||
return;
|
||||
}
|
||||
case @"App\Events\UserBannedEvent":
|
||||
{
|
||||
var data = JsonConvert.DeserializeObject<KickModels.UserBannedEventModel>(pusherMsg.Data);
|
||||
var data = JsonSerializer.Deserialize<KickModels.UserBannedEventModel>(pusherMsg.Data, options);
|
||||
OnUserBanned?.Invoke(this, data);
|
||||
return;
|
||||
}
|
||||
case @"App\Events\UserUnbannedEvent":
|
||||
{
|
||||
var data = JsonConvert.DeserializeObject<KickModels.UserUnbannedEventModel>(pusherMsg.Data);
|
||||
var data = JsonSerializer.Deserialize<KickModels.UserUnbannedEventModel>(pusherMsg.Data, options);
|
||||
OnUserUnbanned?.Invoke(this, data);
|
||||
return;
|
||||
}
|
||||
case @"App\Events\LiveStream\UpdatedLiveStreamEvent":
|
||||
{
|
||||
var data = JsonConvert.DeserializeObject<KickModels.UpdatedLiveStreamEventModel>(pusherMsg.Data);
|
||||
var data = JsonSerializer.Deserialize<KickModels.UpdatedLiveStreamEventModel>(pusherMsg.Data, options);
|
||||
OnUpdatedLiveStream?.Invoke(this, data);
|
||||
return;
|
||||
}
|
||||
case @"App\Events\StopStreamBroadcast":
|
||||
{
|
||||
var data = JsonConvert.DeserializeObject<KickModels.StopStreamBroadcastEventModel>(pusherMsg.Data);
|
||||
var data = JsonSerializer.Deserialize<KickModels.StopStreamBroadcastEventModel>(pusherMsg.Data, options);
|
||||
OnStopStreamBroadcast?.Invoke(this, data);
|
||||
return;
|
||||
}
|
||||
case @"App\Events\StreamerIsLive":
|
||||
{
|
||||
var data = JsonConvert.DeserializeObject<KickModels.StreamerIsLiveEventModel>(pusherMsg.Data);
|
||||
var data = JsonSerializer.Deserialize<KickModels.StreamerIsLiveEventModel>(pusherMsg.Data, options);
|
||||
OnStreamerIsLive?.Invoke(this, data);
|
||||
return;
|
||||
}
|
||||
case @"App\Events\PollUpdateEvent":
|
||||
{
|
||||
var data = JsonConvert.DeserializeObject<KickModels.PollUpdateEventModel>(pusherMsg.Data);
|
||||
var data = JsonSerializer.Deserialize<KickModels.PollUpdateEventModel>(pusherMsg.Data, options);
|
||||
OnPollUpdate?.Invoke(this, data);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="NLog" Version="5.2.8" />
|
||||
<PackageReference Include="System.Text.Json" Version="8.0.3" />
|
||||
<PackageReference Include="Websocket.Client" Version="5.1.1" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Newtonsoft.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace KickWsClient.Models;
|
||||
|
||||
@@ -9,17 +9,17 @@ public class KickModels
|
||||
/// <summary>
|
||||
/// Internal type for badge e.g. moderator
|
||||
/// </summary>
|
||||
[JsonProperty("type")]
|
||||
[JsonPropertyName("type")]
|
||||
public required string Type { get; set; }
|
||||
/// <summary>
|
||||
/// Friendly name for badge e.g. Moderator
|
||||
/// </summary>
|
||||
[JsonProperty("text")]
|
||||
[JsonPropertyName("text")]
|
||||
public required string Text { get; set; }
|
||||
/// <summary>
|
||||
/// Count (if applicable) for badge (e.g. sub count for gifted subs)
|
||||
/// </summary>
|
||||
[JsonProperty("count")]
|
||||
[JsonPropertyName("count")]
|
||||
public int? Count { get; set; }
|
||||
}
|
||||
|
||||
@@ -28,13 +28,13 @@ public class KickModels
|
||||
/// <summary>
|
||||
/// User's hex color
|
||||
/// </summary>
|
||||
[JsonProperty("color")]
|
||||
[JsonPropertyName("color")]
|
||||
public required string Color { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Badges a user has
|
||||
/// </summary>
|
||||
[JsonProperty("badges")]
|
||||
[JsonPropertyName("badges")]
|
||||
public List<ChatMessageSenderIdentityBadgeModel> Badges = [];
|
||||
}
|
||||
|
||||
@@ -43,22 +43,22 @@ public class KickModels
|
||||
/// <summary>
|
||||
/// Kick internal user ID
|
||||
/// </summary>
|
||||
[JsonProperty("id")]
|
||||
[JsonPropertyName("id")]
|
||||
public int Id { get; set; }
|
||||
/// <summary>
|
||||
/// Kick display name
|
||||
/// </summary>
|
||||
[JsonProperty("username")]
|
||||
[JsonPropertyName("username")]
|
||||
public required string Username { get; set; }
|
||||
/// <summary>
|
||||
/// Kick slug (for URLs)
|
||||
/// </summary>
|
||||
[JsonProperty("slug")]
|
||||
[JsonPropertyName("slug")]
|
||||
public required string Slug { get; set; }
|
||||
/// <summary>
|
||||
/// Identity info for display color and badges
|
||||
/// </summary>
|
||||
[JsonProperty("identity")]
|
||||
[JsonPropertyName("identity")]
|
||||
public required ChatMessageSenderIdentityModel Identity { get; set; }
|
||||
}
|
||||
|
||||
@@ -67,12 +67,12 @@ public class KickModels
|
||||
/// <summary>
|
||||
/// Original sender's user ID
|
||||
/// </summary>
|
||||
[JsonProperty("id")]
|
||||
[JsonPropertyName("id")]
|
||||
public int Id { get; set; }
|
||||
/// <summary>
|
||||
/// Original sender's username
|
||||
/// </summary>
|
||||
[JsonProperty("username")]
|
||||
[JsonPropertyName("username")]
|
||||
public required string Username { get; set; }
|
||||
}
|
||||
|
||||
@@ -81,12 +81,12 @@ public class KickModels
|
||||
/// <summary>
|
||||
/// ID (GUID) of the original message
|
||||
/// </summary>
|
||||
[JsonProperty("id")]
|
||||
[JsonPropertyName("id")]
|
||||
public required string Id { get; set; }
|
||||
/// <summary>
|
||||
/// Content of the original message
|
||||
/// </summary>
|
||||
[JsonProperty("content")]
|
||||
[JsonPropertyName("content")]
|
||||
public required string Content { get; set; }
|
||||
}
|
||||
|
||||
@@ -95,12 +95,12 @@ public class KickModels
|
||||
/// <summary>
|
||||
/// Sender of the message that this message is in reply to
|
||||
/// </summary>
|
||||
[JsonProperty("original_sender")]
|
||||
[JsonPropertyName("original_sender")]
|
||||
public required ChatMessageMetadataOriginalSenderModel OriginalSender { get; set; }
|
||||
/// <summary>
|
||||
/// Content of the message that this message is in reply to
|
||||
/// </summary>
|
||||
[JsonProperty("original_message")]
|
||||
[JsonPropertyName("original_message")]
|
||||
public required ChatMessageMetadataOriginalMessageModel OriginalMessage { get; set; }
|
||||
}
|
||||
|
||||
@@ -109,29 +109,29 @@ public class KickModels
|
||||
/// <summary>
|
||||
/// Channel follower count
|
||||
/// </summary>
|
||||
[JsonProperty("followersCount")]
|
||||
[JsonPropertyName("followersCount")]
|
||||
public int FollowersCount { get; set; }
|
||||
/// <summary>
|
||||
/// ID to identify what chatroom this event belongs to
|
||||
/// </summary>
|
||||
[JsonProperty("chatroom_id")]
|
||||
[JsonPropertyName("chatroom_id")]
|
||||
public int ChatroomId { get; set; }
|
||||
/// <summary>
|
||||
/// Maybe returns your username if you're auth'd? No idea. Just returned null for me
|
||||
/// </summary>
|
||||
[JsonProperty("username")]
|
||||
[JsonPropertyName("username")]
|
||||
public string? Username { get; set; }
|
||||
/// <summary>
|
||||
/// Epoch value that signifies ???
|
||||
/// </summary>
|
||||
[JsonProperty("created_at")]
|
||||
[JsonPropertyName("created_at")]
|
||||
public int? CreatedAtEpoch { get; set; }
|
||||
// It returned true even though I'm not signed in which makes no sense, so I'll assume there's a chance it'll
|
||||
// suddenly appear and mark as nullable as it's not really a useful property anyway.
|
||||
/// <summary>
|
||||
/// Does it mean we're following? Who knows, returns true even if you're a guest
|
||||
/// </summary>
|
||||
[JsonProperty("followed")]
|
||||
[JsonPropertyName("followed")]
|
||||
public bool? Followed { get; set; }
|
||||
}
|
||||
|
||||
@@ -140,38 +140,38 @@ public class KickModels
|
||||
/// <summary>
|
||||
/// Message unique GUID that's referenced for replies and deletions
|
||||
/// </summary>
|
||||
[JsonProperty("id")]
|
||||
[JsonPropertyName("id")]
|
||||
public required string Id { get; set; }
|
||||
/// <summary>
|
||||
/// Chatroom ID you can use to differentiate this from other rooms if you sub to multiple at a time
|
||||
/// </summary>
|
||||
[JsonProperty("chatroom_id")]
|
||||
[JsonPropertyName("chatroom_id")]
|
||||
public int ChatroomId { get; set; }
|
||||
/// <summary>
|
||||
/// Content of the message. Emotes are encoded like [emote:161238:russW] which translates to -> https://files.kick.com/emotes/161238/fullsize
|
||||
/// </summary>
|
||||
[JsonProperty("content")]
|
||||
[JsonPropertyName("content")]
|
||||
public required string Content { get; set; }
|
||||
/// <summary>
|
||||
/// Regular message is 'message', replies are 'reply'
|
||||
/// </summary>
|
||||
[JsonProperty("type")]
|
||||
[JsonPropertyName("type")]
|
||||
public required string Type { get; set; }
|
||||
// Why created at is an epoch for followers updated but ISO8601 for chat messages is just a mystery
|
||||
/// <summary>
|
||||
/// Time message was sent
|
||||
/// </summary>
|
||||
[JsonProperty("created_at")]
|
||||
[JsonPropertyName("created_at")]
|
||||
public DateTimeOffset CreatedAt { get; set; }
|
||||
/// <summary>
|
||||
/// Sender of the message
|
||||
/// </summary>
|
||||
[JsonProperty("sender")]
|
||||
[JsonPropertyName("sender")]
|
||||
public required ChatMessageSenderModel Sender { get; set; }
|
||||
/// <summary>
|
||||
/// Message metadata which is set for replies only
|
||||
/// </summary>
|
||||
[JsonProperty("metadata")]
|
||||
[JsonPropertyName("metadata")]
|
||||
public ChatMessageMetadataModel? Metadata { get; set; }
|
||||
}
|
||||
|
||||
@@ -180,17 +180,17 @@ public class KickModels
|
||||
/// <summary>
|
||||
/// User IDs of subscription recipients
|
||||
/// </summary>
|
||||
[JsonProperty("user_ids")]
|
||||
[JsonPropertyName("user_ids")]
|
||||
public List<int> UserIds { get; set; } = [];
|
||||
/// <summary>
|
||||
/// Username of the person who subbed / gifted
|
||||
/// </summary>
|
||||
[JsonProperty("username")]
|
||||
[JsonPropertyName("username")]
|
||||
public required string Username { get; set; }
|
||||
/// <summary>
|
||||
/// Channel ID where the sub event occurred
|
||||
/// </summary>
|
||||
[JsonProperty("channel_id")]
|
||||
[JsonPropertyName("channel_id")]
|
||||
public int ChannelId { get; set; }
|
||||
}
|
||||
|
||||
@@ -199,17 +199,17 @@ public class KickModels
|
||||
/// <summary>
|
||||
/// ID of channel where the subscription event occurred
|
||||
/// </summary>
|
||||
[JsonProperty("chatroom_id")]
|
||||
[JsonPropertyName("chatroom_id")]
|
||||
public int ChatroomId { get; set; }
|
||||
/// <summary>
|
||||
/// Username of the person who bought a sub
|
||||
/// </summary>
|
||||
[JsonProperty("username")]
|
||||
[JsonPropertyName("username")]
|
||||
public required string Username { get; set; }
|
||||
/// <summary>
|
||||
/// Number of months they've subbed now (e.g. 2 if they bought their 2nd month)
|
||||
/// </summary>
|
||||
[JsonProperty("months")]
|
||||
[JsonPropertyName("months")]
|
||||
public int Months { get; set; }
|
||||
}
|
||||
|
||||
@@ -218,7 +218,7 @@ public class KickModels
|
||||
/// <summary>
|
||||
/// ID of the message that was deleted
|
||||
/// </summary>
|
||||
[JsonProperty("id")]
|
||||
[JsonPropertyName("id")]
|
||||
public required string Id { get; set; }
|
||||
}
|
||||
|
||||
@@ -227,12 +227,12 @@ public class KickModels
|
||||
/// <summary>
|
||||
/// ID of this event (NOT the message to be removed!)
|
||||
/// </summary>
|
||||
[JsonProperty("id")]
|
||||
[JsonPropertyName("id")]
|
||||
public required string Id { get; set; }
|
||||
/// <summary>
|
||||
/// Message that was deleted
|
||||
/// </summary>
|
||||
[JsonProperty("message")]
|
||||
[JsonPropertyName("message")]
|
||||
public required MessageDeletedMessageModel Message { get; set; }
|
||||
}
|
||||
|
||||
@@ -241,17 +241,17 @@ public class KickModels
|
||||
/// <summary>
|
||||
/// ID of the user. Note it'll be 0 for the janny
|
||||
/// </summary>
|
||||
[JsonProperty("id")]
|
||||
[JsonPropertyName("id")]
|
||||
public int Id { get; set; }
|
||||
/// <summary>
|
||||
/// User's username
|
||||
/// </summary>
|
||||
[JsonProperty("username")]
|
||||
[JsonPropertyName("username")]
|
||||
public required string Username { get; set; }
|
||||
/// <summary>
|
||||
/// Slug suitable for URLs
|
||||
/// </summary>
|
||||
[JsonProperty("slug")]
|
||||
[JsonPropertyName("slug")]
|
||||
public required string Slug { get; set; }
|
||||
}
|
||||
|
||||
@@ -260,22 +260,22 @@ public class KickModels
|
||||
/// <summary>
|
||||
/// GUID of the event
|
||||
/// </summary>
|
||||
[JsonProperty("id")]
|
||||
[JsonPropertyName("id")]
|
||||
public required string Id { get; set; }
|
||||
/// <summary>
|
||||
/// User who was banished
|
||||
/// </summary>
|
||||
[JsonProperty("user")]
|
||||
[JsonPropertyName("user")]
|
||||
public required UserBannedUserModel User { get; set; }
|
||||
/// <summary>
|
||||
/// Janny who did the sweeping
|
||||
/// </summary>
|
||||
[JsonProperty("banned_by")]
|
||||
[JsonPropertyName("banned_by")]
|
||||
public required UserBannedUserModel BannedBy { get; set; }
|
||||
/// <summary>
|
||||
/// Datetime that the ban expires. Null for permabans
|
||||
/// </summary>
|
||||
[JsonProperty("expires_at")]
|
||||
[JsonPropertyName("expires_at")]
|
||||
public DateTimeOffset? ExpiresAt { get; set; }
|
||||
}
|
||||
|
||||
@@ -284,17 +284,17 @@ public class KickModels
|
||||
/// <summary>
|
||||
/// GUID of the event
|
||||
/// </summary>
|
||||
[JsonProperty("id")]
|
||||
[JsonPropertyName("id")]
|
||||
public required string Id { get; set; }
|
||||
/// <summary>
|
||||
/// User who was unbanned
|
||||
/// </summary>
|
||||
[JsonProperty("user")]
|
||||
[JsonPropertyName("user")]
|
||||
public required UserBannedUserModel User { get; set; }
|
||||
/// <summary>
|
||||
/// Janny who unbanned
|
||||
/// </summary>
|
||||
[JsonProperty("unbanned_by")]
|
||||
[JsonPropertyName("unbanned_by")]
|
||||
public required UserBannedUserModel UnbannedBy { get; set; }
|
||||
}
|
||||
|
||||
@@ -303,12 +303,12 @@ public class KickModels
|
||||
/// <summary>
|
||||
/// ID representing the category
|
||||
/// </summary>
|
||||
[JsonProperty("id")]
|
||||
[JsonPropertyName("id")]
|
||||
public int Id { get; set; }
|
||||
/// <summary>
|
||||
/// Slug representing the category
|
||||
/// </summary>
|
||||
[JsonProperty("slug")]
|
||||
[JsonPropertyName("slug")]
|
||||
public required string Slug { get; set; }
|
||||
}
|
||||
|
||||
@@ -317,27 +317,27 @@ public class KickModels
|
||||
/// <summary>
|
||||
/// ID of the category
|
||||
/// </summary>
|
||||
[JsonProperty("id")]
|
||||
[JsonPropertyName("id")]
|
||||
public int Id { get; set; }
|
||||
/// <summary>
|
||||
/// Friendly name of the category
|
||||
/// </summary>
|
||||
[JsonProperty("name")]
|
||||
[JsonPropertyName("name")]
|
||||
public required string Name { get; set; }
|
||||
/// <summary>
|
||||
/// Category's slug for forming URls etc.
|
||||
/// </summary>
|
||||
[JsonProperty("slug")]
|
||||
[JsonPropertyName("slug")]
|
||||
public required string Slug { get; set; }
|
||||
/// <summary>
|
||||
/// Tags for the category
|
||||
/// </summary>
|
||||
[JsonProperty("tags")]
|
||||
[JsonPropertyName("tags")]
|
||||
public List<string> Tags { get; set; } = [];
|
||||
/// <summary>
|
||||
/// Parent category, if one is present. I think there usually is one, but made it nullable just in case
|
||||
/// </summary>
|
||||
[JsonProperty("parent_category")]
|
||||
[JsonPropertyName("parent_category")]
|
||||
public UpdatedLiveStreamCategoryParentModel? ParentCategory { get; set; }
|
||||
}
|
||||
|
||||
@@ -346,42 +346,42 @@ public class KickModels
|
||||
/// <summary>
|
||||
/// ID of the livestream (numeric)
|
||||
/// </summary>
|
||||
[JsonProperty("id")]
|
||||
[JsonPropertyName("id")]
|
||||
public int Id { get; set; }
|
||||
/// <summary>
|
||||
/// Livestream slug
|
||||
/// </summary>
|
||||
[JsonProperty("slug")]
|
||||
[JsonPropertyName("slug")]
|
||||
public required string Slug { get; set; }
|
||||
/// <summary>
|
||||
/// Livestream title
|
||||
/// </summary>
|
||||
[JsonProperty("session_title")]
|
||||
[JsonPropertyName("session_title")]
|
||||
public required string SessionTitle { get; set; }
|
||||
/// <summary>
|
||||
/// Livestream start time
|
||||
/// </summary>
|
||||
[JsonProperty("created_at")]
|
||||
[JsonPropertyName("created_at")]
|
||||
public DateTimeOffset CreatedAt { get; set; }
|
||||
/// <summary>
|
||||
/// Language of the livestream (e.g. English)
|
||||
/// </summary>
|
||||
[JsonProperty("language")]
|
||||
[JsonPropertyName("language")]
|
||||
public string? Language { get; set; }
|
||||
/// <summary>
|
||||
/// Whether the stream is marked as for a mature audience
|
||||
/// </summary>
|
||||
[JsonProperty("is_mature")]
|
||||
[JsonPropertyName("is_mature")]
|
||||
public bool IsMature { get; set; }
|
||||
/// <summary>
|
||||
/// Number of viewers presently watching
|
||||
/// </summary>
|
||||
[JsonProperty("viewers")]
|
||||
[JsonPropertyName("viewers")]
|
||||
public int Viewers { get; set; }
|
||||
/// <summary>
|
||||
/// Category of the livestream. I believe this is always required but marked it as nullable just in case
|
||||
/// </summary>
|
||||
[JsonProperty("category")]
|
||||
[JsonPropertyName("category")]
|
||||
public UpdatedLiveStreamCategoryModel? Category { get; set; }
|
||||
}
|
||||
|
||||
@@ -390,12 +390,12 @@ public class KickModels
|
||||
/// <summary>
|
||||
/// ID of the channel
|
||||
/// </summary>
|
||||
[JsonProperty("id")]
|
||||
[JsonPropertyName("id")]
|
||||
public int Id { get; set; }
|
||||
/// <summary>
|
||||
/// Whether the streamer was sent to ban world
|
||||
/// </summary>
|
||||
[JsonProperty("is_banned")]
|
||||
[JsonPropertyName("is_banned")]
|
||||
public bool IsBanned { get; set; }
|
||||
}
|
||||
|
||||
@@ -404,12 +404,12 @@ public class KickModels
|
||||
/// <summary>
|
||||
/// Livestream event ID
|
||||
/// </summary>
|
||||
[JsonProperty("id")]
|
||||
[JsonPropertyName("id")]
|
||||
public int Id { get; set; }
|
||||
/// <summary>
|
||||
/// Channel that stopped streaming
|
||||
/// </summary>
|
||||
[JsonProperty("channel")]
|
||||
[JsonPropertyName("channel")]
|
||||
public required StopStreamBroadcastLiveStreamChannelModel Channel { get; set; }
|
||||
}
|
||||
|
||||
@@ -418,7 +418,7 @@ public class KickModels
|
||||
/// <summary>
|
||||
/// Object containing information related to the livestream that stopped
|
||||
/// </summary>
|
||||
[JsonProperty("livestream")]
|
||||
[JsonPropertyName("livestream")]
|
||||
public required StopStreamBroadcastLiveStreamModel Livestream { get; set; }
|
||||
}
|
||||
|
||||
@@ -427,27 +427,27 @@ public class KickModels
|
||||
/// <summary>
|
||||
/// ID of the livestream
|
||||
/// </summary>
|
||||
[JsonProperty("id")]
|
||||
[JsonPropertyName("id")]
|
||||
public int Id { get; set; }
|
||||
/// <summary>
|
||||
/// ID of the channel
|
||||
/// </summary>
|
||||
[JsonProperty("channel_id")]
|
||||
[JsonPropertyName("channel_id")]
|
||||
public int ChannelId { get; set; }
|
||||
/// <summary>
|
||||
/// Title of the stream
|
||||
/// </summary>
|
||||
[JsonProperty("session_title")]
|
||||
[JsonPropertyName("session_title")]
|
||||
public required string SessionTitle { get; set; }
|
||||
/// <summary>
|
||||
/// No idea, just null on my end
|
||||
/// </summary>
|
||||
[JsonProperty("source")]
|
||||
[JsonPropertyName("source")]
|
||||
public string? Source { get; set; }
|
||||
/// <summary>
|
||||
/// Time stream started
|
||||
/// </summary>
|
||||
[JsonProperty("created_at")]
|
||||
[JsonPropertyName("created_at")]
|
||||
public DateTimeOffset CreatedAt { get; set; }
|
||||
}
|
||||
|
||||
@@ -456,7 +456,7 @@ public class KickModels
|
||||
/// <summary>
|
||||
/// Object containing information related to the livestream that has just started
|
||||
/// </summary>
|
||||
[JsonProperty("livestream")]
|
||||
[JsonPropertyName("livestream")]
|
||||
public required StreamerIsLiveLiveStreamModel Livestream { get; set; }
|
||||
}
|
||||
|
||||
@@ -465,17 +465,17 @@ public class KickModels
|
||||
/// <summary>
|
||||
/// ID of the poll option
|
||||
/// </summary>
|
||||
[JsonProperty("id")]
|
||||
[JsonPropertyName("id")]
|
||||
public int Id { get; set; }
|
||||
/// <summary>
|
||||
/// Label of the poll option
|
||||
/// </summary>
|
||||
[JsonProperty("label")]
|
||||
[JsonPropertyName("label")]
|
||||
public required string Label { get; set; }
|
||||
/// <summary>
|
||||
/// Number of votes the poll option has gotten
|
||||
/// </summary>
|
||||
[JsonProperty("votes")]
|
||||
[JsonPropertyName("votes")]
|
||||
public int Votes { get; set; }
|
||||
}
|
||||
|
||||
@@ -484,27 +484,27 @@ public class KickModels
|
||||
/// <summary>
|
||||
/// Title of the poll
|
||||
/// </summary>
|
||||
[JsonProperty("title")]
|
||||
[JsonPropertyName("title")]
|
||||
public required string Title { get; set; }
|
||||
/// <summary>
|
||||
/// Poll options
|
||||
/// </summary>
|
||||
[JsonProperty("options")]
|
||||
[JsonPropertyName("options")]
|
||||
public List<PollUpdatePollOptionModel> Options { get; set; } = [];
|
||||
/// <summary>
|
||||
/// Duration of the poll in seconds
|
||||
/// </summary>
|
||||
[JsonProperty("duration")]
|
||||
[JsonPropertyName("duration")]
|
||||
public int Duration { get; set; }
|
||||
/// <summary>
|
||||
/// Remaining time in seconds
|
||||
/// </summary>
|
||||
[JsonProperty("remaining")]
|
||||
[JsonPropertyName("remaining")]
|
||||
public int Remaining { get; set; }
|
||||
/// <summary>
|
||||
/// Time in seconds to display the results after completion?
|
||||
/// </summary>
|
||||
[JsonProperty("result_display_duration")]
|
||||
[JsonPropertyName("result_display_duration")]
|
||||
public int ResultDisplayDuration { get; set; }
|
||||
}
|
||||
|
||||
@@ -513,7 +513,7 @@ public class KickModels
|
||||
/// <summary>
|
||||
/// Poll data
|
||||
/// </summary>
|
||||
[JsonProperty("poll")]
|
||||
[JsonPropertyName("poll")]
|
||||
public required PollUpdatePollModel Poll { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using Newtonsoft.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using KickWsClient.Converters;
|
||||
|
||||
namespace KickWsClient.Models;
|
||||
|
||||
@@ -9,17 +10,18 @@ public class PusherModels
|
||||
/// <summary>
|
||||
/// Name of the event
|
||||
/// </summary>
|
||||
[JsonProperty("event")]
|
||||
[JsonPropertyName("event")]
|
||||
public required string Event { get; set; }
|
||||
/// <summary>
|
||||
/// Stringified JSON payload
|
||||
/// </summary>
|
||||
[JsonProperty("data")]
|
||||
[JsonPropertyName("data")]
|
||||
[JsonConverter(typeof(StringOrObjectConverter<string>))]
|
||||
public required string Data { get; set; }
|
||||
/// <summary>
|
||||
/// Channel where event originates. Only included events where a channel is applicable
|
||||
/// </summary>
|
||||
[JsonProperty("channel")]
|
||||
[JsonPropertyName("channel")]
|
||||
public string? Channel { get; set; }
|
||||
}
|
||||
|
||||
@@ -28,12 +30,12 @@ public class PusherModels
|
||||
/// <summary>
|
||||
/// Name of the event
|
||||
/// </summary>
|
||||
[JsonProperty("event")]
|
||||
[JsonPropertyName("event")]
|
||||
public required string Event { get; set; }
|
||||
/// <summary>
|
||||
/// Data as object. It's only stringified for responses
|
||||
/// </summary>
|
||||
[JsonProperty("data")]
|
||||
[JsonPropertyName("data")]
|
||||
public required object Data { get; set; }
|
||||
}
|
||||
|
||||
@@ -42,12 +44,12 @@ public class PusherModels
|
||||
/// <summary>
|
||||
/// Internal socket ID
|
||||
/// </summary>
|
||||
[JsonProperty("socket_id")]
|
||||
[JsonPropertyName("socket_id")]
|
||||
public required string SocketId { get; set; }
|
||||
/// <summary>
|
||||
/// Timeout on no activity in seconds
|
||||
/// </summary>
|
||||
[JsonProperty("activity_timeout")]
|
||||
[JsonPropertyName("activity_timeout")]
|
||||
public int ActivityTimeout { get; set; }
|
||||
}
|
||||
|
||||
@@ -56,12 +58,12 @@ public class PusherModels
|
||||
/// <summary>
|
||||
/// Token to authenticate with, use an empty string for guest.
|
||||
/// </summary>
|
||||
[JsonProperty("auth")]
|
||||
[JsonPropertyName("auth")]
|
||||
public string Auth { get; set; } = "";
|
||||
/// <summary>
|
||||
/// Channel you wish to subscribe to. 'channel.2515504' for stream events. 'chatrooms.2515504.v2' for chat where 2515504 is the channel ID
|
||||
/// </summary>
|
||||
[JsonProperty("channel")]
|
||||
[JsonPropertyName("channel")]
|
||||
public required string Channel { get; set; }
|
||||
}
|
||||
|
||||
@@ -70,7 +72,7 @@ public class PusherModels
|
||||
/// <summary>
|
||||
/// Channel you wish to unsubscribe from, e.g. 'channel.2515504'
|
||||
/// </summary>
|
||||
[JsonProperty("channel")]
|
||||
[JsonPropertyName("channel")]
|
||||
public required string Channel { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user