diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/bots.h | 8 | ||||
| -rw-r--r-- | include/config.h | 35 | ||||
| -rw-r--r-- | include/modes.h | 76 | ||||
| -rw-r--r-- | include/servers.h | 2 |
4 files changed, 41 insertions, 80 deletions
diff --git a/include/bots.h b/include/bots.h index 6adcb36a1..80efd8872 100644 --- a/include/bots.h +++ b/include/bots.h @@ -13,6 +13,7 @@ #include "anope.h" #include "serialize.h" #include "commands.h" +#include "config.h" /* A service bot (NickServ, ChanServ, a BotServ bot, etc). */ class CoreExport ServiceBot : public LocalUser @@ -24,12 +25,8 @@ class CoreExport ServiceBot : public LocalUser CommandInfo::map commands; /* Modes the bot should have as configured in service:modes */ Anope::string botmodes; - /* Channels the bot should be in as configured in service:channels */ - std::vector<Anope::string> botchannels; /* Whether or not this bot is introduced to the network */ bool introduced; - /* Bot is defined in the configuration file */ - bool conf; /** Create a new bot. * @param nick The nickname to assign to the bot. @@ -125,10 +122,13 @@ class BotInfo : public Serialize::Object { public: ServiceBot *bot; + Configuration::Block *conf = nullptr; BotInfo(Serialize::TypeBase *type) : Serialize::Object(type) { } BotInfo(Serialize::TypeBase *type, Serialize::ID id) : Serialize::Object(type, id) { } + void Delete() override; + void SetNick(const Anope::string &); Anope::string GetNick(); diff --git a/include/config.h b/include/config.h index fdeddf6dc..65a8bf55d 100644 --- a/include/config.h +++ b/include/config.h @@ -85,6 +85,8 @@ namespace Configuration }; struct Uplink; + struct Usermode; + struct Channelmode; struct CoreExport Conf : Block { @@ -123,6 +125,8 @@ namespace Configuration std::vector<Anope::string> ModulesAutoLoad; /* After how many characters do we wrap lines? */ unsigned int LineWrap; + std::vector<Usermode> Usermodes; + std::vector<Channelmode> Channelmodes; unsigned char CaseMapUpper[256], CaseMapLower[256]; /* module configuration blocks */ @@ -154,14 +158,26 @@ namespace Configuration inline bool operator==(const Uplink &other) const { return host == other.host && port == other.port && password == other.password && ipv6 == other.ipv6; } inline bool operator!=(const Uplink &other) const { return !(*this == other); } }; + + struct Usermode + { + Anope::string name; + char character; + bool param; + bool oper_only, setable; + }; + + struct Channelmode + { + Anope::string name, param_regex; + char character; + char status; /* status char, if any +/@ */ + int level; /* relative level */ + bool oper_only, list, param, param_unset, setable; + + }; } -/** This class can be used on its own to represent an exception, or derived to represent a module-specific exception. - * When a module whishes to abort, e.g. within a constructor, it should throw an exception using ModuleException or - * a class derived from ModuleException. If a module throws an exception during its constructor, the module will not - * be loaded. If this happens, the error message returned by ModuleException::GetReason will be displayed to the user - * attempting to load the module, or dumped to the console if the ircd is currently loading for the first time. - */ class ConfigException : public CoreException { public: @@ -171,11 +187,8 @@ class ConfigException : public CoreException /** This constructor can be used to specify an error message before throwing. */ ConfigException(const Anope::string &message) : CoreException(message, "Config Parser") { } - /** This destructor solves world hunger, cancels the world debt, and causes the world to end. - * Actually no, it does nothing. Never mind. - * @throws Nothing! - */ - virtual ~ConfigException() throw() { } + + virtual ~ConfigException() throw() = default; }; extern Configuration::File ServicesConf; diff --git a/include/modes.h b/include/modes.h index 1858da5e4..c010700ca 100644 --- a/include/modes.h +++ b/include/modes.h @@ -47,6 +47,9 @@ class CoreExport Mode : public Base /* Type of mode this is, eg MODE_LIST */ ModeType type; + bool setable = true; + bool oper_only = false; + /** constructor * @param mname The mode name * @param mclass The type of mode this is @@ -56,6 +59,9 @@ class CoreExport Mode : public Base Mode(const Anope::string &mname, ModeClass mclass, char mc, ModeType type); virtual ~Mode(); + void SetSetable(bool b) { setable = b; } + void SetOperOnly(bool b) { oper_only = b; } + /** Can a user set this mode, used for mlock * @param u The user */ @@ -143,18 +149,6 @@ class CoreExport ChannelModeList : public ChannelMode * @return true on match */ virtual bool Matches(User *u, const Entry *e) { return false; } - - /** Called when a mask is added to a channel - * @param chan The channel - * @param mask The mask - */ - virtual void OnAdd(Channel *chan, const Anope::string &mask) { } - - /** Called when a mask is removed from a channel - * @param chan The channel - * @param mask The mask - */ - virtual void OnDel(Channel *chan, const Anope::string &mask) { } }; /** This is a mode with a paramater, eg +k/l. These modes should use/inherit from this @@ -172,11 +166,13 @@ class CoreExport ChannelModeParam : public ChannelMode /* Should we send an arg when unsetting this mode? */ bool minus_no_arg; + std::regex param_validation; + /** Is the param valid * @param value The param * @return true for yes, false for no */ - virtual bool IsValid(Anope::string &value) const { return true; } + virtual bool IsValid(Anope::string &value) const; }; /** This is a mode that is a channel status, eg +v/h/o/a/q. @@ -235,53 +231,6 @@ class CoreExport ChannelStatus Anope::string BuildModePrefixList() const; }; -class CoreExport UserModeOperOnly : public UserMode -{ - public: - UserModeOperOnly(const Anope::string &mname, char um) : UserMode(mname, um) { } - - bool CanSet(User *u) const override; -}; - -class CoreExport UserModeNoone : public UserMode -{ - public: - UserModeNoone(const Anope::string &mname, char um) : UserMode(mname, um) { } - - bool CanSet(User *u) const override; -}; - -/** Channel mode +k (key) - */ -class CoreExport ChannelModeKey : public ChannelModeParam -{ - public: - ChannelModeKey(char mc) : ChannelModeParam("KEY", mc) { } - - bool IsValid(Anope::string &value) const override; -}; - -/** This class is used for oper only channel modes - */ -class CoreExport ChannelModeOperOnly : public ChannelMode -{ - public: - ChannelModeOperOnly(const Anope::string &mname, char mc) : ChannelMode(mname, mc) { } - - /* Opers only */ - bool CanSet(User *u) const override; -}; - -/** This class is used for channel modes only servers may set - */ -class CoreExport ChannelModeNoone : public ChannelMode -{ - public: - ChannelModeNoone(const Anope::string &mname, char mc) : ChannelMode(mname, mc) { } - - bool CanSet(User *u) const override; -}; - /** This is the mode manager * It contains functions for adding modes to Anope so Anope can track them * and do things such as MLOCK. @@ -291,11 +240,6 @@ class CoreExport ChannelModeNoone : public ChannelMode class CoreExport ModeManager { public: - - /* Number of generic channel and user modes we are tracking */ - static unsigned GenericChannelModes; - static unsigned GenericUserModes; - /** Add a user mode to Anope * @param um A UserMode or UserMode derived class * @return true on success, false on error @@ -380,6 +324,8 @@ class CoreExport ModeManager static void StackerDel(User *u); static void StackerDel(Channel *c); static void StackerDel(Mode *m); + + static void Apply(Configuration::Conf *old); }; /** Represents a mask set on a channel (b/e/I) diff --git a/include/servers.h b/include/servers.h index 5c09ab2d6..1d62938ec 100644 --- a/include/servers.h +++ b/include/servers.h @@ -82,6 +82,8 @@ class CoreExport Server : public Extensible /* Number of users on the server */ unsigned users; + void Burst(); + /** Delete this server with a reason * @param reason The reason */ |
