diff options
author | Adam <Adam@anope.org> | 2014-04-25 16:51:06 -0400 |
---|---|---|
committer | Adam <Adam@anope.org> | 2014-04-25 16:51:06 -0400 |
commit | 6a03eb69ebbe773f1d4139ff88d74ecdb2b0af4b (patch) | |
tree | d370fbc4a1dd55b72dbcda9f2aff24678d5626f3 /include | |
parent | 4fa2a00bd595eb120e6acde5eb167759c2018e33 (diff) |
Add "virtual mode" support
This allows fully tracking extbans and other modes set by a different
underlying mode, such as InspIRCd's namedmodes
Add two configuration options to cs_ban to configure which mode is set
and whether or not to kick banned users.
Add default "mute" fantasy command to botserv.example.conf
Diffstat (limited to 'include')
-rw-r--r-- | include/channels.h | 3 | ||||
-rw-r--r-- | include/config.h | 2 | ||||
-rw-r--r-- | include/modes.h | 41 |
3 files changed, 38 insertions, 8 deletions
diff --git a/include/channels.h b/include/channels.h index 27119adf4..cc30d2030 100644 --- a/include/channels.h +++ b/include/channels.h @@ -276,10 +276,11 @@ class CoreExport Channel : public Base, public Extensible /** Unbans a user from this channel. * @param u The user to unban + * @param mode The mode to unban * @param full Whether or not to match using the user's real host and IP * @return whether or not a ban was removed */ - bool Unban(User *u, bool full = false); + bool Unban(User *u, const Anope::string &mode, bool full = false); /** Check whether a user is permitted to be on this channel * @param u The user diff --git a/include/config.h b/include/config.h index 86a7dce78..019564680 100644 --- a/include/config.h +++ b/include/config.h @@ -138,6 +138,8 @@ namespace Configuration Block *GetModule(const Anope::string &name); BotInfo *GetClient(const Anope::string &name); + + Block *GetCommand(CommandSource &); }; struct Uplink diff --git a/include/modes.h b/include/modes.h index 8f67959e8..3ba54c439 100644 --- a/include/modes.h +++ b/include/modes.h @@ -96,6 +96,9 @@ class CoreExport UserModeParam : public UserMode class CoreExport ChannelMode : public Mode { public: + /* channel modes that can posssibly unwrap this mode */ + std::vector<ChannelMode *> listeners; + /** constructor * @param name The mode name * @param mc The mode char @@ -103,6 +106,18 @@ class CoreExport ChannelMode : public Mode ChannelMode(const Anope::string &name, char mc); bool CanSet(User *u) const anope_override; + + /** 'wrap' this channel mode and param to the underlying mode and param + */ + virtual ChannelMode *Wrap(Anope::string ¶m); + + /** 'unwrap' this mode to our internal representation + */ + ChannelMode *Unwrap(Anope::string ¶m); + + /** called when a mode is being unwrapped, and is asking us if we can unwrap it + */ + virtual ChannelMode *Unwrap(ChannelMode *, Anope::string ¶m); }; /** This is a mode for lists, eg b/e/I. These modes should inherit from this @@ -186,6 +201,25 @@ class CoreExport ChannelModeStatus : public ChannelMode ChannelModeStatus(const Anope::string &name, char mc, char msymbol, short mlevel); }; +/** A virtual mode. This mode doesn't natively exist on the IRCd (like extbans), + * but we still have a representation for it. + */ +template<typename T> +class ChannelModeVirtual : public T +{ + Anope::string base; + ChannelMode *basech; + + public: + ChannelModeVirtual(const Anope::string &mname, const Anope::string &basename); + + ~ChannelModeVirtual(); + + ChannelMode *Wrap(Anope::string ¶m) anope_override; + + ChannelMode *Unwrap(ChannelMode *cm, Anope::string ¶m) = 0; +}; + /* The status a user has on a channel (+v, +h, +o) etc */ class CoreExport ChannelStatus { @@ -257,13 +291,6 @@ class CoreExport ChannelModeNoone : public ChannelMode */ class CoreExport ModeManager { - protected: - /* Array of all modes Anope knows about. Modes are in this array at position - * modechar. Additionally, status modes are in this array (again) at statuschar. - */ - static std::vector<ChannelMode *> ChannelModes; - static std::vector<UserMode *> UserModes; - public: /* Number of generic channel and user modes we are tracking */ |