Show exact months subscribed in Subscriber and Founder badge tooltip (#1424)

This commit is contained in:
apa420 2019-12-01 11:20:56 +01:00 committed by pajlada
parent d99102cd23
commit c00f97ac53

View file

@ -1251,14 +1251,59 @@ void TwitchMessageBuilder::appendTwitchBadges()
break; break;
} }
} }
else if (badge.startsWith("founder/"))
{
if (auto badgeEmote =
this->twitchChannel->globalTwitchBadges().badge("founder",
"0"))
{
auto badgeInfo = this->tags.find("badge-info");
if (badgeInfo != this->tags.end() &&
badgeInfo.value().toString().split(',')[0].startsWith(
"founder/"))
{
auto subMonths =
badgeInfo.value().toString().split(',')[0].mid(8);
this->emplace<BadgeElement>(
badgeEmote.get(),
MessageElementFlag::BadgeSubscription)
->setTooltip(QString((*badgeEmote)->tooltip.string) +
" (" + subMonths + " months)");
}
else
{
this->emplace<BadgeElement>(
badgeEmote.get(),
MessageElementFlag::BadgeSubscription)
->setTooltip((*badgeEmote)->tooltip.string);
}
}
}
else if (badge.startsWith("subscriber/")) else if (badge.startsWith("subscriber/"))
{ {
if (auto badgeEmote = this->twitchChannel->twitchBadge( if (auto badgeEmote = this->twitchChannel->twitchBadge(
"subscriber", badge.mid(11))) "subscriber", badge.mid(11)))
{ {
auto badgeInfo = this->tags.find("badge-info");
if (badgeInfo != this->tags.end() &&
badgeInfo.value().toString().split(',')[0].startsWith(
"subscriber/"))
{
auto subMonths =
badgeInfo.value().toString().split(',')[0].mid(11);
this->emplace<BadgeElement>( this->emplace<BadgeElement>(
badgeEmote.get(), MessageElementFlag::BadgeSubscription) badgeEmote.get(),
MessageElementFlag::BadgeSubscription)
->setTooltip(QString((*badgeEmote)->tooltip.string) +
" (" + subMonths + " months)");
}
else
{
this->emplace<BadgeElement>(
badgeEmote.get(),
MessageElementFlag::BadgeSubscription)
->setTooltip((*badgeEmote)->tooltip.string); ->setTooltip((*badgeEmote)->tooltip.string);
}
continue; continue;
} }
@ -1292,7 +1337,7 @@ void TwitchMessageBuilder::appendTwitchBadges()
} }
} }
} }
} } // namespace chatterino
void TwitchMessageBuilder::appendChatterinoBadges() void TwitchMessageBuilder::appendChatterinoBadges()
{ {