Added functionality of /follow and /unfollow
This commit is contained in:
@@ -2,12 +2,15 @@
|
||||
|
||||
#include "Application.hpp"
|
||||
#include "common/SignalVector.hpp"
|
||||
#include "common/UrlFetch.hpp"
|
||||
#include "controllers/accounts/AccountController.hpp"
|
||||
#include "controllers/commands/Command.hpp"
|
||||
#include "controllers/commands/CommandModel.hpp"
|
||||
#include "messages/MessageBuilder.hpp"
|
||||
#include "providers/twitch/TwitchAccount.hpp"
|
||||
#include "providers/twitch/TwitchChannel.hpp"
|
||||
#include "providers/twitch/TwitchServer.hpp"
|
||||
#include "providers/twitch/twitchapi.hpp"
|
||||
#include "singletons/Paths.hpp"
|
||||
#include "singletons/Settings.hpp"
|
||||
#include "widgets/dialogs/LogsPopup.hpp"
|
||||
@@ -203,6 +206,54 @@ QString CommandController::execCommand(const QString &text, ChannelPtr channel,
|
||||
channel->addMessage(Message::createSystemMessage(message));
|
||||
});
|
||||
|
||||
return "";
|
||||
} else if (commandName == "/follow" && words.size() >= 2) {
|
||||
auto app = getApp();
|
||||
|
||||
auto user = app->accounts->twitch.getCurrent();
|
||||
auto target = words.at(1);
|
||||
if (user->isAnon()) {
|
||||
channel->addMessage(
|
||||
Message::createSystemMessage("You must be logged in to follow someone"));
|
||||
|
||||
return "";
|
||||
}
|
||||
TwitchApi::FindUserId(target, [user, channel, target](QString userId) {
|
||||
if (userId.isEmpty()) {
|
||||
channel->addMessage(
|
||||
Message::createSystemMessage("User " + target + " was not found!"));
|
||||
return;
|
||||
}
|
||||
user->followUser(userId, [channel, target]() {
|
||||
channel->addMessage(
|
||||
Message::createSystemMessage("You successfully followed " + target));
|
||||
});
|
||||
});
|
||||
|
||||
return "";
|
||||
} else if (commandName == "/unfollow" && words.size() >= 2) {
|
||||
auto app = getApp();
|
||||
|
||||
auto user = app->accounts->twitch.getCurrent();
|
||||
auto target = words.at(1);
|
||||
if (user->isAnon()) {
|
||||
channel->addMessage(
|
||||
Message::createSystemMessage("You must be logged in to follow someone"));
|
||||
return "";
|
||||
}
|
||||
|
||||
TwitchApi::FindUserId(target, [user, channel, target](QString userId) {
|
||||
if (userId.isEmpty()) {
|
||||
channel->addMessage(
|
||||
Message::createSystemMessage("User " + target + " was not found!"));
|
||||
return;
|
||||
}
|
||||
user->unfollowUser(userId, [channel, target]() {
|
||||
channel->addMessage(
|
||||
Message::createSystemMessage("You successfully unfollowed " + target));
|
||||
});
|
||||
});
|
||||
|
||||
return "";
|
||||
} else if (commandName == "/logs") {
|
||||
if (words.size() < 2) {
|
||||
|
||||
Reference in New Issue
Block a user