Added support for Twitch's Chat Replies (#3722)

Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
This commit is contained in:
Daniel Sage
2022-07-31 06:45:25 -04:00
committed by GitHub
parent a280089693
commit 20c974fdab
53 changed files with 2022 additions and 310 deletions
+22 -3
View File
@@ -1,5 +1,6 @@
#pragma once
#include "Application.hpp"
#include "common/Aliases.hpp"
#include "common/Atomic.hpp"
#include "common/Channel.hpp"
@@ -7,6 +8,7 @@
#include "common/ChatterSet.hpp"
#include "common/Outcome.hpp"
#include "common/UniqueAccess.hpp"
#include "messages/MessageThread.hpp"
#include "providers/twitch/ChannelPointReward.hpp"
#include "providers/twitch/TwitchEmotes.hpp"
#include "providers/twitch/api/Helix.hpp"
@@ -74,12 +76,15 @@ public:
int slowMode = 0;
};
explicit TwitchChannel(const QString &channelName);
void initialize();
// Channel methods
virtual bool isEmpty() const override;
virtual bool canSendMessage() const override;
virtual void sendMessage(const QString &message) override;
virtual void sendReply(const QString &message, const QString &replyId);
virtual bool isMod() const override;
bool isVip() const;
bool isStaff() const;
@@ -118,6 +123,17 @@ public:
// Cheers
boost::optional<CheerEmote> cheerEmote(const QString &string);
// Replies
/**
* Stores the given thread in this channel.
*
* Note: This method not take ownership of the MessageThread; this
* TwitchChannel instance will store a weak_ptr to the thread.
*/
void addReplyThread(const std::shared_ptr<MessageThread> &thread);
const std::unordered_map<QString, std::weak_ptr<MessageThread>> &threads()
const;
// Signals
pajlada::Signals::NoArgSignal roomIdChanged;
pajlada::Signals::NoArgSignal userStateChanged;
@@ -138,9 +154,6 @@ private:
QString localizedName;
} nameOptions;
protected:
explicit TwitchChannel(const QString &channelName);
private:
// Methods
void refreshLiveStatus();
@@ -151,6 +164,8 @@ private:
void refreshCheerEmotes();
void loadRecentMessages();
void fetchDisplayName();
void cleanUpReplyThreads();
void showLoginMessage();
void setLive(bool newLiveStatus);
void setMod(bool value);
@@ -164,6 +179,8 @@ private:
const QString &getDisplayName() const override;
const QString &getLocalizedName() const override;
QString prepareMessage(const QString &message) const;
// Data
const QString subscriptionUrl_;
const QString channelUrl_;
@@ -171,6 +188,7 @@ private:
int chatterCount_;
UniqueAccess<StreamStatus> streamStatus_;
UniqueAccess<RoomModes> roomModes_;
std::unordered_map<QString, std::weak_ptr<MessageThread>> threads_;
protected:
Atomic<std::shared_ptr<const EmoteMap>> bttvEmotes_;
@@ -194,6 +212,7 @@ private:
QString lastSentMessage_;
QObject lifetimeGuard_;
QTimer chattersListTimer_;
QTimer threadClearTimer_;
QElapsedTimer titleRefreshedTimer_;
QElapsedTimer clipCreationTimer_;
bool isClipCreationInProgress{false};