diff --git a/data/locale/en-US.ini b/data/locale/en-US.ini index ace9b40d..740f7f83 100644 --- a/data/locale/en-US.ini +++ b/data/locale/en-US.ini @@ -1892,8 +1892,10 @@ AdvSceneSwitcher.tempVar.twitch.user_login.subscribe.message="Subscriber Twitch AdvSceneSwitcher.tempVar.twitch.user_login.subscribe.message.description="The user login of the user who sent a resubscription chat message." AdvSceneSwitcher.tempVar.twitch.user_name.subscribe.message="Subscriber Twitch user name" AdvSceneSwitcher.tempVar.twitch.user_name.subscribe.message.description="The user display name of the user who a resubscription chat message." -AdvSceneSwitcher.tempVar.twitch.message.subscribe="Subscription message" -AdvSceneSwitcher.tempVar.twitch.message.subscribe.description="An object that contains the resubscription message and emote information needed to recreate the message." +AdvSceneSwitcher.tempVar.twitch.message.subscribe="Subscription message (JSON)" +AdvSceneSwitcher.tempVar.twitch.message.subscribe.description="A JSON object containing the resubscription message text and emote information. Use 'Subscription message text' to get the plain text." +AdvSceneSwitcher.tempVar.twitch.message_text.subscribe="Subscription message text" +AdvSceneSwitcher.tempVar.twitch.message_text.subscribe.description="The plain text of the resubscription message, with emotes replaced by their names." AdvSceneSwitcher.tempVar.twitch.cumulative_months.subscribe="Number of months subscribed" AdvSceneSwitcher.tempVar.twitch.cumulative_months.subscribe.description="The total number of months the user has been subscribed to the channel." AdvSceneSwitcher.tempVar.twitch.streak_months.subscribe="Subscription streak" diff --git a/plugins/twitch/macro-condition-twitch.cpp b/plugins/twitch/macro-condition-twitch.cpp index 4fcf3c2c..d1fc1d9f 100644 --- a/plugins/twitch/macro-condition-twitch.cpp +++ b/plugins/twitch/macro-condition-twitch.cpp @@ -317,6 +317,21 @@ bool MacroConditionTwitch::CheckChannelLiveEvents() return false; } +bool MacroConditionTwitch::CheckChannelSubscriptionMessageEvent() +{ + return HandleMatchingSubscriptionEvents([this](const Event &event) { + SetVariableValue(event.ToString()); + SetJsonTempVars(event.data, + [this](const char *id, const char *value) { + SetTempVarValue(id, value); + }); + OBSDataAutoRelease message = + obs_data_get_obj(event.data, "message"); + SetTempVarValue("message_text", + obs_data_get_string(message, "text")); + }); +} + bool MacroConditionTwitch::CheckChannelRewardChangeEvents() { return HandleMatchingSubscriptionEvents([this](const Event &event) { @@ -689,7 +704,6 @@ bool MacroConditionTwitch::CheckCondition() case Condition::SUBSCRIPTION_START_EVENT: case Condition::SUBSCRIPTION_END_EVENT: case Condition::SUBSCRIPTION_GIFT_EVENT: - case Condition::SUBSCRIPTION_MESSAGE_EVENT: case Condition::CHEER_EVENT: case Condition::RAID_OUTBOUND_EVENT: case Condition::RAID_INBOUND_EVENT: @@ -720,6 +734,8 @@ bool MacroConditionTwitch::CheckCondition() case Condition::USER_MODERATOR_ADDITION_EVENT: case Condition::USER_MODERATOR_DELETION_EVENT: return CheckChannelGenericEvents(); + case Condition::SUBSCRIPTION_MESSAGE_EVENT: + return CheckChannelSubscriptionMessageEvent(); case Condition::POINTS_REWARD_ADDITION_EVENT: case Condition::POINTS_REWARD_UPDATE_EVENT: case Condition::POINTS_REWARD_DELETION_EVENT: @@ -1207,6 +1223,7 @@ void MacroConditionTwitch::SetupTempVars() setupTempVarHelper("user_name", ".subscribe.message"); setupTempVarHelper("tier", ".subscribe"); setupTempVarHelper("message", ".subscribe"); + setupTempVarHelper("message_text", ".subscribe"); setupTempVarHelper("cumulative_months", ".subscribe"); setupTempVarHelper("streak_months", ".subscribe"); setupTempVarHelper("duration_months", ".subscribe"); diff --git a/plugins/twitch/macro-condition-twitch.hpp b/plugins/twitch/macro-condition-twitch.hpp index 519b1d89..f2bf3e05 100644 --- a/plugins/twitch/macro-condition-twitch.hpp +++ b/plugins/twitch/macro-condition-twitch.hpp @@ -114,6 +114,7 @@ public: private: bool CheckChannelGenericEvents(); bool CheckChannelLiveEvents(); + bool CheckChannelSubscriptionMessageEvent(); bool CheckChannelRewardChangeEvents(); bool CheckChannelRewardRedemptionEvents(); bool HandleMatchingSubscriptionEvents(