From b12c4e1d454621d14d09b2bf11e62df68adade8c Mon Sep 17 00:00:00 2001 From: DatGuy1 Date: Sat, 7 Jul 2018 11:25:12 +0300 Subject: [PATCH] Add text command to display logs (#574) * Add text command to display logs * Allow @username instead of username --- .../commands/CommandController.cpp | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/controllers/commands/CommandController.cpp b/src/controllers/commands/CommandController.cpp index fa8119037..f86506493 100644 --- a/src/controllers/commands/CommandController.cpp +++ b/src/controllers/commands/CommandController.cpp @@ -10,6 +10,7 @@ #include "providers/twitch/TwitchServer.hpp" #include "singletons/Paths.hpp" #include "singletons/Settings.hpp" +#include "widgets/dialogs/LogsPopup.hpp" #include #include @@ -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 ""; } }