summaryrefslogtreecommitdiff
path: root/src/modules/m_hidechans.cpp
diff options
context:
space:
mode:
authorw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>2006-10-30 18:48:41 +0000
committerw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>2006-10-30 18:48:41 +0000
commit2c1dd9be2be86546e6dc1231b5df80af1ec1b23a (patch)
tree3e748cced302c9fa68c685815419984d7fbfa9e1 /src/modules/m_hidechans.cpp
parentd9147559a3212ff9e61f9fed63ba361505ad519f (diff)
Add m_hidechans: Adds usermode +I to hide an oper's channels from non-opers. Also, we don't want to load a .h in the config, Brain :p
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@5583 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules/m_hidechans.cpp')
-rw-r--r--src/modules/m_hidechans.cpp118
1 files changed, 118 insertions, 0 deletions
diff --git a/src/modules/m_hidechans.cpp b/src/modules/m_hidechans.cpp
new file mode 100644
index 000000000..68ce664be
--- /dev/null
+++ b/src/modules/m_hidechans.cpp
@@ -0,0 +1,118 @@
+/* +------------------------------------+
+ * | Inspire Internet Relay Chat Daemon |
+ * +------------------------------------+
+ *
+ * InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
+ * E-mail:
+ * <brain@chatspike.net>
+ * <Craig@chatspike.net>
+ *
+ * Written by Craig Edwards, Craig McLure, and others.
+ * This program is free but copyrighted software; see
+ * the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+#include "users.h"
+#include "channels.h"
+#include "modules.h"
+#include "inspircd.h"
+
+/* $ModDesc: Provides support for hiding oper status with user mode +I */
+
+/** Handles user mode +I
+ */
+class HideChans : public ModeHandler
+{
+ public:
+ HideChans(InspIRCd* Instance) : ModeHandler(Instance, 'I', 0, 0, false, MODETYPE_USER, true) { }
+
+ ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding)
+ {
+ /* Only opers can change other users modes */
+ if ((source != dest) && (!*source->oper))
+ return MODEACTION_DENY;
+
+ if (adding)
+ {
+ if (!dest->IsModeSet('I'))
+ {
+ dest->SetMode('I',true);
+ return MODEACTION_ALLOW;
+ }
+ }
+ else
+ {
+ if (dest->IsModeSet('I'))
+ {
+ dest->SetMode('I',false);
+ return MODEACTION_ALLOW;
+ }
+ }
+
+ return MODEACTION_DENY;
+ }
+};
+
+class ModuleHideChans : public Module
+{
+
+ HideChans* hm;
+ public:
+ ModuleHideChans(InspIRCd* Me)
+ : Module::Module(Me)
+ {
+
+ hm = new HideChans(ServerInstance);
+ ServerInstance->AddMode(hm, 'I');
+ }
+
+ void Implements(char* List)
+ {
+ List[I_OnWhoisLine] = 1;
+ }
+
+ virtual ~ModuleHideChans()
+ {
+ ServerInstance->Modes->DelMode(hm);
+ DELETE(hm);
+ }
+
+ virtual Version GetVersion()
+ {
+ return Version(1,1,0,0,VF_COMMON|VF_VENDOR,API_VERSION);
+ }
+
+ int OnWhoisLine(userrec* user, userrec* dest, int &numeric, std::string &text)
+ {
+ /* Dont display channels if they have +I set and the
+ * person doing the WHOIS is not an oper
+ */
+ return ((!*user->oper) && (numeric == 319) && dest->IsModeSet('I'));
+ }
+};
+
+class ModuleHideChansFactory : public ModuleFactory
+{
+ public:
+ ModuleHideChansFactory()
+ {
+ }
+
+ ~ModuleHideChansFactory()
+ {
+ }
+
+ virtual Module * CreateModule(InspIRCd* Me)
+ {
+ return new ModuleHideChans(Me);
+ }
+
+};
+
+
+extern "C" void * init_module( void )
+{
+ return new ModuleHideChansFactory;
+}