]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_nickban.cpp
09a981b44048521c20e3c822ccb9a787ec1623e2
[user/henk/code/inspircd.git] / src / modules / m_nickban.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2008 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 "inspircd.h"
15
16 /* $ModDesc: Implements extban +b n: - nick change bans */
17
18 class ModuleNickBan : public Module
19 {
20  private:
21  public:
22         ModuleNickBan(InspIRCd* Me) : Module(Me)
23         {
24                 Implementation eventlist[] = { I_OnUserPreNick, I_On005Numeric };
25                 ServerInstance->Modules->Attach(eventlist, this, 2);
26         }
27         
28         virtual ~ModuleNickBan()
29         {
30         }
31         
32         virtual Version GetVersion()
33         {
34                 return Version(1,2,0,0,VF_VENDOR,API_VERSION);
35         }
36
37         virtual int OnUserPreNick(User *user, const std::string &newnick)
38         {
39                 if (!IS_LOCAL(user))
40                         return 0;
41
42                 for (UCListIter i = user->chans.begin(); i != user->chans.end(); i++)
43                 {
44                         if (i->first->IsExtBanned(user, 'n'))
45                         {
46                                 user->WriteServ("NOTICE "+std::string(user->nick)+" :*** Cannot change nick on " + i->first->name + ", as you match a nickname-change ban");
47                                 return 1;
48                         }
49                 }
50
51                 return 0;
52         }
53
54         virtual void On005Numeric(std::string &output)
55         {
56                 if (output.find(" EXTBAN=:") == std::string::npos)
57                         output.append(" EXTBAN=:n");
58                 else
59                         output.insert(output.find(" EXTBAN=:") + 9, "n");
60         }
61 };
62
63
64 MODULE_INIT(ModuleNickBan)
65