Added chat message to redemptions. Added Subscription End to Twitch. Added more variables to certain redemptions.
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
using HermesSocketLibrary.Requests.Messages;
|
||||
using TwitchChatTTS.Twitch.Socket.Messages;
|
||||
|
||||
namespace TwitchChatTTS.Twitch.Redemptions
|
||||
{
|
||||
@ -6,7 +7,7 @@ namespace TwitchChatTTS.Twitch.Redemptions
|
||||
{
|
||||
void Add(RedeemableAction action);
|
||||
void Add(Redemption redemption);
|
||||
Task Execute(RedeemableAction action, string senderDisplayName, long senderId);
|
||||
Task Execute(RedeemableAction action, string senderDisplayName, long senderId, string senderMessage);
|
||||
IEnumerable<RedeemableAction> Get(string twitchRedemptionId);
|
||||
void Initialize();
|
||||
bool RemoveAction(string actionName);
|
||||
|
@ -166,7 +166,7 @@ namespace TwitchChatTTS.Twitch.Redemptions
|
||||
_logger.Debug($"Added redemption action [redemption id: {item.Id}][twitch redemption id: {twitchRedemptionId}]");
|
||||
}
|
||||
|
||||
public async Task Execute(RedeemableAction action, string senderDisplayName, long senderId)
|
||||
public async Task Execute(RedeemableAction action, string senderDisplayName, long senderId, string senderMessage)
|
||||
{
|
||||
_logger.Debug($"Executing an action for a redemption [action: {action.Name}][action type: {action.Type}][chatter: {senderDisplayName}][chatter id: {senderId}]");
|
||||
|
||||
@ -190,7 +190,7 @@ namespace TwitchChatTTS.Twitch.Redemptions
|
||||
if (!string.IsNullOrWhiteSpace(directory))
|
||||
Directory.CreateDirectory(directory);
|
||||
|
||||
await File.WriteAllTextAsync(path, ReplaceContentText(action.Data["file_content"], senderDisplayName));
|
||||
await File.WriteAllTextAsync(path, ReplaceContentText(action.Data["file_content"], senderDisplayName, senderId, senderMessage));
|
||||
_logger.Debug($"Overwritten text to file [file: {action.Data["file_path"]}][chatter: {senderDisplayName}][chatter id: {senderId}]");
|
||||
break;
|
||||
}
|
||||
@ -204,7 +204,7 @@ namespace TwitchChatTTS.Twitch.Redemptions
|
||||
if (!string.IsNullOrWhiteSpace(directory))
|
||||
Directory.CreateDirectory(directory);
|
||||
|
||||
await File.AppendAllTextAsync(path, ReplaceContentText(action.Data["file_content"], senderDisplayName));
|
||||
await File.AppendAllTextAsync(path, ReplaceContentText(action.Data["file_content"], senderDisplayName, senderId, senderMessage));
|
||||
_logger.Debug($"Appended text to file [file: {action.Data["file_path"]}][chatter: {senderDisplayName}][chatter id: {senderId}]");
|
||||
break;
|
||||
}
|
||||
@ -462,9 +462,14 @@ namespace TwitchChatTTS.Twitch.Redemptions
|
||||
return false;
|
||||
}
|
||||
|
||||
private string ReplaceContentText(string content, string username)
|
||||
private string ReplaceContentText(string content, string chatter, long chatterId, string message)
|
||||
{
|
||||
return content.Replace("%USER%", username)
|
||||
return content.Replace("%USER%", chatter)
|
||||
.Replace("%chatter%", chatter)
|
||||
.Replace("%chatterid%", chatterId.ToString())
|
||||
.Replace("%broadcaster%", _user.TwitchUsername)
|
||||
.Replace("%broadcasterid%", _user.TwitchUserId.ToString())
|
||||
.Replace("%message%", message)
|
||||
.Replace("\\n", "\n");
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user