Merge pull request #1012 from apa420/apa-deleted-messages
Added support for single deleted messages
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 687 B |
@@ -0,0 +1,124 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||||
|
|
||||||
|
<svg
|
||||||
|
xmlns:osb="http://www.openswatchbook.org/uri/2009/osb"
|
||||||
|
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||||
|
xmlns:cc="http://creativecommons.org/ns#"
|
||||||
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||||
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||||
|
width="32mm"
|
||||||
|
height="32mm"
|
||||||
|
viewBox="0 0 32 32"
|
||||||
|
version="1.1"
|
||||||
|
id="svg8"
|
||||||
|
inkscape:export-filename="/home/pajlada/git/chatterino2/resources/buttons/trashcan2.png"
|
||||||
|
inkscape:export-xdpi="50.799999"
|
||||||
|
inkscape:export-ydpi="50.799999"
|
||||||
|
inkscape:version="0.92.4 5da689c313, 2019-01-14"
|
||||||
|
sodipodi:docname="trashcan.svg">
|
||||||
|
<defs
|
||||||
|
id="defs2">
|
||||||
|
<linearGradient
|
||||||
|
inkscape:collect="always"
|
||||||
|
id="linearGradient4536"
|
||||||
|
osb:paint="gradient">
|
||||||
|
<stop
|
||||||
|
style="stop-color:#000000;stop-opacity:1;"
|
||||||
|
offset="0"
|
||||||
|
id="stop4532" />
|
||||||
|
<stop
|
||||||
|
style="stop-color:#000000;stop-opacity:0;"
|
||||||
|
offset="1"
|
||||||
|
id="stop4534" />
|
||||||
|
</linearGradient>
|
||||||
|
</defs>
|
||||||
|
<sodipodi:namedview
|
||||||
|
id="base"
|
||||||
|
pagecolor="#ffffff"
|
||||||
|
bordercolor="#666666"
|
||||||
|
borderopacity="1.0"
|
||||||
|
inkscape:pageopacity="0.0"
|
||||||
|
inkscape:pageshadow="2"
|
||||||
|
inkscape:zoom="5.6"
|
||||||
|
inkscape:cx="58.051498"
|
||||||
|
inkscape:cy="84.215087"
|
||||||
|
inkscape:document-units="mm"
|
||||||
|
inkscape:current-layer="layer1"
|
||||||
|
showgrid="true"
|
||||||
|
inkscape:window-width="1529"
|
||||||
|
inkscape:window-height="1419"
|
||||||
|
inkscape:window-x="2160"
|
||||||
|
inkscape:window-y="2400"
|
||||||
|
inkscape:window-maximized="0">
|
||||||
|
<inkscape:grid
|
||||||
|
type="xygrid"
|
||||||
|
id="grid4818"
|
||||||
|
originx="-74.790005"
|
||||||
|
originy="-199.8473"
|
||||||
|
units="mm"
|
||||||
|
spacingx="1"
|
||||||
|
spacingy="1" />
|
||||||
|
</sodipodi:namedview>
|
||||||
|
<metadata
|
||||||
|
id="metadata5">
|
||||||
|
<rdf:RDF>
|
||||||
|
<cc:Work
|
||||||
|
rdf:about="">
|
||||||
|
<dc:format>image/svg+xml</dc:format>
|
||||||
|
<dc:type
|
||||||
|
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||||
|
<dc:title></dc:title>
|
||||||
|
<cc:license
|
||||||
|
rdf:resource="" />
|
||||||
|
</cc:Work>
|
||||||
|
</rdf:RDF>
|
||||||
|
</metadata>
|
||||||
|
<g
|
||||||
|
inkscape:label="Layer 1"
|
||||||
|
inkscape:groupmode="layer"
|
||||||
|
id="layer1"
|
||||||
|
transform="translate(-74.789996,-65.152683)">
|
||||||
|
<path
|
||||||
|
style="fill:none;stroke:#898395;stroke-width:3.5999999;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||||
|
d="m 82.789996,69.152684 v 25 h 16 v -25"
|
||||||
|
id="path4820"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
sodipodi:nodetypes="cccc" />
|
||||||
|
<path
|
||||||
|
style="fill:none;stroke:#898395;stroke-width:3.6;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||||
|
d="M 102.79,69.152684 H 78.789994"
|
||||||
|
id="path4826"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
sodipodi:nodetypes="cc">
|
||||||
|
<title
|
||||||
|
id="title4970">Trashcan top</title>
|
||||||
|
</path>
|
||||||
|
<path
|
||||||
|
style="fill:none;stroke:#898395;stroke-width:2;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||||
|
d="m 87.789996,74.999984 v 14"
|
||||||
|
id="path4830"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
sodipodi:nodetypes="cc" />
|
||||||
|
<path
|
||||||
|
style="fill:none;stroke:#898395;stroke-width:2;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||||
|
d="m 93.789996,88.999984 v -14"
|
||||||
|
id="path4832"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
sodipodi:nodetypes="cc" />
|
||||||
|
<circle
|
||||||
|
style="fill:#898395;fill-opacity:1;stroke:none;stroke-width:6.75056219;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal"
|
||||||
|
id="path4974"
|
||||||
|
cx="90.789993"
|
||||||
|
cy="67.069061"
|
||||||
|
r="1.75" />
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
inkscape:groupmode="layer"
|
||||||
|
id="layer2"
|
||||||
|
inkscape:label="Layer 2"
|
||||||
|
transform="translate(-74.789996,-65.152683)" />
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 4.1 KiB |
@@ -24,6 +24,7 @@
|
|||||||
<file>buttons/modModeEnabled.png</file>
|
<file>buttons/modModeEnabled.png</file>
|
||||||
<file>buttons/modModeEnabled2.png</file>
|
<file>buttons/modModeEnabled2.png</file>
|
||||||
<file>buttons/timeout.png</file>
|
<file>buttons/timeout.png</file>
|
||||||
|
<file>buttons/trashCan.png</file>
|
||||||
<file>buttons/unban.png</file>
|
<file>buttons/unban.png</file>
|
||||||
<file>buttons/unmod.png</file>
|
<file>buttons/unmod.png</file>
|
||||||
<file>buttons/update.png</file>
|
<file>buttons/update.png</file>
|
||||||
|
|||||||
@@ -264,6 +264,7 @@ void Application::initPubsub()
|
|||||||
auto msg = MessageBuilder(action).release();
|
auto msg = MessageBuilder(action).release();
|
||||||
|
|
||||||
postToThread([chan, msg] { chan->addMessage(msg); });
|
postToThread([chan, msg] { chan->addMessage(msg); });
|
||||||
|
chan->deleteMessage(msg->id);
|
||||||
});
|
});
|
||||||
|
|
||||||
this->twitch.pubsub->start();
|
this->twitch.pubsub->start();
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ Resources2::Resources2()
|
|||||||
this->buttons.modModeEnabled = QPixmap(":/buttons/modModeEnabled.png");
|
this->buttons.modModeEnabled = QPixmap(":/buttons/modModeEnabled.png");
|
||||||
this->buttons.modModeEnabled2 = QPixmap(":/buttons/modModeEnabled2.png");
|
this->buttons.modModeEnabled2 = QPixmap(":/buttons/modModeEnabled2.png");
|
||||||
this->buttons.timeout = QPixmap(":/buttons/timeout.png");
|
this->buttons.timeout = QPixmap(":/buttons/timeout.png");
|
||||||
|
this->buttons.trashCan = QPixmap(":/buttons/trashCan.png");
|
||||||
this->buttons.unban = QPixmap(":/buttons/unban.png");
|
this->buttons.unban = QPixmap(":/buttons/unban.png");
|
||||||
this->buttons.unmod = QPixmap(":/buttons/unmod.png");
|
this->buttons.unmod = QPixmap(":/buttons/unmod.png");
|
||||||
this->buttons.update = QPixmap(":/buttons/update.png");
|
this->buttons.update = QPixmap(":/buttons/update.png");
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ public:
|
|||||||
QPixmap modModeEnabled;
|
QPixmap modModeEnabled;
|
||||||
QPixmap modModeEnabled2;
|
QPixmap modModeEnabled2;
|
||||||
QPixmap timeout;
|
QPixmap timeout;
|
||||||
|
QPixmap trashCan;
|
||||||
QPixmap unban;
|
QPixmap unban;
|
||||||
QPixmap unmod;
|
QPixmap unmod;
|
||||||
QPixmap update;
|
QPixmap update;
|
||||||
|
|||||||
@@ -212,6 +212,25 @@ void Channel::replaceMessage(MessagePtr message, MessagePtr replacement)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Channel::deleteMessage(QString messageID)
|
||||||
|
{
|
||||||
|
LimitedQueueSnapshot<MessagePtr> snapshot = this->getMessageSnapshot();
|
||||||
|
int snapshotLength = snapshot.size();
|
||||||
|
|
||||||
|
int end = std::max(0, snapshotLength - 200);
|
||||||
|
|
||||||
|
for (int i = snapshotLength - 1; i >= end; --i)
|
||||||
|
{
|
||||||
|
auto &s = snapshot[i];
|
||||||
|
|
||||||
|
if (s->id == messageID)
|
||||||
|
{
|
||||||
|
s->flags.set(MessageFlag::Disabled);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Channel::addRecentChatter(const MessagePtr &message)
|
void Channel::addRecentChatter(const MessagePtr &message)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ public:
|
|||||||
void addOrReplaceTimeout(MessagePtr message);
|
void addOrReplaceTimeout(MessagePtr message);
|
||||||
void disableAllMessages();
|
void disableAllMessages();
|
||||||
void replaceMessage(MessagePtr message, MessagePtr replacement);
|
void replaceMessage(MessagePtr message, MessagePtr replacement);
|
||||||
|
void deleteMessage(QString messageID);
|
||||||
|
|
||||||
QStringList modList;
|
QStringList modList;
|
||||||
|
|
||||||
|
|||||||
@@ -73,6 +73,10 @@ ModerationAction::ModerationAction(const QString &action)
|
|||||||
{
|
{
|
||||||
this->image_ = Image::fromPixmap(getApp()->resources->buttons.ban);
|
this->image_ = Image::fromPixmap(getApp()->resources->buttons.ban);
|
||||||
}
|
}
|
||||||
|
else if (action.startsWith("/delete"))
|
||||||
|
{
|
||||||
|
this->image_ = Image::fromPixmap(getApp()->resources->buttons.trashCan);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QString xD = action;
|
QString xD = action;
|
||||||
|
|||||||
@@ -266,6 +266,41 @@ void IrcMessageHandler::handleClearChatMessage(Communi::IrcMessage *message)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void IrcMessageHandler::handleClearMessageMessage(Communi::IrcMessage *message)
|
||||||
|
{
|
||||||
|
// check parameter count
|
||||||
|
if (message->parameters().length() < 1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString chanName;
|
||||||
|
if (!trimChannelName(message->parameter(0), chanName))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto app = getApp();
|
||||||
|
|
||||||
|
// get channel
|
||||||
|
auto chan = app->twitch.server->getChannelOrEmpty(chanName);
|
||||||
|
|
||||||
|
if (chan->isEmpty())
|
||||||
|
{
|
||||||
|
log("[IrcMessageHandler:handleClearMessageMessage] Twitch channel {} "
|
||||||
|
"not "
|
||||||
|
"found",
|
||||||
|
chanName);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto tags = message->tags();
|
||||||
|
|
||||||
|
QString targetID = tags.value("target-msg-id").toString();
|
||||||
|
|
||||||
|
chan->deleteMessage(targetID);
|
||||||
|
}
|
||||||
|
|
||||||
void IrcMessageHandler::handleUserStateMessage(Communi::IrcMessage *message)
|
void IrcMessageHandler::handleUserStateMessage(Communi::IrcMessage *message)
|
||||||
{
|
{
|
||||||
auto app = getApp();
|
auto app = getApp();
|
||||||
@@ -516,7 +551,17 @@ void IrcMessageHandler::handleNoticeMessage(Communi::IrcNoticeMessage *message)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
channel->addMessage(msg);
|
QString tags = message->tags().value("msg-id", "").toString();
|
||||||
|
if (tags == "bad_delete_message_error" || tags == "usage_delete")
|
||||||
|
{
|
||||||
|
channel->addMessage(makeSystemMessage(
|
||||||
|
"Usage: \"/delete <msg-id>\" - can't take more "
|
||||||
|
"than one argument"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
channel->addMessage(msg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ public:
|
|||||||
|
|
||||||
void handleRoomStateMessage(Communi::IrcMessage *message);
|
void handleRoomStateMessage(Communi::IrcMessage *message);
|
||||||
void handleClearChatMessage(Communi::IrcMessage *message);
|
void handleClearChatMessage(Communi::IrcMessage *message);
|
||||||
|
void handleClearMessageMessage(Communi::IrcMessage *message);
|
||||||
void handleUserStateMessage(Communi::IrcMessage *message);
|
void handleUserStateMessage(Communi::IrcMessage *message);
|
||||||
void handleWhisperMessage(Communi::IrcMessage *message);
|
void handleWhisperMessage(Communi::IrcMessage *message);
|
||||||
|
|
||||||
|
|||||||
@@ -580,7 +580,7 @@ void TwitchMessageBuilder::parseMessageID()
|
|||||||
|
|
||||||
if (iterator != this->tags.end())
|
if (iterator != this->tags.end())
|
||||||
{
|
{
|
||||||
this->messageID = iterator.value().toString();
|
this->message().id = iterator.value().toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -607,7 +607,7 @@ void TwitchMessageBuilder::parseRoomID()
|
|||||||
void TwitchMessageBuilder::appendChannelName()
|
void TwitchMessageBuilder::appendChannelName()
|
||||||
{
|
{
|
||||||
QString channelName("#" + this->channel->getName());
|
QString channelName("#" + this->channel->getName());
|
||||||
Link link(Link::Url, this->channel->getName() + "\n" + this->messageID);
|
Link link(Link::Url, this->channel->getName() + "\n" + this->message().id);
|
||||||
|
|
||||||
this->emplace<TextElement>(channelName, MessageElementFlag::ChannelName,
|
this->emplace<TextElement>(channelName, MessageElementFlag::ChannelName,
|
||||||
MessageColor::System) //
|
MessageColor::System) //
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ public:
|
|||||||
MessageParseArgs args;
|
MessageParseArgs args;
|
||||||
const QVariantMap tags;
|
const QVariantMap tags;
|
||||||
|
|
||||||
QString messageID;
|
|
||||||
QString userName;
|
QString userName;
|
||||||
|
|
||||||
bool isIgnored() const;
|
bool isIgnored() const;
|
||||||
@@ -55,8 +54,10 @@ private:
|
|||||||
void appendUsername();
|
void appendUsername();
|
||||||
void parseHighlights(bool isPastMsg);
|
void parseHighlights(bool isPastMsg);
|
||||||
|
|
||||||
void appendTwitchEmote(const QString &emote,
|
void appendTwitchEmote(
|
||||||
std::vector<std::tuple<int, EmotePtr, EmoteName>> &vec, std::vector<int> &correctPositions);
|
const QString &emote,
|
||||||
|
std::vector<std::tuple<int, EmotePtr, EmoteName>> &vec,
|
||||||
|
std::vector<int> &correctPositions);
|
||||||
Outcome tryAppendEmote(const EmoteName &name);
|
Outcome tryAppendEmote(const EmoteName &name);
|
||||||
|
|
||||||
void addWords(
|
void addWords(
|
||||||
|
|||||||
@@ -156,6 +156,10 @@ void TwitchServer::messageReceived(Communi::IrcMessage *message)
|
|||||||
{
|
{
|
||||||
handler.handleClearChatMessage(message);
|
handler.handleClearChatMessage(message);
|
||||||
}
|
}
|
||||||
|
else if (command == "CLEARMSG")
|
||||||
|
{
|
||||||
|
handler.handleClearMessageMessage(message);
|
||||||
|
}
|
||||||
else if (command == "USERSTATE")
|
else if (command == "USERSTATE")
|
||||||
{
|
{
|
||||||
handler.handleUserStateMessage(message);
|
handler.handleUserStateMessage(message);
|
||||||
|
|||||||
@@ -1667,7 +1667,9 @@ void ChannelView::handleLinkClick(QMouseEvent *event, const Link &link,
|
|||||||
case Link::UserAction:
|
case Link::UserAction:
|
||||||
{
|
{
|
||||||
QString value = link.value;
|
QString value = link.value;
|
||||||
value.replace("{user}", layout->getMessage()->loginName).replace("{channel}", this->channel_->getName());
|
value.replace("{user}", layout->getMessage()->loginName)
|
||||||
|
.replace("{channel}", this->channel_->getName())
|
||||||
|
.replace("{msg-id}", layout->getMessage()->id);
|
||||||
this->channel_->sendMessage(value);
|
this->channel_->sendMessage(value);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -161,7 +161,8 @@ ModerationPage::ModerationPage()
|
|||||||
// clang-format off
|
// clang-format off
|
||||||
auto label = modMode.emplace<QLabel>(
|
auto label = modMode.emplace<QLabel>(
|
||||||
"Moderation mode is enabled by clicking <img width='18' height='18' src=':/buttons/modModeDisabled.png'> in a channel that you moderate.<br><br>"
|
"Moderation mode is enabled by clicking <img width='18' height='18' src=':/buttons/modModeDisabled.png'> in a channel that you moderate.<br><br>"
|
||||||
"Moderation buttons can be bound to chat commands such as \"/ban {user}\", \"/timeout {user} 1000\", \"/w someusername !report {user} was bad in channel {channel}\" or any other custom text commands.<br>");
|
"Moderation buttons can be bound to chat commands such as \"/ban {user}\", \"/timeout {user} 1000\", \"/w someusername !report {user} was bad in channel {channel}\" or any other custom text commands.<br>"
|
||||||
|
"For deleting messages use /delete {msg-id}.");
|
||||||
label->setWordWrap(true);
|
label->setWordWrap(true);
|
||||||
label->setStyleSheet("color: #bbb");
|
label->setStyleSheet("color: #bbb");
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|||||||
Reference in New Issue
Block a user