Add message_text temp var for subscription message event

The existing "message" temp var for the subscription message event
contained a raw JSON object (including emote metadata) rather than
plain text, making it difficult to use.
This commit is contained in:
WarmUpTill 2026-06-22 20:00:31 +02:00
parent 718cd1866c
commit fcd94bf197
3 changed files with 23 additions and 3 deletions

View File

@ -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"

View File

@ -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");

View File

@ -114,6 +114,7 @@ public:
private:
bool CheckChannelGenericEvents();
bool CheckChannelLiveEvents();
bool CheckChannelSubscriptionMessageEvent();
bool CheckChannelRewardChangeEvents();
bool CheckChannelRewardRedemptionEvents();
bool HandleMatchingSubscriptionEvents(