]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_halfop.cpp
Remove VF_COMMON from mode-provider modules (no longer needed due to better CAPAB...
[user/henk/code/inspircd.git] / src / modules / m_halfop.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
16 class ModeChannelHalfOp : public ModeHandler
17 {
18  public:
19         ModeChannelHalfOp(Module* parent);
20         ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding);
21         unsigned int GetPrefixRank();
22         void RemoveMode(Channel* channel, irc::modestacker* stack = NULL);
23         void RemoveMode(User* user, irc::modestacker* stack = NULL);
24 };
25
26 ModeChannelHalfOp::ModeChannelHalfOp(Module* parent) : ModeHandler(parent, "halfop", 'h', PARAM_ALWAYS, MODETYPE_CHANNEL)
27 {
28         list = true;
29         prefix = '%';
30         levelrequired = OP_VALUE;
31         m_paramtype = TR_NICK;
32 }
33
34 unsigned int ModeChannelHalfOp::GetPrefixRank()
35 {
36         return HALFOP_VALUE;
37 }
38
39 void ModeChannelHalfOp::RemoveMode(Channel* channel, irc::modestacker* stack)
40 {
41         const UserMembList* clist = channel->GetUsers();
42
43         for (UserMembCIter i = clist->begin(); i != clist->end(); i++)
44         {
45                 if (stack)
46                 {
47                         stack->Push(this->GetModeChar(), i->first->nick);
48                 }
49                 else
50                 {
51                         std::vector<std::string> parameters;
52                         parameters.push_back(channel->name);
53                         parameters.push_back("-h");
54                         parameters.push_back(i->first->nick);
55                         ServerInstance->SendMode(parameters, ServerInstance->FakeClient);
56                 }
57         }
58
59 }
60
61 void ModeChannelHalfOp::RemoveMode(User*, irc::modestacker* stack)
62 {
63 }
64
65 ModeAction ModeChannelHalfOp::OnModeChange(User* source, User*, Channel* channel, std::string &parameter, bool adding)
66 {
67         return MODEACTION_ALLOW;
68 }
69
70 class ModuleHalfop : public Module
71 {
72         ModeChannelHalfOp mh;
73  public:
74         ModuleHalfop() : mh(this)
75         {
76                 if (!ServerInstance->Modes->AddMode(&mh))
77                         throw ModuleException("Could not add new modes!");
78         }
79
80         ~ModuleHalfop()
81         {
82                 ServerInstance->Modes->DelMode(&mh);
83         }
84
85         Version GetVersion()
86         {
87                 return Version("Channel half-operator mode provider", VF_VENDOR);
88         }
89 };
90
91 MODULE_INIT(ModuleHalfop)