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

feat: ChannelSuspiciousUserMessage, ChannelSuspiciousUserUpdate #31

Merged
merged 1 commit into from
Jun 12, 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,12 @@
using System;
using System.Collections.Generic;
using System.Text;
using TwitchLib.EventSub.Core.SubscriptionTypes.Channel;
using TwitchLib.EventSub.Websockets.Core.Models;

namespace TwitchLib.EventSub.Websockets.Core.EventArgs.Channel
{
public class ChannelSuspiciousUserMessageArgs : TwitchLibEventSubEventArgs<EventSubNotification<ChannelSuspiciousUserMessage>>

Check failure on line 9 in TwitchLib.EventSub.Websockets/Core/EventArgs/Channel/ChannelSuspiciousUserMessageArgs.cs

View workflow job for this annotation

GitHub Actions / check-buildstatus

The type or namespace name 'ChannelSuspiciousUserMessage' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 9 in TwitchLib.EventSub.Websockets/Core/EventArgs/Channel/ChannelSuspiciousUserMessageArgs.cs

View workflow job for this annotation

GitHub Actions / check-buildstatus

The type or namespace name 'ChannelSuspiciousUserMessage' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 9 in TwitchLib.EventSub.Websockets/Core/EventArgs/Channel/ChannelSuspiciousUserMessageArgs.cs

View workflow job for this annotation

GitHub Actions / check-buildstatus

The type or namespace name 'ChannelSuspiciousUserMessage' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 9 in TwitchLib.EventSub.Websockets/Core/EventArgs/Channel/ChannelSuspiciousUserMessageArgs.cs

View workflow job for this annotation

GitHub Actions / check-buildstatus

The type or namespace name 'ChannelSuspiciousUserMessage' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 9 in TwitchLib.EventSub.Websockets/Core/EventArgs/Channel/ChannelSuspiciousUserMessageArgs.cs

View workflow job for this annotation

GitHub Actions / check-buildstatus

The type or namespace name 'ChannelSuspiciousUserMessage' could not be found (are you missing a using directive or an assembly reference?)
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Text;
using TwitchLib.EventSub.Core.SubscriptionTypes.Channel;
using TwitchLib.EventSub.Websockets.Core.Models;

namespace TwitchLib.EventSub.Websockets.Core.EventArgs.Channel
{
public sealed class ChannelSuspiciousUserUpdateArgs : TwitchLibEventSubEventArgs<EventSubNotification<ChannelSuspiciousUserUpdate>>

Check failure on line 9 in TwitchLib.EventSub.Websockets/Core/EventArgs/Channel/ChannelSuspiciousUserUpdateArgs.cs

View workflow job for this annotation

GitHub Actions / check-buildstatus

The type or namespace name 'ChannelSuspiciousUserUpdate' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 9 in TwitchLib.EventSub.Websockets/Core/EventArgs/Channel/ChannelSuspiciousUserUpdateArgs.cs

View workflow job for this annotation

GitHub Actions / check-buildstatus

The type or namespace name 'ChannelSuspiciousUserUpdate' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 9 in TwitchLib.EventSub.Websockets/Core/EventArgs/Channel/ChannelSuspiciousUserUpdateArgs.cs

View workflow job for this annotation

GitHub Actions / check-buildstatus

The type or namespace name 'ChannelSuspiciousUserUpdate' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 9 in TwitchLib.EventSub.Websockets/Core/EventArgs/Channel/ChannelSuspiciousUserUpdateArgs.cs

View workflow job for this annotation

GitHub Actions / check-buildstatus

The type or namespace name 'ChannelSuspiciousUserUpdate' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 9 in TwitchLib.EventSub.Websockets/Core/EventArgs/Channel/ChannelSuspiciousUserUpdateArgs.cs

View workflow job for this annotation

GitHub Actions / check-buildstatus

The type or namespace name 'ChannelSuspiciousUserUpdate' could not be found (are you missing a using directive or an assembly reference?)
{
}
}
10 changes: 10 additions & 0 deletions TwitchLib.EventSub.Websockets/EventSubWebsocketClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,16 @@ public class EventSubWebsocketClient
/// </summary>
public event AsyncEventHandler<ChannelSubscriptionMessageArgs> ChannelSubscriptionMessage;

/// <summary>
/// Event that triggers on "channel.suspicious_user.message" notifications
/// </summary>
public event AsyncEventHandler<ChannelSuspiciousUserMessageArgs> ChannelSuspiciousUserMessage;

/// <summary>
/// Event that triggers on "channel.suspicious_user.update" notifications
/// </summary>
public event AsyncEventHandler<ChannelSuspiciousUserUpdateArgs> ChannelSuspiciousUserUpdate;

/// <summary>
/// Event that triggers on "channel.unban" notifications
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.Json;
using TwitchLib.EventSub.Core.SubscriptionTypes.Channel;
using TwitchLib.EventSub.Websockets.Core.EventArgs;
using TwitchLib.EventSub.Websockets.Core.EventArgs.Channel;
using TwitchLib.EventSub.Websockets.Core.Handler;
using TwitchLib.EventSub.Websockets.Core.Models;

namespace TwitchLib.EventSub.Websockets.Handler.Channel.SuspiciousUser
{
/// <summary>
/// Handler for 'channel.suspicious_user.message' notifications
/// </summary>
public class ChannelSuspiciousUserMessageHandler : INotificationHandler
{
/// <inheritdoc />
public string SubscriptionType => "channel.suspicious_user.message";

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

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

client.RaiseEvent("ChannelSuspiciousUserMessage", new ChannelSuspiciousUserMessageArgs { 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
@@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.Json;
using TwitchLib.EventSub.Core.SubscriptionTypes.Channel;
using TwitchLib.EventSub.Websockets.Core.EventArgs;
using TwitchLib.EventSub.Websockets.Core.EventArgs.Channel;
using TwitchLib.EventSub.Websockets.Core.Handler;
using TwitchLib.EventSub.Websockets.Core.Models;

namespace TwitchLib.EventSub.Websockets.Handler.Channel.SuspiciousUser
{
/// <summary>
/// Handler for 'channel.suspicious_user.update' notifications
/// </summary>
public class ChannelSuspiciousUserUpdateHandler : INotificationHandler
{
/// <inheritdoc />
public string SubscriptionType => "channel.suspicious_user.update";

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

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

client.RaiseEvent("ChannelSuspiciousUserUpdate", new ChannelSuspiciousUserUpdateArgs { Notification = data });
}
catch (Exception ex)
{
client.RaiseEvent("ErrorOccurred", new ErrorOccuredArgs { Exception = ex, Message = $"Error encountered while trying to handle {SubscriptionType} notification! Raw Json: {jsonString}" });
}
}
}
}
Loading