1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd is copyright (C) 2002-2006 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 * ---------------------------------------------------
28 /* $ModDesc: Forbids users from messaging each other. Users may still message opers and opers may message other opers. */
31 class ModuleRestrictMsg : public Module
36 ModuleRestrictMsg(InspIRCd* Me)
42 void Implements(char* List)
44 List[I_OnUserPreMessage] = List[I_OnUserPreNotice] = 1;
47 virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text, char status)
49 if (target_type == TYPE_USER)
51 userrec* u = (userrec*)dest;
52 if (*u->oper || *user->oper)
54 // message allowed if:
55 // (1) the sender is opered
56 // (2) the recipient is opered
57 // (3) both are opered
58 // anything else, blocked.
61 user->WriteServ("531 %s %s :You are not permitted to send private messages to this user",user->nick,u->nick);
64 // however, we must allow channel messages...
68 virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text, char status)
70 return this->OnUserPreMessage(user,dest,target_type,text,status);
73 virtual ~ModuleRestrictMsg()
77 virtual Version GetVersion()
79 return Version(1,0,0,1,VF_VENDOR);
84 class ModuleRestrictMsgFactory : public ModuleFactory
87 ModuleRestrictMsgFactory()
91 ~ModuleRestrictMsgFactory()
95 virtual Module * CreateModule(InspIRCd* Me)
97 return new ModuleRestrictMsg(Me);
103 extern "C" void * init_module( void )
105 return new ModuleRestrictMsgFactory;