#pragma once #include #include #include #include #include #include #include #include struct ProjectSettings { // *** Administrative settings *** // IRC channel to announce to std::string channel; // name extracted from notify/$user std::string credential_name; // Authorized accounts can edit the event list std::set authorized_accounts; // *** User settings *** // Events to announce std::set events; // Whether to announce events bool enabled; auto to_toml() const -> toml::table; static auto from_toml(const toml::table &v) -> ProjectSettings; }; struct WebhookSettings { std::string host; std::string service; std::map credentials; std::map projects; auto to_toml() const -> toml::table; static auto from_toml(const toml::table &v) -> WebhookSettings; }; class Webhooks { // IRC connection to announce on; could be empty std::shared_ptr client_; // Buffered events in case connection was inactive when event was received std::vector> events_; const char * settings_filename_; public: WebhookSettings settings_; Webhooks(const char * settings_filename) : settings_filename_{settings_filename} { } // Either emit the event now or save it until a connection is set auto send_notice(std::string_view, std::string) -> void; auto set_client(std::shared_ptr client) -> void; auto clear_client() -> void; auto save_settings() const -> void; auto load_settings() -> void; }; auto start_webhook(boost::asio::io_context &io, const char *) -> std::shared_ptr; extern std::map, const myirc::Bot::Command &)> webhook_commands;