Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 HypeTrainProgress LastContribution should be a single object #18

Merged
merged 18 commits into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions TwitchLib.EventSub.Core/AsyncEventHandler.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System;
using System.Threading.Tasks;

namespace TwitchLib.EventSub.Core
{
/// <summary>
/// Custom implementation of asynchronous event handler
/// This is useful to properly and safely handle async Tasks
/// Reference: https://medium.com/@a.lyskawa/the-hitchhiker-guide-to-asynchronous-events-in-c-e9840109fb53
/// </summary>
public delegate Task AsyncEventHandler<in TEventArgs>(object sender, TEventArgs args);

Check warning on line 11 in TwitchLib.EventSub.Core/AsyncEventHandler.cs

View workflow job for this annotation

GitHub Actions / check-buildstatus

Rename type name AsyncEventHandler so that it does not end in 'EventHandler' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1711)
/// <summary>
/// Custom implementation of asynchronous event handler
/// This is useful to properly and safely handle async Tasks
/// Reference: https://medium.com/@a.lyskawa/the-hitchhiker-guide-to-asynchronous-events-in-c-e9840109fb53
/// </summary>
public delegate Task AsyncEventHandler(object sender, EventArgs args);

Check warning on line 17 in TwitchLib.EventSub.Core/AsyncEventHandler.cs

View workflow job for this annotation

GitHub Actions / check-buildstatus

Rename type name AsyncEventHandler so that it does not end in 'EventHandler' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1711)
}
18 changes: 18 additions & 0 deletions TwitchLib.EventSub.Core/Extensions/AsyncEventHandlerExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System;
using System.Threading.Tasks;

