#pragma once #include "ircmsg.hpp" #include #include #include #include #include #include struct hs_database; struct hs_scratch; enum class SnoteTag { ClientConnecting, ClientExiting, CreateChannel, DisconnectingKlined, DroppedChannel, DroppedNick, DroppedNickRename, DroppedAccount, FailedChallenge, FailedChallengeFingerprintMismatch, FailedChallengeHostMismatch, FailedChallengeMissingSecure, FailedChallengeNoBlock, FailedChallengeTls, Freeze, IsNowOper, IsNowOperGlobal, JoinedJuped, Killed, KilledRemote, KilledRemoteOper, LoginAttempts, NewPropagatedKline, NewTemporaryKline, NickChange, NickCollision, NickCollisionServices, OperspyWhois, OperspyWho, PossibleFlooder, PropagatedBanExpired, RejectingKlined, SaveMessage, SetVhostOnMarkedAccount, SighupReloadingConf, Spambot, TemporaryDline, TemporaryKlineExpired, TooManyGlobalConnections, TooManyUserConnections, }; class SnoteMatch { SnoteTag tag_; std::variant, std::match_results> components_; public: SnoteMatch(SnoteTag tag, const std::regex ®ex, std::string_view full) : tag_{tag} , components_{std::make_pair(std::ref(regex), full)} { } auto get_tag() -> SnoteTag { return tag_; } auto get_results() -> const std::match_results &; }; struct SnoteCore { struct DbDeleter { auto operator()(hs_database *db) const -> void; }; struct ScratchDeleter { auto operator()(hs_scratch *scratch) const -> void; }; /// @brief Database of server notice patterns std::unique_ptr db_; /// @brief HyperScan scratch space std::unique_ptr scratch_; SnoteCore(); auto match(const IrcMsg &msg) -> std::optional; }; extern SnoteCore snoteCore;