Skip to content

Commit 8dbcfb5

Browse files
authored
Merge pull request #54 from Bregann/dev
Channel Unban Request Events
2 parents 532b5cd + 4adde38 commit 8dbcfb5

File tree

5 files changed

+100
-0
lines changed

5 files changed

+100
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
using TwitchLib.EventSub.Core.SubscriptionTypes.Channel;
2+
using TwitchLib.EventSub.Websockets.Core.Models;
3+
4+
namespace TwitchLib.EventSub.Websockets.Core.EventArgs.Channel
5+
{
6+
public class ChannelUnbanRequestCreateArgs : TwitchLibEventSubEventArgs<EventSubNotification<ChannelUnbanRequestCreate>>
7+
{ }
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
using TwitchLib.EventSub.Core.SubscriptionTypes.Channel;
2+
using TwitchLib.EventSub.Websockets.Core.Models;
3+
4+
namespace TwitchLib.EventSub.Websockets.Core.EventArgs.Channel
5+
{
6+
public class ChannelUnbanRequestResolveArgs : TwitchLibEventSubEventArgs<EventSubNotification<ChannelUnbanRequestResolve>>
7+
{ }
8+
}

TwitchLib.EventSub.Websockets/EventSubWebsocketClient.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,16 @@ public class EventSubWebsocketClient
319319
/// </summary>
320320
public event AsyncEventHandler<ChannelSharedChatSessionEndArgs> ChannelSharedChatSessionEnd;
321321

322+
/// <summary>
323+
/// Event that triggers on "channel.unban_request.create" notifications
324+
/// </summary>
325+
public event AsyncEventHandler<ChannelUnbanRequestCreateArgs> ChannelUnbanRequestCreate;
326+
327+
/// <summary>
328+
/// Event that triggers on "channel.unban_request.resolve" notifications
329+
/// </summary>
330+
public event AsyncEventHandler<ChannelUnbanRequestResolveArgs> ChannelUnbanRequestResolve;
331+
322332
#endregion
323333

324334
/// <summary>
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
using System;
2+
using System.Text.Json;
3+
using TwitchLib.EventSub.Core.SubscriptionTypes.Channel;
4+
using TwitchLib.EventSub.Websockets.Core.EventArgs;
5+
using TwitchLib.EventSub.Websockets.Core.EventArgs.Channel;
6+
using TwitchLib.EventSub.Websockets.Core.Handler;
7+
using TwitchLib.EventSub.Websockets.Core.Models;
8+
9+
namespace TwitchLib.EventSub.Websockets.Handler.Channel.Moderation
10+
{
11+
/// <summary>
12+
/// Handler for 'channel.unban_request.create' notifications
13+
/// </summary>
14+
public class ChannelUnbanRequestCreateHandler : INotificationHandler
15+
{
16+
/// <inheritdoc />
17+
public string SubscriptionType => "channel.unban_request.create";
18+
19+
/// <inheritdoc />
20+
public void Handle(EventSubWebsocketClient client, string jsonString, JsonSerializerOptions serializerOptions)
21+
{
22+
try
23+
{
24+
var data = JsonSerializer.Deserialize<EventSubNotification<ChannelUnbanRequestCreate>>(jsonString.AsSpan(), serializerOptions);
25+
26+
if (data is null)
27+
throw new InvalidOperationException("Parsed JSON cannot be null!");
28+
29+
client.RaiseEvent("ChannelUnbanRequestCreate", new ChannelUnbanRequestCreateArgs { Notification = data });
30+
}
31+
catch (Exception ex)
32+
{
33+
client.RaiseEvent("ErrorOccurred", new ErrorOccuredArgs { Exception = ex, Message = $"Error encountered while trying to handle {SubscriptionType} notification! Raw Json: {jsonString}" });
34+
}
35+
}
36+
}
37+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
using System;
2+
using System.Text.Json;
3+
using TwitchLib.EventSub.Core.SubscriptionTypes.Channel;
4+
using TwitchLib.EventSub.Websockets.Core.EventArgs;
5+
using TwitchLib.EventSub.Websockets.Core.EventArgs.Channel;
6+
using TwitchLib.EventSub.Websockets.Core.Handler;
7+
using TwitchLib.EventSub.Websockets.Core.Models;
8+
9+
namespace TwitchLib.EventSub.Websockets.Handler.Channel.Moderation
10+
{
11+
/// <summary>
12+
/// Handler for 'channel.unban_request.resolve' notifications
13+
/// </summary>
14+
public class ChannelUnbanRequestResolveHandler : INotificationHandler
15+
{
16+
/// <inheritdoc />
17+
public string SubscriptionType => "channel.unban_request.resolve";
18+
19+
/// <inheritdoc />
20+
public void Handle(EventSubWebsocketClient client, string jsonString, JsonSerializerOptions serializerOptions)
21+
{
22+
try
23+
{
24+
var data = JsonSerializer.Deserialize<EventSubNotification<ChannelUnbanRequestResolve>>(jsonString.AsSpan(), serializerOptions);
25+
26+
if (data is null)
27+
throw new InvalidOperationException("Parsed JSON cannot be null!");
28+
29+
client.RaiseEvent("ChannelUnbanRequestResolve", new ChannelUnbanRequestResolveArgs { Notification = data });
30+
}
31+
catch (Exception ex)
32+
{
33+
client.RaiseEvent("ErrorOccurred", new ErrorOccuredArgs { Exception = ex, Message = $"Error encountered while trying to handle {SubscriptionType} notification! Raw Json: {jsonString}" });
34+
}
35+
}
36+
}
37+
}

0 commit comments

Comments
 (0)