1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2007 InspIRCd Development Team
6 * See: http://www.inspircd.org/wiki/index.php/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
23 /* $ModDesc: Forbids users from messaging each other. Users may still message opers and opers may message other opers. */
26 class ModuleRestrictMsg : public Module
31 ModuleRestrictMsg(InspIRCd* Me)
37 void Implements(char* List)
39 List[I_OnUserPreMessage] = List[I_OnUserPreNotice] = 1;
42 virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
44 if (target_type == TYPE_USER)
46 userrec* u = (userrec*)dest;
47 if (*u->oper || *user->oper)
49 // message allowed if:
50 // (1) the sender is opered
51 // (2) the recipient is opered
52 // (3) both are opered
53 // anything else, blocked.
56 user->WriteServ("531 %s %s :You are not permitted to send private messages to this user",user->nick,u->nick);
59 // however, we must allow channel messages...
63 virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
65 return this->OnUserPreMessage(user,dest,target_type,text,status,exempt_list);
68 virtual ~ModuleRestrictMsg()
72 virtual Version GetVersion()
74 return Version(1,1,0,1,VF_VENDOR,API_VERSION);
79 class ModuleRestrictMsgFactory : public ModuleFactory
82 ModuleRestrictMsgFactory()
86 ~ModuleRestrictMsgFactory()
90 virtual Module * CreateModule(InspIRCd* Me)
92 return new ModuleRestrictMsg(Me);
98 extern "C" void * init_module( void )
100 return new ModuleRestrictMsgFactory;