]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_channelban.cpp
Send SVSNICKs during nick collision to prevent servers that do not fully implement...
[user/henk/code/inspircd.git] / src / modules / m_channelban.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2009 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 j: - matching channel bans */
17
18 class ModuleBadChannelExtban : public Module
19 {
20  private:
21  public:
22         ModuleBadChannelExtban(InspIRCd* Me) : Module(Me)
23         {
24                 Implementation eventlist[] = { I_OnUserPreJoin, I_On005Numeric };
25                 ServerInstance->Modules->Attach(eventlist, this, 2);
26         }
27
28         virtual ~ModuleBadChannelExtban()
29         {
30         }
31
32         virtual Version GetVersion()
33         {
34                 return Version("$Id$", VF_COMMON|VF_VENDOR,API_VERSION);
35         }
36
37         virtual int OnUserPreJoin(User *user, Channel *c, const char *cname, std::string &privs, const std::string &key)
38         {
39                 if (!IS_LOCAL(user))
40                         return 0;
41
42                 if (!c)
43                         return 0;
44
45
46                 for (UCListIter i = user->chans.begin(); i != user->chans.end(); i++)
47                 {
48                         if (c->IsExtBanned(i->first->name, 'j'))
49                         {
50                                 user->WriteNumeric(ERR_BANNEDFROMCHAN, "%s %s :Cannot join channel (You're banned)", user->nick.c_str(),  c->name.c_str());
51                                 return 1;
52                         }
53                 }
54
55                 return 0;
56         }
57
58         virtual void On005Numeric(std::string &output)
59         {
60                 ServerInstance->AddExtBanChar('j');
61         }
62 };
63
64
65 MODULE_INIT(ModuleBadChannelExtban)
66