diff --git a/src/singletons/ircmanager.cpp b/src/singletons/ircmanager.cpp index 5ed5d2fdc..d14530765 100644 --- a/src/singletons/ircmanager.cpp +++ b/src/singletons/ircmanager.cpp @@ -34,9 +34,6 @@ IrcManager::IrcManager(ChannelManager &_channelManager, ResourceManager &_resour , resources(_resources) , accountManager(_accountManager) { - this->messageSuffix.append(' '); - this->messageSuffix.append(QChar(0x206D)); - this->account = accountManager.Twitch.getCurrent(); accountManager.Twitch.userChanged.connect([this]() { this->setUser(accountManager.Twitch.getCurrent()); @@ -208,12 +205,8 @@ void IrcManager::sendMessage(const QString &channelName, QString message) } this->connectionMutex.lock(); - static int i = 0; if (this->writeConnection) { - if (singletons::SettingManager::getInstance().allowDuplicateMessages && (++i % 2) == 0) { - trimmedMessage.append(this->messageSuffix); - } this->writeConnection->sendRaw("PRIVMSG #" + channelName + " :" + trimmedMessage); } diff --git a/src/singletons/ircmanager.hpp b/src/singletons/ircmanager.hpp index 8153d10be..da85f2d30 100644 --- a/src/singletons/ircmanager.hpp +++ b/src/singletons/ircmanager.hpp @@ -89,9 +89,6 @@ private: void onConnected(); void onDisconnected(); - -private: - QByteArray messageSuffix; }; } // namespace singletons diff --git a/src/twitch/twitchchannel.cpp b/src/twitch/twitchchannel.cpp index d78537665..96ca281e3 100644 --- a/src/twitch/twitchchannel.cpp +++ b/src/twitch/twitchchannel.cpp @@ -41,6 +41,9 @@ TwitchChannel::TwitchChannel(const QString &channelName) this->connectedConnection = singletons::IrcManager::getInstance().connected.connect( [this] { this->userStateChanged(); }); + + this->messageSuffix.append(' '); + this->messageSuffix.append(QChar(0x206D)); } TwitchChannel::~TwitchChannel() @@ -87,6 +90,19 @@ void TwitchChannel::sendMessage(const QString &message) // Do last message processing QString parsedMessage = emoteManager.replaceShortCodes(message); + parsedMessage = parsedMessage.trimmed(); + + if (parsedMessage.isEmpty()) + return; + + if (singletons::SettingManager::getInstance().allowDuplicateMessages) { + if (parsedMessage == this->lastSentMessage) { + parsedMessage.append(this->messageSuffix); + + this->lastSentMessage = ""; + } + } + singletons::IrcManager::getInstance().sendMessage(this->name, parsedMessage); } @@ -228,6 +244,5 @@ void TwitchChannel::fetchRecentMessages() } }); } - } // namespace twitch } // namespace chatterino diff --git a/src/twitch/twitchchannel.hpp b/src/twitch/twitchchannel.hpp index 2c5f49058..18f1e0652 100644 --- a/src/twitch/twitchchannel.hpp +++ b/src/twitch/twitchchannel.hpp @@ -57,6 +57,8 @@ private: boost::signals2::connection connectedConnection; bool mod; + QByteArray messageSuffix; + QString lastSentMessage; }; } // namespace twitch