From 27dacdde36da044e613f659cfcc62eb2a4b70c23 Mon Sep 17 00:00:00 2001 From: Rasmus Karlsson Date: Thu, 4 Jan 2018 02:32:24 +0100 Subject: [PATCH] Disable empty-string sending Fixes #191 --- src/singletons/ircmanager.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/singletons/ircmanager.cpp b/src/singletons/ircmanager.cpp index e25cb3c76..ad2d03960 100644 --- a/src/singletons/ircmanager.cpp +++ b/src/singletons/ircmanager.cpp @@ -200,14 +200,19 @@ void IrcManager::disconnect() void IrcManager::sendMessage(const QString &channelName, QString message) { + QString trimmedMessage = message.trimmed(); + if (trimmedMessage.isEmpty()) { + return; + } + this->connectionMutex.lock(); static int i = 0; if (this->writeConnection) { if (singletons::SettingManager::getInstance().allowDuplicateMessages && (++i % 2) == 0) { - message.append(this->messageSuffix); + trimmedMessage.append(this->messageSuffix); } - this->writeConnection->sendRaw("PRIVMSG #" + channelName + " :" + message); + this->writeConnection->sendRaw("PRIVMSG #" + channelName + " :" + trimmedMessage); } this->connectionMutex.unlock(); @@ -399,5 +404,5 @@ Communi::IrcConnection *IrcManager::getReadConnection() return this->readConnection.get(); } +} // namespace singletons } // namespace chatterino -}