summaryrefslogtreecommitdiff
path: root/src/modules/m_restrictchans.cpp
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2005-03-28 00:32:17 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2005-03-28 00:32:17 +0000
commitc0a87dd9fc50b12f4b80699e55040648a979fdb5 (patch)
treeb45731788495da092df718c90fea30625aa7d8d8 /src/modules/m_restrictchans.cpp
parent2f07f35dfdfa6f9c5432d37a21c6b53c6468ace2 (diff)
Added module to restrict channel creation to opers only (requested by [ed])
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@924 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules/m_restrictchans.cpp')
-rw-r--r--src/modules/m_restrictchans.cpp84
1 files changed, 84 insertions, 0 deletions
diff --git a/src/modules/m_restrictchans.cpp b/src/modules/m_restrictchans.cpp
new file mode 100644
index 000000000..b834140fe
--- /dev/null
+++ b/src/modules/m_restrictchans.cpp
@@ -0,0 +1,84 @@
+/* +------------------------------------+
+ * | Inspire Internet Relay Chat Daemon |
+ * +------------------------------------+
+ *
+ * Inspire is copyright (C) 2002-2004 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 <stdio.h>
+#include "users.h"
+#include "channels.h"
+#include "modules.h"
+
+/* $ModDesc: Only opers may create new channels if this module is loaded */
+
+Server *Srv;
+
+class ModuleRestrictChans : public Module
+{
+ public:
+ ModuleRestrictChans()
+ {
+ Srv = new Server;
+ }
+
+ virtual int OnUserPreJoin(userrec* user, chanrec* chan, const char* cname)
+ {
+ // user is not an oper
+ if (!strchr(user->modes,'o'))
+ {
+ // channel does not yet exist (record is null, about to be created IF we were to allow it)
+ if (!chan)
+ {
+ WriteServ(user->fd,"530 %s %s :Only IRC operators may create new channels",user->nick, chan->name,chan->name);
+ return 1;
+ }
+ }
+ return 0;
+ }
+
+ virtual ~ModuleRestrictChans()
+ {
+ delete Srv;
+ }
+
+ virtual Version GetVersion()
+ {
+ return Version(1,0,0,0);
+ }
+};
+
+
+class ModuleRestrictChansFactory : public ModuleFactory
+{
+ public:
+ ModuleRestrictChansFactory()
+ {
+ }
+
+ ~ModuleRestrictChansFactory()
+ {
+ }
+
+ virtual Module * CreateModule()
+ {
+ return new ModuleRestrictChans;
+ }
+
+};
+
+
+extern "C" void * init_module( void )
+{
+ return new ModuleRestrictChansFactory;
+}
+