diff options
Diffstat (limited to 'bot/src/rss.hpp')
| -rw-r--r-- | bot/src/rss.hpp | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/bot/src/rss.hpp b/bot/src/rss.hpp new file mode 100644 index 0000000..cc925ff --- /dev/null +++ b/bot/src/rss.hpp @@ -0,0 +1,57 @@ +#pragma once + +#include <optional> +#include <sol/sol.hpp> +#include <string> +#include <vector> + +#include "api/twitch/helix_client.hpp" +#include "config.hpp" +#include "irc/client.hpp" + +namespace bot { + struct RSSMessage { + std::string title, id, message; + long timestamp; + }; + + struct RSSEvent { + std::string name; + int type; + }; + + struct RSSChannel { + std::string name, url; + std::optional<RSSEvent> event; + std::vector<RSSMessage> messages; + + sol::table as_lua_table(std::shared_ptr<sol::state> state) const; + }; + + class RSSListener { + public: + RSSListener(irc::Client &irc_client, + api::twitch::HelixClient &helix_client, + Configuration &configuration) + : irc_client(irc_client), + helix_client(helix_client), + configuration(configuration) {}; + ~RSSListener() = default; + + void run(); + void add_channel(const std::string &url); + void remove_channel(const std::string &url); + bool has_channel(const std::string &url) const; + + private: + void add_channels(); + void check_channels(); + + std::vector<RSSChannel> channels; + irc::Client &irc_client; + api::twitch::HelixClient &helix_client; + Configuration &configuration; + }; + + std::optional<RSSChannel> get_rss_channel(const std::string &url); +}
\ No newline at end of file |
