mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
Add text command to display logs (#574)
* Add text command to display logs * Allow @username instead of username
This commit is contained in:
parent
0496c6a242
commit
b12c4e1d45
1 changed files with 34 additions and 0 deletions
|
@ -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 "";
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue