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