Fixed Twitch subscriptions. Fixed typos. Fixed Twitch websocket reconnection.

This commit is contained in:
Tom 2024-08-06 21:15:05 +00:00
parent eb8bfdf6b0
commit 8a0e55bb95
11 changed files with 24 additions and 20 deletions

View File

@ -33,7 +33,7 @@ namespace TwitchChatTTS.Twitch.Socket.Handlers
var actions = _redemptionManager.Get("adbreak");
if (!actions.Any())
{
_logger.Debug($"No redemable actions for ad break was found");
_logger.Debug($"No redeemable actions for ad break was found");
return;
}
_logger.Debug($"Found {actions.Count} actions for this Twitch ad break");
@ -45,7 +45,7 @@ namespace TwitchChatTTS.Twitch.Socket.Handlers
}
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)

View File

@ -32,7 +32,7 @@ namespace TwitchChatTTS.Twitch.Socket.Handlers
var actions = _redemptionManager.Get(message.Reward.Id);
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;
}
_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)
{
_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)

View File

@ -28,7 +28,7 @@ namespace TwitchChatTTS.Twitch.Socket.Handlers
var actions = _redemptionManager.Get("follow");
if (!actions.Any())
{
_logger.Debug($"No redemable actions for follow was found");
_logger.Debug($"No redeemable actions for follow was found");
return;
}
_logger.Debug($"Found {actions.Count} actions for this Twitch follow");
@ -40,7 +40,7 @@ namespace TwitchChatTTS.Twitch.Socket.Handlers
}
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)

View File

@ -28,7 +28,7 @@ namespace TwitchChatTTS.Twitch.Socket.Handlers
var actions = _redemptionManager.Get("subscription");
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;
}
_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)
{
_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)

View File

@ -28,7 +28,7 @@ namespace TwitchChatTTS.Twitch.Socket.Handlers
var actions = _redemptionManager.Get("subscription.gift");
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;
}
_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)
{
_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)

View File

@ -6,7 +6,7 @@ namespace TwitchChatTTS.Twitch.Socket.Handlers
{
public class ChannelSubscriptionHandler : ITwitchSocketHandler
{
public string Name => "channel.subscription";
public string Name => "channel.subscribe";
private readonly IRedemptionManager _redemptionManager;
private readonly ILogger _logger;
@ -30,7 +30,7 @@ namespace TwitchChatTTS.Twitch.Socket.Handlers
var actions = _redemptionManager.Get("subscription");
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;
}
_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)
{
_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)

View File

@ -38,8 +38,8 @@ namespace TwitchChatTTS.Twitch.Socket.Handlers
_messageTypes.Add("channel.chat.message_delete", typeof(ChannelChatDeleteMessage));
_messageTypes.Add("channel.channel_points_custom_reward_redemption.add", typeof(ChannelCustomRedemptionMessage));
_messageTypes.Add("channel.follow", typeof(ChannelFollowMessage));
_messageTypes.Add("channel.resubscription", typeof(ChannelResubscriptionMessage));
_messageTypes.Add("channel.subscription.message", typeof(ChannelSubscriptionMessage));
_messageTypes.Add("channel.subscribe", typeof(ChannelSubscriptionMessage));
_messageTypes.Add("channel.subscription.message", typeof(ChannelResubscriptionMessage));
_messageTypes.Add("channel.subscription.gift", typeof(ChannelSubscriptionGiftMessage));
}

View File

@ -40,10 +40,7 @@ namespace TwitchChatTTS.Twitch.Socket.Handlers
var backup = _manager.GetBackupClient();
var identified = _manager.GetWorkingClient();
if (identified != null && backup != identified)
{
await identified.DisconnectAsync(new SocketDisconnectionEventArgs("Closed", "Reconnection from another client."));
}
_logger.Debug($"Reconnection received [receiver: {sender.UID}][main: {identified.UID}][backup: {backup.UID}]");
backup.URL = message.Session.ReconnectUrl;
await backup.Connect();

View File

@ -47,6 +47,8 @@ namespace TwitchChatTTS.Twitch.Socket.Handlers
"channel.chat.clear",
"channel.chat.clear_user_messages",
"channel.ad_break.begin",
"channel.subscribe",
"channel.subscription.gift",
"channel.subscription.message",
"channel.ban",
"channel.channel_points_custom_reward_redemption.add"

View File

@ -71,7 +71,7 @@ namespace TwitchChatTTS.Twitch.Socket
{
if (_identified == client)
{
_logger.Error("Twitch client has been re-identified.");
_logger.Warning("Twitch client has been re-identified.");
return;
}
if (_backup != client)
@ -83,6 +83,7 @@ namespace TwitchChatTTS.Twitch.Socket
if (_identified != null)
{
_logger.Debug("Second Twitch client has been identified; hopefully a reconnection.");
return;
}
@ -101,10 +102,12 @@ namespace TwitchChatTTS.Twitch.Socket
{
if (_identified == client)
{
_logger.Debug("Identified Twitch client has disconnected.");
_identified = null;
}
else if (_backup == client)
{
_logger.Debug("Backup Twitch client has disconnected.");
_backup = null;
}
else

View File

@ -22,6 +22,7 @@ namespace TwitchChatTTS.Twitch.Socket
public event EventHandler<EventArgs> OnIdentified;
public string UID { get; }
public string URL;
public bool Connected { 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("notification", typeof(NotificationMessage));
UID = Guid.NewGuid().ToString("D");
URL = "wss://eventsub.wss.twitch.tv/ws";
}