]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_restrictmsg.cpp
b5f10eb244976a5d38cec4908266e247189cf890
[user/henk/code/inspircd.git] / src / modules / m_restrictmsg.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2007 InspIRCd Development Team
6  * See: http://www.inspircd.org/wiki/index.php/Credits
7  *
8  * This program is free but copyrighted software; see
9  *            the file COPYING for details.
10  *
11  * ---------------------------------------------------
12  */
13
14 #include "inspircd.h"
15
16 /* $ModDesc: Forbids users from messaging each other. Users may still message opers and opers may message other opers. */
17
18
19 class ModuleRestrictMsg : public Module
20 {
21         
22  public:
23  
24         ModuleRestrictMsg(InspIRCd* Me)
25                 : Module(Me)
26         {
27                 
28         }
29
30         void Implements(char* List)
31         {
32                 List[I_OnUserPreMessage] = List[I_OnUserPreNotice] = 1;
33         }
34
35         virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
36         {
37                 if ((target_type == TYPE_USER) && (IS_LOCAL(user)))
38                 {
39                         userrec* u = (userrec*)dest;
40
41                         // message allowed if:
42                         // (1) the sender is opered
43                         // (2) the recipient is opered
44                         // anything else, blocked.
45                         if (IS_OPER(u) || IS_OPER(user))
46                         {
47                                 return 0;
48                         }
49                         user->WriteServ("531 %s %s :You are not permitted to send private messages to this user",user->nick,u->nick);
50                         return 1;
51                 }
52
53                 // however, we must allow channel messages...
54                 return 0;
55         }
56
57         virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
58         {
59                 return this->OnUserPreMessage(user,dest,target_type,text,status,exempt_list);
60         }
61
62         virtual ~ModuleRestrictMsg()
63         {
64         }
65         
66         virtual Version GetVersion()
67         {
68                 return Version(1,1,0,1,VF_VENDOR,API_VERSION);
69         }
70 };
71
72 MODULE_INIT(ModuleRestrictMsg)