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
+57
View File
@@ -0,0 +1,57 @@
#pragma once
#include "providers/bttv/liveupdates/BttvLiveUpdateMessages.hpp"
#include "providers/bttv/liveupdates/BttvLiveUpdateSubscription.hpp"
#include "providers/liveupdates/BasicPubSubManager.hpp"
#include "util/QStringHash.hpp"
#include <pajlada/signals/signal.hpp>
#include <unordered_set>
namespace chatterino {
class BttvLiveUpdates : public BasicPubSubManager<BttvLiveUpdateSubscription>
{
template <typename T>
using Signal =
pajlada::Signals::Signal<T>; // type-id is vector<T, Alloc<T>>
public:
BttvLiveUpdates(QString host);
struct {
Signal<BttvLiveUpdateEmoteUpdateAddMessage> emoteAdded;
Signal<BttvLiveUpdateEmoteUpdateAddMessage> emoteUpdated;
Signal<BttvLiveUpdateEmoteRemoveMessage> emoteRemoved;
} signals_; // NOLINT(readability-identifier-naming)
/**
* Joins a Twitch channel by its id (without any prefix like 'twitch:')
* if it's not already joined.
*
* @param channelID the Twitch channel-id of the broadcaster.
* @param userName the Twitch username of the current user.
*/
void joinChannel(const QString &channelID, const QString &userName);
/**
* Parts a twitch channel by its id (without any prefix like 'twitch:')
* if it's joined.
*
* @param id the Twitch channel-id of the broadcaster.
*/
void partChannel(const QString &id);
protected:
void onMessage(
websocketpp::connection_hdl hdl,
BasicPubSubManager<BttvLiveUpdateSubscription>::WebsocketMessagePtr msg)
override;
private:
// Contains all joined Twitch channel-ids
std::unordered_set<QString> joinedChannels_;
};
} // namespace chatterino