From a51a54bc5979a2491f152abc47ad54e6b63f27c8 Mon Sep 17 00:00:00 2001 From: Dylam De La Torre Date: Tue, 23 Nov 2021 05:21:56 +0100 Subject: Restructure source and resource files (#46) importantly, res is now res/res and css is now res/css --- src/discord/activity.hpp | 137 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 137 insertions(+) create mode 100644 src/discord/activity.hpp (limited to 'src/discord/activity.hpp') diff --git a/src/discord/activity.hpp b/src/discord/activity.hpp new file mode 100644 index 0000000..6b8e944 --- /dev/null +++ b/src/discord/activity.hpp @@ -0,0 +1,137 @@ +#pragma once +#include +#include +#include "util.hpp" +#include "json.hpp" +#include "snowflake.hpp" + +enum class PresenceStatus : uint8_t { + Online, + Offline, + Idle, + DND, +}; + +constexpr inline const char *GetPresenceString(PresenceStatus s) { + switch (s) { + case PresenceStatus::Online: + return "online"; + case PresenceStatus::Offline: + return "offline"; + case PresenceStatus::Idle: + return "idle"; + case PresenceStatus::DND: + return "dnd"; + } + return ""; +} + +constexpr inline const char* GetPresenceDisplayString(PresenceStatus s) { + switch (s) { + case PresenceStatus::Online: + return "Online"; + case PresenceStatus::Offline: + return "Offline"; + case PresenceStatus::Idle: + return "Away"; + case PresenceStatus::DND: + return "Do Not Disturb"; + } + return ""; +} + +enum class ActivityType : int { + Game = 0, + Streaming = 1, + Listening = 2, + Watching = 3, // not documented + Custom = 4, + Competing = 5, +}; + +enum class ActivityFlags { + INSTANCE = (1 << 0), + JOIN = (1 << 1), + SPECTATE = (1 << 2), + JOIN_REQUEST = (1 << 3), + SYNC = (1 << 4), + PLAY = (1 << 5), +}; +template<> +struct Bitwise { + static const bool enable = true; +}; + +struct ActivityTimestamps { + std::optional Start; + std::optional End; + + friend void from_json(const nlohmann::json &j, ActivityTimestamps &m); + friend void to_json(nlohmann::json &j, const ActivityTimestamps &m); +}; + +struct ActivityEmoji { + std::string Name; + std::optional ID; + std::optional IsAnimated; + + friend void from_json(const nlohmann::json &j, ActivityEmoji &m); + friend void to_json(nlohmann::json &j, const ActivityEmoji &m); +}; + +struct ActivityParty { + std::optional ID; + std::optional> Size; + + friend void from_json(const nlohmann::json &j, ActivityParty &m); + friend void to_json(nlohmann::json &j, const ActivityParty &m); +}; + +struct ActivityAssets { + std::optional LargeImage; + std::optional LargeText; + std::optional SmallImage; + std::optional SmallText; + + friend void from_json(const nlohmann::json &j, ActivityAssets &m); + friend void to_json(nlohmann::json &j, const ActivityAssets &m); +}; + +struct ActivitySecrets { + std::optional Join; + std::optional Spectate; + std::optional Match; + + friend void from_json(const nlohmann::json &j, ActivitySecrets &m); + friend void to_json(nlohmann::json &j, const ActivitySecrets &m); +}; + +struct ActivityData { + std::string Name; // + ActivityType Type; // + std::optional URL; // null + std::optional CreatedAt; // + std::optional Timestamps; // + std::optional ApplicationID; // + std::optional Details; // null + std::optional State; // null + std::optional Emoji; // null + std::optional Party; // + std::optional Assets; // + std::optional Secrets; // + std::optional IsInstance; // + std::optional Flags; // + + friend void from_json(const nlohmann::json &j, ActivityData &m); + friend void to_json(nlohmann::json &j, const ActivityData &m); +}; + +struct PresenceData { + std::vector Activities; // null (but never sent as such) + std::string Status; + std::optional IsAFK; + std::optional Since; + + friend void from_json(const nlohmann::json &j, PresenceData &m); + friend void to_json(nlohmann::json &j, const PresenceData &m); +}; -- cgit v1.2.3