feat: Add Live Emote Updates for BTTV (#4147)

This feature is enabled by default and can be disabled in settings with the "Enable BTTV live emotes updates" setting.

Co-authored-by: Felanbird <41973452+Felanbird@users.noreply.github.com>
Co-authored-by: pajlada <rasmus.karlsson@pajlada.com>
This commit is contained in:
nerix
2023-01-21 15:06:55 +01:00
committed by GitHub
parent 56f7c91a64
commit 904749cf62
22 changed files with 856 additions and 33 deletions
+47
View File
@@ -14,6 +14,7 @@
#include "debug/AssertInGuiThread.hpp"
#include "messages/Message.hpp"
#include "messages/MessageBuilder.hpp"
#include "providers/bttv/BttvLiveUpdates.hpp"
#include "providers/chatterino/ChatterinoBadges.hpp"
#include "providers/ffz/FfzBadges.hpp"
#include "providers/irc/Irc2.hpp"
@@ -156,6 +157,7 @@ void Application::initialize(Settings &settings, Paths &paths)
}
this->initPubSub();
this->initBttvLiveUpdates();
this->initSeventvEventAPI();
}
@@ -576,6 +578,51 @@ void Application::initPubSub()
RequestModerationActions();
}
void Application::initBttvLiveUpdates()
{
if (!this->twitch->bttvLiveUpdates)
{
qCDebug(chatterinoBttv)
<< "Skipping initialization of Live Updates as it's disabled";
return;
}
this->twitch->bttvLiveUpdates->signals_.emoteAdded.connect(
[&](const auto &data) {
auto chan = this->twitch->getChannelOrEmptyByID(data.channelID);
postToThread([chan, data] {
if (auto *channel = dynamic_cast<TwitchChannel *>(chan.get()))
{
channel->addBttvEmote(data);
}
});
});
this->twitch->bttvLiveUpdates->signals_.emoteUpdated.connect(
[&](const auto &data) {
auto chan = this->twitch->getChannelOrEmptyByID(data.channelID);
postToThread([chan, data] {
if (auto *channel = dynamic_cast<TwitchChannel *>(chan.get()))
{
channel->updateBttvEmote(data);
}
});
});
this->twitch->bttvLiveUpdates->signals_.emoteRemoved.connect(
[&](const auto &data) {
auto chan = this->twitch->getChannelOrEmptyByID(data.channelID);
postToThread([chan, data] {
if (auto *channel = dynamic_cast<TwitchChannel *>(chan.get()))
{
channel->removeBttvEmote(data);
}
});
});
this->twitch->bttvLiveUpdates->start();
}
void Application::initSeventvEventAPI()
{
if (!this->twitch->seventvEventAPI)