#pragma once #include "ircmsg.hpp" #include #include #include #include #include #include struct hs_database; struct hs_scratch; enum class SnoteTag { ClientConnecting, ClientExiting, RejectingKlined, NickChange, CreateChannel, TemporaryKlineExpired, PropagatedBanExpired, DisconnectingKlined, NewPropagatedKline, NewTemporaryKline, LoginAttempts, PossibleFlooder, Killed, TooManyGlobalConnections, TooManyUserConnections, SetVhostOnMarkedAccount, IsNowOper, NickCollision, OperspyWhois, Freeze, Spambot, FailedChallenge, FailedChallengeHostMismatch, FailedChallengeNoBlock, FailedChallengeTls, FailedChallengeFingerprintMismatch, FailedChallengeMissingSecure, SaveMessage, NickCollisionServices, DroppedChannel, TemporaryDline }; 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;