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 * ---------------------------------------------------
24 /* $ModDesc: Forbids users from messaging each other. Users may still message opers and opers may message other opers. */
27 class ModuleRestrictMsg : public Module
37 virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text)
39 if (target_type == TYPE_USER)
41 userrec* u = (userrec*)dest;
42 if ((strchr(u->modes,'o')) || (strchr(user->modes,'o')))
44 // message allowed if:
45 // (1) the sender is opered
46 // (2) the recipient is opered
47 // (3) both are opered
48 // anything else, blocked.
51 WriteServ(user->fd,"531 %s %s :You are not permitted to send private messages to this user",user->nick,u->nick);
54 // however, we must allow channel messages...
58 virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text)
60 return this->OnUserPreMessage(user,dest,target_type,text);
63 virtual ~ModuleRestrictMsg()
68 virtual Version GetVersion()
70 return Version(1,0,0,1,VF_VENDOR);
75 class ModuleRestrictMsgFactory : public ModuleFactory
78 ModuleRestrictMsgFactory()
82 ~ModuleRestrictMsgFactory()
86 virtual Module * CreateModule()
88 return new ModuleRestrictMsg;
94 extern "C" void * init_module( void )
96 return new ModuleRestrictMsgFactory;