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

add Whisper Received #43

Merged
merged 3 commits into from
Nov 5, 2024
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using TwitchLib.EventSub.Core.SubscriptionTypes.User;
using TwitchLib.EventSub.Websockets.Core.Models;

namespace TwitchLib.EventSub.Websockets.Core.EventArgs.User
{
public class UserWhisperMessageArgs : TwitchLibEventSubEventArgs<EventSubNotification<UserWhisperMessage>>
{ }
}
5 changes: 5 additions & 0 deletions TwitchLib.EventSub.Websockets/EventSubWebsocketClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@
/// <summary>
/// Event that triggers on "channel.charity_campaign.start" notifications
/// </summary>
public event AsyncEventHandler<ChannelCharityCampaignStartArgs> ChannelCharityCampaignStart;

Check warning on line 62 in TwitchLib.EventSub.Websockets/EventSubWebsocketClient.cs

View workflow job for this annotation

GitHub Actions / check-buildstatus

The event 'EventSubWebsocketClient.ChannelCharityCampaignStart' is never used
/// <summary>
/// Event that triggers on "channel.charity_campaign.donate" notifications
/// </summary>
public event AsyncEventHandler<ChannelCharityCampaignDonateArgs> ChannelCharityCampaignDonate;

Check warning on line 66 in TwitchLib.EventSub.Websockets/EventSubWebsocketClient.cs

View workflow job for this annotation

GitHub Actions / check-buildstatus

The event 'EventSubWebsocketClient.ChannelCharityCampaignDonate' is never used
/// <summary>
/// Event that triggers on "channel.charity_campaign.progress" notifications
/// </summary>
Expand Down Expand Up @@ -135,7 +135,7 @@
/// <summary>
/// Event that triggers on "channel.moderator.add" notifications
/// </summary>
public event AsyncEventHandler<ChannelModeratorArgs> ChannelModeratorAdd;

Check warning on line 138 in TwitchLib.EventSub.Websockets/EventSubWebsocketClient.cs

View workflow job for this annotation

GitHub Actions / check-buildstatus

The event 'EventSubWebsocketClient.ChannelModeratorAdd' is never used
/// <summary>
/// Event that triggers on "channel.moderator.remove" notifications
/// </summary>
Expand Down Expand Up @@ -201,7 +201,7 @@
/// <summary>
/// Event that triggers on "channel.prediction.lock" notifications
/// </summary>
public event AsyncEventHandler<ChannelPredictionLockArgs> ChannelPredictionLock;

Check warning on line 204 in TwitchLib.EventSub.Websockets/EventSubWebsocketClient.cs

View workflow job for this annotation

GitHub Actions / check-buildstatus

The event 'EventSubWebsocketClient.ChannelPredictionLock' is never used
/// <summary>
/// Event that triggers on "channel.prediction.progress" notifications
/// </summary>
Expand All @@ -219,7 +219,7 @@
/// <summary>
/// Event that triggers on "channel.shield_mode.end" notifications
/// </summary>
public event AsyncEventHandler<ChannelShieldModeEndArgs> ChannelShieldModeEnd;

Check warning on line 222 in TwitchLib.EventSub.Websockets/EventSubWebsocketClient.cs

View workflow job for this annotation

GitHub Actions / check-buildstatus

The event 'EventSubWebsocketClient.ChannelShieldModeEnd' is never used

/// <summary>
/// Event that triggers on "channel.shoutout.create" notifications
Expand All @@ -228,7 +228,7 @@
/// <summary>
/// Event that triggers on "channel.shoutout.receive" notifications
/// </summary>
public event AsyncEventHandler<ChannelShoutoutReceiveArgs> ChannelShoutoutReceive;

Check warning on line 231 in TwitchLib.EventSub.Websockets/EventSubWebsocketClient.cs

View workflow job for this annotation

GitHub Actions / check-buildstatus

The event 'EventSubWebsocketClient.ChannelShoutoutReceive' is never used

