Add text command to display logs (#574)

* Add text command to display logs

* Allow @username instead of username
This commit is contained in:
DatGuy1 2018-07-07 11:25:12 +03:00 committed by fourtf
parent 0496c6a242
commit b12c4e1d45

View file

@ -10,6 +10,7 @@
#include "providers/twitch/TwitchServer.hpp"
#include "singletons/Paths.hpp"
#include "singletons/Settings.hpp"
#include "widgets/dialogs/LogsPopup.hpp"
#include <QApplication>
#include <QFile>
@ -197,6 +198,39 @@ QString CommandController::execCommand(const QString &text, ChannelPtr channel,
channel->addMessage(Message::createSystemMessage(message));
});
return "";
} else if (commandName == "/logs") {
if (words.size() < 2) {
channel->addMessage(
Message::createSystemMessage("Usage: /logs [user] (channel)"));
return "";
}
auto app = getApp();
auto logs = new LogsPopup();
QString target;
if (words.at(1).at(0) == "@") {
target = words.at(1).mid(1);
} else {
target = words.at(1);
}
if (words.size() == 3) {
QString channelName = words.at(2);
if (words.at(2).at(0) == "#") {
channelName = words.at(2).mid(1);
}
auto logsChannel = app->twitch.server->getChannelOrEmpty(channelName);
if (logsChannel == nullptr) {
} else {
logs->setInfo(logsChannel, target);
}
} else {
logs->setInfo(channel, target);
}
logs->setAttribute(Qt::WA_DeleteOnClose);
logs->show();
return "";
}
}