]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_autoop.cpp
a66e2bd4de24ce9ab64c6b50be233f91635f492f
[user/henk/code/inspircd.git] / src / modules / m_autoop.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2010 InspIRCd Development Team
6  * See: http://wiki.inspircd.org/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 #include "u_listmode.h"
16
17 /* $ModDesc: Provides support for the +w channel mode, autoop list */
18
19 /** Handles +w channel mode
20  */
21 class AutoOpList : public ListModeBase
22 {
23  public:
24         AutoOpList(Module* Creator) : ListModeBase(Creator, "autoop", 'w', "End of Channel Access List", 910, 911, true)
25         {
26                 levelrequired = OP_VALUE;
27         }
28         // TODO need own numerics
29         // TODO add some serious access control for setting this mode (you can currently gain +qa with it)
30 };
31
32
33 class ModuleAutoOp : public Module
34 {
35         AutoOpList mh;
36
37 public:
38         ModuleAutoOp() : mh(this)
39         {
40                 ServerInstance->Modules->AddService(mh);
41                 mh.DoImplements(this);
42
43                 Implementation list[] = { I_OnUserPreJoin, };
44                 ServerInstance->Modules->Attach(list, this, 1);
45         }
46
47         ModResult OnUserPreJoin(User *user, Channel *chan, const char *cname, std::string &privs, const std::string &keygiven)
48         {
49                 if (!chan)
50                         return MOD_RES_PASSTHRU;
51
52                 modelist* list = mh.extItem.get(chan);
53                 if (list)
54                 {
55                         for (modelist::iterator it = list->begin(); it != list->end(); it++)
56                         {
57                                 std::string::size_type colon = it->mask.find(':');
58                                 if (colon == std::string::npos)
59                                         continue;
60                                 if (chan->CheckBan(user, it->mask.substr(colon+1)))
61                                 {
62                                         privs = it->mask.substr(0, colon);
63                                         break;
64                                 }
65                         }
66                 }
67
68                 return MOD_RES_PASSTHRU;
69         }
70
71         void OnCleanup(int target_type, void* item)
72         {
73                 mh.DoCleanup(target_type, item);
74         }
75
76         void OnSyncChannel(Channel* chan, Module* proto, void* opaque)
77         {
78                 mh.DoSyncChannel(chan, proto, opaque);
79         }
80
81         void OnRehash(User* user)
82         {
83                 mh.DoRehash();
84         }
85
86         Version GetVersion()
87         {
88                 return Version("Provides support for the +w channel mode", VF_VENDOR);
89         }
90 };
91
92 MODULE_INIT(ModuleAutoOp)