diff options
-rw-r--r-- | docs/inspircd.conf.example | 3 | ||||
-rw-r--r-- | src/modules/m_stripcolor.cpp | 29 |
2 files changed, 23 insertions, 9 deletions
diff --git a/docs/inspircd.conf.example b/docs/inspircd.conf.example index 62fd21dc2..defa19a18 100644 --- a/docs/inspircd.conf.example +++ b/docs/inspircd.conf.example @@ -1884,6 +1884,9 @@ #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-# # Strip colour module: Adds the channel mode +S #<module name="m_stripcolor.so"> +# +# Optionally, you can allow channel ops to bypass filtering. Defaults to no. +# <stripcolor allowchanops="no"> #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-# # SILENCE module: Adds support for /SILENCE diff --git a/src/modules/m_stripcolor.cpp b/src/modules/m_stripcolor.cpp index 3254d9895..e3a1c39da 100644 --- a/src/modules/m_stripcolor.cpp +++ b/src/modules/m_stripcolor.cpp @@ -85,16 +85,14 @@ class UserStripColor : public ModeHandler class ModuleStripColor : public Module { - - ConfigReader *Conf, *MyConf; - ChannelStripColor *csc; - UserStripColor *usc; + bool AllowChanOps; + ChannelStripColor *csc; + UserStripColor *usc; public: - ModuleStripColor(InspIRCd* Me) - : Module::Module(Me) + ModuleStripColor(InspIRCd* Me) : Module::Module(Me) { - + OnRehash(NULL, ""); usc = new UserStripColor(ServerInstance); csc = new ChannelStripColor(ServerInstance); @@ -105,7 +103,7 @@ class ModuleStripColor : public Module void Implements(char* List) { - List[I_OnUserPreMessage] = List[I_OnUserPreNotice] = 1; + List[I_OnRehash] = List[I_OnUserPreMessage] = List[I_OnUserPreNotice] = 1; } virtual ~ModuleStripColor() @@ -165,6 +163,13 @@ class ModuleStripColor : public Module } } } + + virtual void OnRehash(userrec* user, const std::string ¶meter) + { + ConfigReader Conf(ServerInstance); + + AllowChanOps = Conf.ReadFlag("stripcolor", "allowchanops", 0); + } virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list) { @@ -180,12 +185,18 @@ class ModuleStripColor : public Module else if (target_type == TYPE_CHANNEL) { chanrec* t = (chanrec*)dest; - active = t->IsModeSet('S'); + + // check if we allow ops to bypass filtering, if we do, check if they're opped accordingly. + // note: short circut logic here, don't wreck it. -- w00t + if (!AllowChanOps || AllowChanOps && t->GetStatus(user) != STATUS_OP) + active = t->IsModeSet('S'); } + if (active) { this->ReplaceLine(text); } + return 0; } |