mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
Added deleted messages, will also add the disabled tag to denied automod messages
This commit is contained in:
parent
4cf656fe62
commit
4f79d6fc07
10 changed files with 78 additions and 1 deletions
|
@ -264,6 +264,7 @@ void Application::initPubsub()
|
|||
auto msg = MessageBuilder(action).release();
|
||||
|
||||
postToThread([chan, msg] { chan->addMessage(msg); });
|
||||
chan->deleteMessage(msg->id);
|
||||
});
|
||||
|
||||
this->twitch.pubsub->start();
|
||||
|
|
|
@ -212,6 +212,31 @@ 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 - 20);
|
||||
|
||||
QTime minimumTime = QTime::currentTime().addSecs(-5);
|
||||
for (int i = snapshotLength - 1; i >= end; --i)
|
||||
{
|
||||
auto &s = snapshot[i];
|
||||
|
||||
if (s->parseTime < minimumTime)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (s->id == messageID)
|
||||
{
|
||||
s->flags.set(MessageFlag::Disabled);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Channel::addRecentChatter(const MessagePtr &message)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -62,6 +62,7 @@ public:
|
|||
void addOrReplaceTimeout(MessagePtr message);
|
||||
void disableAllMessages();
|
||||
void replaceMessage(MessagePtr message, MessagePtr replacement);
|
||||
void deleteMessage(QString messageID);
|
||||
|
||||
QStringList modList;
|
||||
|
||||
|
|
|
@ -73,6 +73,10 @@ ModerationAction::ModerationAction(const QString &action)
|
|||
{
|
||||
this->image_ = Image::fromPixmap(getApp()->resources->buttons.ban);
|
||||
}
|
||||
else if (action.startsWith("/delete"))
|
||||
{
|
||||
this->image_ = Image::fromPixmap(getApp()->resources->pajaDank);
|
||||
}
|
||||
else
|
||||
{
|
||||
QString xD = action;
|
||||
|
|
|
@ -267,6 +267,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)
|
||||
{
|
||||
auto app = getApp();
|
||||
|
|
|
@ -27,6 +27,7 @@ public:
|
|||
|
||||
void handleRoomStateMessage(Communi::IrcMessage *message);
|
||||
void handleClearChatMessage(Communi::IrcMessage *message);
|
||||
void handleClearMessageMessage(Communi::IrcMessage *message);
|
||||
void handleUserStateMessage(Communi::IrcMessage *message);
|
||||
void handleWhisperMessage(Communi::IrcMessage *message);
|
||||
|
||||
|
|
|
@ -710,6 +710,9 @@ PubSub::PubSub()
|
|||
// qDebug() << QString::fromStdString(rj::stringify(data));
|
||||
};
|
||||
|
||||
this->moderationActionHandlers["delete"] =
|
||||
[this](const auto &data, const auto &roomID) { qDebug() << "xd"; };
|
||||
|
||||
this->websocketClient.set_access_channels(websocketpp::log::alevel::all);
|
||||
this->websocketClient.clear_access_channels(
|
||||
websocketpp::log::alevel::frame_payload);
|
||||
|
|
|
@ -582,6 +582,7 @@ void TwitchMessageBuilder::parseMessageID()
|
|||
{
|
||||
this->messageID = iterator.value().toString();
|
||||
}
|
||||
this->message().id = this->messageID;
|
||||
}
|
||||
|
||||
void TwitchMessageBuilder::parseRoomID()
|
||||
|
|
|
@ -156,6 +156,10 @@ void TwitchServer::messageReceived(Communi::IrcMessage *message)
|
|||
{
|
||||
handler.handleClearChatMessage(message);
|
||||
}
|
||||
else if (command == "CLEARMSG")
|
||||
{
|
||||
handler.handleClearMessageMessage(message);
|
||||
}
|
||||
else if (command == "USERSTATE")
|
||||
{
|
||||
handler.handleUserStateMessage(message);
|
||||
|
|
|
@ -1667,7 +1667,9 @@ void ChannelView::handleLinkClick(QMouseEvent *event, const Link &link,
|
|||
case Link::UserAction:
|
||||
{
|
||||
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);
|
||||
}
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue