mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
6ea3a1df08
cstdint) Make MessageElement to a class to fit better with the derived classes. Make MessageLayoutElement to a class to fit better with the derived classes. Remove virtual from override functions Replace all instances of boost::signals2 with pajlada::Signals. This lets us properly use clang code model to check for issues. Add missing virtual destructor to AbstractIrcServer Add missing virtual destructor to MessageLayoutElement Remove unused "connectedConnection" connection in TwitchChannel Fix typo in TrimChannelName function Fix typo in MessageParseArgs Replace some raw pointers with unique pointers where it made more sense. This allowed us to remove some manually written destructors whose only purpose was to delete that raw pointer. Reformat: Add namespace comments Reformat: Add empty empty lines between main namespace beginning and end Reformat: Re-order includes Reformat: Fix some includes that used quotes where they should use angle brackets Reformat: Replace some typedef's with using's Filter out more useless warnings
83 lines
2.2 KiB
C++
83 lines
2.2 KiB
C++
#include "messages/message.hpp"
|
|
#include "messageelement.hpp"
|
|
#include "util/irchelpers.hpp"
|
|
|
|
using SBHighlight = chatterino::widgets::ScrollbarHighlight;
|
|
|
|
namespace chatterino {
|
|
namespace messages {
|
|
void Message::addElement(MessageElement *element)
|
|
{
|
|
this->elements.push_back(std::unique_ptr<MessageElement>(element));
|
|
}
|
|
|
|
const std::vector<std::unique_ptr<MessageElement>> &Message::getElements() const
|
|
{
|
|
return this->elements;
|
|
}
|
|
|
|
SBHighlight Message::getScrollBarHighlight() const
|
|
{
|
|
if (this->flags & Message::Highlighted) {
|
|
return SBHighlight(SBHighlight::Highlight);
|
|
}
|
|
return SBHighlight();
|
|
}
|
|
|
|
// Static
|
|
MessagePtr Message::createSystemMessage(const QString &text)
|
|
{
|
|
MessagePtr message(new Message);
|
|
|
|
message->addElement(new TimestampElement(QTime::currentTime()));
|
|
message->addElement(new TextElement(text, MessageElement::Text, MessageColor::System));
|
|
message->flags.EnableFlag(MessageFlags::System);
|
|
message->searchText = text;
|
|
|
|
return message;
|
|
}
|
|
|
|
MessagePtr Message::createTimeoutMessage(const QString &username, const QString &durationInSeconds,
|
|
const QString &reason, bool multipleTimes)
|
|
{
|
|
QString text;
|
|
|
|
text.append(username);
|
|
if (!durationInSeconds.isEmpty()) {
|
|
text.append(" has been timed out");
|
|
|
|
// TODO: Implement who timed the user out
|
|
|
|
text.append(" for ");
|
|
text.append(durationInSeconds);
|
|
bool ok = true;
|
|
int timeoutDuration = durationInSeconds.toInt(&ok);
|
|
text.append(" second");
|
|
if (ok && timeoutDuration > 1) {
|
|
text.append("s");
|
|
}
|
|
} else {
|
|
text.append(" has been permanently banned");
|
|
}
|
|
|
|
if (reason.length() > 0) {
|
|
text.append(": \"");
|
|
text.append(util::ParseTagString(reason));
|
|
text.append("\"");
|
|
}
|
|
text.append(".");
|
|
|
|
if (multipleTimes) {
|
|
text.append(" (multiple times)");
|
|
}
|
|
|
|
MessagePtr message = Message::createSystemMessage(text);
|
|
message->flags.EnableFlag(MessageFlags::System);
|
|
message->flags.EnableFlag(MessageFlags::Timeout);
|
|
message->timeoutUser = username;
|
|
return message;
|
|
}
|
|
|
|
} // namespace messages
|
|
} // namespace chatterino
|