fix comments

This commit is contained in:
hemirt
2019-05-07 20:21:08 +02:00
committed by pajlada
parent 4f5e3f6a27
commit 411502de44
+16 -10
View File
@@ -35,13 +35,17 @@
namespace { namespace {
using namespace chatterino; using namespace chatterino;
static const QStringList whisperCommands{"/w", ".w"};
void sendWhisperMessage(const QString &text) void sendWhisperMessage(const QString &text)
{ {
// (hemirt) pajlada: "we should not be sending whispers through jtv, but
// rather to your own username"
auto app = getApp(); auto app = getApp();
app->twitch.server->sendMessage("jtv", text.simplified()); app->twitch.server->sendMessage("jtv", text.simplified());
} }
bool appendWhisperMessageLocally(const QStringList &words) bool appendWhisperMessageWordsLocally(const QStringList &words)
{ {
auto app = getApp(); auto app = getApp();
@@ -139,7 +143,7 @@ bool appendWhisperMessageLocally(const QStringList &words)
return true; return true;
} }
bool appendWhisperMessageLocally(const QString &textNoEmoji) bool appendWhisperMessageStringLocally(const QString &textNoEmoji)
{ {
QString text = getApp()->emotes->emojis.replaceShortCodes(textNoEmoji); QString text = getApp()->emotes->emojis.replaceShortCodes(textNoEmoji);
QStringList words = text.split(' ', QString::SkipEmptyParts); QStringList words = text.split(' ', QString::SkipEmptyParts);
@@ -151,11 +155,11 @@ bool appendWhisperMessageLocally(const QString &textNoEmoji)
QString commandName = words[0]; QString commandName = words[0];
if (commandName == "/w") if (whisperCommands.contains(commandName, Qt::CaseInsensitive))
{ {
if (words.length() > 2) if (words.length() > 2)
{ {
return appendWhisperMessageLocally(words); return appendWhisperMessageWordsLocally(words);
} }
} }
return false; return false;
@@ -253,11 +257,11 @@ QString CommandController::execCommand(const QString &textNoEmoji,
// works in a valid twitch channel and /whispers, etc... // works in a valid twitch channel and /whispers, etc...
if (!dryRun && channel->isTwitchChannel()) if (!dryRun && channel->isTwitchChannel())
{ {
if (commandName == "/w") if (whisperCommands.contains(commandName, Qt::CaseInsensitive))
{ {
if (words.length() > 2) if (words.length() > 2)
{ {
appendWhisperMessageLocally(words); appendWhisperMessageWordsLocally(words);
sendWhisperMessage(text); sendWhisperMessage(text);
} }
@@ -556,13 +560,15 @@ QString CommandController::execCustomCommand(const QStringList &words,
auto res = result.replace("{{", "{"); auto res = result.replace("{{", "{");
if (dryRun) if (dryRun || !appendWhisperMessageStringLocally(res))
{ {
return res; return res;
} }
else
return appendWhisperMessageLocally(res) ? (sendWhisperMessage(res), "") {
: res; sendWhisperMessage(res);
return "";
}
} }
QStringList CommandController::getDefaultTwitchCommandList() QStringList CommandController::getDefaultTwitchCommandList()