]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_securelist.cpp
c1c79f8dab98ece001f0e23a7775def3c4d4278e
[user/henk/code/inspircd.git] / src / modules / m_securelist.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
6  *                     E-mail:
7  *              <brain@chatspike.net>
8  *                <Craig@chatspike.net>
9  *     
10  * Written by Craig Edwards, Craig McLure, and others.
11  * This program is free but copyrighted software; see
12  *          the file COPYING for details.
13  *
14  * ---------------------------------------------------
15  */
16
17 using namespace std;
18  
19 #include "users.h"
20 #include "channels.h"
21 #include "modules.h"
22 #include "helperfuncs.h"
23 #include "message.h"
24 #include <vector>
25  
26 extern time_t TIME;
27
28 /* $ModDesc: A module overriding /list, and making it safe - stop those sendq problems. */
29  
30 class ModuleSecureList : public Module
31 {
32  private:
33          Server *Srv;
34  public:
35         ModuleSecureList(Server* Me) : Module::Module(Me)
36         {
37                 Srv = Me;
38         }
39  
40         virtual ~ModuleSecureList()
41         {
42         }
43  
44         virtual Version GetVersion()
45         {
46                 return Version(1,0,0,0,VF_VENDOR);
47         }
48  
49         void Implements(char* List)
50         {
51                 List[I_OnPreCommand] = List[I_On005Numeric] = 1;
52         }
53
54         /*
55          * OnPreCommand()
56          *   Intercept the LIST command.
57          */ 
58         virtual int OnPreCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, bool validated)
59         {
60                 /* If the command doesnt appear to be valid, we dont want to mess with it. */
61                 if (!validated)
62                         return 0;
63  
64                 if ((command == "LIST") && (TIME < (user->signon+60)) && (!*user->oper))
65                 {
66                         user->WriteServ("NOTICE %s :*** You cannot list within the first minute of connecting. Please try again later.",user->nick);
67                         /* Some crap clients (read: mIRC, various java chat applets) muck up if they don't
68                          * receive these numerics whenever they send LIST, so give them an empty LIST to mull over.
69                          */
70                         user->WriteServ("321 %s Channel :Users Name",user->nick);
71                         user->WriteServ("323 %s :End of channel list.",user->nick);
72                         return 1;
73                 }
74                 return 0;
75         }
76
77         virtual void On005Numeric(std::string &output)
78         {
79                 output.append(" SECURELIST");
80         }
81
82         virtual Priority Prioritize()
83         {
84                 return (Priority)Srv->PriorityBefore("m_safelist.so");
85         }
86
87 };
88  
89  
90  
91 /******************************************************************************************************/
92  
93 class ModuleSecureListFactory : public ModuleFactory
94 {
95  public:
96         ModuleSecureListFactory()
97         {
98         }
99  
100         ~ModuleSecureListFactory()
101         {
102         }
103  
104         virtual Module * CreateModule(Server* Me)
105         {
106                 return new ModuleSecureList(Me);
107         }
108  
109 };
110  
111 extern "C" void * init_module( void )
112 {
113         return new ModuleSecureListFactory;
114 }