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