Skip to content

Commit

Permalink
feat: ChannelSuspiciousUserMessage, ChannelSuspiciousUserUpdate
Browse files Browse the repository at this point in the history
feat: ChannelSuspiciousUserMessage, ChannelSuspiciousUserUpdate
  • Loading branch information
Mahsaap authored Jun 12, 2024
2 parents bcfc70a + 7b34981 commit 5158299
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 0 deletions.
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 / release-preview

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 / release-preview

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 / release-preview

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 / release-preview

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 / release-preview

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 / release-preview

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 / release-preview

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 / release-preview

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 / release-preview

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 / release-preview

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}" });
}
}
}
}

0 comments on commit 5158299

Please sign in to comment.