2018-04-15 15:09:31 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <rapidjson/document.h>
|
|
|
|
#include <QString>
|
|
|
|
|
|
|
|
#include <chrono>
|
|
|
|
#include <cinttypes>
|
|
|
|
|
|
|
|
namespace chatterino {
|
2018-04-28 15:48:40 +02:00
|
|
|
namespace providers {
|
|
|
|
namespace twitch {
|
2018-04-15 15:09:31 +02:00
|
|
|
|
|
|
|
struct ActionUser {
|
|
|
|
QString id;
|
|
|
|
QString name;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct PubSubAction {
|
2018-04-22 15:37:02 +02:00
|
|
|
PubSubAction(const rapidjson::Value &data, const QString &_roomID);
|
2018-04-15 15:09:31 +02:00
|
|
|
ActionUser source;
|
|
|
|
|
|
|
|
std::chrono::steady_clock::time_point timestamp;
|
2018-04-22 15:37:02 +02:00
|
|
|
QString roomID;
|
2018-04-15 15:09:31 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
// Used when a chat mode (i.e. slowmode, subscribers only mode) is enabled or disabled
|
|
|
|
struct ModeChangedAction : PubSubAction {
|
2018-04-22 15:37:02 +02:00
|
|
|
using PubSubAction::PubSubAction;
|
2018-04-15 15:09:31 +02:00
|
|
|
|
|
|
|
enum Mode {
|
|
|
|
Unknown,
|
|
|
|
Slow,
|
|
|
|
R9K,
|
|
|
|
SubscribersOnly,
|
|
|
|
EmoteOnly,
|
|
|
|
} mode;
|
|
|
|
|
|
|
|
// Whether the mode was turned on or off
|
|
|
|
enum State {
|
|
|
|
Off,
|
|
|
|
On,
|
|
|
|
} state;
|
|
|
|
|
|
|
|
union {
|
|
|
|
uint32_t duration;
|
|
|
|
} args;
|
|
|
|
};
|
|
|
|
|
2018-04-27 18:35:31 +02:00
|
|
|
struct BanAction : PubSubAction {
|
2018-04-22 15:37:02 +02:00
|
|
|
using PubSubAction::PubSubAction;
|
2018-04-15 15:09:31 +02:00
|
|
|
|
|
|
|
ActionUser target;
|
|
|
|
|
|
|
|
QString reason;
|
|
|
|
|
2018-04-27 18:35:31 +02:00
|
|
|
uint32_t duration = 0;
|
2018-04-15 15:09:31 +02:00
|
|
|
|
2018-04-27 18:35:31 +02:00
|
|
|
bool isBan() const
|
|
|
|
{
|
|
|
|
return this->duration == 0;
|
|
|
|
}
|
2018-04-15 15:09:31 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct UnbanAction : PubSubAction {
|
2018-04-22 15:37:02 +02:00
|
|
|
using PubSubAction::PubSubAction;
|
2018-04-15 15:09:31 +02:00
|
|
|
|
|
|
|
ActionUser target;
|
|
|
|
|
|
|
|
enum {
|
|
|
|
Banned,
|
|
|
|
TimedOut,
|
|
|
|
} previousState;
|
2018-04-27 18:35:31 +02:00
|
|
|
|
|
|
|
bool wasBan() const
|
|
|
|
{
|
|
|
|
return this->previousState == Banned;
|
|
|
|
}
|
2018-04-15 15:09:31 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ClearChatAction : PubSubAction {
|
2018-04-22 15:37:02 +02:00
|
|
|
using PubSubAction::PubSubAction;
|
2018-04-15 15:09:31 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ModerationStateAction : PubSubAction {
|
2018-04-22 15:37:02 +02:00
|
|
|
using PubSubAction::PubSubAction;
|
2018-04-15 15:09:31 +02:00
|
|
|
|
|
|
|
ActionUser target;
|
|
|
|
|
|
|
|
// true = modded
|
|
|
|
// false = unmodded
|
|
|
|
bool modded;
|
|
|
|
};
|
|
|
|
|
2018-04-28 15:48:40 +02:00
|
|
|
} // namespace twitch
|
|
|
|
} // namespace providers
|
2018-04-15 15:09:31 +02:00
|
|
|
} // namespace chatterino
|