mirror-chatterino2/src/providers/twitch/TwitchMessageBuilder.hpp

82 lines
2.2 KiB
C++
Raw Normal View History

#pragma once
2017-04-12 17:46:44 +02:00
#include "common/Aliases.hpp"
#include "common/Outcome.hpp"
2018-06-26 14:09:39 +02:00
#include "messages/MessageBuilder.hpp"
2017-12-31 00:50:07 +01:00
#include <IrcMessage>
2017-04-12 17:46:44 +02:00
#include <QString>
#include <QVariant>
2017-04-12 17:46:44 +02:00
2017-04-14 17:52:22 +02:00
namespace chatterino {
struct Emote;
using EmotePtr = std::shared_ptr<const Emote>;
2018-06-26 16:37:59 +02:00
class Channel;
2017-12-31 00:50:07 +01:00
class TwitchChannel;
2017-04-12 17:46:44 +02:00
class TwitchMessageBuilder : public MessageBuilder
2017-04-12 17:46:44 +02:00
{
public:
enum UsernameDisplayMode : int {
Username = 1, // Username
LocalizedName = 2, // Localized name
UsernameAndLocalizedName = 3, // Username (Localized name)
};
2017-07-02 18:12:11 +02:00
TwitchMessageBuilder() = delete;
2017-04-12 17:46:44 +02:00
2018-08-06 21:17:03 +02:00
explicit TwitchMessageBuilder(Channel *_channel,
const Communi::IrcPrivateMessage *_ircMessage,
const MessageParseArgs &_args);
2018-08-06 21:17:03 +02:00
explicit TwitchMessageBuilder(Channel *_channel,
const Communi::IrcMessage *_ircMessage,
const MessageParseArgs &_args,
QString content, bool isAction);
2017-07-02 18:12:11 +02:00
Channel *channel;
TwitchChannel *twitchChannel;
const Communi::IrcMessage *ircMessage;
MessageParseArgs args;
2017-07-02 18:12:11 +02:00
const QVariantMap tags;
QString messageID;
2017-04-12 17:46:44 +02:00
QString userName;
2018-01-23 21:33:49 +01:00
bool isIgnored() const;
MessagePtr build();
2017-04-12 17:46:44 +02:00
private:
2017-07-02 18:12:11 +02:00
void parseMessageID();
void parseRoomID();
2018-01-23 23:28:06 +01:00
void appendChannelName();
2017-07-02 18:12:11 +02:00
void parseUsername();
void appendUsername();
void parseHighlights(bool isPastMsg);
2017-07-02 18:12:11 +02:00
void appendTwitchEmote(const QString &emote,
2018-08-02 14:23:27 +02:00
std::vector<std::pair<int, EmotePtr>> &vec);
Outcome tryAppendEmote(const EmoteName &name);
void addWords(const QStringList &words,
const std::vector<std::pair<int, EmotePtr>> &twitchEmotes);
void addTextOrEmoji(EmotePtr emote);
void addTextOrEmoji(const QString &value);
2017-07-02 18:12:11 +02:00
2018-01-23 23:28:06 +01:00
void appendTwitchBadges();
void appendChatterinoBadges();
2018-08-02 14:23:27 +02:00
Outcome tryParseCheermote(const QString &string);
2018-07-06 19:23:47 +02:00
QString roomID_;
2018-08-02 14:23:27 +02:00
bool hasBits_ = false;
2018-07-06 19:23:47 +02:00
QColor usernameColor_;
const QString originalMessage_;
bool senderIsBroadcaster{};
const bool action_ = false;
2017-04-12 17:46:44 +02:00
};
} // namespace chatterino