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

110 lines
3.6 KiB
C++
Raw Normal View History

#pragma once
2017-04-12 17:46:44 +02:00
#include "common/Aliases.hpp"
#include "common/Outcome.hpp"
#include "messages/SharedMessageBuilder.hpp"
#include "providers/twitch/ChannelPointReward.hpp"
#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>
#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
struct TwitchEmoteOccurence {
int start;
int end;
EmotePtr ptr;
EmoteName name;
};
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,
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
TwitchChannel *twitchChannel;
2017-07-02 18:12:11 +02:00
[[nodiscard]] bool isIgnored() const override;
void triggerHighlights() override;
MessagePtr build() override;
2017-04-12 17:46:44 +02:00
static void appendChannelPointRewardMessage(
const ChannelPointReward &reward, MessageBuilder *builder, bool isMod,
bool isBroadcaster);
// Message in the /live chat for channel going live
static void liveMessage(const QString &channelName,
MessageBuilder *builder);
// Messages in normal chat for channel stuff
static void liveSystemMessage(const QString &channelName,
MessageBuilder *builder);
static void offlineSystemMessage(const QString &channelName,
MessageBuilder *builder);
static void hostingSystemMessage(const QString &channelName,
MessageBuilder *builder, bool hostOn);
static void deletionMessage(const MessagePtr originalMessage,
MessageBuilder *builder);
static void deletionMessage(const DeleteAction &action,
MessageBuilder *builder);
static void listOfUsersSystemMessage(QString prefix, QStringList users,
Channel *channel,
MessageBuilder *builder);
private:
void parseUsernameColor() override;
void parseUsername() override;
2017-07-02 18:12:11 +02:00
void parseMessageID();
void parseRoomID();
void appendUsername();
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);
void appendTwitchEmote(const QString &emote,
std::vector<TwitchEmoteOccurence> &vec,
std::vector<int> &correctPositions);
Outcome tryAppendEmote(const EmoteName &name) override;
2018-08-02 14:23:27 +02:00
void addWords(const QStringList &words,
const std::vector<TwitchEmoteOccurence> &twitchEmotes);
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();
void appendFfzBadges();
2018-08-02 14:23:27 +02:00
Outcome tryParseCheermote(const QString &string);
2018-07-06 19:23:47 +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;
QString bits;
int bitsLeft;
2019-12-21 10:36:46 +01:00
bool bitsStacked = false;
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
};
} // namespace chatterino