]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_securelist.cpp
Removed a pointless check in ./configure --clean that made it only work with one...
[user/henk/code/inspircd.git] / src / modules / m_securelist.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 "users.h"
15 #include "channels.h"
16 #include "modules.h"
17
18 #include <vector>
19 #include "inspircd.h"
20
21 /* $ModDesc: A module overriding /list, and making it safe - stop those sendq problems. */
22
23 class ModuleSecureList : public Module
24 {
25  private:
26          
27  public:
28         ModuleSecureList(InspIRCd* Me) : Module::Module(Me)
29         {
30                 
31         }
32  
33         virtual ~ModuleSecureList()
34         {
35         }
36  
37         virtual Version GetVersion()
38         {
39                 return Version(1,1,0,0,VF_VENDOR,API_VERSION);
40         }
41  
42         void Implements(char* List)
43         {
44                 List[I_OnPreCommand] = List[I_On005Numeric] = 1;
45         }
46
47         /*
48          * OnPreCommand()
49          *   Intercept the LIST command.
50          */ 
51         virtual int OnPreCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, bool validated, const std::string &original_line)
52         {
53                 /* If the command doesnt appear to be valid, we dont want to mess with it. */
54                 if (!validated)
55                         return 0;
56  
57                 if ((command == "LIST") && (ServerInstance->Time() < (user->signon+60)) && (!*user->oper))
58                 {
59                         user->WriteServ("NOTICE %s :*** You cannot list within the first minute of connecting. Please try again later.",user->nick);
60                         /* Some crap clients (read: mIRC, various java chat applets) muck up if they don't
61                          * receive these numerics whenever they send LIST, so give them an empty LIST to mull over.
62                          */
63                         user->WriteServ("321 %s Channel :Users Name",user->nick);
64                         user->WriteServ("323 %s :End of channel list.",user->nick);
65                         return 1;
66                 }
67                 return 0;
68         }
69
70         virtual void On005Numeric(std::string &output)
71         {
72                 output.append(" SECURELIST");
73         }
74
75         virtual Priority Prioritize()
76         {
77                 return (Priority)ServerInstance->PriorityBefore("m_safelist.so");
78         }
79
80 };
81  
82  
83  
84 /******************************************************************************************************/
85  
86 class ModuleSecureListFactory : public ModuleFactory
87 {
88  public:
89         ModuleSecureListFactory()
90         {
91         }
92  
93         ~ModuleSecureListFactory()
94         {
95         }
96  
97         virtual Module * CreateModule(InspIRCd* Me)
98         {
99                 return new ModuleSecureList(Me);
100         }
101  
102 };
103  
104 extern "C" void * init_module( void )
105 {
106         return new ModuleSecureListFactory;
107 }