1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2009 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
24 ModuleRestrictMsg(InspIRCd* Me)
28 Implementation eventlist[] = { I_OnUserPreMessage, I_OnUserPreNotice };
29 ServerInstance->Modules->Attach(eventlist, this, 2);
33 virtual ModResult OnUserPreMessage(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
35 if ((target_type == TYPE_USER) && (IS_LOCAL(user)))
37 User* u = (User*)dest;
39 // message allowed if:
40 // (1) the sender is opered
41 // (2) the recipient is opered
42 // anything else, blocked.
43 if (IS_OPER(u) || IS_OPER(user))
45 return MOD_RES_PASSTHRU;
47 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());
51 // however, we must allow channel messages...
52 return MOD_RES_PASSTHRU;
55 virtual ModResult OnUserPreNotice(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
57 return this->OnUserPreMessage(user,dest,target_type,text,status,exempt_list);
60 virtual ~ModuleRestrictMsg()
64 virtual Version GetVersion()
66 return Version("$Id$",VF_VENDOR,API_VERSION);
70 MODULE_INIT(ModuleRestrictMsg)