diff options
Diffstat (limited to 'src/schemas')
| -rw-r--r-- | src/schemas/channel.hpp | 76 | ||||
| -rw-r--r-- | src/schemas/stream.cpp | 17 | ||||
| -rw-r--r-- | src/schemas/stream.hpp | 11 | ||||
| -rw-r--r-- | src/schemas/user.hpp | 73 |
4 files changed, 0 insertions, 177 deletions
diff --git a/src/schemas/channel.hpp b/src/schemas/channel.hpp deleted file mode 100644 index 2560331..0000000 --- a/src/schemas/channel.hpp +++ /dev/null @@ -1,76 +0,0 @@ -#pragma once - -#include <chrono> -#include <optional> -#include <pqxx/pqxx> -#include <string> - -#include "../constants.hpp" -#include "../utils/chrono.hpp" - -namespace bot::schemas { - class Channel { - public: - Channel(const pqxx::row &row) { - this->id = row[0].as<int>(); - this->alias_id = row[1].as<int>(); - this->alias_name = row[2].as<std::string>(); - - this->joined_at = - utils::chrono::string_to_time_point(row[3].as<std::string>()); - - if (!row[4].is_null()) { - this->opted_out_at = - utils::chrono::string_to_time_point(row[4].as<std::string>()); - } - } - - ~Channel() = default; - - const int &get_id() const { return this->id; } - const int &get_alias_id() const { return this->alias_id; } - const std::string &get_alias_name() const { return this->alias_name; } - const std::chrono::system_clock::time_point &get_joined_at() const { - return this->joined_at; - } - const std::optional<std::chrono::system_clock::time_point> & - get_opted_out_at() const { - return this->opted_out_at; - } - - private: - int id, alias_id; - std::string alias_name; - std::chrono::system_clock::time_point joined_at; - std::optional<std::chrono::system_clock::time_point> opted_out_at; - }; - - class ChannelPreferences { - public: - ChannelPreferences(const pqxx::row &row) { - this->channel_id = row[0].as<int>(); - - if (!row[2].is_null()) { - this->prefix = row[1].as<std::string>(); - } else { - this->prefix = DEFAULT_PREFIX; - } - - if (!row[3].is_null()) { - this->locale = row[2].as<std::string>(); - } else { - this->locale = DEFAULT_LOCALE_ID; - } - } - - ~ChannelPreferences() = default; - - const int &get_channel_id() const { return this->channel_id; } - const std::string &get_prefix() const { return this->prefix; } - const std::string &get_locale() const { return this->locale; } - - private: - int channel_id; - std::string prefix, locale; - }; -} diff --git a/src/schemas/stream.cpp b/src/schemas/stream.cpp deleted file mode 100644 index 6ef10dc..0000000 --- a/src/schemas/stream.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include "stream.hpp" - -namespace bot::schemas { - EventType string_to_event_type(const std::string &type) { - if (type == "live") { - return EventType::LIVE; - } else if (type == "offline") { - return EventType::OFFLINE; - } else if (type == "title") { - return EventType::TITLE; - } else if (type == "game") { - return EventType::GAME; - } else { - return EventType::CUSTOM; - } - } -} diff --git a/src/schemas/stream.hpp b/src/schemas/stream.hpp deleted file mode 100644 index a636ea5..0000000 --- a/src/schemas/stream.hpp +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once - -#include <string> - -namespace bot::schemas { - enum EventType { LIVE, OFFLINE, TITLE, GAME, CUSTOM = 99 }; - EventType string_to_event_type(const std::string &type); - - enum EventFlag { MASSPING }; - -} diff --git a/src/schemas/user.hpp b/src/schemas/user.hpp deleted file mode 100644 index 0bd1368..0000000 --- a/src/schemas/user.hpp +++ /dev/null @@ -1,73 +0,0 @@ -#pragma once - -#include <chrono> -#include <optional> -#include <pqxx/pqxx> -#include <string> - -#include "../utils/chrono.hpp" - -namespace bot::schemas { - class User { - public: - User(const pqxx::row &row) { - this->id = row[0].as<int>(); - this->alias_id = row[1].as<int>(); - this->alias_name = row[2].as<std::string>(); - - this->joined_at = - utils::chrono::string_to_time_point(row[3].as<std::string>()); - - if (!row[4].is_null()) { - this->opted_out_at = - utils::chrono::string_to_time_point(row[4].as<std::string>()); - } - } - - ~User() = default; - - const int &get_id() const { return this->id; } - const int &get_alias_id() const { return this->alias_id; } - const std::string &get_alias_name() const { return this->alias_name; } - void set_alias_name(const std::string &alias_name) { - this->alias_name = alias_name; - } - const std::chrono::system_clock::time_point &get_joined_at() const { - return this->joined_at; - } - const std::optional<std::chrono::system_clock::time_point> & - get_opted_out_at() const { - return this->opted_out_at; - } - - private: - int id, alias_id; - std::string alias_name; - std::chrono::system_clock::time_point joined_at; - std::optional<std::chrono::system_clock::time_point> opted_out_at; - }; - - enum PermissionLevel { SUSPENDED, USER, VIP, MODERATOR, BROADCASTER }; - - class UserRights { - public: - UserRights(const pqxx::row &row) { - this->id = row[0].as<int>(); - this->user_id = row[1].as<int>(); - this->channel_id = row[2].as<int>(); - this->level = static_cast<PermissionLevel>(row[3].as<int>()); - } - - ~UserRights() = default; - - const int &get_id() const { return this->id; } - const int &get_user_id() const { return this->user_id; } - const int &get_channel_id() const { return this->channel_id; } - const PermissionLevel &get_level() const { return this->level; } - void set_level(PermissionLevel level) { this->level = level; } - - private: - int id, user_id, channel_id; - PermissionLevel level; - }; -} |
