From 3156ab273687038ecae4004a524de4bb7bed3c03 Mon Sep 17 00:00:00 2001 From: brain Date: Mon, 28 Mar 2005 01:11:48 +0000 Subject: Added a module at request of [ed] which stops anyone messaging all but opers git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@925 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/m_restrictmsg.cpp | 93 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 src/modules/m_restrictmsg.cpp (limited to 'src/modules/m_restrictmsg.cpp') diff --git a/src/modules/m_restrictmsg.cpp b/src/modules/m_restrictmsg.cpp new file mode 100644 index 000000000..d340cad77 --- /dev/null +++ b/src/modules/m_restrictmsg.cpp @@ -0,0 +1,93 @@ +/* +------------------------------------+ + * | 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 +#include +#include "users.h" +#include "channels.h" +#include "modules.h" + +/* $ModDesc: Forbids users from messaging each other. Users may still message opers and opers may message other opers. */ + + +class ModuleRestrictMsg : public Module +{ + Server *Srv; + public: + + ModuleRestrictMsg() + { + Srv = new Server; + } + + virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text) + { + if (target_type == TYPE_USER) + { + userrec* u = (userrec*)dest; + if (strchr(u->modes,'o')) || (strchr(user->modes,'o'))) + { + // message allowed if: + // (1) the sender is opered + // (2) the recipient is opered + // (3) both are opered + // anything else, blocked. + return 0; + } + WriteServ(user->fd,"531 %s %s :You are not permitted to send private messages to this user",user->nick,u->nick); + return 1; + } + // however, we must allow channel messages... + return 0; + } + + virtual ~ModuleRestrictMsg() + { + delete Srv; + } + + virtual Version GetVersion() + { + return Version(1,0,0,0); + } +}; + + +class ModuleRestrictMsgFactory : public ModuleFactory +{ + public: + ModuleRestrictMsgFactory() + { + } + + ~ModuleRestrictMsgFactory() + { + } + + virtual Module * CreateModule() + { + return new ModuleRestrictMsg; + } + +}; + + +extern "C" void * init_module( void ) +{ + return new ModuleRestrictMsgFactory; +} + -- cgit v1.2.3