2020-10-18 15:54:48 +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"
|
2020-07-04 15:15:59 +02:00
|
|
|
#include "messages/SharedMessageBuilder.hpp"
|
2020-08-08 15:37:22 +02:00
|
|
|
#include "providers/twitch/ChannelPointReward.hpp"
|
2021-06-19 13:56:00 +02:00
|
|
|
#include "providers/twitch/PubsubActions.hpp"
|
2019-12-01 13:32:41 +01:00
|
|
|
#include "providers/twitch/TwitchBadge.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
|
|
|
|
2020-09-26 14:21:46 +02:00
|
|
|
struct TwitchEmoteOccurence {
|
|
|
|
int start;
|
|
|
|
int end;
|
|
|
|
EmotePtr ptr;
|
|
|
|
EmoteName name;
|
|
|
|
};
|
|
|
|
|
2020-07-04 15:15:59 +02:00
|
|
|
class TwitchMessageBuilder : public SharedMessageBuilder
|
2017-04-12 17:46:44 +02:00
|
|
|
{
|
|
|
|
public:
|
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
|
|
|
|
2017-09-16 00:05:06 +02:00
|
|
|
TwitchChannel *twitchChannel;
|
2017-07-02 18:12:11 +02:00
|
|
|
|
2020-07-04 15:15:59 +02:00
|
|
|
[[nodiscard]] bool isIgnored() const override;
|
|
|
|
void triggerHighlights() override;
|
|
|
|
MessagePtr build() override;
|
2017-04-12 17:46:44 +02:00
|
|
|
|
2020-08-08 15:37:22 +02:00
|
|
|
static void appendChannelPointRewardMessage(
|
2021-08-01 15:44:04 +02:00
|
|
|
const ChannelPointReward &reward, MessageBuilder *builder, bool isMod,
|
|
|
|
bool isBroadcaster);
|
2021-05-09 16:17:04 +02:00
|
|
|
|
|
|
|
// Message in the /live chat for channel going live
|
|
|
|
static void liveMessage(const QString &channelName,
|
|
|
|
MessageBuilder *builder);
|
|
|
|
|
|
|
|
// Messages in normal chat for channel stuff
|
2021-05-08 16:46:41 +02:00
|
|
|
static void liveSystemMessage(const QString &channelName,
|
|
|
|
MessageBuilder *builder);
|
|
|
|
static void offlineSystemMessage(const QString &channelName,
|
|
|
|
MessageBuilder *builder);
|
|
|
|
static void hostingSystemMessage(const QString &channelName,
|
2021-06-27 15:50:12 +02:00
|
|
|
MessageBuilder *builder, bool hostOn);
|
2021-06-06 17:51:57 +02:00
|
|
|
static void deletionMessage(const MessagePtr originalMessage,
|
|
|
|
MessageBuilder *builder);
|
2021-06-19 13:56:00 +02:00
|
|
|
static void deletionMessage(const DeleteAction &action,
|
|
|
|
MessageBuilder *builder);
|
2020-08-08 15:37:22 +02:00
|
|
|
|
2017-06-13 21:13:58 +02:00
|
|
|
private:
|
2020-07-04 15:15:59 +02:00
|
|
|
void parseUsernameColor() override;
|
|
|
|
void parseUsername() override;
|
2017-07-02 18:12:11 +02:00
|
|
|
void parseMessageID();
|
|
|
|
void parseRoomID();
|
2017-08-12 13:18:48 +02:00
|
|
|
void appendUsername();
|
2020-09-26 14:21:46 +02:00
|
|
|
|
|
|
|
void runIgnoreReplaces(std::vector<TwitchEmoteOccurence> &twitchEmotes);
|
2017-07-02 18:12:11 +02:00
|
|
|
|
2019-12-01 13:32:41 +01:00
|
|
|
boost::optional<EmotePtr> getTwitchBadge(const Badge &badge);
|
2020-09-26 14:21:46 +02:00
|
|
|
void appendTwitchEmote(const QString &emote,
|
|
|
|
std::vector<TwitchEmoteOccurence> &vec,
|
|
|
|
std::vector<int> &correctPositions);
|
2020-10-04 12:47:23 +02:00
|
|
|
Outcome tryAppendEmote(const EmoteName &name) override;
|
2018-08-02 14:23:27 +02:00
|
|
|
|
2020-09-26 14:21:46 +02:00
|
|
|
void addWords(const QStringList &words,
|
|
|
|
const std::vector<TwitchEmoteOccurence> &twitchEmotes);
|
2020-07-04 15:15:59 +02:00
|
|
|
void addTextOrEmoji(EmotePtr emote) override;
|
|
|
|
void addTextOrEmoji(const QString &value) override;
|
2017-07-02 18:12:11 +02:00
|
|
|
|
2018-01-23 23:28:06 +01:00
|
|
|
void appendTwitchBadges();
|
|
|
|
void appendChatterinoBadges();
|
2020-10-25 10:36:00 +01:00
|
|
|
void appendFfzBadges();
|
2018-08-02 14:23:27 +02:00
|
|
|
Outcome tryParseCheermote(const QString &string);
|
2018-07-06 19:23:47 +02:00
|
|
|
|
2021-08-14 13:06:58 +02:00
|
|
|
bool shouldAddModerationElements() const;
|
|
|
|
|
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-12-19 21:36:02 +01:00
|
|
|
int bitsLeft;
|
2019-12-21 10:36:46 +01:00
|
|
|
bool bitsStacked = false;
|
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
|
|
|
bool senderIsBroadcaster{};
|
2017-04-12 17:46:44 +02:00
|
|
|
};
|
2017-06-07 10:09:24 +02:00
|
|
|
|
|
|
|
} // namespace chatterino
|