/// <summary>
/// Event that triggers on "channel.subscribe" notifications
Expand All @@ -237,11 +237,11 @@
/// <summary>
/// Event that triggers on "channel.subscription.end" notifications
/// </summary>
public event AsyncEventHandler<ChannelSubscriptionEndArgs> ChannelSubscriptionEnd;

Check warning on line 240 in TwitchLib.EventSub.Websockets/EventSubWebsocketClient.cs

View workflow job for this annotation

GitHub Actions / check-buildstatus

The event 'EventSubWebsocketClient.ChannelSubscriptionEnd' is never used
/// <summary>
/// Event that triggers on "channel.subscription.gift" notifications
/// </summary>
public event AsyncEventHandler<ChannelSubscriptionGiftArgs> ChannelSubscriptionGift;

Check warning on line 244 in TwitchLib.EventSub.Websockets/EventSubWebsocketClient.cs

View workflow job for this annotation

GitHub Actions / check-buildstatus

The event 'EventSubWebsocketClient.ChannelSubscriptionGift' is never used
/// <summary>
/// Event that triggers on "channel.subscription.message" notifications
/// </summary>
Expand Down Expand Up @@ -270,17 +270,22 @@
/// <summary>
/// Event that triggers on "stream.offline" notifications
/// </summary>
public event AsyncEventHandler<StreamOfflineArgs> StreamOffline;

Check warning on line 273 in TwitchLib.EventSub.Websockets/EventSubWebsocketClient.cs

View workflow job for this annotation

GitHub Actions / check-buildstatus

The event 'EventSubWebsocketClient.StreamOffline' is never used
/// <summary>
/// Event that triggers on "stream.online" notifications
/// </summary>
public event AsyncEventHandler<StreamOnlineArgs> StreamOnline;

Check warning on line 277 in TwitchLib.EventSub.Websockets/EventSubWebsocketClient.cs

View workflow job for this annotation

GitHub Actions / check-buildstatus

The event 'EventSubWebsocketClient.StreamOnline' is never used

/// <summary>
/// Event that triggers on "user.update" notifications
/// </summary>
public event AsyncEventHandler<UserUpdateArgs> UserUpdate;

/// <summary>
/// Event that triggers on "user.whisper.message" notifications
/// </summary>
public event AsyncEventHandler<UserWhisperMessageArgs> UserWhisperMessage;

#endregion

/// <summary>
Expand Down
26 changes: 26 additions & 0 deletions TwitchLib.EventSub.Websockets/Handler/User/UserUpdateHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,31 @@ public void Handle(EventSubWebsocketClient client, string jsonString, JsonSerial
client.RaiseEvent("ErrorOccurred", new ErrorOccuredArgs { Exception = ex, Message = $"Error encountered while trying to handle {SubscriptionType} notification! Raw Json: {jsonString}" });
}
}
}
/// <summary>
/// Handler for 'user.whisper.message' notifications
/// </summary>
public class UserWhisperMessageHandler : INotificationHandler
{
/// <inheritdoc />
public string SubscriptionType => "user.whisper.message";

/// <inheritdoc />
public void Handle(EventSubWebsocketClient client, string jsonString, JsonSerializerOptions serializerOptions)
{
try
{
var data = JsonSerializer.Deserialize<EventSubNotification<UserWhisperMessage>>(jsonString.AsSpan(), serializerOptions);

if (data is null)
throw new InvalidOperationException("Parsed JSON cannot be null!");

client.RaiseEvent("UserWhisperMessage", new UserWhisperMessageArgs { Notification = data });
}
catch (Exception ex)
{
client.RaiseEvent("ErrorOccurred", new ErrorOccuredArgs { Exception = ex, Message = $"Error encountered while trying to handle {SubscriptionType} notification! Raw Json: {jsonString}" });
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="TwitchLib.EventSub.Core" Version="2.5.3-preview-d80beed" />
<PackageReference Include="TwitchLib.EventSub.Core" Version="2.5.3-preview-ce9df77" />
<PackageReference Include="System.Text.Json" Version="8.0.4" />
</ItemGroup>

Expand Down
Loading