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