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
40 virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text)
42 if (target_type == TYPE_USER)
44 userrec* u = (userrec*)dest;
45 if ((strchr(u->modes,'o')) || (strchr(user->modes,'o')))
47 // message allowed if:
48 // (1) the sender is opered
49 // (2) the recipient is opered
50 // (3) both are opered
51 // anything else, blocked.
54 WriteServ(user->fd,"531 %s %s :You are not permitted to send private messages to this user",user->nick,u->nick);
57 // however, we must allow channel messages...
61 virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text)
63 return this->OnUserPreMessage(user,dest,target_type,text);
66 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()
91 return new ModuleRestrictMsg;
97 extern "C" void * init_module( void )
99 return new ModuleRestrictMsgFactory;