1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * Inspire is copyright (C) 2002-2004 ChatSpike-Dev.
7 * <brain@chatspike.net>
8 * <Craig@chatspike.net>
10 * Written by Craig Edwards, Craig McLure, and others.
11 * This program is free but copyrighted software; see
12 * the file COPYING for details.
14 * ---------------------------------------------------
25 #include "helperfuncs.h"
27 /* $ModDesc: Forbids users from messaging each other. Users may still message opers and opers may message other opers. */
30 class ModuleRestrictMsg : public Module
35 ModuleRestrictMsg(Server* Me)
41 virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text)
43 if (target_type == TYPE_USER)
45 userrec* u = (userrec*)dest;
46 if ((strchr(u->modes,'o')) || (strchr(user->modes,'o')))
48 // message allowed if:
49 // (1) the sender is opered
50 // (2) the recipient is opered
51 // (3) both are opered
52 // anything else, blocked.
55 WriteServ(user->fd,"531 %s %s :You are not permitted to send private messages to this user",user->nick,u->nick);
58 // however, we must allow channel messages...
62 virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text)
64 return this->OnUserPreMessage(user,dest,target_type,text);
67 virtual ~ModuleRestrictMsg()
71 virtual Version GetVersion()
73 return Version(1,0,0,1,VF_VENDOR);
78 class ModuleRestrictMsgFactory : public ModuleFactory
81 ModuleRestrictMsgFactory()
85 ~ModuleRestrictMsgFactory()
89 virtual Module * CreateModule(Server* Me)
91 return new ModuleRestrictMsg(Me);
97 extern "C" void * init_module( void )
99 return new ModuleRestrictMsgFactory;