From c0a87dd9fc50b12f4b80699e55040648a979fdb5 Mon Sep 17 00:00:00 2001 From: brain Date: Mon, 28 Mar 2005 00:32:17 +0000 Subject: 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 --- src/modules/m_restrictchans.cpp | 84 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 src/modules/m_restrictchans.cpp (limited to 'src') 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: + * + * + * + * Written by Craig Edwards, Craig McLure, and others. + * This program is free but copyrighted software; see + * the file COPYING for details. + * + * --------------------------------------------------- + */ + +#include +#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; +} + -- cgit v1.2.3