2017-06-07 10:09:24 +02:00
|
|
|
#pragma once
|
2017-04-12 17:46:44 +02:00
|
|
|
|
2018-08-11 22:23:06 +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>
|
2017-06-13 21:13:58 +02:00
|
|
|
#include <QVariant>
|
2017-04-12 17:46:44 +02:00
|
|
|
|
2017-04-14 17:52:22 +02:00
|
|
|
namespace chatterino {
|
2017-06-13 21:13:58 +02:00
|
|
|
|
2018-08-11 22:23:06 +02:00
|
|
|
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
|
|
|
|
2018-06-28 19:38:57 +02:00
|
|
|
class TwitchMessageBuilder : public MessageBuilder
|
2017-04-12 17:46:44 +02:00
|
|
|
{
|
|
|
|
public:
|
2017-07-23 11:59:05 +02:00
|
|
|
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-09-30 13:37:39 +02:00
|
|
|
explicit TwitchMessageBuilder(Channel *_channel,
|
|
|
|
const Communi::IrcPrivateMessage *_ircMessage,
|
2018-06-28 19:38:57 +02:00
|
|
|
const MessageParseArgs &_args);
|
2018-09-30 13:37:39 +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;
|
2017-09-16 00:05:06 +02:00
|
|
|
TwitchChannel *twitchChannel;
|
2018-02-04 16:33:46 +01:00
|
|
|
const Communi::IrcMessage *ircMessage;
|
2018-06-28 19:38:57 +02:00
|
|
|
MessageParseArgs args;
|
2017-07-02 18:12:11 +02:00
|
|
|
const QVariantMap tags;
|
|
|
|
|
2017-04-12 17:46:44 +02:00
|
|
|
QString userName;
|
|
|
|
|
2019-08-04 14:31:57 +02:00
|
|
|
[[nodiscard]] bool isIgnored() const;
|
|
|
|
// triggerHighlights triggers any alerts or sounds parsed by parseHighlights
|
|
|
|
void triggerHighlights();
|
2018-06-28 19:38:57 +02:00
|
|
|
MessagePtr build();
|
2017-04-12 17:46:44 +02:00
|
|
|
|
2017-06-13 21:13:58 +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();
|
2019-08-11 22:18:01 +02:00
|
|
|
void parseUsernameColor();
|
2017-07-02 18:12:11 +02:00
|
|
|
void parseUsername();
|
2017-08-12 13:18:48 +02:00
|
|
|
void appendUsername();
|
2019-08-04 14:31:57 +02:00
|
|
|
void runIgnoreReplaces(
|
|
|
|
std::vector<std::tuple<int, EmotePtr, EmoteName>> &twitchEmotes);
|
|
|
|
// parseHighlights only updates the visual state of the message, but leaves the playing of alerts and sounds to the triggerHighlights function
|
|
|
|
void parseHighlights();
|
2017-07-02 18:12:11 +02:00
|
|
|
|
2019-04-28 02:25:05 +02:00
|
|
|
void appendTwitchEmote(
|
|
|
|
const QString &emote,
|
|
|
|
std::vector<std::tuple<int, EmotePtr, EmoteName>> &vec,
|
|
|
|
std::vector<int> &correctPositions);
|
2018-08-02 14:23:27 +02:00
|
|
|
Outcome tryAppendEmote(const EmoteName &name);
|
|
|
|
|
2018-09-30 13:37:39 +02:00
|
|
|
void addWords(
|
|
|
|
const QStringList &words,
|
|
|
|
const std::vector<std::tuple<int, EmotePtr, EmoteName>> &twitchEmotes);
|
2018-08-02 14:23:27 +02:00
|
|
|
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;
|
2019-09-08 12:45:25 +02:00
|
|
|
QString bits;
|
2019-08-04 14:31:57 +02:00
|
|
|
bool historicalMessage_ = false;
|
2018-07-06 19:23:47 +02:00
|
|
|
|
2019-08-23 16:52:04 +02:00
|
|
|
QString userId_;
|
2018-07-06 19:23:47 +02:00
|
|
|
QColor usernameColor_;
|
2018-09-23 20:21:50 +02:00
|
|
|
QString originalMessage_;
|
2018-07-06 19:23:47 +02:00
|
|
|
bool senderIsBroadcaster{};
|
|
|
|
|
|
|
|
const bool action_ = false;
|
2019-08-04 14:31:57 +02:00
|
|
|
|
|
|
|
bool highlightVisual_ = false;
|
|
|
|
bool highlightAlert_ = false;
|
|
|
|
bool highlightSound_ = false;
|
2017-04-12 17:46:44 +02:00
|
|
|
};
|
2017-06-07 10:09:24 +02:00
|
|
|
|
|
|
|
} // namespace chatterino
|