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

Updated missing Topics, updated interface #120

Merged
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.PubSub/Events/OnChannelBitsBadgeUnlockArgs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System;
using TwitchLib.PubSub.Models.Responses.Messages;

namespace TwitchLib.PubSub.Events
{
public class OnChannelBitsBadgeUnlockArgs : EventArgs
{
/// <summary>
/// The subscription
/// </summary>
public BitsBadgeNotificationMessage BitsBadgeUnlocks;

/// <summary>
/// The channel ID the event came from
/// </summary>
public string ChannelId;
}
}
18 changes: 18 additions & 0 deletions TwitchLib.PubSub/Events/OnLowTrustUsersArgs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System;
using TwitchLib.PubSub.Models.Responses.Messages;

namespace TwitchLib.PubSub.Events
{
public class OnLowTrustUsersArgs : EventArgs
{
/// <summary>
/// The subscription
/// </summary>
public LowTrustUsers LowTrustUsers;

/// <summary>
/// The channel ID the event came from
/// </summary>
public string ChannelId;
}
}
56 changes: 48 additions & 8 deletions TwitchLib.PubSub/Interfaces/ITwitchPubSub.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,28 @@ namespace TwitchLib.PubSub.Interfaces
/// </summary>
public interface ITwitchPubSub
{
/// <summary>
/// Fires when a moderation event hits a user
/// </summary>
event EventHandler<OnAutomodCaughtUserMessage> OnAutomodCaughtUserMessage;

/// <summary>
/// Fires when Automod updates a held message.
/// </summary>
event EventHandler<OnAutomodCaughtMessageArgs> OnAutomodCaughtMessage;

/// <summary>
/// Occurs when [on ban].
/// </summary>
event EventHandler<OnBanArgs> OnBan;
/// <summary>
/// Occurs when [on bits received].
/// Fires when PubSub receives a bits message.
/// </summary>
event EventHandler<OnBitsReceivedV2Args> OnBitsReceivedV2;
/// <summary>
/// Fires when PubSub receives notice when the channel unlocks bit badge.
/// </summary>
event EventHandler<OnBitsReceivedArgs> OnBitsReceived;
event EventHandler<OnChannelBitsBadgeUnlockArgs> OnChannelBitsBadgeUnlock;
/// <summary>
/// Occurs when [on channel extension broadcast].
/// </summary>
Expand Down Expand Up @@ -54,6 +68,10 @@ public interface ITwitchPubSub
/// </summary>
event EventHandler<OnListenResponseArgs> OnListenResponse;
/// <summary>
/// Fires when PubSub receives notice when the channel detects low trust user.
/// </summary>
event EventHandler<OnLowTrustUsersArgs> OnLowTrustUsers;
/// <summary>
/// Occurs when [on pub sub service closed].
/// </summary>
event EventHandler OnPubSubServiceClosed;
Expand All @@ -74,6 +92,10 @@ public interface ITwitchPubSub
/// </summary>
event EventHandler<OnR9kBetaOffArgs> OnR9kBetaOff;
/// <summary>
/// Fires when PubSub receives notice when a channel cancels the raid
/// </summary>
event EventHandler<OnRaidCancelArgs> OnRaidCancel;
/// <summary>
/// Occurs when [on stream down].
/// </summary>
event EventHandler<OnStreamDownArgs> OnStreamDown;
Expand Down Expand Up @@ -186,12 +208,6 @@ public interface ITwitchPubSub
/// </summary>
Task DisconnectAsync();

/// <summary>
/// Listens to bits events.
/// </summary>
/// <param name="channelTwitchId">The channel twitch identifier.</param>
[Obsolete("This topic is deprecated by Twitch. Please use ListenToBitsEventsV2()", false)]
void ListenToBitsEvents(string channelTwitchId);
/// <summary>
/// Listens to bits events.
/// </summary>
Expand Down Expand Up @@ -255,6 +271,30 @@ public interface ITwitchPubSub
/// </summary>
/// <param name="channelTwitchId">The channel twitch identifier.</param>
void ListenToPredictions(string channelTwitchId);
/// <summary>
/// A user’s message held by AutoMod has been approved or denied.
/// </summary>
/// <param name="myTwitchId">Current user identifier.</param>
/// <param name="channelTwitchId">The channel twitch identifier.</param>
void ListenToUserModerationNotifications(string myTwitchId, string channelTwitchId);
/// <summary>
/// Sends a request to listen to Automod queued messages in a specific channel
/// </summary>
/// <param name="userTwitchId">A moderator's twitch account's ID</param>
/// <param name="channelTwitchId">Channel ID who has previous parameter's moderator</param>
void ListenToAutomodQueue(string userTwitchId, string channelTwitchId);
/// <summary>
/// Message sent when a user earns a new Bits badge in a particular channel, and chooses to share the notification with chat.
/// </summary>
/// <param name="channelTwitchId">The channel twitch identifier.</param>
void ListenToChannelBitsBadgeUnlocks(string channelTwitchId);
/// <summary>
/// The broadcaster or a moderator updates the low trust status of a user, or a new message has been sent in chat by a potential ban evader or a bans shared user.
/// </summary>
/// <param name="channelTwitchId">The channel twitch identifier.</param>
/// <param name="suspiciousUser">Suspicious user identifier.</param>
void ListenToLowTrustUsers(string channelTwitchId, string suspiciousUser);

/// <summary>
/// Sends the topics.
/// </summary>
Expand Down
12 changes: 8 additions & 4 deletions TwitchLib.PubSub/Models/Responses/Message.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using TwitchLib.PubSub.Models.Responses.Messages;
using TwitchLib.PubSub.Models.Responses.Messages.AutomodCaughtMessage;
using TwitchLib.PubSub.Models.Responses.Messages.UserModerationNotifications;

namespace TwitchLib.PubSub.Models.Responses
Expand Down Expand Up @@ -41,9 +40,6 @@ public Message(string jsonStr)
case "chat_moderator_actions":
MessageData = new ChatModeratorActions(encodedJsonMessage);
break;
case "channel-bits-events-v1":
MessageData = new ChannelBitsEvents(encodedJsonMessage);
break;
case "channel-bits-events-v2":
encodedJsonMessage = encodedJsonMessage.Replace("\\", "");
var dataEncoded = JObject.Parse(encodedJsonMessage)["data"].ToString();
Expand Down Expand Up @@ -79,6 +75,14 @@ public Message(string jsonStr)
case "predictions-channel-v1":
MessageData = new PredictionEvents(encodedJsonMessage);
break;
case "channel-bits-badge-unlocks":
encodedJsonMessage = encodedJsonMessage.Replace("\\", "");
var channelBitsBadgeData = JObject.Parse(encodedJsonMessage)["data"].ToString();
MessageData = JsonConvert.DeserializeObject<BitsBadgeNotificationMessage>(channelBitsBadgeData);
break;
case "low-trust-users":
MessageData = new LowTrustUsers(encodedJsonMessage);
break;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System;
using Newtonsoft.Json;

namespace TwitchLib.PubSub.Models.Responses.Messages
{
public class BitsBadgeNotificationMessage : MessageData
{
[JsonProperty(PropertyName = "user_id")]
public string UserId { get; protected set; }

[JsonProperty(PropertyName = "user_name")]
public string UserName { get; protected set; }

[JsonProperty(PropertyName = "channel_id")]
public string ChannelId { get; protected set; }

[JsonProperty(PropertyName = "channel_name")]
public string ChannelName { get; protected set; }

[JsonProperty(PropertyName = "badge_tier")]
public int BadgeTier { get; protected set; }

[JsonProperty(PropertyName = "chat_message")]
public string ChatMessage { get; protected set; }

[JsonProperty(PropertyName = "time")]
public DateTime Time { get; protected set; }
}
}
77 changes: 0 additions & 77 deletions TwitchLib.PubSub/Models/Responses/Messages/ChannelBitsEvents.cs

This file was deleted.

12 changes: 12 additions & 0 deletions TwitchLib.PubSub/Models/Responses/Messages/LowTrustUsers.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace TwitchLib.PubSub.Models.Responses.Messages
{
public class LowTrustUsers : MessageData
{
public string RawData { get; private set; }

public LowTrustUsers(string jsonString)
{
RawData = jsonString;
}
}
}
2 changes: 1 addition & 1 deletion TwitchLib.PubSub/TwitchLib.PubSub.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" />
<PackageReference Include="TwitchLib.Communication" Version="2.0.0-preview-8108207851b6bbef87062f15a497036183ffea70" />
<PackageReference Include="TwitchLib.Communication" Version="2.0.0" />
</ItemGroup>
</Project>
Loading
Loading