diff --git a/src/ircmanager.cpp b/src/ircmanager.cpp index 7c93d2130..8e7472ba0 100644 --- a/src/ircmanager.cpp +++ b/src/ircmanager.cpp @@ -6,6 +6,7 @@ #include "debug/log.hpp" #include "emotemanager.hpp" #include "messages/messageparseargs.hpp" +#include "settingsmanager.hpp" #include "twitch/twitchmessagebuilder.hpp" #include "twitch/twitchparsemessage.hpp" #include "twitch/twitchuser.hpp" @@ -31,6 +32,9 @@ IrcManager::IrcManager(ChannelManager &_channelManager, Resources &_resources, , resources(_resources) , windowManager(_windowManager) { + this->messageSuffix.append(' '); + this->messageSuffix.append(QChar(0x206D)); + AccountManager::getInstance().Twitch.userChanged.connect([this]() { this->setUser(AccountManager::getInstance().Twitch.getCurrent()); @@ -177,11 +181,15 @@ void IrcManager::disconnect() this->writeConnection->close(); } -void IrcManager::sendMessage(const QString &channelName, const QString &message) +void IrcManager::sendMessage(const QString &channelName, QString message) { this->connectionMutex.lock(); + static int i = 0; if (this->writeConnection) { + if (SettingsManager::getInstance().allowDuplicateMessages && (++i % 2) == 0) { + message.append(this->messageSuffix); + } this->writeConnection->sendRaw("PRIVMSG #" + channelName + " :" + message); } diff --git a/src/ircmanager.hpp b/src/ircmanager.hpp index 00bc298dc..01f952660 100644 --- a/src/ircmanager.hpp +++ b/src/ircmanager.hpp @@ -38,7 +38,7 @@ public: bool tryRemoveIgnoredUser(QString const &username, QString &errorMessage); void removeIgnoredUser(QString const &username); - void sendMessage(const QString &channelName, const QString &message); + void sendMessage(const QString &channelName, QString message); void joinChannel(const QString &channelName); void partChannel(const QString &channelName); @@ -89,6 +89,9 @@ private: void onConnected(); void onDisconnected(); + +private: + QByteArray messageSuffix; }; } // namespace chatterino