namespace TwitchLib.EventSub.Core.Extensions
{
public static class AsyncEventHandlerExtensions

Check warning on line 6 in TwitchLib.EventSub.Core/Extensions/AsyncEventHandlerExtensions.cs

View workflow job for this annotation

GitHub Actions / check-buildstatus

Missing XML comment for publicly visible type or member 'AsyncEventHandlerExtensions'
{
public static Task InvokeAsync<TEventArgs>(this AsyncEventHandler<TEventArgs> asyncEventHandler, object sender, TEventArgs args)

Check warning on line 8 in TwitchLib.EventSub.Core/Extensions/AsyncEventHandlerExtensions.cs

View workflow job for this annotation

GitHub Actions / check-buildstatus

Missing XML comment for publicly visible type or member 'AsyncEventHandlerExtensions.InvokeAsync<TEventArgs>(AsyncEventHandler<TEventArgs>, object, TEventArgs)'
{
return asyncEventHandler != null ? asyncEventHandler(sender, args) : Task.CompletedTask;
}

public static Task InvokeAsync(this AsyncEventHandler asyncEventHandler, object sender, EventArgs args)

Check warning on line 13 in TwitchLib.EventSub.Core/Extensions/AsyncEventHandlerExtensions.cs

View workflow job for this annotation

GitHub Actions / check-buildstatus

Missing XML comment for publicly visible type or member 'AsyncEventHandlerExtensions.InvokeAsync(AsyncEventHandler, object, EventArgs)'
{
return asyncEventHandler != null ? asyncEventHandler(sender, args) : Task.CompletedTask;
}
}
}
51 changes: 51 additions & 0 deletions TwitchLib.EventSub.Core/Models/GuestStar/ChannelGuestStarBase.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
namespace TwitchLib.EventSub.Core.Models.GuestStar
{
public abstract class ChannelGuestStarBase

Check warning on line 3 in TwitchLib.EventSub.Core/Models/GuestStar/ChannelGuestStarBase.cs

View workflow job for this annotation

GitHub Actions / check-buildstatus

Missing XML comment for publicly visible type or member 'ChannelGuestStarBase'
{
/// <summary>
/// The broadcaster user ID
/// </summary>
public string BroadcasterUserId { get; set; } = string.Empty;
/// <summary>
/// The broadcaster display name
/// </summary>
public string BroadcasterUserName { get; set; } = string.Empty;
/// <summary>
/// The broadcaster login
/// </summary>
public string BroadcasterUserLogin { get; set; } = string.Empty;
/// <summary>
/// Unique ID representing the session.
/// </summary>
public string SessionId { get; set; } = string.Empty;
/// <summary>
/// The moderator user ID
/// </summary>
public string ModeratorUserId { get; set; } = string.Empty;
/// <summary>
/// The moderator display name
/// </summary>
public string ModeratorUserName { get; set; } = string.Empty;
/// <summary>
/// The moderator login
/// </summary>
public string ModeratorUserLogin { get; set; } = string.Empty;
/// <summary>
/// The user ID of the guest
/// </summary>
public string GuestStarUserId { get; set; } = string.Empty;
/// <summary>
/// The guest display name
/// </summary>
public string GuestStarUserName { get; set; } = string.Empty;
/// <summary>
/// The guest login
/// </summary>
public string GuestStarUserLogin { get; set; } = string.Empty;
/// <summary>
/// The ID of the slot assignment the guest is assigned to. null/empty if the guest is in the INVITED state.
/// <para>or the ID of the slot where settings were updated.</para>
/// </summary>
public string SlotId { get; set; } = string.Empty;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System;

namespace TwitchLib.EventSub.Core.Models.GuestStar
{
public abstract class ChannelGuestStarSessionBase

Check warning on line 5 in TwitchLib.EventSub.Core/Models/GuestStar/ChannelGuestStarSessionBase.cs

View workflow job for this annotation

GitHub Actions / check-buildstatus

Missing XML comment for publicly visible type or member 'ChannelGuestStarSessionBase'
{
/// <summary>
/// The broadcaster user ID
/// </summary>
public string BroadcasterUserId { get; set; } = string.Empty;
/// <summary>
/// The broadcaster display name
/// </summary>
public string BroadcasterUserName { get; set; } = string.Empty;
/// <summary>
/// The broadcaster login
/// </summary>
public string BroadcasterUserLogin { get; set; } = string.Empty;
/// <summary>
/// Unique ID representing the session.
/// </summary>
public string SessionId { get; set; } = string.Empty;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using TwitchLib.EventSub.Core.Models.GuestStar;

namespace TwitchLib.EventSub.Core.SubscriptionTypes.Channel
{
/// <summary>
/// Channel GuestStar Guest Update subscription type model
/// <para>Description:</para>
/// <para>The channel.guest_star_guest.update subscription type sends a notification when a guest moves between interaction states in an active Guest Star session.</para>
/// </summary>
public class ChannelGuestStarGuestUpdate : ChannelGuestStarBase
{
/// <summary>
/// The current state of the user after the update has taken place. Can be one of the following:
/// <para>
/// invited — The guest has transitioned to the invite queue. This can take place when the guest was previously assigned a slot, but have been removed from the call and are sent back to the invite queue.
/// </para>
/// <para>
/// ready — The guest has signaled they are ready and can be assigned a slot.
/// </para>
/// <para>
/// backstage — The guest has been assigned a slot in the session, but is not currently seen live in the broadcasting software.
/// </para>
/// <para>
/// live — The guest is now live in the host's broadcasting software.
/// </para>
/// <para>
/// removed — The guest was removed from the call or queue.
/// </para>
/// </summary>
public string State { get; set; } = string.Empty;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System;
using TwitchLib.EventSub.Core.Models.GuestStar;

namespace TwitchLib.EventSub.Core.SubscriptionTypes.Channel
{
/// <summary>
/// Channel GuestStar Session Begin subscription type model
/// <para>Description:</para>
/// <para>The channel.guest_star_session.begin subscription type sends a notification when the host begins a new Guest Star session.</para>
/// </summary>
public class ChannelGuestStarSessionBegin : ChannelGuestStarSessionBase
{
/// <summary>
/// RFC3339 timestamp indicating the time the session began.
/// </summary>
public DateTimeOffset StartedAt { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;
using TwitchLib.EventSub.Core.Models.GuestStar;

namespace TwitchLib.EventSub.Core.SubscriptionTypes.Channel
{
/// <summary>
/// Channel GuestStar Session End subscription type model
/// <para>Description:</para>
/// <para>The channel.guest_star_session.end subscription type sends a notification when a running Guest Star session is ended by the host, or automatically by the system.</para>
/// </summary>
public class ChannelGuestStarSessionEnd : ChannelGuestStarSessionBase
{
/// <summary>
/// RFC3339 timestamp indicating the time the session began.
/// </summary>
public DateTimeOffset StartedAt { get; set; }
/// <summary>
/// RFC3339 timestamp indicating the time the session ended.
/// </summary>
public DateTimeOffset EndedAt { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
namespace TwitchLib.EventSub.Core.SubscriptionTypes.Channel
{
/// <summary>
/// Channel GuestStar Settings Update subscription type model
/// <para>Description:</para>
/// <para>The channel.guest_star_settings.update subscription type sends a notification when the host preferences for Guest Star have been updated.</para>
/// </summary>
public class ChannelGuestStarSettingsUpdate
{
/// <summary>
/// User ID of the host channel
/// </summary>
public string BroadcasterUserId { get; set; } = string.Empty;
/// <summary>
/// The broadcaster display name
/// </summary>
public string BroadcasterUserName { get; set; } = string.Empty;
/// <summary>
/// the broadcaster login
/// </summary>
public string BroadcasterUserLogin { get; set; } = string.Empty;
/// <summary>
/// Flag determining if Guest Star moderators have access to control whether a guest is live once assigned to a slot.
/// </summary>
public bool IsModeratorSendLiveEnabled { get; set; }
/// <summary>
/// Number of slots the Guest Star call interface will allow the host to add to a call.
/// </summary>
public int SlotCount { get; set; }
/// <summary>
/// Flag determining if browser sources subscribed to sessions on this channel should output audio
/// </summary>
public bool IsBrowserSourceAudioEnabled { get; set; }
/// <summary>
/// This setting determines how the guests within a session should be laid out within a group browser source. Can be one of the following values:
/// <para>tiled — All live guests are tiled within the browser source with the same size.</para>
/// <para>screenshare — All live guests are tiled within the browser source with the same size. If there is an active screen share, it is sized larger than the other guests.</para>
/// </summary>
public string GroupLayout { get; set; } = string.Empty;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using TwitchLib.EventSub.Core.Models.GuestStar;

namespace TwitchLib.EventSub.Core.SubscriptionTypes.Channel
{
/// <summary>
/// Channel GuestStar Slot Update subscription type model
/// <para>Description:</para>
/// <para>The channel.guest_star_slot.update subscription type sends a notification when a slot setting is updated in an active Guest Star session.</para>
/// </summary>
public class ChannelGuestStarSlotUpdate : ChannelGuestStarBase
{
/// <summary>
/// Flag that signals whether the host is allowing the slot’s video to be seen by participants within the session.
/// </summary>
public bool HostVideoEnabled { get; set; }
/// <summary>
/// Flag that signals whether the host is allowing the slot’s audio to be heard by participants within the session.
/// </summary>
public bool HostAudioEnabled { get; set; }
/// <summary>
/// Value between 0-100 that represents the slot’s audio level as heard by participants within the session.
/// </summary>
public int HostVolume { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class HypeTrainProgress : HypeTrainBase
/// <summary>
/// The most recent contribution.
/// </summary>
public HypeTrainContribution[] LastContribution { get; set; } = Array.Empty<HypeTrainContribution>();
public HypeTrainContribution LastContribution { get; set; } = new HypeTrainContribution();
/// <summary>
/// The time when the Hype Train expires. The expiration is extended when the Hype Train reaches a new level.
/// </summary>
Expand Down
9 changes: 4 additions & 5 deletions TwitchLib.EventSub.Core/TwitchLib.EventSub.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
<PackageId>TwitchLib.EventSub.Core</PackageId>
<Title>TwitchLib.EventSub.Core</Title>
<Authors>swiftyspiffy, Prom3theu5, Syzuna, LuckyNoS7evin</Authors>
<Company></Company>
<VersionPrefix>2.3.1</VersionPrefix>
<VersionPrefix>2.4.3</VersionPrefix>
<VersionSuffix>$(VersionSuffix)</VersionSuffix>
<AssemblyVersion>2.3.1</AssemblyVersion>
<FileVersion>2.3.1</FileVersion>
<AssemblyVersion>2.4.3</AssemblyVersion>
<FileVersion>2.4.3</FileVersion>
<Description>Contains Subscription Types and Models for Twitch's EventSub system</Description>
<PackageIconUrl>https://cdn.syzuna-programs.de/images/twitchlib.png</PackageIconUrl>
<PackageProjectUrl>https://github.com/TwitchLib/TwitchLib.EventSub.Websockets</PackageProjectUrl>
Expand All @@ -18,7 +17,7 @@
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<Copyright>Copyright 2023</Copyright>
<PackageTags>twitch library events eventsub subscriptiontypes c# csharp net netstandard2.0 netstandard2.1 5.0 6.0 7.0</PackageTags>
<PackageReleaseNotes>Added missing WinningOutcomeId to ChannelPredictionEnd model</PackageReleaseNotes>
<PackageReleaseNotes>Added GuestStar Subscription Types, added AsyncEventHandler delegate</PackageReleaseNotes>
<PackageReadmeFile>README.md</PackageReadmeFile>
<NeutralLanguage>en-US</NeutralLanguage>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
Expand Down
Loading