Fixed Twitch subscriptions. Fixed typos. Fixed Twitch websocket reconnection.
This commit is contained in:
parent
eb8bfdf6b0
commit
8a0e55bb95
@ -33,7 +33,7 @@ namespace TwitchChatTTS.Twitch.Socket.Handlers
|
|||||||
var actions = _redemptionManager.Get("adbreak");
|
var actions = _redemptionManager.Get("adbreak");
|
||||||
if (!actions.Any())
|
if (!actions.Any())
|
||||||
{
|
{
|
||||||
_logger.Debug($"No redemable actions for ad break was found");
|
_logger.Debug($"No redeemable actions for ad break was found");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_logger.Debug($"Found {actions.Count} actions for this Twitch ad break");
|
_logger.Debug($"Found {actions.Count} actions for this Twitch ad break");
|
||||||
@ -45,7 +45,7 @@ namespace TwitchChatTTS.Twitch.Socket.Handlers
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.Error(ex, $"Failed to execute redeeemable action [action: {action.Name}][action type: {action.Type}][redeem: ad break]");
|
_logger.Error(ex, $"Failed to execute redeemable action [action: {action.Name}][action type: {action.Type}][redeem: ad break]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
@ -32,7 +32,7 @@ namespace TwitchChatTTS.Twitch.Socket.Handlers
|
|||||||
var actions = _redemptionManager.Get(message.Reward.Id);
|
var actions = _redemptionManager.Get(message.Reward.Id);
|
||||||
if (!actions.Any())
|
if (!actions.Any())
|
||||||
{
|
{
|
||||||
_logger.Debug($"No redemable actions for this redeem was found [redeem: {message.Reward.Title}][redeem id: {message.Reward.Id}][transaction: {message.Id}]");
|
_logger.Debug($"No redeemable actions for this redeem was found [redeem: {message.Reward.Title}][redeem id: {message.Reward.Id}][transaction: {message.Id}]");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_logger.Debug($"Found {actions.Count} actions for this Twitch channel point redemption [redeem: {message.Reward.Title}][redeem id: {message.Reward.Id}][transaction: {message.Id}]");
|
_logger.Debug($"Found {actions.Count} actions for this Twitch channel point redemption [redeem: {message.Reward.Title}][redeem id: {message.Reward.Id}][transaction: {message.Id}]");
|
||||||
@ -44,7 +44,7 @@ namespace TwitchChatTTS.Twitch.Socket.Handlers
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.Error(ex, $"Failed to execute redeeemable action [action: {action.Name}][action type: {action.Type}][redeem: {message.Reward.Title}][redeem id: {message.Reward.Id}][transaction: {message.Id}]");
|
_logger.Error(ex, $"Failed to execute redeemable action [action: {action.Name}][action type: {action.Type}][redeem: {message.Reward.Title}][redeem id: {message.Reward.Id}][transaction: {message.Id}]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
@ -28,7 +28,7 @@ namespace TwitchChatTTS.Twitch.Socket.Handlers
|
|||||||
var actions = _redemptionManager.Get("follow");
|
var actions = _redemptionManager.Get("follow");
|
||||||
if (!actions.Any())
|
if (!actions.Any())
|
||||||
{
|
{
|
||||||
_logger.Debug($"No redemable actions for follow was found");
|
_logger.Debug($"No redeemable actions for follow was found");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_logger.Debug($"Found {actions.Count} actions for this Twitch follow");
|
_logger.Debug($"Found {actions.Count} actions for this Twitch follow");
|
||||||
@ -40,7 +40,7 @@ namespace TwitchChatTTS.Twitch.Socket.Handlers
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.Error(ex, $"Failed to execute redeeemable action [action: {action.Name}][action type: {action.Type}][redeem: follow]");
|
_logger.Error(ex, $"Failed to execute redeemable action [action: {action.Name}][action type: {action.Type}][redeem: follow]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
@ -28,7 +28,7 @@ namespace TwitchChatTTS.Twitch.Socket.Handlers
|
|||||||
var actions = _redemptionManager.Get("subscription");
|
var actions = _redemptionManager.Get("subscription");
|
||||||
if (!actions.Any())
|
if (!actions.Any())
|
||||||
{
|
{
|
||||||
_logger.Debug($"No redemable actions for this subscription was found [message: {message.Message.Text}]");
|
_logger.Debug($"No redeemable actions for this subscription was found [message: {message.Message.Text}]");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_logger.Debug($"Found {actions.Count} actions for this Twitch subscription [message: {message.Message.Text}]");
|
_logger.Debug($"Found {actions.Count} actions for this Twitch subscription [message: {message.Message.Text}]");
|
||||||
@ -40,7 +40,7 @@ namespace TwitchChatTTS.Twitch.Socket.Handlers
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.Error(ex, $"Failed to execute redeeemable action [action: {action.Name}][action type: {action.Type}][redeem: subscription][message: {message.Message.Text}]");
|
_logger.Error(ex, $"Failed to execute redeemable action [action: {action.Name}][action type: {action.Type}][redeem: resubscription][message: {message.Message.Text}]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
@ -28,7 +28,7 @@ namespace TwitchChatTTS.Twitch.Socket.Handlers
|
|||||||
var actions = _redemptionManager.Get("subscription.gift");
|
var actions = _redemptionManager.Get("subscription.gift");
|
||||||
if (!actions.Any())
|
if (!actions.Any())
|
||||||
{
|
{
|
||||||
_logger.Debug($"No redemable actions for this gifted subscription was found");
|
_logger.Debug($"No redeemable actions for this gifted subscription was found");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_logger.Debug($"Found {actions.Count} actions for this Twitch gifted subscription [gifted: {message.UserLogin}][gifted id: {message.UserId}][Anonymous: {message.IsAnonymous}][cumulative: {message.CumulativeTotal ?? -1}]");
|
_logger.Debug($"Found {actions.Count} actions for this Twitch gifted subscription [gifted: {message.UserLogin}][gifted id: {message.UserId}][Anonymous: {message.IsAnonymous}][cumulative: {message.CumulativeTotal ?? -1}]");
|
||||||
@ -40,7 +40,7 @@ namespace TwitchChatTTS.Twitch.Socket.Handlers
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.Error(ex, $"Failed to execute redeeemable action [action: {action.Name}][action type: {action.Type}][redeem: gifted subscription]");
|
_logger.Error(ex, $"Failed to execute redeemable action [action: {action.Name}][action type: {action.Type}][redeem: gifted subscription]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
@ -6,7 +6,7 @@ namespace TwitchChatTTS.Twitch.Socket.Handlers
|
|||||||
{
|
{
|
||||||
public class ChannelSubscriptionHandler : ITwitchSocketHandler
|
public class ChannelSubscriptionHandler : ITwitchSocketHandler
|
||||||
{
|
{
|
||||||
public string Name => "channel.subscription";
|
public string Name => "channel.subscribe";
|
||||||
|
|
||||||
private readonly IRedemptionManager _redemptionManager;
|
private readonly IRedemptionManager _redemptionManager;
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
@ -30,7 +30,7 @@ namespace TwitchChatTTS.Twitch.Socket.Handlers
|
|||||||
var actions = _redemptionManager.Get("subscription");
|
var actions = _redemptionManager.Get("subscription");
|
||||||
if (!actions.Any())
|
if (!actions.Any())
|
||||||
{
|
{
|
||||||
_logger.Debug($"No redemable actions for this subscription was found [subscriber: {message.UserLogin}][subscriber id: {message.UserId}]");
|
_logger.Debug($"No redeemable actions for this subscription was found [subscriber: {message.UserLogin}][subscriber id: {message.UserId}]");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_logger.Debug($"Found {actions.Count} actions for this Twitch subscription [subscriber: {message.UserLogin}][subscriber id: {message.UserId}]");
|
_logger.Debug($"Found {actions.Count} actions for this Twitch subscription [subscriber: {message.UserLogin}][subscriber id: {message.UserId}]");
|
||||||
@ -42,7 +42,7 @@ namespace TwitchChatTTS.Twitch.Socket.Handlers
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.Error(ex, $"Failed to execute redeeemable action [action: {action.Name}][action type: {action.Type}][redeem: subscription][subscriber: {message.UserLogin}][subscriber id: {message.UserId}]");
|
_logger.Error(ex, $"Failed to execute redeemable action [action: {action.Name}][action type: {action.Type}][redeem: subscription][subscriber: {message.UserLogin}][subscriber id: {message.UserId}]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
@ -38,8 +38,8 @@ namespace TwitchChatTTS.Twitch.Socket.Handlers
|
|||||||
_messageTypes.Add("channel.chat.message_delete", typeof(ChannelChatDeleteMessage));
|
_messageTypes.Add("channel.chat.message_delete", typeof(ChannelChatDeleteMessage));
|
||||||
_messageTypes.Add("channel.channel_points_custom_reward_redemption.add", typeof(ChannelCustomRedemptionMessage));
|
_messageTypes.Add("channel.channel_points_custom_reward_redemption.add", typeof(ChannelCustomRedemptionMessage));
|
||||||
_messageTypes.Add("channel.follow", typeof(ChannelFollowMessage));
|
_messageTypes.Add("channel.follow", typeof(ChannelFollowMessage));
|
||||||
_messageTypes.Add("channel.resubscription", typeof(ChannelResubscriptionMessage));
|
_messageTypes.Add("channel.subscribe", typeof(ChannelSubscriptionMessage));
|
||||||
_messageTypes.Add("channel.subscription.message", typeof(ChannelSubscriptionMessage));
|
_messageTypes.Add("channel.subscription.message", typeof(ChannelResubscriptionMessage));
|
||||||
_messageTypes.Add("channel.subscription.gift", typeof(ChannelSubscriptionGiftMessage));
|
_messageTypes.Add("channel.subscription.gift", typeof(ChannelSubscriptionGiftMessage));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,10 +40,7 @@ namespace TwitchChatTTS.Twitch.Socket.Handlers
|
|||||||
|
|
||||||
var backup = _manager.GetBackupClient();
|
var backup = _manager.GetBackupClient();
|
||||||
var identified = _manager.GetWorkingClient();
|
var identified = _manager.GetWorkingClient();
|
||||||
if (identified != null && backup != identified)
|
_logger.Debug($"Reconnection received [receiver: {sender.UID}][main: {identified.UID}][backup: {backup.UID}]");
|
||||||
{
|
|
||||||
await identified.DisconnectAsync(new SocketDisconnectionEventArgs("Closed", "Reconnection from another client."));
|
|
||||||
}
|
|
||||||
|
|
||||||
backup.URL = message.Session.ReconnectUrl;
|
backup.URL = message.Session.ReconnectUrl;
|
||||||
await backup.Connect();
|
await backup.Connect();
|
||||||
|
@ -47,6 +47,8 @@ namespace TwitchChatTTS.Twitch.Socket.Handlers
|
|||||||
"channel.chat.clear",
|
"channel.chat.clear",
|
||||||
"channel.chat.clear_user_messages",
|
"channel.chat.clear_user_messages",
|
||||||
"channel.ad_break.begin",
|
"channel.ad_break.begin",
|
||||||
|
"channel.subscribe",
|
||||||
|
"channel.subscription.gift",
|
||||||
"channel.subscription.message",
|
"channel.subscription.message",
|
||||||
"channel.ban",
|
"channel.ban",
|
||||||
"channel.channel_points_custom_reward_redemption.add"
|
"channel.channel_points_custom_reward_redemption.add"
|
||||||
|
@ -71,7 +71,7 @@ namespace TwitchChatTTS.Twitch.Socket
|
|||||||
{
|
{
|
||||||
if (_identified == client)
|
if (_identified == client)
|
||||||
{
|
{
|
||||||
_logger.Error("Twitch client has been re-identified.");
|
_logger.Warning("Twitch client has been re-identified.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (_backup != client)
|
if (_backup != client)
|
||||||
@ -83,6 +83,7 @@ namespace TwitchChatTTS.Twitch.Socket
|
|||||||
|
|
||||||
if (_identified != null)
|
if (_identified != null)
|
||||||
{
|
{
|
||||||
|
_logger.Debug("Second Twitch client has been identified; hopefully a reconnection.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,10 +102,12 @@ namespace TwitchChatTTS.Twitch.Socket
|
|||||||
{
|
{
|
||||||
if (_identified == client)
|
if (_identified == client)
|
||||||
{
|
{
|
||||||
|
_logger.Debug("Identified Twitch client has disconnected.");
|
||||||
_identified = null;
|
_identified = null;
|
||||||
}
|
}
|
||||||
else if (_backup == client)
|
else if (_backup == client)
|
||||||
{
|
{
|
||||||
|
_logger.Debug("Backup Twitch client has disconnected.");
|
||||||
_backup = null;
|
_backup = null;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -22,6 +22,7 @@ namespace TwitchChatTTS.Twitch.Socket
|
|||||||
|
|
||||||
public event EventHandler<EventArgs> OnIdentified;
|
public event EventHandler<EventArgs> OnIdentified;
|
||||||
|
|
||||||
|
public string UID { get; }
|
||||||
public string URL;
|
public string URL;
|
||||||
public bool Connected { get; private set; }
|
public bool Connected { get; private set; }
|
||||||
public bool Identified { get; private set; }
|
public bool Identified { get; private set; }
|
||||||
@ -50,6 +51,7 @@ namespace TwitchChatTTS.Twitch.Socket
|
|||||||
_messageTypes.Add("session_reconnect", typeof(SessionWelcomeMessage));
|
_messageTypes.Add("session_reconnect", typeof(SessionWelcomeMessage));
|
||||||
_messageTypes.Add("notification", typeof(NotificationMessage));
|
_messageTypes.Add("notification", typeof(NotificationMessage));
|
||||||
|
|
||||||
|
UID = Guid.NewGuid().ToString("D");
|
||||||
URL = "wss://eventsub.wss.twitch.tv/ws";
|
URL = "wss://eventsub.wss.twitch.tv/ws";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user