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

94 lines
2.7 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-09-30 13:37:39 +02:00
explicit TwitchMessageBuilder(Channel *_channel,
const Communi::IrcPrivateMessage *_ircMessage,
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;
TwitchChannel *twitchChannel;
const Communi::IrcMessage *ircMessage;
MessageParseArgs args;
2017-07-02 18:12:11 +02:00
const QVariantMap tags;
2017-04-12 17:46:44 +02:00
QString userName;
[[nodiscard]] bool isIgnored() const;
// triggerHighlights triggers any alerts or sounds parsed by parseHighlights
void triggerHighlights();
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 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
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;
bool historicalMessage_ = false;
2018-07-06 19:23:47 +02:00
QColor usernameColor_;
Squashed commit of the following: commit ea07bbef0be589cc5412bff0a25735ac713128e3 Merge: 0b36f436 5cfcf114 Author: hemirt <hemirt@email.cz> Date: Sun Sep 23 20:05:14 2018 +0200 Merge branch 'blacklist' into blacklistnew commit 5cfcf114b65ea7c0fca9654393ac2faa78610098 Author: hemirt <hemirt@email.cz> Date: Sun Sep 23 20:00:16 2018 +0200 rename second pattern to replacement commit f08cc4cf88c49140a282d3d29af5ad8e7179bb7c Author: hemirt <hemirt@email.cz> Date: Sun Sep 23 19:52:30 2018 +0200 delete out commented code commit 1acb1278aa0109359e0e349ae240d10b34de9d34 Author: hemirt <hemirt@email.cz> Date: Sun Sep 23 19:52:03 2018 +0200 fix replacement with emotes issues commit 646268ab1883a955291f152029fa37f4416e681e Author: hemirt <hemirt@email.cz> Date: Sun Aug 19 01:06:36 2018 +0200 fix build commit ad711b4c15ef0660c554af5ceea82397769a2313 Merge: e8e059f8 8bcc9c48 Author: hemirt <hemirt@email.cz> Date: Sun Aug 19 00:52:38 2018 +0200 Merge branch 'master' of https://github.com/fourtf/chatterino2 into blacklist commit e8e059f8473271128086c5230cf1c40b235af380 Author: hemirt <hemirt@email.cz> Date: Sun Aug 19 00:25:58 2018 +0200 add replaced emotes into twitchEmotes commit a63454f00de479cee1ab1eca18a8b4ab93e37d52 Merge: e7f2f397 63eaf3b9 Author: hemirt <hemirt@email.cz> Date: Sat Aug 11 22:38:16 2018 +0200 Merge branch 'master' of https://github.com/fourtf/chatterino2 into blacklist commit e7f2f397378d0582d989ff8fcbe83bcec41449a1 Author: hemirt <hemirt@email.cz> Date: Sat Aug 11 21:54:01 2018 +0200 emotedata commit f00d3da537ec14aebd9cbb84d63f7b16c196f199 Author: hemirt <hemirt@email.cz> Date: Sat Jul 28 19:53:55 2018 +0200 rename variables to fit better, emotes in capture groups from regex work commit 00c9fa080aeb8a4a187743d708ba139cbed5a849 Author: hemirt <hemirt@email.cz> Date: Mon Jul 9 19:53:53 2018 +0200 add case sensitivity checkbox and fix validity issues due to isValid that checked regex commit 4385fcd13fe6e011b91a3f4a29fd440d019fc499 Author: hemirt <hemirt@email.cz> Date: Sun Jul 8 21:09:14 2018 +0200 remove commented code commit 1834342f74c4fbff38b81fa2c2fcfd6c55adc0d5 Author: hemirt <hemirt@email.cz> Date: Sun Jul 8 21:03:13 2018 +0200 IgnorePhrase replacement also removes twitch emotes info about the matched and changed parts and shifts positions of other emotes from emote infos to the corresponding new position commit d3b6e294ed38fa8587c367c5da6f257641c28b86 Author: hemirt <hemirt@email.cz> Date: Sun Jul 8 16:21:33 2018 +0200 ignore phrases
2018-09-23 20:21:50 +02:00
QString originalMessage_;
2018-07-06 19:23:47 +02:00
bool senderIsBroadcaster{};
const bool action_ = false;
bool highlightVisual_ = false;
bool highlightAlert_ = false;
bool highlightSound_ = false;
2017-04-12 17:46:44 +02:00
};
} // namespace chatterino