#pragma once #include "messages/Message.hpp" #include #include namespace chatterino { struct SystemMessageTag { }; struct TimeoutMessageTag { }; const SystemMessageTag systemMessage{}; const TimeoutMessageTag timeoutMessage{}; MessagePtr makeSystemMessage(const QString &text); class MessageBuilder { public: MessageBuilder(); MessageBuilder(const QString &text); MessageBuilder(SystemMessageTag, const QString &text); MessageBuilder(TimeoutMessageTag, const QString &username, const QString &durationInSeconds, const QString &reason, bool multipleTimes); MessageBuilder(const BanAction &action, uint32_t count = 1); MessageBuilder(const UnbanAction &action); Message *operator->(); Message &message(); MessagePtr release(); void append(std::unique_ptr element); QString matchLink(const QString &string); template T *emplace(Args &&... args) { static_assert(std::is_base_of::value, "T must extend MessageElement"); auto unique = std::make_unique(std::forward(args)...); auto pointer = unique.get(); this->append(std::move(unique)); return pointer; } private: std::unique_ptr message_; }; } // namespace chatterino