1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2010 InspIRCd Development Team
6 * See: http://wiki.inspircd.org/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
16 /* $ModDesc: Forbids users from messaging each other. Users may still message opers and opers may message other opers. */
19 class ModuleRestrictMsg : public Module
27 Implementation eventlist[] = { I_OnUserPreMessage, I_OnUserPreNotice };
28 ServerInstance->Modules->Attach(eventlist, this, 2);
32 virtual ModResult OnUserPreMessage(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
34 if ((target_type == TYPE_USER) && (IS_LOCAL(user)))
36 User* u = (User*)dest;
38 // message allowed if:
39 // (1) the sender is opered
40 // (2) the recipient is opered
41 // anything else, blocked.
42 if (IS_OPER(u) || IS_OPER(user))
44 return MOD_RES_PASSTHRU;
46 user->WriteNumeric(ERR_CANTSENDTOUSER, "%s %s :You are not permitted to send private messages to this user",user->nick.c_str(),u->nick.c_str());
50 // however, we must allow channel messages...
51 return MOD_RES_PASSTHRU;
54 virtual ModResult OnUserPreNotice(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
56 return this->OnUserPreMessage(user,dest,target_type,text,status,exempt_list);
59 virtual ~ModuleRestrictMsg()
63 virtual Version GetVersion()
65 return Version("Forbids users from messaging each other. Users may still message opers and opers may message other opers.",VF_VENDOR);
69 MODULE_INIT(ModuleRestrictMsg)