fixed #237 /mentions

This commit is contained in:
fourtf
2018-01-23 23:28:06 +01:00
parent d741bf6df3
commit fa344deaf0
8 changed files with 33 additions and 29 deletions
+3 -1
View File
@@ -1,5 +1,7 @@
#include "twitchchannel.hpp"
#include "debug/log.hpp"
#include "messages/message.hpp"
#include "singletons/channelmanager.hpp"
#include "singletons/emotemanager.hpp"
#include "singletons/ircmanager.hpp"
#include "singletons/settingsmanager.hpp"
@@ -239,7 +241,7 @@ void TwitchChannel::fetchRecentMessages()
messages::MessageParseArgs args;
twitch::TwitchMessageBuilder builder(channel, privMsg, args);
if (!builder.isIgnored()) {
messages.push_back(builder.parse());
messages.push_back(builder.build());
}
}
channel->addMessagesAtStart(messages);
+12 -18
View File
@@ -44,7 +44,7 @@ bool TwitchMessageBuilder::isIgnored() const
return false;
}
MessagePtr TwitchMessageBuilder::parse()
MessagePtr TwitchMessageBuilder::build()
{
singletons::SettingManager &settings = singletons::SettingManager::getInstance();
singletons::EmoteManager &emoteManager = singletons::EmoteManager::getInstance();
@@ -56,11 +56,14 @@ MessagePtr TwitchMessageBuilder::parse()
// this->appendWord(Word(Resources::getInstance().badgeCollapsed, Word::Collapsed, QString(),
// QString()));
// The timestamp is always appended to the builder
// Whether or not will be rendered is decided/checked later
// PARSING
this->parseMessageID();
// Appends the correct timestamp if the message is a past message
this->parseRoomID();
this->appendChannelName();
// timestamp
bool isPastMsg = this->tags.contains("historical");
if (isPastMsg) {
// This may be architecture dependent(datatype)
@@ -71,20 +74,11 @@ MessagePtr TwitchMessageBuilder::parse()
this->emplace<TimestampElement>();
}
this->parseMessageID();
this->parseRoomID();
// TIMESTAMP
this->emplace<TwitchModerationElement>();
this->parseTwitchBadges();
this->appendTwitchBadges();
this->addChatterinoBadges();
if (this->args.includeChannelName) {
this->parseChannelName();
}
this->appendChatterinoBadges();
this->appendUsername();
@@ -232,7 +226,7 @@ void TwitchMessageBuilder::parseRoomID()
}
}
void TwitchMessageBuilder::parseChannelName()
void TwitchMessageBuilder::appendChannelName()
{
QString channelName("#" + this->channel->name);
Link link(Link::Url, this->channel->name + "\n" + this->messageID);
@@ -492,7 +486,7 @@ bool TwitchMessageBuilder::tryAppendEmote(QString &emoteString)
// fourtf: this is ugly
// maybe put the individual badges into a map instead of this mess
void TwitchMessageBuilder::parseTwitchBadges()
void TwitchMessageBuilder::appendTwitchBadges()
{
singletons::ResourceManager &resourceManager = singletons::ResourceManager::getInstance();
const auto &channelResources = resourceManager.channels[this->roomID];
@@ -649,7 +643,7 @@ void TwitchMessageBuilder::parseTwitchBadges()
}
}
void TwitchMessageBuilder::addChatterinoBadges()
void TwitchMessageBuilder::appendChatterinoBadges()
{
auto &badges = singletons::ResourceManager::getInstance().chatterinoBadges;
auto it = badges.find(this->userName.toStdString());
+4 -4
View File
@@ -39,7 +39,7 @@ public:
QString userName;
bool isIgnored() const;
messages::MessagePtr parse();
messages::MessagePtr build();
private:
QString roomID;
@@ -48,7 +48,7 @@ private:
void parseMessageID();
void parseRoomID();
void parseChannelName();
void appendChannelName();
void parseUsername();
void appendUsername();
void parseHighlights();
@@ -57,8 +57,8 @@ private:
std::vector<std::pair<long, util::EmoteData>> &vec);
bool tryAppendEmote(QString &emoteString);
void parseTwitchBadges();
void addChatterinoBadges();
void appendTwitchBadges();
void appendChatterinoBadges();
bool tryParseCheermote(const QString &string);
};