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 void Implements(char* List)
43 List[I_OnUserPreMessage] = List[I_OnUserPreNotice] = 1;
46 virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text)
48 if (target_type == TYPE_USER)
50 userrec* u = (userrec*)dest;
51 if ((strchr(u->modes,'o')) || (strchr(user->modes,'o')))
53 // message allowed if:
54 // (1) the sender is opered
55 // (2) the recipient is opered
56 // (3) both are opered
57 // anything else, blocked.
60 WriteServ(user->fd,"531 %s %s :You are not permitted to send private messages to this user",user->nick,u->nick);
63 // however, we must allow channel messages...
67 virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text)
69 return this->OnUserPreMessage(user,dest,target_type,text);
72 virtual ~ModuleRestrictMsg()
76 virtual Version GetVersion()
78 return Version(1,0,0,1,VF_VENDOR);
83 class ModuleRestrictMsgFactory : public ModuleFactory
86 ModuleRestrictMsgFactory()
90 ~ModuleRestrictMsgFactory()
94 virtual Module * CreateModule(Server* Me)
96 return new ModuleRestrictMsg(Me);
102 extern "C" void * init_module( void )
104 return new ModuleRestrictMsgFactory;