smol commit, idk if I will continue this

This commit is contained in:
apa420 2019-01-20 17:03:45 +01:00
parent e9bd9ddb8e
commit cd5c373e01
4 changed files with 28 additions and 14 deletions

View file

@ -117,4 +117,12 @@ struct AutomodAction : PubSubAction {
QString msgID; QString msgID;
}; };
struct AutomodUserAction : PubSubAction {
using PubSubAction::PubSubAction;
ActionUser target;
QString message;
};
} // namespace chatterino } // namespace chatterino

View file

@ -577,40 +577,50 @@ PubSub::PubSub()
this->moderationActionHandlers["denied_automod_message"] = this->moderationActionHandlers["denied_automod_message"] =
[this](const auto &data, const auto &roomID) { [this](const auto &data, const auto &roomID) {
// This message got denied by a moderator // This message got denied by a moderator
AutomodUserAction action(data, roomID);
getCreatedByUser(data, action.source);
qDebug() << "test2222"; qDebug() << "test2222";
qDebug() << QString::fromStdString(rj::stringify(data));
}; };
this->moderationActionHandlers["add_blocked_term"] = this->moderationActionHandlers["add_blocked_term"] =
[this](const auto &data, const auto &roomID) { [this](const auto &data, const auto &roomID) {
// A term has been added // A term has been added
qDebug() << "test3333"; qDebug() << "test3333";
qDebug() << QString::fromStdString(rj::stringify(data));
}; };
this->moderationActionHandlers["approved_automod_message"] = this->moderationActionHandlers["approved_automod_message"] =
[this](const auto &data, const auto &roomID) { [this](const auto &data, const auto &roomID) {
// This message got approved by a moderator // This message got approved by a moderator
qDebug() << "test5555"; qDebug() << "test5555";
qDebug() << QString::fromStdString(rj::stringify(data));
}; };
this->moderationActionHandlers["add_permitted_term"] = this->moderationActionHandlers["add_permitted_term"] =
[this](const auto &data, const auto &roomID) { [this](const auto &data, const auto &roomID) {
// This term got a pass through automod // This term got a pass through automod
qDebug() << "test6666"; qDebug() << "test6666";
qDebug() << QString::fromStdString(rj::stringify(data));
}; };
this->moderationActionHandlers["modified_automod_properties"] = this->moderationActionHandlers["modified_automod_properties"] =
[this](const auto &data, const auto &roomID) { [this](const auto &data, const auto &roomID) {
// The automod settings got modified // The automod settings got modified
qDebug() << "test4444"; qDebug() << "test4444";
qDebug() << QString::fromStdString(rj::stringify(data));
}; };
this->moderationActionHandlers["delete_blocked_term"] = this->moderationActionHandlers["delete_blocked_term"] =
[this](const auto &data, const auto &roomID) { [this](const auto &data, const auto &roomID) {
// This term got deleted // This term got deleted
qDebug() << "test7777"; qDebug() << "test7777";
qDebug() << QString::fromStdString(rj::stringify(data));
}; };
this->moderationActionHandlers["delete_permitted_term"] = this->moderationActionHandlers["delete_permitted_term"] =
[this](const auto &data, const auto &roomID) { [this](const auto &data, const auto &roomID) {
// This term got deleted // This term got deleted
qDebug() << "test8888"; qDebug() << "test8888";
qDebug() << QString::fromStdString(rj::stringify(data));
}; };
this->websocketClient.set_access_channels(websocketpp::log::alevel::all); this->websocketClient.set_access_channels(websocketpp::log::alevel::all);
this->websocketClient.clear_access_channels( this->websocketClient.clear_access_channels(

View file

@ -114,6 +114,7 @@ public:
Signal<UnbanAction> userUnbanned; Signal<UnbanAction> userUnbanned;
Signal<AutomodAction> automodMessage; Signal<AutomodAction> automodMessage;
Signal<AutomodUserAction> automodUserMessage;
} moderation; } moderation;
struct { struct {

View file

@ -419,28 +419,21 @@ void TwitchAccount::autoModAllow(const QString msgID)
QString url("https://api.twitch.tv/kraken/chat/twitchbot/approve"); QString url("https://api.twitch.tv/kraken/chat/twitchbot/approve");
NetworkRequest req(url, NetworkRequestType::Post); NetworkRequest req(url, NetworkRequestType::Post);
req.setRawHeader("Content-type", "application/json"); req.setRawHeader("Content-Type", "application/json");
/*req.setRawHeader curl - i - H 'Client-ID: abcd' -
H 'Accept: application/vnd.twitchtv.v5+json' -
H 'Authorization: OAuth efgh' -
H "Content-type: application/json" --data '{"msg_id":"msgid"}';*/
auto qba = (QString("{\"msg_id\":\"") + msgID + "\"}").toUtf8(); auto qba = (QString("{\"msg_id\":\"") + msgID + "\"}").toUtf8();
qDebug() << qba; qDebug() << qba;
req.setRawHeader("Content-Length", QByteArray::number(qba.size()));
req.setPayload(qba); req.setPayload(qba);
req.setCaller(QThread::currentThread()); req.setCaller(QThread::currentThread());
req.makeAuthorizedV5(this->getOAuthClient(), this->getOAuthToken()); req.makeAuthorizedV5(this->getOAuthClient(), this->getOAuthToken());
req.onError([=](int errorCode) { req.onError([=](int errorCode) {
qDebug() << "you just got an error 4HEad" << errorCode; log("[TwitchAccounts::autoModAllow] Error {}", errorCode);
return true; return true;
}); });
req.onReplyCreated([=](QNetworkReply *reply) -> void {
//
//
return;
});
req.execute(); req.execute();
} }
@ -449,15 +442,17 @@ void TwitchAccount::autoModDeny(const QString msgID)
QString url("https://api.twitch.tv/kraken/chat/twitchbot/deny"); QString url("https://api.twitch.tv/kraken/chat/twitchbot/deny");
NetworkRequest req(url, NetworkRequestType::Post); NetworkRequest req(url, NetworkRequestType::Post);
req.setRawHeader("Content-type", "application/json"); req.setRawHeader("Content-Type", "application/json");
auto qba = (QString("{\"msg_id\":\"") + msgID + "\"}").toUtf8(); auto qba = (QString("{\"msg_id\":\"") + msgID + "\"}").toUtf8();
qDebug() << qba; qDebug() << qba;
req.setRawHeader("Content-Length", QByteArray::number(qba.size()));
req.setPayload(qba); req.setPayload(qba);
req.setCaller(QThread::currentThread()); req.setCaller(QThread::currentThread());
req.makeAuthorizedV5(this->getOAuthClient(), this->getOAuthToken()); req.makeAuthorizedV5(this->getOAuthClient(), this->getOAuthToken());
req.onError([=](int errorCode) { req.onError([=](int errorCode) {
qDebug() << "you just got an error 4HEad" << errorCode; log("[TwitchAccounts::autoModDeny] Error {}", errorCode);
return true; return true;
}); });
req.execute(); req.execute();