Add support for non-highlight channel point rewards (#1809)

This commit is contained in:
Jonas Schmitt
2020-08-08 15:37:22 +02:00
committed by GitHub
parent 1bd3d10eef
commit 11b8948290
23 changed files with 498 additions and 25 deletions
+45
View File
@@ -235,6 +235,50 @@ void TwitchChannel::refreshFFZChannelEmotes(bool manualRefresh)
manualRefresh);
}
void TwitchChannel::addChannelPointReward(const ChannelPointReward &reward)
{
if (!reward.hasParsedSuccessfully)
{
return;
}
if (!reward.isUserInputRequired)
{
MessageBuilder builder;
TwitchMessageBuilder::appendChannelPointRewardMessage(reward, &builder);
this->addMessage(builder.release());
return;
}
bool result;
{
auto channelPointRewards = this->channelPointRewards_.access();
result = channelPointRewards->try_emplace(reward.id, reward).second;
}
if (result)
{
this->channelPointRewardAdded.invoke(reward);
}
}
bool TwitchChannel::isChannelPointRewardKnown(const QString &rewardId)
{
const auto &pointRewards = this->channelPointRewards_.accessConst();
const auto &it = pointRewards->find(rewardId);
return it != pointRewards->end();
}
boost::optional<ChannelPointReward> TwitchChannel::channelPointReward(
const QString &rewardId) const
{
auto rewards = this->channelPointRewards_.accessConst();
auto it = rewards->find(rewardId);
if (it == rewards->end())
return boost::none;
return it->second;
}
void TwitchChannel::sendMessage(const QString &message)
{
auto app = getApp();
@@ -660,6 +704,7 @@ void TwitchChannel::refreshPubsub()
auto account = getApp()->accounts->twitch.getCurrent();
getApp()->twitch2->pubsub->listenToChannelModerationActions(roomId,
account);
getApp()->twitch2->pubsub->listenToChannelPointRewards(roomId, account);
}
void TwitchChannel::refreshChatters()