mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
Make /delete
errors a bit more verbose (#3350)
Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
This commit is contained in:
parent
1ca3dfde7f
commit
a68980878e
|
@ -31,6 +31,7 @@
|
|||
- Minor: Clean up chat messages of special line characters prior to sending. (#3312)
|
||||
- Minor: IRC now parses/displays links like Twitch chat. (#3334)
|
||||
- Minor: Added button & label for copying login name of user instead of display name in the user info popout. (#3335)
|
||||
- Minor: Make `/delete` errors a bit more verbose (#3350)
|
||||
- Bugfix: Fixed colored usernames sometimes not working. (#3170)
|
||||
- Bugfix: Restored ability to send duplicate `/me` messages. (#3166)
|
||||
- Bugfix: Notifications for moderators about other moderators deleting messages can now be disabled. (#3121)
|
||||
|
|
|
@ -866,6 +866,43 @@ void CommandController::initialize(Settings &, Paths &paths)
|
|||
|
||||
return "";
|
||||
});
|
||||
this->registerCommand(
|
||||
"/delete", [](const QStringList &words, ChannelPtr channel) -> QString {
|
||||
// This is a wrapper over the standard Twitch /delete command
|
||||
// We use this to ensure the user gets better error messages for missing or malformed arguments
|
||||
if (words.size() < 2)
|
||||
{
|
||||
channel->addMessage(
|
||||
makeSystemMessage("Usage: /delete <msg-id> - Deletes the "
|
||||
"specified message."));
|
||||
return "";
|
||||
}
|
||||
|
||||
auto messageID = words.at(1);
|
||||
auto uuid = QUuid(messageID);
|
||||
if (uuid.isNull())
|
||||
{
|
||||
// The message id must be a valid UUID
|
||||
channel->addMessage(makeSystemMessage(
|
||||
QString("Invalid msg-id: \"%1\"").arg(messageID)));
|
||||
return "";
|
||||
}
|
||||
|
||||
auto msg = channel->findMessage(messageID);
|
||||
if (msg != nullptr)
|
||||
{
|
||||
if (msg->loginName == channel->getName() &&
|
||||
!channel->isBroadcaster())
|
||||
{
|
||||
channel->addMessage(makeSystemMessage(
|
||||
"You cannot delete the broadcaster's messages unless "
|
||||
"you are the broadcaster."));
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
return QString("/delete ") + messageID;
|
||||
});
|
||||
|
||||
this->registerCommand("/raw", [](const QStringList &words, ChannelPtr) {
|
||||
getApp()->twitch2->sendRawMessage(words.mid(1).join(" "));
|
||||
|
|
|
@ -807,10 +807,17 @@ void IrcMessageHandler::handleNoticeMessage(Communi::IrcNoticeMessage *message)
|
|||
}
|
||||
|
||||
QString tags = message->tags().value("msg-id").toString();
|
||||
if (tags == "bad_delete_message_error" || tags == "usage_delete")
|
||||
if (tags == "usage_delete")
|
||||
{
|
||||
channel->addMessage(makeSystemMessage(
|
||||
"Usage: /delete <msg-id>. Can't take more than one argument"));
|
||||
"Usage: /delete <msg-id> - Deletes the specified message. "
|
||||
"Can't take more than one argument."));
|
||||
}
|
||||
else if (tags == "bad_delete_message_error")
|
||||
{
|
||||
channel->addMessage(makeSystemMessage(
|
||||
"There was a problem deleting the message. "
|
||||
"It might be from another channel or too old to delete."));
|
||||
}
|
||||
else if (tags == "host_on" || tags == "host_target_went_offline")
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue