Renamed private members
This commit is contained in:
@@ -85,7 +85,7 @@ void BTTVEmotes::loadChannelEmotes(const QString &channelName, std::weak_ptr<Emo
|
||||
QString code = emoteObject.value("code").toString();
|
||||
// emoteObject.value("imageType").toString();
|
||||
|
||||
auto emote = this->channelEmoteCache.getOrAdd(id, [&] {
|
||||
auto emote = this->channelEmoteCache_.getOrAdd(id, [&] {
|
||||
EmoteData emoteData;
|
||||
QString link = linkTemplate;
|
||||
link.detach();
|
||||
|
||||
@@ -21,7 +21,7 @@ public:
|
||||
void loadChannelEmotes(const QString &channelName, std::weak_ptr<EmoteMap> channelEmoteMap);
|
||||
|
||||
private:
|
||||
EmoteMap channelEmoteCache;
|
||||
EmoteMap channelEmoteCache_;
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
||||
@@ -121,11 +121,11 @@ void Emojis::loadEmojis()
|
||||
parseEmoji(emojiData, unparsedEmoji);
|
||||
|
||||
for (const auto &shortCode : emojiData->shortCodes) {
|
||||
this->emojiShortCodeToEmoji.insert(shortCode, emojiData);
|
||||
this->emojiShortCodeToEmoji_.insert(shortCode, emojiData);
|
||||
this->shortCodes.emplace_back(shortCode);
|
||||
}
|
||||
|
||||
this->emojiFirstByte[emojiData->value.at(0)].append(emojiData);
|
||||
this->emojiFirstByte_[emojiData->value.at(0)].append(emojiData);
|
||||
|
||||
this->emojis.insert(emojiData->unifiedCode, emojiData);
|
||||
|
||||
@@ -145,11 +145,11 @@ void Emojis::loadEmojis()
|
||||
parseEmoji(variationEmojiData, variation,
|
||||
emojiData->shortCodes[0] + "_" + toneNameIt->second);
|
||||
|
||||
this->emojiShortCodeToEmoji.insert(variationEmojiData->shortCodes[0],
|
||||
this->emojiShortCodeToEmoji_.insert(variationEmojiData->shortCodes[0],
|
||||
variationEmojiData);
|
||||
this->shortCodes.push_back(variationEmojiData->shortCodes[0]);
|
||||
|
||||
this->emojiFirstByte[variationEmojiData->value.at(0)].append(variationEmojiData);
|
||||
this->emojiFirstByte_[variationEmojiData->value.at(0)].append(variationEmojiData);
|
||||
|
||||
this->emojis.insert(variationEmojiData->unifiedCode, variationEmojiData);
|
||||
}
|
||||
@@ -179,8 +179,8 @@ void Emojis::loadEmojiOne2Capabilities()
|
||||
|
||||
QString shortCode = parts[0];
|
||||
|
||||
auto emojiIt = this->emojiShortCodeToEmoji.find(shortCode);
|
||||
if (emojiIt != this->emojiShortCodeToEmoji.end()) {
|
||||
auto emojiIt = this->emojiShortCodeToEmoji_.find(shortCode);
|
||||
if (emojiIt != this->emojiShortCodeToEmoji_.end()) {
|
||||
std::shared_ptr<EmojiData> emoji = *emojiIt;
|
||||
emoji->capabilities.insert("EmojiOne 2");
|
||||
continue;
|
||||
@@ -190,7 +190,7 @@ void Emojis::loadEmojiOne2Capabilities()
|
||||
|
||||
void Emojis::sortEmojis()
|
||||
{
|
||||
for (auto &p : this->emojiFirstByte) {
|
||||
for (auto &p : this->emojiFirstByte_) {
|
||||
std::stable_sort(p.begin(), p.end(), [](const auto &lhs, const auto &rhs) {
|
||||
return lhs->value.length() > rhs->value.length();
|
||||
});
|
||||
@@ -277,8 +277,8 @@ void Emojis::parse(std::vector<std::tuple<EmoteData, QString>> &parsedWords, con
|
||||
continue;
|
||||
}
|
||||
|
||||
auto it = this->emojiFirstByte.find(character);
|
||||
if (it == this->emojiFirstByte.end()) {
|
||||
auto it = this->emojiFirstByte_.find(character);
|
||||
if (it == this->emojiFirstByte_.end()) {
|
||||
// No emoji starts with this character
|
||||
continue;
|
||||
}
|
||||
@@ -348,7 +348,7 @@ void Emojis::parse(std::vector<std::tuple<EmoteData, QString>> &parsedWords, con
|
||||
QString Emojis::replaceShortCodes(const QString &text)
|
||||
{
|
||||
QString ret(text);
|
||||
auto it = this->findShortCodesRegex.globalMatch(text);
|
||||
auto it = this->findShortCodesRegex_.globalMatch(text);
|
||||
|
||||
int32_t offset = 0;
|
||||
|
||||
@@ -359,9 +359,9 @@ QString Emojis::replaceShortCodes(const QString &text)
|
||||
|
||||
QString matchString = capturedString.toLower().mid(1, capturedString.size() - 2);
|
||||
|
||||
auto emojiIt = this->emojiShortCodeToEmoji.constFind(matchString);
|
||||
auto emojiIt = this->emojiShortCodeToEmoji_.constFind(matchString);
|
||||
|
||||
if (emojiIt == this->emojiShortCodeToEmoji.constEnd()) {
|
||||
if (emojiIt == this->emojiShortCodeToEmoji_.constEnd()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -35,12 +35,12 @@ class Emojis
|
||||
{
|
||||
public:
|
||||
void initialize();
|
||||
void load();
|
||||
void parse(std::vector<std::tuple<EmoteData, QString>> &parsedWords, const QString &text);
|
||||
|
||||
EmojiMap emojis;
|
||||
|
||||
std::vector<QString> shortCodes;
|
||||
|
||||
void load();
|
||||
QString replaceShortCodes(const QString &text);
|
||||
|
||||
private:
|
||||
void loadEmojis();
|
||||
@@ -48,20 +48,14 @@ private:
|
||||
void sortEmojis();
|
||||
void loadEmojiSet();
|
||||
|
||||
public:
|
||||
QString replaceShortCodes(const QString &text);
|
||||
|
||||
void parse(std::vector<std::tuple<EmoteData, QString>> &parsedWords, const QString &text);
|
||||
|
||||
private:
|
||||
/// Emojis
|
||||
QRegularExpression findShortCodesRegex{":([-+\\w]+):"};
|
||||
QRegularExpression findShortCodesRegex_{":([-+\\w]+):"};
|
||||
|
||||
// shortCodeToEmoji maps strings like "sunglasses" to its emoji
|
||||
QMap<QString, std::shared_ptr<EmojiData>> emojiShortCodeToEmoji;
|
||||
QMap<QString, std::shared_ptr<EmojiData>> emojiShortCodeToEmoji_;
|
||||
|
||||
// Maps the first character of the emoji unicode string to a vector of possible emojis
|
||||
QMap<QChar, QVector<std::shared_ptr<EmojiData>>> emojiFirstByte;
|
||||
QMap<QChar, QVector<std::shared_ptr<EmojiData>>> emojiFirstByte_;
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
||||
@@ -112,7 +112,7 @@ void FFZEmotes::loadChannelEmotes(const QString &channelName, std::weak_ptr<Emot
|
||||
|
||||
QJsonObject urls = emoteObject.value("urls").toObject();
|
||||
|
||||
auto emote = this->channelEmoteCache.getOrAdd(id, [id, &code, &urls] {
|
||||
auto emote = this->channelEmoteCache_.getOrAdd(id, [id, &code, &urls] {
|
||||
EmoteData emoteData;
|
||||
fillInEmoteData(urls, code, code + "<br/>Channel FFZ Emote", emoteData);
|
||||
emoteData.pageLink =
|
||||
|
||||
@@ -21,7 +21,7 @@ public:
|
||||
void loadChannelEmotes(const QString &channelName, std::weak_ptr<EmoteMap> channelEmoteMap);
|
||||
|
||||
private:
|
||||
ConcurrentMap<int, EmoteData> channelEmoteCache;
|
||||
ConcurrentMap<int, EmoteData> channelEmoteCache_;
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
||||
@@ -8,23 +8,23 @@ struct EmoteValue {
|
||||
public:
|
||||
int getSet()
|
||||
{
|
||||
return _set;
|
||||
return set_;
|
||||
}
|
||||
|
||||
int getId()
|
||||
{
|
||||
return _id;
|
||||
return id_;
|
||||
}
|
||||
|
||||
const QString &getChannelName()
|
||||
{
|
||||
return _channelName;
|
||||
return channelName_;
|
||||
}
|
||||
|
||||
private:
|
||||
int _set;
|
||||
int _id;
|
||||
QString _channelName;
|
||||
int set_;
|
||||
int id_;
|
||||
QString channelName_;
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "providers/twitch/Pubsub.hpp"
|
||||
#include "providers/twitch/PubsubClient.hpp"
|
||||
|
||||
#include "debug/Log.hpp"
|
||||
#include "providers/twitch/PubsubActions.hpp"
|
||||
@@ -24,41 +24,41 @@ static std::map<QString, std::string> sentMessages;
|
||||
|
||||
namespace detail {
|
||||
|
||||
PubSubClient::PubSubClient(WebsocketClient &_websocketClient, WebsocketHandle _handle)
|
||||
: websocketClient(_websocketClient)
|
||||
, handle(_handle)
|
||||
PubSubClient::PubSubClient(WebsocketClient &websocketClient, WebsocketHandle handle)
|
||||
: websocketClient_(websocketClient)
|
||||
, handle_(handle)
|
||||
{
|
||||
}
|
||||
|
||||
void PubSubClient::start()
|
||||
{
|
||||
assert(!this->started);
|
||||
assert(!this->started_);
|
||||
|
||||
this->started = true;
|
||||
this->started_ = true;
|
||||
|
||||
this->ping();
|
||||
}
|
||||
|
||||
void PubSubClient::stop()
|
||||
{
|
||||
assert(this->started);
|
||||
assert(this->started_);
|
||||
|
||||
this->started = false;
|
||||
this->started_ = false;
|
||||
}
|
||||
|
||||
bool PubSubClient::listen(rapidjson::Document &message)
|
||||
{
|
||||
int numRequestedListens = message["data"]["topics"].Size();
|
||||
|
||||
if (this->numListens + numRequestedListens > MAX_PUBSUB_LISTENS) {
|
||||
if (this->numListens_ + numRequestedListens > MAX_PUBSUB_LISTENS) {
|
||||
// This PubSubClient is already at its peak listens
|
||||
return false;
|
||||
}
|
||||
|
||||
this->numListens += numRequestedListens;
|
||||
this->numListens_ += numRequestedListens;
|
||||
|
||||
for (const auto &topic : message["data"]["topics"].GetArray()) {
|
||||
this->listeners.emplace_back(Listener{topic.GetString(), false, false, false});
|
||||
this->listeners_.emplace_back(Listener{topic.GetString(), false, false, false});
|
||||
}
|
||||
|
||||
auto uuid = CreateUUID();
|
||||
@@ -77,11 +77,11 @@ void PubSubClient::unlistenPrefix(const std::string &prefix)
|
||||
{
|
||||
std::vector<std::string> topics;
|
||||
|
||||
for (auto it = this->listeners.begin(); it != this->listeners.end();) {
|
||||
for (auto it = this->listeners_.begin(); it != this->listeners_.end();) {
|
||||
const auto &listener = *it;
|
||||
if (listener.topic.find(prefix) == 0) {
|
||||
topics.push_back(listener.topic);
|
||||
it = this->listeners.erase(it);
|
||||
it = this->listeners_.erase(it);
|
||||
} else {
|
||||
++it;
|
||||
}
|
||||
@@ -105,16 +105,16 @@ void PubSubClient::unlistenPrefix(const std::string &prefix)
|
||||
|
||||
void PubSubClient::handlePong()
|
||||
{
|
||||
assert(this->awaitingPong);
|
||||
assert(this->awaitingPong_);
|
||||
|
||||
Log("Got pong!");
|
||||
|
||||
this->awaitingPong = false;
|
||||
this->awaitingPong_ = false;
|
||||
}
|
||||
|
||||
bool PubSubClient::isListeningToTopic(const std::string &payload)
|
||||
{
|
||||
for (const auto &listener : this->listeners) {
|
||||
for (const auto &listener : this->listeners_) {
|
||||
if (listener.topic == payload) {
|
||||
return true;
|
||||
}
|
||||
@@ -125,29 +125,29 @@ bool PubSubClient::isListeningToTopic(const std::string &payload)
|
||||
|
||||
void PubSubClient::ping()
|
||||
{
|
||||
assert(this->started);
|
||||
assert(this->started_);
|
||||
|
||||
if (!this->send(pingPayload)) {
|
||||
return;
|
||||
}
|
||||
|
||||
this->awaitingPong = true;
|
||||
this->awaitingPong_ = true;
|
||||
|
||||
auto self = this->shared_from_this();
|
||||
|
||||
runAfter(this->websocketClient.get_io_service(), std::chrono::seconds(15), [self](auto timer) {
|
||||
if (!self->started) {
|
||||
runAfter(this->websocketClient_.get_io_service(), std::chrono::seconds(15), [self](auto timer) {
|
||||
if (!self->started_) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (self->awaitingPong) {
|
||||
if (self->awaitingPong_) {
|
||||
Log("No pong respnose, disconnect!");
|
||||
// TODO(pajlada): Label this connection as "disconnect me"
|
||||
}
|
||||
});
|
||||
|
||||
runAfter(this->websocketClient.get_io_service(), std::chrono::minutes(5), [self](auto timer) {
|
||||
if (!self->started) {
|
||||
runAfter(this->websocketClient_.get_io_service(), std::chrono::minutes(5), [self](auto timer) {
|
||||
if (!self->started_) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -158,7 +158,7 @@ void PubSubClient::ping()
|
||||
bool PubSubClient::send(const char *payload)
|
||||
{
|
||||
WebsocketErrorCode ec;
|
||||
this->websocketClient.send(this->handle, payload, websocketpp::frame::opcode::text, ec);
|
||||
this->websocketClient_.send(this->handle_, payload, websocketpp::frame::opcode::text, ec);
|
||||
|
||||
if (ec) {
|
||||
Log("Error sending message {}: {}", payload, ec.message());
|
||||
@@ -40,15 +40,6 @@ struct Listener {
|
||||
|
||||
class PubSubClient : public std::enable_shared_from_this<PubSubClient>
|
||||
{
|
||||
WebsocketClient &websocketClient;
|
||||
WebsocketHandle handle;
|
||||
uint16_t numListens = 0;
|
||||
|
||||
std::vector<Listener> listeners;
|
||||
|
||||
std::atomic<bool> awaitingPong{false};
|
||||
std::atomic<bool> started{false};
|
||||
|
||||
public:
|
||||
PubSubClient(WebsocketClient &_websocketClient, WebsocketHandle _handle);
|
||||
|
||||
@@ -65,6 +56,15 @@ public:
|
||||
private:
|
||||
void ping();
|
||||
bool send(const char *payload);
|
||||
|
||||
WebsocketClient &websocketClient_;
|
||||
WebsocketHandle handle_;
|
||||
uint16_t numListens_ = 0;
|
||||
|
||||
std::vector<Listener> listeners_;
|
||||
|
||||
std::atomic<bool> awaitingPong_{false};
|
||||
std::atomic<bool> started_{false};
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
@@ -8,14 +8,14 @@
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
TwitchAccount::TwitchAccount(const QString &_username, const QString &_oauthToken,
|
||||
const QString &_oauthClient, const QString &_userID)
|
||||
TwitchAccount::TwitchAccount(const QString &username, const QString &oauthToken,
|
||||
const QString &oauthClient, const QString &userID)
|
||||
: Account(ProviderId::Twitch)
|
||||
, oauthClient(_oauthClient)
|
||||
, oauthToken(_oauthToken)
|
||||
, userName(_username)
|
||||
, userId(_userID)
|
||||
, _isAnon(_username == ANONYMOUS_USERNAME)
|
||||
, oauthClient_(oauthClient)
|
||||
, oauthToken_(oauthToken)
|
||||
, userName_(username)
|
||||
, userId_(userID)
|
||||
, isAnon_(username == ANONYMOUS_USERNAME)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -26,49 +26,49 @@ QString TwitchAccount::toString() const
|
||||
|
||||
const QString &TwitchAccount::getUserName() const
|
||||
{
|
||||
return this->userName;
|
||||
return this->userName_;
|
||||
}
|
||||
|
||||
const QString &TwitchAccount::getOAuthClient() const
|
||||
{
|
||||
return this->oauthClient;
|
||||
return this->oauthClient_;
|
||||
}
|
||||
|
||||
const QString &TwitchAccount::getOAuthToken() const
|
||||
{
|
||||
return this->oauthToken;
|
||||
return this->oauthToken_;
|
||||
}
|
||||
|
||||
const QString &TwitchAccount::getUserId() const
|
||||
{
|
||||
return this->userId;
|
||||
return this->userId_;
|
||||
}
|
||||
|
||||
bool TwitchAccount::setOAuthClient(const QString &newClientID)
|
||||
{
|
||||
if (this->oauthClient.compare(newClientID) == 0) {
|
||||
if (this->oauthClient_.compare(newClientID) == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
this->oauthClient = newClientID;
|
||||
this->oauthClient_ = newClientID;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TwitchAccount::setOAuthToken(const QString &newOAuthToken)
|
||||
{
|
||||
if (this->oauthToken.compare(newOAuthToken) == 0) {
|
||||
if (this->oauthToken_.compare(newOAuthToken) == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
this->oauthToken = newOAuthToken;
|
||||
this->oauthToken_ = newOAuthToken;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TwitchAccount::isAnon() const
|
||||
{
|
||||
return this->_isAnon;
|
||||
return this->isAnon_;
|
||||
}
|
||||
|
||||
void TwitchAccount::loadIgnores()
|
||||
@@ -95,8 +95,8 @@ void TwitchAccount::loadIgnores()
|
||||
}
|
||||
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(this->ignoresMutex);
|
||||
this->ignores.clear();
|
||||
std::lock_guard<std::mutex> lock(this->ignoresMutex_);
|
||||
this->ignores_.clear();
|
||||
|
||||
for (const auto &block : blocks.GetArray()) {
|
||||
if (!block.IsObject()) {
|
||||
@@ -112,7 +112,7 @@ void TwitchAccount::loadIgnores()
|
||||
continue;
|
||||
}
|
||||
|
||||
this->ignores.insert(ignoredUser);
|
||||
this->ignores_.insert(ignoredUser);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,9 +168,9 @@ void TwitchAccount::ignoreByID(const QString &targetUserID, const QString &targe
|
||||
return false;
|
||||
}
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(this->ignoresMutex);
|
||||
std::lock_guard<std::mutex> lock(this->ignoresMutex_);
|
||||
|
||||
auto res = this->ignores.insert(ignoredUser);
|
||||
auto res = this->ignores_.insert(ignoredUser);
|
||||
if (!res.second) {
|
||||
const TwitchUser &existingUser = *(res.first);
|
||||
existingUser.update(ignoredUser);
|
||||
@@ -219,9 +219,9 @@ void TwitchAccount::unignoreByID(
|
||||
TwitchUser ignoredUser;
|
||||
ignoredUser.id = targetUserID;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(this->ignoresMutex);
|
||||
std::lock_guard<std::mutex> lock(this->ignoresMutex_);
|
||||
|
||||
this->ignores.erase(ignoredUser);
|
||||
this->ignores_.erase(ignoredUser);
|
||||
}
|
||||
onFinished(UnignoreResult_Success, "Successfully unignored user " + targetName);
|
||||
|
||||
@@ -262,9 +262,9 @@ void TwitchAccount::checkFollow(const QString targetUserID,
|
||||
|
||||
std::set<TwitchUser> TwitchAccount::getIgnores() const
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(this->ignoresMutex);
|
||||
std::lock_guard<std::mutex> lock(this->ignoresMutex_);
|
||||
|
||||
return this->ignores;
|
||||
return this->ignores_;
|
||||
}
|
||||
|
||||
void TwitchAccount::loadEmotes(std::function<void(const rapidjson::Document &)> cb)
|
||||
|
||||
@@ -33,7 +33,7 @@ enum FollowResult {
|
||||
class TwitchAccount : public Account
|
||||
{
|
||||
public:
|
||||
TwitchAccount(const QString &username, const QString &oauthToken, const QString &oauthClient,
|
||||
TwitchAccount(const QString &username, const QString &oauthToken_, const QString &oauthClient_,
|
||||
const QString &_userID);
|
||||
|
||||
virtual QString toString() const override;
|
||||
@@ -73,14 +73,14 @@ public:
|
||||
QColor color;
|
||||
|
||||
private:
|
||||
QString oauthClient;
|
||||
QString oauthToken;
|
||||
QString userName;
|
||||
QString userId;
|
||||
const bool _isAnon;
|
||||
QString oauthClient_;
|
||||
QString oauthToken_;
|
||||
QString userName_;
|
||||
QString userId_;
|
||||
const bool isAnon_;
|
||||
|
||||
mutable std::mutex ignoresMutex;
|
||||
std::set<TwitchUser> ignores;
|
||||
mutable std::mutex ignoresMutex_;
|
||||
std::set<TwitchUser> ignores_;
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
namespace chatterino {
|
||||
|
||||
TwitchAccountManager::TwitchAccountManager()
|
||||
: anonymousUser(new TwitchAccount(ANONYMOUS_USERNAME, "", "", ""))
|
||||
: anonymousUser_(new TwitchAccount(ANONYMOUS_USERNAME, "", "", ""))
|
||||
{
|
||||
this->currentUserChanged.connect([this] {
|
||||
auto currentUser = this->getCurrent();
|
||||
@@ -20,18 +20,18 @@ TwitchAccountManager::TwitchAccountManager()
|
||||
|
||||
std::shared_ptr<TwitchAccount> TwitchAccountManager::getCurrent()
|
||||
{
|
||||
if (!this->currentUser) {
|
||||
return this->anonymousUser;
|
||||
if (!this->currentUser_) {
|
||||
return this->anonymousUser_;
|
||||
}
|
||||
|
||||
return this->currentUser;
|
||||
return this->currentUser_;
|
||||
}
|
||||
|
||||
std::vector<QString> TwitchAccountManager::getUsernames() const
|
||||
{
|
||||
std::vector<QString> userNames;
|
||||
|
||||
std::lock_guard<std::mutex> lock(this->mutex);
|
||||
std::lock_guard<std::mutex> lock(this->mutex_);
|
||||
|
||||
for (const auto &user : this->accounts.getVector()) {
|
||||
userNames.push_back(user->getUserName());
|
||||
@@ -43,7 +43,7 @@ std::vector<QString> TwitchAccountManager::getUsernames() const
|
||||
std::shared_ptr<TwitchAccount> TwitchAccountManager::findUserByUsername(
|
||||
const QString &username) const
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(this->mutex);
|
||||
std::lock_guard<std::mutex> lock(this->mutex_);
|
||||
|
||||
for (const auto &user : this->accounts.getVector()) {
|
||||
if (username.compare(user->getUserName(), Qt::CaseInsensitive) == 0) {
|
||||
@@ -124,10 +124,10 @@ void TwitchAccountManager::load()
|
||||
if (user) {
|
||||
Log("[AccountManager:currentUsernameChanged] User successfully updated to {}",
|
||||
newUsername);
|
||||
this->currentUser = user;
|
||||
this->currentUser_ = user;
|
||||
} else {
|
||||
Log("[AccountManager:currentUsernameChanged] User successfully updated to anonymous");
|
||||
this->currentUser = this->anonymousUser;
|
||||
this->currentUser_ = this->anonymousUser_;
|
||||
}
|
||||
|
||||
this->currentUserChanged.invoke();
|
||||
@@ -136,13 +136,13 @@ void TwitchAccountManager::load()
|
||||
|
||||
bool TwitchAccountManager::isLoggedIn() const
|
||||
{
|
||||
if (!this->currentUser) {
|
||||
if (!this->currentUser_) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Once `TwitchAccount` class has a way to check, we should also return false if the credentials
|
||||
// are incorrect
|
||||
return !this->currentUser->isAnon();
|
||||
return !this->currentUser_->isAnon();
|
||||
}
|
||||
|
||||
bool TwitchAccountManager::removeUser(TwitchAccount *account)
|
||||
|
||||
@@ -59,10 +59,10 @@ private:
|
||||
AddUserResponse addUser(const UserData &data);
|
||||
bool removeUser(TwitchAccount *account);
|
||||
|
||||
std::shared_ptr<TwitchAccount> currentUser;
|
||||
std::shared_ptr<TwitchAccount> currentUser_;
|
||||
|
||||
std::shared_ptr<TwitchAccount> anonymousUser;
|
||||
mutable std::mutex mutex;
|
||||
std::shared_ptr<TwitchAccount> anonymousUser_;
|
||||
mutable std::mutex mutex_;
|
||||
|
||||
friend class AccountController;
|
||||
};
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "common/UrlFetch.hpp"
|
||||
#include "debug/Log.hpp"
|
||||
#include "messages/Message.hpp"
|
||||
#include "providers/twitch/Pubsub.hpp"
|
||||
#include "providers/twitch/PubsubClient.hpp"
|
||||
#include "providers/twitch/TwitchMessageBuilder.hpp"
|
||||
#include "singletons/Emotes.hpp"
|
||||
#include "singletons/Settings.hpp"
|
||||
@@ -16,15 +16,15 @@
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
TwitchChannel::TwitchChannel(const QString &channelName, Communi::IrcConnection *_readConnection)
|
||||
TwitchChannel::TwitchChannel(const QString &channelName, Communi::IrcConnection *readConnection)
|
||||
: Channel(channelName, Channel::Type::Twitch)
|
||||
, bttvChannelEmotes(new EmoteMap)
|
||||
, ffzChannelEmotes(new EmoteMap)
|
||||
, subscriptionURL("https://www.twitch.tv/subs/" + name)
|
||||
, channelURL("https://twitch.tv/" + name)
|
||||
, popoutPlayerURL("https://player.twitch.tv/?channel=" + name)
|
||||
, mod(false)
|
||||
, readConnection(_readConnection)
|
||||
, mod_(false)
|
||||
, readConnection_(readConnection)
|
||||
{
|
||||
Log("[TwitchChannel:{}] Opened", this->name);
|
||||
|
||||
@@ -60,8 +60,8 @@ TwitchChannel::TwitchChannel(const QString &channelName, Communi::IrcConnection
|
||||
this->fetchRecentMessages(); //
|
||||
});
|
||||
|
||||
this->messageSuffix.append(' ');
|
||||
this->messageSuffix.append(QChar(0x206D));
|
||||
this->messageSuffix_.append(' ');
|
||||
this->messageSuffix_.append(QChar(0x206D));
|
||||
|
||||
static QStringList jsonLabels = {"moderators", "staff", "admins", "global_mods", "viewers"};
|
||||
auto refreshChatters = [=](QJsonObject obj) {
|
||||
@@ -161,8 +161,8 @@ void TwitchChannel::sendMessage(const QString &message)
|
||||
|
||||
if (!this->hasModRights()) {
|
||||
if (app->settings->allowDuplicateMessages) {
|
||||
if (parsedMessage == this->lastSentMessage) {
|
||||
parsedMessage.append(this->messageSuffix);
|
||||
if (parsedMessage == this->lastSentMessage_) {
|
||||
parsedMessage.append(this->messageSuffix_);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -172,19 +172,19 @@ void TwitchChannel::sendMessage(const QString &message)
|
||||
|
||||
if (messageSent) {
|
||||
qDebug() << "sent";
|
||||
this->lastSentMessage = parsedMessage;
|
||||
this->lastSentMessage_ = parsedMessage;
|
||||
}
|
||||
}
|
||||
|
||||
bool TwitchChannel::isMod() const
|
||||
{
|
||||
return this->mod;
|
||||
return this->mod_;
|
||||
}
|
||||
|
||||
void TwitchChannel::setMod(bool value)
|
||||
{
|
||||
if (this->mod != value) {
|
||||
this->mod = value;
|
||||
if (this->mod_ != value) {
|
||||
this->mod_ = value;
|
||||
|
||||
this->userStateChanged.invoke();
|
||||
}
|
||||
@@ -201,9 +201,9 @@ void TwitchChannel::addRecentChatter(const std::shared_ptr<Message> &message)
|
||||
{
|
||||
assert(!message->loginName.isEmpty());
|
||||
|
||||
std::lock_guard<std::mutex> lock(this->recentChattersMutex);
|
||||
std::lock_guard<std::mutex> lock(this->recentChattersMutex_);
|
||||
|
||||
this->recentChatters[message->loginName] = {message->displayName, message->localizedName};
|
||||
this->recentChatters_[message->loginName] = {message->displayName, message->localizedName};
|
||||
|
||||
this->completionModel.addUser(message->displayName);
|
||||
}
|
||||
@@ -216,22 +216,22 @@ void TwitchChannel::addJoinedUser(const QString &user)
|
||||
return;
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> guard(this->joinedUserMutex);
|
||||
std::lock_guard<std::mutex> guard(this->joinedUserMutex_);
|
||||
|
||||
joinedUsers << user;
|
||||
joinedUsers_ << user;
|
||||
|
||||
if (!this->joinedUsersMergeQueued) {
|
||||
this->joinedUsersMergeQueued = true;
|
||||
if (!this->joinedUsersMergeQueued_) {
|
||||
this->joinedUsersMergeQueued_ = true;
|
||||
|
||||
QTimer::singleShot(500, &this->object, [this] {
|
||||
std::lock_guard<std::mutex> guard(this->joinedUserMutex);
|
||||
QTimer::singleShot(500, &this->object_, [this] {
|
||||
std::lock_guard<std::mutex> guard(this->joinedUserMutex_);
|
||||
|
||||
auto message =
|
||||
Message::createSystemMessage("Users joined: " + this->joinedUsers.join(", "));
|
||||
Message::createSystemMessage("Users joined: " + this->joinedUsers_.join(", "));
|
||||
message->flags |= Message::Collapsed;
|
||||
this->addMessage(message);
|
||||
this->joinedUsers.clear();
|
||||
this->joinedUsersMergeQueued = false;
|
||||
this->joinedUsers_.clear();
|
||||
this->joinedUsersMergeQueued_ = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -245,39 +245,39 @@ void TwitchChannel::addPartedUser(const QString &user)
|
||||
return;
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> guard(this->partedUserMutex);
|
||||
std::lock_guard<std::mutex> guard(this->partedUserMutex_);
|
||||
|
||||
partedUsers << user;
|
||||
partedUsers_ << user;
|
||||
|
||||
if (!this->partedUsersMergeQueued) {
|
||||
this->partedUsersMergeQueued = true;
|
||||
if (!this->partedUsersMergeQueued_) {
|
||||
this->partedUsersMergeQueued_ = true;
|
||||
|
||||
QTimer::singleShot(500, &this->object, [this] {
|
||||
std::lock_guard<std::mutex> guard(this->partedUserMutex);
|
||||
QTimer::singleShot(500, &this->object_, [this] {
|
||||
std::lock_guard<std::mutex> guard(this->partedUserMutex_);
|
||||
|
||||
auto message =
|
||||
Message::createSystemMessage("Users parted: " + this->partedUsers.join(", "));
|
||||
Message::createSystemMessage("Users parted: " + this->partedUsers_.join(", "));
|
||||
message->flags |= Message::Collapsed;
|
||||
this->addMessage(message);
|
||||
this->partedUsers.clear();
|
||||
this->partedUsers_.clear();
|
||||
|
||||
this->partedUsersMergeQueued = false;
|
||||
this->partedUsersMergeQueued_ = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
TwitchChannel::RoomModes TwitchChannel::getRoomModes()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(this->roomModeMutex);
|
||||
std::lock_guard<std::mutex> lock(this->roomModeMutex_);
|
||||
|
||||
return this->roomModes;
|
||||
return this->roomModes_;
|
||||
}
|
||||
|
||||
void TwitchChannel::setRoomModes(const RoomModes &_roomModes)
|
||||
{
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(this->roomModeMutex);
|
||||
this->roomModes = _roomModes;
|
||||
std::lock_guard<std::mutex> lock(this->roomModeMutex_);
|
||||
this->roomModes_ = _roomModes;
|
||||
}
|
||||
|
||||
this->roomModesChanged.invoke();
|
||||
@@ -285,24 +285,24 @@ void TwitchChannel::setRoomModes(const RoomModes &_roomModes)
|
||||
|
||||
bool TwitchChannel::isLive() const
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(this->streamStatusMutex);
|
||||
return this->streamStatus.live;
|
||||
std::lock_guard<std::mutex> lock(this->streamStatusMutex_);
|
||||
return this->streamStatus_.live;
|
||||
}
|
||||
|
||||
TwitchChannel::StreamStatus TwitchChannel::getStreamStatus() const
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(this->streamStatusMutex);
|
||||
return this->streamStatus;
|
||||
std::lock_guard<std::mutex> lock(this->streamStatusMutex_);
|
||||
return this->streamStatus_;
|
||||
}
|
||||
|
||||
void TwitchChannel::setLive(bool newLiveStatus)
|
||||
{
|
||||
bool gotNewLiveStatus = false;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(this->streamStatusMutex);
|
||||
if (this->streamStatus.live != newLiveStatus) {
|
||||
std::lock_guard<std::mutex> lock(this->streamStatusMutex_);
|
||||
if (this->streamStatus_.live != newLiveStatus) {
|
||||
gotNewLiveStatus = true;
|
||||
this->streamStatus.live = newLiveStatus;
|
||||
this->streamStatus_.live = newLiveStatus;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -369,21 +369,21 @@ void TwitchChannel::refreshLiveStatus()
|
||||
// Stream is live
|
||||
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(channel->streamStatusMutex);
|
||||
channel->streamStatus.live = true;
|
||||
channel->streamStatus.viewerCount = stream["viewers"].GetUint();
|
||||
channel->streamStatus.game = stream["game"].GetString();
|
||||
channel->streamStatus.title = streamChannel["status"].GetString();
|
||||
std::lock_guard<std::mutex> lock(channel->streamStatusMutex_);
|
||||
channel->streamStatus_.live = true;
|
||||
channel->streamStatus_.viewerCount = stream["viewers"].GetUint();
|
||||
channel->streamStatus_.game = stream["game"].GetString();
|
||||
channel->streamStatus_.title = streamChannel["status"].GetString();
|
||||
QDateTime since = QDateTime::fromString(stream["created_at"].GetString(), Qt::ISODate);
|
||||
auto diff = since.secsTo(QDateTime::currentDateTime());
|
||||
channel->streamStatus.uptime =
|
||||
channel->streamStatus_.uptime =
|
||||
QString::number(diff / 3600) + "h " + QString::number(diff % 3600 / 60) + "m";
|
||||
|
||||
channel->streamStatus.rerun = false;
|
||||
channel->streamStatus_.rerun = false;
|
||||
if (stream.HasMember("stream_type")) {
|
||||
channel->streamStatus.streamType = stream["stream_type"].GetString();
|
||||
channel->streamStatus_.streamType = stream["stream_type"].GetString();
|
||||
} else {
|
||||
channel->streamStatus.streamType = QString();
|
||||
channel->streamStatus_.streamType = QString();
|
||||
}
|
||||
|
||||
if (stream.HasMember("broadcast_platform")) {
|
||||
@@ -392,7 +392,7 @@ void TwitchChannel::refreshLiveStatus()
|
||||
if (broadcastPlatformValue.IsString()) {
|
||||
const char *broadcastPlatform = stream["broadcast_platform"].GetString();
|
||||
if (strcmp(broadcastPlatform, "rerun") == 0) {
|
||||
channel->streamStatus.rerun = true;
|
||||
channel->streamStatus_.rerun = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -435,7 +435,7 @@ void TwitchChannel::fetchRecentMessages()
|
||||
auto channel = dynamic_cast<TwitchChannel *>(shared.get());
|
||||
assert(channel != nullptr);
|
||||
|
||||
static auto readConnection = channel->readConnection;
|
||||
static auto readConnection = channel->readConnection_;
|
||||
|
||||
QJsonArray msgArray = obj.value("messages").toArray();
|
||||
if (msgArray.empty()) {
|
||||
|
||||
@@ -80,7 +80,7 @@ public:
|
||||
QString roomID;
|
||||
|
||||
RoomModes getRoomModes();
|
||||
void setRoomModes(const RoomModes &roomModes);
|
||||
void setRoomModes(const RoomModes &roomModes_);
|
||||
|
||||
StreamStatus getStreamStatus() const;
|
||||
|
||||
@@ -97,36 +97,35 @@ private:
|
||||
void setLive(bool newLiveStatus);
|
||||
void refreshLiveStatus();
|
||||
void startRefreshLiveStatusTimer(int intervalMS);
|
||||
|
||||
mutable std::mutex streamStatusMutex;
|
||||
StreamStatus streamStatus;
|
||||
|
||||
mutable std::mutex userStateMutex;
|
||||
UserState userState;
|
||||
|
||||
void fetchRecentMessages();
|
||||
|
||||
bool mod;
|
||||
QByteArray messageSuffix;
|
||||
QString lastSentMessage;
|
||||
RoomModes roomModes;
|
||||
std::mutex roomModeMutex;
|
||||
mutable std::mutex streamStatusMutex_;
|
||||
StreamStatus streamStatus_;
|
||||
|
||||
QObject object;
|
||||
std::mutex joinedUserMutex;
|
||||
QStringList joinedUsers;
|
||||
bool joinedUsersMergeQueued = false;
|
||||
std::mutex partedUserMutex;
|
||||
QStringList partedUsers;
|
||||
bool partedUsersMergeQueued = false;
|
||||
mutable std::mutex userStateMutex_;
|
||||
UserState userState_;
|
||||
|
||||
Communi::IrcConnection *readConnection;
|
||||
bool mod_ = false;
|
||||
QByteArray messageSuffix_;
|
||||
QString lastSentMessage_;
|
||||
RoomModes roomModes_;
|
||||
std::mutex roomModeMutex_;
|
||||
|
||||
friend class TwitchServer;
|
||||
QObject object_;
|
||||
std::mutex joinedUserMutex_;
|
||||
QStringList joinedUsers_;
|
||||
bool joinedUsersMergeQueued_ = false;
|
||||
std::mutex partedUserMutex_;
|
||||
QStringList partedUsers_;
|
||||
bool partedUsersMergeQueued_ = false;
|
||||
|
||||
Communi::IrcConnection *readConnection_ = nullptr;
|
||||
|
||||
// Key = login name
|
||||
std::map<QString, NameOptions> recentChatters;
|
||||
std::mutex recentChattersMutex;
|
||||
std::map<QString, NameOptions> recentChatters_;
|
||||
std::mutex recentChattersMutex_;
|
||||
|
||||
friend class TwitchServer;
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
||||
@@ -120,7 +120,7 @@ EmoteData TwitchEmotes::getEmoteById(const QString &id, const QString &emoteName
|
||||
_emoteName = it.value();
|
||||
}
|
||||
|
||||
return _twitchEmoteFromCache.getOrAdd(id, [&emoteName, &_emoteName, &id] {
|
||||
return twitchEmoteFromCache_.getOrAdd(id, [&emoteName, &_emoteName, &id] {
|
||||
EmoteData newEmoteData;
|
||||
auto cleanCode = cleanUpCode(emoteName);
|
||||
newEmoteData.image1x =
|
||||
|
||||
@@ -62,10 +62,10 @@ private:
|
||||
void loadSetData(std::shared_ptr<TwitchEmotes::EmoteSet> emoteSet);
|
||||
|
||||
// emote code
|
||||
ConcurrentMap<QString, EmoteValue *> _twitchEmotes;
|
||||
ConcurrentMap<QString, EmoteValue *> twitchEmotes_;
|
||||
|
||||
// emote id
|
||||
ConcurrentMap<QString, EmoteData> _twitchEmoteFromCache;
|
||||
// emote id
|
||||
ConcurrentMap<QString, EmoteData> twitchEmoteFromCache_;
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
||||
@@ -27,11 +27,11 @@ TwitchMessageBuilder::TwitchMessageBuilder(Channel *_channel,
|
||||
, ircMessage(_ircMessage)
|
||||
, args(_args)
|
||||
, tags(this->ircMessage->tags())
|
||||
, originalMessage(_ircMessage->content())
|
||||
, action(_ircMessage->isAction())
|
||||
, originalMessage_(_ircMessage->content())
|
||||
, action_(_ircMessage->isAction())
|
||||
{
|
||||
auto app = getApp();
|
||||
this->usernameColor = app->themes->messages.textColors.system;
|
||||
this->usernameColor_ = app->themes->messages.textColors.system;
|
||||
}
|
||||
|
||||
TwitchMessageBuilder::TwitchMessageBuilder(Channel *_channel,
|
||||
@@ -43,11 +43,11 @@ TwitchMessageBuilder::TwitchMessageBuilder(Channel *_channel,
|
||||
, ircMessage(_ircMessage)
|
||||
, args(_args)
|
||||
, tags(this->ircMessage->tags())
|
||||
, originalMessage(content)
|
||||
, action(isAction)
|
||||
, originalMessage_(content)
|
||||
, action_(isAction)
|
||||
{
|
||||
auto app = getApp();
|
||||
this->usernameColor = app->themes->messages.textColors.system;
|
||||
this->usernameColor_ = app->themes->messages.textColors.system;
|
||||
}
|
||||
|
||||
bool TwitchMessageBuilder::isIgnored() const
|
||||
@@ -56,7 +56,7 @@ bool TwitchMessageBuilder::isIgnored() const
|
||||
|
||||
// TODO(pajlada): Do we need to check if the phrase is valid first?
|
||||
for (const auto &phrase : app->ignores->phrases.getVector()) {
|
||||
if (phrase.isMatch(this->originalMessage)) {
|
||||
if (phrase.isMatch(this->originalMessage_)) {
|
||||
Log("Blocking message because it contains ignored phrase {}", phrase.getPattern());
|
||||
return true;
|
||||
}
|
||||
@@ -105,7 +105,7 @@ MessagePtr TwitchMessageBuilder::build()
|
||||
// MessageElement::Collapsed);
|
||||
// }
|
||||
//#endif
|
||||
this->message->flags |= Message::Collapsed;
|
||||
this->message_->flags |= Message::Collapsed;
|
||||
|
||||
// PARSING
|
||||
this->parseMessageID();
|
||||
@@ -181,13 +181,13 @@ MessagePtr TwitchMessageBuilder::build()
|
||||
|
||||
// words
|
||||
|
||||
QStringList splits = this->originalMessage.split(' ');
|
||||
QStringList splits = this->originalMessage_.split(' ');
|
||||
|
||||
long int i = 0;
|
||||
|
||||
for (QString split : splits) {
|
||||
MessageColor textColor =
|
||||
this->action ? MessageColor(this->usernameColor) : MessageColor(MessageColor::Text);
|
||||
this->action_ ? MessageColor(this->usernameColor_) : MessageColor(MessageColor::Text);
|
||||
|
||||
// twitch emote
|
||||
if (currentTwitchEmote != twitchEmotes.end() && currentTwitchEmote->first == i) {
|
||||
@@ -279,7 +279,7 @@ MessagePtr TwitchMessageBuilder::build()
|
||||
i++;
|
||||
}
|
||||
|
||||
this->message->searchText = this->userName + ": " + this->originalMessage;
|
||||
this->message_->searchText = this->userName + ": " + this->originalMessage_;
|
||||
|
||||
return this->getMessage();
|
||||
}
|
||||
@@ -302,10 +302,10 @@ void TwitchMessageBuilder::parseRoomID()
|
||||
auto iterator = this->tags.find("room-id");
|
||||
|
||||
if (iterator != std::end(this->tags)) {
|
||||
this->roomID = iterator.value().toString();
|
||||
this->roomID_ = iterator.value().toString();
|
||||
|
||||
if (this->twitchChannel->roomID.isEmpty()) {
|
||||
this->twitchChannel->roomID = this->roomID;
|
||||
this->twitchChannel->roomID = this->roomID_;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -323,7 +323,7 @@ void TwitchMessageBuilder::parseUsername()
|
||||
{
|
||||
auto iterator = this->tags.find("color");
|
||||
if (iterator != this->tags.end()) {
|
||||
this->usernameColor = QColor(iterator.value().toString());
|
||||
this->usernameColor_ = QColor(iterator.value().toString());
|
||||
}
|
||||
|
||||
// username
|
||||
@@ -339,7 +339,7 @@ void TwitchMessageBuilder::parseUsername()
|
||||
// this->userName = displayNameVariant.toString() + " (" + this->userName + ")";
|
||||
// }
|
||||
|
||||
this->message->loginName = this->userName;
|
||||
this->message_->loginName = this->userName;
|
||||
}
|
||||
|
||||
void TwitchMessageBuilder::appendUsername()
|
||||
@@ -347,7 +347,7 @@ void TwitchMessageBuilder::appendUsername()
|
||||
auto app = getApp();
|
||||
|
||||
QString username = this->userName;
|
||||
this->message->loginName = username;
|
||||
this->message_->loginName = username;
|
||||
QString localizedName;
|
||||
|
||||
auto iterator = this->tags.find("display-name");
|
||||
@@ -357,12 +357,12 @@ void TwitchMessageBuilder::appendUsername()
|
||||
if (QString::compare(displayName, this->userName, Qt::CaseInsensitive) == 0) {
|
||||
username = displayName;
|
||||
|
||||
this->message->displayName = displayName;
|
||||
this->message_->displayName = displayName;
|
||||
} else {
|
||||
localizedName = displayName;
|
||||
|
||||
this->message->displayName = username;
|
||||
this->message->localizedName = displayName;
|
||||
this->message_->displayName = username;
|
||||
this->message_->localizedName = displayName;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -402,7 +402,7 @@ void TwitchMessageBuilder::appendUsername()
|
||||
// userDisplayString += IrcManager::getInstance().getUser().getUserName();
|
||||
} else if (this->args.isReceivedWhisper) {
|
||||
// Sender username
|
||||
this->emplace<TextElement>(usernameText, MessageElement::Text, this->usernameColor,
|
||||
this->emplace<TextElement>(usernameText, MessageElement::Text, this->usernameColor_,
|
||||
FontStyle::ChatMediumBold)
|
||||
->setLink({Link::UserInfo, this->userName});
|
||||
|
||||
@@ -421,11 +421,11 @@ void TwitchMessageBuilder::appendUsername()
|
||||
this->emplace<TextElement>(currentUser->getUserName() + ":", MessageElement::Text,
|
||||
selfColor, FontStyle::ChatMediumBold);
|
||||
} else {
|
||||
if (!this->action) {
|
||||
if (!this->action_) {
|
||||
usernameText += ":";
|
||||
}
|
||||
|
||||
this->emplace<TextElement>(usernameText, MessageElement::Text, this->usernameColor,
|
||||
this->emplace<TextElement>(usernameText, MessageElement::Text, this->usernameColor_,
|
||||
FontStyle::ChatMediumBold)
|
||||
->setLink({Link::UserInfo, this->userName});
|
||||
}
|
||||
@@ -443,7 +443,7 @@ void TwitchMessageBuilder::parseHighlights()
|
||||
QString currentUsername = currentUser->getUserName();
|
||||
|
||||
if (this->ircMessage->nick() == currentUsername) {
|
||||
currentUser->color = this->usernameColor;
|
||||
currentUser->color = this->usernameColor_;
|
||||
// Do nothing. Highlights cannot be triggered by yourself
|
||||
return;
|
||||
}
|
||||
@@ -481,8 +481,8 @@ void TwitchMessageBuilder::parseHighlights()
|
||||
|
||||
if (!app->highlights->blacklistContains(this->ircMessage->nick())) {
|
||||
for (const HighlightPhrase &highlight : activeHighlights) {
|
||||
if (highlight.isMatch(this->originalMessage)) {
|
||||
Log("Highlight because {} matches {}", this->originalMessage,
|
||||
if (highlight.isMatch(this->originalMessage_)) {
|
||||
Log("Highlight because {} matches {}", this->originalMessage_,
|
||||
highlight.getPattern());
|
||||
doHighlight = true;
|
||||
|
||||
@@ -533,7 +533,7 @@ void TwitchMessageBuilder::parseHighlights()
|
||||
}
|
||||
|
||||
if (doHighlight) {
|
||||
this->message->flags |= Message::Highlighted;
|
||||
this->message_->flags |= Message::Highlighted;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -567,11 +567,11 @@ void TwitchMessageBuilder::appendTwitchEmote(const Communi::IrcMessage *ircMessa
|
||||
int start = coords.at(0).toInt();
|
||||
int end = coords.at(1).toInt();
|
||||
|
||||
if (start >= end || start < 0 || end > this->originalMessage.length()) {
|
||||
if (start >= end || start < 0 || end > this->originalMessage_.length()) {
|
||||
return;
|
||||
}
|
||||
|
||||
QString name = this->originalMessage.mid(start, end - start + 1);
|
||||
QString name = this->originalMessage_.mid(start, end - start + 1);
|
||||
|
||||
vec.push_back(
|
||||
std::pair<long int, EmoteData>(start, app->emotes->twitch.getEmoteById(id, name)));
|
||||
@@ -613,7 +613,7 @@ void TwitchMessageBuilder::appendTwitchBadges()
|
||||
{
|
||||
auto app = getApp();
|
||||
|
||||
const auto &channelResources = app->resources->channels[this->roomID];
|
||||
const auto &channelResources = app->resources->channels[this->roomID_];
|
||||
|
||||
auto iterator = this->tags.find("badges");
|
||||
|
||||
@@ -791,7 +791,7 @@ bool TwitchMessageBuilder::tryParseCheermote(const QString &string)
|
||||
{
|
||||
auto app = getApp();
|
||||
// Try to parse custom cheermotes
|
||||
const auto &channelResources = app->resources->channels[this->roomID];
|
||||
const auto &channelResources = app->resources->channels[this->roomID_];
|
||||
if (channelResources.loaded) {
|
||||
for (const auto &cheermoteSet : channelResources.cheermoteSets) {
|
||||
auto match = cheermoteSet.regex.match(string);
|
||||
|
||||
@@ -28,8 +28,7 @@ public:
|
||||
explicit TwitchMessageBuilder(Channel *_channel, const Communi::IrcPrivateMessage *_ircMessage,
|
||||
const MessageParseArgs &_args);
|
||||
explicit TwitchMessageBuilder(Channel *_channel, const Communi::IrcMessage *_ircMessage,
|
||||
const MessageParseArgs &_args, QString content,
|
||||
bool isAction);
|
||||
const MessageParseArgs &_args, QString content, bool isAction);
|
||||
|
||||
Channel *channel;
|
||||
TwitchChannel *twitchChannel;
|
||||
@@ -44,14 +43,6 @@ public:
|
||||
MessagePtr build();
|
||||
|
||||
private:
|
||||
QString roomID;
|
||||
|
||||
QColor usernameColor;
|
||||
const QString originalMessage;
|
||||
bool senderIsBroadcaster{};
|
||||
|
||||
const bool action = false;
|
||||
|
||||
void parseMessageID();
|
||||
void parseRoomID();
|
||||
void appendChannelName();
|
||||
@@ -66,6 +57,14 @@ private:
|
||||
void appendTwitchBadges();
|
||||
void appendChatterinoBadges();
|
||||
bool tryParseCheermote(const QString &string);
|
||||
|
||||
QString roomID_;
|
||||
|
||||
QColor usernameColor_;
|
||||
const QString originalMessage_;
|
||||
bool senderIsBroadcaster{};
|
||||
|
||||
const bool action_ = false;
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
||||
@@ -42,13 +42,13 @@ protected:
|
||||
QString cleanChannelName(const QString &dirtyChannelName) override;
|
||||
|
||||
private:
|
||||
void onMessageSendRequested(TwitchChannel *channel, const QString &message, bool &sent);
|
||||
|
||||
std::mutex lastMessageMutex_;
|
||||
std::queue<std::chrono::steady_clock::time_point> lastMessagePleb_;
|
||||
std::queue<std::chrono::steady_clock::time_point> lastMessageMod_;
|
||||
std::chrono::steady_clock::time_point lastErrorTimeSpeed_;
|
||||
std::chrono::steady_clock::time_point lastErrorTimeAmount_;
|
||||
|
||||
void onMessageSendRequested(TwitchChannel *channel, const QString &message, bool &sent);
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
||||
Reference in New Issue
Block a user