+
+
+class CensorException : public ModuleException
+{
+ public:
+ virtual const char* GetReason()
+ {
+ return "Could not find <censor file=\"\"> definition in your config file!";
+ }
+};
+
+class CensorUser : public ModeHandler
+{
+ public:
+ CensorUser(InspIRCd* Instance) : ModeHandler(Instance, 'G', 0, 0, false, MODETYPE_USER, false) { }
+
+ ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding)
+ {
+ /* Only opers can change other users modes */
+ if ((source != dest) && (!*source->oper))
+ return MODEACTION_DENY;
+
+ if (adding)
+ {
+ if (!dest->IsModeSet('G'))
+ {
+ dest->SetMode('G',true);
+ return MODEACTION_ALLOW;
+ }
+ }
+ else
+ {
+ if (dest->IsModeSet('G'))
+ {
+ dest->SetMode('G',false);
+ return MODEACTION_ALLOW;
+ }
+ }
+
+ return MODEACTION_DENY;
+ }
+};
+
+class CensorChannel : public ModeHandler
+{
+ public:
+ CensorChannel(InspIRCd* Instance) : ModeHandler(Instance, 'G', 0, 0, false, MODETYPE_CHANNEL, false) { }
+
+ ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding)
+ {
+ if (adding)
+ {
+ if (!channel->IsModeSet('G'))
+ {
+ channel->SetMode('G',false);
+ return MODEACTION_ALLOW;
+ }
+ }
+ else
+ {
+ if (channel->IsModeSet('G'))
+ {
+ channel->SetMode('G',false);
+ return MODEACTION_ALLOW;
+ }
+ }
+
+ return MODEACTION_ALLOW;
+ }
+};
+