From ba99d6213993ae166642a18231c8ed4a54cf5a52 Mon Sep 17 00:00:00 2001 From: apa420 <17131426+apa420@users.noreply.github.com> Date: Fri, 13 Jul 2018 22:23:03 +0200 Subject: [PATCH] Fixed /ignore and /unignore as well as give description for the command (#611) * Fixed /ignore and /unignore as well as give description for the command --- src/controllers/commands/CommandController.cpp | 13 ++++++++++--- src/providers/twitch/TwitchAccount.cpp | 5 ++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/controllers/commands/CommandController.cpp b/src/controllers/commands/CommandController.cpp index 595643ccd..9d43a0d96 100644 --- a/src/controllers/commands/CommandController.cpp +++ b/src/controllers/commands/CommandController.cpp @@ -6,7 +6,6 @@ #include "controllers/commands/Command.hpp" #include "controllers/commands/CommandModel.hpp" #include "messages/MessageBuilder.hpp" -#include "providers/twitch/TwitchAccount.hpp" #include "providers/twitch/TwitchApi.hpp" #include "providers/twitch/TwitchChannel.hpp" #include "providers/twitch/TwitchServer.hpp" @@ -172,7 +171,11 @@ QString CommandController::execCommand(const QString &text, ChannelPtr channel, channel->addMessage(Message::createSystemMessage(messageText)); return ""; - } else if (commandName == "/ignore" && words.size() >= 2) { + } else if (commandName == "/ignore") { + if (words.size() < 2) { + channel->addMessage(Message::createSystemMessage("Usage: /ignore [user]")); + return ""; + } auto app = getApp(); auto user = app->accounts->twitch.getCurrent(); @@ -189,7 +192,11 @@ QString CommandController::execCommand(const QString &text, ChannelPtr channel, }); return ""; - } else if (commandName == "/unignore" && words.size() >= 2) { + } else if (commandName == "/unignore") { + if (words.size() < 2) { + channel->addMessage(Message::createSystemMessage("Usage: /unignore [user]")); + return ""; + } auto app = getApp(); auto user = app->accounts->twitch.getCurrent(); diff --git a/src/providers/twitch/TwitchAccount.cpp b/src/providers/twitch/TwitchAccount.cpp index 785f159e5..695bc369f 100644 --- a/src/providers/twitch/TwitchAccount.cpp +++ b/src/providers/twitch/TwitchAccount.cpp @@ -130,7 +130,7 @@ void TwitchAccount::ignore(const QString &targetName, this->ignoreByID(targetUserId, targetName, onFinished); // }; - PartialTwitchUser::byName(this->userName_).getId(onIdFetched); + PartialTwitchUser::byName(targetName).getId(onIdFetched); } void TwitchAccount::ignoreByID(const QString &targetUserID, const QString &targetName, @@ -138,7 +138,6 @@ void TwitchAccount::ignoreByID(const QString &targetUserID, const QString &targe { QString url("https://api.twitch.tv/kraken/users/" + this->getUserId() + "/blocks/" + targetUserID); - NetworkRequest req(url, NetworkRequestType::Put); req.setCaller(QThread::currentThread()); req.makeAuthorizedV5(this->getOAuthClient(), this->getOAuthToken()); @@ -197,7 +196,7 @@ void TwitchAccount::unignore(const QString &targetName, this->unignoreByID(targetUserId, targetName, onFinished); // }; - PartialTwitchUser::byName(this->userName_).getId(onIdFetched); + PartialTwitchUser::byName(targetName).getId(onIdFetched); } void TwitchAccount::unignoreByID(