irccd  3.0.3
Public Member Functions | List of all members
irccd::daemon::rule_service Class Reference

Store and solve rules. More...

#include <rule_service.hpp>

Public Member Functions

 rule_service (bot &bot)
 
auto list () const noexcept -> const std::vector< rule > &
 
void add (rule rule)
 
void insert (rule rule, std::size_t position)
 
void remove (std::size_t position)
 
auto require (std::size_t position) const -> const rule &
 
auto require (std::size_t position) -> rule &
 
auto solve (std::string_view server, std::string_view channel, std::string_view origin, std::string_view plugin, std::string_view event) noexcept -> bool
 
void load (const config &cfg) noexcept
 

Detailed Description

Store and solve rules.

Constructor & Destructor Documentation

◆ rule_service()

irccd::daemon::rule_service::rule_service ( bot bot)

Create the rule service.

Parameters
botthe irccd instance

Member Function Documentation

◆ add()

void irccd::daemon::rule_service::add ( rule  rule)

Append a rule.

Parameters
rulethe rule to append

◆ insert()

void irccd::daemon::rule_service::insert ( rule  rule,
std::size_t  position 
)

Insert a new rule at the specified position.

Parameters
rulethe rule
positionthe position

◆ list()

auto irccd::daemon::rule_service::list ( ) const -> const std::vector< rule > &
noexcept

Get the list of rules.

Returns
the list of rules

◆ load()

void irccd::daemon::rule_service::load ( const config cfg)
noexcept

Load rules from the configuration.

Parameters
cfgthe config

◆ remove()

void irccd::daemon::rule_service::remove ( std::size_t  position)

Remove a new rule from the specified position.

Precondition
position must be valid
Parameters
positionthe position

◆ require() [1/2]

auto irccd::daemon::rule_service::require ( std::size_t  position) -> rule &

Overloaded function.

Get a rule at the specified index or throw an exception if not found.

Parameters
positionthe position
Returns
the rule
Exceptions
std::out_of_rangeif position is invalid

◆ require() [2/2]

auto irccd::daemon::rule_service::require ( std::size_t  position) const -> const rule &

Get a rule at the specified index or throw an exception if not found.

Parameters
positionthe position
Returns
the rule
Exceptions
std::out_of_rangeif position is invalid

◆ solve()

auto irccd::daemon::rule_service::solve ( std::string_view  server,
std::string_view  channel,
std::string_view  origin,
std::string_view  plugin,
std::string_view  event 
) -> bool
noexcept

Resolve the action to execute with the specified list of rules.

Parameters
serverthe server name
channelthe channel name
originthe origin
pluginthe plugin name
eventthe event name (e.g onKick)
Returns
true if the plugin must be called

The documentation for this class was generated from the following file: