mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
fixed #237 /mentions
This commit is contained in:
parent
d741bf6df3
commit
fa344deaf0
|
@ -11,10 +11,9 @@
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
namespace messages {
|
namespace messages {
|
||||||
class Message;
|
|
||||||
|
|
||||||
typedef std::shared_ptr<Message> MessagePtr;
|
|
||||||
typedef uint16_t MessageFlagsType;
|
typedef uint16_t MessageFlagsType;
|
||||||
|
class Message;
|
||||||
|
typedef std::shared_ptr<Message> MessagePtr;
|
||||||
|
|
||||||
class Message
|
class Message
|
||||||
{
|
{
|
||||||
|
@ -86,6 +85,5 @@ private:
|
||||||
|
|
||||||
std::vector<std::unique_ptr<MessageElement>> elements;
|
std::vector<std::unique_ptr<MessageElement>> elements;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace messages
|
} // namespace messages
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|
|
@ -8,7 +8,6 @@ public:
|
||||||
bool disablePingSoungs = false;
|
bool disablePingSoungs = false;
|
||||||
bool isReceivedWhisper = false;
|
bool isReceivedWhisper = false;
|
||||||
bool isSentWhisper = false;
|
bool isSentWhisper = false;
|
||||||
bool includeChannelName = false;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace messages
|
} // namespace messages
|
||||||
|
|
|
@ -256,7 +256,12 @@ void IrcManager::privateMessageReceived(Communi::IrcPrivateMessage *message)
|
||||||
twitch::TwitchMessageBuilder builder(c.get(), message, args);
|
twitch::TwitchMessageBuilder builder(c.get(), message, args);
|
||||||
|
|
||||||
if (!builder.isIgnored()) {
|
if (!builder.isIgnored()) {
|
||||||
c->addMessage(builder.parse());
|
messages::MessagePtr message = builder.build();
|
||||||
|
if (message->hasFlags(messages::Message::Highlighted)) {
|
||||||
|
singletons::ChannelManager::getInstance().mentionsChannel->addMessage(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
c->addMessage(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#include "twitchchannel.hpp"
|
#include "twitchchannel.hpp"
|
||||||
#include "debug/log.hpp"
|
#include "debug/log.hpp"
|
||||||
|
#include "messages/message.hpp"
|
||||||
|
#include "singletons/channelmanager.hpp"
|
||||||
#include "singletons/emotemanager.hpp"
|
#include "singletons/emotemanager.hpp"
|
||||||
#include "singletons/ircmanager.hpp"
|
#include "singletons/ircmanager.hpp"
|
||||||
#include "singletons/settingsmanager.hpp"
|
#include "singletons/settingsmanager.hpp"
|
||||||
|
@ -239,7 +241,7 @@ void TwitchChannel::fetchRecentMessages()
|
||||||
messages::MessageParseArgs args;
|
messages::MessageParseArgs args;
|
||||||
twitch::TwitchMessageBuilder builder(channel, privMsg, args);
|
twitch::TwitchMessageBuilder builder(channel, privMsg, args);
|
||||||
if (!builder.isIgnored()) {
|
if (!builder.isIgnored()) {
|
||||||
messages.push_back(builder.parse());
|
messages.push_back(builder.build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
channel->addMessagesAtStart(messages);
|
channel->addMessagesAtStart(messages);
|
||||||
|
|
|
@ -44,7 +44,7 @@ bool TwitchMessageBuilder::isIgnored() const
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
MessagePtr TwitchMessageBuilder::parse()
|
MessagePtr TwitchMessageBuilder::build()
|
||||||
{
|
{
|
||||||
singletons::SettingManager &settings = singletons::SettingManager::getInstance();
|
singletons::SettingManager &settings = singletons::SettingManager::getInstance();
|
||||||
singletons::EmoteManager &emoteManager = singletons::EmoteManager::getInstance();
|
singletons::EmoteManager &emoteManager = singletons::EmoteManager::getInstance();
|
||||||
|
@ -56,11 +56,14 @@ MessagePtr TwitchMessageBuilder::parse()
|
||||||
// this->appendWord(Word(Resources::getInstance().badgeCollapsed, Word::Collapsed, QString(),
|
// this->appendWord(Word(Resources::getInstance().badgeCollapsed, Word::Collapsed, QString(),
|
||||||
// QString()));
|
// QString()));
|
||||||
|
|
||||||
// The timestamp is always appended to the builder
|
// PARSING
|
||||||
// Whether or not will be rendered is decided/checked later
|
this->parseMessageID();
|
||||||
|
|
||||||
// Appends the correct timestamp if the message is a past message
|
this->parseRoomID();
|
||||||
|
|
||||||
|
this->appendChannelName();
|
||||||
|
|
||||||
|
// timestamp
|
||||||
bool isPastMsg = this->tags.contains("historical");
|
bool isPastMsg = this->tags.contains("historical");
|
||||||
if (isPastMsg) {
|
if (isPastMsg) {
|
||||||
// This may be architecture dependent(datatype)
|
// This may be architecture dependent(datatype)
|
||||||
|
@ -71,20 +74,11 @@ MessagePtr TwitchMessageBuilder::parse()
|
||||||
this->emplace<TimestampElement>();
|
this->emplace<TimestampElement>();
|
||||||
}
|
}
|
||||||
|
|
||||||
this->parseMessageID();
|
|
||||||
|
|
||||||
this->parseRoomID();
|
|
||||||
|
|
||||||
// TIMESTAMP
|
|
||||||
this->emplace<TwitchModerationElement>();
|
this->emplace<TwitchModerationElement>();
|
||||||
|
|
||||||
this->parseTwitchBadges();
|
this->appendTwitchBadges();
|
||||||
|
|
||||||
this->addChatterinoBadges();
|
this->appendChatterinoBadges();
|
||||||
|
|
||||||
if (this->args.includeChannelName) {
|
|
||||||
this->parseChannelName();
|
|
||||||
}
|
|
||||||
|
|
||||||
this->appendUsername();
|
this->appendUsername();
|
||||||
|
|
||||||
|
@ -232,7 +226,7 @@ void TwitchMessageBuilder::parseRoomID()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TwitchMessageBuilder::parseChannelName()
|
void TwitchMessageBuilder::appendChannelName()
|
||||||
{
|
{
|
||||||
QString channelName("#" + this->channel->name);
|
QString channelName("#" + this->channel->name);
|
||||||
Link link(Link::Url, this->channel->name + "\n" + this->messageID);
|
Link link(Link::Url, this->channel->name + "\n" + this->messageID);
|
||||||
|
@ -492,7 +486,7 @@ bool TwitchMessageBuilder::tryAppendEmote(QString &emoteString)
|
||||||
|
|
||||||
// fourtf: this is ugly
|
// fourtf: this is ugly
|
||||||
// maybe put the individual badges into a map instead of this mess
|
// maybe put the individual badges into a map instead of this mess
|
||||||
void TwitchMessageBuilder::parseTwitchBadges()
|
void TwitchMessageBuilder::appendTwitchBadges()
|
||||||
{
|
{
|
||||||
singletons::ResourceManager &resourceManager = singletons::ResourceManager::getInstance();
|
singletons::ResourceManager &resourceManager = singletons::ResourceManager::getInstance();
|
||||||
const auto &channelResources = resourceManager.channels[this->roomID];
|
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 &badges = singletons::ResourceManager::getInstance().chatterinoBadges;
|
||||||
auto it = badges.find(this->userName.toStdString());
|
auto it = badges.find(this->userName.toStdString());
|
||||||
|
|
|
@ -39,7 +39,7 @@ public:
|
||||||
QString userName;
|
QString userName;
|
||||||
|
|
||||||
bool isIgnored() const;
|
bool isIgnored() const;
|
||||||
messages::MessagePtr parse();
|
messages::MessagePtr build();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString roomID;
|
QString roomID;
|
||||||
|
@ -48,7 +48,7 @@ private:
|
||||||
|
|
||||||
void parseMessageID();
|
void parseMessageID();
|
||||||
void parseRoomID();
|
void parseRoomID();
|
||||||
void parseChannelName();
|
void appendChannelName();
|
||||||
void parseUsername();
|
void parseUsername();
|
||||||
void appendUsername();
|
void appendUsername();
|
||||||
void parseHighlights();
|
void parseHighlights();
|
||||||
|
@ -57,8 +57,8 @@ private:
|
||||||
std::vector<std::pair<long, util::EmoteData>> &vec);
|
std::vector<std::pair<long, util::EmoteData>> &vec);
|
||||||
bool tryAppendEmote(QString &emoteString);
|
bool tryAppendEmote(QString &emoteString);
|
||||||
|
|
||||||
void parseTwitchBadges();
|
void appendTwitchBadges();
|
||||||
void addChatterinoBadges();
|
void appendChatterinoBadges();
|
||||||
bool tryParseCheermote(const QString &string);
|
bool tryParseCheermote(const QString &string);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -456,6 +456,9 @@ messages::MessageElement::Flags ChannelView::getFlags() const
|
||||||
if (split->getModerationMode()) {
|
if (split->getModerationMode()) {
|
||||||
flags = (MessageElement::Flags)(flags | MessageElement::ModeratorTools);
|
flags = (MessageElement::Flags)(flags | MessageElement::ModeratorTools);
|
||||||
}
|
}
|
||||||
|
if (this->channel == singletons::ChannelManager::getInstance().mentionsChannel) {
|
||||||
|
flags = (MessageElement::Flags)(flags | MessageElement::ChannelName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return flags;
|
return flags;
|
||||||
|
|
|
@ -130,6 +130,9 @@ void Notebook::select(SplitContainer *page)
|
||||||
if (this->selectedPage != nullptr) {
|
if (this->selectedPage != nullptr) {
|
||||||
this->selectedPage->setHidden(true);
|
this->selectedPage->setHidden(true);
|
||||||
this->selectedPage->getTab()->setSelected(false);
|
this->selectedPage->getTab()->setSelected(false);
|
||||||
|
for (auto split : this->selectedPage->getSplits()) {
|
||||||
|
split->updateLastReadMessage();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this->selectedPage = page;
|
this->selectedPage = page;
|
||||||
|
|
Loading…
Reference in a new issue